PDA

View Full Version : DIY Serial LCD



lwindridge
- 7th January 2005, 18:49
OK, this is mainly for fun but I'm trying to setup a serial LCD using a standard 16x2 LCD panel and a 16F84A.

Only problem is I just can't get it working properly.

Has anyone done this before and has some code I can scan over?

Like I said, I'm just doing this to learn some more about the PIC's and serial communication so it's not a desperate measure to get an all singing all dancing one :)

Cheers

Leigh

mister_e
- 7th January 2005, 18:59
What you know about your LCD ? Baudrate, command... tell us the exact things you have on hand.

I'll consider that your serial LCD is a 2400 baud, drive true, and accept common command.

Serpin VAR PORTB.0
TRISB.0=0
Serpin=0
pause 1000 'waiting for lcd startup

Serout serpin,0,[$fe,1,"hello",13,10]
here : goto here

mister_e
- 7th January 2005, 19:07
But maybe you want to do a kinda serial backpack too...



' Serial LCD 2400 BAUD

SerData VAR byte
SerPin VAR PORTB.0
TRISB.0=1

LCDOut $FE,1 'Clear LCD

Start:
SERIN SerPin,0,SerData 'receive data
LCDOut Serdata ' Send to LCD
GOTO Start

lwindridge
- 7th January 2005, 19:17
Yep, serial backpack is what I'm attempting to do.

I've essentially got what you've put in your example, but it just doesn't receive the data effectively enough at all and tends to fill the screen up with garbage.

I'm sure there's got to be a better way to keep things in sync, but at the mo I can't see it!!

mister_e
- 7th January 2005, 19:31
Depending on wich baudrate you perform it too. Is it doing the same garbage stuff on 2400 bauds? If you're using PIC to Send data to the PIC may try to add

DEFINE CHAR_PACING 1000

and post what happen. If you're using Hyperter, Microcode studio, be sure of the polarity of your SERIN ... i.e True/inverted.

Case you use Hyperterm you must set SERIN inverted if you're not using any RS-232 inverter (Like MAX232) .

example for 2400 BAUD

SERIN Serpin,4,SerData 'receive data from PC inverted

with this, be sure of your resistor between PIC and PC. Work good between 1K and 10K.

lwindridge
- 7th January 2005, 19:41
Surely for 2400 Inverted the Serin mode should be 396 right?

Or am I barking up the wrong tree??

lwindridge
- 7th January 2005, 19:42
Ignore me - that's for Serin2 - DOH!!

mister_e
- 7th January 2005, 20:00
Hehe, that's happen !!! for serin2 :16780

lwindridge
- 7th January 2005, 20:03
OK so that kind of works ok now.

Just need to figure out a way of telling it if there's no valid serial data coming in then just sit tight and wait...

I guess adding a flow pin might help eh??

mister_e
- 7th January 2005, 20:46
for sure you can use a flow pin, but most serial LCD backpack on the market doesn't have those... you can simply check the SerData range. In all backpack i did, i've never use this kind of flow control... but if you feel safer with that issue...

lwindridge
- 7th January 2005, 20:47
I don't really think it'll be an issue, but it just seems that if the port isn't connected to anything it just spurts garbage out everywhere.

Other than that it seems to be working lovely now!

mister_e
- 7th January 2005, 20:59
I don't really think it'll be an issue, but it just seems that if the port isn't connected to anything it just spurts garbage out everywhere

easiest way... pull-down resistor (let's say 22k) to ground.

That way if your lcd it's not connected... he will see only 0'S

lwindridge
- 7th January 2005, 21:36
Well, that's another project sorted - works lovely now!

Thanks for all your help there Steve.

Next one in line is interfacing data output using a serial inverter or similar to datalogging software on a PC.

But that's later... ;)

solara
- 10th January 2005, 10:41
If you have a Palm PDA, you can go wireless with SirPic's simple plug and play interface, and data logging software....
htttp://www.sirpic.com