lcd to 40x2 direct connection

In manual 3 page 35 [Connnecting The LCD (OPTION 3)]... what chip is it referring to 28x2 or 18x ect....
The LCD has 6 lines that can be connected directly to the PIC microcontroller pins 2,3,4,5,6,7...
The PIC microcontroller Iam using is the 40x2....My question is what pins of the 40x2 would I connect THE DB4,DB5,DB6,DB7,SE.RS of the lcd to
 
Last edited:

BeanieBots

Moderator
You could connect to any of the 'regular' outputs (legs 33 to 40 on a 40X2) and adjust the code accordingly.
Looks like that diagram is suggesting legs 35 to 40 but I've not read the whole manual so can't be 100% sure.
 

hippy

Ex-Staff (retired)
The pin numbers on page 35 refer to "Output Pin" numbers of the standard output port of the 18X etc. Note that the LCD in this manual has its data lines labelled incorrectly in reverse. LCD leg 14 is LCD DB7, LCD leg 11 is LCD DB4.

For a 40X -

40X Output Pin 7 ( leg 40 ) to LCD DB7 ( leg 14 )
40X Output Pin 6 ( leg 39 ) to LCD DB6 ( leg 13 )
40X Output Pin 5 ( leg 38 ) to LCD DB5 ( leg 12 )
40X Output Pin 4 ( leg 37 ) to LCD DB4 ( leg 11 )
40X Output Pin 3 ( leg 36 ) to LCD E ( leg 6 )
40X Output Pin 2 ( leg 35 ) to LCD RS ( leg 4 )

Examples of correct wiring for various sized PICAXE are shown here ...

www.hippy.freeserve.co.uk/picaxelc.htm

For 40X2 use I'd use the 40X wiring and convert the PICAXE code to be suitable - You can use the Programming Editor X2 Conversion Wizard to convert 40X code to 40X2 code and that should work. Change "byte" to "bite" and change "get" to "idx" for the code on the above we site link.

PS : It's not a "PIC microcontroller", it's a PICAXE.
 
Last edited:

nbw

Senior Member
I'm wondering about page 39 of the picaxe_manual_3. It says that although only 6 OUT pins are used, the 'dirs' command will affect all 8 pins. I'm thinking of direct connecting to an 18x and using the extra 2 pins for something else - am I right in reading that I can't? Or will it be ok?

Hippy might be able to assist with this one :)
 

nbw

Senior Member
Ah, I trolled / trawled through more posts and found the answer - supplied by Hippy previously!. Using peek and poke I can 're-create' the before and after for pins 0 and 1.

SO here's another q: I wish to use pin3 of my 18X for PWM, so will that be affected by the LCD code? :)

thanks IA
 

inglewoodpete

Senior Member
The setup that hippy advocates above has Pin 3 connected to the LCD enable input. 'fraid thats a bit fundamental on an LCD (or any other chip/module):rolleyes: The LCD will go :eek: with PWM on its enable pin!

I suggest that you move the LCD's enable function to another output pin on the 18X.
 
Last edited:

hippy

Ex-Staff (retired)
Once you go away from that connection scheme the Rev-Ed ( and my ) software will need to be rewritten to work, and rewritten again to use unused pins.

Get it working with the recommended connection scheme first, then working with the re-ordered pins, then working with use of the unused pins. Keep backups of each version of the code which works so you can go back and verify the LCD is still working. Try to jump in at the end and if it doesn't work it will simply be suggested to start from the beginning again and implement incrementally anyway.

Prototype on breadboard before committing to a vero-board or PCB design.
 

nbw

Senior Member
Sinking further!

So I tried a serial LCD chip on the new 24x2 display. Nothing. I adjusted contrast so I can see a row of squares. Backlight is fine.

So, I removed the serial LCD and wired it up directly to my 18X. 5.06V going to the LCD itself.
No luck at all.

The manufacturer claims it HD44780 or equivalent... and then I noticed something which doesn't look right near the bottom right of the spec sheet - the line addresses look wrong. i.e. not 128, 192 but 00 and $40. I've attached the sheet:
 

Attachments

westaust55

Moderator
lcd direct connection

@nbw,
Other data/control pins have been mentioned but not the R/W line. Do you have the LCD pin 5 pulled low to 0V?

Can you upload a clear photo of your circuit showing both ends of each wire so we can check pin to pin.. Will help folks here look for wiring errors.
 

nbw

Senior Member
hi guys. Got it working in 6-line mode. I didn't appreciate (duh) the importance of the code requiring all outputs be together starting from 7 down. I was using the outputs available, which was a combination of 0 - 7 exlcuding 3 for the PWM

So I re-arranged and got characters displaying fine using Hippy's code.

That pwm issue is still interesting though. I'd really like to use this 18X as it's ideal for this piece of work. I'm using all 3 ADCs, and on the output side - just the PWM and the other lines are free for the LCD.

Is it possible to change something in Hippy's code to 'skip' output 3 (pwm) and use the next one down say output 1?

I'll post my code in about 10 mins once I get it off the other PC.

cheers all
 

nbw

Senior Member
Here's the code for the 20M

Here's the code for the 20M that is currently driving the 24x2 LCD. No PWM of course on the 20M but it shows you where I'm at.

I renamed the .bas as .dsn
 

Attachments

hippy

Ex-Staff (retired)
The manufacturer claims it HD44780 or equivalent... and then I noticed something which doesn't look right near the bottom right of the spec sheet - the line addresses look wrong. i.e. not 128, 192 but 00 and $40.
That sounds right, address usually goes $00 to $7F but that's set by using a command of $80+address, hence the $80 to $FF you see after the 254 in SEROUT for serial controlled LCD's and what has to be sent out as a command when using direct parallel.
 

nbw

Senior Member
right Hippy - the addresses I used to get things to appear on the top and bottom lines were the usual 128+x, 192+x.
 

hippy

Ex-Staff (retired)
That pwm issue is still interesting though. I'd really like to use this 18X as it's ideal for this piece of work.
The should be possible; just move E to another pin, nothing else should need to change, though I haven't tried PWM at the same time.
 

nbw

Senior Member
Well, I'm going to go out of the house, slap myself twice, and come back in.

I just retried the serial firmware chip, and it works. Man, I must be getting old / losing it / both. Maybe my kids are doing me head in?!!?

Question tho for you Hippy: I'm serouting at t2400, is it possible to transmit a bit faster e.g. 4800? I'm wondering if LCDs in general being rather slow devices might prefer to stay at 2400.

p.s. thanks for your thoughts on this thread. I'm going to post a ton of pixs when the project is finished.
 

hippy

Ex-Staff (retired)
Baud rate will depend on what serial module / serial LCD you have. Baud rate should not be dependant on LCD operation and speed but it depends on the module and how its firmware is implemented. Most LCD commands can be completed in just a few microseconds, Clear Screen is the usual exception which takes longer.
 

westaust55

Moderator
Here's the code for the 20M that is currently driving the 24x2 LCD. No PWM of course on the 20M but it shows you where I'm at.

I renamed the .bas as .dsn
While in this case the file size is > 19K so yes worthwhile, but with many (including me) using the "dsn" extension for file types that are not supported, it is good for all to remember that the forum can directly accept .bas files up to 19.5kbytes in size.

Upload File from your Computer

Upload File from a URL

Uploading File(s) - Please Wait
Attachment Key
Filetype Max Filesize Max Width Max Height
bas 19.5 KB - -
cad 19.5 KB - -
dsn 976.6 KB - -
 
Last edited:

nbw

Senior Member
And as penance for me somehow managing to screw up a simple serial LCD to 24x2 connection, I've just discovered a big stinging hole in my tooth and have to go to the dentist. And, wait for it, I nearly got a tooth-hurty appointment..... ;-)
 
Top