View Single Post
  #3   Spotlight this post!  
Unread 01-02-2011, 13:15
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: How do you use timer properly?

Quote:
Originally Posted by 3p1c w1n View Post
Should this code work?
I don't think it will work. It seems like it's properly written to do what you want, but what you want is not compatible with the robot communication framework. Any delays like that in your Teleop code will prevent everything else from running and cause the safety watchpuppies to shut down all the robot outputs.

What you should do is learn how to implement a state machine. Your needs call for a case block with three cases: Idle, Lowering, and Raising. You will need to use shift registers or feedback nodes to hold the current state and remember an event time. In the Idle state, keep the motor off and use the button to change the state to Lowering. In the Lowering state, run the motor down and use a simple comparison to detect when X time has elapsed and change the state to Raising. In the Raising state, run the motor up and use a simple comparison to detect when X time has elapsed and change the state back to Idle.

Does this sound like something you can work with? If not, we can probably point you to a solid tutorial on state machines in LabVIEW. I'd rather not just give you working code until you've tried to understand the concepts on your own.
Reply With Quote