DMD Brightness control

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Papbo
Posts: 12
Joined: Sun Feb 19, 2017 10:59 am

Re: DMD Brightness control

Post by Papbo » Mon Mar 06, 2017 7:10 pm

Loki wrote:Now i understand, i checked my wirings and it is not connected anywhere.
ok Loki, It was also my conclusion...and I don't know how to use this pin 53 or if it is for a further usage??
Regards
Papbo

Loki
Posts: 18
Joined: Mon Jul 06, 2015 7:12 pm

Re: DMD Brightness control

Post by Loki » Mon Mar 06, 2017 8:09 pm

it has some SPI functionality, but if you use part of hw SPI for dmd it will be useless for anything else

Papbo
Posts: 12
Joined: Sun Feb 19, 2017 10:59 am

Re: DMD Brightness control

Post by Papbo » Tue Mar 07, 2017 12:08 pm

Loki wrote:it has some SPI functionality, but if you use part of hw SPI for dmd it will be useless for anything else
Ok Loki,
Regards
papbo

aprada66
Posts: 4
Joined: Sun Jul 30, 2017 3:03 pm

Re: DMD Brightness control

Post by aprada66 » Mon Jul 31, 2017 11:10 pm

Hi:

Here is my solution using timer2 to:
a) Control the DMD scanning
b) Control the brithtness

How to work:
Using timer2 interrupts in normal mode, the service routine turns ON and OFF the display, according the state of OE signal.


THE CODE:

//In Setup:
TCCR2A = B00000000; //Normal port operation
TCCR2B = B00000101; //clk/128
TCNT2 = 0;
TIMSK2 = B00000010; //Timer2 interrupt enabled (each 2ms)


//Timer2 interrupt service routine:
ISR(TIMER2_COMPA_vect) //Interruption every 2ms
{
if(!digitalRead(PIN_DMD_nOE))//Display OFF?
{//Display ON
TCNT2 = 255 - dmdBrillo;//dmdBrillo is a register with (1=min and 254=max)
dmdDelay++;
dmd.scanDisplayBySPI();
}
else
{//Display OFF
TCNT2 = dmdBrillo + 1;//dmdBrillo is a register with (1=min and 254=max)
OE_DMD_ROWS_OFF();
}
}

hapra2000
Posts: 1
Joined: Fri Oct 27, 2017 5:46 pm

Re: DMD Brightness control

Post by hapra2000 » Fri Oct 27, 2017 6:08 pm

Loki wrote:
Tue Feb 21, 2017 9:20 pm

Hi in attachemnt is updated DMD.cpp + DMD.h with birghtness and split step marquee as seen in my video, use Timer1.initialize( 5100 );
it works for me withou resistor on MEGA and UNO.just copy it onto %USERPROFILE%\My documents\Arduino\libraris\DMD

that Flickering on video is problem with phone camera and its refresh rate, it is not visible in real.
Hi Loki,
Your modification code is very good.
But it seem your code of stepmarquee2 function missing from DMD.cpp ?
Do you have the updates shareable ?

gogoce
Posts: 1
Joined: Sun Oct 14, 2018 7:27 pm

Re: DMD Brightness control

Post by gogoce » Sun Oct 14, 2018 7:47 pm

Brissieboy wrote:
Sat Jan 18, 2014 11:37 am
I have played around a fair bit with brightness control for the DMDs. Here is how I achieved it.
First you will need to install a pull-down resistor on the Output Enable line (incorrectly labelled nOE on the little DMD Connector board. The value is not critical but around 10K should be fine. It needs to be connected between nOE (D9) and any convenient Gnd pin. This wont work properly without it. (It also helps prevent the random LED flash on powerup.)
(EDIT: Actually the value is a little more critical than that. It needs to be LESS THAN 10k. This is to ensure the DMD sees a logic low even when/if the Arduino 20k internal pull-up is enabled.) I suggest 4k7 (or 5k6 or 6k8).
In DMD.h:
Change the following lines
#define OE_DMD_ROWS_OFF() { digitalWrite( PIN_DMD_nOE, LOW ); }
#define OE_DMD_ROWS_ON() { digitalWrite( PIN_DMD_nOE, HIGH ); }
to:
#define OE_DMD_ROWS_OFF() { pinMode( PIN_DMD_nOE,INPUT ); } // leaves the line floating
#define OE_DMD_ROWS_ON() { pinMode( PIN_DMD_nOE, OUTPUT ); } // re-asserts with PWM still as set

The brightness can be set/changed with the following line within your sketch:
Timer1.setPwmDuty(PIN_DMD_nOE, Brightness);
where "Brightness" is an integer between 0 (off) and 1024 (100%)
It will need to be set initially in your setup() area and then can be changed anywhere else in your sketch that it needs to be done.
Most control is achieved at the lower range values (around 10 as a minimum useable, and 1024 giving 100% brightness, and 100 giving about half brightness) with the scale looking like it is logarithmic rather than linear. I found the following steps to be an acceptable range: 10, 16, 25, 40, 64, 100, 160, 250, 400, 640, 1024.

EDIT:
As I mention in a later post, you also need to start the PWM by including this in your setup() code:

Code: Select all

  Timer1.pwm(PIN_DMD_nOE, Brightness); // to setup PWM and the starting brightness
  Timer1.attachInterrupt(ScanDMD);
So the steps are:
1. Fit the 4k7 resistor
2. Modify the 2 lines in the dmd.h file
3. Declare the variable 'Brightness' as an int
4. Add Timer1.pwm() to setup() as explained above
5. Set the brightness as required within the body of your sketch using Timer1.setPwmDuty()
6. Make sure the DMD is powerered properly.

Many thanks to stryker for being the guineapig and working through the all this!!
/*--------------------------------------------------------------------------------------

dmd_clock_readout.cpp
Example clock readout project for the Freetronics DMD, a 512 LED matrix display
panel arranged in a 32 x 16 layout.

Copyright (C) 2011 Marc Alexander (info <at> freetronics <dot> com)

See http://www.freetronics.com/dmd for resources and a getting started guide.

Note that the DMD library uses the SPI port for the fastest, low overhead writing to the
display. Keep an eye on conflicts if there are any other devices running from the same
SPI port, and that the chip select on those devices is correctly set to be inactive
when the DMD is being written to.

USAGE NOTES
-----------

- Place the DMD library folder into the "arduino/libraries/" folder of your Arduino installation.
- Get the TimerOne library from here: http://code.google.com/p/arduino-timero ... loads/list
or download the local copy from the DMD library page (which may be older but was used for this creation)
and place the TimerOne library folder into the "arduino/libraries/" folder of your Arduino installation.
- Restart the IDE.
- In the Arduino IDE, you can open File > Examples > DMD > dmd_demo, or dmd_clock_readout, and get it
running straight away!

The DMD comes with a pre-made data cable and DMDCON connector board so you can plug-and-play straight
into any regular size Arduino Board (Uno, Freetronics Eleven, EtherTen, USBDroid, etc)

Please note that the Mega boards have SPI on different pins, so this library does not currently support
the DMDCON connector board for direct connection to Mega's, please jumper the DMDCON pins to the
matching SPI pins on the other header on the Mega boards.

This example code is in the public domain.
The DMD library is open source (GPL), for more see DMD.cpp and DMD.h

--------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------
Includes
--------------------------------------------------------------------------------------*/
#include <SPI.h> //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h> //
#include <TimerOne.h> //
#include "Arial_black_16.h"
int brightness;
//Fire up the DMD library as dmd
DMD dmd(1, 1);

/*--------------------------------------------------------------------------------------
Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
called at the period set in Timer1.initialize();
--------------------------------------------------------------------------------------*/
void ScanDMD()
{
Timer1.setPwmDuty(PIN_DMD_nOE, Brightness);
//brightness = 400;
//dmd.scanDisplayBySPI(); //Parlaklık degeri 0-255 -- Yakop°
}

/*--------------------------------------------------------------------------------------
Show clock numerals on the screen from a 4 digit time value, and select whether the
flashing colon is on or off
--------------------------------------------------------------------------------------*/
void ShowClockNumbers( unsigned int uiTime, byte bColonOn )
{
dmd.clearScreen(true);
dmd.drawChar( 1, 3, '0' + ((uiTime % 10000) / 1000), GRAPHICS_NORMAL ); // thousands
dmd.drawChar( 8, 3, '0' + ((uiTime % 1000) / 100), GRAPHICS_NORMAL ); // hundreds
dmd.drawChar( 17, 3, '0' + ((uiTime % 100) / 10), GRAPHICS_NORMAL ); // tens
dmd.drawChar( 25, 3, '0' + (uiTime % 10), GRAPHICS_NORMAL ); // units
if ( bColonOn )
dmd.drawChar( 15, 3, ':', GRAPHICS_OR ); // clock colon overlay on
else
dmd.drawChar( 15, 3, ':', GRAPHICS_NOR ); // clock colon overlay off
}

/*--------------------------------------------------------------------------------------
setup
Called by the Arduino architecture before the main loop begins
--------------------------------------------------------------------------------------*/



void setup(void)
{
int brightness;
brightness = 460
Timer1.initialize( 5000 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.pwm(PIN_DMD_nOE, Brightness); // to setup PWM and the starting brightness
Timer1.attachInterrupt(ScanDMD);

//clear/init the DMD pixels held in RAM
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)
dmd.selectFont(Arial_Black_16);

}

/*--------------------------------------------------------------------------------------
loop
Arduino architecture main loop
--------------------------------------------------------------------------------------*/
void loop(void)
{
unsigned int ui;

// 10 x 14 font clock, including demo of OR and NOR modes for pixels so that the flashing colon can be overlayed
ui = 1234;
ShowClockNumbers( ui, true );
delay( 1000 );
ShowClockNumbers( ui, false );
delay( 1000 );
ShowClockNumbers( ui, true );
delay( 1000 );
ShowClockNumbers( ui, false );
delay( 1000 );

ui = 2345;
ShowClockNumbers( ui, true );
delay( 1000 );
ShowClockNumbers( ui, false );
delay( 1000 );
ShowClockNumbers( ui, true );
delay( 1000 );
ShowClockNumbers( ui, false );
delay( 1000 );
}



ERROR !!!!!!!!!!!!!!!!!!!

User avatar
stryker
Posts: 270
Joined: Sat Jan 14, 2012 2:44 pm

Re: DMD Brightness control

Post by stryker » Sun Oct 28, 2018 6:17 am

ERROR !!!!!!!!!!!!!!!!!!!
I've not looked further, but this code generates an error at compile time:

Code: Select all

'Brightness' was not declared in this scope
c++ is case sensitive. You've defined brightness but then pass Brightness (uppercase B) to the pwm function. Additionally, not sure if you mean to but you define brightness as a global variable, and also again as a variable of local scope in setup(). Presuming that was a mistake I commented that out when testing.

Code: Select all

void setup(void)
{
//  int brightness;
Fix those, and it compiles.

Cheers, Geoff

Post Reply