View Single Post
  #5   Spotlight this post!  
Unread 12-02-2012, 15:02
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Restricting Window Motors Number of Turn

Quote:
Originally Posted by cilginbilgin View Post
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.


Last edited by Ether : 12-02-2012 at 15:07.
Reply With Quote