Go to Post It would also level the playing field by bringing the bottom up, rather than the top down. - russell [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-02-2013, 21:29
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
How do you program limit switches?

Right now I have a limit switch plugged into one of the ports on the Digital IO. Now what methods/classes do use to tell whether the limit switch is pressed or not. There doesn't seem to be a "limit switch" and I'm not sure what to use.

Anyone else know?
Reply With Quote
  #2   Spotlight this post!  
Unread 18-02-2013, 21:36
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: How do you program limit switches?

Im working on the same thing for my team for tomorrow. What are you trying to control with the switch?
Reply With Quote
  #3   Spotlight this post!  
Unread 18-02-2013, 21:38
shank948 shank948 is offline
VP of Programming - 948
AKA: Stephen Shank
FRC #0948 (NRG (Newport Robotics Group))
Team Role: Alumni
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Bellevue, Wa
Posts: 21
shank948 is an unknown quantity at this point
Re: How do you program limit switches?

Use a DigitalInput. It should be declared as a static variable, like this:

public static DigitalInput limitSwitch;

Initialize it like this:

limitSwitch = new DigitalInput(slot,channel);

To use the limit switch, call the get() method on it, which, assuming you have it wired correctly, will return true if the switch is closed and false if it is open.

Any more questions?
__________________
If it's green and slimy, it's Biology.
If it smells, it's Chemistry.
If it doesn't work, it's Physics.
- My Physics Teacher

Fixed:
If it doesn't work, it's our Robot up until that last few days of the build season.
Reply With Quote
  #4   Spotlight this post!  
Unread 18-02-2013, 21:47
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
Re: How do you program limit switches?

Quote:
Originally Posted by shank948 View Post
Use a DigitalInput. It should be declared as a static variable, like this:

public static DigitalInput limitSwitch;

Initialize it like this:

limitSwitch = new DigitalInput(slot,channel);

To use the limit switch, call the get() method on it, which, assuming you have it wired correctly, will return true if the switch is closed and false if it is open.

Any more questions?
ok, so for the constructor. I pass the slot that it's plugged into on the DigitalIO for the slot, but what do I pass for channel?
Reply With Quote
  #5   Spotlight this post!  
Unread 18-02-2013, 21:48
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
Re: How do you program limit switches?

Quote:
Originally Posted by Zer0 View Post
Im working on the same thing for my team for tomorrow. What are you trying to control with the switch?
A motorized car jack that stops working when it goes too low or too high
Reply With Quote
  #6   Spotlight this post!  
Unread 18-02-2013, 21:55
dheerm's Avatar
dheerm dheerm is offline
Drive Team and Head Programmer
AKA: Dheer Mirchandani
FRC #0224 (The Tribe)
Team Role: Programmer
 
Join Date: Oct 2012
Rookie Year: 2010
Location: Piscataway
Posts: 37
dheerm will become famous soon enough
Re: How do you program limit switches?

DigitalInput name = new DigitalInput(slot)


fill in slot with the slot on the DIO that the switch is plugged into and name with whatever you want to call it.

name.get() will return you the boolean indicating whether the switch is pressed or Unpressed. If it's wired right, true will be pressed and false will be unpressed
__________________
"All you need is duct tape and a dream"

Team 224:
District Champions @TCNJ w/ Team 56 and Team 293

8th alliance captain at MAR championships w/ (take a guess) , Team 56 and Team 293.

www.team224.com
Reply With Quote
  #7   Spotlight this post!  
Unread 18-02-2013, 22:35
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
Re: How do you program limit switches?

Thanks, guys! Limit switch is working
Reply With Quote
  #8   Spotlight this post!  
Unread 18-02-2013, 23:06
Bill_B Bill_B is offline
You cannot not make a difference
FRC #2170
 
Join Date: Jan 2010
Rookie Year: 2004
Location: Connecticut
Posts: 1,099
Bill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond reputeBill_B has a reputation beyond repute
Re: How do you program limit switches?

Quote:
Originally Posted by Negative 9 View Post
A motorized car jack that stops working when it goes too low or too high
Scissor jack? Very suave just to think of it.
__________________
Nature's Fury FLL team 830 - F L eLements
FRC team 2170 - Titanium Tomahawks
Reply With Quote
  #9   Spotlight this post!  
Unread 18-02-2013, 23:10
Negative 9 Negative 9 is offline
Registered User
FRC #0611
 
Join Date: Dec 2012
Location: Mclean, VA
Posts: 46
Negative 9 is an unknown quantity at this point
Re: How do you program limit switches?

Quote:
Originally Posted by Bill_B View Post
Scissor jack? Very suave just to think of it.
Yup! We use it to change the angle of our shooter.
Reply With Quote
  #10   Spotlight this post!  
Unread 19-02-2013, 00:33
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: How do you program limit switches?

Quote:
Originally Posted by Negative 9 View Post
Yup! We use it to change the angle of our shooter.
Awesome! So are we

Here's ours:

https://sphotos-a.xx.fbcdn.net/hphot...42295922_n.jpg

https://sphotos-a.xx.fbcdn.net/hphot...83332209_n.jpg

https://sphotos-a.xx.fbcdn.net/hphot...17571241_n.jpg
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional
Reply With Quote
  #11   Spotlight this post!  
Unread 19-02-2013, 01:44
arithehun arithehun is offline
Registered User
AKA: Ari Falkner
FRC #3024
Team Role: Programmer
 
Join Date: Feb 2011
Rookie Year: 2011
Location: Ashland, Oregon
Posts: 27
arithehun is an unknown quantity at this point
Re: How do you program limit switches?

For some of you using command based programming, I noticed that the DigitalIOButton class wasn't working properly, so I programmed my own DigitalButton class using the very-functional DigitalInput class.

Code:
public class DigitalButton extends Button {
    private int channel;
    DigitalInput buttonInput;
    
    public DigitalButton(int channel) {
        this.channel = channel;
        buttonInput = new DigitalInput(channel);
    }

    public int getChannel() {
        return this.channel;
    }
    
    public boolean get() {
        return buttonInput.get();
    }
    
}
Reply With Quote
Reply


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 22:16.

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