Help with scrolling Text

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Help with scrolling Text

Post by kitbots » Tue Oct 30, 2012 2:53 am

I've just got my DMD up and running and its working well with the DMDscrolltext demo.
I'd like to be able to scroll some text, flash on and off some none moving text, and then scroll some different text.
I'm a mech eng and its 30 plus years since I did any programming (in BASIC) and I can't get my head around how the coding works. Its really for a one off application (a scrolling sign welcoming audience to a show)

Could somebody please be so kind as to post the code to do the above?

Pete

joevpt
Posts: 6
Joined: Fri Sep 21, 2012 10:31 pm

Re: Help with scrolling Text

Post by joevpt » Wed Oct 31, 2012 9:07 pm

Here you go Pete...

Code: Select all

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

 dmd_pete.cpp 
--------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------
  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>   //Needed for the panel refresh which is done every 5ms.
#include "SystemFont5x7.h"  // Including both fonts.  If you don't need it, comment one out.
#include "Arial_black_16.h"

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1   // Just 1 panel x 1 panel
#define DISPLAYS_DOWN 1
#define FLASHES 4           // For the flashing text, number of flashes.

DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

/*--------------------------------------------------------------------------------------
  Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
  called at the period set in Timer1.initialize();
--------------------------------------------------------------------------------------*/
void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

/*--------------------------------------------------------------------------------------
  setup
  Called by the Arduino architecture before the main loop begins
--------------------------------------------------------------------------------------*/
void setup(void)
{

   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
   Timer1.initialize( 5000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
   Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()

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

}

/*--------------------------------------------------------------------------------------
  loop
  Arduino architecture main loop
--------------------------------------------------------------------------------------*/
void loop(void)
{
   byte b;

   // Clear the panel(s)
   dmd.clearScreen( true );

   // THE FIRST MESSAGE - SCROLLING
   // Select the font. Both fonts included here.  Just comment out one of them
   //dmd.selectFont(System5x7);
   dmd.selectFont(Arial_Black_16);
   char msgOne[] = "Scrolling Text for message 1";
   int msgOneLength = 28;
   dmd.drawMarquee(msgOne,msgOneLength,(32*DISPLAYS_ACROSS)-1,0);
   long start=millis();
   long timer=start;
   boolean ret=false;
   while(!ret){
     if ((timer+30) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }


   // THE SECOND MESSAGE NON SCROLLING - FLASHING
   // Select the font. Both fonts included here.  Just comment out one of them
   dmd.selectFont(System5x7);
   //dmd.selectFont(Arial_Black_16);
   char msgTwo[] = "Eight";
   int msgTwoLength = 5;
   int noOfFlashes = 3;
   for (int i=0;i<noOfFlashes;i++)
   {
     // Display the message (flash it on)  (1,5 = top corner of text )
     dmd.drawString(  1,  5, msgTwo, msgTwoLength, GRAPHICS_NORMAL );
     delay(500);  // wait 0.5 seconds
     // Blank the message ( flash it off)
     dmd.drawString(  1,  5, msgTwo, msgTwoLength, GRAPHICS_NOR );
     delay(500);  // wait 0.5 seconds
   }
   dmd.clearScreen( true );

   // THE THIRD MESSAGE -  SCROLLING
   // Select the font. Both fonts included here.  Just comment out one of them
   //dmd.selectFont(System5x7);
   dmd.selectFont(Arial_Black_16);
   char msgThree[] = "Scrolling Text for message 3";
   int msgThreeLength = 28;
   dmd.drawMarquee(msgThree,msgThreeLength,(32*DISPLAYS_ACROSS)-1,0);
   start=millis();
   timer=start;
   ret=false;
   while(!ret){
     if ((timer+30) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
   
   // A delay of 1 sec before we start again
   delay(1000);
   
}



kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Re: Help with scrolling Text

Post by kitbots » Thu Nov 01, 2012 1:14 pm

Brilliant!, Thanks, I'll try that out tonight.


Pete

kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Re: Help with scrolling Text

Post by kitbots » Mon Nov 05, 2012 8:19 pm

kitbots wrote:Brilliant!, Thanks, I'll try that out tonight.


Pete

It worked. Thanks.

kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Re: Help with scrolling Text

Post by kitbots » Tue Feb 19, 2013 6:55 pm

Just completed show where my two panel display worked well for more than two days running all day :D

I'd like to increase the scrolling speed but can't see the line in the code that controls that and
if anything its just too bright. I have a 4A powersupply running it now but did notice that when its running of the USB is much less bright......would just changing to say a 1A supply mimic this?





joevpt wrote:Here you go Pete...

Code: Select all

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

 dmd_pete.cpp 
--------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------
  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>   //Needed for the panel refresh which is done every 5ms.
#include "SystemFont5x7.h"  // Including both fonts.  If you don't need it, comment one out.
#include "Arial_black_16.h"

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1   // Just 1 panel x 1 panel
#define DISPLAYS_DOWN 1
#define FLASHES 4           // For the flashing text, number of flashes.

DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

/*--------------------------------------------------------------------------------------
  Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
  called at the period set in Timer1.initialize();
--------------------------------------------------------------------------------------*/
void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

/*--------------------------------------------------------------------------------------
  setup
  Called by the Arduino architecture before the main loop begins
--------------------------------------------------------------------------------------*/
void setup(void)
{

   //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
   Timer1.initialize( 5000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
   Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()

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

}

/*--------------------------------------------------------------------------------------
  loop
  Arduino architecture main loop
--------------------------------------------------------------------------------------*/
void loop(void)
{
   byte b;

   // Clear the panel(s)
   dmd.clearScreen( true );

   // THE FIRST MESSAGE - SCROLLING
   // Select the font. Both fonts included here.  Just comment out one of them
   //dmd.selectFont(System5x7);
   dmd.selectFont(Arial_Black_16);
   char msgOne[] = "Scrolling Text for message 1";
   int msgOneLength = 28;
   dmd.drawMarquee(msgOne,msgOneLength,(32*DISPLAYS_ACROSS)-1,0);
   long start=millis();
   long timer=start;
   boolean ret=false;
   while(!ret){
     if ((timer+30) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }


   // THE SECOND MESSAGE NON SCROLLING - FLASHING
   // Select the font. Both fonts included here.  Just comment out one of them
   dmd.selectFont(System5x7);
   //dmd.selectFont(Arial_Black_16);
   char msgTwo[] = "Eight";
   int msgTwoLength = 5;
   int noOfFlashes = 3;
   for (int i=0;i<noOfFlashes;i++)
   {
     // Display the message (flash it on)  (1,5 = top corner of text )
     dmd.drawString(  1,  5, msgTwo, msgTwoLength, GRAPHICS_NORMAL );
     delay(500);  // wait 0.5 seconds
     // Blank the message ( flash it off)
     dmd.drawString(  1,  5, msgTwo, msgTwoLength, GRAPHICS_NOR );
     delay(500);  // wait 0.5 seconds
   }
   dmd.clearScreen( true );

   // THE THIRD MESSAGE -  SCROLLING
   // Select the font. Both fonts included here.  Just comment out one of them
   //dmd.selectFont(System5x7);
   dmd.selectFont(Arial_Black_16);
   char msgThree[] = "Scrolling Text for message 3";
   int msgThreeLength = 28;
   dmd.drawMarquee(msgThree,msgThreeLength,(32*DISPLAYS_ACROSS)-1,0);
   start=millis();
   timer=start;
   ret=false;
   while(!ret){
     if ((timer+30) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
   
   // A delay of 1 sec before we start again
   delay(1000);
   
}



42n8
Posts: 46
Joined: Wed Dec 26, 2012 8:10 pm
Location: Auckland, NZ

Re: Help with scrolling Text

Post by 42n8 » Wed Feb 20, 2013 12:32 pm

I have a 4A powersupply running it now but did notice that when its running of the USB is much less bright......would just changing to say a 1A supply mimic this?
The max current available from a USB port is 0.5A. When running from the USB, notice that there is no power connection. All of the power is derived from the microprocessor SPI ports, which effectively creates a constant current source.

When running from a power supply the entire load is visible to the supply and, because it is a constant voltage source, the DMD will draw as much current as it can.

To do what you want, you would need to drive the DMD from a constant current source.

So as it stands, no, all you will do is overload the supply and probably kill it in a very short space of time.

There are other ways to do it as well. I think someone on here (Debenham?) created an arduino library that uses Pulse Width Modulation to reduce the time that the nOE pin is active.

Personally, I do the same thing in hardware using a PIC18F microprocessor.


Regards

kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Re: Help with scrolling Text

Post by kitbots » Fri Feb 22, 2013 3:26 pm

OK Thanks, I get it,so would something like this then limit the current as required?
http://www.ebay.com/itm/Universal-Modul ... 0316505427
Its certainly cheap enough to give it a try.


42n8 wrote:
I have a 4A powersupply running it now but did notice that when its running of the USB is much less bright......would just changing to say a 1A supply mimic this?
The max current available from a USB port is 0.5A. When running from the USB, notice that there is no power connection. All of the power is derived from the microprocessor SPI ports, which effectively creates a constant current source.

When running from a power supply the entire load is visible to the supply and, because it is a constant voltage source, the DMD will draw as much current as it can.

To do what you want, you would need to drive the DMD from a constant current source.

So as it stands, no, all you will do is overload the supply and probably kill it in a very short space of time.

There are other ways to do it as well. I think someone on here (Debenham?) created an arduino library that uses Pulse Width Modulation to reduce the time that the nOE pin is active.

Personally, I do the same thing in hardware using a PIC18F microprocessor.


Regards

kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Re: Help with scrolling Text

Post by kitbots » Fri Feb 22, 2013 3:30 pm

I'd like to increase the scrolling speed but can't see the line in the code that controls that......



Anyone got an idea how to change scrolling speed? :?:

42n8
Posts: 46
Joined: Wed Dec 26, 2012 8:10 pm
Location: Auckland, NZ

Re: Help with scrolling Text

Post by 42n8 » Sat Feb 23, 2013 1:56 am

OK Thanks, I get it,so would something like this then limit the current as required?
http://www.ebay.com/itm/Universal-Modul ... 0316505427
Its certainly cheap enough to give it a try.
That's a very specific question but there are two answers.
  • Yes, in theory, when it is set up as a current source it will deliver a precise amount of current and the intensity will be varied with the current source but it requires a fixed number of LEDs to be on.

    The negative part of this answer is that if your display message changes then the available current will be shared by all on LEDS. So if you reduce the number of ON LEDs then the voltage will rise in an attempt to supply the current specified. This could destroy the DMD.
  • In practice, the DMD cannot draw a constant current from a generic source. The reason is that there are times when the LEDs are not in the ON state and the constant current source will raise the voltage as above. The short transient voltage spike might be enough to destroy the DMD.
While you could try to control it using a high power zenner diode, the likelihood is that you will get some flicker due mostly to voltage changes that will undoubtedly occur before the zenner knee.

The "ideal" constant current source is controlled by the microprocessor. The reason is that the programmer instructs the microprocessor to tell the DMD to light a number of LEDS and at the same time tells the power source to deliver an exact amount of current to light the LEDs.

Note that microprocessors are never powered from such a source.


Regards

kitbots
Posts: 11
Joined: Tue Oct 30, 2012 2:39 am

Re: Help with scrolling Text

Post by kitbots » Sun Feb 24, 2013 6:59 pm

Thanks for the reply.

The info. for the constant current regulator says it will regulate both current and voltage and I will be supplying it with 5v from a regulated power supply so how could the voltage ever go higher? Is the microprocessor really regulating the current when its powered through the USB or is it simply the regulators in the laptop that is limiting the current? If the latter then surely the constant current constant voltage device would do the same but simply at a higher level. I certainly do not see the brightness change as the amount of text goes up and down when powered through the USB.

I do not intend to supply the microprocessor through the constant current regulator.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests