Shop OBEX P1 Docs P2 Docs Learn Events
RFID Reader and RFID Reader/Writer Help Needed — Parallax Forums

RFID Reader and RFID Reader/Writer Help Needed

NWCCTVNWCCTV Posts: 3,629
edited 2015-05-31 13:08 in Propeller 1
I am not sure what I am doing wrong but it must be something. I have tried ALL of the various RFID Objects in the OBEX and I can not get any of them to work. I have a Parallax RFID Reader-Serial and a Parallax RFID Reader/Writer-Serial. I have verified that they both work using my trusty old BS2 BOE Board. I am using a Parallax Pro. Development Board to connect to. I tried Jonnymac's Demo code from the OBEX and placed 3.3K resistors between pins 16 and 17 and I still get nothing. One thing I do see is that on my Stamp BOE Board, the LED is Red when I first apply power and on the Prop Board the LED is Green. Does anyone have any suggestions?

Comments

  • kwinnkwinn Posts: 8,697
    edited 2015-05-31 08:42
    The led on the reader is green when the power is on and the /enable signal is high. This is the idle state. The /enable signal must be pulled low to read a card/tag. That will cause the led to change to red.
  • asimoasimo Posts: 1
    edited 2015-05-31 10:17
    hello ,

    I found the same problem with the RFID RW serial 28440, try this code it works fine for me
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-05-31 11:13
    OK, So that works for the RFID RW Module. However, I really need to figure something out for the Read Module.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-05-31 11:58
    So I was able to get Jonnymac's code going by using just a 10K resistor on SOUT only on my RFID Reader. Now, I am trying to blink an LED if the Tag ID matches. Attached is my code but it does not work. It will run but the LED does not blink. I have added this code:
    if tidx ==   Tag1
       dira[2] := 1
       repeat
         outa[2] := 1
         waitcnt(clkfreq / 2 + cnt)
         outa[2] := 0
         waitcnt(clkfreq / 2 + cnt)
    
    '' =================================================================================================
    ''
    ''   File....... jm_rfid_demo.spin
    ''   Purpose.... Parallax Serial RFID Reader demo for the Propeller Activity Board. 
    ''               Use pins 16 and 17 as they have 3.9K resistors inline to prevent too much current 
    ''               into the pins from the 5V RFID device. Make sure that the header power jumpers are 
    ''               set to 5V (default), and to move the power switch to position 2 to power the headers. 
    ''   Author..... Jon "JonnyMac" McPhalen
    ''               Copyright (c) 2014 Jon McPhalen
    ''               -- see below for terms of use
    ''   E-mail..... jon@jonmcphalen.com
    ''   Started.... 23 SEP 2014
    ''   Updated.... 03 OCT 2014
    ''
    '' =================================================================================================
    
    
    con { timing }
    
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000                                          ' use 5MHz crystal
    
      CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq               ' system freq as a constant
      MS_001   = CLK_FREQ / 1_000                                   ' ticks in 1ms
      US_001   = CLK_FREQ / 1_000_000                               ' ticks in 1us
    
    
    con { io pins }
    
      RX1     = 31                                                  ' programming / terminal
      TX1     = 30
      
      SDA     = 29                                                  ' eeprom / i2c
      SCL     = 28
    
      RFID_RX = 1                                                  ' RFID on PAB
      RFID_EN = 0
      
    
    con
    
      #0, LSBFIRST, MSBFIRST
      
    
    con { pst formatting }
    
       #1, HOME, GOTOXY, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR
      #14, GOTOX, GOTOY, CLS
    
    
    obj
    
      term : "fullduplexserial" 
      rfid : "fullduplexserial"
      pins  : "Input Output Pins"
      time : "Timing"
    
    var
              
    
    pub main | idx
    
      setup                                                         ' start program objects
    
    
      repeat 
        repeat 2
          term.tx(CR)
        term.str(string("Present tag:", CR))
        
        accept_tag(@tagbuf)                                         ' wait for tag
        
        term.str(string("-- "))                                     ' display tag string
        repeat idx from 0 to 9
          term.tx(byte[@tagbuf][idx])
        term.tx(CR)
        
        idx := get_tag_id(@tagbuf)                                  ' lookup tag
        
        if (idx => 0)                                               ' display name for tag
          term.str(string("-- "))
          term.str(@@Names[idx])
        else
          term.str(string("-- Unknown tag"))
    
        pause(3000) 
        
    
        
    pub setup
    
    '' Setup IO and objects for application
    
      term.start(RX1, TX1, %0000, 115_200)                  ' terminal via programming port                 
      rfid.start(RFID_RX, RFID_RX, %1100, 2400)             ' open-drain serial for RFID                         
    
    
    con
    
      { --------- }
      {  R F I D  }
      { --------- }
    
    
    con
    
      LAST_TAG = 3                                                  ' tag #s are 0..LAST_TAG
      
    
    var
    
      byte  tagbuf[10]                                              ' tag buffer
      
    
    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
    
     
     if tidx ==   Tag1
       dira[2] := 1
       repeat
         outa[2] := 1
         waitcnt(clkfreq / 2 + cnt)
         outa[2] := 0
         waitcnt(clkfreq / 2 + cnt)
    
      
    dat { tags data }
    
      Tag0        byte      "05000038D4"
      Tag1        byte      "05009B3955"
      Tag2        byte      "05000038D4"
      Tag3        byte      "05009A8B3B"          
    
      Tags        word      @Tag0, @Tag1, @Tag2, @Tag3
    
    
      Name0       byte      "Luke Skywalker", 0
      Name1       byte      "Princess Leia", 0
      Name2       byte      "Luke Skywalker", 0
      Name3       byte      "Obi Wan Kenobi", 0
    
      Names       word      @Name0, @Name1, @Name2, @Name3        
    
    
    con
    
      { ------------- }
      {  B A S I C S  }
      { ------------- }
    
    
    pub pause(ms) | t
    
    '' Delay program in milliseconds
    
      if (ms < 1)                                                   ' delay must be > 0
        return
      else
        t := cnt - 1776                                             ' sync with system counter
        repeat ms                                                   ' run delay
          waitcnt(t += MS_001)
        
    
    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 { license }
    
    {{
    
      Terms of Use: MIT License
    
      Permission is hereby granted, free of charge, to any person obtaining a copy of this
      software and associated documentation files (the "Software"), to deal in the Software
      without restriction, including without limitation the rights to use, copy, modify,
      merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
      permit persons to whom the Software is furnished to do so, subject to the following
      conditions:
    
      The above copyright notice and this permission notice shall be included in all copies
      or substantial portions of the Software.
    
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
      INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
      PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
      HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
      CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
      OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
    }}
    
  • JonnyMacJonnyMac Posts: 9,105
    edited 2015-05-31 11:59
    That's old code. See my June column in Nuts & Volts for my latest adventures with the Parallax RFID reader.

    Edit: Code is attached so you don't have to track it down on the N&V web site.
  • kwinnkwinn Posts: 8,697
    edited 2015-05-31 12:06
    Set the pin connected to the /enable pin low, have one of the serial objects wait for input from a scanned card, then output the data to pst or something similar. If you have a serial to usb cable or prop plug you could tie the /enable signal low and send the serial data directly to the pc. It should read the card when it is held near the reader.

    I'm working on an access system using the four port serial object and the serial reader but ran into a problem. The cards I wanted to use do not seem to work with these readers so I have no way to test until the tags and card I am about to order get here.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-05-31 12:11
    @kwinn, I got the reading part figured out. Now I just want to light an LED!!!!
  • ErlendErlend Posts: 612
    edited 2015-05-31 13:04
    NWCCTV wrote: »
    @kwinn, I got the reading part figured out. Now I just want to light an LED!!!!

    -and do not forget, the reader likes 5v, not 3.3 (that was my blunder some time ago)

    Erlend
  • NWCCTVNWCCTV Posts: 3,629
    edited 2015-05-31 13:08
    Yes, I am running it @ 5V.
Sign In or Register to comment.