OctaBar, Shift shield, trouble

Hello everyone,
I’m having some trouble working with the Uno, shiftyVu, shift shield, and two OctaBars. Here’s an overview of what i’m trying to do: there are 3 modes, a sound reactive mode, sequenced slow fade, and manual mixture using pots. and a single button to switch between them with indicator leds. The problem i’m running into started with the octabars; i had the following code running with just 4 of the 16 satelites to test with and things were going smoothly, when i plugged in the second octabar i noticed none of its ports nor the 8th port on the first bar were working and it may not have been the entire time as i hadn’t been using it up to that point, in total i had 6 of 16 ports working. I updated the code and still nothing. when i got it working again the lights seemed to only illuminate blue with a slight hue of green, despite having brought the red and green channels to 1023, still only 6 out of 16 working ports. I have unplugged the second octabar and taken the shiftyVu shield out of the equation and plugged the connector cable for the remaining bar and satellites directly into the shift shield and now i get no lights whatsoever, aside from the power indicators on the arduino and octabar. I have ~13V going to the bar, i’ve tried several power configurations for the arduino including 9V 300mA to the shield, also to the arduino itself, and the pwr pass through jumper with no luck, even tried a different Arduino. what i thought was a software problem may be a hardware problem, though i’m hoping it’s just something i over looked in the code; the initial problem seemed as if i just wasn’t shifting over enough registers. If anyone has some ideas it would be much appreciated.

Here is the code i’m running, it still needs some work so please excuse the syntax and bulk:

#include <math.h>
#include <avr/pgmspace.h>
#include "rgbdefs.h"

#define clockpin 13 // CI
#define enablepin 10 // EI
#define latchpin 9 // LI
#define datapin 11 // DI
#define NumLEDs 16
#define NumLEDsVu 10


float adc1avg = 0;
float adc2avg = 0;
long prevMillis = 0;
long interval = 2000;
int LEDChannels[NumLEDs][3] = {
  0};
int LEDChannelsVU[NumLEDsVu*2][3] = {
  0};
int SB_CommandMode;
int SB_RedCommand;
int SB_GreenCommand;
int SB_BlueCommand;
int CRegCount = 0;
int LEDModeOnePin = 4;
int LEDModeTwoPin = 5;
int LEDModeThreePin = 6;
volatile int Mode = 1;
PROGMEM prog_uchar Gradients[4][24] = {
  {
    0,0,0, 25,25,0, 50,50,0, 100,100,0, 150,150,0, 200,200,0, 255,255,0, 0,0,0  }
  ,
  {
    255,0,0, 255,0,0, 255,0,0, 255,0,0, 255,0,0, 255,0,0, 255,0,0, 0,0,255  }
  ,
  {
    0,255,0, 0,255,0, 0,255,0, 0,255,0, 0,255,0, 0,255,0, 0,255,0, 255,0,0  }
  ,
  {
    255,255,255, 255,0,255, 0,0,255, 0,255,0, 0,255,0, 255,255,0, 255,0,0, 0,0,0  }
};

byte PlasmaGradient[8][3] = {
  0};

void SelectGradient(int gradient) {

  for (int d = 0; d < 8; d++) {

    PlasmaGradient[d][0] = pgm_read_byte_near(Gradients[gradient] + d * 3);
    PlasmaGradient[d][1] = pgm_read_byte_near(Gradients[gradient] + d * 3 + 1);
    PlasmaGradient[d][2] = pgm_read_byte_near(Gradients[gradient] + d * 3 + 2);

  }
}


void setup() {
  Serial.begin(115200);
  pinMode(datapin, OUTPUT);
  pinMode(latchpin, OUTPUT);
  pinMode(enablepin, OUTPUT);
  pinMode(clockpin, OUTPUT);
  pinMode(LEDModeOnePin, OUTPUT);
  pinMode(LEDModeTwoPin, OUTPUT);
  pinMode(LEDModeThreePin, OUTPUT);
  analogReference(INTERNAL);
  SPCR = (1<<SPE)|(1<<MSTR)|(0<<SPR1)|(0<<SPR0);
  digitalWrite(latchpin, LOW);
  digitalWrite(enablepin, LOW);
  attachInterrupt (0, changeMode, RISING);    

}

void SB_Latch() {
  delayMicroseconds(10);
  digitalWrite(latchpin,HIGH); // latch data into registers
  delayMicroseconds(10);
  digitalWrite(latchpin,LOW);
}

void SB_SendPacket() {
  if (SB_CommandMode == B01) {
    SB_RedCommand = 127;   //TEST: try set to 127
    SB_GreenCommand = 127;
    SB_BlueCommand = 127;
  }

  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();

  }
  SB_Latch();
  SB_CommandMode = B01; // Write to current control registers
  for (int z = 0; z < NumLEDs; z++) SB_SendPacket();
  SB_Latch();

}

void  WriteLEDArrayVU() {
  SB_CommandMode = B00; // Write to PWM control registers
  for (int h = 0;h<NumLEDsVu*2;h++) {
    SB_RedCommand = LEDChannelsVU[h][0];
    SB_GreenCommand = LEDChannelsVU[h][1];
    SB_BlueCommand = LEDChannelsVU[h][2];
    SB_SendPacket();
  } 

  delayMicroseconds(1);
  PORTB |= (1 << 1);
  delayMicroseconds(1);
  PORTB |= (1 << 2);
  delayMicroseconds(1);
  PORTB &= ~(1 << 2);
  delayMicroseconds(1);
  PORTB &= ~(1 << 1);

  SB_CommandMode = B01; // Write to current control registers
  for (int z = 0; z < NumLEDsVu*2; z++) SB_SendPacket();
  delayMicroseconds(1);
  PORTB |= (1 << 1);
  delayMicroseconds(1);
  PORTB &= ~(1 << 1); 
}

RGBType GradientMap(int color) {

  if (color < 0 ) color = 0;
  if (color > 255) color = 255;

  float GradientRed = 0;
  float GradientGreen = 0;
  float GradientBlue = 0;

  int GradientIndex1 = color/32;
  int GradientIndex2 = color/32 + 1;
  int GradientRatio = color % 32;

  if (GradientIndex2 > 7) GradientIndex2 = 7;

  GradientRed   = (PlasmaGradient[GradientIndex1][0] * (32 - GradientRatio) + PlasmaGradient[GradientIndex2][0] * (GradientRatio)) / 8160.0;
  GradientGreen = (PlasmaGradient[GradientIndex1][1] * (32 - GradientRatio) + PlasmaGradient[GradientIndex2][1] * (GradientRatio)) / 8160.0;
  GradientBlue  = (PlasmaGradient[GradientIndex1][2] * (32 - GradientRatio) + PlasmaGradient[GradientIndex2][2] * (GradientRatio)) / 8160.0;  

  RGBType RGB;

  RETURN_RGB(GradientRed, GradientGreen, GradientBlue);

}

void drawGraph() {

  SelectGradient(3);
  RGBType specRGBleft;
  RGBType specRGBright;

  float scaleFactor = 255/(NumLEDsVu);

  for (int i = 0;i<NumLEDsVu;i++) {

    specRGBleft = GradientMap((i+1)*scaleFactor - adc1avg*1.5 + 255);
    specRGBright = GradientMap((i+1)*scaleFactor - adc2avg*1.5 + 255);

    LEDChannelsVU[i][0] = specRGBleft.R*1023;
    LEDChannelsVU[i][1] = specRGBleft.G*1023;
    LEDChannelsVU[i][2] = specRGBleft.B*1023;

    LEDChannelsVU[i+NumLEDsVu][0] = specRGBright.R*1023;
    LEDChannelsVU[i+NumLEDsVu][1] = specRGBright.G*1023;
    LEDChannelsVU[i+NumLEDsVu][2] = specRGBright.B*1023;    

  }    

}

void changeMode() {
  Mode = Mode % 3;
  Mode ++; 
}

void loop() {
  unsigned long currentMillis = millis();
  switch(Mode) {

  case 1:
    if(Mode=1){
      digitalWrite(LEDModeOnePin, HIGH);  
      digitalWrite(LEDModeTwoPin, LOW);  
      digitalWrite(LEDModeThreePin, LOW);  
    }
    int X;     
    if(Mode = 1){
      for(int d=0; d<NumLEDs; d++) {
        for(int f=0; f<=2; f++) {     
          for(int a=1; a < 1023; a++) {
            if(a<1023) X=1022-a;
            if(X<10) X=0; 

            //delayMicroseconds(2500);
            //if(Mode=1) {   
            LEDChannels[d][f] = a; 
            LEDChannels[d%2][f] = a;
            LEDChannels[d][f%2] = X; 

            if(a>1022){
              while(a>0) {
                a--; 
              }  
            }
            if(millis() - prevMillis > interval) {
              prevMillis = currentMillis;
              WriteLEDArray();
            }
            else {
              break; 
            }  
          }
        }
      }
    } 
    Serial.println("in mode 1");
    break;

  case 2:
    if(Mode=2){
      digitalWrite(LEDModeTwoPin, HIGH);
      digitalWrite(LEDModeOnePin, LOW);
      digitalWrite(LEDModeThreePin, LOW);      
    }
    adc1avg = adc1avg * 0.95 + analogRead(2) * 0.05;
    adc2avg = adc2avg * 0.95 + analogRead(3) * 0.05;
    drawGraph();
    WriteLEDArrayVU();
    Serial.println(analogRead(2));

    delay(1);

    delay(400);
    Serial.println("in mode 2");
    break;

  case 3:
    if(Mode=3){
      digitalWrite(LEDModeThreePin, HIGH);
      digitalWrite(LEDModeOnePin, LOW);    
      digitalWrite(LEDModeTwoPin, LOW);  
    }
    LEDChannels[0][0] = 0;
    LEDChannels[0][1] = 1023;
    LEDChannels[0][2] = 0;

    LEDChannels[1][0] = 0;
    LEDChannels[1][1] = 1023;
    LEDChannels[1][2] = 0;

    WriteLEDArray();
    delay(200);

    LEDChannels[0][0] = 1023;
    LEDChannels[0][1] = 0;
    LEDChannels[0][2] = 0;

    LEDChannels[1][0] = 1023;
    LEDChannels[1][1] = 0;
    LEDChannels[1][2] = 0;
    
    Serial.println("in mode 3");
    break;
  }  
}

It sounds like a hardware problem, but you should probably use one of the basic demo sketches for ShiftBrites first. I'm not following your code very easily.

If the OctoBars are faulty, please send them back and we'll repair them.

Note that the easiest way to destroy an OctoBar is to plug one of the data cables shifted over by one pin...that'll run 12V into a logic port. Avoid that...in the meantime we're thinking about choosing a different connector. The same problem exists for ShiftBars but those are a lot easier to replace just one!

Is there a procedure for determining if the bars or shift shield are toast? i still get all pwr indicators, but im becoming more suspicious of one or both being fried.

Basically just use some known good code, like our ShiftBrite demo code, and plug in some lights. If it doesn't work...it doesn't work. There are 8 chips in series on the board, and if one chip is bad the following chips also won't work. Fortunately we have found them easy enough to repair (with hot air rework). We found a few that had solder manufacturing problems and have been doing 100% testing...however, a few might have slipped out early on.

ok, cool. Im not really sure what is working and what is not at this point so i will probably just order both bars and the shield, then determine which pieces arent working and send them back to you to take a look at. I have to get this project wrapped up in the next few days but i’ll send a follow up email through your site.
Thanks again.