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:

 

Charlieplexed 7-segment display

 

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 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:

 

Five with 7 segment display 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

 

Result of charlieplexing 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.

     

    References:
    1 Wikipedia

     


     < Beakman MotorHomepage
    howto Index
    Coin Mechanism for Coin-operated Projects I.> 

     

    If any information, data, picture or design infringes a copyrighted material, please send me an e-mail asking to remove it along with the supporting data.
    Some features may not work with Google Chrome. © 2006-2010 Jose Pino - Powered by JPC Alpha