In numerous robotic applications, a sensor is essential for gauging light intensity. The conventional method, depicted in Figure 1, utilizes an A/D converter to assess the voltage drop across resistor R1, generated by the photocurrent passing through a phototransistor. The fixed value of R1 restricts the range of light that can be detected; a high resistor value is appropriate for detecting low light levels, while a low resistance is effective in brightly lit conditions. Additionally, the A/D converter’s resolution contributes to determining the range of measurable light levels. An underutilized feature of a standard LED is its capability to operate in reverse-biased photocurrent mode, producing a light-induced photocurrent, albeit at a significantly reduced value compared to a phototransistor.
Utilizing Diode Properties for Current Measurement
Directly measuring current can be challenging, but there’s an alternative approach outlined in reference . This technique exploits a specific property of a reverse-biased LED: its relatively large capacitance. The method involves charging this capacitor and allowing the photo-current to discharge it. The duration of discharge depends on the intensity of light falling on the LED (refer to Figure 2). Employing a single I/O pin of a microcontroller, the capacitor can be charged and the discharge time measured by toggling the pin between output and high-impedance input modes.
Two-Stage Measurement Process
The measurement process unfolds in two stages. Firstly, the pin is configured as an output and set to high, charging up the LED capacitance (see Figure 3). Secondly, the pin is switched to an input pin (disconnected from any pull-up resistor), and the time is measured until the input voltage level drops below the lower input threshold level (depicted in Figure 4). The provided example program, tailored for an Atmel AVR processor, illustrates this method of measuring light intensity.
The program alternates the state of all output bits from port A in each cycle. Creating an output square wave with an approximately 50% duty cycle. The wave’s frequency is proportional to the measured illumination, ranging from millihertz in darkened environments to several hundred kilohertz when light directly illuminates the LED. Achieving such a measurement range using an A/D converter would be challenging. LEDs with narrow beams have a corresponding limited ‘detection angle,’ making them more directional, which proves advantageous in certain applications. Additionally, various LEDs are sensitive to specific colors, offering utility in specific robotic scenarios.