Flashing problem : Driving two colors on a 8x8 Led Matrix by using two Max 7221

Hi everyone, I successfully drove one color on the matrix board. The problem I am having is that two colors can appear at the same time but there is a side effect

It is a RGB 8x8 matrix. At the back, there are 32 pins.
Left side
pin 1-4 controls the first 4 columns
pin 5-12 controls the 8 green rows
pin 12-15 controls the last 4 columns

Right side
pin 16-23 controls the 8 red rows
pin 24-32 controls the 8 blue rows

I connect the Din, V5+, ground, clock and load from the arduino uno to the max7221.
I also connect Dig0 -Dig7 and SegDP to Seg G to the matrix.
At this point, I can drive the blue color by typing the code lc.setLed(BLUE,1,1,true);

For driving one more color
I only connect Dig1 and Seg A from the second max7221 to the matrix. I just try to test if I can drive two colors at the same time.

At location (1,1), I can see the red color
At location (0,0), I can see the blue color
But at location (1, 0 -8) , I can see blue color flashing
at location (1,0), I can see red color flashing

The attachment shows that green is shown at 0,0 and blue is shown at 1,7.
But at location (0,1-7) are flashing in blue and at location (1,0-6) are flashing in green

Here is my code

#include <LedControl.h>

#define BLUE 0
#define RED 1
int COLOR;
LedControl lc=LedControl(13,12,11,2);

void setup() {
// put your setup code here, to run once:
COLOR=BLUE;

lc.shutdown(COLOR,false);
lc.setIntensity(COLOR,8);
lc.clearDisplay(COLOR);
lc.setLed(COLOR,row,col,true);
COLOR =RED;
lc.shutdown(COLOR,false);
lc.setIntensity(COLOR,8);
lc.clearDisplay(COLOR);
lc.setLed(COLOR,1,1,true);

void loop() {
// put your main code here, to run repeatedly:

}

The problem I am having is that two colors cannot appear concurrently with the same brightness.

Yes that's right you can't. This is because of the shared common connector on the matrix.

Is there a way to solve it?

You may have to abandon the max7221 idea. Do you just want 7 colours? Are the rgb leds in the matrix common anode or common cathode? What other components do you have that you could use? Shift registers, transistors...

Paul

PaulRB: You may have to abandon the max7221 idea. Do you just want 7 colours? Are the rgb leds in the matrix common anode or common cathode? What other components do you have that you could use? Shift registers, transistors...

Paul

Thank you for trying to answer my question I only want 2 colors displaying on the matrix. The leds are common anode for sure and the two max7221s are common anodes. I follow everything from http://playground.arduino.cc/Main/MultiplexMAX72xx

All the wires are connected but When two colors appear on the matrix at the same time, some other locations flash.

Isaac2134:
The leds are common anode for sure and the two max7221s are common anodes.

As Mike already tried to tell you, that doesn’t matter. You just can’t use 2 x max7221 for this. That would only work if the matrix had 8 separate anode connectors for red, 8 more for blue and 8 more for green, as well as the 24 cathodes, a total of 48 pins. But it only has 32 because of those common anodes. That’s why you can’t make max7219 work with more than one colour. With those common anodes you are forced to connect the anode pins of two max chips together, and the chip was not designed to work like that.

You could drive it with 3 (2 colours) or 4 (3 colours) shift registers and 8 pnp transistors…

PaulRB: As Mike already tried to tell you, that doesn't matter. You just can't use 2 x max7221 for this. That would only work if the matrix had 8 separate anode connectors for red, 8 more for blue and 8 more for green, as well as the 24 cathodes, a total of 48 pins. But it only has 32 because of those common anodes. That's why you can't make max7219 work with more than one colour. With those common anodes you are forced to connect the anode pins of two max chips together, and the chip was not designed to work like that.

You could drive it with 3 (2 colours) or 4 (3 colours) shift registers and 8 pnp transistors....

Thank you .... I have already bought two max7221. Someone told me that I could do it with two max7221 and I saw a lot of successful videos on Youtube. How to get 8 more separate anode connectors? Is there a way to drive to colors in my situation? I have wires,resistors,capacitors,RGB led matrix, two max7221 and an uno arduino.

Two MAX7221 will work - you have to put one in shutdown mode while you drive one color, then put the other in shutdown mode to drive the other color:

"Shutdown Mode When the MAX7219 is in shutdown mode, the scan oscillator is halted, all segment current sources are pulled to ground, and all digit drivers are pulled to V+, thereby blanking the display. [so not ideal for using 2 a dual color display without adding isolation diodes - Crossroads] The MAX7221 is identical, except the drivers are high-impedance. [so basically disconnected from the Anode & Cathode pins] Data in the digit and control registers remains unaltered. Shutdown can be used to save power or as an alarm to flash the display by successively entering and leaving shutdown mode. For minimum supply current in shutdown mode, logic inputs should be at ground or V+ (CMOS-logic levels). Typically, it takes less than 250μs for the MAX7219/ MAX7221 to leave shutdown mode. The display driver can be programmed while in shutdown mode, and shutdown mode can be overridden by the display-test function."

Same with 3 colors - two in shutdown mode while the 3rd controls the unique anodes and common cathodes.

You'll have to create your own blink-without-delay looping to time multiplex the color drives.

CrossRoads: You'll have to create your own blink-without-delay looping to time multiplex the color drives.

Thank you for trying to help me But I still don't understand what I have to do to finish making the game. I am making a connect 4 game. will it still work with just two max7221? Here is an example of the game http://www.coolmath-games.com/0-connectfour

I can be able to control blue color checker and drop it from the top row to the bottom row. A new checker will then be generated at location (0,0).

But the problem is that I want to switch to another color when the previous checker is still on the board. I tried to shutdown the previous color and switch the color to green. It didn't work. Is it possible to just shut down one color on a specific location?

CrossRoads: Two MAX7221 will work - you have to put one in shutdown mode while you drive one color, then put the other in shutdown mode to drive the other

My apologies Bob, I stand corrected. But this does not sound easy for a beginner. Would you recommend this technique over using ordinary shift registers for the OP?

I follow everything from http://playground.arduino.cc/Main/MultiplexMAX72xx

Yes and that follows the suggestions made by CrossRoads.

The only problem is that that articles has one fatal flaw in its reasoning. Basically the two MAX chips are running off free running oscillators in order to perform a scan. So what you are trying to do when multiplexing them is to stop a scan on one chip and start it on the other. You are trying to do this using a timed ISR ( interrupt service routine ) on the Arduno. So in effect you have three oscillators, one on the Arduino, and one each on the chips and you are hoping that they will some how magically synchronise. If they do not synchronise then you will get flashing due to an incomplete or over scan on each chip , which is exactly what you are seeing.

This is an example of a very poor design that perhaps once or twice worked by chance and was not tested too closely. Even if you get it to work then as temperature changes it is likely to drift as the MAX72xx's free running oscillators change frequency.

Isaac2134: But I still don't understand what I have to do to finish making the game.

I would suggest that you get one of these:- http://www.adafruit.com/products/902

If you want to use the display you have then use the HT16K33 chip to drive it.

Grumpy_Mike: I would suggest that you get one of these:- http://www.adafruit.com/products/902

If you want to use the display you have then use the HT16K33 chip to drive it.

I already bought all the stuff. It costed me a lot... Will Shift register help? I am still trying to think of a cheaper way to solve the situation...

Will a shift register help what?

Sure you can drive a matrix with a shift register and some buffers but your Arduino has to do the multiplexing.

Grumpy_Mike: Will a shift register help what?

Sure you can drive a matrix with a shift register and some buffers but your Arduino has to do the multiplexing.

Can I drive a matrix with two shift register and one max7221 ? All I need to have is to create 16 more pins for the second color. Then my second max7221 will be useless.

You have already been answered in full.

You can drive the matrix with two colours using the two MAX7221 and nothing else. You need your code to be written carefully so that every 10 ms (by checking "millis()" in your loop) you disable the current MAX7221 and enable the alternate one. This will allow the MAX7221 just enough time to start up and perform a complete scan of the eight columns (or rows).

This will inevitably cause flicker, there is no way to avoid it but you can probably minimise it by "tuning" the 10 ms figure in your code. It is not necessary to use interrupts (but in this case, you could).

To drive the matrix with shift registers you will need:

3 x tpic6c595 shift registers, or 1 x 74hc595 plus 2 x tpic6c595

16 x series resistors, around 100R to 330R. With the data sheet for the display you can work out the best values to use.

8 x pnp transistors for example bc327, to switch the common anode connections

8 x 1K resistors to limit the transistor base currents

8 x 10K resistors to pull up the transistor bases and switch them off (may not be needed if 74hc595 is used).

Guys, check my list, did I miss anything?

Guys, check my list, did I miss anything?

Looks fine to me :)

Can I drive a matrix with two shift register and one max7221

No.