luscious electric delight (L.E.D.):
Contributors:
Leif Krinkle
leifkrinkle@leifkrinkle.com
http://www.leifkrinkle.com/
Rob Faludi
rob@faludi.com
http://www.faludi.com/
Zach Layton
zachlayton@gmail.com
http://www.zachlaytonindustries.com/
Benedetta Piantella
bp432@nyu.edu
http://itp.nyu.edu/~bp432/blug/
L.E.D.
We set out to harness the power of the LED. As a single discrete element, the LED is a simple binary indicator. By grouping many LEDs together, like pixels, more and more information can be conveyed. The trick is to find the most efficient way of addressing the state of each LED.
ROW COLUMN SCANNING
We started experimenting with “row/column scanning”. This term refers to how the columns of shared anodes(+) and rows of shared cathodes(-) in an LED matrix can be quickly turned on and off to control a single LED within the matrix. Because the number of LEDs with in a matrix will always be fewer than the total number of rows and columns, it is more efficient to quickly address the columns and rows than each individual LED.
We first soldered a 4x4 matrix of LEDs by hand.
By sharing the cathodes of LED in a row and the anodes of each LED in a column we were able to address the 16 LEDs by connecting only the 4 rows and 4 columns to my microcontroller. By quickly changing the states of the pins on the microcontroller from high(+) to low(-) we could create animations and motion across the LED matrix. An individual LED could be lit and its neighbors darkened by quickly turning that LED’s anode(+) column pin high and its cathode(-) row low, then grounding the surrounding anode(+) columns by bringing them low and shunting the surrounding cathode(-) rows by bringing them high.
MAX7221 SEVEN SEGMENT
A simpler way of showing data like numbers and crude letters would be to use a segmented display.
These displays come in many arrangements and varying numbers of segments. The most common and easiest to use is the 7-segment LED display.
All the led in the display share a common cathode(-). By grounding the common cathode(-) and bringing a combination of the 7 anode(-) pins any number from 0 to 9 can be represented on the display. With the 7-segment display, as opposed to the LED matrix, we are addressing each LED individually, which isn’t very efficient.
Using a driver IC, like the Maxim 7221 or 7219, solves this efficiency problem. By connecting the 7-segment display to the driver IC, only three pins are required for communication between the driver IC and the microcontroller to control the display. Using a clock pin and a data pin, bits are shifted from the microcontroller to the driver IC using a simple SHIFTOUT command in PIC Basic. The driver then displays the number represented by the byte shifted to it. The 7219 is very easy to use, plus the driver can control 8 7-segment displays and multiple drivers can be chained together to display any number of digits.
SHIFT REGISTER / PERSISTENCE OF VISION
The Maxim 7219 is an intelligent shift register. A simple shift register can take serial data shifted in, like the 7219, but instead of translating that data for an LED display, it displays those bits in parallel by bring its pins high or low corresponding to the order of bits received. This can be used to set the individual states of many LED’s. The state of each LED can be changed very quickly. I used the Allegro A6278 to control 16 LEDs. A pattern was sent very quickly from the microcontroller to the A6278 so quickly the pattern was unperceivable unless the LED were quickly moved from side to side. This phenomenon is known as persistence of vision, meaning that if a light is moved quickly in front of the eyes, the brain will retain the image for a brief moment. If an on/off pattern is quickly displayed along a single column of LEDs and the column is moved quickly, the brain will retain each state of the column in space for the brief period of time, thus seeing the pattern displayed on the column. Using only 16 LEDs an image could be seen 24 pixels across by 16 pixels tall when the LED were shaken back and forth by hand. The display area for a persistence of vision display is dependant on how quickly the display can cover that space in the brief period the brain takes to update.
MAX6953/LED MATRIX/I2C
The MAX7219 worked well with the 7-Segment displays, and the A6278 worked well for 16 individual LEDs, but something larger, like an LED matrix display, requires something slightly more sophisticated to quickly and effectively control the thousands of LEDs in a large LED matrix display. Maxim makes the MAX6953 specifically designed to control multiple 5x7 LED matrices. The microcontroller communicates to the MAX6953 using a two-wire I2C synchronous serial communication. I2C uses a clock line and a data line, because the data is transmitted along side a clock, the data can be transmitted from the microcontroller to the driver extremely fast. I2C routines were easily used in PIC Basic, to configure the MAX6953 and display ASCII characters on 4 5x7 led matrices.
The MAX6953 has 104 pre-loaded characters, but what makes them much more useful than just displaying text are the 24 user definable characters. These fonts can be updated regularly to display graphics and moving images. The MAX6953 has an addressing feature, each IC can be set to one of 16 addresses, meaning there can be 16 MAX6953s on a single I2C bus, that’s 64 5x7 LED matrices, or 2400 LEDs.
PIC-C/INTERRUPTS
PIC Basic was fine for telling to the MAX6953 to display pre-loaded fonts, but it would take something much faster to continually update graphics on an array of 12 MAX6953s.
PIC-C allows code to be written with closer access to the inner workings of the microcontroller. PIC-C is a little harder to use than PIC Basic, but with a lot less overhead the code runs much more efficiently.
I2C communication capabilities are built into a lot of PIC microcontrollers, but we were not able to get the hardware I2C bus to cooperate, so we found a software I2C library online.
Fast I2C communication between the microcontroller and the MAX6953 was made quickly using PIC-C and the software I2C library.
Not only would the microcontroller have to communicate data quickly to the drivers, it would also have to be constantly listening for new data coming in from a remote computer generating the graphics. In this case the microcontroller would have to enable an interrupt so that it could be sending data to the LED display and receiving data from the remote controller at the same time, without missing a beat. The incoming serial data would be read into a buffer, and as soon as the microcontroller was able to, it would grab the data in the buffer and send it out to the array of MAX6953s.
It was a trick to process the data from a computer image into an array of bytes that could be sent to the MAX6953 array and displayed at moving images on the LED display. Each of the MAX6953 controlled 4 5x7 LED matrices. Each matrix was set to display one of 4 user definable fonts in the driver’s memory. Each column of 7 LEDs in each user definable font is set by a byte representing the binary on/off pattern of that column. There are 5 columns for each matrix’s font, 4 matrices per driver, so 20 bytes were given along with the driver’s address to create a custom graphic on each of the 12 drivers. By using a baud rate of 57.6kbps from the computer to the microcontroller and high speed I2C from the microcontroller 252 bytes were sent to the 12 MAX6953s every frame, achieving a continuous frame rate of 30fps.
m_i2c_1.c
EAGLE/ADVANCED CIRCUITS
Once everything was tested on a breadboard, we commited the design to a printed circuit board (PCB). Using Eagle CAD we drew the circuit schematic, then arranged and routed my PCB layout. We decided to make the system modular so that modules could be easily added, removed, or replaced. Each module would have one MAX6953, one 3.3V power regulator, the appropriate capacitors and resistors, as well as a pair data/clock and power/ground connections on either side of the module so that power and data could be easily chained from one module to another. The design was submitted to Advanced Circuits and within a week we got our PCBs ready to stuff, solder, and hook together.
Photos by:
1 - Sai Sriskandarajah
2 - Benedetta Piantella
As seen on Make Blog: http://www.makezine.com/blog/archive/2007/03/luscious_electric_delight.html