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 o
f 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
1.LM3914 data sheet.
2.Lancaster, Don, "Tech Musings," August 2001.
3."Charlieplexing: Reduced Pin-Count LED Multiplexing," Maxim Application Note 1880, Feb 10, 2003.
4.Benabadji, Noureddine, "PIC microprocessor drives 20-LED dot- or bar-graph display," EDN, Sept 1, 2006, pg 71.
英文原文地址:http://www.edn.com/article/CA6406730.html