![]() |
Timing functions
We want a motor to spin for two seconds after a button is pressed AND keep spinning (until time is up) even if the joystick button is not being pressed.
Can we use a timing function in the true case to keep the case true (therefor the motor keeps running) even if the button is NOT being pressed? or do we need to take a different approach? |
Re: Timing functions
Once you set a motor to start running it will continue to run until you tell it to turn off.
So, what you can do is use your case True to Set the motor on and set a time to be fed back into the loop using a shift register or feedback node. Then in the False case check to see if the time has expired before stopping the motor. |
Re: Timing functions
2 Attachment(s)
Mark- Did I do this right?
|
Re: Timing functions
1 Attachment(s)
Well in not really.
Just look at the attached code. Use the SubVI where ever you need to latch and hold a boolean state for a set amount of time. Note: the Hold and Release subVI triggers on a rising edge. So even if you continue to hold the button on the joystick it will set it's output to FALSE (off) after to set time has passed. Omar |
Re: Timing functions
Quote:
Let me ask you another question. We just created a state machine for another mechanism after watching the LVMastery video. Would it be easier and/or more efficient to make a state machine? Ben Zimmer stated that timed waits can slow down your code. |
Re: Timing functions
This can be used with a state machine (or not).
A lot depends on what else is going on in the state or what other parallel loops you have going on. You could have multiple state machines running in parallel. But you could use the output of the Hold and Release to decide when it is time to change states. Note: This VI is Reentrant so that it can be use to control one than one motor, There for each place you use it, they are independent of each other and will not know what time has been set in the other placements. Meaning you have to return to the same clone to detect the timeout. So if you want to set it one state but check it another state you will need to make a copy of it and rename to dedicate to that motor or function and make it non-re-entrant. Then you will be able to set the hold time in one location, but be able to check the timeout in another location. Omar |
Re: Timing functions
Quote:
You do not want to place a wait inside your telop loop because it will slow down you loop by the amount of the wait. The code in your telop loop needs to get what it has to do fast and loop back around or your robot will not respond to joystick commands or other inputs. If you have a wait for 2sec while your motor spins then for that 2 sec your joysticks will seem to be DEAD! Ben Zimmer addresses this with his example of a stop time. |
| All times are GMT -5. The time now is 11:07. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi