16*2 or 20*4 LCD wiring

Discussion in 'General Electronics Chat' started by R!f@@, Apr 23, 2014.

  1. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    I like to clear some doubts.

    I checked the diagram on the easypic.

    The LCD connection in 4bit mode.

    I know that D4 to D7 are the data.
    And there are RS & EN.

    Q1. Are the above pins connected directly to PIC pins ?
    Q2. The D0 to D3 lines need to be grounded directly or through a resistor ?

    The R/W pin

    Q3. Is this the Read/write address pin ?

    This pin is not used as I saw.

    Q4. Should this pin be directly grounded directly or through a resistor ?

    I have seen pin labelled Vo or Vee.

    Q5. Is this the contrast pin ?
    Q6. Will LCD get damaged connecting this pin directly to Vdd or Ground ?

    I can google and I will see lot's of ways to do this. But I'd rather ask someone who has done this. That is connected a LCD to a circuit, not to a demo board.

    I do not wanna damage my Brand New (am going to buy) beautiful LCD's for my PSU and ADC value checker project.
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Here's how I connect mine:
    [​IMG]

    Every LCD I've seen wires this way to these pin numbers, 'cept those without backlights. If you happen to have different pin numbers go by the names not the numbers.

    The left hand connections are PIC pins, plus power (Vdd) and ground (Vss).

    You can ignore the buttons on the bottom (or ask pretty please how I re-use the LCD pins read some buttons).
     
    • LCD.jpg
      LCD.jpg
      File size:
      69.4 KB
      Views:
      233
  3. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    I will hold on to the pretty please part for later.

    Right now I wanna know why you are using R/W.
     
  4. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,542
    2,369
    Also I took my examples I still use from http://www.winpicprog.co.uk/pic_tutorial.htm
    There is a also a demo using descrete switches as an exercise to write to the LCD manually for the Hitachi based HD44780.
    You may not need the R/W depending on whether you want to read back from the data register/memory.
    Also rather than use time delays, the module can be checked for busy status.
    Max.
     
    Last edited: Apr 23, 2014
  5. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    You need 6 pins for D4-7 and RS and E. They can be direct connected to the PIC.

    MikroC compiler you are using does not need or use the R/W pin, that's an old fashioned way of doing it. Modern display standard is write-only. Just connect R/W to ground and save a PIC pin.

    The Ve is the contrast control pin. Some displays can work with this pin just grounded, others need this pin to the wiper of a 10k trimpot. You always get a better display with a trimpot to adjust contrast.

    The manual that came with your EasyPIC7 has a really nice diagram showing the LCD connection. I think this is it?;

    [​IMG]
     
    R!f@@ likes this.
  6. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Because it is simple the most efficient way to drive an LCD. The only resource you cannot buy is time, and having the R/W there gives you the best performance possible.

    The trick is to check the busy bit just before any operation to insure the last op is complete.
     
    R!f@@ likes this.
  7. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    And I thought the easypic diagram had shown that way for simplicity.

    Thanks Guys. My doubts are clear now.
     
  8. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    We've had this discussion before.

    It may give better TIME performance if you need those few mciroseconds, but overall performance and reliability might be an issue.

    Checking the flag requires losing one more digital driver pin, that is a loss of "performance". I pay dearly for pins and that one pin can be the difference between needing a much larger PIC.

    And the need to tristate the 4 data pins between input and outputs costs time for pin voltage settling, and can risk a very serious hardware bug; TRIS RMW.

    Switching from input to output also risks hardware state latchup if the pins are floating. So for good design you really should have 4 pullup resistors on the 4 data pins, that can be another performance and cost issue.

    Good design means really trying to avoid situations where you constantly have to switch pins between being inputs and outputs. That's more of a last resort than a good design choice.
     
  9. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    No we haven't. But I've read your posts often enough to know when you say some idea is "old fashioned" but yours is "modern" you probably have not done the math and are exaggerating your position.
     
    Last edited: Apr 24, 2014
  10. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Be very careful then programming the 4X20 line display. The adressing is kind of strange
    (NOTE all numbers in hex format)
    Line 1 start at adress 0x00 (same as always)
    Line 2 start at adress 0x40
    Line 3 start at adress 0x10
    Line 4 start at adress 0x50
     
    JohnInTX and R!f@@ like this.
  11. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    I will get back to addressing part when the Displays are in my hand.

    But thanks for the heads up
     
  12. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    And I've read your posts often enough to know that you love the idea that I'm wrong and leap to embrace it. ;)

    I've been working with displays since PIC had little clear windows on top. Since then displays have evolved, old fashioend display drivers used R/W like Hitachi 44780, but even back in those days it was an option because they knew poeple didn't want to have to "read" from an output device like a display.

    Modern displays are almost universally write-only devices. Would you like examples or can you go look it up for yourself?

    So my point about "modern display standards" being write-only and reading from a display is "old fashioned" is perfectly valid.

    If you are going to keep criticising my posts you might want to do more homework.
     
  13. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    And I've been working with PICs before they had that little window as EPROM was yet to be invented, General Instrument still owned the product line, and Simon was the killer app.

    Sure, your point about "modern display standards" is completely valid, but as we are discussing the "old fashioned Hitachi 44780" it really doesn't apply here at all, does it?

    One reaps what one sows. You have been intrusive and argumentative from the first. Your worst flaw is you confuse your preference for God given commandments.

    Enough, I feel like I'm feeding a troll.
     
  14. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Please guys. Don't start this.
    Modern or not I do not care.
    If it works well, I am happy

    You both give good advice, so I do not want you to be arguing over stupid things.

    If you both become cross at each other I will be the one to suffer.
     
  15. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Don't worry Rif@@, ErnieM and I have a long history where I discuss technical points and he doesn't like what I said and then starts posting snide personal insults.

    You'll see it in a lot of old threads, it's nothing at all to do with you. :)
     
  16. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Don't worry, I'm here looking out for your interests by explaining all (most?) of the alternatives so you are free to choose what best suits you, your project, and your skill level.

    I will point out bad advice when it is offered. That can only be to your benefit.
     
  17. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    Good to hear that Guys.
     
    GopherT likes this.
  18. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,754
    760
    OK.. Today I got the LCD's. Took a while to get here.

    2 pcs 20*4 and 2pc 16*2

    Plug them in to the easyPIC and the 16*2 works fine and as said before from you guys the 20*4 also works but just 2 upper rows ( the same code )

    Time to write some code for the ADC checker.
     
  19. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,388
    1,605
    Yeah that is completely expected. The lower two rows have a different address and they are not continious, meaning if you expect row 2 to flow to row 3 you will be dissapointed.

    The good news is it is just some code to get the other rows working. The hardware is done!
     
  20. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,361
    Simply note that 16 x 1, 16 x 2 and 20 x 4 LCD displays all use the same Hitachi HD44780 controller and therefore use the same character memory which is really a single 80 x 1 memory.

    All you need to do is figure out where each line starts in memory.

    (Hence line #2 begins at character position 40.)

    Edit: I made a mistake somewhere. t06 is correct. Line #2 begins at 0x40. I have to go check my notes.
     
    Last edited: Jun 17, 2014
Loading...