Timing Motor Functions in Teleop


I’m new to Labview as my team recently switched over from Java. I was wondering how to time a motor turning function so that when I press a button on the joystick, the motor turns for 5 seconds then stops. I have everything but the timing part. Any help would be appreciated.


Two common methods:

  1. In Teleop, set a time and keep checking to see if it’s expired. (is it done yet?..Is it done yet?..)

  2. In Periodic Tasks, just set a timer.

Some other examples are found here.

First of all, Teleop is not the place to put this. Teleop is called around every 20 ms, if I recall correctly, so anything slower than that will “freeze” up teleop and make your controls unresponsive. So, instead you should place timed sequences like this in Periodic Tasks. As to how you would actually make the motor run for 5 seconds, there are a couple ways. You could do something like this, or just make a while loop with a 5000 ms delay in it that only runs once, and then put that inside a case structure to control it.

Thank you so much for your response.

As I said, I am new to Labview and programming it for FRC. When you said keep checking if a time expires, what do you mean by that?

I’m sorry if this question seems really dumb, but I would appreciate any answer you could give me. Thank you so much!

Thank you the second method solved my problem.

One last question…

what is the name of the green arrow function block and what does it do?


It’s a way of making something only trigger once on a button press. There should be some explanation of it on this page, which is where the example was taken from.

That arrow thingy is called a feedback node and is found on the Programming -> Structures palette.
Basically it remembers what the previous value of the data line was.


For the sake of other rookies who may be reading, it’s perfectly fine to put this in TeleOp if you use a “state machine” approach like Mark showed.

When the button is first pressed, read the system clock and set a “target value” equal to the system clock plus 5 seconds (5000ms).

On every subsequent execution of TeleOp, check to see if the system clock has reached (or passed) that target value. If it has not, just finish the rest of your TeleOp and get out before your allotted 20ms; otherwise execute whatever code you wanted to run, and wait for the next button press to start the process again.