View Single Post
  #2   Spotlight this post!  
Unread 05-02-2009, 23:48
airnate airnate is offline
Registered User
FRC #0236 (Techno Ticks)
Team Role: Programmer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: southeastern CT
Posts: 93
airnate is a jewel in the roughairnate is a jewel in the roughairnate is a jewel in the rough
Re: limit switch help

You could do something like the attached code picture. If you wire your limit switch to a GPIO (aka DIO) input on the Digital Sidecar so that when the limit switch closes it sends 5V to the DIO, then the code will detect it as True when the motor reaches its limit.

So in the included code the motor is first sent Set Speed of 1 to get it moving. The while loop waits for the motor to reach the limit. When the limit switch returns True, the Set Speed is called again with a 0 to stop the motor.

If you make this code into a subVI I would recommend that you call the Open and CLose outside of the main loop of your program and pass in the device references (i.e. MotorControlDevRef, DigitalInputDevRef) into the subVI and back out again.
Attached Thumbnails
Click image for larger version

Name:	limit_switch.png
Views:	162
Size:	12.8 KB
ID:	7333  
Reply With Quote