Detecting Bumps
The Limit Switch
Robots can use Touch Sensors to interact and gain information about its envirment. Touch sensors are most commonly used to detect when a robot has reached a wall, if an object is in the right position, or if a robot's arm has moved to a specific location or limit. There are different types of Touch Sensors with different form factors but they work under the same principle.
Limit Switches are one type of a Touch Sensor, and will be the one that we will use for our project. A Limit switch has a lever that can be used to prevent an arm from moving further than it should. Underneath the arm, you can see a small button that gets pushed when the lever is pushed down far enough.
Limit Switches have spring loaded buttons that will "spring open" once the lever arm is released.
Mini Project Control Motor Using A Sensor (Limit Switch)
In this project, you will use a Limit Switch to control when a motor runs. The motor will run when the Limit Switch is pushed in, and will stop when it is released. This project will build on the Motor Control Board Circuit.
Find the following components in your kit:
- Motor Control Board Circuit
- Arduino Uno
- USB A-to-B cord
- Limit Switch
- 2 Wires (red and black) of 22 AWG 5 pin wire
- 22-16 gauge Female Quick Disconnects
- Insulated Crimper
- Header Pins
- Header Pin Housings
- Header Pin Crimper
To connect to the limit switch we will need too create 22 AWG wire with male header pins on one side and a new type of connector, called quick disconnects, on the other end.
Start by cutting, separating, and stripping two 22 AWG wire.
Take the red and black wires, and attach male header pins to the end of them.
For a refresher on how to attach male header pins to your wire, complete the following steps.
To begin attaching and crimping spade connectors, you will need the following:
- 22 AWG Wire
- Wire Cutter/Stripper
- Header Pin Crimper
- Male or Female Header Crimps
- Header pin housings or shells
- Needle nose pliers or Wire Cutter / Stripper
You may want to have extra crimps and wires. These crimps are small, require a special crimping tool, precise techniques and practice to create a proper crimp.
Header pin crimps are made up of three distinct portions: The mating pin zone is the portion of the crimp that interfaces with the component that you are connecting to. The other two portions interface with the wire. There is the conductor crimp zone which is the portion of the cimp that forms around the conductor and makes the electrical connection. The final part is the insulation crimp zone, where this part of the crimp forms around the wire’s insulation. This further securies the wire and creates a strain release. Both male and female header pins are crimped using the same process.
Cut a piece of the wire to the needed length and separate the number of wire you need from the .
Strip the ends of the wire so that 0.10 in or 2.5 mm of wire is exposed. It may be easier to strip the wires longer and trim the exposed wires to 0.10 in or 2.5 mm.
Cut off the male or female pin off of their connector strips. Keep the metal tab connected to the crimp, it will be used to align the crimp into the header pin crimper.
Place the wire into the crimp. Make sure the exposed wire is not in the mating pin zone.
To give your crimp a better chance to be successful use your wire cutters or needle nose pliers to start to fold over the tabs on the insulation crimp zone.
The recommended crimper has 2 different crimping areas the larger anvil crimps the insulation zone while the smaller anvil crimps the conductor zone. Make sure to line up the zones correctly or the crimp will not crimp properly.
Use the crimping tool to crimp the conductor crimp zone and the insulation crimp zone. Make sure the Mating pin zone is extended completely out of the crimping tool. If you crimp this part it will deform and will not function
After crimping, if you inspect the connection and see that the crimped parts are not fully compressed onto the wire you may want to crimp the connection a second time.
Once the crimp is successfully attached to the wire you can remove the metal carrier strip by bending or cutting it off. After removing that, the crimp is ready to be placed into the plastic housing.
The plastic housing, or shields as they are sometimes called, add structure and support to make the crimp more durable. The plastic housings come in various sizes that can hold multiple connections in one block. Some projects will have all the connections next to each other which make the multi-connection block very convenient to use. Using single pin housing is easier to learn on and creates wires that have more flexibility in how they can be connected.
Both the male and female header pins have a small square or rectangle of metal in the pin mating zone. This metal “tab” will lock itself into the square opening or “slot” in the housing. Make sure the tab and the slot are facing the same direction and push the crimp into the larger opening in the housing. If done successfully the crimp will lock itself in the housing.
Perform a pull test to confirm that the crimp will not slip out of the housing. If the housing does not easly slip off you have successfully made a crimp!
Follow along with this module to learn how to use quick disconnect crimps.
To begin crimping both male and female quick disconnects, you will need the following:
- Male or Female Quick Disconnects Crimps
- 22 AWG Wire
- Insulated Crimper
- Wire Stripper
Quick Disconnect connectors are that can be connected and disconnected with out addtional tools. These crimps always work in pairs, a male connector fits into a female connector. Male connectors can be found built into different electrial components as well as being crimped to wires.
Take the end of the wire, and make sure there is enough conductor exposed to attach the connector -- about 0.5 cm, or a quater (1/4) of an inch is good for this type of clip.
Insert the the stripped wire into a male or female crimp. Make sure the wire does not extend past the crimping tube.
Insert the crimp and wire into the slot on your crimper that matches the size of the wire.
Firmly squeeze the handle of the crimper to press the tube around the exposed wire. Many crimper designs will not open back up until you have squeezed far enough -- if the crimper won't open, keep squeezing until it does.
Line up the wire and crimp in the jaws and squeeze the crimper until the crimper snaps open.
Give the crimp and the wire a soft pull. If the crimp is secure the wire will not come out of the crimp
Attach the newly created wires to the Limit Switch.
You will need to attach the Quick Disconnect of the black wire to the common "COM" port of the Limit Switch, and the Quick Disconnect of the red wire to the Normaly Open "NO" port of the Limit Switch.
- Take you circuit from your Motor Control Board. Make sure the blue and green wires are plugged into ports 13 and 12 respectively. The red and black wires, from the Motor Control Board, should be connected to 5V and GND respectively.
- To start to connect the Limit Switch connect the male header pin end of the black wire to a GND pin of the Arduino.
- Connect the male header pin end of the red wire to digital pin 8 on the Arduino.
- Connecting the limit switch this way will allow the arduino to monitor when port 8 is connected to GND.
Connect the Arduino to your computer using the USB A-to-B cable.
Download the following program: LimitSwitch.ino
Open the Arduino software and open the LimitSwitch” program.
Click on the Upload button to upload the program to the Arduino Uno. The program should immediately run after it is done uploading.
What happens?
The motor should move only when the Limit Switch is pressed in, and stop when it is released!
Explanation
The Limit Switch is connected to the Arduino from a GND to a Digital pin. If you look in the program, you will see that in the setup, it is being set as an "INPUT_PULLUP". What this means is that we are setting up Digital Pin 8 to be an INPUT that is in a special "PULLUP" mode.
This INPUT_PULLUP mode tells the Arduino to invert the input so that instead of “HIGH” being what we’re used to (on), it inverts it so that it is off. So for the Limit Switch, it allows us to use the pin so that if it is not pushed in, it is not giving the Arduino a HIGH signal.