Microcontroller drives logarithmic/linear dot/bar 20-LED display
Dhananjay V Gadre and Anurag Chugh, Netaji Subhas Institute of Technology, New Delhi, India; Edited by Brad Thompson and Fran Granville -- 1/18/2007
Available for more than 20 years, National Semiconductor's venerable LM3914 dot/bar-display driver still enjoys wide popularity among designers. The LM3914 can sense an analog voltage level and display it on 10 LEDs by illuminating one of 10 in dot mode or by progressively illuminating LEDs in bar-graph mode. Recently, an application needed an analog-input-voltage display capable of displaying more than 10 levels in linear- and logarithmic-scale formats. According to the LM3914's data sheet, you can cascade multiple 3914s to display more than 10 levels (Reference 1), but, even so, the LM3914 offers only linear displays of its input voltage. (Editor's note: National Semiconductor also offers the LM3915, a logarithmic, 3-dB-per-step version, and the LM3916, which displays its input in volume units, for audio applications.)
This application required more flexibility than the LM3914 offers, and it uses a circuit based on an Atmel AVR-family ATTiny13 microcontroller, which features 1 kbyte of program memory; a four-channel, 10-bit ADC; and six general-purpose I/O pins. Altering the circuit's firmware allows linear or logarithmic scaling of the 0 to 5V input-voltage range.
The circuit in Figure 1 continuously displays the input voltage in 20 levels. When closed, switch S1 freezes the displayed reading at its then-current level. Five of the microcontroller's six I/O pins control all 20 LEDs and the switch. Configured as an ADC-input channel, the remaining I/O pin receives the analog-input voltage. The microcontroller uses Charlieplexing, a method of using I/O lines to drive as many as N×(N–1) LEDs, to drive 20 LEDs with only five I/O pins (references 2 through 4).
The firmware is written in C and compiled using AVR-GCC, a freeware C compiler and assembler available in Windows and Linux versions. It uses the Tiny13's internal 10-bit ADC operating in free-running, interrupt-driven mode to convert the analog-input voltage into a digital number. Upon completion of each conversion, the ADC generates an interrupt that a subroutine reads; the interrupt stores the ADC's converted output in a shared variable.
| References |
|
© 2009, Reed Business Information, a division of Reed Elsevier Inc. All Rights Reserved.
