Go to Post In FIRST, success = inspiration. - Daniel Brim [more]
Home
Go Back   Chief Delphi > Technical > Electrical
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 09-02-2015, 20:24
Team 4939 Team 4939 is offline
Registered User
AKA: Anshul Shah
FRC #4939 (All spark 9)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Brampton
Posts: 52
Team 4939 is an unknown quantity at this point
Micro Switch Wiring & Programming

Greetings from Team 4939,

Hopefully everybody is having a great final week of building. We were just in the phase of finishing some things up on our robot, and we decided that if we added a micro switch to the robot that would help us in the functionality of our platform. We are hoping that the micro switch will basically let the program know to stop the platform when it reaches to high or to low on or elevator system. We have never used this type of thing on our team, so we are looking for some help on this.

Any input in the programming or electrical wiring of the Micro switch would be greatly appreciated.

Thanks
  #2   Spotlight this post!  
Unread 09-02-2015, 20:42
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,074
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Micro Switch Wiring & Programming

Quote:
Originally Posted by Team 4939 View Post
Any input in the programming...
You neglected to mention what programming language.

While you're waiting for responses, this might be helpful:

https://wpilib.screenstepslive.com/s...ntrol-behavior


  #3   Spotlight this post!  
Unread 09-02-2015, 21:11
pastelpony's Avatar
pastelpony pastelpony is offline
Programmer/Electrical
AKA: Zach M
FRC #3525 (Nuts and Bolts of Fury)
Team Role: Programmer
 
Join Date: Feb 2014
Rookie Year: 2013
Location: Waterbury, Connecticut
Posts: 152
pastelpony will become famous soon enough
Re: Micro Switch Wiring & Programming

We're using these things for the same purpose of stopping a potentially-dangerous component of the robot.

What we did was saw off the male end of a PWM cable and solder the signal and ground to NO and COM respectively. The female side of the PWM then goes into the DIO breakout of the roboRIO. You'd treat it as a digital input in your code and look for a boolean value to decide what would happen if pressed/not pressed.
__________________
Team 3525 Head Programmer (2014- ) - Java (Formerly LabVIEW)
  #4   Spotlight this post!  
Unread 09-02-2015, 22:51
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,606
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: Micro Switch Wiring & Programming

Sorry about this - the NI specifications document for the roboRIO do NOT mention the pullup resistors. You have to go to the RoboRIO User Manual to find this info. I'll leave the post below here alone, as a reference for anyone who wants to wire a board that does not have pullup resistors built in.

As this was posted on the electrical forum, I'll describe how to wire them.

First of all, I'll assume that you're using a standard PWM color-coded cable, black is ground, red is 5V, and white is signal. Crimp a female Dupont (0.1" header-style) connector at one end, red wire in the middle.

I will refer to a setup where the return value is 0V normally and 5V when the switch is engaged as "normal" logic, and the reverse (5V normally, 0V when engaged) as "reverse" logic.
  • To get normal logic for double-throw switches (those with three terminals) such as those shown in the pictures referenced by Ether, wire the white wire to the pole (common), black to the normally closed terminal, and white to the normally open terminal.
  • For a single-pole switch (two terminals), you need to add a resistor. We're using 2K this year based on the numbers I looked up online, but we haven't gotten any answers back to confirm this is the right value.
    • To get normal logic with a normally open switch: Connect the red wire to one terminal on the switch and the white wire to the other terminal. This gives you 5V when the switch is engaged. However, it is "floating" when it is not, so you need to ground it. However, you need to limit the amount of current that will flow through the switch when the switch is closed. This is where the resistor comes in. Connect the black wire to one lead of the resistor, and the other lead of the resistor to the same terminal as the white wire.
    • If your switch is normally closed, wiring it as described above will give "reverse" logic.

For any of these setups, if you want the opposite logic from the one described, swap the black and red wires. Leave the white wire, switch, and resistor (if any) in the same configuration otherwise.


Finally, for any of these setups, plug this into one of the DIO ports, black at ground, white at signal.
__________________

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.

Last edited by GeeTwo : 10-02-2015 at 00:32. Reason: Prepended first paragraph (retraction)
  #5   Spotlight this post!  
Unread 09-02-2015, 23:54
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Micro Switch Wiring & Programming

Quote:
Originally Posted by GeeTwo View Post
For a single-pole switch (two terminals), you need to add a resistor.
You don't need to add a resistor to sense a contact closure. The roboRIO digital inputs already have one. Just connect the switch between the GND (black) and SIG (white) wires.

Programming depends on the language you're using.
  #6   Spotlight this post!  
Unread 10-02-2015, 01:30
SousVide SousVide is offline
Registered User
no team
 
Join Date: Jan 2011
Location: CA
Posts: 91
SousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to beholdSousVide is a splendid one to behold
Re: Micro Switch Wiring & Programming

Suggestion for this use would be to wire these micro-switches as NC for failsafe. If the wiring or the switch somehow fails - the usually mode is a break in the line, then it will act as if the switch is depressed and disallow movement. If you wire it up as NO, you will have no way to know that there is a break in the line until the device crashes or hits a hardstop.

See:
http://www.allaboutcircuits.com/vol_4/chpt_6/5.html

Quote:
Originally Posted by pastelpony View Post
We're using these things for the same purpose of stopping a potentially-dangerous component of the robot.

What we did was saw off the male end of a PWM cable and solder the signal and ground to NO and COM respectively. The female side of the PWM then goes into the DIO breakout of the roboRIO. You'd treat it as a digital input in your code and look for a boolean value to decide what would happen if pressed/not pressed.
  #7   Spotlight this post!  
Unread 10-02-2015, 15:53
Team 4939 Team 4939 is offline
Registered User
AKA: Anshul Shah
FRC #4939 (All spark 9)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Brampton
Posts: 52
Team 4939 is an unknown quantity at this point
Re: Micro Switch Wiring & Programming

So sorry for forgetting to mention the programming language. The programming language that we use is JAVA.

Thanks once again.
  #8   Spotlight this post!  
Unread 10-02-2015, 16:09
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Micro Switch Wiring & Programming

In a procedural language like C++ or Java, the programming for a limit switch is simple. Just before you call the motor.Set() method, test to see whether the value to send to the motor is forward while the forward limit switch is active, and set the value to zero if so. If you also have a reverse limit switch, add another test to see whether the motor value is reverse while the reverse switch is active, and zero the value if so. Only then do you actually set the motor to that value.
  #9   Spotlight this post!  
Unread 10-02-2015, 21:30
Team 4939 Team 4939 is offline
Registered User
AKA: Anshul Shah
FRC #4939 (All spark 9)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2014
Location: Brampton
Posts: 52
Team 4939 is an unknown quantity at this point
Re: Micro Switch Wiring & Programming

Quote:
Originally Posted by Alan Anderson View Post
In a procedural language like C++ or Java, the programming for a limit switch is simple. Just before you call the motor.Set() method, test to see whether the value to send to the motor is forward while the forward limit switch is active, and set the value to zero if so. If you also have a reverse limit switch, add another test to see whether the motor value is reverse while the reverse switch is active, and zero the value if so. Only then do you actually set the motor to that value.
What is the name of the object when introducing the limit switch to the program?
  #10   Spotlight this post!  
Unread 10-02-2015, 21:44
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Micro Switch Wiring & Programming

Switches are read using DigitalInput objects.
Closed Thread


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 11:30.

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