SERIN from Multiple Pins
John R.
Posts: 1,376
I'm new to STAMPs, and have a BS2 reading from an RFID reader, processing the tag, and spitting output to an LCD.
So far, so good.
I'd like to add a second RFID reader, on another pin.
I've got the SERIN waiting for the $0A character.· Is there a way to have a second SERIN command "active", or way to switch "back and forth" between two (or more) pins until one has a signal?
Is this something one of the other chips (with a build in buffer) could handle better?
The ultimate application would be a number of RFID readers on a model railroad reporting back any tags (in order) that passed over them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
So far, so good.
I'd like to add a second RFID reader, on another pin.
I've got the SERIN waiting for the $0A character.· Is there a way to have a second SERIN command "active", or way to switch "back and forth" between two (or more) pins until one has a signal?
Is this something one of the other chips (with a build in buffer) could handle better?
The ultimate application would be a number of RFID readers on a model railroad reporting back any tags (in order) that passed over them.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
Comments
·· You could employ short time-outs on your SERIN statement.· That would let you switch between the two when one isn't getting any data.· The Help Files and BASIC Stamp Manual explain the timeout feature quite well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Truly Understand the Fundamentals and the Path will be so much easier...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
Main:
· GOSUB Get_Tag
· ' rest of program that handles tag
· GOTO Main
Get_Tag:
· SERIN RFID1, T2400, 1000, Get_Tag2, [noparse][[/noparse]WAIT($0A), STR buf\10]
· RETURN
Get_Tag2:
· SERIN RFID2, T2400, 1000, Get_Tag, [noparse][[/noparse]WAIT($0A), STR buf\10]
· RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thanks for the snipets, the light bulb is now glowing brightly!
I was thinking of the "timeout" function more as an "error condition", not a way to do the multi-tasking. It's probably even in the docs, but being the impatient American, after instant results, I was skimming...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10