An LED is not only LE (light emitting) - it is also a D (diode). And as a semiconductor diode it is sensitive to light at certain wavelengths. There are two effects: photoelectric voltage generation and reduction of leakage current in blocking mode. Here we use the leakage current.
The Making of
How to measure it? If we had some capacitor we could use RCTIME-type software. The good news is: Our LED in blocking mode has a built in capacitor! Remember the D? Every diode in blocking mode has a certain voltage-dependent capacitance. For an LED expect between 5 pF and 50 pF for voltages up to our VCC of 3.3 V dependent on the LED type. Yes, we could also use them as varicaps. But that's a different story. The leakage current not only depends on the LED type but also on the illumination that hits the LED. From my observations it seems to be in the sub-nA range in the dark and up to almost uA-values in full sunlight.
Back to the question. If we charge the capacitance of the LED in blocking direction to VCC, switch the pin connected to its cathode from output to input, we only have to measure how long it takes that the voltage passes the logic input threshold. Expect a few us up to whole seconds. And don't expect the time to be proportional to the light intensity!
The Uses
Nice, isn't it? But what can we do with this brilliant idea? Well, we need a certain time until we find bright or dark.
- This almost excludes fast optical data transmission. Almost? If we think about it a bit we might find some acceleration.
- We can use it for touch sensors. Measure the light falling on the sensor and if a finger blocks it we know that it's touched. Or mount a bright LED in direct proximity and register the reflection.
- It's also suited for photoelectric security mechanisms. If you want to protect your home put a sender LED on one side of the window and a sensor LED on the other side. You might need some focusing lens here. Or if you want to stop a closing door if someone is in between you can also use it.
- You want to control something dependent on ambient illumination. Like switching lights on in the dark. Or extending a sun shade when it's bright.
How to get it
I've already posted a first version at the propeller forum at Parallax. In the meantime I have written PASM and SPIN versions. They are available in one file in a small application that can be used as demo, for debugging, for calibration.
No comments:
Post a Comment