led cube (serial connection problems)

I am making an led cube using STP08DP05 (http://www.st.com/stonline/books/pdf/docs/13405.pdf) to drive the multiplexed leds.

Currently no matter what i change the cube still seems to lighting up columns 1 2 3 and occasionally 4. From what I can tell this is due to the serial connection with the chips.

I have one serial from pin 2 on the auruino into sdi and out from sdo to the other chip driving the last 8 columns.

anything helps!!!

//pins
int sdiPin = 1; //
int clkPin = 2;
int latPin = 3;
int L1 = 4;
int L2 = 5;
int L3 = 6;
int L4 = 7;

//vars

byte led[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};


//-----------------------------------------
void setup()
{
  pinMode(sdiPin, OUTPUT);
  pinMode(clkPin, OUTPUT);
  pinMode(latPin, OUTPUT);
  pinMode(L1, OUTPUT);
  pinMode(L2, OUTPUT);
  pinMode(L3, OUTPUT);
  pinMode(L4, OUTPUT);
  //digitalWrite(clkPin, LOW);
  Serial.begin(9600);
}
//-----------------------------------------
void loop()
{
  digitalWrite(L4, HIGH);
  digitalWrite(L3, HIGH);
  digitalWrite(L2, HIGH);
  digitalWrite(L1, HIGH);
  
  

//turn all LEDs off then turn them on
  
  delay(.00000002);
  
  Serial.print(0, BIN);
  delayMicroseconds(.007);
  digitalWrite(clkPin, HIGH);
  delayMicroseconds(.015);
  digitalWrite(latPin, HIGH);
  delayMicroseconds(.005);
  digitalWrite(clkPin, LOW);
  delayMicroseconds(.015);
  digitalWrite(latPin, LOW);

  delay(.00000002);
  
  Serial.print(255, BIN);
  delayMicroseconds(.007);
  digitalWrite(clkPin, HIGH);
  delayMicroseconds(.015);
  digitalWrite(latPin, HIGH);
  delayMicroseconds(.005);
  digitalWrite(clkPin, LOW);
  delayMicroseconds(.015);
  digitalWrite(latPin, LOW);
}

And posting your code may also be required to fully understand your symptom. I use the 16 bit version of this same chip, two of them wired in series to drive a 5x5x5 led cube. The chips are great with their internal constant current output drivers.

Lefty

The code is posted in the first post, and I will have a wiring diagram in a few hours.

delayMicroseconds(.007);

You are trying to delay for 7/1000 of a microsecond? That won't work. The input to delayMicroseconds is integer. So, you are effectively calling delayMicroseconds with 0 as input, and that is never a good idea.

Here is all the updated information. I believe the problem is in the serial connection.

led cube is using STP08DP05 (http://www.st.com/stonline/books/pdf/docs/13405.pdf) to drive the multiplexed leds.

//pins
int sdiPin = 1;
int clkPin = 2;
int latPin = 3;
int L1 = 4;
int L2 = 5;
int L3 = 6;
int L4 = 7;

//vars

byte led[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};


//-----------------------------------------
void setup()
{
  pinMode(sdiPin, OUTPUT);
  pinMode(clkPin, OUTPUT);
  pinMode(latPin, OUTPUT);
  pinMode(L1, OUTPUT);
  pinMode(L2, OUTPUT);
  pinMode(L3, OUTPUT);
  pinMode(L4, OUTPUT);
  //digitalWrite(clkPin, LOW);
  Serial.begin(9600);
}
//-----------------------------------------
void loop()
{
  digitalWrite(L4, HIGH);
  digitalWrite(L3, HIGH);
  digitalWrite(L2, HIGH);
  digitalWrite(L1, HIGH);
  
  
  //setup chip
 
  
  delay(10);
  
  Serial.println(0, BIN);
  delayMicroseconds(7);
  digitalWrite(clkPin, HIGH);
  delayMicroseconds(15);
  digitalWrite(latPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(clkPin, LOW);
  delayMicroseconds(15);
  digitalWrite(latPin, LOW);

  delay(10);
  
  Serial.println(255, BIN);
  delayMicroseconds(7);
  digitalWrite(clkPin, HIGH);
  delayMicroseconds(15);
  digitalWrite(latPin, HIGH);
  delayMicroseconds(5);
  digitalWrite(clkPin, LOW);
  delayMicroseconds(15);
  digitalWrite(latPin, LOW);
}

After uncovering the "ShiftOut" command, I have made some progress and rewrote my code completely. I can now specify which ground I want to activate. I am still having a problem though- some of the LEDs are lighting up dimly when i apply voltage to their respective levels; and at the same time the correct LED is lighting up brightly. The dim LEDs are in the same place every time, but they are not in the same columns. Any ideas?

ShiftOut : http://www.arduino.cc/en/Tutorial/ShiftOut

//pins
int dataPin = 11;
int clockPin = 12;
int latchPin = 8;
int L1 = 4;
int L2 = 5;
int L3 = 6;
int L4 = 7;

//holders for infromation you're going to pass to shifting function
byte dataRED;
byte dataGREEN;
byte dataArrayRED[16];
byte dataArrayGREEN[16];

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  Serial.begin(9600);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);

  //Arduino doesn't seem to have a way to write binary straight into the code 
  //so these values are in HEX.  Decimal would have been fine, too. 
  dataArrayRED[0] = 0x01;  //00000000
  dataArrayRED[1] = 0x10;  //00000010
  dataArrayRED[2] = 0x00;  //00000100
  dataArrayRED[3] = 0x00;  //00001000
  dataArrayRED[4] = 0x02;  //00010000
  dataArrayRED[5] = 0x20;  //00100000
  dataArrayRED[6] = 0x00;  //01000000
  dataArrayRED[7] = 0x00;  //10000000
  dataArrayRED[8] = 0x04;  //00000000
  dataArrayRED[9] = 0x40;  //00000000
  dataArrayRED[10] = 0x00; //00000000
  dataArrayRED[11] = 0x00; //00000000
  dataArrayRED[12] = 0x08; //00000000
  dataArrayRED[13] = 0x80; //00000000
  dataArrayRED[14] = 0x00; //00000000
  dataArrayRED[15] = 0x00; //00000000
  

  //Arduino doesn't seem to have a way to write binary straight into the code 
  //so these values are in HEX.  Decimal would have been fine, too. 
  dataArrayGREEN[0] = 0x00;  //00000000
  dataArrayGREEN[1] = 0x00;  //00000000
  dataArrayGREEN[2] = 0x01;  //00000000
  dataArrayGREEN[3] = 0x10;  //00000000
  dataArrayGREEN[4] = 0x00;  //00000000
  dataArrayGREEN[5] = 0x00;  //00000000
  dataArrayGREEN[6] = 0x02;  //00000000
  dataArrayGREEN[7] = 0x20;  //00000000
  dataArrayGREEN[8] = 0x00;  //00000001
  dataArrayGREEN[9] = 0x00;  //00000010
  dataArrayGREEN[10] = 0x04; //00000100
  dataArrayGREEN[11] = 0x40; //00001000
  dataArrayGREEN[12] = 0x00; //00010000
  dataArrayGREEN[13] = 0x00; //00100000
  dataArrayGREEN[14] = 0x08; //01000000
  dataArrayGREEN[15] = 0x80; //10000000
  
}

void loop() 
    {       
    for (int j = 0; j < 16; j++)
      {
      //load the light sequence you want from array
      dataRED = dataArrayRED[j];
      dataGREEN = dataArrayGREEN[j];
      //ground latchPin and hold low for transmitting
      digitalWrite(latchPin, 0);
      digitalWrite(L4, HIGH);
      //send the data to the chip
      shiftOut(dataPin, clockPin, dataGREEN);   
      shiftOut(dataPin, clockPin, dataRED);
      delayMicroseconds(10000);
      digitalWrite(L4, LOW);    
      digitalWrite(L3, HIGH);
      delayMicroseconds(10000);
      digitalWrite(L3, LOW);
      digitalWrite(L2, HIGH);
      delayMicroseconds(10000);
      digitalWrite(L2, LOW);
      digitalWrite(L1, HIGH);
      delayMicroseconds(10000);
      digitalWrite(L1, LOW);
      //return the latch pin high to signal chip that it 
      //no longer needs to listen for information
      digitalWrite(latchPin, 1);
      delay(1);
      }
    }
      


void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first, 
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut[ch65533]
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that %00000001 or "1" will go through such
  //that it will be pin Q0 that lights. 
  for (i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result 
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000 
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1<<i) ) {
      pinState= 1;
    }
    else {      
      pinState= 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin  
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }

  //stop shifting
  digitalWrite(myClockPin, 0);
}

Well I know that I had lots of strange leds light when they weren't supposed to and not light when the were supposed to. Although the majority of the leds worked as they should. It turned out just to be wiring problems between my logic board and the led assembly. I used 40 pin ribbon cable and connectors at both ends, and I had used the wrong style of ribbon cable, it was the correct width but it had ground wires between every other 'real' wire!

I bring that up not because you may used that same arrangement, but rather the only way I could troubleshoot and isolate the problems was to come up with logical test patterns. All on, all off, alternating on and off of adjacent leds. I put all the test patterns into one sketch and had extra digital input pins used such as grounding any one would run one of those patterns. That way I could change test patterns on the run for testing purposes. That and with the aid of my O-scope I finally figured it out to be the very last thing I would have thought of, the dam ribbon cable! My software was ok, the logic board with processor and shift chips were ok, just my interconnects. In building I had carefully ohm-metered every sub-assembly for correct interconnection but not with the logic board and led assembly connected together.

So don't know if that might help or not, just throwing out ideas. :wink:

Lefty

Hmm interesting. My follow up question to that is were the "strange leds" completely light up or were they dim? Also, I am using individual wires connecting the columns of the cube to the output pins of the chips, so I don't think that would be the problem. Thanks for your help lefty, I'll post when i get it figured out. Let me know if you get any more ideas.

My follow up question to that is were the "strange leds" completely light up or were they dim?

Mostly dim or maybe some were half brightness as I recall. There were lots of backdoor circuits being created by all the random gound connections being created by the cable and I suspect the constant current output was being shared by some leds via the wiring problems.

Lefty