Unless you are making a one-shot device, you need to be a bit more subtle. For argument sake, and since it's the more common case for limit switches this year, I'll assume your actuator is moving up and down. I'll also assume that motion in the positive direction is up, and the negative direction is down.
If the
top limit switch is set, you want to limit your applied force so that it can only be zero or negative; you may want to "come down" later.
If the
bottom limit switch is set, you want to limit your applied force so that it can only be zero or positive; you may want to "go up" later.
Just doing the full initializer and the set() methods, it would look something like:
Code:
Class MyWinchController extends Talon {
DigitalInput topLimitSwitch;
DigitalInput bottomLimitSwitch;
MyWinchController(int PWM, int topLimitDIO, int bottomLimitDIO) {
super(PWM);
topLimitSwitch = new DigitalInput (topLimitDIO);
bottomLimitSwitch = new DigitalInput (bottomLimitDIO);
}
set(double speed) {
if (topLimitSwitch.get() && (speed>0.0)) speed = 0.0;
if (bottomLimitSwitch.get() && (speed<0.0)) speed = 0.0;
super.set(speed);
}
}