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 with less EMI emissions. 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_Circuit_Schematic
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.

The MD_MAX72xx library needs to be informed of the the following parameters 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.

 

In MD_MAX72xx prior to version 3.0.0, the type of module being used for the library is defined by editing the appropriate #define in the MD_MAX72xx header file. For most users, this will be the only action necessary.

From version 3.0.0 onwards, the module type is specified in the application as one of the parameters to the class constructor. This eliminates the need to edit the library header file for the different module types.

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 is used for testing.

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 mapping can be matched to an existing hardware type.

Advertisements

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

  1. Mario

    Hi Marco,

    Thanks for the library but I have two questions:

    1. Where did you get the info that the MAX7221 is for use with common anode displays?
    The datasheets states:
    The MAX7219 and MAX7221 are identical except for two parameters: the MAX7221 segment drivers are slew-rate limited to reduce electromagnetic interference (EMI), and its serial interface is fully SPI compatible.
    They also mention a difference in behaviour of pin 12 (Load data/ chip select) but there is no mention of common anode use.

    2. Can you advise on the best way to modify the library for use with 8 rows x 5 cols matrix displays instead of 8×8 displays?

    Thanks,

    Mario

    Like

    1. You are correct that the 7221 is the same. Article has been amended.

      What needs to be done depends on your hardware. If is is not MAX72xx then I would find a different way to do this. If is is MAX72xx then you will need to restrict the active ‘digits’ in the hardware (scan register) and also ensure that the module boundary calculations are correct as you now have to divide by 5 rather than 8. This could be as easy as changing a constant but I doubt it.

      Like

      1. Mario

        Thanks for the advice.
        I have a bunch of 8×5 matrix units so I’m looking for a way to use them.
        There is no controlling hardware connected so I think I will go for the MAX72xx option and try to get the code working.

        Like

  2. bgpssk

    Hi marco_c

    I wasted almost 1 week researching on how to fix the mirrored letters on 32*8 LED matrix using Parola library. Every talks about making parameter (USE_PAROLA_HW or USE_GENERIC_HW) changes in MD_MAX72xx.h. No one has provided the explanation as you have provided. Suggestion to use “Determining New Hardware Configurations” is excellent and should resolve the problem. Will try out and update this post if issue is resolved.

    Like

    1. Sorry it took you so long to get to the info. Similar info is available in the information supplied with the libraries and there is a clear warning on the github site README file that the modules need to be configured in the library.

      Worst case you can just try each of the module types in turn. Nothing will get damaged – you will just see various permutations of incorrect behavior.

      If you get no joy, tech support is easier in the Arduino forum at http://forum.arduino.cc/index.php?topic=171056.0

      Like

      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?

        Like

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

        Like

  3. 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…

    Like

      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.

        Like

      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.

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s