RFID trouble
Erlend
Posts: 612
It is the first time I am using the Parallax RFID reader. Hooked it up and ran RFID_demo by Gavin Garner, only changed from lcd to pst debug.
At power on, the green light comes on, then as the code starts running the light gets red. There it stops. I've tried both the cards and the buttons that came with it, but no reaction. From debug points it appears that the 'start' signal from the RFID does not come i.e. Sout never goes low. It looks like a hardware failure, but I just now unwrapped the RFID - its brand new. Yes, I have checked the pin & wiring.
the last debug text is "Reader enabled--"
At power on, the green light comes on, then as the code starts running the light gets red. There it stops. I've tried both the cards and the buttons that came with it, but no reaction. From debug points it appears that the 'start' signal from the RFID does not come i.e. Sout never goes low. It looks like a hardware failure, but I just now unwrapped the RFID - its brand new. Yes, I have checked the pin & wiring.
CON
_xinfreq=5_000_000
_clkmode=xtal1+pll16x '80MHz system clock is recommended for stable data transfer
RFID=22 'Propeller pin connected to RFID's "SOUT" pin (through a 1k resistor)
RFID_EN=23 'Propeller pin connected to RFID's "/ENABLE" pin
OBJ
Debug : "Parallax Serial Terminal"
VAR
byte i,RFIDdata[12] 'The RFIDdata array stores ID byte codes read from the RFID
PUB Main
Debug.start(19200) 'Initialize the Debug_Lcd object
Debug.str(string("Starting test..."))
repeat
ReadRFID 'This method gets the RFID tag's data from the scanner
DisplayRFID 'This method displays the RFID tag's data on the LCD screen
if CheckRFID 'If the return value from the CheckRFID method is one, then the
Debug.str(string("Access Granted!")) ' tag's ID matched one of the preprogrammed codes
else 'If the return value from the CheckRFID method is zero, then the
Debug.str(string("Access Denied!")) ' tag's ID did not match any of the preprogrammed codes
PUB ReadRFID | bit,time,deltaT
Debug.str(string("Reading..."))
dira[RFID]~ 'Set direction of RFID to be an input
dira[RFID_EN]~~ 'Set direction of RFID_EN to be an output
deltaT:=clkfreq/2400 'Set deltaT to 1/2400th of a second for 2400bps "Baud" rate
outa[RFID_EN]~ 'Enable the RFID reader
Debug.str(string("Reader enabled..."))
repeat i from 0 to 11 'Fill in the 12 byte arrays with data sent from RFID reader
waitpeq(1 << RFID,|< RFID,0) 'Wait for a high-to-low signal on RFID's SOUT pin, which
waitpeq(0 << RFID,|< RFID,0) ' signals the start of the transfer of each packet of 10 data bits
Debug.str(string("Sout start received..."))
time:=cnt 'Record the counter value at start of each transmission packet
waitcnt(time+=deltaT+deltaT/2) 'Skip the start bit (always zero) and center on the 2nd bit
repeat 8 'Gather 8 bits for each byte of RFID's data
RFIDdata[i]:=RFIDdata[i]<<1 + ina[RFID] 'Shift RFIDdata bits left and add current bit (state of RFID pin)
waitcnt(time+=deltaT) 'Pause for 1/2400th of a second (2400 bits per second)
RFIDdata[i]><=8 'Reverse the order of the bits (RFID scanner sends LSB first)
outa[RFID_EN]~~ 'Disable the RFID reader
PUB DisplayRFID
Debug.str(string("Displaying..."))
if RFIDdata[0]<>10 or RFIDdata[11]<>13 'All cards should have the same start byte and end byte
Debug.str(string("Error! Try Again."))
ReadRFID 'Try running the "ReadRFID" method again
else
repeat i from 1 to 10 'Display each of the 10 unique identification bytes
Debug.dec(RFIDdata[i])
Debug.str(string(" "))
PUB CheckRFID
repeat i from 0 to 9 'Compare tag's 10 unique ID #s against ID #s stored in data table
if RFIDdata[i+1]<>Tag1[i] and RFIDdata[i+1]<>Tag2[i] and RFIDdata[i+1]<>Tag3[i]
if RFIDdata[i+1]<>Tag4[i] and RFIDdata[i+1]<>Tag5[i] and RFIDdata[i+1]<>Tag6[i] 'etc.
return 0 'If one of the IDs does not match, return a zero
return 1 'If one of the ID sequences matched, return a one
DAT
'i= 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Tag1 byte 48,70,48,51,48,50,56,53,55,53 '<-- Enter your own RFID tag ID numbers here
Tag2 byte 48,70,48,50,65,54,55,48,69,48
Tag3 byte 48,52,49,54,50,66,66,53,55,54
Tag4 byte 48,70,48,50,65,54,55,50,51,66
Tag5 byte 48,70,48,50,65,54,55,50,51,66
Tag6 byte 48,52,49,54,50,66,66,53,53,54
the last debug text is "Reader enabled--"

Comments
You might remove the 'Debug.str(string("Sout start received..."))' in that it will upset the receive timing
So many times I have missed having a scope, I think it's time to open my wallet.
DAT 'i= 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Tag1 byte 48,70,48,51,48,50,56,53,55,53 '<-- Enter your own RFID tag ID numbers here Tag2 byte 48,70,48,50,65,54,55,48,69,48 Tag3 byte 48,52,49,54,50,66,66,53,55,54 Tag4 byte 48,70,48,50,65,54,55,50,51,66 Tag5 byte 48,70,48,50,65,54,55,50,51,66 Tag6 byte 48,52,49,54,50,66,66,53,53,54EDIT: sorry about that, I see your having a different problem with the reader.
Maybe try to remove all the debug strings from PUB readRFID...
-Tommy
-well that's a catch 22 - I need to run the reader to find out the number of the cards - which it should do regardless of if it matches DAT or not.
What changes did you make to the original code? Just the debug statements?
Comment out those, and see what happens.
-Tommy
Erlend