Data Polarity

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Tue May 07, 2019 10:36 am

I Just had some free time so I ran a copy of your sketch supplied in the earlier post.
It displays correctly for me, however you need to change line 62 from

Code: Select all

      Serial.println(readString);
to

Code: Select all

      Serial.println(myString);
to echo your received characters back to the serial monitor, and you are not yet displaying those received characters on the DMD - only the 'OK' message.

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Tue May 07, 2019 1:37 pm

I just diplay "OK" for testing.
This is my dmd_demo result https://www.youtube.com/watch?v=cjUJ6bwhhhU
I need all dot off, the data dot on.

Again, thank so much for your time !

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Tue May 07, 2019 1:54 pm

This is my P10 module (exactly it) : https://www.ebay.com/itm/Red-LED-Displa ... 3699804495

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Tue May 07, 2019 5:49 pm

Code: Select all

#include "SPI.h"        
#include "DMD.h"        
#include "TimerOne.h"
#include "Arial_black_16.h" 
#include "SystemFont5x7.h"
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd( DISPLAYS_ACROSS , DISPLAYS_DOWN );
void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

void setup() {
    Serial.begin(9600);
    Serial.println("Demo !");
    Serial.println();
    Timer1.initialize( 5000 );           
    Timer1.attachInterrupt( ScanDMD );  
    dmd.clearScreen( true );            
}

void drawText( String dispString ) 
{
  dmd.clearScreen( false );
  char newString[256];
  int sLength = dispString.length();
  dispString.toCharArray( newString, sLength+1 );
  dmd.selectFont( Arial_Black_16 );
  dmd.drawString( 0, 0, newString ,sLength, GRAPHICS_INVERSE);
}

//============

void loop(void) {
   drawText("123");
   delay( 1000 );
}
LET TRY THIS CODE WITH GRAPHICS_NORMAL AND GRAPHICS_INVERSE

In DMD.h
I was remove this line for right display:

Code: Select all

this->drawLine(bX + strWidth , bY, bX + strWidth , bY + height, GRAPHICS_INVERSE);

Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Wed May 08, 2019 6:08 am

It works fine for me except for these:
Line 25:

Code: Select all

  dmd.clearScreen( false );
clears the screen to all LEDs ON. I think you mean to have all leds OFF, so it should be:

Code: Select all

  dmd.clearScreen( true );
Line 30:

Code: Select all

  dmd.drawString( 0, 0, newString ,sLength, GRAPHICS_INVERSE);
displays the '123' as black on white. Since you want normal white on black, you need:

Code: Select all

  dmd.drawString( 0, 0, newString ,sLength, GRAPHICS_NORMAL);
With those 2 changes, it works fine for me. It looks like you may have a problem in your setup.
The DMD in your link appears to be the standard format, but I cannot be certain of that as there is no detail. However it appears that the basic operation of the display is working as you are able to communicate with it. The output from the dmd_demo indicates a problem as it the inverse image of what should be happening. It indicates that the display you have may not be identical to the 'Freetronics' DMD and may not be 100% compatible with the DMD library - the data line may be inverted or it could be something else??
There is a lot of information on the DMDs on this forum. You could start here to get some help on how they work.
A word of warning: make sure you are powering your DMD from a good 5Volt power source (capable of at least 2 Amps) and not powered from the USB connection. This overloads the USB port and can lead to problems.

dinhhuynhky
Posts: 10
Joined: Sun May 05, 2019 3:24 am

Re: Data Polarity

Post by dinhhuynhky » Wed May 08, 2019 9:27 am

The problem in my P10 module, it use positive control data.

Code: Select all

clearScreen(true)
This line in my case will turn all LEDs on.

Code: Select all

clearScreen(false)
This line in my case will turn all LEDs off.
and

Code: Select all

//drawText("123");
dmd.drawString( 0, 0, newString ,sLength, GRAPHICS_INVERSE);
this will make LED turn on "123". ( GRAPHICS_INVERSE - it working perfect with me )
It's working now.
this is my final code:

Code: Select all

#include "SPI.h"        
#include "DMD.h"        
#include "TimerOne.h"
#include "Arial_black_16.h" 
#include "SystemFont5x7.h"
#include "Arial14.h"

#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd( DISPLAYS_ACROSS , DISPLAYS_DOWN );

String inputString = "";         // a string to hold incoming data
boolean stringComplete = false;  // whether the string is complete
String commandString = "";
void ScanDMD()
{ 
  dmd.scanDisplayBySPI();
}

void setup() {
    Serial.begin(9600);
    Serial.println("Demo !");
    Serial.println();
    Timer1.initialize( 5000 );           
    Timer1.attachInterrupt( ScanDMD );  
    dmd.clearScreen( false );   
    drawText("000");         
}

void drawText( String dispString ) 
{
  dmd.clearScreen( false );
  char newString[256];
  int sLength = dispString.length();
  dispString.toCharArray( newString, sLength+1 );
  dmd.selectFont( Arial_Black_16 );
  dmd.drawString( 2, 0, newString ,sLength, GRAPHICS_INVERSE);
}

//============

void loop(void) {
  while (Serial.available() > 0 ) {
  
       String str = Serial.readString();
  
       dmd.clearScreen( false );
      Serial.println("Input: " + str);
      stringComplete = false;
      drawText(str);
      delay( 1000 );
  
   }

    
  }
and of course I must remove this line

Code: Select all

this->drawLine(bX + strWidth , bY, bX + strWidth , bY + height, GRAPHICS_INVERSE);
This will make a vertical lines after every char.

So, thank you so much for your help.
Great job !

Brissieboy
Posts: 161
Joined: Fri Sep 20, 2013 7:25 am

Re: Data Polarity

Post by Brissieboy » Wed May 08, 2019 10:34 am

It is all pointing to your display not being compatable with the DMD library.
You could try inverting the data line - the others appear to function normally. That could be done in the library in software or just a simple inverter in the physical interface hardware.
And you will need the line you deleted

Code: Select all

this->drawLine(bX + strWidth , bY, bX + strWidth , bY + height, GRAPHICS_INVERSE);
as that provides the space between characters, unless you have made some alternative method.
And that's about all I can offer - except maybe to get hold of a compatible DMD.

Post Reply