Single microcontroller pin senses ambient light, controls illumination

Texas Instruments MSP430F2013

Loren Passmore

EDN

As in a previous Design Idea (Reference 1), this design uses an LED as a transducer to measure the ambient-light level and to provide illumination. This Design Idea uses the same principle as its predecessor but consists of only one LED, two resistors, one IC, and one 0.1-µF bypass capacitor. This circuit for providing ambient-light feedback requires no additional components. Despite requiring only a few components, the circuit in Figure 1 offers considerable flexibility because the microprocessor's software controls the LED's brightness and its relationship to ambient-light levels. For night-light applications, one mode turns on the LED when ambient light decreases. Conversely, for power-saving regulation of a portable device's LCD backlight, a second mode turns on the LED when the ambient-light level increases.

Single microcontroller pin senses ambient light, controls illumination
Figure 1. An LED, a microprocessor, two resistors, and one capacitor
constitute the entire circuit.

You can download Listing 1, sample code for this Design Idea, which provides 64 levels of PWM (pulse-width-modulated) intensity control over the LED's brightness in either mode. In operation, one of the microprocessor's multifunction pins drives the LED with a PWM waveform for several hundred milliseconds. After the waveform's final cycle, the software switches the microprocessor's pin to input mode and connects the LED to the microprocessor's internal 16-bit sigma-delta ADC. Ambient light illuminates the LED, producing voltage, which the ADC measures, and the microprocessor computes the PWM waveform's parameters for the next series of illumination cycles. The cycle rate's high repetition frequency eliminates any discernible flickering of the LED.

In the listing, when the software and ambient-light level specify that the LED should turn off for an extended interval, the CPU goes into a low-power state for 250 msec. During its sleep mode and for a few hundred microseconds while performing ADC conversions, the circuit draws only about 20 µA and thus suits itself well to battery-powered-system applications.

At start-up, the microprocessor stores an initial voltage level, which the LED produces, and uses this value to scale the PWM levels. Shading the LED or moving the circuit into a darker area immediately increases the LED's brightness, which the listing's 64 PWM levels control in small steps. The MSP430F2013's ADC presents input impedance of approximately 200 kΩ. When driving this impedance, an LED occupying a small, 0805, surface-mount footprint generates only a few 10s of millivolts. However, the MSP430F2013's 16-bit ADC resolves the LED's voltage with sufficient resolution to ensure good performance under normal room-lighting levels.

In addition, the MSP430F2013 includes a four-level PGA (programmable-gain amplifier), offering gains of one, four, eight, and 16 to further amplify the LED's minuscule output voltage. The circuit also exploits the microprocessor's onboard low-frequency clock oscillator, which allows low-powered operation without an external crystal. The resultant circuit includes only six components, including a battery.

Note:

The code can execute on Texas Instruments' eZ430 demonstration board without hardware modifications because the board includes an LED connected to port P1.0.

Reference

Materials on the topic

EDN

You may have to register before you can post comments and get full access to forum.
EMS supplier