您当前的位置:五五电子网电子知识单片机-工控设备DSP/FPGA技术驱动20个对数/线性点/柱状LED的微控制器 正文
驱动20个对数/线性点/柱状LED的微控制器

驱动20个对数/线性点/柱状LED的微控制器

点击数:7583 次   录入时间:03-04 11:46:02   整理:http://www.55dianzi.com   DSP/FPGA技术

  自做模拟电路到LM3914显示 驱动 为用户提供可编程性。

  美国国家半导体公司的老产品LM3914点/柱状显示驱动器已面市20多年了,但仍被广泛应用。LM3914可以感知模拟电压,并通过点状模式点亮10个 LED 中的一个,或以柱形图模式逐个点亮LED的方法,显示电压大小。最近,有个应用需要显示模拟输入电压,要求具有线性或对数刻度格式下10个以上等级的LED显示。根据 LM3914的数据手册,可以将多个3914级联,从而获得10个以上LED的显示(参考文献1),但即使这么做,LM3914也只能线性显示输入电压。(编辑注:美国国家半导体还提供 LM3915,这是一款对数型3dB步长版,而LM3916适于音频应用,以音量单位显示输入。)

  本应用的要求超出LM3914提供的灵活性,使用一个基于Atmel AVR系列ATTiny13 微控制器 电路,其具有1kB程序存储器、一个四通道10位ADC,以及6个通用I/O 口。调整电路固件就可以实现0~5V输入电压范围内的线性或对数型转换。

  图1中电路以20个LED连续显示输入电压。当开关S1关闭时,将显示冻结在其后电流水平的读数上。微控制器6个I/O口中的5个控制着所有20个LED和开关。剩下的I/O口配置成ADC输入通道,接收模拟输入电压。微控制器采用 Charlieplexing的方法(这是一种用I/O口线驱动多达N×(N-1)个LED的方法),只用5个I/O口就可以驱动20个 LED(参考文献2 ~ 4)。

电路以20个LED连续显示输入电压

  固件用C语言编写,并用AVR-GCC编译,这是Windows和Linux版本下C和汇编编译器的免费软件。它使用可自由运 行在中断驱动模式的Tiny13的内部10位ADC,将模拟输入电压转换成数字量。每次转换完成时,ADC 产生一个由子程序读的中断,这个中断将 ADC转换输出结果保存在一个共享变量中。

  为产生无闪烁的显示,一个内部定时器由9.6MHz系统时钟产生一个1875Hz的中断,以大于90Hz的速率驱动多路LED。将ADC计数值除以一个常数得到输入电压的线性显示。用查找表衡量ADC计数产生对数显示。图2表示确定该查找表值的对数转换曲线。用于线性和对数显示的 ATTiny13控制程序版本都可从本设计实例处下载。可对源代码做修改,而只显示0V~5V输入电压中的某个子区间。例如,可以设定1V~3V为线性显示范围,或2V ~ 3V输入电压为对数显示。

查找表值的对数转换曲线

  英文原文:

  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.)

www.55dianzi.com

  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 LED s 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




本文关键字:控制器  DSP/FPGA技术单片机-工控设备 - DSP/FPGA技术

《驱动20个对数/线性点/柱状LED的微控制器》相关文章>>>