hi all,

i did some small changes and read data on 9600.

But i cannot make it work yet.

When i pass the TAG from the reader does not display the name.

It displays 'Bad Dag' only. And the tag is the valid one i pass from the reader.

Could you please help me with my program?

I have tags from Sparkfun that i believe are with 12 digits so i think we need to make some changes there.

here is the code:

Code:
@ DEVICE PIC16F628A      

CMCON = 7   
DEFINE OSC 4	'Set oscillator in MHz

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                                ' Ενεργοποίησε το LCD
Lcdout $FE,1,4
lcdout $FE, 1," Leonardo"
pause 500
' -----[ Variables ]-------------------------------------------------------

buf	    VAR	Byte(12)' RFID bytes buffer
tagNum	VAR	Byte	' from EEPROM table
idx	    VAR	Byte	' tag byte index
char	VAR	Byte	' character from table

' -----[ EEPROM Data ]-----------------------------------------------------

Tag1	DATA	"450052B6BC1D"
Tag2	DATA	"450052F2EB0E"


' -----[ Initialization ]--------------------------------------------------

high portb.1	' turn off RFID reader portb.1 is the reciever port
LOW portb.2	    ' lock the door!
Low portb.3	    ' Turn off LED

' -----[ Program Code ]----------------------------------------------------

Main:
high portb.3
low portb.1					    ' activate the reader
SERIN2 portb.1, 84, [WAIT($0A)] ' STR buf\12]	' wait for hdr + ID
high portb.1					' deactivate reader
pause 500
 
Check_List:
  FOR tagNum = 1 to 2				' scan through known tags
    FOR idx = 0 TO 11				' scan bytes in tag
    READ (((tagNum-1) * 12) + idx), char	' get tag data from table
    IF (char <> buf(idx)) THEN Bad_Char		' compare tag to table
    NEXT
    GOTO Tag_Found				  ' all bytes match!

Bad_Char:					      ' try next tag
  NEXT

Bad_Tag:
  tagNum = 0
  high porta.3
  pause 200
  low porta.3
  pause 200
  lcdout $FE, 1," bad tag"
  pause 500
  FREQOUT porta.3, 1000 */ $100, 115 */ $100	' groan
  PAUSE 1000
  lcdout $FE,1
  GOTO Main

Tag_Found:

IF tagNum = 1 then displayName1

IF tagNum = 2 then displayName2

GOTO Main

displayName1:
lcdout $FE, 1,"ASTANAPANE"    'assuming your display is on porta.0 @ 9600 baud
pause 500                                      'Pause ,5 sec then clear display
goto open_door

displayName2:
lcdout $FE, 1,"TIGRI"   	'assuming your display is on porta.0 @ 9600 baud
pause 500                                       'Pause ,5 sec then clear display
goto open_door

open_door:
  HIGH portb.2					' remove latch
  High portb.3					' Light LED
  FREQOUT portb.3, 2000 */ $100, 880 */$100	' beep
  LOW portb.2					' restore latch
  Low portb.3					' LED OFF
  GOTO Main