Arduino

LED Matrix Multi-Display with Arduino


The LedMx library is an Open Source library to easily control multiple IDM-LMX3208 series 32x8 LED matrix display boards with simple printf like functions.  Features accented fonts, left, center, right justification, blinking and intensity control.  Can combine multiple displays boards into single text line or separate them into multilines.  The library has an object wrapper class for C++ applications.  See demo video bellow showing different usage combinations of the displays.  The hardware supported by this library are shown at the bottom of this page.


The Software

API functions

void LedMxBlink(LEDMXDEV *pDev, int OnOff);
void LedMxInit(LEDMXDEV *pDev, LEDMXCFG *pCfg);
void LedMxIntensity(LEDMXDEV *pDev, int Level);
void LedMxPrintAt(LEDMXDEV *pDev, int col, const char *pStr);
void LedMxPrintCenter(LEDMXDEV *pDev, const char *pStr);
void LedMxPrintf(LEDMXDEV *pDev, LEDMXPRTMODE Mode, const char *pFormat, ...);
void LedMxvPrintf(LEDMXDEV *pDev, LEDMXPRTMODE Mode, const char *pFormat, va_list vl);
void LedMxPrintLeft(LEDMXDEV *pDev, const char *pStr);
void LedMxPrintRight(LEDMXDEV *pDev, const char *pStr);
void LedMxSetRam(LEDMXDEV *pDev, unsigned RamAddr, char Data, int Len, int PanelNo);
void LedMxWriteRam(LEDMXDEV *pDev, unsigned Addr, uint8_t const *pData, int Len, int DevNo);

Switch settings

There is a 4 positions DIP switch at the back of the IDM-LMX3208-30R board.  This DIP switch is set to make the board responds to the corresponding CS lines on the connector.   This is to allows 4 boards to be daisy-chained together on the same channel.  In each display chain, one must be set to CS1.  There is no require fixed physical order in which the board must be placed in the chain.  The software will order the displays accordingly based on the configuration settings.

I sell on Tindie

Configuration

Configuration data can be defined statically or dynamically in the code.   Shown bellow is a static configuration settings.  This configuration bellow is for one channel with 2 display boards.  The two display boards are daisy-chaned on channel 1 (i.e. connected to P1 on the LMXSHIELD).
#include "ardledmxio.h"
// The LEDMXIOCFG is the hardware configuration of I/O interface to the display. // In this case, it is the LMXSHIELD for Aduino Uno // Arduino Digital I/O pin mapping for the LMXSHIELD
LEDMXIOCFG g_IOCfg = { 
  LMXSHIELD_WR,    // WR pin 
  LMXSHIELD_RD,    // RD pin
  LMXSHIELD_DATA,  // Data pin
  LMXSHIELD_EN,    // Enable pin
  { LMXSHIELD_AD0, LMXSHIELD_AD1, LMXSHIELD_AD2, -1,}, // The LMXSHIELD uses 3 digital pins to address 8 Displays
  3, // Number of CS pins 
  LMXSHIELD_CSTYPE, // Type of addressing for access to display
};
// The LEDMXCFG is the LED matrix display arrangement configuration
// Each of this data structure define the arrangement of displays boards
// for a single line.  For multiple lines, many of this data structure 
// can be defined.
// In this config defines a line of 2 displays using display CS1 & CS2 of P1
LEDMXCFG g_Cfg = {
  &g_IOCfg,   // The I/O interface configuration above LEDMXIOCFG
  2,  // Number of display board connected, max 8 boards 
  {0, 1, 2, 3, 4, 5, 6, 7}, // display board ordering, 0-1 are on connector P1, 4-7 are on P2
};
// In this config # 2 defines a line of 4 displays using display CS1-CS4 of the P2
LEDMXCFG g_Cfg2 = {
  &g_IOCfg,   // The I/O interface configuration above LEDMXIOCFG
  2,  // Number of display board connected, max 8 boards 
  {4, 5, 6, 7, 0, 1, 2, 3}, // display board ordering, 0-1 are on connector P1, 4-7 are on P2
};
The configuration above is a typical use of 6 displays arranged in 2 lines with one LMXSHIELD.  Where the first line makes use of two 5mm displays IDM-LMX3208-50 to display data such as temperature, time, date, etc...  The 2nd line composes of four 3mm displays IDM-LMX3208-30 to displays scrolling messages. Now that the configurations are defined, we need declare the instance of the display to be used.     
// This is the data instance require by all LMX C functions.   // It is initialized bit LedMxInit.  
LEDMXDEV g_LmxDev;    // For line 1
LEDMXDEV g_LmxDev2;   // For line 2
// for C++ program use the LedMx class instead of LEDMXDEV
// LedMx g_LmxDev;  
// LedMx g_LmxDev2;

Inititalization


Before any display functions can be used.  The library and display need to be initialized with the previously defined configuration.  This is done by calling LedMxInit() function.  This is only need to be done once, unless we want to change configuration.  This function ensure that the digital pins are initialized properly, the fonts are set and the displays are energized   

LedMxInit(&g_LmxDev, &g_Cfg);     // For line 1   
LedMxInit(&g_LmxDev2&g_Cfg2);   // For line 2

Using C++ class, the initialization is  

g_lmxDev.Init(g_Cfg);     // For line 1  
g_lmxDev.Init(g_Cfg2);    // For line 2

Displaying


Now that the display is initialized, let show something on the display. To display a text string on the left side:   

LedMxPrintLeft(&g_LmxDev, "Text Left");
or   
LedMxPrintf(&g_LmxDev, LEDMXPRTMODE_JLEFT, "Text Left");

To display a text string on the right side:   

LedMxPrintRight(&g_LmxDev, "Text Right");
or   
LedMxPrintf(&g_LmxDev, LEDMXPRTMODE_JRIGHT, "Text Left");


Let make a text entering from the right and scrolls off to the left side.

  static char text[] = {"Scrolling Text"};
  int col = g_LmxDev.NbPanel;
  int i = col;
  int pixlen;
  pixlen = LedMxPixStrLen(&g_LmxDev, text);
  for (i = col; i + pixlen > 0; i-= 1)
  {
    LedMxPrintAt(&g_LmxDev, i, text);     // Adjust delay for faster or slower scrolling speed
    delay(5);
  }


Configuring for 2 independent channels


Configuring for two channels is very simple.  All we need to do is to add another config data.  From the same IO config already defined above.  Let add a new display configuration and let call them config2.

// LED matrix display configuration
LEDMXCFG g_Cfg2 = {
  &g_IOCfg,
  1,  // Number of display board in connected, max 8 boards 
  {4, 5, 6, 70, 1, 2, 3}, // display board ordering, here we use channel 2
};
// This is the data instance require by all LMX C functions.   // It is initialized bit LedMxInit.  
LEDMXDEV g_LmxDev2;   

Same as before, we need initialize the config2.   

LedMxInit(&g_LmxDev2&g_Cfg2);

Now to display on the new display configuration all we need to do is to use the config2 instead of the previous one. To display a text string on the left side on both display:   

LedMxPrintLeft(&g_LmxDev, "Text Left"); // display 1 (on channel 1)   
LedMxPrintLeft(&g_LmxDev2, "Text Left"); // display 2 (on channel 2)

Combining 2 channels into one display line


Previously, we have configured the library to use one channel with two displays boards.  Then we added an other channel with one display board.  Now let combine both channels into one big display of 96x8 pixels.  Here is the new configuration data.

// LED matrix display configuration
LEDMXCFG g_Cfg = {
  &g_IOCfg,
  3,  // Number of display board in connected, max 8 boards 
  {0, 1, 4,}, // display board ordering, 0-1 are on connector P1, 4-7 are on P2
};
LedMxInit(&g_LmxDev&g_Cfg);

We have the display board CS1 and CS2 on channel 1 combined with display board CS1 on channel 2. Library source code : https://github.com/hnhoan/LED-Matrix-Arduino
For other platform, see my EHAL page for general embedded software development.  Currently available for Bluetooth nRF51 series processor.


The hardware


The hardware supported by this library are listed bellow.  You buy them via Buy Now button or from eBay or Tindie by searching for IDM-LMX3208.


The shields

LMXSHIELD - Shield for Arduino to interface with the IDM-LMX3208 series displays.
Control up to 8 display boards
I sell on Tindie

The LMXSHIELD a display interface for Arduino Uno.  It has 2 channels where each channel can daisy-chained 4 display modules.  Digital output 2-8 of the Arduino are used by the shield to interface with the 8 display modules.  Software I/O configuration for the LMXSHIELD is as follow :

// The LEDMXIOCFG is the configuration of I/O interface to the display. // In this case, it is the LMXSHIELD for Aduino Uno // Arduino Digital I/O pin mapping for the LMXSHIELD
LEDMXIOCFG g_IOCfg = { 
  LMXSHIELD_WR,    // WR pin 
  LMXSHIELD_RD,    // RD pin
  LMXSHIELD_DATA,  // Data pin
  LMXSHIELD_EN,    // Enable pin
  { LMXSHIELD_AD0, LMXSHIELD_AD1, LMXSHIELD_AD2, -1,}, // The LMXSHIELD uses 3 digital pins to address 8 Displays
  3, // Number of CS pins 
  LMXSHIELD_CSTYPE, // Type of addressing for access to display
};
IBB-LMXBLUE - Shield for Arduino to control up to 16 IDM-LMX3208 series display boards with on board DC switching regulator.  Enough to power both the displays and Arduino.
Available now on tindie
The IBB-LMXBLUE a display interface that supports dual hosts Arduino and the IMM-NRF51822 Bluetooth module.  Install all jumpers JP1 side to select IMM-NRF51822,  jumpers series JP2 to select Arduino.  It has 4 channels where each channel can daisy-chained 4 display modules.  Digital output 2-9 of the Arduino are used by the shield to interface with the 16 display modules.  Software configuration for the IBB-LMXBLUE shield is as follow :

// The LEDMXIOCFG is the configuration of I/O interface to the display. // In this case, it is the IBB-LMXBLUE for Aduino Uno // Arduino Digital I/O pin mapping for the IBB-LMXBLUE
LEDMXIOCFG g_IOCfg = { 
  LMXSHIELD_WR,    // WR pin 
  LMXSHIELD_RD,    // RD pin
  LMXSHIELD_DATA,  // Data pin
  LMXSHIELD_EN,    // Enable pin
  { LMXSHIELD_AD0, LMXSHIELD_AD1, LMXSHIELD_AD2, LMXSHIELD_AD3,}, // The LMXSHIELD uses 4 digital pins to address 8 Displays
  4, // Number of CS pins 
  LMXSHIELD_CSTYPE, // Type of addressing for access to display
};


The display

32x8 LED matrix, dot size 3mm, pitch 4mm.
IDM-LMX3208-30R - Red LED.
IDM-LMX3208-30G - Green LED
available on Tindie
32x8 LED matrix, dot size 5mm, pitch 7.62mm.
IDM-LMX3208-50R - Red LED.
IDM-LMX3208-50G - Green LED
available on Tindie
The display module is the IDM-LMX3208 series,  32x8 LED matrix.  Available in 2 LED dot size, 3mm (IDM-LMX3208-30) and 5mm (IDM-LMX3208-50) with LED in Red or Green color.  The user guide is here
Features :
  • 16 levels PWM brightness control
  • Support Synchronized blinking in daisy chained configuration
  • Up to 4 boards can be daisychained together for a total of 128x8
  • Serial interface to microcontroller requires only 3 GPIOs
  • Dimension : 128x52mm (5.04" x 2.05"), 241x80mm (9.5" x 3.15")
  • Operating voltage 5V @165mA full on.
  • Wavelength 625-640 nm (Red color)
  • Wavelength 565-575 nm (Green color)

The kit

Kit containing one LMXSHIELD and two IDM-LMX3208 series display boards
I sell on Tindie
Other hardware
UART to RS-232 breakout board
I sell on Tindie

No comments:

Post a Comment