Shop OBEX P1 Docs P2 Docs Learn Events
RFID trouble — Parallax Forums

RFID trouble

ErlendErlend Posts: 612
edited 2013-01-21 11:44 in Propeller 1
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.
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

  • Mike GreenMike Green Posts: 23,101
    edited 2013-01-20 10:17
    Do you have the 1K resistor between the Propeller I/O pin and the RFID Reader's SOUT pin?

    You might remove the 'Debug.str(string("Sout start received..."))' in that it will upset the receive timing
  • ErlendErlend Posts: 612
    edited 2013-01-20 23:43
    Yes, I have a 1k to the Sout. Removing Debug.str(string("Sout start received...") didn't help either. I'm wondering, shouldn't the RFID change from red to green as long as it has power, and 'enable' is high. I doesn't need to wait for Propeller to act, I am guessing.
    So many times I have missed having a scope, I think it's time to open my wallet.
  • TtailspinTtailspin Posts: 1,326
    edited 2013-01-21 06:56
    you have to change, or add, the new card numbers into the DAT section,
    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
    

    EDIT: 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
  • ErlendErlend Posts: 612
    edited 2013-01-21 07:16
    Ttailspin wrote: »
    you have to change, or add, the new card numbers into the DAT section,
    -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.
  • TtailspinTtailspin Posts: 1,326
    edited 2013-01-21 07:22
    Sorry about that Erlend, I had not finished my coffee before I spouted off...:)

    What changes did you make to the original code? Just the debug statements?
    Comment out those, and see what happens.


    -Tommy
  • ErlendErlend Posts: 612
    edited 2013-01-21 11:44
    Don't worry - coffee is like bios - no booting without it. Besides, I've been stupid and spoiled by all the bits that can take 3.3v or 5v or whatever. Well, the RFID cannot. I had connected the Vcc jumper to 3.3V instead of 5V. Bummer. Now I am greeted with "Access granted"!

    Erlend
Sign In or Register to comment.