Newhaven Display Forum

Newhaven Products => Character LCDs => Topic started by: c2hollow on July 07, 2014, 11:52:27 AM

Title: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: c2hollow on July 07, 2014, 11:52:27 AM
I have an NHD‐0420H1Z‐FL‐GBW‐3V3 that I am having trouble getting working.

I have re-created the sample code for the "Example Initialization Program", and confirmed that I am sending 3.3 volt signals along all the appropriate pins. However, I seem to be unable to send any characters to the display - All I see are blocked out first and third lines.

I'm not sure where to go from here in terms of debugging. The only thing I've noticed is that in the sample code there is: "command 0x30 = Wake up". I can't find this command in the manual for the LCD driver, so I don't know exactly what it does.
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: Michael_L on July 08, 2014, 09:32:04 AM
That command is the function set command, (shown on page 6 of the datasheet), and is needed to initialize the display.  Without it, the display will not function correctly.
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: c2hollow on July 08, 2014, 01:17:09 PM
I don't understand, if 0x30 is the function set, then why further down in the code is there:

command(0x38); //Function set: 8-bit/2-line
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: Michael_L on July 08, 2014, 04:51:35 PM
They are both function set commands.  The difference between them is that they are using different parameter values.  The controller knows its the function set command based off the first nibble "001x" (x = dont care).  That last dont care bit, along with the second nibble, are the parameters for the command.  The first 0x30 call is to "wake up" the display as you have said, the 0x38 call is to configure it correctly.

Here is some Arduino code I've used that works (it's only for a 2 line display but the code is the same):
Code: [Select]
// R/W signal is tied to ground (always write, never read)

int RS = 30;   //RS signal connected to digital pin 30 of Arduino Mega2560
int E = 31;    //E signal connected to digital pin 30 of Arduino Mega2560

const char text1[] = {"Newhaven Display"};
const char text2[] = {" Character LCD  "};

void command(char c)

   digitalWrite(RS, LOW);
   PORTA = c;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
}

void data(char d)
{
   digitalWrite(RS, HIGH);
   PORTA = d;
   digitalWrite(E, HIGH);
   delay(1);
   digitalWrite(E, LOW);
}

void Home()
{
   command(0x01);
   delay(5);
}

void nextline()
{
   command(0xC0);
}

void disp_pic()
{
   int i;
   Home();
   for (i=0;i<16;i++)
   {
      data(text1[i]);
   }
   nextline();
   for (i=0;i<16;i++)
   {
      data(text2[i]);
   }
}

void setup()
{
   DDRA = 0xFF;    //set PORTA as output
   PORTA = 0x00;   //initialize PORTA to 0x00
   pinMode(RS, OUTPUT);
   pinMode(E, OUTPUT);
   digitalWrite(E, HIGH);
   delay(40);
   command(0x30);
   delay(5);
   command(0x30);
   delay(5);
   command(0x30);
   delay(5);
   command(0x38);
   command(0x10);
   command(0x0c);
   command(0x06);
   delay(5);
}

void loop()

  disp_pic();
  delay(5000);
}
Hopefully this will shed some light on any potential errors in your software.
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: c2hollow on July 09, 2014, 11:04:40 AM
Do you know why the first and third lines would be full of boxes and the other lines are blank? Could that provide me a clue as to what I'm doing wrong in the initialization?
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: Michael_L on July 10, 2014, 08:43:52 AM
There really isn't any particular reason why, or incorrect initialization command, this just happens when the display is not initialized.  Have you matched your code to what I have posted?  I have verified it to work on that display.  What voltage are you using on pin 3?  Do you have any other displays to test?

EDIT:  I just saw your other post saying you got it to work.  Thank you for sharing!
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: sask_ben on July 16, 2017, 04:10:19 PM
I just got this display as well. I have used the 2 line NHD-0216BZ-FL-YBW display. Everything looks exactly the same and have wired it all the same but nothing is coming up on the NHD‐0420H1Z‐FL‐GBW‐3V3. Any suggestions?
Title: Re: Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3
Post by: Saurabh_B on July 17, 2017, 08:17:45 AM
Hi,

Can you tell me what the voltage you have going to VDD and V0 are for this display?