# LCD (2x16) showing only one line when data bits grounded

Status
Not open for further replies.

#### Pommie

##### Well-Known Member
The initialization sequence doesn't mention D3-D0.

Mike.

#### jpanhalt

##### Well-Known Member
Agree. On reviewing the HD44780 datasheet (assuming that is what the THS has), the data pins are tristate and have weak pull-ups (about 50 uA at 3 V):

The datasheet (p. 39) further refers to DB3 : B0 as "not connected:"
Since DB0 to DB3 are not connected, a rewrite is then required. However, since one operation is completed in
two accesses for 4-bit operation, a rewrite is needed to set the functions (see Table 12).
I suspect the real reason for the one-line display is that the controller expects the low nibble to be unconnected or high.

Elerion
Since you have both the breadboard and PCB made, perhaps a test with DB3 : B0 tied high with a 20K resistor and see whether it comes up in 1-line or 2-line mode.

John

#### large_ghostman

##### Well-Known Member
The initialization sequence doesn't mention D3-D0.

Mike.View attachment 107088
I think Mike thats the software one.....The table i posted is from the hardware pdf that shows how to control the LCD with switches etc. So just as a guess seeing as the little star where I badly drew a red box, says initialization, Maybe there is a hardware and software way, I know you can send hex commands to set bits in the chip inside, but also set them via direct signals to the pins on the outside (did that make sense???).

The other thing that dosnt make sense in your diagram is where do you set the home cursor,on/off and dotformat and number of lines ect?? I think maybe its showing basic software set up, while the one i posted shows the set up commands (again not sure I made sense there). anyway pdf is posted, its the one from the thread sticky in micros sections and was first published in everyday electronics.

MIKE, i suspect it not explicit mentioned because the wiring diagram in the PDF shows them tied high and the other shows then unconnected.
Just as a second thought i wonder if there are different versions, the timing given in the one I posted and yours are the same, but the one I have in a written sheet is lower.

John i was aware of the pull ups I drew around the bit that pointed out it has weak pull ups. Although its getting off track a bit, for the OP just leave the pins unconnected , all will be well lol

Last edited:

#### large_ghostman

##### Well-Known Member
Agree. On reviewing the HD44780 datasheet (assuming that is what the THS has), the data pins are tristate and have weak pull-ups (about 50 uA at 3 V):
View attachment 107089

The datasheet (p. 39) further refers to DB3 : B0 as "not connected:"

I suspect the real reason for the one-line display is that the controller expects the low nibble to be unconnected or high.

Elerion
Since you have both the breadboard and PCB made, perhaps a test with DB3 : B0 tied high with a 20K resistor and see whether it comes up in 1-line or 2-line mode.

John
Which is exactly what I said!! actually its only DB3 and D0 and D1 dosnt matter what they are as denoted by the X, D2 is 7X5 dot mode if held low and 10x whatever if held high.

#### dr pepper

##### Well-Known Member
Looks like your right ghostie, I didnt know that and I've used these displays for over 20 years.
Everytime I've used them it was 4 bit mode with the unused 4 floating.

#### large_ghostman

##### Well-Known Member
Looks like your right ghostie, I didnt know that and I've used these displays for over 20 years.
Everytime I've used them it was 4 bit mode with the unused 4 floating.
Whats really neat is unless you read the two articles in the pdf's, the assumption is they are software controlled. When i first used them Pommie gave me some code snippits in swordfish basic, he then went on holiday.

i couldnt get it working so read the pdf's, now in software you have the timing diagram and there is 100us for this and 150 uS for that, but you can do EVERYTHING on these LCD's in hardware!!

If you use Hex switches you can display anything on them and set anything just using switches, as pommie pointed out you got to debounce though (thats another story!!). Considering 16 pins and 2 are for light, thats pretty amazing. But I think looking back over some threads, some of the troubles have been hardware related and not so much timing etc.

The moment you apply power, if certain pins are in the wrong state on the micro or the LCD your in trouble, more so on the LCD. The micro is just a case of setting the pin correctly and then do the initializing routine. But playing with it last night, i found i couldnt over ride the hardware with software, so grounding that one pin sets it 1 line, dosnt matter what you do software wise it wont budge.

But I goto wonder why they made it so everything could be displayed with switches etc?? Just getting Hello world on the screen is alot of switch pushing

#### Nigel Goodwin

##### Super Moderator
But I goto wonder why they made it so everything could be displayed with switches etc??
Fairly obviously they didn't, ANY similar logic system can be worked with switches - and micro-controller outputs (or logic gates) are simply electronic 'switches'.

The only reason you're really aware of it in this case is that it was commonly done in tutorials to demonstrate the operation of the device, and not for actual use.

While you're far too younger to remember it, many early experimenters micro-processor systems were programmed using toggle switches - you set the address bus with a row of toggle switches, you set the data bus with another row, and pressed a 'store' button. This programmed the set address with the set data, you repeated this for the entire program, a byte at a time, incremented the address bus as you went.

#### ericgibbs

##### Well-Known Member
While you're far too younger to remember it, many early experimenters micro-processor systems were programmed using toggle switches - you set the address bus with a row of toggle switches, you set the data bus with another row, and pressed a 'store' button. This programmed the set address with the set data, you repeated this for the entire program, a byte at a time, incremented the address bus as you went.
Hi Nigel.
I remember it well, also those reams of preprinted machine coding sheets that had be entered by hand,,,, happy days!

Eric

#### large_ghostman

##### Well-Known Member
Fairly obviously they didn't, ANY similar logic system can be worked with switches - and micro-controller outputs (or logic gates) are simply electronic 'switches'.

The only reason you're really aware of it in this case is that it was commonly done in tutorials to demonstrate the operation of the device, and not for actual use.

While you're far too younger to remember it, many early experimenters micro-processor systems were programmed using toggle switches - you set the address bus with a row of toggle switches, you set the data bus with another row, and pressed a 'store' button. This programmed the set address with the set data, you repeated this for the entire program, a byte at a time, incremented the address bus as you went.
Yeah I guess i think in terms of databus etc, things like SPI.

OFF TOPIC KIND OF

I won a stack of 1970's IBM punch cards on ebay a few months back, no idea what they would do if put in a machine or through the letter box (whatever you did with them). but 200 cards with little square holes in. Was only 99p (£2.85 p&P ), no use for them at all but kind of nice to have.

What I would LOVE to have is the motors from the tape to Tape reels. Apparently they are the bees knees for kicking out high voltage if you turn them at low RPM. But not easy to get now.

#### large_ghostman

##### Well-Known Member
The hardware version of doing the LCD is alot of fun actually, except one the hex switches I have is a bit iffy. i will get a new one.

#### Pommie

##### Well-Known Member
LG, can you try adding one more command to the initialization code. Add a new command of 0x3c to see if that sets it to two lines and the right charset.

Edit, I just checked some of my code and I set the LCD to 2 row mode after the initialization shown above.

Mike.

Last edited:

#### large_ghostman

##### Well-Known Member
LG, can you try adding one more command to the initialization code. Add a new command of 0x3c to see if that sets it to two lines and the right charset.

Edit, I just checked some of my code and I set the LCD to 2 row mode after the initialization shown above.

Mike.
Same here. So looks like the initialization dosnt set things in stone, hence why grounding the lower data pins puts it into 1 line mode. Works other way as well, tying high makes them 2 line even if your code set it 1 line during initialization. Something to watch for when people have trouble with LCD's.

i had assumed once you done the initialization you had to do it again to change things...apparently not. Going off on one my tangents... could mean some fun doing graphics with the custom graphic set on the fly and very fast.....

#### Pommie

##### Well-Known Member
Whoops, just had a look at the initialization code for a project that used a 4x20 LCD and I write the command during the init. It should also be 0x2c not 0x3c as I posted above (bad memory).

Here's my init.
Code:
    __delay_ms(30);                 //delay for LCD to initialise.
WriteNibble(0x30);              //Required for initialisation
__delay_ms(5);                  //required delay
WriteNibble(0x30);              //Required for initialisation
__delay_ms(1);                  //required delay
WriteCommand(0x20);             //set to 4 bit interface
WriteCommand(0x2c);             //set to 4 bit interface, 2 line and 5*10 font
WriteCommand(0x01);             //clear display
WriteCommand(0x06);             //move cursor right after write
WriteCommand(0x0C);             //turn on display
I checked the board and I'd left D0-D3 floating so can't confirm if this works with the pins grounded.

Mike.

#### dr pepper

##### Well-Known Member
Hey Nige I had a 8080a trainer that was programmed by toggle switches, glad we dont have those anymore.
Aerospace had stuff like thatt too I believe.
Some logic devices will not work with switches as they have ac couple i/o, the 6800 I think is like this, however the majority of logic you come across these days will work down to dc.

#### large_ghostman

##### Well-Known Member
Whoops, just had a look at the initialization code for a project that used a 4x20 LCD and I write the command during the init. It should also be 0x2c not 0x3c as I posted above (bad memory).

Here's my init.
Code:
    __delay_ms(30);                 //delay for LCD to initialise.
WriteNibble(0x30);              //Required for initialisation
__delay_ms(5);                  //required delay
WriteNibble(0x30);              //Required for initialisation
__delay_ms(1);                  //required delay
WriteCommand(0x20);             //set to 4 bit interface
WriteCommand(0x2c);             //set to 4 bit interface, 2 line and 5*10 font
WriteCommand(0x01);             //clear display
WriteCommand(0x06);             //move cursor right after write
WriteCommand(0x0C);             //turn on display
I checked the board and I'd left D0-D3 floating so can't confirm if this works with the pins grounded.

Mike.
Thats the bit I can confirm, my LCD is on a bread board, I spotted the code mistake as I followed your code closely. If you ground the first 4 pins you normally leave floating in 4 bit mode. Lets call them D0 -D3.

D0 on its own does nothing if tied high or low, but does have function before code starts depending how other pins are set. If its tied high and all others low then it clars display which is the same as writing 0X01 in code during init

D1 again dosnt do anything unless tied high. I found all the lower four data pins had init functions depending how they were physicaly tied, left floating then everything is under software control

D2 if grounded before the code starts will put the LCD into 5 X 7 dot mode. If you keep it grounded it stays in that mode regardless what your code says. However if you tie it high before the code it starts in 5 X 10 dot mode, after the init code if its tied low you cant change it in code.

D3 If tied Low before code starts will put the display into 1 line mode, and tied high will give 2 line mode. Again I was unable to override it with init code.

As a side note, there is apparently 4 types of these controllers all with same designation, the main difference appears to be the special characters, one is even a European one, all mine are the Katana ones except 1 which appears to be the one with a Yen sign but not all the katana characters.

Status
Not open for further replies.