RFID Tag Reader code - where did the bytes go?
Brian Riley
Posts: 626
In addition to some other goodies I recently bought an RFID reader on which to experiment. When I went to interface it with some existing code I found that the 'entry fee' was prohibitive, that is to say the TEN BYTE BUFFER for non SPRAM chips made it a non starter for anything complex. Now that bugged me ... so I did some thinking and came up with this solution. I tried it first on a second copy of the RFID_basic.BS2 code, a simple recognition and display card ID, and then on the recognition and comparison program.
They key to this fix is this line
The buffer now becomes 5 bytes not 10 (when you only have 26 bytes available, salvaging 5 is THE WORLD!) each EEPROM DATA statement for Tag IDS is 5 bytes not 10 bytes
The search loops become "0 TO 4" instead of "0 TO 9" etc. The code worked clean the first time I tried it. In terms of data structures it is much more compact, in strict terms you can double the number of tags to store. What I don't know is how much extra prgram space the new SERIN statement takes versus the old. Because of formatting the read may be a bit slower, though as someone said on the forum recently, "2400 baud is very forgiving." The program evaluation and comparison is quicker by half as many loops times how many tags you can store.
So now the RFID Reader code RAM requirements are less stringent and it 'plays well with others' much better! I hope this is of use to you all.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
They key to this fix is this line
SERIN RFIDLine, T2400,200, Look4Tone, [noparse][[/noparse]WAIT($0A), HEX2 buf(0), HEX2 buf(1), HEX2 buf(2), HEX2 buf(3), HEX2 buf(4)] ' used instead of SERIN RFIDLine, T2400,200, Look4Tone, [noparse][[/noparse]WAIT($0A), buf\10]
The buffer now becomes 5 bytes not 10 (when you only have 26 bytes available, salvaging 5 is THE WORLD!) each EEPROM DATA statement for Tag IDS is 5 bytes not 10 bytes
TagA DATA $0F, $32, $95, $98, $9D ' TagB DATA $0F, $32, $95, $36, $6B ' ' used inStead of TagA DATA "0F3295989D" ' TagB DATA "0F3295366B" '
The search loops become "0 TO 4" instead of "0 TO 9" etc. The code worked clean the first time I tried it. In terms of data structures it is much more compact, in strict terms you can double the number of tags to store. What I don't know is how much extra prgram space the new SERIN statement takes versus the old. Because of formatting the read may be a bit slower, though as someone said on the forum recently, "2400 baud is very forgiving." The program evaluation and comparison is quicker by half as many loops times how many tags you can store.
So now the RFID Reader code RAM requirements are less stringent and it 'plays well with others' much better! I hope this is of use to you all.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
·· Very nice.·· 'Nuf said.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards from Chile
Goten
www.chilebot.cl
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
The easiest way is to check the Memory Map -- that's part of the reason it's there. Of course, the version using HEX modifiers will probably require a bit more space, but that is probably less of an issue than variable consumption. And since the RFID reader transmits at 2400 baud, there is plenty of time (during the stop bit) for the BASIC Stamp to handled the conversion.
[noparse][[/noparse]Update] Okay, my Stamp editor was open so I did a quick test with just the SERIN statement.· When receiving 10 raw bytes into the array the program takes 17 bytes; when the program is updated to receive five hex values the program consumes 43 bytes.· Don't panic, this only happens in one location and if your program is struggling for variable space this is definitely worth doing.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 2/24/2006 5:50:57 PM GMT
At the risk of getting a kink in my wrist (patting myself on the back!) It is even more 'valuable' than I though it might be. I did a demo of a system I put togther this past weekend at a local hamfest forum. I am going to write it up with pix and code this week and post it to the projects section. It marries a BS2, Emic speech unit, an RC-4, RFID reader, an 8870 DTMF decoder and a DS1302 RTC. I am proud to say that every single I/O pin got used (I had to tie the RFID enable to ground!)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont