Shop OBEX P1 Docs P2 Docs Learn Events
security system using RFID — Parallax Forums

security system using RFID

navychiefnavychief Posts: 40
edited 2011-04-03 18:59 in General Discussion
I found the attached code from one of the forums and planning to apply it; however it won't activate the RFID to read tags. My tag serial number is 0133C2DD. Help please....
«1

Comments

  • FranklinFranklin Posts: 4,747
    edited 2011-04-03 11:13
    So, when you "LOW Enable" it does not activate the reader? Check your wiring and add a few debug statements to see where the program fails.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 12:41
    I connected RFID pin (Sin) to P0 and (Sout) to P1. Is it correct? Thank you. I'll check the debug.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 12:47
    I just did the debug and it seems like the program won't pass this command
    SERIN RX, T2400, [WAIT($0A), STR buf\10] ' wait for hdr + ID
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-04-03 14:04
    My tag serial number is 0133C2DD

    There is something wrong there , the tag number should be a 10 character string.

    Jeff T.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 14:12
    I used this code to get the tag number. Could you please take a look if I did it right? Thank you.


    '
    [ I/O Definitions ]

    RFID_TX PIN 0 ' Connects to RFID R/W Module SIN
    RFID_RX PIN 1 ' Connects to RFID R/W Module SOUT


    '
    [ Constants ]

    #SELECT $STAMP
    #CASE BS2
    T9600 CON 84
    #ENDSELECT

    Baud CON T9600

    ' RFID R/W Module Commands
    ' Number of bytes returned in ()
    RFID_Read CON $01 ' Read data from specified address, valid locations 1 to 33 (5)
    RFID_Write CON $02 ' Write data to specified address, valid locations 3 to 31 (1)
    RFID_Login CON $03 ' Login to tag with password (1)
    RFID_SetPass CON $04 ' Change tag's password from old to new (1)
    RFID_Protect CON $05 ' Enable/disable password protection (1)
    RFID_Reset CON $06 ' Reset tag (1)
    RFID_ReadLegacy CON $0F ' Read unique ID from EM4102 read-only tag (for backwards compatibility with Parallax RFID Card Reader, #28140 and #28340) (12)

    ' Memory map/address locations for EM4x50 tag
    ' Each address holds/returns a 32-bit (4 byte) value
    ' ADDR 3-31 are User EEPROM area
    ADDR_Serial CON 32 ' Device Serial Number
    ADDR_DeviceID CON 33 ' Device Identification

    ' Status/error return codes
    ERR_OK CON $01 ' No errors
    ERR_LIW CON $02 ' Did not find a listen window
    ERR_NAK CON $03 ' Received a NAK, could be invalid command
    ERR_NAK_OLDPW CON $04 ' Received a NAK sending old password (RFID_SetPass), could be incorrect password
    ERR_NAK_NEWPW CON $05 ' Received a NAK sending new password (RFID_SetPass)
    ERR_LIW_NEWPW CON $06 ' Did not find a listen window after sending old password (RFID_SetPass)
    ERR_PARITY CON $07 ' Parity error when reading data


    '
    [ Variables ]

    buf VAR BYTE(12) ' data buffer

    idx VAR BYTE ' index
    idy VAR BYTE
    counter VAR WORD

    '
    [ EEPROM Data ]


    '
    [ Initialization ]

    Initialize:
    PAUSE 250 ' let DEBUG open
    DEBUG CLS ' clear the screen
    DEBUG "Parallax RFID Read/Write Module Test Application", CR,
    "
    ", CR, CR

    '
    [ Program Code ]

    Main:
    DEBUG "Reading tag's unique serial number..."
    Read_Tag:
    SEROUT RFID_TX, Baud, ["!RW", RFID_Read, ADDR_Serial] ' Read tag's serial number
    SERIN RFID_RX, Baud, [STR buf\5] ' Get status byte and data bytes
    IF buf(0) <> ERR_OK THEN Read_Tag ' If we get an error, keep trying until the read is successful
    FOR idx = 1 TO 4 ' Print data
    DEBUG HEX2 buf(idx)
    NEXT
    DEBUG CR
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 14:28
    Are you using 28140 or 28440 ?
  • navychiefnavychief Posts: 40
    edited 2011-04-03 14:37
    I'm using 28440 reader. Thank you for checking my post.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-04-03 14:48
    Try this and see if you can retrieve the number
    buf VAR Byte(10)
    x VAR Nib
    
    main:
    
    LOW 0
    
    FOR x=0 TO 9
    buf(x)="-"
    NEXT
    
    SERIN 1,396,[WAIT($0A), STR buf\10]
    
    DEBUG STR buf\10,CR
    
    PAUSE 500
    
    GOTO main
    

    Jeff T.

    EDIT forget the above and excuse me for jumping to conclusions . The above deals with a different reader.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 14:48
    Then you should be using the sample/source code for that unit --
    http://www.parallax.com/Portals/0/Downloads/docs/prod/rf/28440-RFID-RW-BS2code.zip
  • navychiefnavychief Posts: 40
    edited 2011-04-03 14:59
    The RFID reader remains inactive green indication. Tell me, connecting Sin pin to P0 is the proper way. I might have wrong wiring here. Thank you
  • navychiefnavychief Posts: 40
    edited 2011-04-03 15:52
    This is what I got using the File...... rfid_rw_test.bs2:

    Parallax RFID Read/Write Module Test Application

    Reading tag's unique serial number...01E762A1
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:02
    Then it's "working"?
    In post #1 you stated, "My tag serial number is 0133C2DD" and the source app
    bounced back that it's "01E782A1".

    I bought a bunch of tags from Parallax, but there was no notation as to their #s,
    so how do you know that yours is "...DD"?

    PE -- Oh, and, yes
    RFID_TX PIN 0 ' Connects to RFID R/W Module SIN
    RFID_RX PIN 1 ' Connects to RFID R/W Module SOUT
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:07
    My bad, the 0133C2DD is my first tag then I tried different one 01E782A1. How come that Low Enable or Low RFID_TX code is not working; the RFID won't activate.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:10
    Attached is the wiring setup.
    320 x 240 - 33K
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:13
    The "$FEEDBEEF" thing?
    That's where it's going to reprogram your tag to = $FEEDBEEF.
    You have to be using a writable, R/W, RFID tag, a 'read-only' cannot be changed.

    PE -- http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/txtSearch/rfid/List/0/SortField/4/ProductID/689/Default.aspx
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:17
    Yes, is that what I supposed to use in EEPROM table? Thanks for supporting me on this one.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:20
    The "eeprom" is (is in) the R/W tag.
    Please confirm that you definitely have an R/W tag.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:23
    Yes. I have R/W tag
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:26
    Attached is the print out after the source app read/write on the tag.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:26
    So, the program is not getting to where the DEBUG prints: "Writing and verifying data to tag..." ?
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:32
    It gets to that point I just deleted that part on the second run.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:34
    Then what's the problem?
    You want to do another number or what?
    Help me help you, Chief.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:38
    I can't make this program code to activate RFID to scan tags.
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:40
    I would like to use the RFID to control lock/unlock of door lock using a designated tag.
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:50
    OK, I think that is going to work only with the other/read-only/legacy RFIDs.
    They have 5 bytes, but the R/Ws have 4 bytes.

    I modified the prior program (attached.) It will look for $EF in buf(4).
    If you didn't re-write your tag then change the test byte to look for $A1 (or whichever tag you're waving in front of it.)
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:56
    Crumbs, slight error.
    Try this one (it should look for the hex $EF, not "EF")
  • navychiefnavychief Posts: 40
    edited 2011-04-03 17:56
    I'm just getting Expected THEN on this section:
    Check:
    IF buf(4) = "EF" THEN Unlock
    DEBUG "Go Away!", CR
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 17:58
    See #27, I Edited while you were posting
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2011-04-03 18:01
    forgot those hex2's

    PE -- Please post a screen shot of your results. You're a nice guy, Chief, but I'm reluctant to open RTFs (etc.)
  • navychiefnavychief Posts: 40
    edited 2011-04-03 18:23
    Thanks PJ, you're the best.
Sign In or Register to comment.