|

楼主 |
发表于 2008-12-25 22:40:58
|
显示全部楼层
SetSensorMode(SENSOR_1,SENSOR_MODE_RAW);
distance = SENSOR_1;
//Enable C1 charge as soon as possible
SetSensor(SENSOR_1,SENSOR_LIGHT);
Component Selection
- D1 prevents destroying the sensor in case of reverse connection. I didn't use the full-bridge rectifier used in Lego sensor that enables sensors to work when connected backwards (number of needed diodes jumps from 3 to 8!). I considered that someone able to build this sensor is also able to connect it in the right way... For those who want it, here is the diagram with full bridge rectifier. I used 1 Amp Shottky diode 1N5819 for D1, which is inexpensive and readily available. It's low forward drop voltage is less than 0.1V for the current that flows through it, this enables it to charge C1 to the highest voltage possible.
- C1 stores energy that will be used during measurement phase. It must provide +5V at the end of this stage. Assuming typical values for the GP2D12 (I=35mA, conversion time=50ms) and an initial +7.5V across C1, its value is C = I * dT / dV = 35 * 50 / (7.5-5) = 700 µF. Small margin with 1000 µF...
- U1 is a low drop out 5V regulator in TO92 case. I used a Telcom/Microchip TC55RP5000 but other regulators will probably work, such as STMicroelectronics L4931-50. Standard regulators such as 78L05 will NOT work because they require more than +7V at input to get a +5V output. Take care with some low drop regulators such as LM2931 that require more than 25 mA when powered at 1V. With RCX current limitation, this hog eats all energy. (I was caught with this one...)
- Q1 switches power on and off for GP2D12. At 35mA current, I originally used a plain vanilla BC548. My sensor began to work with it, but exhibited strange behavior. Looking to GP2D12 power supply I then discovered 2V dips! I then looked at the GP2D12 consumption and discovered that it was pulsed (220mA pulses 1/8th of time, superimposed to a 8mA constant current. See oscilloscope captures here ). At such a current, BC548 has a low gain, and since I couldn't lower base resistor R1 (main current drain during capacitor charge) I used a high performance Zetex transistor, ZTX718 that offers high gain at high current (other similar devices can work!).
|
|