Shop OBEX P1 Docs P2 Docs Learn Events
RFID tag Car alarm help — Parallax Forums

RFID tag Car alarm help

Mr. PhinneyMr. Phinney Posts: 2
edited 2010-09-22 18:52 in Accessories
I am currently trying to impplement the Parallax RFID tag reader along with a BS2 into my car. i am trying to set this up so that if i scan a tag once it unlocks the driver door, if i scan it twice it unlocks both the driver and passenger door, 3 times it pops the trunk open, 4 times unlocks the fuel cover, and then finally 5 times locks both doors and arms the car so if any one opens a door it sounds the horn off.

I need help programing the BS2 to count how many times i scan the tag and then based on how many times go to a routine to then control what is choosen.

can anyone help? everything is appriciated

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-09-20 18:28
    Sure we can help. write code that you think will do what you want, test it on the stamp. If it does not work post it here and tell us what it did and what it did wrong. We can then help you fix the code. Oh, also tell us how you have everything connected.
  • Mr. PhinneyMr. Phinney Posts: 2
    edited 2010-09-21 11:39
    ok im currently just using the RFID.bs2 file with some stuff cut out this is what i have so far....


    ' =========================================================================
    '
    ' File....... RFID.BS2
    ' Purpose.... RFID Tag Reader / Simple Security System
    ' Author..... (c) Parallax, Inc. -- All Rights Reserved
    ' E-mail..... support@parallax.com
    ' Started....
    ' Updated.... 09 SEPT. 2005
    '
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    ' =========================================================================


    '
    [ Program Description ]
    '
    ' Reads tags from a Parallax RFID reader and compares to known tags (stored
    ' in EEPROM table). If tag is found, the program will disable a lock.


    '
    [ Revision History ]


    '
    [ I/O Definitions ]

    Enable PIN 0 ' low = reader on
    RX PIN 1 ' serial from reader
    Spkr PIN 2 ' speaker output
    Horn PIN 3 ' to horn relay for alram
    RLED PIN 4 ' Status LED set high red
    GLED PIN 5 ' Status LED set high green
    DLock PIN 6 ' to relay to lock driver door active low
    DUnLock PIN 7 ' to relay to unlock driver door active low
    Plock PIN 8 ' to relay to lock passenger door active low
    PUnlock PIN 9 ' to relay to unlock passenger door active low
    TUnlock PIN 10 ' to relay to unlock latch on trunk active low
    GCap PIN 11 ' to relay to unlock gas cover
    DSW PIN 12 ' driver door switch if needed
    PSW PIN 13 ' passenger door switch if needed

    '
    [ Constants ]

    T1200 CON 813
    T2400 CON 396
    T4800 CON 188
    T9600 CON 84
    T19K2 CON 32
    TMidi CON 12
    T38K4 CON 6


    SevenBit CON $2000
    Inverted CON $4000
    Open CON $8000
    Baud CON T2400



    TmAdj CON $100 ' x 1.0 (time adjust)
    FrAdj CON $100 ' x 1.0 (freq adjust)



    LastTag CON 3





    '
    [ Variables ]


    buf VAR Byte(10) ' RFID bytes buffer
    tagNum VAR Nib ' from EEPROM table
    idx VAR Byte ' tag byte index
    char VAR Byte ' character from table
    counter VAR Nib ' counter variable




    '
    [ EEPROM Data ]

    Tag1 DATA "0415E9C518" ' valid tags
    Tag2 DATA "360061A0D2"
    Tag3 DATA " "



    '
    [ Initialization ]

    Reset:
    HIGH Enable ' turn of RFID reader



    '
    [ Program Code ]

    Main:
    LOW Enable ' activate the reader
    SERIN RX, T2400, [WAIT($0A), STR buf\10] ' wait for hdr + ID
    HIGH Enable ' deactivate reader

    Check_List:
    FOR tagNum = 1 TO LastTag ' scan through known tags
    FOR idx = 0 TO 9 ' scan bytes in tag
    READ (tagNum - 1 * 10 + idx), char ' get tag data from table
    IF (char <> buf(idx)) THEN Bad_Char ' compare tag to table
    NEXT
    GOTO Tag_Found ' all bytes match!

    Bad_Char: ' try next tag
    NEXT

    Bad_Tag:
    tagNum = 0
    LOW 5
    HIGH 4
    PAUSE 10
    GOTO Main

    Tag_Found:





    i dont know what i need to do to get this thing to count how many times the card has been scanned. if it is scanned once i want it to unlock the driver door, 2 times it unlocks the driver and passenger door if i can get a snippet of code just for that i can manage to do the rest
  • FranklinFranklin Posts: 4,747
    edited 2010-09-21 18:22
    So, the first time you scan it it opens the driver door then next it open the passenger door, etc.? By the time you scan the lock code all your doors, your trunk and fuel doors will be open and then your alarm will be set. You need to build in a time limit within which the swipes need to occur and a counter like
    if scan 
       if timer < max time 
           count = count + 1
    
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-09-22 18:52
    i scan a tag once it unlocks the driver door, if i scan it twice it unlocks both the driver and passenger door, 3 times it pops the trunk open, 4 times unlocks the fuel cover, and then finally 5 times locks both doors and arms the car so if any one opens a door it sounds the horn off.

    I can see some problems with this set up first what if you just want the gas tank door to open you have to scan it four time why not have it where you scan your card once then with one switch or five switches select which one you want and you can have if the selection is not made in a few seconds then it dose nothing just an :idea:
    or you could have different card one for each function which is very easy to do btw just an :idea:

    Second problem I see is if you hold your card to long you may pass the selection you want and may have to have some kinda time out in your code when I write code for my gate opener and garage door opener I use at least a two second delay now your delay could be shorter

    The prolem I had was if you scan your card and it would open the door but if you held the card there to long it would then stop the door from opening or closing the right way this was because the Basic Stamp was controlling another controller garage door opener

    I hope this help
Sign In or Register to comment.