Arduino MEGA 2560

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
TheRevva

Arduino MEGA 2560

Post by TheRevva » Thu Oct 17, 2013 9:25 am

If there's anyone out there who wants to connect up a DMD to an Arduino MEGA using the supplied DMD_CON board (i.e. without having to make a mess with jumper wires to re-route pins to the MEGA SPI pins)...
Well, I've made some 'mods' to the DMD library to make it work...
Basically, it eliminates the need for SPI altogether replacing the SPI calls with low-level bit-banging on the appropriate pins... (8 thru 13).
In the interests of speeding things up, I also changed all the digitalWrite() calls into low level direct port access so this code will ONLY work on a MEGA. It'd be easy enough to convert back to digitalWrite(), but I see no reason why anyone would want to.

The zip file below contains an updated DMD.h and DMD.cpp which must be copied into your Arduino 'libraries' sub-folder.
DMD.zip
(8.37 KiB) Downloaded 722 times
Enjoy.

NB: I have NOT calculated the new pixel dot clock rate. However, it's probably quite a bit more than the 125kHz used in the SPI library version. Therefore, USE SHORT CABLES!!!

RuralGeek
Posts: 10
Joined: Tue Aug 27, 2013 3:57 am

Re: Arduino MEGA 2560

Post by RuralGeek » Sun Nov 03, 2013 10:21 pm

Nice work - will put it to the test on my Mega2560 clones tonight and report back the results.

RuralGeek
Posts: 10
Joined: Tue Aug 27, 2013 3:57 am

Re: Arduino MEGA 2560

Post by RuralGeek » Mon Nov 04, 2013 9:48 am

I get an error when compiling:
Error 8 error : error: 'PORTH' was not declared in this scope

Something to do with these #defines:

Code: Select all

#define LIGHT_DMD_ROW_01_05_09_13()       { PORTH &= 0xE7; }			// { digitalWrite( PIN_DMD_B,  LOW ); digitalWrite( PIN_DMD_A,  LOW ); }
#define LIGHT_DMD_ROW_02_06_10_14()       { PORTH &= 0xEF; PORTH |= 0x08; }	// { digitalWrite( PIN_DMD_B,  LOW ); digitalWrite( PIN_DMD_A, HIGH ); }
#define LIGHT_DMD_ROW_03_07_11_15()       { PORTH &= 0xF7; PORTH |= 0x10; }	// { digitalWrite( PIN_DMD_B, HIGH ); digitalWrite( PIN_DMD_A,  LOW ); }
#define LIGHT_DMD_ROW_04_08_12_16()       { PORTH |= 0x18; }			// { digitalWrite( PIN_DMD_B, HIGH ); digitalWrite( PIN_DMD_A, HIGH ); }
#define LATCH_DMD_SHIFT_REG_TO_OUTPUT()   { PORTH |= 0x20; PORTH &= 0xDF; }	// { digitalWrite( PIN_DMD_SCLK, HIGH ); digitalWrite( PIN_DMD_SCLK,  LOW ); }
#define OE_DMD_ROWS_OFF()                 { PORTH &= 0xBF; }			// { digitalWrite( PIN_DMD_nOE, LOW  ); }
#define OE_DMD_ROWS_ON()                  { PORTH |= 0x40; }			// { digitalWrite( PIN_DMD_nOE, HIGH ); }
Any ideas?

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Arduino MEGA 2560

Post by angusgr » Wed Nov 06, 2013 5:24 am

Hi RuralGeek,

Do you have Arduino Mega 2560 selected as the board type? Only the Megas have enough pins to reach PORTH.

- Angus

RuralGeek
Posts: 10
Joined: Tue Aug 27, 2013 3:57 am

Re: Arduino MEGA 2560

Post by RuralGeek » Wed Nov 06, 2013 6:13 am

Gotcha - thanks for that - have been testing VS2012 as shown here: http://www.megunolink.com/building-ardu ... al-studio/

Will change the hardware type and go from there.

markc
Posts: 1
Joined: Sat Aug 09, 2014 8:07 am

Re: Arduino MEGA 2560

Post by markc » Sat Aug 09, 2014 8:08 am

Ah perfect - thank you so much for sharing!

coromonadalix
Posts: 26
Joined: Wed Apr 09, 2014 9:03 pm

Re: Arduino MEGA 2560

Post by coromonadalix » Sun Aug 24, 2014 2:11 pm

hello

This worked ...

But i renamed it DMDmega and put it in the librairies, and changed all the occurences of dmd.h and dmd.cpp to dmdmega.h and dmdmega.cpp, and in the files themselves too.

This way i can work with my two different arduino boards ...

gennaropirozzi
Posts: 1
Joined: Mon Apr 06, 2015 3:24 pm

Re: Arduino MEGA 2560

Post by gennaropirozzi » Mon Apr 06, 2015 3:35 pm

Hello,
I hawe download DMD.ZIP for MEGA 2560 and without change any pin of DMD connector I have all led in reverse mode with demo program
id est the led which must on is off and the led which must on is off!!!!!!!!!
What I to do????
Thanks you.

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: Arduino MEGA 2560

Post by angusgr » Wed Apr 08, 2015 12:24 am

Hi gennaro,

I can't help you with MEGA2560, sorry, but another option is to use the DMD2 beta library:
https://github.com/freetronics/DMD2

It should just work on MEGA2560, using same pins as the library in this thread.

Angus

Copycat
Posts: 1
Joined: Thu Apr 07, 2016 2:33 am

Re: Arduino MEGA 2560

Post by Copycat » Sat Apr 09, 2016 12:39 pm

Hello, I purchased the 32X16 DMD display with DMDCON connector. It worked perfectly on my arduino uno R3. I need to use it on an arduino mega which I am experiencing difficulties. From the DMDCON connector I used jumpers to pins 50 thru 52 instead of 11 thru 13. The display works but only if I apply a small amount of pressure on the corner of the micro processor. Otherwise the display is garbled junk or nothing at all. I've tried two different arduino mega's and a sainsmart mega all with the same result. Any idea what the issue is?

I certainly would like to do away with the jumpers and plug the DMDCON connector right into the mega pins. Is this where the DMD2 comes into play or should I try the modified DMD files using the bit banging process as mentioned in this topic discussion. Any help would be greatly appreciated!

Post Reply