Go to Post Thank you to all of the mentors, You ARE changing the future. - chellyzee93 [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:49.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi