Go Down

Topic: Scrolling text on LED matrices using SPI and arduino Mega2560 (Read 9181 times) previous topic - next topic

Aaron_dyer

Ok.....I must've missed that on the datasheet....

I'm going to open up the rats nest  (I have it all in an enclosure)

I'm going to replace the R's now...

Aaron_dyer

Ok I have replaced the 10K's with 33 K's I had.....feel much better....the Matrices that would work were very bright......

so I closed it all back up....now the first matrix lights up totally..

the second matrix = Row 2 is only lit up...matrix 3 and 4 = nothing


I'll try and paste my code here....

I may have to shrink it down some....

I'm going to start trying to get the matrices working....

My LCD , LEDs, Buttons all work fine,....


Aaron_dyer

Attached is my schematic and how its wired up....

CrossRoads

Do me a favor.

make these 2 changes
Code: [Select]

 // *******************Initialize the LCD**************//
 
/*  comment out the LCD and all the delays as a test
 
 lcd.begin(40, 2);
 lcd.setCursor(3,0);


Code: [Select]

   lcd.setCursor(0, 1);
   
   lcd.print("<-- Down Control        Clock:");

*/   end of commenting out LCD setup code
}
 
 
 void loop ()
 
 {
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

CrossRoads

Where are the 0.1uF and 1uF (or 10uF) caps on the VCC pin of each device?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Aaron_dyer

Oh yes, I did include a 10 u F and 100 nF on the Vcc line for the first Max7219.....are you saying each chip would need this?

Aaron_dyer

I totally got rid of all the LEDs and LCD commands...I pretty much used your code and just changed ss0-ss3 to the pinouts for the Mega.....

When I open the serial monitor now....the 3rd and 4th matrices blink some but nothing accurate yet....

here is the code I'm using now....

Aaron_dyer

Attached is a picture of my project is you're curious.....

Everything works how I would like it to except the matrices.....They are blinking erratically at times...or steady on....etc.

CrossRoads

Enclosure looks nice!  Better than my PCB with Duemilanove cable-tied to it.

Yes, you need caps for each device. 0.1uF keeps high frequency noise,  10uF acts as local current buffer for the large currents being switched on/off.

Looks like you have slightly old code.  See if this helps

byte display_test = 0x0D;           This needs to be 0x0F,

byte displayArray[192] = { }; // 192 bytes

These need to be written with 0x07:
Code: [Select]

  // scan limit to all 7 columns
  digitalWrite (ss0, LOW);
  SPI.transfer (scan_limit);
  SPI.transfer (0x08);
  digitalWrite (ss0, HIGH);
  digitalWrite (ss1, LOW);
  SPI.transfer (scan_limit);
  SPI.transfer (0x08);
  digitalWrite (ss1, HIGH);
  digitalWrite (ss2, LOW);
  SPI.transfer (scan_limit);
  SPI.transfer (0x08);
  digitalWrite (ss2, HIGH);
  digitalWrite (ss3, LOW);
  SPI.transfer (scan_limit);
  SPI.transfer (0x08);
  digitalWrite (ss3, HIGH);


these need to be written with 0x01 for Normal mode (vs shutdown)
Code: [Select]

  // dispay test to normal
  digitalWrite (ss0, LOW);
  SPI.transfer (display_test);
  SPI.transfer (0x00);
  digitalWrite (ss0, HIGH);
  digitalWrite (ss1, LOW);
  SPI.transfer (display_test);
  SPI.transfer (0x00);
  digitalWrite (ss1, HIGH);
  digitalWrite (ss2, LOW);
  SPI.transfer (display_test);
  SPI.transfer (0x00);
  digitalWrite (ss2, HIGH);
  digitalWrite (ss3, LOW);
  SPI.transfer (display_test);
  SPI.transfer (0x00);
  digitalWrite (ss3, HIGH);


Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Aaron_dyer

Why thank you...I made the enclosure with a Vernier Caliper, A dremmel and a file.......took a few days...I bought the 40 x 2 LCD for 2.75 $ and wanted to something with it right....

I then bought a mega and I wanted to have multiple things working on the enclosure....so I made the matrices as well.....

I updating the code now....

I did add the caps....now I can get some type of response from the 3rd and 4th matrix...at least I'm getting there now....

When I power up, its like the first whole matrix is lit, the 2nd row of the 2nd matrix is lit and then all of 3rd and 4th matrices are lit.....

When I open the serial monitor, the LCD resets and goes through the setup again......

getting there.....Arduino is so much fun.....debugging and all...

CrossRoads

"Arduino is so much fun.....debugging and all..."
I know what you mean - epsecially doing things like copying addresses wrong from the datasheet - took me two nights to figure that one out!
Or even better - I was saving stuff to EEPROM - totally overlooking the fact that there are only 1023 bytes, while the code  happily wrote to 1500 bytes & hosed the data I was putting there. Someone else spotted that for me.  Worked great while I was buffering in the 2048 bytes of SRAM even!

The other thing I did was to write 0's to all the digit registers before anything else, right after the pinMode commands, so when they then come out of shutdown mode they don't turn on by themselves.
Code: [Select]

  // clear the MAX7219 digit registers

  digitRegister = 0x01;  // digit0, up to 0x80 for digit7
  for (x = 0; x<8; x=x+1){ 
    digitalWrite (ss0, LOW);
    SPI.transfer (digitRegister);
    SPI.transfer(0);
    digitalWrite (ss0, HIGH);
    digitRegister = digitRegister+1;
  }
  // next digit
  digitRegister = 0x01;  // digit0, up to 0x80 for digit7
  for (x = 0; x<8; x=x+1){ 
    digitalWrite (ss1, LOW);
    SPI.transfer (digitRegister);
    SPI.transfer (0);
    digitalWrite (ss1, HIGH);
    digitRegister = digitRegister+1;
  }

  // next digit
  digitRegister = 0x01;  // digit0, up to 0x08 for digit7
  for (x = 0; x<8; x=x+1){ 
    digitalWrite (ss2, LOW);
    SPI.transfer (digitRegister);
    SPI.transfer(0);
    digitalWrite (ss2, HIGH);
    digitRegister = digitRegister+1;
  }

  // next digit
  digitRegister = 0x01;  // digit0, up to 0x08 for digit7
  for (x = 0; x<8; x=x+1){ 
    digitalWrite (ss3, LOW);
    SPI.transfer (digitRegister);
    SPI.transfer(0);
    digitalWrite (ss3, HIGH);
    digitRegister = digitRegister+1;
  }
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Aaron_dyer

I'm not 100 % sure where you would add this in.....so I took a guess....

attached is my entire code so far....

the schematic and picture is posted...I replaced resistors with 33 K's now instead of 10 K's....

I have an electrolytic 10 uF cap on each device and a .01 u F ceramic cap on each (I was hoping that could work)

disregard the email tonight.....

I'm going to take a video tonight of it working so far.....so you'll have a better image...

attached is the code so far....with a few updates you gave me....

Aaron_dyer

I have recorded a video of what I have so far.....

I was thinking I may need to do a better job with the caps......

I may resolder them in from each Vcc on the max7219s to its ground and not just on a Vcc / Gnd plane......that run parallel ya know on the PCB (Radio shack board)

anyways, heres the video..

http://www.youtube.com/watch?v=TxtDsnzoABg

I bought 10 more max7219s tonight as well...10  for 4.99 $ can't beat that......

If I can't get this to work, I may just go with the Uno / Duelminove and use an i2c LCD to conserve the I/Os but then redesign the enclosure as well....


anyhows....Still WIP but I'm trying

Aaron_dyer

I noticed and commented in the similar post going on about the coupling caps......It was mentioned to use a 10 uF polarized cap and no less than a 0.1 uF ceramic cap for each device....I'll change up the caps tomorrow because I know I didn't use the correct ceramic caps.....I think I used 0.001 uF

Go Up