MD_MAX72xx strange behavior [SOLVED]

Hello,

I'm trying to use a chinese 32x78 led matrix with max7219 chip.

I can use it successfully with the library LedControl, and the whole matrix seems in good working condition.

I can also run the sketch MD_MAX72xx_HW_Mapper.

But the other examples of the MD_MAX72x library lead to strange results, chaotic response.

Is there a fundamental difference between the MD_MAX72xx_HW_Mapper sketch and the others of the library ?

It seems that my configuration is (according to the MD_MAX72xx_HW_Mapper test)

#define	HW_DIG_ROWS	0
#define	HW_REV_COLS	0
#define	HW_REV_ROWS	1

which is documented like this in the header :
"Combinations not listed here have probably not been tested and may not work correctly "

Is somebody have faced the same problems ?

Provide a link to the hardware so we can see what you are doing.

Thanks Marco for your answer.

My hardware is what you call "generic", a chinese one.

I'm using an Arduino Uno.

My wiring is like this
Arduino Uno - Matrix Dot
+5v -> Vin
Gnd -> Gnd
pin 12 Data -> DIN
pin 11 CLK -> CLK
pin 10 CS -> CS

I made some tests this morning, I changed the matrix (I have several), and I changed the Arduino.
Same results.

I made the MD_MAX72xx_HW_Mapper test with the matrix like this :

|||| up
I----I
I I
I----I
I I
I----I
I I
I----I
I I
I----I down

So as I said, in this orientation, the test give me this result :

#define	HW_DIG_ROWS	0
#define	HW_REV_COLS	0
#define	HW_REV_ROWS	1

So I changed the MD_MAX72xx_lib.h to :

#if USE_OTHER_HW	    // user defined custom hardware configuration
//#pragma message "OTHER HW selected"
#define	HW_DIG_ROWS	0 ///< MAX72xx digits are mapped to rows in on the matrix
#define	HW_REV_COLS	0 ///< Normal orientation is col 0 on the right. Set to 1 if reversed
#define	HW_REV_ROWS	1 ///< Normal orientation is row 0 at the top. Set to 1 if reversed
#endif

and the MD_MAX72xx.h to :

/**
 \def USE_OTHER_HW
 Set to 1 to use other hardware not defined above.
 Module 0 (Data In) must be set up on the RHS and the CUSTOM hardware defines
 must be set up in the MD_MAD72xx_lib.h file under for this section, using the HW_Mapper
 utility to work out what the correct values to use are.
 */
#define	USE_OTHER_HW	1

Is there anything wrong in this configuration ?
I tried to reverse (180°) the matrix, and change the config files but without success.

" Module 0 (Data In) must be set up on the RHS"
What do you call RHS ?

That looks like one of those 4 connected modules. They are usually fc-16 type, not generic.

How is that a 32x78 display as per your opening post?

Yes I forget to mention that I use a 4 connected module.

And it's a 32x8. Wrong typing :slight_smile:

I just tried the MD_MAX72xx_HW_Test with fc-16 settings.

The whole matrix light up and strange characters sometimes appears...

Forget using hw-test and just set fc-16 in the library. Then make sure you are starting the Parola library with the right parameters or you have the right pins connected for hardware spi.

My MD_MAX72xx.h :

/**
 * \file
 * \brief Main header file for the MD_MAX72xx library
 */

/**
 \def USE_PAROLA_HW
 Set to 1 (default) to use the Parola hardware modules. The
 software was originally designed to operate with this hardware type.
 */
#define	USE_PAROLA_HW	0

/**
 \def USE_GENERIC_HW
 Set to 1 to use 'generic' hardware modules commonly available, with
 connectors at the top and bottom of the PCB, available from many sources.
 */
#define	USE_GENERIC_HW	0

/**
 \def USE_ICSTATION_HW
 Set to 1 to use ICStation DIY hardware module kits available from
 http://www.icstation.com/product_info.php?products_id=2609#.UxqVJyxWGHs
 This hardware must be set up with the input on the RHS.
 */
#define	USE_ICSTATION_HW	0

/**
 \def USE_FC16_HW
 Set to 1 to use FC16 hardware module kits.
 FC16 modules are similar in format to the ICStation modules but are wired differently.
 Modules are identified by a FC-16 designation on the PCB
  */
#define	USE_FC16_HW	1

/**
 \def USE_OTHER_HW
 Set to 1 to use other hardware not defined above.
 Module 0 (Data In) must be set up on the RHS and the CUSTOM hardware defines
 must be set up in the MD_MAD72xx_lib.h file under for this section, using the HW_Mapper
 utility to work out what the correct values to use are.
 */
#define	USE_OTHER_HW	0

/**
 \def USE_LOCAL_FONT
 Set to 1 (default) to enable local font in this library and enable
 loadChar() and related methods. If the library is just used for
 graphics some FLASH RAM can be saved by not including the code to process
 font data. The font file is stored in PROGMEM.
 */
#define	USE_LOCAL_FONT	1

/**
 \def USE_INDEX_FONT
 Set to 1 to enable font indexing to speed up font lookups - usually disabled.
 This will trade off increased stack RAM usage for lookup speed if enabled.
 When disabled lookups will then become linear searches through PROGMEM.
 Uses ASCII_INDEX_SIZE elements of uint16_t (512 bytes) if enabled. For most
 purposes the increase in speed is not needed.

 USE_LOCAL FONT must be enabled for this option to take effect.
 */
#define	USE_INDEX_FONT	0

// Display parameter constants
// Defined values that are used throughout the library to define physical limits
#define	ROW_SIZE	8		///< The size in pixels of a row in the device LED matrix array
#define COL_SIZE  8		///< The size in pixels of a column in the device LED matrix array
#define	MAX_INTENSITY	0xf	///< The maximum intensity value that can be set for a LED array
#define	MAX_SCANLIMIT	7	  ///< The maximum scan limit value that can be set for the devices

I checked et rechecked my wiring and the pin assignement in the sketch.

I tried to run the Parola_HelloWorld.
The whole matrix light up and that's all.

It's very frustrating >:(

I continue my project with the LedControl library and this 32x8 matrix, but I must complete this project by a 96 x 16 matrix.
And with all the searches I've made, I think I will need you library !

Have you ever heard about incompatible hardware with your library ?

I am pretty sure you have not got incompatible hardware. Most 'problems' are usually people not reading documentation, code comments or following instructions.

+5v -> Vin
Gnd -> Gnd
pin 12 Data -> DIN
pin 11 CLK -> CLK
pin 10 CS -> CS

  1. Make sure you are using the latest versions of both libraries.

  2. If you are using a separate power supply make sure the GND for this module is connected to the GND on the Arduino.

  3. At the top of any of the examples is this:

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define MAX_DEVICES 4
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN    10

// Hardware SPI connection
MD_Parola P = MD_Parola(CS_PIN, MAX_DEVICES);
// Arbitrary output pins
// MD_Parola P = MD_Parola(DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

As per the comments:

If you are using the Hardware SPI connection then the pins (CLK, DATA, CS) on a Uno must be as per the code (13, 10, 11) not the ones you have (11, 12, 10).

If you are not using Hardware SPI, then you need to comment out the hardware SPI variable declaration and uncomment the one below for Arbitrary output pins. Then you can use whatever you like but the performance is lower.

Thanks for the help !

And you were so right when you say "Most 'problems' are usually people not reading documentation, code comments or following instructions."

The problem was the spi connection. I didn't noticed the uncomment trick for arbitrary pins...

As I have the luck to speak with you, do you think I can achieve my 96x16 matrix (6 of the 4 connected modules) with one single SPI connection, in terms of performance ?

As I have the luck to speak with you, do you think I can achieve my 96x16 matrix (6 of the 4 connected modules) with one single SPI connection, in terms of performance ?

No problems with that setup for hardware SPI. I have no experience with software SPI with that many but it should work. It is just a LOT slower.

If "x16" you intent double height display, then be aware there seems to be an intermittent bug with multi zone displays height that has been discussed on other forum threads. Still no solution at the time of this post.

Yes I wanted to do a double height sketch project.

Have you got some links about the bug you described ?
I have tried to google it, with no success.

Just look in the main Parola thread in Exhibition/Gallery forum.

Hi Marco_C
I followed your examples and it is indeed very helpful, now I am trying to achieve is to have multiple lines with have its own messages with its own CS number, but only one works.

Any issue with belew code?

// Use the Parola library to scroll text on the display
//
// Demonstrates the use of the scrolling function to display text received
// from the serial interface
//
// User can enter text on the serial monitor and this will display as a
// scrolling message on the display.
// Speed for the display is controlled by a pot on SPEED_IN analog in.
// Scrolling direction is controlled by a switch on DIRECTION_SET digital in.
// Invert ON/OFF is set by a switch on INVERT_SET digital in.
//
// UISwitch library can be found at https://github.com/MajicDesigns/MD_UISwitch
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//
//# ModuleType_t
//MD_MAX72XX::PAROLA_HW  LITERAL1
//MD_MAX72XX::GENERIC_HW  LITERAL1
//MD_MAX72XX::ICSTATION_HW  LITERAL1
//MD_MAX72XX::FC16_HW LITERAL1

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::ICSTATION_HW
#define MAX_DEVICES 12
#define CLK_PIN   13
#define DATA_PIN  11
#define CS_PIN1    10
#define CS_PIN2    9
#define CS_PIN3    6

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN1, MAX_DEVICES);
MD_Parola Q = MD_Parola(HARDWARE_TYPE, CS_PIN2, MAX_DEVICES);
MD_Parola R = MD_Parola(HARDWARE_TYPE, CS_PIN3, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

uint8_t scrollSpeed = 25;    // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 2000; // in milliseconds

// Global message buffers shared by Serial and Scrolling functions
#define  BUF_SIZE  75
#define  BUF_SIZE2  75
#define  BUF_SIZE3  75
char curMessage[BUF_SIZE] = { "" };
char curMessage2[BUF_SIZE2] = { "" };
char curMessage3[BUF_SIZE3] = { "" };
char newMessage[BUF_SIZE] = { "Line 1" };
char newMessage2[BUF_SIZE2] = { "Line 2" };
char newMessage3[BUF_SIZE3] = { "Line 3" };

bool newMessageAvailable = true;
bool newMessageAvailable2 = true;
bool newMessageAvailable3 = true;


void setup()
{
  Serial.begin(57600);
  Serial.print("\n[Parola Scrolling Display]\nType a message for the scrolling display\nEnd message line with a newline");

  P.begin();
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
//Q.begin();
//Q.displayText(curMessage2, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
//R.begin();
//R.displayText(curMessage3, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}

void loop()
{

  if (P.displayAnimate())
  {
    if (newMessageAvailable)
    {
      strcpy(curMessage, newMessage);
      newMessageAvailable = false;
    }
    P.displayReset();
  }

/*
  if (Q.displayAnimate())
  {
    if (newMessageAvailable2)
    {
      strcpy(curMessage2, newMessage2);
      newMessageAvailable2 = false;
    }
    Q.displayReset();
  }
*/
/*
  if (R.displayAnimate())
  {
    if (newMessageAvailable3)
    {
      strcpy(curMessage3, newMessage3);
      newMessageAvailable3 = false;
    }
    R.displayReset();
  }
*/
}

Are you serious? All the code referencing Q and R is commented out.

Thans Marco for the prompt reply,

Yes There were commented out as when I activated them the where the problem arises

Please in future post the code that does not work rather than a facsimile.

Also, when you ask for help please give more details:
In what way doesn't it work? What do you expect to see and what do you actually see?
How are the modules wired?
What power supply are you using?
Have you got the latest libraries?

By resetting "newMessageAvailable = false;" in the first check you do realise that it will fail for every other check following?