Four-way Multiplexer for LEGO RCX Touch Sensors


Click image for a closer view.

Background

This is a page I have been meaning to write for years. This information is mostly obsolete since LEGO introduced the NXT product which has intelligent sensors and no longer has the requirement of providing an analog signal which represents digital values.

Several low cost 3 port multiplexers have been built that use standard LEGO RCX jacks. These jacks require a 2x2 double-stack plate connector to get back into the RCX. I considered this too big for small robots and wanted a system that could use smaller connectors. The 0.1 inch header

Multiplexer

Four way touch sensor multiplexer for RCX. Program allows RCX to know which of the four connected switches are depressed. Any combination can be detected.

The RCX has three analog inputs each of which is connected to a 10-bit analog to digital converter (ADC) via a 10k ohm pullup resistor. Using that pullup as part of a voltage divider is the objective.

Mux made with 4 resistors that came in a single cheap Radio Shack package. All resistors are standard 5% tolerance (lowest grade) with these values:

  12k 22k 47k 100k
Notice how each successive value is approximately double the preceding one. I did a lot of complex math to determine the ideal values of the resistors using commonly found parts available in any Radio Shack in the country. I tested all combinations of common resistors at the extreme limits of their standard 5% tolerance to find values that would allow discrimination of any combinations of buttons pushed. I have no idea how this program does it as I wrote the code many years ago and never documented it at the time.

Touch Sensors

I started with a 2x2 touch sensor with standard connection. The connector is almost as big as the sensor. Note that the connector can only be attached in one direction because of the position of the electrical contacts. Attaching the connector at 90 degrees shorts it out because of the design intent of the LEGO connector.

I wanted touch sensors that were as small as possible. A single 2x2 brick with plug less than 1x1 is significantly smaller than a 2x3 brick with 2x2 connector. Switches in these sensors were donated by antiquated 2-button mice. These mice were destined for the garbage when they were replace with wheel mice. Newer mice should work just as well.

Wires

Connectors are standard 0.1 inch Header Strips. Remember jumpering IRQ settings on ISA card in your PC? These connectors are a penny a pin. At this price, I can make as many connecting wires as I want, all of varying lengths, and not worry about the cost of the wires. Standard LEGO connectors are about $3.00 each.

Please ignore my soldering. That is the primary reason why I went into software.

Code to Isolate Pressed Switches

The entire objective was to determine what switches were pressed. Here is the code to do just that.
Questions?  See the elecbrick FAQ.
Comments?  doug@elecbrick.com.
elecbrick is a trademark of Doug Eaton.   LEGO is a trademark of The LEGO Company which does not sponsor, authorize or endorse this site.   Please visit www.lego.com.   Not responsible for errors or omissions.   These inventories and descriptions are for informational purposes only.