For robots to move and interact with their environment, they require some form of programming, which takes inputs. Depending on those inputs, you can then configure outputs such as lights, motors, and beepers. The simplest robots with advanced motors (such as servos and steppers) can accept numeric instructions to perform an action, such as a CNC, which is told to move in a certain way.
More intelligent robots, however, are capable of determining the nature of their environment and take action accordingly. For example, a robot with a light detector could locate light sources and stay near them, so that it can use a solar panel to charge its internal batteries. Sensors can be used for many more things than just responding to simple stimuli; they can be used to balance a robot with accelerometers, determine how much pressure to hold an object with, or even recognize its creator and respond accordingly.
As we are still in the beginner stages of robotics, we will look at a very simple sensor that can be very useful in many robot designs: the spring antenna.
If there’s one thing that most insects have, it’s an antenna. There is a great reason for this: antennae are incredibly versatile and can sense many different stimuli. While the most apparent use of antennae is to objects directly in front of something, they are capable of detecting pheromones, chemicals, and even timing for migration reasons (depending on the species). In robotics, a pair of antennae can be used as a method for object avoidance by signaling when an object has been touched.
Creating a spring antenna is incredibly simple and requires no specialist sensors - a piece of wire is all you need! The antenna that feels objects extends outward from the robot and is connected to the robot controller input and tied to power via a resistor, while a wire spring is connected to ground and encases the bottom section of the antenna. When the antenna makes contact with an object, it deflects the object and makes contact with the spring sheath, which closes the circuit and pulls the microcontroller input low.
While this antenna sensor can be connected to a motor controller to turn motors away from objects, it is more convenient to process the data and combine it with other sensors. For example, it may be desirable to collide with an object if certain conditions are met and avoid when not. However, this circuit should not be directly connected to a microcontroller’s input for a few reasons:
The first, and most important issue is the lack of input protection. The antenna’s job is to feel objects in the real world that could easily be carrying an electrical charge. As anyone who has worked with static sensitive parts knows, this will cause some serious issues when the antenna touches a charged object.
The second problem is called switch bounce, where contact with an object may produce brief erratic outputs during contact and create a disconnection between the spring and feeler.
The third issue is that a piece of electrical wire extending from the robot can potentially induce voltages onto touched objects (although this is not always too pressing of a problem).
The first and second problems are solved with the schematic (see the Scheme-It Schematic above), which provides multiple types of input protection. The resistor R1 is a current-limiting resistor that helps prevent too much current from traveling towards the input of the microcontroller. The diode D1 is a Zener diode that will not allow the input to the circuit to go above 5.1V or below 0V (closer to -0.6V). The de-bounce issue is solved with the use of a capacitor and a Schmitt trigger (optional IC to use would be NC7SZ14P5XCT-ND & mounting board). When contact is made with an external object, the capacitor decouples any sudden switch bounces and smooths them out, while the Schmitt trigger provides hysteresis.
The third problem is something that is solved in the design. Instead of using a fully uninsulated wire, it would be better to have the feeler insulated up to the spring where the insulation can be removed. This way, the feelers do not conduct any current into objects they touch. This may help in environments which could be wet or conductive.