Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: Pedro147 on Sep 21, 2012, 08:44 am

Title: Max72XX scrolling text code
Post by: Pedro147 on Sep 21, 2012, 08:44 am
I came across this code on the forum for Max 7221 for scrolling text.

http://arduino.cc/forum/index.php/topic,22305.0.html

I believe that the 7221 and  7219 are very similair and I only currently have the 7219 so if this code works with the 7221 is it conceivable that it would also work with 7219.
In the link to Youtube the uploader says that "It currently does not work with Arduino 1.0 only 0023." Obviously I am currently using Arduino 1.0 but I would like to try the code out. My question is can I have two different versions of the Arduino IDE installed on my computer at once and just use the version applicable to the code that I wish to run. The only other thought that I had was that I think that I read that previous versions of the IDE used .pde rather than .ino files If this is indead the case, and version 023 requires .pde files, do I just copy and paste the code into the Processing  text editor which will and save it as .pde and then copy and paste that into the Arduino IDE.

Thanks for reading Pedro.
Title: Re: Max72XX scrolling text code
Post by: nickgammon on Sep 21, 2012, 10:57 am
Yes, I have both versions installed, in different folders.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 21, 2012, 11:13 am
Thanks for that Nick
Title: Re: Max72XX scrolling text code
Post by: Riva on Sep 21, 2012, 01:38 pm
A quick look and only thing I can see that would make it not work on v1.0+ is the LedControl library and AFAIK it has since been updated to be 1.0+ compatible. Attached is a demo code I did for 2x MAX7219 chips arranged as a 16x8 matrix. I have since updated it to kern the fonts but don't have the code here with me at work.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 21, 2012, 11:51 pm
Thanks Riva iI would like to try your latest code for 2x MAX7219 chips arranged as a 16x8 matrix and would it be possible to give me a copy of the schematic,
thank you Pedro
Title: Re: Max72XX scrolling text code
Post by: Riva on Sep 22, 2012, 09:46 am

Thanks Riva iI would like to try your latest code for 2x MAX7219 chips arranged as a 16x8 matrix and would it be possible to give me a copy of the schematic,
thank you Pedro

I had attached the test code and it's library to the previous post but the final code that also does kerning and all other relevant files/info including schematics are in this thread http://arduino.cc/forum/index.php/topic,118338.0.html (http://arduino.cc/forum/index.php/topic,118338.0.html)
Due to the layout of the 16x8 matrix I have, the font was doubled in width from a 5x7 to 10x7. I have attached the kerning test code using the 5x7 font but it's output was written to drive a Rainbowduino but should be relativity easy to adapt to the MAX7219.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 22, 2012, 11:33 am
Thanks Riva,

I have seen your impressive clock before and I forgot about it and the code so thanks again,

Pedro
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 28, 2012, 08:32 am
Hello Riva,

I just got around to trying your ScrollTest2 code for the Max7219.  Very impressive work and thank you so much for sharing all your hard work,

Pedro.
Title: Re: Max72XX scrolling text code
Post by: Riva on Sep 28, 2012, 10:56 am

I just got around to trying your ScrollTest2 code for the Max7219.  Very impressive work and thank you so much for sharing all your hard work

No problem. Community is about sharing and helping.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 30, 2012, 04:04 am
I am having a little trouble with a Max 7219 controlling an 8 x 8 LED matrix. I have previously constructed one as a hardwired cicuit so I know that the code and circuit schematic  (Nick Gammons) are good.

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

I am now trying to cascade two 7219's and have built a second circuit on a breadboard to connect up to the aforementioned hardwired circuit but the problem that I am having is that when I upload a sketch to the breadboard circuit (which at this stage is a standalone circuit) it displays the first character perfectly (so the matrix is correctly wired) and then nothing unless I press reset or upload the code again. I have checked my wiring ,and that the one polarised 10 mf cap is correct etc but cannot find a problem. Any clues would be appreciated,

Pedro.
Update - now the problem gets more Gremlinesque  :smiley-mr-green: one two char sketch is displaying correctly but others are still reacting as initially described ?
Title: Re: Max72XX scrolling text code
Post by: nickgammon on Sep 30, 2012, 04:33 am
Show your code please.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 30, 2012, 04:49 am
It is your code from the link I posted in the question Nick -

Code: [Select]

#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 ("PEDRO ", 600);
}  // end of loop



There seems to be no pattern to this problem, some code displays ok and some doesn't. It is definitely a hardware or Arduino sofware issue IMHO (extremely humble  :) )
Title: Re: Max72XX scrolling text code
Post by: nickgammon on Sep 30, 2012, 04:58 am
Can you describe the problem in more detail? You have two LED matrices, right? One connected to one 7219 and the other to the other 7219? And how have you connected to the two 7219s together?

When you say "some code displays ok" can you be more explicit?

Your code displays "PEDRO" so do you see "P" on one and "E" on the other? Or what, exactly?
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 30, 2012, 05:13 am
I do have one circuit hardwired that works perfectly ok. I am now constructing exactly the same circuit on a breadboard so I can eventually daisy chain the two together to scroll text effectively as a 16 x 8 matrix. The circuit on the breadboard is the problem one in so far as it works with one ( two character) code example (using your code with what I want displayed in showString) but another block of exactly the same code but with different characters in showString, briefly displays the first character of showString and the the display remains blank.
Title: Re: Max72XX scrolling text code
Post by: Riva on Sep 30, 2012, 08:27 am
Quote
I am having a little trouble with a Max 7219 controlling an 8 x 8 LED matrix. I have previously constructed one as a hardwired cicuit so I know that the code and circuit schematic  (Nick Gammons) are good.

If you have the 2x MAX7219 chips wired as per my clock schematic then the ScrollTest2.ino posted above is configured for a pair of MAX7219 chips and should work okay.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Sep 30, 2012, 09:04 am
Thanks Riva,

yes as soon as I get the second circuit working I will be trying your code with the two matrices connected together, but until then I still have this hardware problem,

Pedro.
Title: Re: Max72XX scrolling text code
Post by: Riva on Oct 01, 2012, 09:42 am

yes as soon as I get the second circuit working I will be trying your code with the two matrices connected together, but until then I still have this hardware problem,

Is it a hardware problem? you say it displays a couple of characters okay using one piece of code but with a different bit of code it displays just one character then nothing. The ScrollTest2 code should also work fine with a single MAX7219 chip, how does that look if you upload it to the arduino connected to the breadboard matrix.
Do you have both capacitors on the MAX7219 chip and a suitable IREF resistor value for your particular type of LED's
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Oct 01, 2012, 11:59 pm
Hi Riva,

Yes I have the two caps, 10 ?f and 0.1 ?f  on pin 19 of the 7219 and my LED matrix has Rset resistor value of 28k ohms  2.01 v forward voltage and although there is no reference to the DC forward current in the datasheet (Chinese Ebay matrices) I am settling on a conservative 20 mA.

I have exactly the same circuit built up on veroboard and have no problems with it. As stated this is an intermittent problem where one piece of code will display ok and then if I upload a different code example I then have this problem of it only displaying the first character and then nothing. I have swapped the 7219 for another new one that I have but the problem remains. It certainly is a mystery.
Title: Re: Max72XX scrolling text code
Post by: Riva on Oct 02, 2012, 01:36 pm
Maybe your getting crosstalk between the breadboard wires. Keep the DIN, LOAD & CLK short and if possible away from the SEG & DIG wires.
It could also be power related. Ensure your PSU can deliver the power needed. Maybe setting LED intensity to 1 lc.setIntensity(address,ledIntensity) or increasing IREF value will allow the sketch to run and you would then know problem it's power related.
Title: Re: Max72XX scrolling text code
Post by: Pedro147 on Oct 02, 2012, 01:55 pm
Thank you for those diagnostic tips Riva, I will try all your suggestions tommorow and see if that helps [damn electrical Gremlins at it again  :) ]
Title: Re: Max72XX scrolling text code
Post by: Aaron_dyer on Nov 06, 2012, 07:12 pm
I'm getting so frustrated with trying to do this.....I have been working with 'CrossRoads" as well to try and get mine working..

I have 4 MAX7219 and 4   8 x 8 matrices.....I can only get the first two matrices to light up totally (all 64 LEDs) on each but the other two blink when powered up and then nothing..

I have 1.0.1 and I don't understand why some of these posts say use "LedControl.h"   When I try that it just says error compiling....

I am using a Mega2560 and using SPI library...

I have 51 = MOSI

52 = CLK (SCK)

53 = (1st Chip Load)

49 = (2nd chip Load)

48 = (3rd chip Load)

47 = (4th chip Load)


My code is way too long to post here due to the mega also controlling other circuits but What am I doing wrong...

I have the (MOSI) DataIn pins all in parallel  (Im not using Data Out (Pin 24 of Max7219) to cascade)

I have SCK all in Parallel

and then the SS (Loads) are all individually connected to each Pin out assigned above.....

I have 10 Resistors for Iset


Trying to get them to scroll..........
Any help would be appreciated...
Title: Re: Max72XX scrolling text code
Post by: CrossRoads on Nov 06, 2012, 07:19 pm
"I have 10 Resistors for Iset"
What does that mean?
I have a single 27K resistor for each MAX7219.

Make a copy of your code, strip it down to just the MAX7219 parts, get that working. Then add other parts back in.
You don't need to put my name in quotes, folks know who I am.
Title: Re: Max72XX scrolling text code
Post by: Aaron_dyer on Nov 06, 2012, 07:25 pm
I tried to mean 10 K resistors for Iset   or for each Max7219.....Typing too fast..didn't get the "K" in there....
Title: Re: Max72XX scrolling text code
Post by: CrossRoads on Nov 06, 2012, 07:29 pm
According to Table 11 of MAX7219 spec, you'd be drawing close to 40mA per LED then.
Turn on a whole column, that's 320mA. x 4 parts = 1280mA. What do you have for a supply?
Title: Re: Max72XX scrolling text code
Post by: Aaron_dyer on Nov 06, 2012, 07:32 pm
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...