serial LCD and keypad driver

donrecardo

Senior Member
Hi
Has anyone used the Serial LCD and keypad driver from Web4Robots ?

I have a couple and was hoping to learn how to use them

I have connected an LCD to the driver with a pot for contrast control
and on applying power I get the splash screen ok. I wish to drive it
from an 18X picaxe chip .

The driver by default starts up in 9600 baud .
Could someone give me a hint as to a line of code to display something
like " Hello 123" on the LCD

The driver can work in serial or i2C mode , and I would like to learn how to
talk to it both ways , Serial/I2c
The manual is here but to be honest I dont really understand it
http://www.web4robot.com/files/SerialLCDCtrl.pdf

normally for serial I use things like serout 7, n2400, ("Hello")
but I tried changing N2400 to N9600 to match the controllers baud rate but it didnt like that , and with i2c its normally writei2c 0, ("Hello") but looking in the manual I cant see what I should use for the address to write to. To make it worse where I am used to seeing things like (254,1) to clear the display , this chip uses hex with numbers like 0xFE

Can anyone point me in the right direction, if I could just get it to change baud rate to 2400 I feel I could then get it to talk to me via serout

Regards
Don
 

Chavaquiah

Senior Member
Lousy datasheet, I must say. Still useful and, with some experimentation, I'm sure you'll be talking to the LCD in no time.

If your Picaxe can not reach 9600, maybe start with i2c. There is one command to change baud rate. Let's hope the new baudrate is stored in some non volatile memory.

Don't worry about hex numbers. Just write something like $FE.

Default i2c address is $4C. Now, maybe these are only the 7 MSB bits and you have to add a binary digit to the right. Try with both $4C and $98. One should work.

Then you could change baud rate. For 2400 the command would be "$FE, $02, $01" or "254, 2, 1". Try both a write to address 0 { WRITEI2C 0, ($FE, 2, 1) } and to use the first command byte as an address { WRITEI2C $FE, (2, 1) }.

To change cursor position, the command is $FE, $0C, col (0-19), row (0-3). The manual is so great that it lists once the order as col/row and then as row/col.


UPDATE:

I had a very cursory look at example code for the Arduino. Seems you should forget about addresses. Try using $FE or the first byte of each command as the sddress to write to. Also, you probably won't be able to read from the LCD using i2c on a Picaxe. At least without bit-banging. Better concentrate your efforts on the serial interface. Try both T2400 and N2400 (after changing baudrate via i2c).


EDIT:

Sorry, I was very wrong about Picaxe's i2c commands. The address to write to/read from is optional. As such, you should have no problems. Just use it like WRITEI2C ($FE, 2, 1).
 
Last edited:

westaust55

Moderator
With the 18X, if you change the clock frequency with

SETFREQ m8​

then you have access to 9600 baud with

SEROUT <pin>, N9600_8, ("your info here")
; maybe need T9600_8 in which case add a HIGH <pin> before first SEROUT


if you change the LCD baud rate down to 2400 or 4800 baud then you can run the 18X at 4MHz if you need to for other commands/devices (SETFREQ m4)
 

donrecardo

Senior Member
Thanks both for your help.

The great news is it now works :) well in serial at least .

I thought I should write down what I did so any other beginners like me
could follow it

I used
Setfreq m8
Serout 7, N9600, ($FE,£07) which should display the current baud rate
but I got nowhere so I changed it to

setfreq m8
High 7
Serout 7, T9600, ($FE,$07) Eureka !!!

The LCD then displayed " Baud Rate 9600 " thats ok as its the default rate

Now I made the code

setfreq m8
High 7
Serout 7, T9600, ($FE,$02,1) which should change its baud rate to 2400

Again I ran the display routine to see the baud rate but didn't get what I
expected , then I realised , if it did indeed change its baud rate to 2400 its
hardly suprising that it wont listen to me any more when I send at 9600

I changed the code to

' setfreq m8 Commented out
High 7
Serout 7, T2400, ($FE,$07) use 2400 to send the commands

LCD Display now reads " Baud rate 2400 " Result !!!!

Now I can talk to it at 2400 with my 18x easily

I discovered that

High 7
Serout 7, T2400 , ($FE,$15,5,"Hello") prints "Hello" on the LCD
the $FE,$15 tells it to send to the LCD , the 5 is the string length, and Hello is the string to print

Also using the character table you can display anything to LCD eg.
High 7
Serout 7, T2400, ($34,$37,$30,$F4) will display 470 Ohms ( it displays the
omega sign but I dont know how to display that on here)

I still cant get it to work in i2c but will keep trying
Thanks again to the 2 that helped me out and I hope this post helps any other newbie that buys the Web4robot lcd driver module

Don
 

hippy

Ex-Staff (retired)
Can't help with the I2C side of things but one handy tip for

Serout 7, T2400, ($34,$37,$30,$F4)

is to define those hard to remember numbers as named constants with symbol definitions ...

Symbol OHMS = $F4
High 7
Pause 10
Serout 7, T2400, ( "470", OHMS )
 

donrecardo

Senior Member
Can't help with the I2C side of things but one handy tip for

Serout 7, T2400, ($34,$37,$30,$F4)

is to define those hard to remember numbers as named constants with symbol definitions ...

Symbol OHMS = $F4
High 7
Pause 10
Serout 7, T2400, ( "470", OHMS )
Thats a good idea, I shall have to try to remember things like that

Don
 
Top