Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

My 4 line hd44780 only displays the first and third line...

Status
Not open for further replies.

si2030

Member
Hi there,

I have a PIC16F877A hooked up to a 4x20 lcd module and I am using the Extreme Electronics LCD library for MPLAB X. It works fine for a two line LCD but now that I have plugged in the 4 line LCD it will only display the first and third lines. If I take power away from the bread board and then plug it back in it display all four lines.

I included their library for your interest. I have set up my bread board with exactly the same pin outs as they stipulate.

I have had a look at the code and they run an initialise method before the LCD can be used. Just wondering if there is a particular set up that a four line LCD needs to operate properly? Is there something you need to know for this or is it something else. It would nice to have all 4 lines available.

Kind Regards Simon
 

Attachments

  • lcd_44780_pic16 (1).zip
    5 KB · Views: 159
Hi Ian and thanks for the quick reply... yes I already found that and have unremarked this line. I Used LCDGotoXY(0,1); to force it to the second line but is does not show up... unless I unplug the power to the bread board and then re-plug it in.

I have included my LCDTest.c program for your interest.

Simon
 

Attachments

  • LCDTest.c
    2 KB · Views: 254
Yes your right... it did look iffy.. so I changed it to this...

Code:
#ifdef LCD_TYPE_162
    #define LCD_TYPE_162
#endif

#ifdef LCD_TYPE_202
    #define LCD_TYPE_202
#endif

#ifdef LCD_TYPE_204
    #define LCD_TYPE_204
#endif

I also changed the LCDTest file to this:

Code:
LCDGotoXY(0,0);

LCDWriteString("Hello there! - Line 1");

LCDGotoXY(0,1);

LCDWriteString("Line 2");

LCDGotoXY(0,2);

LCDWriteString("Line 3");

LCDGotoXY(0,3);

LCDWriteString("Line 4");

But alack alas it still displays the first and third.... really thought that would do it.

Have included the updated files...
 

Attachments

  • LCDTest.c
    2.1 KB · Views: 250
  • lcd_hd44780_pic16.c
    7.6 KB · Views: 706
Hi there,

I have had a quick look at the code of this and others and there is a line that appears in LCDinit (at line 243) LCDCmd (0b00101000) and they refer to this as "//function set 4-bit,2 line 5x7 dot format"

In other implementations its LCDcmd 0x28.

They refer to this as a 4 bit 2 line device from what I can infer. Is there a different setting if its a 4bit 4 line device?? Interest to hear some comments.

Kind Regards
Simon
 
They are both meaning the same thing, 28h. It's just one is being expressed as binary (00101000).

I think you need to get right back to basics here and look at what the display is expecting. As I remember it, all of these hd44780 type displays believe they are really 2 lines of 40 characters each, with line 3 being a continuation of line 1 and line 4 being a continuation of line 2. You only access a "window" or portion of the DD Ram address whenever you send characters to the display, the starting position of that "window" being set using the DD Ram address. The DD Ram address for line 1 begins at 80h and becomes line 2 at C0h. Line 3 begins at address 94h and becomes line 4 at D4h. So for example, to write to line 1, you would set the DD Ram address to 80h then send your characters, or to send to line 4 you would first set the DD Ram address to 94h, then send your characters.

Make sure that you are indeed initialising the display properly (turning up the contrast sometimes helps you see if it is going in the right direction), then send the correct command to set it as 2 line, 4 bit mode, 5*7 character format which I assume is what you are after. Some displays benefit from having the unused pins tied to ground via a resistor, some don't mind if they are left floating. Personally I never leave them floating and ground them using 10k resistors and I rarely have problems with oddball displays misbehaving. Also, depending on just how closely the manufacturer has emulated/ followed the hd44780 spec you may find that you need to send the initialisation commands several times before the display finally cottons on that is what you want.

To test your initialisation etc, set the DD Ram address yourself then send up to 20 characters as Ian already suggested.

Hopefully this will help you get to the bottom of the problem :)
 
Status
Not open for further replies.

Latest threads

Back
Top