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.
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.
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.