Charlieplexing 7-segment LED display.
Also known as "Multiplexing", here is a method how to control eight 7-segment displays using only 9 microcontroller ports. (August 20, 2009)
Charlieplexing is a technique proposed in early 1995 by Charlie Allen at Maxim Integrated Products for driving a multiplexed display in which relatively few I/O pins on a microcontroller.1 I saw for the first time the Maxim application notes back in 2005 but I was not able to create a software to use a 'Charlieplexed' display. Today, I did finish an algorithm to be able to control eight 7-segment LED display using 8 pins from a microcontroller, 9 pins if decimal point required.
Let's see the schematic:

Each pin, from B0 to B7 is connected directly to the common anode or common cathode of the 7-segment LED dsplay, the others pins are connected to control the segments of each display.
Each display is connected as follows:
First: B0-CC/CA, B1-A, B2-B, B3-C, B4-D, B5-E, B6-F, B7-G, A0-DP
Second: B0-A, B1-CC/CA, B2-B, B3-C, B4-D, B5-E, B6-F, B7-G, A0-DP
Third: B0-A, B1-B, B2-CC/CA, B3-C, B4-D, B5-E, B6-F, B7-G, A0-DP
Fourth: B0-A, B1-B, B2-C, B3-CC/CA, B4-D, B5-E, B6-F, B7-G, A0-DP
Fifth: B0-A, B1-B, B2-C, B3-D, B4-CC/CA, B5-E, B6-F, B7-G, A0-DP
Sixth: B0-A, B1-B, B2-C, B3-D, B4-E, B5-CC/CA, B6-F, B7-G, A0-DP
Seventh: B0-A, B1-B, B2-C, B3-D, B4-E, B5-F, B6-CC/CA, B7-G, A0-DP
Eighth: B0-A, B1-B, B2-C, B3-D, B4-E, B5-F, B6-G, B7-CC/CA, A0-DP
To display some data, we need to define the position and the data. Let's assume the first display is the left one and the last one is located at the right position. Here is the procedure to control this Charlieplexed display:
Define variable DATA Define variable POSITION if POSITION = 1 port A0 = DATA BIT 7 ; shift all bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 DATA BIT 5 = DATA BIT 4 DATA BIT 4 = DATA BIT 3 DATA BIT 3 = DATA BIT 2 DATA BIT 2 = DATA BIT 1 DATA BIT 1 = DATA BIT 0 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B0 as output PORT B = DATA PORT B0 = 0 ; 0 for Common cathode end if if POSITION = 2 port A0 = DATA BIT 7 ; shift 7 bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 DATA BIT 5 = DATA BIT 4 DATA BIT 4 = DATA BIT 3 DATA BIT 3 = DATA BIT 2 DATA BIT 2 = DATA BIT 1 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B1 as output PORT B = DATA PORT B1 = 0 ; 0 for Common cathode end if if POSITION = 3 port A0 = DATA BIT 7 ; shift 6 bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 DATA BIT 5 = DATA BIT 4 DATA BIT 4 = DATA BIT 3 DATA BIT 3 = DATA BIT 2 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B2 as output PORT B = DATA PORT B2 = 0 ; 0 for Common cathode end if if POSITION = 4 port A0 = DATA BIT 7 ; shift 5 bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 DATA BIT 5 = DATA BIT 4 DATA BIT 4 = DATA BIT 3 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B3 as output PORT B = DATA PORT B3 = 0 ; 0 for Common cathode end if if POSITION = 5 port A0 = DATA BIT 7 ; shift 4 bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 DATA BIT 5 = DATA BIT 4 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B4 as output PORT B = DATA PORT B4 = 0 ; 0 for Common cathode end if if POSITION = 6 port A0 = DATA BIT 7 ; shift 3 bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B5 as output PORT B = DATA PORT B5 = 0 ; 0 for Common cathode end if if POSITION = 7 port A0 = DATA BIT 7 ; shift 2 bits DATA BIT 7 = DATA BIT 6 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B6 as output PORT B = DATA PORT B6 = 0 ; 0 for Common cathode end if if POSITION = 8 port A0 = DATA BIT 7 ; shift 1 bit set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 set PORT B7 as output PORT B = DATA PORT B7 = 0 ; 0 for Common cathode end ifPlease be aware the above listing IS NOT A PROGRAM or written in any specific programming language. It's only an explanations of the steps needed to control a Multiplexed 7-segment LED display.
Let's see how it works:

Then, we need to process the variable DATA as indicated when the POSITION = 5:
port A0 = DATA BIT 7 ; shift 4 bits DATA BIT 7 = DATA BIT 6 DATA BIT 6 = DATA BIT 5 DATA BIT 5 = DATA BIT 4 set PORT B as input where data bit = 0 set PORT B as output where data bit = 1 PORT B = DATA PORT B4 = 0 ; 0 for Common cathode

The left picture shows the result of the process.
The main advantage, and the only one, of Charlieplexing is that only 9 IO ports are used for eight displays. The problems that can be presented are:
For more information about Charlieplexing or multiplexing multiple LEDs, here is an article that I wrote back in 2006.
References:
1 Wikipedia
< Anthony Sotillet's POV Display | Homepage microcontroller Index |
Four Digit Counter> |