Thread: Switch help
View Single Post
  #5   Spotlight this post!  
Unread 20-01-2014, 23:16
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,113
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: Switch help

Quote:
Originally Posted by nelson.ke@ View Post
...we would like the first option with the switch stopping the motor and then you have to release the trigger and press the trigger again to start the cycle.
That's going to involve something a little more complicated than simple combinatorial logic. I suggest implementing it as a flat sequence in Periodic Tasks.

In the first frame, halt the motor and wait for the trigger to be released. In the second frame, halt the motor and wait for the trigger to be pressed. In the third, set the motor to whatever value you want it to run at and wait for the limit switch to be activated. Put the entire sequence in a neverending while loop so it starts over every time it finishes.

The "wait for" parts can be programmed as while loops that terminate when the condition is seen. Make sure to put a delay inside each of those loops so they don't monopolize the cRIO's CPU.

If this isn't enough to start with, let me know and I'll give you some example code to look at.
Reply With Quote