Shop OBEX P1 Docs P2 Docs Learn Events
SERIN from Multiple Pins — Parallax Forums

SERIN from Multiple Pins

John R.John R. Posts: 1,376
edited 2005-10-27 16:22 in BASIC Stamp
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

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-10-27 14:44
    John,

    ·· 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
  • Tom WalkerTom Walker Posts: 509
    edited 2005-10-27 14:44
    Since the Stamp is single-tasking, watching multiple ports with SERIN is not possible. Your best bet, using the Stamp, would probably be looping through multiple SERINs with short timeouts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • John R.John R. Posts: 1,376
    edited 2005-10-27 15:14
    Thanks for the replies. I saw some of that in the help, and being new, didn't quite grasp the practical impications. I'll give it a shot tonight or over the weekend and see what happens.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 15:39
    As has been suggested, you can use the BS2's timeout feature of SERIN to switch back and forth -- here's a simple framework:

    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
  • John R.John R. Posts: 1,376
    edited 2005-10-27 16:22
    Jon;

    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
Sign In or Register to comment.