Control DMD text over network

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
dtbaker
Posts: 26
Joined: Sat Jun 02, 2012 12:52 pm

Control DMD text over network

Post by dtbaker » Sat Jun 02, 2012 2:13 pm

Hey guys,

I created this (very quick, very ugly) arduino mashup which allows me to control the text on our DMD over the network.

Load it up to an etherten with DMD(s) connected, then visit http://192.168.0.107/status and you will see an input box asking for the text to display. Enter your text, click the button, and away it goes.

Or you could script it from another PC using wget or similar and just call http://192.168.0.107/set?string=Your+Text+Here - I might make a nicer interface on our webserver in PHP, sanatise any input there and then push it to the arduino behind the scenes. Reset it to default text after a few minutes even.

There are no string limits in place at the moment and it doesn't handle special characters too well yet. They're all easy fixes so I'll polish them off another time.

We'll be putting this up at tomorrows barcamp on the Gold Coast and members can post their own shoutouts. Connected a little buzzer so whenever a new word is uploaded it buzzes for a few seconds to get peoples attention :P

haha. bit of fun.

Code: https://bitbucket.org/gctechspace/ardui ... etwork.ino


Dave

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: Control DMD text over network

Post by Aussie_Wombat » Sun Jun 03, 2012 5:17 am

I just use the UDP Test tool from SimpleCommTools.com and send the data through the network using UDP. Sample code in the viewtopic.php?f=26&t=661 " Etherten with DMD - Internet text display" post.. OR code from a php page or *.html in the same post...

Cheers Dennis

dtbaker
Posts: 26
Joined: Sat Jun 02, 2012 12:52 pm

Re: Control DMD text over network

Post by dtbaker » Sun Jun 03, 2012 5:54 am

Cool! I should have searched for a solution before hacking together my own.

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: Control DMD text over network

Post by Aussie_Wombat » Sun Jun 03, 2012 6:04 am

UDP handles all the special characters as well....

~!@#$%^&*()_+-={}[]:";'<>?,./

Cheers Dennis

baldgeek
Posts: 9
Joined: Tue Apr 03, 2012 7:29 pm

Re: Control DMD text over network

Post by baldgeek » Mon Jun 04, 2012 1:13 pm

Great work Dennis.

I have been messing about with my sign a fair bit since you posted the code to get it up and running... Loads of fun!

The main issue I have had is that I found you cant send the string via UDP too often, if you do, the Auduino pukes on itself and corrupts the sting.
To get around it, I have my home automation controller get the string length and use that as a delay timer. That way it only resends the string once its done scrolling.
(To work out the characters per second, I sent several string lengths and timed them, then took an average, seems to work well enough).

I must be really inpatient or something, because the default scroll speed was way too slow for me.... so, at the expense of some quality, I ramped things up a fair bit. There is a tiny bit of tearing, but its very minor, and I dont have to stand looking at the sign for more than a few seconds to see the whole message (~160 characters). Before it was upwards of 2 minutes....

At the moment, I dont have the string defaulting to anything after a timer. You have to enter a full stop (period) to have it scroll the automation data. I kind of like it that way.

Lastly, I put a webcam on it so that the user could see the sign in real time... The LED's were so bright it was really hard to adjust the camera. I tried a few different cameras, all of them were overwhelmed by the brightness. I am using an old computer power supply, so could not turn down the volts easily (and I was worried I might start glitching the display electronics), so I ended up putting a single bit of old black bed sheet over the display.
That calms it down enough that the camera does not freak out any more.

Done. Done and Done.

Thanks again for your help. Really could not have done it without your help.

Ben.

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: Control DMD text over network

Post by Aussie_Wombat » Mon Jun 04, 2012 8:37 pm

I found the 256 character length was using up all the sram. so I changed it all to 128 characters instead. All works ok now... I am powering 3 DMD's using a 5V 5A power pack and it overwhelms my camera on my phone still.

I am using your code for a sign in a t-shirt stall at a discount market to display advertising information, so the repeating text was essential for me. Glad to hear I could help..

Cheers Dennis

Aussie_Wombat
Posts: 51
Joined: Tue May 22, 2012 12:52 pm
Location: Adelaide, South Australia

Re: Control DMD text over network

Post by Aussie_Wombat » Wed Feb 20, 2013 8:51 am

I use the UDP test tool V3.0 from Simple Comms Tools-UDP Test tool
to send data over the local area network and control the text output on the DMD panels.

Code: Select all


#include <SPI.h>        
#include <DMD.h>        
#include <TimerOne.h>   
#include <SPI.h>         
#include <Ethernet.h>
#include <EthernetUdp.h>
//#include "SystemFont5x7.h"
#include "Arial_black_16.h"

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 3
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 11);

unsigned int localPort = 8888;      // local port to listen on
unsigned int returnPort = 56000;      // local port to return on
#define UDP_TX_PACKET_MAX_SIZE 128
//#define PIN_OTHER_SPI_nCS 10
// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back
String oldText;
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

void setup() {

     //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)
      // start the Ethernet and UDP:
  Serial.begin(9600);
      

    oldText = "*** Custom Shirts ***  T-Shirts, Polo shirts and Caps with your design, here from $20...";
   

  Ethernet.begin(mac,ip);
  delay(2000);
  Udp.begin(localPort);
  delay(500);

}

void loop() {

        Serial.println(Ethernet.localIP()); //print out the findings.

  
  String displaytext = getUdpCharacters();
       Serial.println("returned data"); //print out the findings.
       Serial.println(displaytext); //print out the findings.

        if (displaytext == ""){displaytext = oldText;}
      Serial.println(displaytext); //print out the findings.

    dmd.selectFont(Arial_Black_16);
    char marqueeString[128];
    int myTextLength = displaytext.length();
    displaytext.toCharArray(marqueeString, myTextLength+1);
    
    dmd.drawMarquee(marqueeString,myTextLength,(32*DISPLAYS_ACROSS)-1,0);
    long start=millis();
   long timer=start;
   boolean ret=false;
   while(!ret){
     if ((timer+15) < millis()) {
       ret=dmd.stepMarquee(-1,0);
       timer=millis();
     }
   }
   oldText = displaytext;
  delay(2000);
  
}

String getUdpCharacters() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if(packetSize)
  {
   Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i =0; i < 4; i++)
    {
      Serial.print(remote[i], DEC);
      if (i < 3)
      {
       Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), returnPort );
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
  String Mytext = String(packetBuffer);
  Mytext = Mytext.substring(0,packetSize);
 
  return Mytext;
}


The main bit is to set the ip of the arduino(etc) and then the local ports it listen's and reply's on, as well as # of DMD's...and "oldtext"

IPAddress ip(192, 168, 1, 11);

unsigned int localPort = 8888; // local port to listen on
unsigned int returnPort = 56000; // local port to return on

In the UDP test tool, you set the remote ip, and listen port(8888) to that of the Arduino(etc) and the host port to the reply port(56000) .

type the text to send ( I set a max of 128 characters ) and click send. The text will change once the draw.marquee function has finished displaying...If no text is sent the oldtext is redisplayed..

Aussie_Wombat

Post Reply