Quote:
Originally Posted by cilginbilgin
We tried to figure out how to restrict window motors and we created a while loop in the timed.vi because using while loop in the teleop.vi is not recommended. Are we supposed to put the while loop in the timed vi or in which vi should we use the while loop??? Thanks in advance!!!
|
I'm not a LabVIEW guru and I don't have LabVIEW installed here so I'm not equipped to give you LabVIEW-specific examples, but I think you want to put the equivalent of this into the periodic tasks vi:
Code:
while (1) {
if (!run_me) {sleep(20ms); continue;}
run_me= false;
doSomething;
sleep(3000ms);
doSomethingElse;
}
"run_me" is a boolean global variable. Whenever your TeleOp code sets it to "true", the code in red runs once.
The "doSomething" would be to turn your motor on. The "sleep(3000ms)" would be how long you want to leave the motor running. The "doSomethingElse" would be to turn the motor off.
The "sleep(20ms)" is there to limit how fast the code polls "run_me" while waiting for it to become true. Without the sleep, this loop would always want a slice of CPU time. That would waste resources. Make the 20ms as long as tolerable and only as short as necessary.
Perhaps a knowledgeable LabVIEW person could post a code snippet.