20161212T16:30 Charlieplexing - OrCarin/CET-3510-1KB-Contest GitHub Wiki
Driving multiple LEDs with an Arduino is generally limited by the number of I/O pins. One method of increasing this limit is with multiplexing, particularity charlieplexing. This relies on tri-state logic, that is three states for each pin (High, Low, and Float). An array of up to n by n-1 LEDs can be controlled with n many pins. This is best illustrated with the following schematic for a 4:12 scheme:
Initial prototyping was preformed on a 4:12 design, that is controlling 12 LEDs with only 4 pins. Each row is connected in a common cathode configuration, while each column is connected in a common anode configuration. LEDs are powered row by row, selecting each row by connecting to ground. The other three pins are used to power each LED, and should be set to High to power an LED, or High-Impedence to keep an LED off.
Charlieplexing arrays can easily be expanded by adding an additional row and column. For the ease of use with 7 segments leds, the following 8:28 common cathode scheme was developed (the limit is 8 pins to 56 LEDs). One bit will be used as the selector, with the other 7 to control each of the LEDs.
Although 8 pins could power up to 56 LEDs in an 8:56 scheme, only 28 will be used for our application. Powering each display can be done with a 8 bit output to DDRD (with the selector bit set to 1) to set which LEDs to be turned on by configuring them as low impedance by setting them to 1, or high impedance by setting them to 0. The same set of 8 bit output is also sent to PortD (with the selector bit set to 0) to set the voltage levels on each pin, high to turn on a LED and low to turn a LED off. This was found to have a vastly smaller code footprint than typical Arduino code, since we can control up to 8 pins with a single byte.
It is important to note that switching between four sets of LEDs reduces overall brightness since the Duty Cycle is 25%. Therefore, the 330 ohm resistors were swapped for 100 ohm resistors to deliver more power to the LEDs. The overall power delivered to the LEDs of 62.5 mW at this duty cycle (5v^2/100ohm/4) was within the 100 mW operational limit of the LEDs. It is conceivable to fully utilize the 8 rows, perhaps upgrading to 2 sets of 2 digit displays and using 47 ohm resistors.
Another important note is that all elements in each rows must be functional, or other parts of the array will not behave as expected. For example, if an LED becomes an open circuit (burning out or becoming disconnected), attempting to power this damaged LED can turn on other LEDs in the array.
Pins 0 to 7 were selected to control our LEDs. However, the Arduino Uno introduces has a limit since pins 0 and 1 are used for uploading our programs. While not entirely necessary during out current stage of development, de-chipping an Arduino is necessary so that the programmer does not interfere with the LEDs.