Eight-pin microcontrollers offer numerous peripheral features. However, the maximum number of I/O pins available is often limited to six, since two pins would be required for the chip's power supply. So, it can be challenging to design systems based on these devices, especially if they involve a significant display requirement.
For instance, controlling a large number of LEDs is a problem with eight-pin microcontrollers, unless you resort to a method called "Charlieplexing." This idea was originally described in Don Lancaster's August 2001 Tech Musings (www.tinaja.com/glib/muse152.pdf) in addition to Maxim Integrated Products application note AN1880 (http://pdfserv.maxim-ic.com/en/an/AN1880.pdf).
In general, Charlieplexing allows N I/O pins to control N*(N 1) LEDs. For example, Figure 1 shows five pins of a microcontroller connected to 20 LEDs. In this Charlieplexed display, one of the pins is an output pin set to logic 1 and another pin is an output set to 0. The rest of the pins are set as inputs in a high-impedance state.
Thus, at any given time, only one of the LEDs is turned on. After a suitable delay, this LED is turned off by changing the pin configuration and the next LED is turned on. The rate at which each LED is turned on must be more than 50 Hz to avoid any noticeable flicker. So, for 20 LEDs the overall display refresh rate should be at least 1000 Hz.
Our application required a counter with a maximum count of 200. We could easily have used a suitably complex microcontroller, but we decided to try using the most inexpensive eight-pin device available. We selected the Atmel AVR ATtiny15. The counter input was from a pushbutton switch, so only five of the six I/O pins would be available for the display. Because the counter was meant for hexadecimal-literate engineers, we decided to have a two-digit display with the count going from 00 to FF(Hex). Even so, fitting a two-digit display seemed difficult.
We used a Charlieplexed display to arrange the LEDs in the required two-digit, seven-segment format, which would serve our purpose (Fig. 2). We chose 3mm, high-brightness LEDs. Each segment of the seven-segment display consists of three LEDs set in parallel.
All resistors are 100-Ω, 1/4-W CFRs. The peak current through the LEDs is about 30 mA with a 5-V supply, but the system works at any supply voltage from 3 V to 6 V. The refresh rate was set to 1000 Hz, derived from the ATtiny15's internal system clock of 1.6 MHz. The circuit can also be adapted to work with a number of other ATtiny devices or eight-pin PIC microcontrollers.
The control program for the ATtiny15 microcontroller for the counter application described can be downloaded here.
Although our implementation is for a simple counter, the system is expandable. The display can be increased to a 2-1/2-digit format. Also, many eight-pin microcontrollers have a built-in analog-to-digital converter channel that can be used together with a 2-1/2-digit display to build a voltmeter. Similarly, the technique can implement a frequency counter with an auto-ranging feature.
A limitation with Charlieplexing is the low duty cycle of the current through each LED. Since only one LED is on at any given time, the duty cycle is 1/\[N*(N 1)\]. For 20 LEDs, the duty cycle of current through the LEDs will be a mere 5%. As the number of LEDs increases, duty cycle decreases. So, to maintain a particular average current through the LED, the peak current would have to increase proportionately. At some point, the peak current would exceed the LED ratings, and Charlieplexing would not be possible.
One other consideration—only microcontrollers that allow each pin to be configured as an output as well as a high-impedance input can be used. Thus, a typical 8051 isn't suitable to control a Charlieplexed LED display.
IDEAS FOR DESIGN WANTED
Send us your Ideas for Design. We'll pay you $150 for every Idea for Design that we publish. In addition, this year's top design as selected by our readers will earn an additional $500, with two runners up each receiving $250. You can submit your Ideas For Design via:
• E-mail: firstname.lastname@example.org
• Postal mail to:
Ideas For Design
45 Eisenhower Dr., Suite 550
Paramus, NJ 07652
Go to www.electronicdesign.com for our submission guidelines.