conundrum (yet another LED matrix question)

I've been struggling with driving a simple 8x8 LED matrix. I'm using the recommended MAX7221 (essentially identical to 7219) and the code on the Arduino playground (adapted from the built in 7219_v1 example) found here:
http://www.arduino.cc/playground/LEDMatrix/Max7219

I'm using a Lite-On matrix (LTP-14188A), it happens to be bi-color but i'm only using one color.
LITE-ON Technology Corporation.

It is cathode-common on the rows and anode-common on the columns. I have the DIG pins on the 7221 hooked up to columns and SEG pins hooked up to rows. No matter what commands I send, all LEDs are on. (I also tried it the other way but all LEDS were off no matter what.)

As you can see in the code, I am not setting Display Test register by mistake. I also am setting Decode Mode register to non-segment, i.e. matrix, display. I have not thoroughly verified the code since many others have reported using it and it works, although it seems to be correct (although the bitshifting in the putByte command could be more elegant). i also tried the original max7219_v1 code in the example led_drivers folder with no success.

Load line is pulled to ground with a 10k resistor. I-Set is pulled high with a 22k resistor, which appears to work fine as all LEDs are bright and can run off USB power as well as external power. The 7221 is decoupled from V+ to GND with 220uF and 0.1uF caps.

All the LEDs light up when power is applied. they do NOT go off when chip is re-programmed or reset. sending shutdown command manually has no effect. i have even tried a brand new 7221 chip. same thing.

if i attach an LED to the data line, clock line, and load line i can see voltage pulses, so they appear to be working. the load line appears to be high more of the time than the others (i.e. no visible flicker on debug LED), whichis what you would expect given that it is low only for a microsecond after both reg and data bytes are sent. (this is my cheap way of debugging without a scope :slight_smile: ).

i can manually light an LED by placing its anode + leg to a segment pin on the 7221 and its cathode - leg to a digit pin. this makes sense since the datasheet says the SEG sources current, right?

so, in summary - i'm stumped!

i thought perhaps the load and clock pins were getting toggled too quickly, so i put in a 1ms delay and 1 row randomly lit up. this indicates nothing since the code is supposedly displaying a diagonal line, i.e. only 1 LED per row. i changed delay again and re-programmed and now entire display is blank. i removed delay and display is still blank. i manually applied power to display and LEDs all still work. I replaced 7221 with yet another one, just in case, and display is still blank.

so now i'm thinking all LEDs being on was some weird initial state. and then i tried reversing wires (i.e. DIG/SEG) again, in case i was confused about cathode/anode, but still nothing.

i triple-checked all pinouts and wiring. now i'm really stumped. the fact that at some point all LEDs were on no matter what, and now all are off, suggests the problem is not in the wiring from the chip to the matrix but either in the chip itself or the communication between the arduino and the chip. but code probably not wrong since that should produce consistently wrong results, and of course other people use it and it works for them. what could the problem be?

okay i'm going to continue having this conversation with myself :)... i tried external power supply (12V 1000mA, with a 7805 voltage regulator) and suddenly all the LEDs went back on! so i thought hm must be a power issue after all, except that it has been running fine off USB power with all LEDs on - and when LEDs were all off, you would expect to see the Arduino reset if too much current was needed, but this was not happening. I measured the current coming from external power to the chip+matrix (with all LEDs on) and it was about 145mA. so not that big a deal. but i did notice voltage regulator was very hot. not sure why it was hot with only 145mA, maybe this points to some problem? i checked for shorts but all seemed fine, arduino program ran for 5 minutes with no visible problem.

however - after i switched back to USB power, and nothing lit up, and then switched again back to external power - still nothing! once again the display is blank and no amount of fiddling or resets can make it go on again. the regulator is not hot, only about 15mA being used now, but it is warm, i can't tell if it's more than it should be for sure but from past experience it seems a bit warmer than it should be, however input voltage is actually 13.5V so it could be that.

any way, sorry for the boring details, i'm just trying to get to the bottom of this and it's frustrating... :stuck_out_tongue:

I cant attest to the validity of the code posted at the link you sent me via email -- didn't see that in the playground when I was fiddling with my max chip about a month ago. I sent (via email) you a copy of the sketch that I based my entire animation sequencer off of, but it was included with the download of the Ard IDE at the time, so you may already have it.

Now that I read about your intermittent problems with the display I would blame it on wiring of some sort. You have two breadboards in the picture, are they sure to be good? You said that you can manually light one LED by supplying power to a row and column pin on the display (this is good....I might continue this thought and test every single LED individually to make sure there is no short).

It could also be caused by broken wires...when you plug in the external power source it changes the angle between the Ard and the breadboard setup thus changing the way that the broken wires do or do not connect.

I only had time to browse over the code in the playground and I personally don't like its structure but that does not say anything about how it works, which, as I said, I cannot attest to either way. But because of the apparent disarray of the code I would think that it might be probable that it isn't guaranteed to work. Even the original code included with the IDE (the one I sent to you in email) had some subtle bugs and useless function overhead, etc. that I removed when expanding into my own library.

Robert Carpenter

I re-wired the whole thing, no dice. I tried the code you sent me, and - it worked! After some line by line comparison, I found the bug in the built-in example file (examples/leds/led_drivers/max7219_v1) and the playground file. Well, it's not quite a bug, because it only applies to the 7221.

In the max7219_put function, the load line should be set LOW to begin, not HIGH. this is not strictly necessary for the 7219, only the 7221. ["For the MAX7219, serial data ... is shifted ... with each rising edge of CLK regardless of the state of LOAD. For the MAX7221, CS [LOAD] must be low to clock data in or out."]

This irritates me because i read that the 7221 is identical to the 7219 except that they are high-impedance. but they are also fully SPI compatible. I failed to fully comprehend what that meant when i first read that.

void max7219_put(byte reg, byte data)
{
  max7219_setLoad(LOW);  // begin    ** in the example this is HIGH, which is wrong! ** 
  max7219_putByte(reg);  // specify register
  max7219_putByte(data); // put data
  max7219_setLoad(LOW);  // latch in data
  max7219_setLoad(HIGH); // end
}

So I humbly suggest the example file should be changed since this way it will work with both the 7219 and the 7221.

Great!

I am glad to hear that the code helped. I think that the way that the datasheet specifies the timing diagram for the 7219 indicates that it should be LOW before setting the data as well, but it is obviously more tolerant.

In any case, the code you tried is buggy. Glad to get to the bottom of it.

right, i saw that as well. i guess i should post in the "bugs" forum? and how does one post a correction/suggestion to a playground page?

hi

you can just register for the "playground" and then correct the error yourself-- it's a wiki.
You can, of course, also add you own pages too.
D