0
\$\begingroup\$

I was experimenting the other day trying to find some way to get cheap light sensors and read somewhere that LEDs can be driven backwards and let through current backwards more the larger amount of light shining on the LED. Then my solution involved setting pin to high ( 5V ) and switching to input and measuring time (clock cycles) required to leak down to a false state ( close to 0V ).

schematic

simulate this circuit – Schematic created using CircuitLab

Any idea how I can modify my circuit to get a faster more predictable maximum time for the time counter for my controller?

\$\endgroup\$
  • 2
    \$\begingroup\$ Cripes. A simple google comes up with lots of pages on the topic. Here's the first one: wiki.analog.com/university/courses/electronics/… and there are many, many more. There are whole pages on using these to allow micros inside of cubes to talk to each other, in fact. \$\endgroup\$ – jonk Jan 19 '17 at 19:00
  • \$\begingroup\$ Yes you are right. Maybe unnecessary to ask so fast when there are very many approaches so easily available. \$\endgroup\$ – mathreadler Jan 19 '17 at 19:05
2
\$\begingroup\$

You can use an LED as a photodiode. They are not the same however, a photodiode produces a leakage current in the opposite direction from LED's. One problem is the currents are also small (as with photodiodes in the mA to uA range).

To gain the current a transimpedance amplifier is necessary and change it to a voltage that can be read by your micro controller

\$\endgroup\$
2
\$\begingroup\$

This kind of circuit DOES work with both photodiodes and phototransistors, but have never tried it without an integrating capacitor. With a LED, the only capacitance in the circuit is diode capacitance, and input-pin capacitance (plus stray capacitance). Wiring the diode very close to the input pin should help reduce stray capacitance, and reduce pick-up of stray transients.
Note that adding capacitance will increase measurement time, with the advantage of improving resolution:

schematic

simulate this circuit – Schematic created using CircuitLab The PIC microcontroller that I used specified GPIO leakage current to be rather high, but measured leakage at room temperature showed that leakage current of GPIO pin was negligible, less than 1 nA. At high temperatures, leakage current can affect results. Leakage would be difficult to discern from photocurrent. Note that threshold voltage of a GPIO pin will vary from chip-to-chip, so that this method is not good for measuring absolute light levels.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.