Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - RichardR

Pages: [1]
OLEDs / NHD‐0420CW‐AG3: blinking part of text?
« on: March 02, 2016, 07:06:21 AM »
I have one more question about the NHD‐0420CW‐AG3 OLED display: is it possible to make some text blink?

I'm using the display to control a machine, and in some situations, I want to show the word 'PAUSED' blinking, with the rest of the text static. I found blink on/off functions for the cursor and for the display as a whole, but not for just part of the text, e.g. defined like this:

[text (static)]
[command: blink enable]
[text (blinking)]
[command: blink disable]
[text (static)]

Or do I have to take care of this myself, periodically overwriting the blink text with spaces?

Thanks once more in advance,

Richard Rasker

OLEDs / Re: NHD‐0420CW‐AG3 Contrast question
« on: January 16, 2016, 09:52:02 AM »
Regarding the Set Contrast command the margin of change is around 30-40%
OK, that would explain it. From what I can judge with the naked eye, the difference between minimum and maximum contrast is indeed some 30%. A bit of a shame, really, because that makes the contrast function far less useful, but  then again, it's no big deal for my application. (It would be different if I wanted to have a true 'dim' function for inobtrusive night-time operation.)

Thanks again, best regards,


OLEDs / NHD‐0420CW‐AG3 Contrast question
« on: December 28, 2015, 01:57:48 PM »

Thanks to Saurabh's good advice, I managed to get the NHD‐0420CW OLED display working properly. I have however a question about the contrast function. I'm using the following commands to set the contrast:

Code: [Select]
command(0x2A); //function set (extended command set)
command(0x79); //OLED command set enabled
command(0x81); //set contrast control
command(0x7F); //set contrast value
command(0x78); //OLED command set disabled
command(0x28); //function set (fundamental command set)

And yes, this seems to work, but while the contrast value can be set between 0x00 and 0xFF (with 0x7F as the default value), the effect is tiny -- the difference between 0x00 and 0xFF is perhaps a 30% change in visible brightness (at first, I thought that it didn't work at all).

The same goes for the fade function:

Code: [Select]
command(0x2A); //function set (extended command set)
command(0x79); //OLED command set enabled
command(0x23); //fade/blink function
command(0x30); //blink, with step every 8 frames
command(0x78); //OLED command set disabled
command(0x28); //function set (fundamental command set)

The display brightness only changes marginally (hardly visible), and only at the lowest point it goes completely black for a moment.

Did I perhaps do something wrong with setting up registers? Or is the actual contrast range indeed very small? Or could I have damaged the display? (I think I once set the display for 2.8V I/O instead of 5V while testing, but that doesn't appear to have damaged anything else).

Thanks once again!

Best regards,


Ah, OK, I surmised that this was a demo program to show how different functions are addressed -- I never realized that this initialization sequence was actually necessary for proper functioning of the display.

Thank you for clarifying this! (Although it might be handy if the datasheet mentioned that this initialization is actually more than just an example -- it is vitally important.)

OK, at least I know what to transmit -- so now I can get on with debugging my I2C code.

Thanks again for the heads-up!

Best regards,


Hello Saurabh,

This display does have a lengthy initialization sequence that needs to occur to setup the registers on the display controller.

No, I did not initialize the display -- I assumed that it would default to a simple 4x20 character mode, like most other displays I worked with. Also, I thoroughly read both the NHD-0420CW-AG3 and the US2066 datasheets, and the only reference to initialization I can find has to do with the RES# pin: "When the pin is pulled LOW, initialization of the chip is executed."
The code examples don't mention any initialization either.
Am I using the wrong datasheets? Because that would explain a lot...

Where can I find information about this initialization sequence? On pages 15-16 of the US2066 datasheet, a Power ON and OFF sequence is mentioned, but that deals with several different voltages for the US2066 controller (VDDIO, VDD, VCC etcetera) -- while the actual display unit only has one VDD connection. So I assume this is dealt with internally. The only commands here are 0Ch for On and 08h for Off -- neither of which do anything visible here. Is there perhaps some sort of simple test mode?

And what initialization sequence should I use to get a 4 x 20 display? And is there some document that explains about the IS, RE and SD command bits?

Sorry if I ask a lot of questions, but I really can't find any answers in the datasheets that I have here.

Thank you for your reply,

Best regards,


I'm trying to get an OLED display type NHD‐0420CW‐AG3 working with a 16F1789 PIC controller, via I2C.
Unfortunately, even after several days of digging through the datasheets, checking out code examples, and just trying to get things working, I still can't get anything to show. No doubt, this has to do with the facts that
1. This is the first time that I try to use I2C with a PIC controller,
2. I'm working in assembler, not C or another higher language, and
3. There are some things in the display datasheet unclear to me.
As far as I can tell, the electrical signals should be OK, and from what I can see, and at least the I2C Start condition is initiated. But after that, nothing much happens. So my problems may very well be due to programming error.

If I may address the last point first: I understand most things in the display datasheet, except the table with the display commands.
There, three yellow columns labeled IS, RE, and SD are shown. What are these bits, and how are they addressed? Even the far more elaborate US2066 datasheet doesn't explain this -- or are these bits implicit in the command sent? If so, what is their function? Or did I overlook something here? I really tried reading the datasheets thoroughly, but still haven't a clue what these three bits are supposed to be. Also, I'm afraid that I don't completely understand Figure 5-7 in the US2066 datasheet (the I2C bus data format), even though I understand the basics of I2C communication itself.

Then there's the actual I2C addressing. I try sending simple byte sequences to the display, but it doesn't appear to respond at all, so I must be doing something wrong.
In the US2066 datasheet, I see that the display's slave address is supposed to be 0x78, OR'ed with SA0 (=0 in my case), and R/W (=0 so far). The following byte is supposed to be the control byte, to indicate the nature of the next byte (command or data), with 0x80 (Co=1, D/C#=0) for commands, and 0x40 (Co=0, D/C#=1) for data.

So I tried sending the following to the display from the PIC16F1789, translated from the example program code in the display datasheet:

[Initiate Start condition]
0x78 (address)
0x80 (command code)
0x01 (clear display)
0x80 (command code)
0x02 (return home)
0x04 (data code)
0x1F (write one solid block in first position)
[Initiate Stop condition]

Unfortunately, this doesn't do anything. I tried breaking this up in single commands, each one preceded by the address and terminated by a Stop condition, but that also doesn work properly.
It is very well possible that my PIC ASM code is to blame -- when I try sending these bytes without using the I2C block interrupt mechanism, the I2C bus immediately hangs after initiating the Start condition. When trying to send subsequent bytes through the proper interrupt routine, the I2C bus appears to function properly, but still nothing shows. In the US2066, there's also a description of a Power ON sequence, by sending fundamental command 0x0C, with RE=0, and SD=0(?). Should I use this first?

So actually I hope that my question is simple: is at least the above sequence of bytes sent out correct? If not, then what should be the correct sequence to turn on the display, and to get at least one character to show?
As long as I know that I should be sending out the right byte sequences, I can more easily figure out what I'm doing wrong in my assembly code. I tried locating I2C code examples, but there's very little to be found in PIC assembly code (at least I couldn't find anything).

Thanks in advance for any hints,

Best regards,


Pages: [1]