Offline
Newbie
Karma: 0
Posts: 28
|
 |
« on: October 09, 2012, 11:19:24 pm » |
Hello, I am trying to put together a circuit using my arduino mega 1280, a max7219 LED driver and a 8x8 LED matrix. I have torn down my circuit and rebuilt it. I have swapped every part and wire also. For some reason, my LED matrix lights up ALL the led's all the time. Can someone help me understand what I'm doing wrong? Even if I set the intensity to 1 the brightness doesn't change. Even if I indicate that only 1 LED should turn on, they still turn on. Even if I set lc.shutdown(0,true) they all stay on. I have followed the wiring diagram here: http://arduino.cc/playground/Main/MAX72XXHardwareC1 I have as 0.1uF C2 I have as 100uF (not the 10uF as stated in the diagram but it's all I have) Rset is 10k My code is: #include "LedControl.h" // need the library LedControl lc=LedControl(12,11,10,1); // lc is our object // pin 12 is connected to the MAX7219 pin 1 // pin 11 is connected to the CLK pin 13 // pin 10 is connected to LOAD pin 12 // 1 as we are only using 1 MAX7219 void setup() { // the zero refers to the MAX7219 number, it is zero for 1 chip lc.shutdown(0,false);// turn off power saving, enables display lc.setIntensity(0,1);// sets brightness (0~15 possible values) lc.clearDisplay(0);// clear screen } void loop() { for (int row=0; row<8; row++) { for (int col=0; col<8; col++) { lc.setLed(0,col,row,true); // turns on LED at col, row delay(10); lc.setLed(0,col,row,false); // turns off LED at col, row delay(10); } } }
|
|
|
|
« Last Edit: October 09, 2012, 11:20:57 pm by yumology »
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16433
Available for Design & Build services
|
 |
« Reply #1 on: October 10, 2012, 12:40:33 am » |
Try this simple sketch. Uses the SPI pins to drive the MAX7219. I had it running for 4 '7219s last night, stripped out the 2-3-4 digits here. Connect pins 10,11,13 to the '7219. None of this silly software bit banging stuff. D10 goes to Load (7219-12), D11 goes to DIN (7219-1), D13 goes to CLK (7219-13). Make sure you have 0.1uF cap on its Vcc pin (7219-19), and an additional 10uF wouldn't hurt. /* program to put message on a MAX7219s. Set up in No Decode mode. */ // ************************************ // //a_presetup #include <SPI.h>
// define pins usage // D11-12-13 SPI interface
byte ss0 = 10; byte x; // define variables // bytes to send to MAX7219s, with some initial data byte displayArray[] = { 0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //16 bytes
// define 7219 register addresses for setup byte decode_mode = 0x09; // 0x00 = No decode for digits 7-0 byte intensity_level = 0x0A; // 0x08 = mid level. Range is 0x00 to 0x0F byte scan_limit = 0x0B; // 0x07 for all columns byte shutdown_normal = 0x0C; // 0x00 - shutdown, 0x01 = normal byte display_test = 0x0F; // 0x00 = normal, 0x01 = display test mode all on full
// ************************************ //
// b_setup void setup(){
pinMode (ss0, OUTPUT); digitalWrite (ss0, HIGH);
Serial.begin(115200);
// turn on SPI port SPI.begin();
/* set up MAX7219 registers */
// decode to No decode mode digitalWrite (ss0, LOW); SPI.transfer (decode_mode); SPI.transfer (0x00); digitalWrite (ss0, HIGH);
Serial.println("No decode mode");
// intensity to mid level digitalWrite (ss0, LOW); SPI.transfer (intensity_level); SPI.transfer (0x0f); digitalWrite (ss0, HIGH);
Serial.println("Intensity");
// scan limit to all 7 columns digitalWrite (ss0, LOW); SPI.transfer (scan_limit); SPI.transfer (0x07); digitalWrite (ss0, HIGH);
Serial.println("Scan Limit");
// dispay test On digitalWrite (ss0, LOW); SPI.transfer (display_test); SPI.transfer (0x01); digitalWrite (ss0, HIGH); delay(200);
Serial.println("Display test on");
// dispay test to normal digitalWrite (ss0, LOW); SPI.transfer (display_test); SPI.transfer (0x00); digitalWrite (ss0, HIGH); delay(200);
Serial.println("Display test off");
// shutdown to Normal mode digitalWrite (ss0, LOW); SPI.transfer (shutdown_normal); SPI.transfer (0x01); digitalWrite (ss0, HIGH);
Serial.println("Normal mode");
delay(250);
Serial.println("setup done");
} // ************************************ //
// c_loop void loop(){
// ************************************ // Serial.println("slaveSelect0 low "); // put data in registers 1 to 9. 16 bit transfer - address/data for (x = 1; x<9; x=x+1){ digitalWrite (ss0, LOW); SPI.transfer (x); SPI.transfer(displayArray[x-1]);// array 0 to 7 digitalWrite (ss0, HIGH); }
delay(1000);
Serial.println("slaveSelect0 high");
for (x = 1; x<9; x=x+1){ digitalWrite (ss0, LOW); SPI.transfer (x); SPI.transfer(displayArray[x+7]); // array 8 t0 15 digitalWrite (ss0, HIGH); }
delay(1000);
} // end loop
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #2 on: October 10, 2012, 01:01:50 am » |
That code uploaded but it simply displayed all 64 LED's as on.
In fact when I even take out the arduino from the circuit completely all 64 LED's stay on...
Does it matter that much if I use a 100uF capacitor instead of a 10uF one?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16433
Available for Design & Build services
|
 |
« Reply #3 on: October 10, 2012, 01:17:25 am » |
10uF/100uF - either is okay. Check your wiring - perhaps you have anodes/cathodes swapped. That code will make the alternating LEDs turn on/off - I posted a video of it doing that yesterday for all 4 displays. See video in this message. http://arduino.cc/forum/index.php/topic,126144.0.html
|
|
|
|
« Last Edit: October 10, 2012, 01:25:12 am by CrossRoads »
|
Logged
|
|
|
|
|
Valencia, Spain
Offline
Edison Member
Karma: 65
Posts: 2227
|
 |
« Reply #4 on: October 10, 2012, 04:21:38 am » |
Hello, I am trying to put together a circuit using my arduino mega 1280, a max7219 LED driver and a 8x8 LED matrix.
I have torn down my circuit and rebuilt it. I have swapped every part and wire also. For some reason, my LED matrix lights up ALL the led's all the time. Can someone help me understand what I'm doing wrong? Even if I set the intensity to 1 the brightness doesn't change. Even if I indicate that only 1 LED should turn on, they still turn on. Even if I set lc.shutdown(0,true) they all stay on.
From the symptoms it sounds like you're putting the 7219 into "test" mode. Normally you'd have to do that deliberately but it could happen if you only ever put '1's on the data line (the test register is register 0x0f and you put '1's into it...)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #5 on: October 10, 2012, 10:52:32 am » |
SOLVED. Crossroads was right, I had my annodes and cathodes connected incorrectly. Thank you!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16433
Available for Design & Build services
|
 |
« Reply #6 on: October 10, 2012, 01:33:18 pm » |
and didn't even see the schematic 
|
|
|
|
|
Logged
|
|
|
|
|
Canberra Australia
Online
Sr. Member
Karma: 4
Posts: 274
Enthusiastic Newbie
|
 |
« Reply #7 on: October 10, 2012, 02:01:04 pm » |
It must be psychic fault diagnosis  cool
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #8 on: October 10, 2012, 09:56:51 pm » |
Ok, new problem. Step 2 of my project is to control the bi-colors of my LED matrix. My schematic is attached. I have proven that each MAX7219 is wired correctly by using the code from before to drive one and simply remove the other from the circuit by taking it out entirely. I see all LEDs light up perfect. The problem is when I have both MAX7219's in at once none of my LEDs display. Here is my code: #include "LedControl.h"
/* Now we need a LedControl to work with. ***** These pin numbers will probably not work with your hardware ***** pin 12 is connected to the DataIn pin 11 is connected to the CLK pin 10 is connected to LOAD */ LedControl lc=LedControl(12,11,10,2); /* This time we have more than one device. But all of them have to be initialized individually. */ void setup() { lc.shutdown(0,true); lc.shutdown(1,true); lc.setIntensity(0,8); lc.clearDisplay(0); lc.setIntensity(1,8); lc.clearDisplay(1); }
void loop() { lc.shutdown(1,true); lc.shutdown(0,false); for (int row=0; row<8; row++) { for (int col=0; col<8; col++) { lc.setLed(0,col,row,true); // turns on LED at col, row delay(10); lc.setLed(0,col,row,false); // turns off LED at col, row delay(10); } } lc.shutdown(0,true); lc.shutdown(1,false); for (int col2=0; col2<8; col2++) { for (int row2=0; row2<8; row2++) { lc.setLed(1,col2,row2,true); // turns on LED at col, row delay(10); lc.setLed(1,col2,row2,false); // turns off LED at col, row delay(10); } } }
|
|
|
|
« Last Edit: October 10, 2012, 09:58:33 pm by yumology »
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16433
Available for Design & Build services
|
 |
« Reply #9 on: October 10, 2012, 10:02:00 pm » |
You need to use 7221's then:
"Eight-Digit Drive Lines that sink current from the display common cathode. The MAX7219 pulls the digit outputs to V+ when turned off. The MAX7221’s digit drivers are high-impedance when turned off."
"Seven Segment Drives and Decimal Point Drive that source current to the display. On the MAX7219, when a segment driver is turned off it is pulled to GND. The MAX7221 segment drivers are high-impedance when turned off."
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #10 on: October 10, 2012, 10:05:58 pm » |
LOL, I waited a month for these stinking 7219's to come in. Ok thanks for the help once again!
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16433
Available for Design & Build services
|
 |
« Reply #11 on: October 10, 2012, 10:32:34 pm » |
A month? Where'd you order from? I got 8 in less than a week from taydaelectronics. $1.25 each. I have red/green displays (freebies) that I thought were single color, didn't really have plans for dual color so am using just 1 for now. No thoughts as to content for dual color yet.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #12 on: October 10, 2012, 10:53:35 pm » |
Ordered on ebay and it just took a month for some reason. Thanks for the link. See here is where I went wrong. I saw this video Right at the 4m 12s mark you see the schematic which I guess just can't work. I wonder if it has has anything to do with a common anode LED matrix compared to a common cathode...
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16433
Available for Design & Build services
|
 |
« Reply #13 on: October 10, 2012, 11:42:16 pm » |
You have common anode parts? Bet it could still be made to work. I see he has the 2 parts daisy chained, and sharing the cathode. Don't see how that's working with the multiplexing. Like to see the code behind it.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 28
|
 |
« Reply #14 on: October 10, 2012, 11:59:49 pm » |
I just checked my matrix.
Pin 1 is held at positive. If I then put Pin12 at negative a green LED turns on. Or if I put Pin13 at negative a red LED turns on.
To me this means I must have a common anode matrix.
|
|
|
|
|
Logged
|
|
|
|
|
|