July 2004: This is the first custom proximity sensor I made for the RCX, fitted in a box made by two 2×4 bricks. It returns a reading that is proportional to the distance from an object. In 2005, I made a smaller proximity sensor that returns a digital reading, depending on the presence of the object. In the image at left, you can see the IR led and the little window through which phototransistor detects objects. It is completely insensitive to ambient light, because it seeks only modulated IR light.
The assembly is a bit bulky, because I used through-hole components instead of SMD devices. Let’s take a look at the schematic. All starts from the diode bridge that supplies the sensor. In this design, I saved one diode as explained by van Mattijs, Stef en Robbert Mientki, by combining the positive power supply and generating the output signal.
IC1B is a square wave oscillator that drives the IR led. When an object is in sight, a fraction of the emitted IR light is reflected back, is detected by IR phototransistor and amplified by BC547. The 1N4148 diode, the 1M resistor and the 100nF capacitor form a peak detector, which converts IR light signal into DC voltage. IC1A buffers the voltage to RCX, and through the 10k resistor, produces a variable current. With no object detection, the RCX reads about 50 (light sensor percentage value); the value decreases in quite a linear way when an object moves from 25 cm away (value is 47) to 4 cm (value is about 10) .