nd help wiring MAX7221 to bar graph arrays

Hi -

I want to control multiple 10-segment led bargraph displays with my Arduino NG using the multiplexing capabilities of the MAX7221: http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1339

Ultimately I will have 8 7221's running 512 LEDs. I have found the library for programming the arduino to work with the 7221 (http://www.wayoda.org/arduino/ledcontrol/index.html), and have read about running 64 leds from one 7221. On page 13 of the datasheet they show 2 7221's multiplexed - this is what I'm using as a guide.

I am very close to understanding how it's all going to work, but I'm stuck on the actual wiring bit due to my limited electronics knowledge.

On my breadboard I have a bargraph (10 leds) and a single 7221. I did an earlier test adjusting the brightness of an led directly using a potentiometer, as well as blinking the led with a program via the arduino, and that all worked great. Now I want to wire the leds to the 7221.

This is how I currently have it wired - I have not put power to it as I suspect I'm doing something wrong:

On the breadboard I have a +5v rail and a ground rail I have a wire from the +5v rail over to a pad that has: - a 10k resistor running to [ISET], and - a 0.1uF cap running to the ground rail, and - a wire running to [V+]

I have wires from both [GND]s to the ground rail

so far I have wired 4 leds to the 7221 as follows: [DIG0] to the + of led 1, - to the ground rail [DIG1] to the + of led 2, - to the ground rail [SEGA] to the + of led 3, - to the ground rail [SEGB] to the + of led 4, - to the ground rail

I'm pretty sure this is wrong, since this is just a 1 to 1 correlation which even if it works will only give me 16 leds. I'm pretty sure I need to wire it differently to get the matrix behavior described in the datasheet and code articles, but the matrix diagrams are not translating into actual wiring for me.

Once I have this right I'll wire the [LOAD] [CLOCK] and [DIN] to the arduino and I should be ready to program, right?

Can anyone get me on the right track here? I am in way over my head and loving it. Please forgive any aspect of this question which seems completely stupid as I am a total amateur but learning fast now that I have my hands on the parts. :)

hi

what you need now is a schematic diagram-- a drawing of the circuit. There is too much complexity at this point ot describe it in words.

D

what you need now is a schematic diagram-- a drawing of the circuit.

Yes, that would be great. I haven't been able to find one that shows this complete circuit. Lots of discussion of common anode and common cathode and diagrams of the leds laid out in a matrix and I have found some schematics using similar ICs but not this one.

I meant you need to draw one :)

D

ok, i will work on that…

I found this but it is for wiring an 8x8 matrix: http://www.woe.onlinehome.de/proj_gif/ledmodul.gif

I want to have each matrix 60 leds high and one wide. Eventually there will be 8 of these (480 LEDs). Then later I want to double it.

I guess if I understood the common cathode/anode thing better it would help.

I can think of it as 6 10-segment bars in a grid shape (6x10), that is addressable similar to above - but I’m not sure how to wire the bars (anode/cathode) to each other to make an addressable grid with 16 pins like in these examples. Right now for 60 leds I have 120 pins: 60 anodes and 60 cathodes.

Update: ok, this helped: “An LED Matrix is an array of LED’s with the anode or positive terminal of each row connected together, and the cathode or negative terminal of each column connected together. Or the anode can be connected to a column, and cathode connected to a row.” http://www.nuxie1.com/guides/led-matrix-information.html

Here's a drawing with my guesses as to 2 approaches to wiring the led matrix.

http://www.soundwidgets.com/uploaded_images/xenome_wiring.gif

Any help appreciated!

hey

it’s a start… but it takes a lot of work to decode without the chips in place. :slight_smile:
How about adding the chips and the Arduino if possible. Normally in a design with multiple LED drivers like this, only one chip and its associated LEDS are shown. also the LEDS are always shown as a diode type symbol. Makes it easy to read in the universal language of electronics.

D

I just made sketches over a physical design drawing I had on had. It isn't meant to be a schematic it's a conceptual tool for myself, and so people know what I'm talking about (e.g. "6 x 10-segment tall bar graphs x 16"). From what I've rad, I get how the MAX7221 chip connects to the Arduino.

I will eventually have to make a nice schematic and it's starting to look like I will need to make a custom PCB. I'm at the very early pre-prototype stage so I want to leave things malleable as I find out what's possible by breadboarding. It's been really cool to be able to actually hook stuff together and make things light up - like magic . I've spent weeks and weeks poring over these and other forums and reading datasheets but it wasn't until I actually started hooking things up that it started really clicking for me - I guess I learn with my hands.

I'll add some legends and the pinout of the 7221 to the drawing, then maybe make an actual schematic of the circuit I'm trying to build. I was having a hard time grasping the shared cathode/anode stuff but I realize it's just + and - on either side of the diode. Probably a no-brainer to anyone else but I had to see it. Most of the 7221 example schematics I found online are made for a 7-segment readout or for a pre-made 8x8 grid with only 16 pins - already matrixed.

Now that I drew it out I get how I can matrix the bar graphs to work like a set of 8x8 grids, to leverage existing code libraries and circuits for the 7221/7219. I already have 10 7221's and other assorted goodies but for now I think I'll just breadboard one vertical 60x1 "grid" and see how that goes.

hey

there is a thread here that you may find useful… someone wrote a library for the 7221.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1182324757/

D

Thanks for all the help so far. I have updated my cryptic drawing a little, but decided to spend my time wiring up the prototype:

http://www.soundwidgets.com/uploaded_images/Y1_proto_board_1.jpg

The updated drawing below shows how I've wired the MAX7221 to the Arduino. I didn't show all the wires from the 7221 to the led matrix (the one on the right, the vertical stack) but they are labeled (SEGDP, SEGA, SEGB... / DIG0, DIG1, DIG2...)

http://www.soundwidgets.com/uploaded_images/xenome_wiring_2.jpg

At first I had the anode and cathode of the matrix reversed from what is shown in the drawing, but I was getting nothing, so on a whim I flipped the bargraphs around and voila things started to light up. I'm not sure if this is correct, though, as you'll see from the issues I'm having below.

I have compiled and loaded the Matrix Sprite example program to the Arduino, set as follows: PIN 0 = DIN, PIN 1 = LOAD, PIN 3 = CLK. When it is running I see a steady 5.2 v at pins 1 and 2. Pin 0 pulses between 5.2 v and about 1 v at regular intervals.

But I am having some unexpected behavior once I hook it to the array:

  1. without even being connected to the Arduino at all, except for power, if I put 5v to V+ (pin 19) on the 7221 all the LEDS light up really bright and stay that way.

  2. If I then plug in just the DIN wire from the matrix to pin 0 on the Arduino, the whole matrix dims to a lower brightness, and the whole array flashes on and off in a sort of random sequence (on for a few seconds, off for a second, on again then off right away, etc).

  3. when I plug in the LOAD and CLK wires I get different behavior. Sometimes just touching a pin with my finger changes it to bright again or starts the blinking again. At this point I generally unplug from power because I don't want to fry anything.

My uneducated guesses:

a) Maybe I need to add resistors to the 3 data wires? It almost seems like the data pins are sending enough voltage through the system that they're lighting up the leds all by themselves. My hint is that if I unlpug the + and - wires but leave the data pins connected the array lights up dimly and flashes the mysterious pattern - as if every time the DIN fires off it lights the whole array).

b) Maybe I need to switch anode and cathode back to he way they were (flip the bars again)?

c) Maybe I need to add resistors to the 8 common busses of either the anode or cathodes?

Sorry for my bad drawing and being a complete noob and so on but I feel like I am THIS close to making this work - I can almost taste it. My wiring of the matrix seems to be good even though it looks like a rat's nest - leds light and unlight when I disconnect the wire as expected so I think that part is pretty okay.

Oh and one last question on the drawing of the 7221 schematic it shows the resistor and capacitor network at the power supply and I find it a little confusing. Does the white triangle below the capacitor represent common ground or something else? If not what is the actual wiring supposed to look like for these guys?

Maybe that last post was too complicated for a reply. :frowning:

I have simplified the circuit down to where I have only 2 leds hooked up but it is still doing the same thing. Even though the code says to only flash one led, all the leds hooked up get an initial bright flash (initialization?), then it goes dark, then it flashes dimly on all attached leds in a pattern that seems to match the loop. It is as if the DIN is sending the only voltage and lighting the leds.

Here is the code:

#include <binary.h>
#include <Sprite.h>
#include <Matrix.h>

/* create a new Matrix instance
pin 9: data (din)
pin 11: load (load)
pin 10: clock (clk)
*/
Matrix myMatrix = Matrix(9, 11, 10);

void setup()
{
}

void loop()
{
// myMatrix.clear(); // clear display

delay(1000);

// turn some pixels on
myMatrix.write(1, 1, HIGH);

delay(1000);
}

Please help! I have been stuck in the same place for 2 days now. Also, though reading the datasheet over and over, I am confused about how I would initialize the 7221 - is it different in this way than the 7219? An actual code example of how this would look would be great. Also, I would love if the LedControl 7221 library had an actual code example instead of just pseudocode and explanation. It looks like it will do exactly what I need but I am still learning how to program this stuff so need to work with examples. Thanks…

Hi, I've been on vacation so this might come a bit late:

Here is the code that produces the characters on the Led-Matrix and the 7-Segment display from the documentation of the LedControl-library. (http://www.wayoda.org/arduino/ledcontrol/index.html) (Pictures were taken while running the code)

#include "LedControl.h"

//we will be using up to 8 cascaded MAX7221 , on pins 12,10,11 (adjust to your hardware please!)
LedControl lc=LedControl(12,10,11,8);

unsigned long delaytime=1000;

void setup() {
   lc.shutdown(0,false);  //shutdown mode off for the matrix 7221
   lc.setIntensity(0,15); //maximum brightness for the matrix 7221
   lc.shutdown(1,false);  //shutdown mode off for the 7-segmet driver
   lc.setIntensity(1,15); //maximum brightness for this one too
   //clear the displays
   lc.clearDisplay(0);
   lc.clearDisplay(1);
}

//Write some charaters to the four digit 7-segment display
void write7Segment() {
  //We first write "Ardu"
  lc.setChar(1,3,'a',false);
  lc.setRow(1,2,5);
  lc.setChar(1,1,'d',false);
  lc.setRow(1,0,0x1c);
  //Wait for a second
  delay(delaytime);
  //then write "ino"
  lc.setRow(1,3,0x10);
  lc.setRow(1,2,0x15);
  lc.setRow(1,1,0x1D);
  lc.setChar(1,0,' ',false);
  delay(delaytime);
} 

//write the characters arduino to the matrix driver
void writeMatrix() {
  //These are the led's to be switched on(=1) or off(=0) for the letter 'A'
  //Since I have only a 5x7 matrix I will have to send only 5 bytes to the driver
  //using an array of byte for the led-data is just an conveniance thing
  //refer to the LedControl.setRow() function, each of the bytes in the arrays
  //switches 8 leds on or off 
  byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
  //We have some more letters
  byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
  byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
  byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
  byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
  byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
  byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};
  
  //Write 'A'
  lc.setRow(0,0,a[0]);
  lc.setRow(0,1,a[1]);
  lc.setRow(0,2,a[2]);
  lc.setRow(0,3,a[3]);
  lc.setRow(0,4,a[4]);
  //Wait a second
  delay(delaytime);
  //Write 'r'
  lc.setRow(0,0,r[0]);
  lc.setRow(0,1,r[1]);
  lc.setRow(0,2,r[2]);
  lc.setRow(0,3,r[3]);
  lc.setRow(0,4,r[4]);
  delay(delaytime);
  lc.setRow(0,0,d[0]);
  lc.setRow(0,1,d[1]);
  lc.setRow(0,2,d[2]);
  lc.setRow(0,3,d[3]);
  lc.setRow(0,4,d[4]);
  delay(delaytime);
  lc.setRow(0,0,u[0]);
  lc.setRow(0,1,u[1]);
  lc.setRow(0,2,u[2]);
  lc.setRow(0,3,u[3]);
  lc.setRow(0,4,u[4]);
  delay(delaytime);
  lc.setRow(0,0,i[0]);
  lc.setRow(0,1,i[1]);
  lc.setRow(0,2,i[2]);
  lc.setRow(0,3,i[3]);
  lc.setRow(0,4,i[4]);
  delay(delaytime);
  lc.setRow(0,0,n[0]);
  lc.setRow(0,1,n[1]);
  lc.setRow(0,2,n[2]);
  lc.setRow(0,3,n[3]);
  lc.setRow(0,4,n[4]);
  delay(delaytime);
  lc.setRow(0,0,o[0]);
  lc.setRow(0,1,o[1]);
  lc.setRow(0,2,o[2]);
  lc.setRow(0,3,o[3]);
  lc.setRow(0,4,o[4]);
  delay(delaytime);
}

void loop() { 
  writeMatrix();
  write7Segment();
}

This might help a bit, guess you are right , I should present some complete examples :-(

I'll be listening now, but have to do my laundry first :-) !

Eberhard

:) Hey thanks! Welcome back - hope you had a nice vacation. Not too late - still messing around with this. I will give this a shot after work today. Sorry if I got cranky or anything.

:) Success! I was right - I had the anode and cathode backwards. Some more poring over datasheets and schematics of similar circuits finally did the trick and I am able to run the Sprite Matrix example and it works! I too quickly accepted flipping the bar-graphs (because they lit up) before troubleshooting the circuit the way I'd initially built it. What I should have done is switch the SEGs with the DIGs at the 7221, which is what finally worked, along with flipping the bar graphs back to having the anode on the left. It also helped to read up on sinking vs sourcing current as I finally understood how the multiplexing works and how the circuit needed to be setup.

I was able to get things working at first with the tomek ness Sprite Matrix example. It was helpful that the example lights up in an animated way because this made it easier to see when I was getting actual results. So far unable to get the wayoda 7221 library to work but I think I am just missing something obvious. Now I just have to work out an intuitive way to address my 1x60 array programatically.

Hello. I’m having what seem like similar issues trying to get a very basic (1x3) matrix working.
I’m really stuck and hope someone can help as I have very little electronics experience.

What I would like is for the LEDs at row 1 and 3 to blink. Ultimately I am just trying to light the LED’s in sequence.
I have a much larger project in mind, but I need to get this basic example working first.

Here is a picture of my breadboard as I currently have it setup:

Here is my pin configuration on the MAX7219:

I was trying to follow the WIRING "hello_matrix"example: http://wiring.org.co/learning/examples/hello_matrix.html , but I’m running into the same problems as phineus in that my LED’s just seem to stay lit up.

I’m really lost as to where to go at this point. Any help would be greatly appreciated.

Oh, here is my source as I currently have it:

#include <binary.h>
#include <Sprite.h>

#include <Matrix.h>

Matrix myMatrix = Matrix(0, 2, 1); 

void setup() 
{ 
  myMatrix.setBrightness(7); 
} 

void loop() 
{ 
  myMatrix.clear(); // clear display 

  delay(1000); 

  // turn some pixels on 
  myMatrix.write(1, 2, HIGH); 
  myMatrix.write(1, 3, HIGH); 

  delay(1000); 
}