Simultaneously lighting multiple led matrices

Hello,

I have 5 led matrices using maxim 7219 and an arduino micro. Everything works fine except I cannot figure out something. How do I have them all turn on at the same time? What happens is : First I turn on the power and the first one (one that has Din connected directly to the the arduino) lights up. Then with slight delay the second turns on, then a slight delay then the third comes on, etc.... So if I want all of them to flash on and off, it looks more like a fast scroll due each on in succession lagging behind the previous one. Is there a technique that would allow them all to turn on at the same time? I am assuming it has to due with how and when each chip is receiving the signal.

Thank you

I am assuming it has to due with how and when each chip is receiving the signal.

Maybe but you should not be able to perceive this unless there is something wrong with the software?

Try driving it with the SPI port.

Post your code, we can only guess as to what happens in setup() or loop() as to how messages are sent out.

Mike is right, even if not using SPI, all 5 should be updated much faster than the eye could notice. Post your sketch, I think there must be something wrong with it.

Paul

thanks guys…
this is the sample code that is supposed to do is flash the top 4 leds rows in all the matrices then flash the bottom 4. so it looks like a long continuous bar at top then bottom.

#include “LedControl.h”

LedControl lc=LedControl(12,11,10,5);

unsigned long delaytime=50;

void setup() {

int devices=lc.getDeviceCount();

for(int address=0;address<devices;address++) {
lc.shutdown(address,false);
lc.setIntensity(address,8);
lc.clearDisplay(address);

for (int x=0; x<9; x++){
pinMode(x,INPUT);
digitalWrite(x,HIGH);
}

}
}
void loop() {

lc.setColumn(0,0,B11110000);
lc.setColumn(0,1,B11110000);
lc.setColumn(0,2,B11110000);
lc.setColumn(0,3,B11110000);
lc.setColumn(0,4,B11110000);
lc.setColumn(0,5,B11110000);
lc.setColumn(0,6,B11110000);
lc.setColumn(0,7,B11110000);

lc.setColumn(1,0,B11110000);
lc.setColumn(1,1,B11110000);
lc.setColumn(1,2,B11110000);
lc.setColumn(1,3,B11110000);
lc.setColumn(1,4,B11110000);
lc.setColumn(1,5,B11110000);
lc.setColumn(1,6,B11110000);
lc.setColumn(1,7,B11110000);

lc.setColumn(2,0,B11110000);
lc.setColumn(2,1,B11110000);
lc.setColumn(2,2,B11110000);
lc.setColumn(2,3,B11110000);
lc.setColumn(2,4,B11110000);
lc.setColumn(2,5,B11110000);
lc.setColumn(2,6,B11110000);
lc.setColumn(2,7,B11110000);

lc.setColumn(3,0,B11110000);
lc.setColumn(3,1,B11110000);
lc.setColumn(3,2,B11110000);
lc.setColumn(3,3,B11110000);
lc.setColumn(3,4,B11110000);
lc.setColumn(3,5,B11110000);
lc.setColumn(3,6,B11110000);
lc.setColumn(3,7,B11110000);

lc.setColumn(4,0,B11110000);
lc.setColumn(4,1,B11110000);
lc.setColumn(4,2,B11110000);
lc.setColumn(4,3,B11110000);
lc.setColumn(4,4,B11110000);
lc.setColumn(4,5,B11110000);
lc.setColumn(4,6,B11110000);
lc.setColumn(4,7,B11110000);

delay(delaytime);

lc.setColumn(0,0,B00001111);
lc.setColumn(0,1,B00001111);
lc.setColumn(0,2,B00001111);
lc.setColumn(0,3,B00001111);
lc.setColumn(0,4,B00001111);
lc.setColumn(0,5,B00001111);
lc.setColumn(0,6,B00001111);
lc.setColumn(0,7,B00001111);

lc.setColumn(1,0,B00001111);
lc.setColumn(1,1,B00001111);
lc.setColumn(1,2,B00001111);
lc.setColumn(1,3,B00001111);
lc.setColumn(1,4,B00001111);
lc.setColumn(1,5,B00001111);
lc.setColumn(1,6,B00001111);
lc.setColumn(1,7,B00001111);

lc.setColumn(2,0,B00001111);
lc.setColumn(2,1,B00001111);
lc.setColumn(2,2,B00001111);
lc.setColumn(2,3,B00001111);
lc.setColumn(2,4,B00001111);
lc.setColumn(2,5,B00001111);
lc.setColumn(2,6,B00001111);
lc.setColumn(2,7,B00001111);

lc.setColumn(3,0,B00001111);
lc.setColumn(3,1,B00001111);
lc.setColumn(3,2,B00001111);
lc.setColumn(3,3,B00001111);
lc.setColumn(3,4,B00001111);
lc.setColumn(3,5,B00001111);
lc.setColumn(3,6,B00001111);
lc.setColumn(3,7,B00001111);

lc.setColumn(4,0,B00001111);
lc.setColumn(4,1,B00001111);
lc.setColumn(4,2,B00001111);
lc.setColumn(4,3,B00001111);
lc.setColumn(4,4,B00001111);
lc.setColumn(4,5,B00001111);
lc.setColumn(4,6,B00001111);
lc.setColumn(4,7,B00001111);

delay(delaytime);

}

1) what turgid code can you not shorten it? Well I know that what you wrote in the loop function could be about seven lines. 2) read how to use the forum sticky, edit that code an put it in code tags. 3) what is that libary? Please provide a link to it. 4) why are you setting the serial TX line as an input?

Presumably its the standard LedControl library.

I suspect that library sacrifices speed for ease of use. There is no “update now” function in the library, so I supect that every last tiny change made to the display results in all 5 displays in the chain getting a complete data refresh.

The playground page on the library points out that using setColumn() is very inefficient. It calls setLed() 8 times. If each call to setLed() means a complete refresh of all 5 of your matrices, I can see why it takes so long to update the whole display.

So maybe its not your sketch after all, but the inefficient library.

Sounds like things might improve if you re-code your sketch to use setRow() rather than setColumn().

Maybe there is a more sophisticated library out there that does not have these issues.

Or you could drive the displays directly in your sketch and not use a library at all, that is what I have done in the past, albeit only with a single max7219. That would allow you to use the Arduino’s hardware SPI also, for best possible speed.

I suspect this bit of code:

    for (int x=0; x<9; x++){
        pinMode(x,INPUT);
        digitalWrite(x,HIGH);
    }

is completely bogus. If you do not know what it is for, I would strongly recommend deleting it. However, I don’t think it is related to your display update issues.

Thanks Paul

Yes that part of the code was to be deleted I was in mid-edit experimenting with some things and forgot to delete it. I did this in setRow first it did the same thing. I am using this "long" format of the LEDs as I was just testing to see what some sprites look like. And it is easy enough to change.

I agree I think it the library. I usually use Microchip and just started messing with arduino. I wrote a quick program to do this with a 10f micro I had. It works fine, no delay. I may address the ports directly and not use that library.

Thanks again

LedControl does all writes in real time. It makes no attempt to buffer or optimise comms.

You may want to try my MD_MAX72XX library which may be better for your needs. Link to my code libraries in the signature block.

PaulRB:
I suspect this bit of code:

    for (int x=0; x<9; x++){

pinMode(x,INPUT);
       digitalWrite(x,HIGH);
   }


is completely bogus. If you do not know what it is for, I would strongly recommend deleting it.

Except that it interferes with the serial port and fails to cover all ports and thus is bogus, it would set all pins to default to INPUT_PULLUP to avoid floating pins.

Yes that is what I was experimenting with....pull all unused to high, so no floating pins. But I never finished to get all the pins. That code in or out has had no effect on the problem.

Macro_c ...I will try that link....

thanks