Pages: [1]   Go Down
Author Topic: MAX7219 and LED matrix  (Read 1530 times)
0 Members and 1 Guest are viewing this topic.
Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Very much"on learner plates"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been trying to build Nick Gammon's version of a MAX7219 controlling an 8 x 8 LED matrix.

http://www.gammon.com.au/forum/?id=11516

 Now I realise that my question is like asking your car mechanic to diagnose a problem with your car over the telephone or internet as the case may be  and  I know that while limited advice can be offered in this situation it can still be helpful sometimes. I have double checked all the connections, double checked that I correctly copy / pasted the code into the sketch with font.h file in the same folder (thanks Riva)

The sketch uploads ok but all the LED's in columns 1,2.5.7 and 8 remain constantly on while column 6  lights very occasionally if at all. This leaves the LED's in columns 3 and 4 which change constantly (as if they are the only columns forming part of that letter)

If I change The input in "showString" to only one character then to a different single character I can see the difference in what is being displayed in columns 3 and 4.

Now as I previously stated I know this question is as they say "a big ask" but I have never been backwards in coming forward   smiley-cool Hoping that someone can offer any suggestions as to how I attempt to diagnose this problem as I find this whole project very elegant in it's use of SPI, and especially accessing the text to be scrolled from the font.h file which is stored in PROGMEM. Anything that negates producing large arrays in the actual code running is a god-send in my book.

Thank you for at least reading my question and I hope someone might be able something for me to try to "fix da problem" BluesBoy.

p.s. I have attached Nick's code for reference please keep in mind any advice that you offer will have to be dumbed down, I am a novice here   smiley

Code:

#include <SPI.h>
#include <avr/pgmspace.h>
#include "font.h"



 // define max7219 registers
const byte MAX7219_REG_NOOP        = 0x0;
const byte MAX7219_REG_DIGIT0      = 0x1;
const byte MAX7219_REG_DIGIT1      = 0x2;
const byte MAX7219_REG_DIGIT2      = 0x3;
const byte MAX7219_REG_DIGIT3      = 0x4;
const byte MAX7219_REG_DIGIT4      = 0x5;
const byte MAX7219_REG_DIGIT5      = 0x6;
const byte MAX7219_REG_DIGIT6      = 0x7;
const byte MAX7219_REG_DIGIT7      = 0x8;
const byte MAX7219_REG_DECODEMODE  = 0x9;
const byte MAX7219_REG_INTENSITY   = 0xA;
const byte MAX7219_REG_SCANLIMIT   = 0xB;
const byte MAX7219_REG_SHUTDOWN    = 0xC;
const byte MAX7219_REG_DISPLAYTEST = 0xF;
 

void sendByte (const byte reg, const byte data)
  {    
  digitalWrite (SS, LOW);
  SPI.transfer (reg);
  SPI.transfer (data);
  digitalWrite (SS, HIGH);
  }  // end of sendByte
 
 
void letter (const byte c)
 {
  for (byte col = 0; col < 8; col++)
    sendByte (col + 1, pgm_read_byte (&cp437_font [c] [col]));
 }  // end of letter
 
void showString (const char * s, const unsigned long time)
{
  char c;
  while (c = *s++)
    {
    letter (c);
    delay (time);
    letter (' ');  // brief gap between letters
    delay (10);      
    }
}  // end of showString

void setup () {
 
  SPI.begin ();
    
  sendByte (MAX7219_REG_SCANLIMIT, 7);   // show all 8 digits
  sendByte (MAX7219_REG_DECODEMODE, 0);  // using an led matrix (not digits)
  sendByte (MAX7219_REG_DISPLAYTEST, 0); // no display test
  
  // clear display
  for (byte col = 0; col < 8; col++)
    sendByte (col + 1, 0);

  sendByte (MAX7219_REG_INTENSITY, 7);  // character intensity: range: 0 to 15
  sendByte (MAX7219_REG_SHUTDOWN, 1);   // not in shutdown mode (ie. start it up)
                                        
}   // end of setup
 
void loop ()
 {
 showString ("Nick Gammon greets you! ", 500);
 }  // end of loop  
« Last Edit: August 31, 2012, 11:14:02 pm by BluesBoy » Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1273
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When I built mine, there were shorts/dry solder joints that needed to be fixed up. Try debugging by manually connecting the LED matrix to power - for each row connecting each column (like the software would do) to make sure that only one LED comes on. Make sure you connect the power through a resistor or you could damage the LED.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Very much"on learner plates"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for that advice Marco_c,

I will test each individual LED to make sure I don't have a dud matrix. When you say "  there were shorts/dry solder joints" in which compoments? I only have mine on a breadboard at this stage but I suppose that even  the breadboard or max7219 itself can be faulty. That's the problem there are so many areas for potential mis or non connection. Oh the joys of electronics.

Thanks again for your suggestion BluesBoy.
Logged

Sydney, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1273
Big things come in large packages
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Mine was all soldered up on a 'prototype pcb' - the type with just pads around the holes. I tried the breadboard approach but 8x8 LEDs and a breadboard was a bit hard for me to handle. It is actually very easy to build one up it up, but the number of solder joints meant there were bound to be some problems.

I have read before that on this forum some people have problems with the 7219 on breadboards because the high frequency used to update the display causes weird effects on the type of 'mechanical' electrical (if that makes sense) joints used.
Logged

Arduino libraries http://arduinocode.codeplex.com
Parola hardware & library http://parola.codeplex.com

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Very much"on learner plates"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again for that information Marco,

 I haven't read too much about the 7219's other than two tutorials by Nick Gammon and John at Tronixstuff. I just thought that I would build one up on the breadboard before commiting myself to hours of planning and soldering on up on veroboard. I am just in the middle of making a circuit up on veroboard with three IC's and although I am enjoying the challange, having done the circuit on the breadboard first at least I know that if it doesn't work after all that soldering it's most likey a bad joint as you experienced on your project. I will take all that you have told me on board and see if I can get it up and running thanks again,

BluesBoy.
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looking at the code linked, the font is storing "byte"s in program memory, you can't do that and when you read it back you'll get a garbled result pretty much exactly as you describe.  Read the documentation here: http://arduino.cc/en/Reference/PROGMEM

I would also suggest you look at the LedControl library for the MAX7219.  

I have mine set up on a breadboard while I'm waiting for PCBs to arrive, and it's working perfectly.  The MAX7219 only scans the display at 800Hz, so I can't imagine any sort of "high frequency" problems.



Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Very much"on learner plates"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi thanks for that Oracle, just while I see your still online would you be able to send me a link to the schematic that you are using with the LedControl library so I can connect it up and see if I have any better luck with it. Thanks for your suggestion, BluesBoy.
Logged

0
Offline Offline
God Member
*****
Karma: 2
Posts: 854
Arduino rocks!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The wiring is very basic, and what you have should work fine, you just need to pass your 3 pins to the LedControl constructors.   I did wire it as in http://arduino.cc/playground/Main/MAX72XXHardware but without the 10uF capacitor, and 18k for the ISET resistor.  I've got din, clock, and load going to 12, 11, and 10 on my arduino, and the LED pins based on my matrix which I worked out by testing.

The main thing you'll need is the instructions for the library which are here: http://arduino.cc/playground/Main/LedControl    and it includes a test sketch to make sure everything is working.
Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Very much"on learner plates"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the prompt reply Oracle

(I like your work  smiley-cool ) I just had a look at the LedControl page and as you said, saw that the wiring was the same as what I have now. I'll connect it all back up and try that code to see how it goes. Thanks for your interest and suggestions and I'll let you know how I go.

BluesBoy.
« Last Edit: September 03, 2012, 06:26:10 am by BluesBoy » Logged

Australia
Offline Offline
Newbie
*
Karma: 0
Posts: 18
Very much"on learner plates"
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just an update on the problem that I had with Nick Gammon's "too cool for school" code. The only problem with it was the person who connected the wiring to the matrix (me)   smiley-grin  It works a treat and as I initially stated is an elegant and concise piece of coding so thank you Nick. Thanks also to those who offered some suggestions as to how to fix it. You gave me the encouragement to stick at it until I sorted out what I had done wrong.

 BluesBoy.
Logged

Pages: [1]   Go Up
Jump to: