Author Topic: OLED Initialization - NHD-0420DZW-AB5  (Read 2455 times)

signalflow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
OLED Initialization - NHD-0420DZW-AB5
« 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.
« Last Edit: February 18, 2016, 01:02:32 PM by signalflow »

signalflow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Re: OLED Initialization - NHD-0420DZW-AB5
« Reply #1 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.


Paul_B

  • Administrator
  • Sr. Member
  • *****
  • Posts: 248
  • Karma: 16
    • View Profile
Re: OLED Initialization - NHD-0420DZW-AB5
« Reply #2 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);

signalflow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Re: OLED Initialization - NHD-0420DZW-AB5
« Reply #3 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?

signalflow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Re: OLED Initialization - NHD-0420DZW-AB5
« Reply #4 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.

Paul_B

  • Administrator
  • Sr. Member
  • *****
  • Posts: 248
  • Karma: 16
    • View Profile
Re: OLED Initialization - NHD-0420DZW-AB5
« Reply #5 on: February 19, 2016, 12:21:05 PM »
Glad to hear you got your display up and running!


 

Questions regarding NHD‐0220DZW‐AY5 & NHD‐0420DZW‐AY5

Started by tseyfarthBoard OLEDs

Replies: 3
Views: 2882
Last post August 20, 2015, 09:51:26 AM
by Saurabh_B
16x2 OLED NHD-0216KZW-AY5 Intermittent, and perament vertical dots Brightness

Started by BenB2013Board OLEDs

Replies: 5
Views: 4680
Last post Today at 03:16:14 AM
by tolikkk
NHD‐0420DZW‐AB5 Lines

Started by RickJBoard OLEDs

Replies: 1
Views: 2287
Last post January 09, 2015, 04:18:32 PM
by Michael_L
NHD‐0420DZW‐AY5 SPI Interface

Started by vinaykBoard OLEDs

Replies: 0
Views: 2054
Last post October 26, 2015, 05:13:10 AM
by vinayk
Display current of 128x64 yellow OLED (2.7-12864UMY3) really 175mA?

Started by flywheelBoard OLEDs

Replies: 1
Views: 3409
Last post June 30, 2014, 04:48:12 PM
by Michael_L