16*2 or 20*4 LCD wiring

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
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.
 

ErnieM

Joined Apr 24, 2011
8,377
Here's how I connect mine:


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).
 

Attachments

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I will hold on to the pretty please part for later.

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

MaxHeadRoom

Joined Jul 18, 2013
28,700
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.
 

Attachments

Last edited:

THE_RB

Joined Feb 11, 2008
5,438
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?;

 

ErnieM

Joined Apr 24, 2011
8,377
Right now I wanna know why you are using R/W.
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.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
And I thought the easypic diagram had shown that way for simplicity.

Thanks Guys. My doubts are clear now.
 

THE_RB

Joined Feb 11, 2008
5,438
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.
...
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.
 

ErnieM

Joined Apr 24, 2011
8,377
We've had this discussion before.
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:

t06afre

Joined May 11, 2009
5,934
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
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I will get back to addressing part when the Displays are in my hand.

But thanks for the heads up
 

THE_RB

Joined Feb 11, 2008
5,438
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.
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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.
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?

And I've read your posts often enough to know that you love the idea that I'm wrong and leap to embrace 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.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
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.
 

THE_RB

Joined Feb 11, 2008
5,438
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. :)
 

ErnieM

Joined Apr 24, 2011
8,377
If you both become cross at each other I will be the one to suffer.
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.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
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.
 

ErnieM

Joined Apr 24, 2011
8,377
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 )
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!
 

MrChips

Joined Oct 2, 2009
30,824
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:
Top