View Single Post
  #3   Spotlight this post!  
Unread 15-02-2015, 22:35
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,574
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Programming Limit Switches

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 you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote