Newhaven Products > Character LCDs

Problems with a NHD‐0420H1Z‐FL‐GBW‐3V3

(1/2) > >>

c2hollow:
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.

Michael_L:
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.

c2hollow:
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

Michael_L:
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: ---// 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);
}
--- End code ---
Hopefully this will shed some light on any potential errors in your software.

c2hollow:
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?

Navigation

[0] Message Index

[#] Next page

Go to full version