Internals of RCX Input Ports and Sensors

The three input ports of the RCX are connected to the 10 bit A/D converter of the Hitachi microcontroller as shown in Figure 1a. The A/D converter converts the analog voltage drop across the two input port terminals into a 10 bit value.

Figure 1a The internal of an input port shows how the
terminals are connected to the pin of an A/D converter.
Figure 1b The internal of a touch sensor with a switch and
an internal 500 Ohm resistor.Tom Dean, Sensors and Sensing, (6.2.2004).

When a simple passive sensor, like the touch sensor of Figure 1b, is connected to an input port, the 10 bit value obtained from the A/D converter is related to the voltage drop through the touch sensor. When the switch is off (no connection, infinite resistance) the drop is 5 V because of the pull-up resistor of 10 k Ohm. When the switch is on this is the voltage drop through the 500 Ohm resistor of the touch sensor. The voltage drop can be calculated by means of the formula for a voltage divider ( p.100, Martin, 2000):

V(on) = 5*500/(500+10000) V = 0.24 V
In general, the voltage drop through a sensor with resistance R is given by:
V(through sensor) = 5*R/(R+10000) V
The conversion of the voltage between 0 V and 5 V into a 10 bit raw value between 0 and 1023 is done so 0 V corresponds to 0 (direct connection or short-circuit, resistance 0) and 5 V to 1023 (no connection, infinite resistance). In between the mapping is linear. Hence, the raw 10 bit value obtained is related to the resistance of the sensor as follows ( p.235, Baum et al):
RawValue = 1023*R/(R+10000)
This model of the values obtained from the input ports can be verified by e.g. connecting resistors with known resistance values to the input port and read the corresponding raw values. The result obtained can e.g. be as follows:

Resistance (Ohm) Raw value
100098
2250202
4000300
6400402
10000520
14000600
21500699
36300802
74000902
100000927
200000974
10000001014

The functional relationship of the formula is shown graphically in Figure 2 together with points representing the measurements of the table. As can be seen there is a close correspondence between the measured values and the formula for the RawValue.

Figure 2 The fourteen resistance, raw value pairs connected with straight lines. The functional relationship of the formula is shown as the dashed line.

Figure 3 A closer look at the curve for smaller values of R in Figure 2.

When it comes to the active sensors these are much more complicated inside as can be seen from the figures 4 to 7. There is however still a simple relationship between the raw value measured and the sensor resistance if the A/D conversion takes place with no power is supplied to the active sensor.

Figure 4 Michael Gasperi, MindStorms RXC Sensor Input Page, (6.2.2004), contains this photo
of the inside of the LEGO light sensor.

Figure 5 Reverse engineering of the LEGO Light sensor has resulted in this circuit diagram. The reverse
engineering has been described by Michael Gasperi also on the LEGO Light Sensor page.

Figure 6 Philippe Hurbain, Lego® Rotation Sensor Internals, (6.2.2004), contains photos, circuit
diagrams and detailed operation of the rotation sensor.

Figure 7 Reverse engineering of the rotation sensor has resulted in this circuit diagram. The reverse
engineering has been described by Philippe Hurbain also on the Lego® Rotation Sensor Internals page.

More Information About Sensors and Sensing


Last update: 30-08-07