|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: waits
In your situation, a wait will do.
A wait node in LV works as follows: Once its inputs are available, it notes the time, adds the delay to it, and sets an alarm for delay milliseconds in the future. The node will not be considered complete (it is executing, but without using the CPU), until that alarm goes off. Any dependent code is postponed, and parallel code is not. Now the reason that it impacts loops and sequences the way it does is because of the most commonly overlooked element of LV -- the diagram. The open space on the window, the white background of the loop and sequence is the same as the {} bracketed code within other languages. The while loop's diagram is not complete until all nodes on it are complete. Same for sequence and other structure nodes that contain a diagram. Executing a diagram consists of executing all nodes it contains once and only once, and it is not complete and cannot execute again until all the nodes complete execution. For example, I attached an image of a loop with various parallel things going on inside it. They are the i (which some may not count and may even be compiled out), the Bool wired to the loop continuation (similarly trivial), and the three waits (two for 1000ms and one for 500ms). When the loop starts to execute its diagram, it will allow all of the parallel tasks to proceed at their own rate. So in this case, the three waits will run in parallel and the overall loop rate will be about 1Hz. If additional code is inserted into the loop that reads sensors or computes math, and it runs in parallel, it will not impact the loop rate unless the code takes longer than 1000ms to complete. The second image shows how to run code before and after a delay, make sure there is an execution dependency -- either a data flow dependency or as shown in the image, a sequence dependency. The third image shows another common usage where you want to start something, not waiting for it to complete, and 500 ms after starting it, start something else. I hope this helped. Greg McKaskle |
|
#2
|
||||
|
||||
|
Re: waits
Quote:
In other words, "after something is done, or 500ms elapses" means "after something is done, or 500ms elapses - whichever is longer", correct? |
|
#3
|
|||||
|
|||||
|
Re: waits
Quote:
|
|
#4
|
|||
|
|||
|
Re: waits
Sorry for the confusion. That is what I get for taking so long to write a post and then rushing out at the last minute and not reviewing it carefully.
I agree with your wording Ether. The point of all this is that statements running in parallel on a diagram determine when the diagram completes, and the completion of that diagram determines when dependent code, such as the next frame of a sequence, or the next iteration of a loop can begin. Greg McKaskle |
|
#5
|
|||
|
|||
|
Re: waits
After reading my post again, I want to correct it.
The final image was meant convey the case where the start times are what you want to use for the time reference. I hope this is one is clearer. Greg McKaskle |
|
#6
|
||||
|
||||
|
Re: waits
so will this run the motors for 1 second, or will it pulse the motors once, and then wait 1 second before moving on
|
|
#7
|
|||||
|
|||||
|
Re: waits
That will start the motors, while the Wait twiddles it's virtual thumbs letting them run for one second, before leaving the frame.
Of course, the way it's written, nothing stops the motors, so after the frame finishes executing the motors will still be running and will continue to run until told otherwise. Last edited by Mark McLeod : 05-02-2012 at 18:41. |
|
#8
|
||||
|
||||
|
Re: waits
ok think i got it now. thanks
|
|
#9
|
|||||
|
|||||
|
Re: waits
Quote:
It's a Drive function, so the motor safety will stop the motors after a tenth of a second unless something has been changed from the default configuration. |
|
#10
|
|||||
|
|||||
|
Re: waits
True enough.
What Alan means is, your structure would work the way you intend for individual motors, but drive motors (Open2Motor, Open4Motor) have an automatically applied Safety that will shut down the motors if you don't keep rapidly telling them what to do. To make your structure work the way you intend it would need an extra vi call. And at the end you would re-enable the Safety, before Teleop began, as well as set your motors to neutral. |
|
#11
|
||||
|
||||
|
Re: waits
ok, so this way i don't have to use for loops every time i try to drive in autonomous
|
|
#12
|
||||
|
||||
|
Re: waits
one more question: is there a way to get the time from the driver station? The wait time is not at all accurate, and it would be easier than using encoders
|
|
#13
|
|||||
|
|||||
|
Re: waits
In my experience, the wait time is very accurate. How are you finding it not to be? What time are you looking for, and what do you intend to do with it?
|
|
#14
|
|||
|
|||
|
Re: waits
You can send the data from the DS, but that will require a bit of networking.
The Match Info that is an input parameter to the teleop should be pretty accurate, and show should elapsed times. How are you testing to determine they are "not at all accurate", and how much error is that? Greg McKaskle |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|