LCD problem

cabala

New Member
I'm not sure where to post this, so please feel free to move this if necessary. I'm working on trying to get a PIC16F886 to control a basic 4X20 parallel LCD module and am having some issues when writing characters. It's sort of difficult to explain the issues, but basically the LCD is working because the cursor moves after each character write, but there is no character to be seen.

During the initialization, I can control all of the set-up instructions just fine, 5x8 font or 5x11, no cursor, blinking, shift pattern and everything, but like I said when I write a character, nothing gets printed to the screen, but the address counter is incremented correctly, because the cursor moves. And then I can even issue a return home command and the cursor returns home correctly.

I'm not really sure what's wrong. Anyone seen this oddity before? Also if I play with the contrast adjust via my 10K pot, if the contrast pin is essentially grounded, every character position has the "block" looking character. If I start to raise the voltage a little, they slowly dissapear until only the cursor is left, but again no character. And if I continue raising it, the cursor dissapears too. I think this is the correct operation. It wasn't until I did this did I realize the LCD was even initializing correctly.

Any help would be really appreciated. The LCD is brand new and is a Newhaven NHD-0420H1Z-FL-GBW-3V.
 
Hi,

What voltage are you operating the 16F886 at.?
As you may know the LCD is a 3V version.
 
I don't know if this is it, or not, but the block characters appear on a project I'm currently working on. After the LCD initializes the blocks go away. Is it possible you left out a command initialization step?

If you can post the exact initialization commands, it would be helpful to diagnose the problem (assuming it is caused by an initialization step)

Here's a LCD tutorial that I found very helpful:
**broken link removed**

The datasheet indicates the absolute max voltage is 7 volts.
https://www.newhavendisplay.com/specs/NHD-0420H1Z-FL-GBW-3V3.pdf

Good Luck!
 
You need to post your code for write command and write data. I suspect your write data routine has a bug as the write command function is working correctly.

Mike.
 
I'll post some code and a schematic even if it will help. I'm assuming I am doing the initialization properly, but the datasheet is generic in the sense, that it doesn't specify what the exact initialization sequence should be. Only from looking at other examples and tutorials on the basic internal controller was I able to get as far as I have.

Anyways, I'm running the PIC at 3.3V, and the backlight is being powered by 5V. The contrast is being controlled by a 10K pot in between VDD and VSS(GND). Below is the schematic and code. I'm sorry for the code, it's not the best but simply a test routine to get the thing working correctly. I was then going to clean it up and incorporate it into the rest of the project code.

Another note about the code. I got the initialization routine from a manual that was written by Optrex for there LCD's but is generic to the internal controller that is used by most LCD's. Here is the link:

https://www.electro-tech-online.com/custompdfs/2008/11/Dmcman_full.pdf

It does work on some level, because at the end of my main routine, I issue the return home command and the cursor returns to AC position 0x00. Also, you will notice that only after the initial two 4-bit commands do I check the busy_flag. I read somewhere that the busy_flag can only be checked after deciding whether you want 4-bit or 8-bit and that you can just wait long enough after an instruction command and it has the same effect. Either way works as I only use it once.

Thanks for all the help. This has been really frustrating, and you're right it's probably a simple timing error or something of the like.
 

Attachments

  • schem.jpg
    89.4 KB · Views: 194
  • test.c
    test.c
    2.2 KB · Views: 175
You need to post your code for write command and write data. I suspect your write data routine has a bug as the write command function is working correctly.
Yup, I too agree! this can happen if you are sending wrongly a character code which can not be displayed by LCD, but the cursor will still move to the next position.
In 0x00 to 0xff range, there are many ASCII codes which don't make any displayable character, you might be sending one of them to LCD by mistake in your write code.
 
Last edited:
You can remove following part from your code, it doesn't serve any purpose here, you don't need to send the same code three times for 8-bit mode.
// Set to 8-bit mode
PORTC = 0x00;
PORTA = 0x30;
RC2 = 1; //Pulse Enable signal
delay_ms(1);
RC2 = 0; //Disable Pulse signal
delay_ms(5);
RC2 = 1;
delay_ms(1);
RC2 = 0;
delay_ms(5);
LCDcheck();
And Put some more delay, like 100mS before initializing LCD, to allow the voltage to settle down.
 
Yea, I didn't think it was absolutely necessary, but technically I think that Optrex manual was having me send the 8-bit command in two 4-bit instructions, then one final 8-bit for number of lines and font size, but you get the same results whether you send it three times, or once.

I removed that section of code and also made the inital delay before "initialization" larger, but I still get the same results. I'm having trouble understanding whether the display is not initializing correctly (i.e. clearing - hence the block characters showing everywhere when the contrast pin is adjusted) or if it's just not writing correctly, hence the cursor moving but no character appearing.

I'm at a loss what could be wrong.


[EDIT] Well, I guess we all live and learn, but ultimately a little bit of user error caused the problem. The LCD was initializing just fine actually and it was writing characters just fine, but I had RA6 and RA7 flipped in reference to DB6 and DB7 AND I just so happened to pick the row of test characters that when written would actually write the character that is in two columns over and are all blanks. I wrote a question mark and it actually showed up, then I tried a small case b and got a japanese character and new my problem instantly. I remember when wiring it up, that I thought it was odd for microchip to flip RA6 and 7 but must have forgotten thereafter. Well problem solved. Hope in the future this may help someone on some level.
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…