RFID circit

madguernseyboy

New Member
Hi all

I am just beginning in learning RFID and built this circit


now i dont understand whats wrong but i understand the RFID chip is sending a string of ASCII CMOS out each time i scan.

when i receive the data back to the terminal each time it is slightly different.
Example
137140109711116522574252
13615389610716323166252
137140109711116522566252
1371401010110716222766252
1361531011710716323166252

therefore the somewhere the data is unstable i guess????


Code:
setfreq m8
poke $90, 1

main:
serin 3,N2400,b0,b1,b2,b3,b4,b5,b6,b7,b8
'Stop, sit here and wait for RFID serial data

serout 0,N2400,(#b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7,#b8,10,13)
'Transmit the serial back to the pc

goto main

Can anyone shed some light on my problem? thank you
 
Last edited:

hippy

Ex-Staff (retired)
Staff member
It does look like the SERIN is dropping, missing or corrupting characters. That could simply be because the PICAXE is not running fast enough to keep up with the data sent. That can often be overcome by increasing the speed, as you have done, but going beyond M8.

The baud rate appears to be 4800 so you could try -

Code:
[color=Navy]#Picaxe [/color][color=Black]08M2[/color]
[color=Navy]#Terminal 4800[/color]
[color=Blue]SetFreq M32
Do
  SerIn [/color][color=Navy]3[/color][color=Black], [/color][color=Blue]N4800_32[/color][color=Black], [/color][color=Purple]b0[/color][color=Black],[/color][color=Purple]b1[/color][color=Black],[/color][color=Purple]b2[/color][color=Black],[/color][color=Purple]b3[/color][color=Black],[/color][color=Purple]b4[/color][color=Black],[/color][color=Purple]b5[/color][color=Black],[/color][color=Purple]b6[/color][color=Black],[/color][color=Purple]b7[/color][color=Black],[/color][color=Purple]b8
  [/color][color=Blue]SerOut [/color][color=Navy]0[/color][color=Black], [/color][color=Blue]N4800_32[/color][color=Black], [/color][color=Blue]( [/color][color=Black]#[/color][color=Purple]b0[/color][color=Black],#[/color][color=Purple]b1[/color][color=Black],#[/color][color=Purple]b2[/color][color=Black],#[/color][color=Purple]b3[/color][color=Black],#[/color][color=Purple]b4[/color][color=Black],#[/color][color=Purple]b5[/color][color=Black],#[/color][color=Purple]b6[/color][color=Black],#[/color][color=Purple]b7[/color][color=Black],#[/color][color=Purple]b8[/color][color=Black],[/color][color=Blue]CR[/color][color=Black],[/color][color=Blue]LF )
Loop[/color]
Perhaps post a link to the RFID reader datasheet as that may suggest alternative solutions.
 

madguernseyboy

New Member
hey thanks for the help
but its still giving me the same issue

20969812121886921212551
21669812121886921212551
20969812122526921411251
21769812122526921212551
 

hippy

Ex-Staff (retired)
Staff member
It seems more consistent but still corrupting data. Perhaps an M2 just isn't fast enough and you may need to go to an X2 and use background receive.

The other option would be to see if there is a checksum in what is sent so you can at least tell if you have valid or invalid data, can reject data which is not correct. If the results are mostly incorrect that would probably just be frustrating rather than a good solution.

A datasheet link or at least details of the RFID type, model, manufacturer or where purchased form would probably help.
 

Goeytex

Senior Member
With the Picaxe set for M32, I suspect that the serial data format should be T9600_32. I do not see anything in the data sheet indicating that the serial data should be inverted.

An M2 should be more than capable of receiving consecutive back-to-back bytes of serial data at T9600_32.

EDIT: On page 6 of the datasheet it indicates inverted serial data on pin 9. It also indicates a 4K7 pullup is required on this pin.
Pin 8 should then be non-inverted serial data. So it seems you have a choice.
 
Last edited:

madguernseyboy

New Member
hippy, Buzby and Goeytex
thank you very much it now works fine

the final code was
Code:
#Picaxe 08M2
SetFreq M32
Do
  SerIn 3, T9600_32, b0,b1,b2,b3,b4,b5,b6,b7,b8
  SerTxd( #b0,#b1,#b2,#b3,#b4,#b5,#b6,#b7,#b8,CR,LF )
Loop
and i had to set the terminal to 38400
to be honest I don't understand why the terminal must be at a higher baud. can someone direct me to a page where i can learn more on the subject?

I will upload my final schematic later for others to learn from

Again thanks
Brendan
 

hippy

Ex-Staff (retired)
Staff member
Glad you got things resolved.

As Goeytex says the SERTXD baud rate is fixed ( 4800 at 4MHz ) and will correspondingly increase as you increase operating speed, and there's no option to change that -- though you can drop the speed down before outputting and increase it again after.

M4 = 4800 baud
M8 = 9600
M16 = 19200
M32 = 38400
M64 = 76800
 

colinsmurph

New Member

madguernseyboy

New Member
Hi all for those looking for info on this project
this was the final schematic and Board with the code I used.
Thanks again to everyone that helped




Code:
#Picaxe 08M2
#Terminal 9600
SetFreq M32

symbol RFID	= C.3	
symbol LED	= C.2	
symbol BUTT	= pin1	
symbol SERV	= C.4	

SYMBOL tagNum = B9 ' from EEPROM table
SYMBOL pntr = B10 ' pointer to character in table
SYMBOL character = b11

'Numbers listed in EEprom data are for the cards I used, yours will be different
' -----[ EEPROM Data ]---------------------------------
eeprom 0,  (63,153,47,230,230,151,151,95,100)	' Tag 0
eeprom 10,(63,101,99,230,102,166,204,153,93)	' Tag 1
eeprom 20,(63,101,99,230,102,166,204,51,100)	' Tag 2


main:
goto CheckReader
goto main




CheckReader:

SerIn RFID, T9600_32, b0,b1,b2,b3,b4,b5,b6,b7,b8
‘ use this line to discover the RFID TAG No
'SerTxd( #b0,",",#b1,",",#b2,",",#b3,",",#b4,",",#b5,",",#b6,",",#b7,",",#b8,CR,LF )

    Check_List:

    FOR tagNum = 0 TO 2 ' scan through known tags saved in EEPROM
 
    pntr = tagNum * 10 + 0 : READ pntr, character ' Read character from EEPROM
    IF character <> b0 THEN Bad_Char ' Compare tag data with character from EEPROM one at a time
    pntr = tagNum * 10 + 1 : READ pntr, character
    IF character <> b1 THEN Bad_Char
    pntr = tagNum * 10 + 2 : READ pntr, character
    IF character <> b2 THEN Bad_Char
    pntr = tagNum * 10 + 3 : READ pntr, character
    IF character <> b3 THEN Bad_Char
    pntr = tagNum * 10 + 4 : READ pntr, character
    IF character <> b4 THEN Bad_Char
    pntr = tagNum * 10 + 5 : READ pntr, character
    IF character <> b5 THEN Bad_Char
    pntr = tagNum * 10 + 6 : READ pntr, character
    IF character <> b6 THEN Bad_Char
    pntr = tagNum * 10 + 7 : READ pntr, character
    IF character <> b7 THEN Bad_Char
    pntr = tagNum * 10 + 8 : READ pntr, character
    IF character <> b8 THEN Bad_Tag
    
    GOTO Tag_Found ' all characters matched EEPROM Data, valid tag found


    Bad_Char:
       sertxd  ("Tag does not match, checking next saved card",CR,LF)
       NEXT


    Bad_Tag:
	sertxd  ("TAG NOT FOUND",CR,LF)
	goto main

    
    
    
    Tag_Found:
    'These are simple if-then commands to action when a valid card is found

    if tagNum=0 then
    gosub servoopen
    end if

    if tagNum=1 then
    gosub servoopen
    end if

    if tagNum=2 then
    gosub servoopen
    end if

    goto main
    
    servoopen:
    for b18 = 0 to 5
    	high LED 
    	pause 500
    	low LED
    	pause 500
    NEXT
&#8216; ADD CODE HERE FOR MOVING SERVO
    return
 
Top