Distance tracking

As many have pointed out, the RCX may use its IR-communication system together with the light-sensor as a proximity-detector. Thus the RCX may find an object or determine the distance to a wall.

The light-sensor must point to the same direction as the IR-LED.

To operate this sensoring, the RCX must continuously send an IR-signal. As the LEGO light-sensor is IR-sensitive, its values will grow, when a reflecting object is in front of the RCX.

Here a Robolab 2.5 program! The IR-signal is not constant as it is modulated to carry some data and it also makes pauses between bursts. And above all, the IR-frequency of 38kHz is enormous compared to the slow RCX-sampling rate ( fs= 1 / 3.1E-3 ). So the light-sensor values variate a lot. Therefore it's a good idea to take the weighted average to filter out the random part of the sensor-signal.

The program controls a mobile robot that starts at about 1 m from a white wall towards this wall. The control-distance is measured by the rotation-sensor.

(Note the sending value 0x55 = 85 = b'0101 0101'. The IR-protocol lets this value be followed by its complement b'1010 1010'. This is not too important here. Any value will do the job.)

The values decrease significantly in function of the distance from the wall. As the light intensity decreases proportionnally to the square of the distance, the curve should have a parabolic aspect, which is given.

Note that the ambient light and even the color of the wall do play an important role here. With some mathematical effort however this influence can be eliminated too. (Stand by: we keep on working on this.)