PDA

View Full Version : serial data to LCD



cunninghamjohn
- 18th November 2008, 20:07
I am trying out an experiment where one pic16f84 sends out serial data, whilst another receives the data on an LCD. I can only get the LCD to display a 0 for the received data with my code. Any suggestions?

transmitter

INCLUDE "modedefs.bas"
pause 1500

START
SEROUT PORTB.4,N2400,["1234"]
PAUSE 50
GOTO START

receiver

INCLUDE "modedefs.bas"
pause 500
START
M VAR BYTE
SERIN PORTB.5,N2400,[M]
lcdout $FE,1,#M
LCDOUT $FE,$C0,"HELLO"
PAUSE 300
GOTO START

mackrackit
- 18th November 2008, 20:18
Me thinks this will be of interest to you.
http://www.picbasic.co.uk/forum/showthread.php?t=4972&highlight=serial+backpack

mackrackit
- 18th November 2008, 20:29
And changing


START
SEROUT PORTB.4,N2400,["1234"]

to


START
N = 1234
SEROUT PORTB.4,N2400,[DEC N]

might help

mister_e
- 18th November 2008, 20:42
Much simple... your SERIN line is wrong

SERIN PorPin, Mode, Variable

Using the square bracket says you want to wait a specific character..


INCLUDE "modedefs.bas"
M VAR BYTE
pause 500
START
SERIN PORTB.5,N2400,#M
lcdout $FE,1,#M
GOTO START

if you send 1234... it will never fit in a BYTE variable.. max=255...

Leave your transmitter code as is, but change 1234, to 123 for now to see what happen.


PS: DEC modifier should not work for SEROUT, but for SEROUT2 .

Archangel
- 18th November 2008, 22:01
have a look here, esp. post 16:http://www.picbasic.co.uk/forum/showthread.php?t=4972&highlight=cren

cunninghamjohn
- 20th November 2008, 17:06
Thanks to everyone for the quick replies. I havent had chance to try the corrected code as yet, Ill post back when I get chance.

Regards, John

cunninghamjohn
- 22nd November 2008, 21:24
Ok I now have a working prototype, thanks to all that contributed.
Transmitter:

INCLUDE "modedefs.bas"
N VAR BYTE
FOR N=0 TO 255
serout PORTB.0,N300,[N]
TOGGLE PORTB.1
PAUSE 100
NEXT N

Receiver:

INCLUDE "modedefs.bas"
N VAR BYTE
PAUSE 1000
START
LCDOUT $FE,$C0,"SERIAL RECEIVER"
SERIN PORTB.4,N300,N
LCDOUT $FE,1,#N
PAUSE 50
GOTO START

Leonardo
- 23rd November 2008, 20:10
Ok I now have a working prototype, thanks to all that contributed.
Transmitter:

INCLUDE "modedefs.bas"
N VAR BYTE
FOR N=0 TO 255
serout PORTB.0,N300,[N]
TOGGLE PORTB.1
PAUSE 100
NEXT N

Receiver:

INCLUDE "modedefs.bas"
N VAR BYTE
PAUSE 1000
START
LCDOUT $FE,$C0,"SERIAL RECEIVER"
SERIN PORTB.4,N300,N
LCDOUT $FE,1,#N
PAUSE 50
GOTO START

Hello,

You can put the schema to understand it better.

Thank you

cunninghamjohn
- 25th November 2008, 15:50
The receiver is simply the LCD display example in the picbasic pro manual, with a 4MHz crystal and uses 4 data lines to the LCD. The serial input is on pin 10. The transmitter is a 16F84 with 4MHz xtal, pull up resistor on MCLR and the serial output on pin 10. Power for both modules is a battery pack and 7805 regulator.
I am thinking of replacig the wire linking the tx to the rx with one of those 433MHz tx/rx modules so I can use the display remotely.