|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
Timing Motor Functions in Teleop
Hi,
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. Thanks! |
|
#2
|
|||||
|
|||||
|
Re: Timing Motor Functions in Teleop
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. Last edited by Mark McLeod : 26-01-2014 at 12:04. |
|
#3
|
||||
|
||||
|
Re: Timing Motor Functions in Teleop
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! |
|
#4
|
||||
|
||||
|
Re: Timing Motor Functions in Teleop
Quote:
Quote:
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. |
|
#5
|
|||
|
|||
|
Re: Timing Motor Functions in Teleop
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.
|
|
#6
|
||||
|
||||
|
Re: Timing Motor Functions in Teleop
Quote:
|
|
#7
|
||||
|
||||
|
Re: Timing Motor Functions in Teleop
One last question...
what is the name of the green arrow function block and what does it do? Thanks. |
|
#8
|
|||
|
|||
|
Re: Timing Motor Functions in Teleop
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.
|
|
#9
|
|||||
|
|||||
|
Re: Timing Motor Functions in Teleop
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. |
|
#10
|
||||
|
||||
|
Re: Timing Motor Functions in Teleop
Thanks.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|