PDA

View Full Version : Garbage in from RFID



lilimike
- 13th November 2009, 04:36
Hi,
I can not get arround to read the RFID reader.
I was able to properly read my RFID by connecting to pin 3 from my computer's serial port and using hyperterminal so I know the RFID module is working.

Running my code bellow I see the word "test" on my LCD so I know the LCD is properly connected but everytime I get a beep out of my RFID tag I get garbage characters and different characters every time I use the same tag, I am using the dev board that came with Pickit2 (16F887) and connected LCD in 4 bit mode to port B0-B3, RS to B4 and EN to B5 with output of RFID to port C7.

Any help would be appreciated to get me started.

Thank you.



INCLUDE "modedefs.bas"
DEFINE OSC 4
TRISB = %11000000
ADCON0 = %00000000
ANSELH = %00000000
WPUB = %00000000
IOCB = %00000000

DEFINE LCD_DREG PORTB ' Set LCD Data port
DEFINE LCD_DBIT 0 ' Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
DEFINE LCD_RSBIT 4 ' Set LCD Register Select bit
DEFINE LCD_EREG PORTB ' Set LCD Enable port
DEFINE LCD_EBIT 5 ' Set LCD Enable bit
DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
DEFINE LCD_LINES 2 ' Set number of lines on LCD
DEFINE LCD_COMMANDUS 2000' Set command delay time in us
DEFINE LCD_DATAUS 50 ' Set data delay time in us
define HSER_RCSTA 90h
'DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 9600
DEFINE HSER_SPBRG 25
define HSER_CLROERR
A0 var byte
A1 var byte
A2 var byte
A3 var byte
A4 var byte
A5 var byte
A6 var byte
A7 var byte
A8 var byte
A9 var byte
A10 var byte
A11 var byte


LCDOUT $FE,1,"test" 'clear lcd
pause 1000
LCDOUT $FE,1


main:
HSERIN [A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11]
LCDOUT $FE,1,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11

goto main

End

Sphere
- 13th November 2009, 16:22
Are you connecting your reader via a max232 chip to your pic.

Sphere

lilimike
- 13th November 2009, 17:04
Well I was hoping to connect directly to pin RX!
Maybe I am missing some knowledge?
Can this be done?

Sphere
- 13th November 2009, 21:56
The signal needs to be inverted if using the hardware serial pin on your pic hence the reason for the max232. You could just use serin2 comand and run it in inverted mode.

Sphere

lilimike
- 14th November 2009, 13:37
Sphere,

You sent me to the right direction and I finally got it working, I spent a lot of time trying to understanding the mode value from serin2 because in the PBP manual it says bit 15 is not used but it is not specified anywhere (that I could find) that it should be set to 1 but I got it now.

Thanks for your help.

Mike

Sphere
- 14th November 2009, 18:48
No problem.

Sphere

berke1984
- 6th December 2009, 14:55
'************************************************* ***************
INCLUDE "MODEDEFS.BAS"

'***********************DEFINITIONS*************** ************************
DEFINE Osc 4
'--------------------------------------------------------------------------------------------
'***********************SERIAL COMM DEFINITION**********************
DEFINE HSER_TXSTA 24h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 19200

DEFINE LCD_DREG PORTb
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTb
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTb
DEFINE LCD_EBIT 3

cmcon=7
trisb=%00000010
trisa=%00000001

a var word
b var word
c var word
d var word
e var word

ANAPROGRAM:

hserin [hex2 a,hex2 b,hex2 c,hex2 d,hex2 e]
pause 50
LCDOut $fe, 1,hex2 a,hex2 b,hex2 c,hex2 d,hex2 e
pause 10

goto anaprogram

end