Features This Sharp GP2D12 infrared distance sensor interface comes with Sharp GP2D12 sensor. Sharp GP2D12 can precisely and reliably read distance from 10cm-80cm. Sharp GP2D12 provides your RCX with capability of measuring distances from an obstacle.
Philo had suggested an idea to interface GP2D12 with RCX. His idea involved a concept of storing energy in a capacitor and using it once you have accumulated enough.
We have redesigned this circuit to improve it's performance and overcome certain limitations.
Since this interface is not powered through motor power port, it uses a program to perform it's reading cycle, unlike Light sensor or Touch sensor, and as a result performance is slightly slower than the motor powered interface. Use this interface if you are really short of power ports.
You will find the example of NQC program here.
Power consumption 10mA while charging.
Can be read once in 250 ms in normal operation mode.
Can be read continuously for 1 second in fast access mode. ( only fully charged, after this cycle you'll need to wait for few seconds for the sensor to get charged completely again.)
More sensitive and with more usable range.
Range: 10 - 80 cms.
Size: 2 studs x 6 studs
The white connectors shown in the picture are for illustration purpose. If you are using non-lego wires, you may attach this connector.
// Read GP2D12 Sensor output and displays
// raw value on RCX display (requires RCX 2 firmware)
SetUserDisplay(value,0); // Display "value" on LCD
SetSensor(SENSOR_1,SENSOR_LIGHT); // Active mode: starts charging sensor
Wait(100); // Wait for full charge on startup
SetSensor(SENSOR_1,SENSOR_TOUCH); // Passive mode: starts measure
Wait(6); // Wait for GP2D12 conversion time (50ms)
value=SENSOR_1; // reads and display value
SetSensor(SENSOR_1,SENSOR_LIGHT); // Recharge sensor
Wait(40); // for 250 ms
Calibration Plot Use this plot to convert RCX reading to distance using GP2D12.
Note: Calibration may have 10% variation from sensor to sensor.