|
|
|
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):
In general, the voltage drop through a sensor with resistance R is given by:V(on) = 5*500/(500+10000) V = 0.24 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):V(through sensor) = 5*R/(R+10000) V
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:RawValue = 1023*R/(R+10000)
| Resistance (Ohm) | Raw value |
|---|---|
| 1000 | 98 |
| 2250 | 202 |
| 4000 | 300 |
| 6400 | 402 |
| 10000 | 520 |
| 14000 | 600 |
| 21500 | 699 |
| 36300 | 802 |
| 74000 | 902 |
| 100000 | 927 |
| 200000 | 974 |
| 1000000 | 1014 |
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. |