View Single Post
  #2   Spotlight this post!  
Unread 05-02-2013, 20:16
bvisness's Avatar
bvisness bvisness is offline
Programming Mentor, Former Driver
FRC #2175 (The Fighting Calculators)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2010
Location: Woodbury, MN
Posts: 181
bvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of lightbvisness is a glorious beacon of light
Re: How to program a limit switch?

I've attached screenshots of how our team used limit switches to limit movement in 2011. The first screenshot shows how we initialized our limit switches, and the second shows how we implemented them in our Teleop code.

The VI with the arrow and question mark in the second screenshot is In Range And Coerce, which is a VI many people don't know about - primarily the Coerce part. It takes whatever number you input (in this case, our motor signal) and forces it inside a specified range if it falls outside the limits.

In our code, if the upper limit switch is pressed, it sets the upper end of the range to 0 so we can't move up any farther. (So our range is -1 to 0.) Likewise, if the lower switch is pressed, we set the lower end to 0 (range: 0 to 1).
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	78
Size:	5.2 KB
ID:	13821  Click image for larger version

Name:	Capture1.PNG
Views:	94
Size:	5.8 KB
ID:	13822  
Reply With Quote