N and V column
Column #120: You Can’t Touch That: Non-contact Access Control
The Nuts and Volts of BASIC Stamps (Volume 6) • Page 63
Is It Magic?
Okay, how does it work? It's not magic; in fact it's not terribly complicated. When power (5
VDC) is applied to the reader a green LED will indicate that it's ready to function. By pulling
the ENABLE pin low, the reader becomes active (LED changes to red) and the antenna
broadcasts a modulated signal. If a tag is within range (up to four inches with the Parallax
reader), it will harvest the RF energy with its own antenna and modulate its unique
identification code in a manner that can be detected by the reader. A microcontroller on the
reader tests the bits from the RFID tag to make sure the information is valid, and then the tag
number is converted to an ASCII stream to be transmitted on the SOUT pin at 2400 baud.
Keep in mind that when the antenna is active (red LED), the device is broadcasting and
consuming about 200 mA from the power supply. If you're going to do a project that involves
batteries, you may want to add a physical button to activate the reader only when a card is
actually present, or use a timeout with SERIN (BS2 family only) to disable the reader
periodically and reduce the load on the power supply.
Since RFID is so common in controlled-access and security systems, let's go that direction.
And just for fun, let's build a super-simple, single-tag access control device with a BS1. Can
we do it? Absolutely. In fact, the code is so simple we can look at the whole thing in one
shot:
Main:
LOW Enable
SERIN RX, T2400, ($0A, "0F0184F20B")
HIGH Enable
Access_Granted:
HIGH Latch
PAUSE 2000
LOW Latch
GOTO Main
We start by activating the reader (ENABLE pin is pulled low) and then simply waiting the for
a specific tag string. And let me correct something I left out: the tag ID string is preceded by
a linefeed character ($0A) and followed by a carriage return ($0D). We'll see why this is
useful a bit later.