|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Micro Switch Wiring & 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
|
||||
|
||||
|
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. |
|
#4
|
|||||
|
|||||
|
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.
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. Last edited by GeeTwo : 10-02-2015 at 00:32. Reason: Prepended first paragraph (retraction) |
|
#5
|
|||||
|
|||||
|
Re: Micro Switch Wiring & Programming
Quote:
Programming depends on the language you're using. |
|
#6
|
|||
|
|||
|
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:
|
|
#7
|
|||
|
|||
|
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
|
|||||
|
|||||
|
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
|
|||
|
|||
|
Re: Micro Switch Wiring & Programming
Quote:
|
|
#10
|
|||||
|
|||||
|
Re: Micro Switch Wiring & Programming
Switches are read using DigitalInput objects.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|