limit rows on MAX7219 for matrix display ?

I am finally onto a project that displays two 8 character names on a display.

I have made single character pcbs with 7 x 5 leds each with a MAX7219 mux / driver

I will be storing the characters in flash memory ( as per Nick Gammons forum ).

If I were to use the 7 seg decoding function of the MAX, I could limit the number of columns to 5, and get a 20% duty cycle for greater brightness than the full matrix 12.5%.

There are 2 problems though, firstly this function doesn't seem to be available for driving a matrix, and secondly I have connected my digits to the rows, and the segments to the columns, so limiting the digits to 5 would chop off the top of my display .

Is there a way to limit the rows to 5 ?

Your question is puzzling. The 7 segment decoding function relates only to 7-segment displays and limits the actual patterns to digits 0 to 9, "-" and the characters "H", "E", "P", "L"; 16 patterns including blank.

But you are not simply producing 7-segment displays?

For matrices, you can limit the number of columns displayed to five with the Scan Limit register, but this means that the columns are common cathode and you have to code the data bytes to each column rather than row. It is your choice as to how you wire it.

Digits can be limited down to 1; if <3 tho, the Rset resistor may need adjusting:

The scan-limit register sets how many digits are displayed,
from 1 to 8. They are displayed in a multiplexed
manner with a typical display scan rate of 800Hz with 8
digits displayed. If fewer digits are displayed, the scan
rate is 8fOSC/N, where N is the number of digits
scanned. Since the number of scanned digits affects
the display brightness, the scan-limit register should
not be used to blank portions of the display (such as
leading zero suppression). Table 8 lists the scan-limit
register format.
If the scan-limit register is set for three digits or less,
individual digit drivers will dissipate excessive amounts
of power. Consequently, the value of the RSET resistor
must be adjusted according to the number of digits displayed,
to limit individual digit driver power dissipation.
Table 9 lists the number of digits displayed and the
corresponding maximum recommended segment current
when the digit drivers are used.

I don't see anything in the datasheet that says this is not available when using No-Decode mode.

John,
You seem to have shot yourself in the foot by using the digits as rows instead of columns.

Thanks guys,

( slap on very tired forehead ! )

I can mount the LEDs the other way round ( a to k ) ?

I am just assembling a second pcb.

Sure, set up the anodes to go horizontally, and the cathodes vertically.

Might have to do some playing to figure out which corner lights up when you send this to the registers:
01-> 1
02 -> 0
03 -> 0
04 -> 0
05 -> 0
06 -> 0
07 -> 0

8x8
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000001

or 7wide x 5high, send 7 byte
0000000
0000000
0000000
0000000
0000001

or 5wide x 7 high, send 5 bytes
00000
00000
00000
00000
00000
00000
00001

Try using the MD_MAX72XX library (link in the repository below). My Parola modules are probably wired the same way as your matrix and you may find that the scan limit works the way you expect.

He wanted to limit the segments tho for 5x7 displays that were flipped 90 degrees - isn't Parola set up for 8x8 displays with cathode columns?

5x8 would come from the scan limit, 5x7 comes from not wiring one of the bits.

Parola library sits over the top of the 'hardware' library MD_MAX72xx. This library has recently been upgraded to allow use with the more generic hardware available on eBay and other sources (which is basically 'flipped' 90 degrees). One or other modes may suit, depends on the actual details of the wiring. I figure for the cost of a download and a compile of the test program (which exercises the scan limit) it is worth a try. If it does not work no-one is worse off :slight_smile:

I have spent a lot of time on this today, I thought it would be time for me to move from v22 to V1.0.4, which I have quickly tried to do over the last year or so, many times.

I got over the first hurdles, and actually got blink to work !!!

but now if I try to run a sketch with LedControl on V1.0.4 I get error message below

( the convoluted address was me extracting the arduino to a whole new fresh directory )

I havnt even got one row lighting steadily yet ! even in v22 ..

In file included from sketch_dec14a.pde:1:
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:54: error: 'byte' does not name a type
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:56: error: 'byte' does not name a type
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:66: error: 'byte' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:66: error: 'byte' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:133: error: 'boolean' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:144: error: 'byte' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:155: error: 'byte' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:166: error: 'byte' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:166: error: 'boolean' has not been declared
C:\a NEW SCOREBAUDS folder\dec13arduino1 4\arduino-1.0.4\libraries\LedControl/LedControl.h:181: error: 'boolean' has not been declared

The other confusing thing is that most of the examples have the arduino pin11 for clock, 12 for data , and 10 for LOAD ( notCS )

I thought that SPI pins were set at 11 for data, and 13 for clock ? with a choice of not CS ?

Yes, that's the part that gets me - got this great SPI hardware, and the LED library bit-bangs the control signals. I don't use it. Instead, SPI.transfer with 13 = clock, 11 = dataout, and 10 for CS.

Its got me so confused, but also one of the many examples today said that beware using lots of wire or breadboards as the SPI signals can get corrupt.

I am tempted to use my favourite shiftout at a nice slow pace that I send around to 20 chips over several square meters with no problem.

I guess I would have to just send out the extra register byte before each byte of bitmap data .

What, and people can't figure out how to slow down SPI?
Do what you gotta do I guess.

"What, and people can't figure out how to slow down SPI?" LOL

I aint got there yet :slight_smile:

I tried the sample sketch you ( Crossroads ) showed in a post last year
It goes through one sequence of patterns ( hooray ! ) but then freezes with all LEDs on.
If I stick a SPI.transfer (display_test); SPI.transfer (0x00);
at the end of the loop, it repeats the 2 patterns and still shows all the LEDs on briefly before repeating.
The other wierd thing is that I would have expected the rows to alternate, but only one row of LEDs changes.
( I have slowed the SPI down by 8 and its the same )

/* 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

So now I am trying Nick Gammons MAX7219 sketch again, but on V1.0.4 ( I cant get any of the LedDisplay library ones to run on V1 )

I have created a file font.h and put it in the V1.0.4 library ( which worked after a fashion in V22, albeit strange patterns )

When I try to compile I get 'cp437_font' was not declared in this scope

Any clues ?

in the words of a 60s song ( Hello Mother, Hello Father ) " Mother Father kindly disregard this letter "

Thanks for all the help - it was 2am finger trouble !

somewhere along the way ( after I had checked the 5v to the display board ) I plugged in the header strip with the 5v onto the 3v3 arduino pin !

OK all the sketches are doing lovely things now, I just have to get my rows in the right order ( or bitmaps )