User Tools

Site Tools


shiftbar

ShiftBar

ASCII ShiftBars are optimized to drive clusters of LEDs, or commonly available 12V common-anode RGB LED bars. It has three LED current sink outputs and a small controller chip, the Allegro A6281. The A6281 provides 10-bit PWM and 7-bit current control for each of the LED channels. It uses a simple clocked serial interface to receive a 10-bit brightness value for each color, resulting in over a billion possible colors. Each input is buffered and output on the other side of the module. This allows each ShiftBar to repeat the signal to the next, allowing longer cable runs between elements without excessive loading of microcontroller I/O pins.

ShiftBar elements feature current control and automatic overtemperature control (an overheating channel driver will shut off until it has cooled). Each channel can also be adjusted with a separate current control register, for fine tuning of each LED if close brightness matching is necessary. The chip also has an overall current limit setting that is controlled with the onboard potentiometer. The integrated voltage regulator powers the internal logic, allowing a single 5.5 to 17 volt supply rail to power the ShiftBar chain. A screw clamp terminal is also provided for a direct power connection.

Features

Controller: Allegro A6281
LED: User-supplied, up to 150mA per channel
Current: 450mA maximum (all channels on)
Power Supply: 5.5V to 17V DC
PCB Size: 1.70“ x 0.84”
Pin Spacing: 0.1 inches

Power Connections

The V+ and GND pins power both the LED and the control chip. A separate screw clamp terminal is also provided for a direct power connection, which is recommended to avoid problems caused by voltage drop along a chain of modules. The outermost + and - terminals should be connected to the main power supply bus. ShiftBars require up to 450mA per module when all LEDs are active. The supply voltage should be kept between 5.5 and 17 volts, depending on requirements of the attached LEDs.

As is true of most digital electronics, if you connect power backwards or short contacts with metal objects or other modules on the chain, you WILL destroy the logic chip. Please triple-check all cables and make sure the modules are not in contact with anything conductive BEFORE applying power.

LED Connections

The R, G, and B screw clamp terminals should be connected to the LEDs that you want to control. The LEDs should have their anodes (positive leads) wired together, and connected to the + terminal next to the B terminal. The signal names are only provided for reference, and match the order in all the provided example code. The ShiftBar can also be used to control three channels of LEDs with the same color, or even some other kind of load that requires no more than 150mA and can benefit from 10-bit PWM.

Current Setting Potentiometer

The current setting potentiometer controls the current that will be allowed to flow through the A6281 controller and each of the LED channels. The current setting is only a maximum; the LEDs you attach may already have limiting resistors. Current regulation allows a wider range of input voltages for a given LED array; it will prevent the LEDs from being destroyed if your supply voltage is higher than it should be. On the ShiftBar, the potentiometer adjusts the current limit between 10mA and 150mA maximum for each channel. Rotating the knob in the direction of the arrow indicated on the above photo will increase the current limit.

Data In / Data Out

The DI (Data In) pin carries the actual control information into the ShiftBar. It is the input to an internal 32-bit shift register. Every time data is shifted into the controller, the binary value on the DI pin is placed in Bit 0 of the shift register, and the value in Bit 31 overflows out the DO (Data Out) pin to the next ShiftBar in the chain. Data is shifted in using MSB (most significant bit first).

Clock In / Clock Out

The CI (Clock In) pin controls the shifting process. Each time the CI pin is sent to logic high and low, data is shifted into the DI pin and out of the DO pin. The CI signal is passed through the ShiftBar to the CO (Clock Output) pin, so the next ShiftBar can receive the bits from the DO line.

Latch In / Latch Out

The LI (Latch Input) pin causes the ShiftBar to accept whatever is in its shift register as a new command. If you send the LI pin high and then low after 32 clocks, the first ShiftBar in the chain has all new data from the DI pin. The second ShiftBar contains whatever was already in the first ShiftBar, and so on. To command all ShiftBars in a chain, you must toggle the LI pin after you have shifted data to all ShiftBars; 32 clock cycles times the number of ShiftBars in the chain. The LI pin passes through to the LO (Latch Output) pin.

Enable In / Enable Out

The EI (Enable Input) turns the entire chain on and off. If it is sent to logic high, then it will blank all ShiftBars. When EI is low, all ShiftBars will display the colors specified previously. The EI pin passes through to the EO pin.

Command Format

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
PWM Counter 0 PWM Counter 1 PWM Counter 2 0 X
Dot Correction 0 Clock
Mode
X Dot Correction 1 X X X Dot Correction 2 X ATB ATB 1 X

Each color has 10 bits of the 32 bit command word, as shown in the above diagram. The 10 bits allow PWM (pulse width modulation) control of LED brightness to 1024 possible levels. This is only true if the remaining 2 bits are set to zero. Otherwise, the ShiftBar enters a command mode that allows current control and other parameters. This should always be set as shown in the code below, unless you have a specific reason to do otherwise. Additional information is available at the bottom of page 7 in the A6281 datasheet.

Essentially, when Bit 30 is 1 the ShiftBar enters command mode, the last row of the table above. You can set a 7-bit current control value for each LED, 0 to 127 corresponds to about 33% to 100% power. The Clock Mode setting lets you change the PWM frequency or use an external source; it is normally set to 00 which is an 800KHz internal PWM (please refer to the A6281 datasheet for other settings if needed). The bits marked “X” have no effect on the device. The bits marked “ATB” are for Allegro internal testing, but have the side effect of stopping the output buffers. That means if you accidentally write an ATB due to noise, you must write to each ShiftBar's command register to be able to rewrite the next one.

Since the control mode can set the ShiftBar to unusable modes, it is a good idea to write the control register often. Most of my code writes it each time the color values are written.

Code Example

The following code example works for ShiftBrites, MegaBrites, or ShiftBars.

The following Arduino code illustrates using the built-in SPI hardware for faster updates, though it is not really needed for only two ShiftBrites. This code should flash two ShiftBrites (or ShiftBars, or MegaBrites) alternating red and blue. If a ShiftBrite Shield or Shifty VU Shield is used, you should only have to plug in the cables and attach an external power supply, taking care that the ShiftBrite signal names are matched to the shield signal names.

Once you have this code working, you should be able to use it as a basis for any ShiftBrite application. Simply adjust the NumLEDs definition at the beginning of the program, and then write your desired color values from 0 to 1023 in the LEDChannels array. Once all the colors are in the array, call the WriteLEDArray() function and the ShiftBrites should switch to their new colors.

#define clockpin 13 // CI
#define enablepin 10 // EI
#define latchpin 9 // LI
#define datapin 11 // DI
 
#define NumLEDs 2
 
int LEDChannels[NumLEDs][3] = {0};
int SB_CommandMode;
int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;
 
void setup() {
 
   pinMode(datapin, OUTPUT);
   pinMode(latchpin, OUTPUT);
   pinMode(enablepin, OUTPUT);
   pinMode(clockpin, OUTPUT);
   SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
   digitalWrite(latchpin, LOW);
   digitalWrite(enablepin, LOW);
 
 
}
 
void SB_SendPacket() {
 
    if (SB_CommandMode == B01) {
     SB_RedCommand = 120;
     SB_GreenCommand = 100;
     SB_BlueCommand = 100;
    }
 
    SPDR = SB_CommandMode << 6 | SB_BlueCommand>>4;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_BlueCommand<<4 | SB_RedCommand>>6;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_RedCommand << 2 | SB_GreenCommand>>8;
    while(!(SPSR & (1<<SPIF)));
    SPDR = SB_GreenCommand;
    while(!(SPSR & (1<<SPIF)));
 
}
 
void WriteLEDArray() {
 
    SB_CommandMode = B00; // Write to PWM control registers
    for (int h = 0;h<NumLEDs;h++) {
	  SB_RedCommand = LEDChannels[h][0];
	  SB_GreenCommand = LEDChannels[h][1];
	  SB_BlueCommand = LEDChannels[h][2];
	  SB_SendPacket();
    }
 
    delayMicroseconds(15);
    digitalWrite(latchpin,HIGH); // latch data into registers
    delayMicroseconds(15);
    digitalWrite(latchpin,LOW);
 
    SB_CommandMode = B01; // Write to current control registers
    for (int z = 0; z < NumLEDs; z++) SB_SendPacket();
    delayMicroseconds(15);
    digitalWrite(latchpin,HIGH); // latch data into registers
    delayMicroseconds(15);
    digitalWrite(latchpin,LOW);
 
}
 
void loop() {
 
   LEDChannels[0][0] = 1023;
   LEDChannels[0][1] = 0;
   LEDChannels[0][2] = 0;
 
   LEDChannels[1][0] = 0;
   LEDChannels[1][1] = 0;
   LEDChannels[1][2] = 1023;
 
   WriteLEDArray();
   delay(200);
 
   LEDChannels[0][0] = 0;
   LEDChannels[0][1] = 0;
   LEDChannels[0][2] = 1023;
 
   LEDChannels[1][0] = 1023;
   LEDChannels[1][1] = 0;
   LEDChannels[1][2] = 0;
 
   WriteLEDArray();
   delay(200);
 
 
}
/home/macetec/public_html/docs/data/pages/shiftbar.txt · Last modified: 2015/05/22 00:50 by macegr