Newhaven Display Forum

Newhaven Products => OLEDs => Topic started by: signalflow on February 18, 2016, 12:52:58 PM

Title: OLED Initialization - NHD-0420DZW-AB5
Post by: signalflow on February 18, 2016, 12:52:58 PM
Hi, I have been struggling with initializing the OLED NHD-0420DZW-AB5 correctly using the default 8-bit (6800 parallel interface).

I looked at the code supplied by newhaven for 8-bit given at the thread below:
http://www.newhavendisplay.com/NHD_forum/index.php/topic,1005.0.html
which initializes with

void init(){
   E = 0;
   Delayms(5);
   command(0x30);  //0x30
   Delayms(100);
   command(0x30);  //0x30
   Delayms(10);
   command(0x30);  //0x30
   Delayms(10);
   command(0x38);  //func set 8-bit
   command(0x10);  //cursor/disp shift left
   command(0x0c);  //Display ON
   command(0x06);  //Entry mode set
}

This does not match what the datasheet says on pg. 20 which would be something like shown below but I put a delayms(10) at the end of the command() function instead of checking Busy flag.

void init(){
   E = 0;
   Delayms(5);
   command(0x38);  //func set 8-bit
   Delayms(100);

   command(0x08);  //Display OFF
   command(0x01);  //Clear display
        command(0x06);  //Entry mode set
   command(0x02);  //HOME
   command(0x0C);  //Display ON
}

Neither of these types of initialization work.  Do we need the three dummy function sets at the beginning (0x30)?  It just seems like the datasheet almost gets you there, but leaves out some required commands for initalization and timing.  For example, the datasheet says power on and wait >1ms although your example code above shows it waiting 100 ms.  It's really easy to get an HD44780 to work, but this has been extremely challenging.  Any help appreciated and once we figure out how to initialize the display properly, then please update the datasheet.

Thanks.
Title: Re: OLED Initialization - NHD-0420DZW-AB5
Post by: signalflow on February 18, 2016, 02:26:21 PM
Can the enable signal go HIGH before the data is put onto the 8 data pins and then bring ENABLE signal LOW?

I am setting EN=1 and RS and R/W to their appropriate value, then putting data on the 8 pins, then bringing Enable low to latch it.  Something is not working right though.

Title: Re: OLED Initialization - NHD-0420DZW-AB5
Post by: Paul_B on February 19, 2016, 08:34:46 AM
Hi Signalflow,

Im sorry to hear about the trouble you are having with NHD-0420DZW-AB5. Let me help you out with your initialization sequence  ;)

Please try the following:

On power up, the display is initilaized as:

1. Display clear

2. Function set:
DL="1": 8-bit interface data
N="0": 1-line display
F="0": 5 x 8 dot character font

3. Power turn off
PWR=0

4. Display on/off control: D="0": Display off C="0": Cursor off B="0": Blinking off

5. Entry mode set
I/D="1": Increment by 1
S="0": No shift

6. Cursor/Display shift/Mode / Pwr
S/C=0, R/L=1: Shifts cursor position to the right
G/C=0: Character mode
Pwr=1: Internal DCDC power on

Code: [Select]
// 4-Bit initialization sequence
  write4bits(0x03); // Put back into 8-bit mode
  delayMicroseconds(5000);
  if(_oled_ver == OLED_V2) { 
    write4bits(0x08);
    delayMicroseconds(5000);
  }
  write4bits(0x02); // Put into 4-bit mode
  delayMicroseconds(5000);
  write4bits(0x02);
  delayMicroseconds(5000);
  write4bits(0x08);
  delayMicroseconds(5000);
 
  command(0x08); // Turn Off
  delayMicroseconds(5000);
  command(0x01); // Clear Display
  delayMicroseconds(5000);
  command(0x06); // Set Entry Mode
  delayMicroseconds(5000);
  command(0x02); // Home Cursor
  delayMicroseconds(5000);
  command(0x0C); // Turn On - enable cursor & blink
  delayMicroseconds(5000);
Title: Re: OLED Initialization - NHD-0420DZW-AB5
Post by: signalflow on February 19, 2016, 11:09:48 AM
OK, I seem to have gotten it to initialize properly.

The problem I am having still is that I can write strings such as
LCD_write_string("Test") but if I put spaces in like
"LCD_write_string("Test String") then it gives me erroneous character for the space.  Also the display (characters) are dimming.  The brightness is oscillating or cycling from the top of each character to the bottom over and over.  Is it supposed to do that or maybe it isn't initialized properly?
Title: Re: OLED Initialization - NHD-0420DZW-AB5
Post by: signalflow on February 19, 2016, 11:27:41 AM
Nevermind, seems I had a bad connection on Vcc (was low voltage).  Once I gave it a good connection the display quit flickering and the erroneous characters went away for spaces.
Title: Re: OLED Initialization - NHD-0420DZW-AB5
Post by: Paul_B on February 19, 2016, 12:21:05 PM
Glad to hear you got your display up and running!