When we’re using a BS2, BS2e, or BS2sx, the tag string
is stored in our variable buffer; otherwise, it gets stuffed into
the first 10 bytes of the Scratchpad. See how much easier this
is? The STR and SPSTR modifiers are huge time-savers here.
With the tag string in RAM, we can compare it against
the table, and again, it’s much easier with the BS2-family.
FOR tagNum = 1 TO LastTag
FOR idx = 0 TO 9
READ (tagNum - 1 10 + idx), char
#IF __No_SPRAM #THEN
IF (char <> buf(idx)) THEN Bad_Char
GET idx, chkChar
IF (char <> chkChar) THEN Bad_Char
byte from the reader. Our conditional symbol sets up the
code to make the comparison against a byte in the variable array or against a byte from the Scratchpad. Note that
the Scratchpad cannot be treated like an array, so we are
forced to use GET to access the appropriate byte.
Moving on to a good tag, we will do the same as before:
sound the beeper (with FREQOUT) and disable the security
lock. Remember that FREQOUT is one of those instructions
that differs from Stamp to Stamp, so conditional compilation
constants are used to keep the timing (two seconds) and
tone (880 Hz) the same, no matter which module we use.
FREQOUT Spkr, 2000 */ TmAdj, 880 */ FrAdj
As with the BS1, a loop is used to work through the
known tag strings. What we’re able to do here, however, is
use a second loop to test each byte of the received string.
The inner loop reads the appropriate byte from the current
tag data and compares it against the corresponding tag
We’ve also added the ability to display the name of the
person who is assigned to the valid tag. A simple loop will
send the characters of the name to a display. We’ll keep it
easy and use the Debug Terminal.
NUTS & VOLTS
DEBUG DEC tagNum, “: “
[Name0, Name1, Name2, Name3], idx
READ idx, char
IF (char = 0) THEN EXIT
idx = idx + 1
The result of the tag search (in the variable tagNum)
will be from one to the number of known tags if the tag
string is valid. If not, the search will result in zero. The
“Show_Name” routine uses the result of the tag search to
LOOKUP the first character of the corresponding name.
After that, each character is printed in a loop until the zero-terminator is encountered. We could very easily change
the DEBUG line to SEROUT for a serial LCD or to
LCD-OUT if we’re using a BS2p or BS2pe and have a parallel
LCD connected as required.
Well, that’s it. That was pretty simple, wasn’t it? I think
so and I’m having a lot of fun with the RFID reader. Be sure
to check out the resources listed, as there is lots of interesting information on RFID technology. Joe Grand’s website has some really cool stuff (if you’re into hardware
hacking, you’ll love his books).
Until next time ... Happy Stamping! NV