Charlieplexing


Charlieplexing is a technique for accessing a large number of LEDs, switches, micro-capacitors or other I/O entities, using relatively few tri-state logic wires from a microcontroller. These I/O entities can be wired as discrete components, x/y arrays, or woven in a diagonally intersecting pattern to form diagonal arrays.

Etymology

Although the technique was introduced in 2001 by Maxim Integrated, the name "Charlieplexing", however, first occurred in a 2003 application note. It was named after Charles "Charlie" M. Allen, an applications engineer of MAX232 fame, who had proposed this method internally.

How and why to use Charlieplexing

The simplest way to address a single pixel is to run a wire out to it and another wire back to ground, but this requires a lot of wiring. A slight improvement is to have everything return on a common ground, but this still requires one wire for each pixel or button. For an X by Y array, X*Y pins are required.
With tri-state logic pins, matrix wiring needs only X+Y pins and wires. Each X and each Y take turns being on vs being disconnected; the disadvantage is that each light is only powered at most 1/ of the time. If there is enough fan-out, the Y pins can be left always on, and all checked in parallel. The refresh can then happen every 1/X of the time, but the X wires each need to pass enough current to light up Y lights at once.
Charlieplexing is a further improvement on matrix wiring, which enables the I/O entities to be connected between any two microcontroller I/O pins. Instead of X horizontal wires meeting Y vertical wires, every wire meets every other wire. Assuming diodes are used for the connections, Charlieplexing needs only about half as many pins as a conventional matrix arrangement, at the cost of more complicated mapping. Alternatively, the same number of pins will support a display nearly four times as large.
VccGNDHi-ZMatrixSwitchLED
123,4
213,4
132,4
312,4
142,3
412,3
231,4
321,4
241,3
421,3
341,2
431,2

For example, with 4 I/O pins, standard x/y matrix multiplexing distinguishes only 4 positions. Pins representing the same direction can never pair with each other.
With Charlieplexing, each pin can pair with any other pin, so those same 4 I/O pins have 6 unique pairings: all those available to matrix multiplexing, but also and.
Because the microcontroller can send current in either direction, and diodes can filter out one direction, each connection can address two diodes separately. In this example, 4 pins with six connections can identify 12 independent diodes. Doubling connections with diodes isn't unique to Charlieplexing, but is rarely done unless I/O pins are scarce enough to at least consider Charlieplexing.
Although Charlieplexing is more efficient in its use of I/O lines, the mapping from I/O lines to a physical location is usually more complicated.
Other issues that affect standard multiplexing but are exacerbated by Charlieplexing include:
  • consideration of current requirements and the forward voltages of the LEDs.
  • a requirement to cycle through the in-use LEDs rapidly so that the persistence of the human eye perceives the display to be lit as a whole. Multiplexing can generally be seen by a strobing effect and skewing if the eye's focal point is moved past the display rapidly.

    Origin

The Charlieplexing technique was introduced by Maxim Integrated in 2001 as a reduced pin-count LED multiplexing scheme in their MAX6951 LED display driver.
Also in 2001, when the name "Charlieplexing" became common, Don Lancaster illustrated the method as part of his musings about the "N-connectedness" problem, referring to Microchip Technology, who had already discussed it as "complementary LED drive technique" in a 1998 application note and would later include it in a tips & tricks booklet.
While Microchip did not mention the origin of the idea, they might have picked it up in the PICLIST, a mailing list on Microchip PIC microcontrollers, where, also in 1998, Graham Daniel proposed it to the community as a method to drive rows and columns of bidirectional LEDs. Daniel at the time had created simple circuits with PIC 12C508 chips driving 12 LEDs off 5 pins with a mini command set to set various lighting displays in motion.
The method, however, was known and utilized by various parties much earlier in the 1980s, and has been described in detail as early as in 1979 in a patent by Christopher W. Malinowski, Heinz Rinderle and Martin Siegle of the Department of Research and Development, AEG-Telefunken, Heilbronn, Germany for what they called a "three-state signaling system".
Reportedly, similar techniques were already in use as early as 1972 for track signaling applications in model railroading.
Display multiplexing is very different from multiplexing used in data transmission, although it has the same basic principles. In display multiplexing, the data lines of the displays are connected in parallel to a common databus on the microcontroller. Then, the displays are turned on and addressed individually. This allows the use of fewer I/O pins than it would normally take to drive the same number of displays directly. Here, each "display" could, for instance, be one calculator digit, not the complete array of digits.
With traditional multiplexing I/O pins can drive a maximum of LEDs, or listen to that many input switches. Charlieplexing can drive LEDs, or listen to buttons even if directionality is not enforced by a diode.

Tri-state multiplexing (Charlieplexing)

The Charlieplexing configuration may be viewed as a directed graph, where the drive pins are vertices and the LEDs are directed edges; there is an outward-pointing edge connected from each vertex to each other vertex, hence with n drive pins there are total edges. This equates to n pins being able to drive n2n segments or LEDs.
PinsLEDs
22
36
412
520
630
742
856
972
1090
11110
12132
13156
14182
15210
16240
20380
24552
32992
401,560
482,256
563,080
644,032
nn2 − n

If the number of LEDs is known, then the number of pins can be found from the equation:, the result being rounded to the nearest whole number.
Example: If L = 57, then √L = 7.549, and 1 + √L = 8.549; the nearest whole number to this is 9, so 9 pins are needed to drive 57 LEDs.
If L = 56, then √L = 7.483, and 1 + √L = 8.483; the nearest whole number to this is 8, so 8 pins are needed to drive 56 LEDs.
; Origin of the equation in Charlieplexing:
Unlike in a traditional x/y multiplexed array, where a sub-set of conductive elements crosses a different sub-set of conductive elements, in a "fully Charlieplexed" multiplexed array, each conductive element crosses every other conductive element.
Six conductive elements in a standard x/y multiplexed array forms a maximum of nine unique intersections.
The other diagrams also show six conductive elements, but here all six elements cross over themselves, forming a multiplexed array of 36 intersections. LEDs are shown placed at every intersection. However, each conductor also crosses itself at the diagonal. Horizontal conductor 1 crosses vertical conductor 1, horizontal conductor 2 crosses vertical conductor 2, etc. This means that six of these LEDs are short-circuited. The six diagonal LEDs will, therefore, never light up, because no voltage can ever develop across them, so has to be subtracted from the total. There is no point in installing these LEDs.
This leaves 30 LEDs that can be uniquely addressed and lit up independently.
Conductor "a" crossing conductor "b" is distinguishable from conductor "b" crossing conductor "a" because LED polarity is reversed. For example, when conductor 3 is positive and conductor 2 is negative, current flows through, and lights up LED D8, but when conductor 3 is negative and conductor 2 is positive, current flows through, and lights up LED D9.
These reverse polarity LED pairs are called complementary pairs. This diagram has 15 complementary pairs, allowing 30 LEDs to be lit independently.
The 6 unusable diagonal LEDs can be conveniently replaced by actual bidirectional shortcuts.
By adjusting diagonally the form of horizontal and vertical connectors along the short-circuited main diagonal of the original matrix, this can be easily transformed into an array of 5 × 6 or 6 × 5 LEDs arranged on a regular grid.
A similar pattern could be used for a 10 × 11 matrix that could be used to drive up to 110 keys on a modern PC keyboard, where each key switch includes a small serial diode or LED, so that only 11 pins would be needed to individually control all of them.
Charlieplexing can also be used to significantly reduce the number of controlling pins for much larger matrixes, such as modern digital displays with high resolution. E.g. for a 4K RGB display at 3840 × 2160, this requires more than 8 millions individually addressable pixels, each featuring at least 3 colored LEDs or LCD cells, for a total of nearly 25 millions LEDs or LCD cells. Using a conventional x/y multiplexing would require at least  = 10320 controlling pins and many selection chips for controlling rows and columns all around the panel of LEDs or LCD cells. But with Charlieplexing, this can be reduced to only 63 controlling pins for the selection gate of display columns, plus 46 × 3 controlling pins for the selection and power-activation of RGB display rows, by a single transistor for each row or column ; these controlling pins can easily fit around the output pins of one or two controller chips, even if we add the few additional pins needed on the controller for power, ground, clocks and I/O buses, surface-mounted with a high density and low cost on a single-layer PCB, and no need of complex routing and interconnection holes between layers; a dual layer is needed only for the basic Charlieplexing matrix mounted on borders of the panel itself.
Positions in the Charlieplexed matrix are not reduced to be just LEDs or diodes, they can be filled as well by two pins of a transistor so that its third pin is used as output to further control other devices, such as the horizontal and vertical selection lines of a large flat display panel.