Shop OBEX P1 Docs P2 Docs Learn Events
RFID Tag Problems — Parallax Forums

RFID Tag Problems

I have been testing a basic program where I present a RFID tag and it displays the ID number. For most RFID tags it works as expected. But I have one set of tags that works a few times but then causes it to crash when presenting the tag. I have tested the set on a windows based reader and it works fine every time.

Comments

  • karlprescott,

    Is this a Parallax reader and are you using Parallax tags?
    Are the working and failing tags that same part number?

    Also, post your code.
  • I’m using the parallax rfid reader serial. The tags are some I have purchased from eBay. They are all passive tags.
  • karlprescottkarlprescott Posts: 15
    edited 2018-08-28 14:39
    Code
    con
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
    
      CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq
      MS_001   = CLK_FREQ / 1_000
    
    
    con
    
      TX_PIN        = 0                                   'Display Port
      BAUD          = 19_200
    
      RFID_RX = 17                                                  ' RFID on PAB
      RFID_EN = 16
    
      servoPin = 10                              ' Servo signal to this I/O pin-change if needed  
    
    
    con 
    
      #1, HOME, GOTOXY, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR, #14, GOTOX, GOTOY, #16, CLS      ' PST formmatting control
      
      LAST_TAG = 3                                                  ' tag #s are 0..LAST_TAG    
       
    obj
    
      term : "FullDuplexSerial.spin" 
    
      rfid : "FullDuplexSerialPlus.spin" 
    
    
    var
    
      byte  teststr[32]                                             ' string buffer
    
      byte  tagbuf[10]                                              ' tag buffer  
    
    pub main | idx, b
    
      setup                                                         ' start program objects
      
      'term.start(TX_PIN, TX_PIN, %1000, BAUD)   ' start LCD terminal
      'rfid.start(RFID_RX, RFID_RX, %1100, 2400)             ' open-drain serial for RFID
      
      repeat 
    
        term.str(string(12," Wait Ball:", CR))
    
        accept_tag(@tagbuf)                                         ' wait for tag
    
        term.str(string(12," ID "))
        term.str(@tagbuf)
     
        term.tx(CR)  
        
        pause(3000)
    
    
    PUB CenterServo(n) | tInc, tc, tHa, t, c
    
    ctra[30..26] := %00100                    ' Configure Counter A to NCO
    ctra[8..0]   := servoPin
    
    frqa := n
    dira[servoPin]~~
    
    ' Set up cycle and high times
    tInc := clkfreq/1_000_000
    tC   := tInc * 21_500
    tHa  := tInc * 1500
    
    t    := cnt                               ' Mark counter time
    
    repeat c from 1 to 100                    ' Repeat PWM signal
      phsa := -tHa                            ' Set up the pulse
      t += tC                                 ' Calculate next cycle repeat
      waitcnt(t)                              ' Wait for next cycle
    
    
    pub setup
    
    '' Setup IO and objects for application
    
      term.start(TX_PIN, TX_PIN, %1000, BAUD)   ' start LCD terminal           
      term.tx(17)             'Turn Display Light on
                       
      rfid.start(RFID_RX, RFID_RX, %1100, 2400)             ' open-drain serial for RFID                         
    
    
    pub accept_tag(p_buf) | c, idx
    
    '' Enables RFID reader for ms milliseconds
    '' -- reads tag bytes (if available) into p_buf
    
      bytefill(p_buf, 0, 10)                                        ' clear old data
    
      rfid.rxflush                                                  ' clear rx buffer
      
      low(RFID_EN)                                                  ' enable reader
    
      repeat
        c := rfid.rx
      until (c == $0A)                                              ' wait for $0A (LF)
    
      repeat 10                                                     ' rx 10 tag bytes
        byte[p_buf++] := rfid.rx
    
      input(RFID_EN)                                                ' disable reader
      
    
    pub get_tag_id(p_buf) | tidx, p_check, bidx
    
    '' Compares tag data in ram (at p_buf) with known tags
    '' -- returns tag index (0..LAST_TAG) if found
    '' -- returns -1 if tag not found
    
      repeat tidx from 0 to LAST_TAG                                ' loop through known tags
        p_check := @@Tags[tidx]                                     ' get hub address of tag being tested
        repeat bidx from 0 to 9                                     ' loop through bytes in tag
          if (byte[p_buf][bidx] <> byte[p_check][bidx])             ' if byte mismatch
            quit                                                    ' abort this tag
        if (bidx == 10)                                             ' if all bytes matched
          return tidx                                               ' return this tag id
          
      return -1                                                     ' return not found
    
         
    pub pause(ms) | t
    
      t := cnt - 1088                                               ' sync with system counter
      repeat (ms #> 0)
        waitcnt(t += MS_001)                                        ' delay 1ms (syncronized)
    
        
    pub high(pin)
    
    '' Makes pin output and high
    
      outa[pin] := 1
      dira[pin] := 1
    
    
    pub low(pin)
    
    '' Makes pin output and low
    
      outa[pin] := 0
      dira[pin] := 1
    
    
    pub toggle(pin)
    
    '' Toggles pin state
    
      !outa[pin]
      dira[pin] := 1
    
    
    pub input(pin)
    
    '' Makes pin input and returns current state
    
      dira[pin] := 0
    
      return ina[pin]
      
    
    dat { tags data }
    
      Tag0        byte      "7A00219388"
      Tag1        byte      "7A00216BC1"
      Tag2        byte      "7A00216CAE"
      Tag3        byte      "7A0021A6E3"          
    
      Tags        word      @Tag0, @Tag1, @Tag2, @Tag3
    
    
      Name0       byte      "PINK", 0
      Name1       byte      "ORANGE", 0
      Name2       byte      "BLUE", 0
      Name3       byte      "YELLOW", 0
    
      Names       word      @Name0, @Name1, @Name2, @Name3        
    
    



    ModEdit: Code tags added.
  • The black tags cause problems after a few scans. The keyring one works everytime
    2016 x 1512 - 635K
  • Huh. A lot of that code looks suspiciously like... mine! Anyway, I've updated the way that I handle tags; instead of character-by-character comparison, I store the tags as proper strings and use strcomp. Updated demo is attached. See you you fare with it.
  • Karl,
    Post your code between code tags see "C" in posting header... B I U C etc.
    Jim
  • karlprescott,

    Parallax makes high quality products that are rarely faulty but you never know what you will get from ebay.
    Did the seller claim all the tags were from Parallax?
  • Jonny Mac. Some code is your samples you posted. They helped me lots when I was working on a smart card project.

    Aren’t tags just tags? Can you not use any rfid tag with a parallax reader?
  • JonnyMacJonnyMac Posts: 8,912
    edited 2018-09-01 16:27
    Aren’t tags just tags? Can you not use any rfid tag with a parallax reader?
    No.
    My employer rents a loft in an upscale apartment complex for us to work off-site. It uses RFID keys -- and we only have one. We looked them up and they are listed as 125kHz -- the same as the Parallax reader. Still, we couldn't read the key because there is a secondary protection scheme embedded in it. We had to take the social engineering route to get spares without incurring the $150 per-key charge.



Sign In or Register to comment.