FIRST Robotics Competition Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Would like information on using delay timer

I am looking for information on how to use delay's within labview.  I am looking to take a pushbutton from the joystick and essentially start a delay timer (0.5 sec) and provide the pushbutton output after the delay to a solenoid.

I have looked through labview help and it is not apparent how to create a timer.  I suppose I could use the user watchdog, but I think there is a simpler way using a timer and perhaps a latch or one-shot.

0 Kudos
Message 1 of 5
(3,790 Views)

The obvious, but not right, solution is to use the "wait" function in LabVIEW.  This isn't the right solution because everything inside a LabVIEW loop must complete before the loop can proceed to the next iteration.  If you put the wait inside the same loop as you feed the watchdog, the watchdog will get fed once, and then not be fed again until the wait completes and the loop proceeds.

The correct way to do this is store a timer value in a shift register.  One implementation: when you first push the button, add your wait time (say, 500ms) to the current millisecond timer value and store that in a shift register.  Each time through the loop, see if the current time has reached the value stored in the shift register; if so, your timer expired.  Be careful not to use = as the comparison, since it's unlikely that your loop will execute an exact number of milliseconds later.

Someone asked a similar question last year and I posted an example then.  You can find it if you dig back through the discussions, but it's a good exercise to try writing your own.

0 Kudos
Message 2 of 5
(2,686 Views)

See the example I posted on ChiefDelphi

http://www.chiefdelphi.com/forums/showthread.php?t=82255

Omar

Omar
0 Kudos
Message 3 of 5
(2,686 Views)

I suppose if there's already a link to one example, might as well add mine too:

http://decibel.ni.com/content/message/4712#4712

Just to show an alternate way to achieve a similar result.

0 Kudos
Message 4 of 5
(2,686 Views)

Thanks for the information on this.  I appreciate it.

I may end up using a variation on the same theme.

0 Kudos
Message 5 of 5
(2,686 Views)