40x4 LCD to PICAXE 40X2 interfacing question

vk6bgn

New Member
Hello All,

I have acquired a 40x4 back lit LCD display from a decommissioned piece of equipment. I really don’t need to haul yet another old piece of gear home but for some reason I felt compelled to.

At some point in the very near future I would like to interface it to one of my spare PICAXE 40X2 chips. Looking at the PICAXE chip documentation and the LCD (HD44780?) documentation, I’m trying to figure out what is the best PICAXE pin to LCD pin arrangement.

It appears to me that a hook up scheme might go something like this.

PICAXE pin-----LCD pin
---------------K(BL), pin 16
---------------A(BL), pin 15
Pin 40(b.7)-----DB7, pin 14
Pin 39(b.6)-----DB6, pin 13
Pin 38(b.5)-----DB5, pin 12
Pin 37(b.4)-----DB4, pin 11
Pin 36(b.3)-----DB3, pin 10
Pin 35(b.2)-----DB2, pin 09
Pin 34(b.1)-----DB1, pin 08
Pin 33(b.0)-----DB0, pin 07
Pin 30(d.7)-----E, pin 06
0V-------------R/W, pin 05
Pin 29(d.6)-----RS, pin 04
Potentiometer--Contrast, pin 03
Vdd +5VCD-----pin 2
Vss 0V---------pin 1

The only reason I chose this pin arrangement is I thought it might be easier with all the PICAXE output pins in a row when drawing up the PCB artwork to interface with the panel mounted 40x4 LCD display.

Questions:
Is this the obvious choice??? (for my very manual and tedious artwork program, this will work best for the component layout)

Is there a better choice of PICAXE pins that could be used to make coding easier???

You thoughts and comments appreciated.

"Hammy"
 

John West

Senior Member
I'd suggest you seriously consider investing in a serial LCD interface/controller chip. They're cheap - free up controller pins for other uses - and make LCD control code writing a breeze.

I think Rev. Ed. offers such a circuit - you might want to look at their product line for it.

AXE033IC or AXE033-IC I believe is the part number for just the chip. AXE033 is the base number for an entire bd kit. Others here can steer you to it.


Also - here's an LCD controller chip I've personally used in the past. Still do:

http://www.phanderson.com/lcd106/lcd107.html

http://www.wulfden.org/downloads/manuals/K107manual.pdf

The first addy is for the chip itself - offered by Dr. Anderson - who sometimes frequents this forum.

The second addy is for a site that supplies both the chips and an all-purpose bd and parts - a product I have also used in the past. Seems to work just fine.

There is a version of the chip specifically for PICAXE interface.

These interface chips for the Hitachi controller save so much hassle they are worth their weight in gold as far as I'm concerned. But if you are forced by space limitations or just want to do things the hard way in order to learn more about the PICAXE and LCD's then the way you describe will indeed work. Since I've only worked with the dedicated interface chips I can't offer much help on which pins are best to use in a direct connection.

BTW - I don't think a 4X40 LCD is directly supported by the Anderson chip - but all you really need is a free control line to toggle between the 2 Hitachi display chips in order to make it work. Not too hard to do.
 
Last edited:

westaust55

Moderator
LCD interface

Still not quite an answer to your question, but some "food for thought".

The parallel interface as you have proposed will give a high data transfer speed to the LCD module at the expense of using around 10 PICAXE IO pins. Then ere is the possible need for an extra line still as John West has mentioned.

Use of a commercially available serial Backpack module as discussed by John West will allow you to use the conventional SEROUT command and your program code will be the most portable for use on other hardware.

Alternatively if you are just experimenting and can accept slower speeds (for example t to 10 times slower than SEROUT) then you could alway try a 1-Wire interface using Maxim DS2408+DS2413 or a shift register based approach in 2 or 3 wire interface. I have posted some information on both of these methods in the past along with hardware, program code and some data transfer speeds.


finally, I note that your post footer/signature indicates:
"Editor version: 5.2.9 for Windoz"
PE version 5.2.11 has beena round for a while now.


EDIT:
Also have you first tried connecting up the LCD to a PICAXE via a breadboard to check operation of the LCD.

Some LCD modules require a small negative voltage for the contrast.
Better to know the circuit will function before you commit to a PCB design and etch the board.
 
Last edited:

vk6bgn

New Member
Thanks for the reply. I’m actually revisiting a previous amateur radio project from a few years ago where I tried to use a freebie AXE-33(?) 2x16 serial LCD but found it way to slow for what I was trying to accomplish. So slow that I eventually threw in the towel on having a LCD in the PICAXE-18X radio repeater controller project. I believe in the end I used that last available pin on the 18X to drive a LED or relay rather then a serial display.

Now that I have acquired the 4x40 LCD, 40 pin IC sockets and purchased a couple 40X2’s, I thought I might give it another go. It's occurred to me that maybe trying to print to a LCD display with 8 bits rather then serially, would be so much faster????? And since I only require the same number of pins as an 18X, a lack of I/O will not be an issue. Hence the revisit and attacking the project again.

Back to the original question of which I/O pins to use? Unless someone comes to the rescue and can enlighten me on any programming difficulties using any other 40X2 pins, I guess I will just use Port B. For backyard circuit board etching, it appears to be physically the easiest to get D6, D7, 0V, +5V and the eight port B I/O pins to the edge of the circuit board and exit and attach to the LCD since all those pins are consecutive. Pin 29 – 40. All in a row! Just a thought.

Thanks again.
 

hippy

Technical Support
Staff member
For fastest parallel driving of LCD it's best to put data lines on one port and contiguous. If using 4-bit interface, LCD D4-D7 to PinX.0-PinX.3 or PinX.4-pinX.7, for 8-bit interfacing LCD D0-D7 to pinX.0-pinX.7. Any port can be used.

Control signals can usually go on any spare pins anywhere but there is some benefit in placing RS on the same port as D4-D7 when using 4-bit mode.

My personal preference is to wire in 4-bit mode, D4-D7, RS and E placed as they are on a single port as the Manual 3 code shows for an LCD connected to an 18X. That way you can test with Rev-Ed code supplied in Manual 4.

Note that for 40x4 displays these are usually two separate 40x2 displays in the same package. You will likely have to initialise these completely independently; two separate E lines, shared D0-D7 and RS lines.
 
Last edited:

westaust55

Moderator
I’m actually revisiting a previous amateur radio project from a few years ago where I tried to use a freebie AXE-33(?) 2x16 serial LCD but found it way to slow for what I was trying to accomplish. So slow that I eventually threw in the towel on having a LCD in the PICAXE-18X radio repeater controller project. I believe in the end I used that last available pin on the 18X to drive a LED or relay rather then a serial display.
In respect of the speed (all based upon 4MHz clock speed),
An AXE033 operates at a baud rate of 2400 so the data transfer rate is around 240 characters per second.
By comparison, shift register methods are around 30-40 characters per second.
Untested, but based upon an average of 0.25ms per instruction and a bit longer for GOSUB and RETURN commands, with a 4-bit parallel interface will give around 250 characters/second
The 8-bit parallel interface does not require splitting each nybble out of the character byte and (again untested but) should achieve around 500 chars per second so akin to 4800 baud.

Sparkfun do a LCD module that others have used here that will use a serial output at 9600 baud. Not sure whether the LCD interface is available on its own but if so may be worthy of consideration for higher speeds and fewer pins sued.
 
Top