|
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.
|