1. 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.
    Dismiss Notice

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

Discussion in 'General Electronics Chat' started by Elerion, Jul 14, 2017.

Tags:
  1. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    9,886
    Likes:
    306
    Location:
    Brisbane Australia
    The initialization sequence doesn't mention D3-D0.

    Mike. LCD init.png
     
    • Agree Agree x 1
  2. jpanhalt

    jpanhalt Well-Known Member Most Helpful Member

    Joined:
    Jun 21, 2006
    Messages:
    5,704
    Likes:
    477
    Location:
    Cleveland, OH, USA
    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):
    upload_2017-7-16_2-34-28.png

    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
     
  3. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND
    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: Jul 16, 2017
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND

    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.
     
  6. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,442
    Likes:
    236
    Location:
    North west UK
    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.
     
  7. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND
    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 :D
     
  8. Nigel Goodwin

    Nigel Goodwin Super Moderator Most Helpful Member

    Joined:
    Nov 17, 2003
    Messages:
    38,985
    Likes:
    616
    Location:
    Derbyshire, UK
    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.
     
  9. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,044
    Likes:
    637
    Location:
    Ex Yorks' Hants UK
    ONLINE
    Hi Nigel.
    I remember it well, also those reams of preprinted machine coding sheets that had be entered by hand,,,, happy days!:banghead:

    Eric
     
  10. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND
    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.
     
  11. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND
    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.
     
  12. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    9,886
    Likes:
    306
    Location:
    Brisbane Australia
    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: Jul 17, 2017
  13. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND
    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.....
     
  14. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    9,886
    Likes:
    306
    Location:
    Brisbane Australia
    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 (text):

        __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.
     
  15. dr pepper

    dr pepper Well-Known Member

    Joined:
    Oct 6, 2008
    Messages:
    4,442
    Likes:
    236
    Location:
    North west UK
    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.
     
  16. Little Ghostman

    Little Ghostman Well-Known Member Most Helpful Member

    Joined:
    Jan 7, 2011
    Messages:
    3,654
    Likes:
    422
    Location:
    SCOTLAND
    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.
     

Share This Page