Shop OBEX P1 Docs P2 Docs Learn Events
Another RFID Question — Parallax Forums

Another RFID Question

NWCCTVNWCCTV Posts: 3,629
edited 2013-03-16 09:18 in Propeller 1
Is there just a simple OBEX demo that will display the results of the RFID tag reading in a Serial Terminal instead of using either VGA or LCD?

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2013-03-13 09:18
    I haven't seen the LCD example, but it would seem to be easily reconfigured for the PST since both use a serial interface.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-14 13:47
    Does this look like it will work?
    CON
      _xinfreq=5_000_000
      _clkmode=xtal1+pll16x                            '80MHz system clock is recommended for stable data transfer
      LCD_pin=0                                        'Propeller pin connected to LCD's "RX" pin
      RFID=1                                           'Propeller pin connected to RFID's "SOUT" pin (through a 1k resistor)
      RFID_EN=2                                        'Propeller pin connected to RFID's "/ENABLE" pin
                                                            
    OBJ
      ser : "FullDuplexSerial" 
    VAR
      byte i,RFIDdata[12]                              'The RFIDdata array stores ID byte codes read from the RFID
     
    PUB Main
      ser.start(31,30,0,19200)                        'wait for any input from terminal ser.rx
    "Debug.init(LCD_pin,19200,4)                      'Initialize the Debug_Lcd object  "
     " Debug.cursor(0)                                  'Make the cursor invisible"
     " Debug.backlight(true)                            'Turn on the backlight  "
      repeat
        ReadRFID                                       'This method gets the RFID tag's data from the scanner
        ser.str(string(DisplayRFID))                                    'This method displays the RFID tag's data on the LCD screen
        "Debug.gotoxy(0,3)                              'Set the LCD screen's cursor to start of the bottom line"
        if CheckRFID                                   'If the return value from the CheckRFID method is one, then the
          ser.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   
          ser.str(string("Access Denied!"))          ' tag's ID did not match any of the preprogrammed codes                
                                                       
    PUB ReadRFID | bit,time,deltaT                                                                                    
      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
      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
        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
      ser.cls                                        'Clear the Serial screen                                     
      if RFIDdata[0]<>10 or RFIDdata[11]<>13           'All cards should have the same start byte and end byte   
          ser.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             
          ser.dec(RFIDdata[i])                                                                      
          ser.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
    'etc.
    
    
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-15 17:49
    Moderators, Can you please move this to the Propeller 1 Forum? Getting no response here.
  • TtailspinTtailspin Posts: 1,326
    edited 2013-03-16 07:29
    This one uses the Serial Terminal...
  • TtailspinTtailspin Posts: 1,326
    edited 2013-03-16 07:34
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-03-16 09:18
    Great. Thanks for the help everyone.
Sign In or Register to comment.