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:
Taken from http://www.josepino.com
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.
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 if
Please 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:
If we are going to display the number 5 at the fifth display, we need to set the DATA variable as 01101101 [binary] because each segment gets the binary value as: A=1, B=0, C=1, D=1, E=0, F=1, G=1, DP=0
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
So, we get the variable DATA as 11001101 after shifting 4 bits, then it is sent to the port B and the bit 4 is set as 0. The PORT B will be 11x011x1 were x = Input port or Hi-Z.
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:
The refresh rate for each LED must be greater than 50Hz. This is to avoid flickering.
The port used for charlieplexing should be tri-state.
The forward voltages of the LEDs should be the same on each one. This will avoid other LEDs to lit when it's not intended.
The reverse voltage of the LED should be greater than the voltage used for the display. If a single LED fails, either by becoming an open circuit, by becoming a short-circuit, the impact will be catastrophic for the display.
For more information about Charlieplexing or multiplexing multiple LEDs,
here is an article
that I wrote back in 2006.