Home Robotics C++ Physics II AP Physics B Electronics AP Java Astronomy Independent Study Summer Session Contests  About
                                                       

Touch Sensor

 

This device consists of a contact switch held open with a spring and wired in series with a load resistor.

Note

Simple mechanical switches such as the Lego touch sensor tend to bounce when pressed. The signal we want to detect corresponds to distinct pressings of the switch; the bounces that arise as a consequence of mechanical and electrical chattering of the contacts are considered noise.

Nearly all mechanical switches generate some "bounce". That is, for every time they are switched, they actually open and close their contacts several times before settling down to their new position. For normal switches, this can last from as little as a fraction of a millisecond (ms), to as long as 50 ms. Only very high quality switches generate little or no bounce.

This is not usually a problem if you are merely turning on a light, but if you are working with logic devices, all these extra bounces can create havoc. For instance, what if every time you pressed a button to increment a counter you actually added several counts to the total?

One way of de-bouncing a switch is by using an RC network to slow either the rising or falling edge of the event.  We can use the fact that the time for a capacitor to recover 63% of its voltage, in seconds, is the product of the Resistance in ohms and the capacitance in farads. 

In order to avoid counting the bounces when a switch is pressed, e.g., on a computer keyboard, mechanical switches are generally debounced either by adding additional circuitry (e.g., a capacitor across the switch contacts) or by employing some sort of filtering subroutine which, when it detects a voltage transition, it ignores subsequent transitions for a short period following the initial transition assuming that the later transitions are due to bounces and not distinct pressing events. The RCX and legOS software do a good job of conditioning touch sensors so that they are reasonably well behaved.

This type of construction makes a nice push button, with a bit of tension. Unlike the previous, it gives you a flat-front bumper, rather than an angled one. You can also add another axle to make sure the rubber band doesn't slip off. Adjusting the length of the center axle allow for more or less sensitive interactions.

 

You can also use the touch sensor as a rotation sensor. Attach a cam to the rotating axle, and then position the LEGO sensor so that it is hit by the cam as the axle rotates. Counting the number of hits, combined with the wheel radius, can give you a distance reading. Measuring the time between hits can give you a speed measurement. Note that this only works well for axles that don't rotate very fast.

 

This simple attachment makes the touch sensor into more of an angled push-bumper. It has a simple pivot point that allows touch along the pivoting piece to actuate the sensor. One of the many options is also shown.