RFID tag Car alarm help
Mr. Phinney
Posts: 2
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
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
' =========================================================================
'
' 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
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