PDA

View Full Version : LCD SEROUT2 help



CSU_2010
- 24th November 2008, 23:22
Hi all,
I have a serial LCD connected to a 16F88. I can get things to display on the LCD if I write the code like:



SEROUT2 lcd,396,[$FE,1,"Test"]


But I am lost on how to get a variable to display.



SEROUT2 lcd,396,[$FE,1,variable]


The end result I'm looking for is getting an RFID tag number from a reader and display that tag number on the lcd. I'm using a parallax RFID reader.

Thanks for any help,
Josh

mackrackit
- 24th November 2008, 23:39
SEROUT2 lcd,396,[$FE,1,#variable]

CSU_2010
- 24th November 2008, 23:42
I got this code to work:



DEFINE OSC 8 'Internal Oscillator set to 8mhz
OSCCON.4=1
OSCCON.5=1
OSCCON.6=1

ANSEL=0 'Turns off A/D converter

lcd Var PORTB.5

tag1 Var BYTE

Pause 500

SEROUT lcd,0,[$FE,1]

Pause 200

SEROUT lcd,0,[$FE,1,"Test"]

Pause 2000

SEROUT2 lcd,396,[$FE,$C0,"2nd Line???"]

tag1=123

SEROUT2 lcd,396,[$FE,$94,DEC tag1]


But now I'm trying to get a ten digit number to display, something like

1000504B02

and i keep getting errors.

mackrackit
- 24th November 2008, 23:47
How are you storing this 10 digit number? In an array?

CSU_2010
- 24th November 2008, 23:49
I'm not really sure how to store it, I tried just putting


tag1=100050A4B7


But it truncates and displays only "FF"

mackrackit
- 25th November 2008, 00:04
The easy way would be

tag1 Var LONG
If you are using PBP 2.50

Otherwise I would say you need to store it an array.

CSU_2010
- 25th November 2008, 00:17
This is what I tried:



buf VAR BYTE(10) 'Tag code stored as word

SERIN2 rx,396,[STR buf\10]

SEROUT2 lcd,396,[$FE,$C0,STR buf\10]



The LCD then displays a three digit display but it's symbols and not anything readable.

mackrackit
- 25th November 2008, 00:35
I am feeling lazy, so I will point you here.
http://www.picbasic.co.uk/forum/showthread.php?t=544

astanapane
- 5th June 2011, 11:43
Hello all,

since i didnt find anywhere in the forum the solutions or a thread for the following question, i would like to request your advice.

I'm currently building an RFID reader tag with PIC16F628a and LCD 2x16.

i'm trying to display the tag number on the LCD screen.

My problem is that i want to use SERIN2 for getting the tag number and the SEROUT2 for displaying it to the LCD.

Since i only know how to use 2x16LCD command as follows:

DEFINE LCD_DREG PORTB 'define port to LCD
DEFINE LCD_DBIT 4 'RB4 RB5 RB6 RB7 to D4 D5 D6 D7 display
DEFINE LCD_RSREG PORTA 'RS on porta
DEFINE LCD_RSBIT 0 'RS on porta.0
DEFINE LCD_EREG PORTA 'Enable on porta
DEFINE LCD_EBIT 1 'Numero Enable porta.1
DEFINE LCD_BITS 4 '
DEFINE LCD_LINES 2 'lines 2

So i have connected the pic16f628 according to the above configuration for the LCD 2x16.

I have also connected the RX pin in order to read the data from the RFID output data.

SERIN2 portb.1, 84, [WAIT($02), Str buf\10]

The problem is that the TX from the pic16f628a is not connected anywhere.

How do i display the tag number with serout2 command to an LCD 2x16?

or lets start from the very basic staff.

first of all to display something on the LCD using the serout2 command.

I dont understand how to use the portb.2 which is the TX port for the pic16f628a to the LCD.

thanks for any help.

the following is my code.


@ device pic16f628a
include "modedefs.bas"

CMCON = 7
define osc 8

DEFINE LCD_DREG PORTB 'define port to LCD
DEFINE LCD_DBIT 4 'RB4 RB5 RB6 RB7 to D4 D5 D6 D7 display
DEFINE LCD_RSREG PORTA 'RS on porta
DEFINE LCD_RSBIT 0 'RS on porta.0
DEFINE LCD_EREG PORTA 'Enable on porta
DEFINE LCD_EBIT 1 'Numero Enable porta.1
DEFINE LCD_BITS 4 '
DEFINE LCD_LINES 2 'lines 2
PAUSE 200 ' Stop 200ms
LCDOUT $FE,1 ' power lcd
Lcdout $FE,1,4
lcdout $FE, 1," Copyright 2011"
lcdout $FE, $C0,"Leonardo Bilalis"
pause 2000
lcdout $FE,1
' -----[ Variables ]-------------------------------------------------------

buf VAR byte [10]' RFID bytes buffer
tagNum VAR Byte ' from EEPROM table
idx VAR Byte ' tag byte index
char VAR Byte ' character from table

Main:
lcdout $FE,1," Please use your"
lcdout $FE, $C0," TAG"
pause 500
high portb.3
pause 500
SERIN2 portb.1, 84, [WAIT($02), Str buf\10]
pause 500

serout2 portb.2,84 [STR buf] 'this pin is nowhere connected :(
pause 1000 'Pause ,1 sec

goto main

HenrikOlsson
- 5th June 2011, 12:29
Hi,

How do i display the tag number with serout2 command to an LCD 2x16?
You don't..... you use LCDOUT. If you had a serial LCD (or back-pack) then you'd use SEROUT but since you have the LCD wired to your PIC in parallel 4-bit mode mode you use LCDOUT just like you're already doing in the code. And the STR modifier works with LCDOUT as well

LCDOUT $FE,$C0, "Tag: ", STR buf

/Henrik.

astanapane
- 5th June 2011, 12:57
DEar Mr. Henrik,

i will try and let you know in a bit.

Regards,

P.S.

i DID IT!!!!!!!!!!!!!

thanks a lot!!!!!!! thanks thanks. i didnt know that is so easy.

Now i have a tag nubmer dipslayed in LCD 2x16.

thank you very much for your help.

astanapane
- 5th June 2011, 19:04
hi all again,

this is the video from the code above.

thanks Henrik for helping me to complete my code.


http://www.youtube.com/watch?v=MY0kzakfE0g