Limit Switch Programming Help

Hi Guys,

We are building a catapult mechanism to shoot the ball and to set the position of the catapult to ready to shoot, we are using a limit switch. I want the program to run 2 motors until the limit switch is on while i’m pressing a button on joystick, so the catapult will stop itself when it’s stretched enough.

I wrote this in teleop, but it didn’t work. Where am i wrong? I wrote their begin and finish parts as well.

http://i.imgur.com/nfc8rsj.jpg

Are you by any chance using Jaguars? You could always wire your limit switch directly to the inputs on the Jaguar itself and let it do all the work.

On the other hand, how is your limit switch wired? Remember that the Digital Sidecar inputs are always pulled high until you pull them low. Wire your limit switch with the signal wire going to COM and the negative wire to the NO terminal.

With this wiring, you will also need to switch your comparison values (switch the 0 and 1) so that when the switch is pressed (goes false) it will stop your motors

You say it didn’t work. What did it do instead of what you wanted?

Are you sure your limit switch is giving you True and False values in the direction you expect? Use the Test mode and view the switch’s value on the Dashboard to see what it really does.

I don’t use Jaguars as motor controllers. I wired the white wire to the NC and black wire to the COM and wired the other side of the PWM cable directly to the one of the DIO s on the Digital Side Car, but i have still problems with that.

When I press the button, motors move for a moment and then stops. The movement isn’t continous as I press the button. How can I use the test mode to test this? Do I need to edit the Test VI ?

Where have you put this code (Teleop, Periodic Tasks)?

What does your Begin look like for creating the motor?

The code you posted looks okay. Is there somewhere else in the program that might be continually turning off your winch motors, like in Periodic Tasks? Is the case input connected directly to a joystick button, or is there some other processing before it reaches the case?

Is your motor wiring correct, with both motors turning in a direction that doesn’t make them fight each other? Install only one winch motor circuit breaker and try running it, then remove that breaker and install one on the other winch motor. Do the motors run as expected one at a time?

This sentence solved my problem.

Not in Periodic Tasks, but in Teleop I was controlling those motors with one more button as well. I solved this by combining two case. So now, when i m not pressing that button, the motors aren’t set themselves to 0 value.

Thanks for your help.