Macetech’s ShiftBrite is a high-power RGB LED coupled with an Allegro A6281 backpack. The A6281 uses three 10bit pulse-width modulators to mix millions of colors using the red, green, and blue elements in the RGB LED. Multiple modules can be chained together for bigger projects, like the ShiftBrite table.
The ShiftBrite module is a complete A6281 development board. It doesn’t require any extra parts, just a 5-9volt supply.
The A6281 is one of the most complete RGB LED driver ICs, but it’s only made in a tiny QFN package. The ShiftBrite is a good way to try the A6281 without soldering a small chip.
A bunch of A6281 modules can be chained together. Each module repeats all of the serial input signals on separate output pins, so the A6281 will work over long cable runs.
We used our Bus Pirate universal serial interface to demonstrate the ShiftBrite, but the command sequences will be the same for any microcontroller. We connected the Bus Pirate to the ShiftBrite as shown in the table above.
We setup the Bus Pirate for raw3wire mode (M, 8), and chose open drain outputs (Hi-Z) so we can interface the ShiftBrite at 5volts. The Bus Pirate can’t output 5volts directly, so we enabled the bus pull-up resistors (menu ‘p’ in v2) and attached the pull-up resistor voltage input pin to the 5volt supply. Finally, we enabled the on-board power supply (capital ‘W’).
The LED driver output is only active when the enable pin (EI) is held low.
RAW3WIRE>A <– capital ‘A’, EI pin high, output disabled
RAW3WIRE>a <– small ‘a’, EI pin low, output active
We used the Bus Pirate’s auxiliary pin to toggle the A6281′s enable pin, but you could also bypass this feature by wiring EI directly to ground. A small ‘a’ in the Bus Pirate terminal takes the AUX/EI pin connection low, enabling the LED output.
Two commands update the A6281 settings. The configuration command controls dot correction and clock settings. The LED pulse-width modulator (PWM) command updates the three 10bit values that set the red, green, and blue channel brightness. Both commands are 32 bits (4 bytes) long, bit 30 selects the configuration or pulse-width modulator command. Refer to the chart above, or datasheet page 7.
The interface protocol is like SPI, but the master-input-slave-output pin is unused. Data is sent most significant bit first, starting with bit 31. Commands are sent by clocking 32 bits into the chip and then toggling the latch pin.
Before we can start mixing colors, we need to setup the A628a’s internal clock and write the dot correction values.
RAW3WIRE>0b01000111 0b11110001 0b11111100 0b01111111 ][
WRITE: 0×47 <–write 32bits of data
CS DISABLED <–latch pin high
CS ENABLED <–latch pin low
We wrote the values in binary so it’s easy to follow along in the table above. Remember that bit 31 is sent first, so the order of bits shown here is opposite of what is shown in the table.
The complete setup command is 32 bits (4 bytes) long. Bit 30 sets this as a configuration command (1). Bit 7 and 8 configure the clock source, value 00 configures the 800KHz internal oscillator (datasheet page 7). Three 7bit ‘dot correction’ values fine tune the LED color channels if you want to correct a wonky pixel in a large array (see the register locations in the table above). We set all the dot correction values to full (1111111). Several bits trigger test functions or don’t have a purpose, these should be entered as 0.
After entering 32 bits, toggle the A6281 latch pin (][) to lock the data into the register. Now that the chip is configured and the output enabled, we can finally play with the LED.
RAW3WIRE>0b00111111 0b11111111 0b11111111 0b11111111 ][
First, turn all the colors to full. Bit 31 (0) is ignored, bit 30 (0) indicates a LED pulse-width modulator update command, and the remaining bits set all three channels to 100%. The three PWM values control the output intensity of each color as follows: blue (bits 29:20), red (bits 19:10), and green (bits 9:0). Raise and lower the latch pin (][) to end the command.
Next, test each each color individually.
RAW3WIRE>0b00111111 0b11110000 0b00000000 0b00000000 ][
Bit 30 (0) signals an LED PWM update command, followed by a 100% setting for the blue channel (1111111111) and 0% settings for the red and green channels. When we toggle the latch pin (][) the new values are saved and the LED color changes to blue.
RAW3WIRE>0b00000000 0b00001111 0b11111100 0b00000000 ][
This time we’ll set the LED to 100% red. Bit 30 (0) signals an LED PWM update command, followed by a 0% setting for the blue channel, a 100% setting for the red channel (1111111111), and a 0% setting for green. When we toggle the latch pin (][) the LED color changes to red.
RAW3WIRE>0b00000000 0b00000000 0b00000011 0b11111111 ][
Finally, we set the LED to 100% green. Bit 30 signals an LED PWM update, followed by 0% settings for the blue and red channels, and a 100% setting for the green channel (1111111111). Toggle the latch pin (][) and the LED color changes to green.
Like this post? Check out the parts posts you may have missed. Want to request a part post? Please leave your suggestions in the comments.
Hack a Day review disclosure: Macetech gave us a couple free ShiftBrites at Maker Faire 2008.