Thread: Limit Switch
View Single Post
  #4   Spotlight this post!  
Unread 20-02-2010, 21:03
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: Limit Switch

Programming for a limit switch is straightforward. You just need to read the value of the switch and test for "active". Sometimes a limit switch will return a True when it's inactive, and False when it's active; sometimes it will be the other way around. You also need to know whether the motor would be moving "forward" or "reverse" when it hits the switch.

When you see that the switch is active and the motor is being asked to travel in the direction you don't want it to go anymore, set the motor value to zero. That's it. If the switch is not active, don't do anything special; that will let the motor move normally. If the motor isn't being told to go in the direction you don't want it to go, don't do anything special; that will let the motor go back away from the limit.