Parola A to Z – Adapting for Different Hardware

Parola_ModuleAn ongoing question on many Arduino forums is the adaptation of software to the different types of matrix modules. Usually the poster has tried some LED matrix software and the display is reversed or upside down, or animations are disjointed across the module boundaries.

There are clear reasons this happens, and the Parola library has software configuration parameters that allow you to adapt how the software operates to suit your hardware module.

Why is there a problem?

The first thing to understand is why there is a problem at all.

The MAX7219 control IC was originally designed to control up to 8 digits of 7 segment display. Each digit has 7 LED segments (named a to g) and a decimal point (dp) connected through a common cathode. The MAX7221 does the same thing but for a common anode type display. The IC multiplexes the display of the segments sequentially across all the digits to be displayed.

Basically, the IC capable of controlling 64 individual LEDs (8 digits x (7 seg + 1 dp)) and there are 64 LEDs in a LED matrix.

However, unlike the mapping to digits/segments, there is no standard mapping of the 64 LEDs to matrix rows and columns. So there are a number of hardware configurations that can (and do!) result, depending on how the hardware designer has wired up the MAX7219 to the LED module:

  • ‘Rows’ can be wired as ‘digits’ or ‘segments’ increasing left to right or right to left
  • ‘Columns’ can be wired as ‘segments’ or ‘digits’ increasing  top to bottom or bottom to top.
Parola Module Circuit Diagram

So, any matrix can be physically wired so that the matrix orientation (in physical space) can have rows or columns in either direction and in any order. This means that writing a library like Parola, where the code must assume a standard coordinate system for it to work, requires a mapping between the physical pixels (LEDs) and this standard coordinate system.

A Brief Word on Coordinate Systems

Two Cartesian coordinate systems are used in the library. One defines the pixels seen (display coordinates), and the other is an underlying hardware coordinate system based on digits and segments mapping to the MAX72xx hardware control registers.

In Parola, display coordinates always have their origin in the top right corner of a display and by convention

  1. Column numbers (and therefore module numbers) increment to the left
  2. Row numbers (0..7) increment top to bottom

All user functions consistently use display coordinates to make animations independent of underlying hardware changes. It is the job of the hardware control library functions to map display coordinates to hardware coordinates.

Adapting the Library

The coordinate system mapping is a function of the hardware library (MD_MAX72xx). From the above discussion, the hardware library needs to know if

  1. ‘Digits’ are mapped to rows or columns. This also fixes ‘segments’ to the other axis.
  2. The order in which each axis is wired (up/down and left/right). A simplifying assumption (which has been valid so far!) is that the LEDs are wired sequentially and not in random order.

Therefore the MD_MAX72xx_lib.h header file defines the following indicators to direct the hardware coordinate mapping:

  • HW_DIG_ROWS – set to 1 if MAX72xx digits are mapped to rows in on the matrix
  • HW_REV_COLS – set to 0 for normal orientation with col 0 on the right, set to 1 if reversed
  • HW_REV_ROWS – set to 0 for normal orientation with row 0 at the top set to 1 if reversed

In practice, there seems to be four common types of matrix modules on the market, and so it is convenient to define ‘canned’ combinations for those matrix types:

  • Parola style modules that are now manufactured as kits by ElectroDragon. The library was originally developed for this module type.
  • Generic Modules commonly available from many suppliers (eg, eBay) at reasonable cost. They are characterized by IN and OUT connectors at the short ends of the rectangular PCB.
  • ICStation kit module available as kits from ICStation.
  • FC-16 modules identifiable by the FC-16 designation silk-screened on the PCB. Many of the ‘joined-up’ module systems are made up of individual FC-16 modules.

The type of module being used for the library can be defined by editing the appropriate #define in the MD_MAX72xx header file. For most users, this will be the only action necessary.

Determining New Hardware Configurations

The library example code includes a utility called MD_MAX72xx_HW_Mapper. This is test software to map display hardware rows and columns. It uses a generic SPI interface and only one MAX72xx/8×8 LED module required.

It is independent of the libraries as the code is used to directly map the display orientation by setting pixels on the display and printing to the serial monitor which MAX72xx hardware component (segment and digit) is being exercised.

By observing the LED display and the serial monitor you can build a map like the one below. It is worth noting the direction in which the rows and columns are scanned by the utility, as this is the easiest way to work out the row/column reversal values.

The result of these observations is a grid definition that looks somewhat like:

DIG0 D1 D2 D3 D4 D5 D6 D7
Seg G
Seg F
Seg E
Seg D
Seg C
Seg B
Seg A
Seg DP

From this example mapping it is clear

  • MAX72xx digits map to the columns, HW_DIG_ROWS is 0.
  • DIG0 is on the left (columns were also scanned left to right), so HW_REV_COLS should be set
    to 1 to reverse it to the standard 0 on the right.
  • Seg G is at the top (rows were also top to bottom), so HW_REV_ROWS should be set to 0,
    as it is already standard with 0 on top.

Note that in some situations using the module ‘upside down’ will result in a better configuration than would otherwise be the case. An example of this is the generic module mapping. Also remember that the modules are daisy chained from right to left.

Having determined the values for the defines, the new mapping can be configured, or matched to an existing hardware type. A blank ‘USE_OTHER_HW’ canned combination is available in the MD_MAX72xx_lib.h file for this new configuration if it is selected in the main MD_MAX72xx.h header file.


8 thoughts on “Parola A to Z – Adapting for Different Hardware

  1. Hi Marco, First off thank you very much for creating these amazing library / module for the arduino. I’m not really sure what to call it but I thank you greatly. I just want to reach out to you to see if you can help me with the problem I encountered running other examples in the MD_MAX79xx. I can only run the test example. Other examples is not running correctly. I get garbled text in serial when running the print message example. I don’t have the arduino with me right now but I might be able to send pics later…


      1. Thank you again Marco. Why is it always the obvious mistakes are the one hard to resolve… Anyway, I got the MD_max72xx_printTest working. I just have another question regarding fonts. How can I use the sys_var_double font? I did run the txt2font and it produced a h file for sys_var_double but for the life of me I can never figure out how to use it in the printTest example. I have read the md_max72xx h file as well as the library but I can’t make or do not understand how to change font to sys_var_double. Can you please direct me to either an example or a discussion where this came up before? I have been searching the internet and I can’t find an example using this font.
        Again, I appreciate your help on this matter and I thank you greatly for your contribution and help to a fellow like me.


      2. The double height font is for double height displays. There is an A to Z article on working with double height displays and there are a bunch of double height examples to look at.


      1. thanks,those panels controled by 74h138 and 74h595. If I use 7219,32*64 needs 32 8*8led matrix.
        the question is parola lib supported so many led matrix?


      2. Yes it can support that many. So users have used up to 40+ in a row. However, this is on/off (sungle color) control only and not tri-color.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s