Small problem with led matrix

So I have been working on a "shield" (actually 3 layers of protoboard with wires everywhere, I don't have access to tools to make pcbs) that controls 2 8*8 RG led matrices using only 4 arduino pins, and two more optionally for the pins on the shift register for high-impedance mode and the register clear pin.
I have one matrix all wired up, and I have been testing it with various things.
Right now I have a little animated smiley face that opens and closes its mouth.
But the eyes, which should be a 4 dot square, only have the upper half showing.
I have checked and all the pixels in the matrix are functional, so I think this may just be a silly mistake in my code. Yet I cant figure it out!
Here's the code:

/*
Data is sent out in bytes, green-->red-->rows
 */


const int clockPin = 2;
const int dataPin = 3;
const int latch1 = 4;
const int latch2 = 5;
const int oePin = 6;
const int clrPin = 7;

byte rows[8] = {
  B00000001, 
  B00000010, 
  B00000100, 
  B00001000, 
  B00010000, 
  B00100000, 
  B01000000, 
  B10000000
};
byte greenEyes[8] =  {
  B00000000,
  B01100110,
  B01100110,
  B00000000,
  B00000000,
  B00000000,
  B00000000,
  B00000000
};

byte redMouth[8] = {
  B00000000,
  B00000000,
  B00000000,
  B00000000,
  B10000001,
  B11000011,
  B01111110,
  B00111100
};

byte redOpen[8] = {
  B00000000,
  B00000000,
  B00000000,
  B00000000,
  B11111111,
  B10000001,
  B01000010,
  B00111100
};

void setup()  {
  for(int i = 2; i<=7; i++)   {
    pinMode(i, OUTPUT);
  }

}

void loop()  {
  long time=millis();
  while(time > millis() - 500)  {
    for(int i =0; i<8; i++)  {
      digitalWrite(latch1, LOW);

      shiftOut(dataPin, clockPin, LSBFIRST, greenEyes[i]);

      shiftOut(dataPin, clockPin, MSBFIRST, redMouth[i]);
      shiftOut(dataPin, clockPin, LSBFIRST, rows[i]);
      digitalWrite(latch1, HIGH);
    }
  }
  time = millis();
  while(time > millis() - 500)  {
    for(int i =0; i<8; i++)  {
      digitalWrite(latch1, LOW);

      shiftOut(dataPin, clockPin, LSBFIRST, greenEyes[i]);

      shiftOut(dataPin, clockPin, MSBFIRST, redOpen[i]);
      shiftOut(dataPin, clockPin, LSBFIRST, rows[i]);
      digitalWrite(latch1, HIGH);
    }
  }

}

Any help? Thanks
:slight_smile:

You'll need to show us a circuit diagram (schematic) of how you've connected the shift registers to the LED matrix.

D2 --- data pin on rows register
red register-attached to serial out of row register
green register- atached to serial out of red register
Common clock
Common latch
Other obvious things, vcc, etc.

Outputs of row register-- rows of led matrix, in reverse order
Outputs of red register-- red columns of matrix, reverse order
Outputs of green register-- green columns, not reverse order

Does this help?

NVM I think its hardware related. I'll check all the connections and post my results.

Edit: Also, it is the third and fourth rows that do not work.

I will work on the schematic.

Does this help?

No you need to post a schematic. Draw on on paper, photograph it, put the photo on a sharing site and paste the link after clicking the picture icon (third from the left)

Schematic time!:
http://img689.imageshack.us/img689/4775/schematicforone.jpg

It is a large image so I did not use the image tags.

Notes:
The mess of wires between the 74hc595 and the uln2803 is just the pins of one connected to the respective pins on the other. In my actual circuit they are connected via headers on two separate protoboards.

I am sure that the connections to the matrices are correct and that they are connected.

bump

I hope the wiring is neater than the diagram :wink:

Well it looks OK but it is hard to follow what is going on.

Can you get those pixels around the eyes to light up independently in a simple test?

Edit: Also, it is the third and fourth rows that do not work.

Faulty ULN2803? Or maybe the row shiftregister. Or it could be the wiring somewhere on those two outputs.

I will try testing the pixel in a separate program, but

I know that the pixels work after directly connecting it to a power source
I know the shift register is working, I tested it with a simple led
I know that the sink driver works
I know that the connections are good.

When I say "know", I mean I am 99.9% sure.
So I guess for now I will keep testing it.

And mike, the wiring is worse than in the schematic.
All of it fits on the equivalent of one 3*2" protoboard. (one half each of two protoboards)

Edit: Yep, I can individually light the pixels, so make that 100% sure.

But I STILL cannot find any errors in the program!

Maybe a stupid question, but how did you test the pixels?

I did this in pseudocode:
"
latch activate
write value to green register
write value to red register
write 00110000 (troublesome rows) to row register
latch deactivate
"
and the correct rows lit up.

Maybe you have newer code, but in the posted code, I see shiftOuts for the columns(?), but I don't see any reference to latch2 in main loop to select which row that those column data is for.

Latch2 is the latch pin for a second set of registers--- I will be controllng two matrices.
Unused right now, just trying to get one Matrix working for now.
So, it's unrelated.

Maybe you have found a more efficient way, but I don't see how you can combine the row and column shiftOut() in one loop. They need to be nested don't they?

That is, enable row 0, setup columns for row 0, wait 500 ms.
disable row 0, enable row 1, setup columns for row 1, wait 500 ms, etc.

Something like this? Note that I had to use latch2 for rows to keep it independent of columns.

  for (int row=0; row < 8; row++)
  {
    digitalWrite(latch2, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, rows[row]);
    digitalWrite(latch2, HIGH);

    time = millis();
    while(time > millis() - 500)  {
      for(int i =0; i<8; i++)  {
        digitalWrite(latch1, LOW);
        shiftOut(dataPin, clockPin, LSBFIRST, greenEyes[i]);
        shiftOut(dataPin, clockPin, MSBFIRST, redOpen[i]);
        digitalWrite(latch1, HIGH);
      }
    }
  }

[edit]Of course, if you change the code to be as above, you will need to modify your circuit so the 595 for the row no longer chained to the red and green 595s. :-([/edit]

I think you misunderstand...
All three registers have a common latch.
The second latch pin is irrelevant.
I am using row-column scanning to display an image. For each reow it turns on the appropriate red or green columns, and it does this for every row in sequence really fast but our eyes can't tell.

Problem is it displays nothing when it gets to the third and fourth rows.

Still nothing?

Still nothing?

Well it seems like a pretty puzzling problem. Have you tried other patterns in the "greenEyes" array? Like all 1's, every other row all 1s and 0s..?

Grrrh... I am completely confuddled.

I was fiddling around with variable values and
If I change rows[] to

byte rows[8] = {
  B00000001, 
  B00000010, 
  B00001100, 
  B00001000, 
  B00010000, 
  B00100000, 
  B01000000, 
  B10000000
};

The eyes extend to both the third and fourth rows of the matrix

I just don't get it.
How, electronically, through simple wiring could I get what seems to work as an and gate- either both rows are on or none at all?

Puzzling indeed. Does it also show up on row 3 and 4 when you change only rows[4] to B00001100 as well?

I have 3 theories in ascending unlikelyness order:

  1. Do you have decoupling capacitors near the supply voltage of the ICs? Like, 100nF or so near the shiftregisters. A long shot, and I find it strange the same two rows are giving you troble all the time if this is the reason.

  2. The variable of rows[3] or rows[4] gets overwritten with zeroes... but I don't really see how. Try changing the order of the rows[] array with one of the other arrays, and see if it changes things.

and nr. 3:

How, electronically, through simple wiring could I get what seems to work as an and gate- either both rows are on or none at all?

You are using an old protoboard with some oxidized connections, forming a P-N substrate junction with some of the wires you have for row 3 and 4, forming a diode-AND gate (ok maybe not... and chemistry was never my strong side :stuck_out_tongue: )

Edit: typo.