Design Idea
Microcontroller drives logarithmic/linear dot/bar 20-LED display
Do-it-yourself analog-to-LM3914 display driver offers user programmability.
Dhananjay V Gadre and Anurag Chugh, Netaji Subhas Institute of Technology, New Delhi, India; Edited by Brad Thompson and Fran Granville -- EDN, 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.
To provide a flicker-free display, an internal timer generates a 1875-Hz interrupt derived from the 9.6-MHz system clock to drive the multiplexed LEDs at a rate exceeding 90 Hz. Dividing the ADC count by a constant yields a linear display of the input voltage. A look-up table scales the ADC count to produce a logarithmic display. Figure 2 shows the logarithmic-conversion curve that defines the look-up table's values. Versions of the ATTiny13's control programs for linear and logarithmic scales are available for downloading from this Design Idea. You can modify the source code to display only a particular subrange of the input voltage of 0 to 5V. For example, you can specify a linear-display range spanning 1 to 3V or a logarithmic scale for input voltages of 2 to 3V.
| References |
|














