Quote:
Originally Posted by GeeTwo
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);
}
}
|
If I am using a simple motor for my elevator system, would I need the && statements for speed?
If I wanted the elevator to go in the opposite direction for about 1 second based on which switch is pressed, what would that look like?
And what is 'super(PWM)' represent?