Shop OBEX P1 Docs P2 Docs Learn Events
Multitasking with BS2? — Parallax Forums

Multitasking with BS2?

gswhitegswhite Posts: 2
edited 2006-11-07 14:24 in BASIC Stamp
Hey All,

I'm new to the group and new to Basic Stamp.· I have access to BS2's so that's what I'm learning with.· I played with the OOPic's for a while.· The OOPIc's object code is fast but anything scripted is slow and serial comms are terrible.·

In BS2 I·need to wait for a SERIN sequence, "xyz" for now, and the status of 8 inputs a the same time.· If all eight inputs are high,·I need to turn on an output.· The program halts while waiting for SERIN = "xyz".· How can I wait for an incoming serial byte and monitor a·group of 8 I/O at the same time?

thanks ahead,
Geoff·

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-11-07 03:52
    Strictly speaking, you can't do it with a Stamp.· The Stamp is single threaded.· It does only one thing at a time.· Sometimes you can get around this a little like controlling more than one servo at a time by interleaving the pulses.· If the "xyz" gets sent repeatedly until answered, you can set up a timeout.· If the "xyz" doesn't come in within some number of milliseconds, you abort the SERIN and go check the switches, then go back to listening for the "xyz" for a little while.· You might miss the "xyz" while you're off looking at the switches.· There are external coprocessors that can take some of the load off.· They're usually fairly cheap PICs with internal clocks.· One does input buffering of serial data so you could still use the SERIN, but the PIC saves up several received bytes and retransmits them to the Stamp when the Stamp signals that it's ready to receive.
    ·
  • gswhitegswhite Posts: 2
    edited 2006-11-07 05:00
    I see. How 'bout the newer versions of Stamp? Does the Javelin have this capability, or the Propeller? The timeout could work, giving the 8 I/O priority and enabling the serial routines with an input might do the trick. I'll have extra I/O to play with. The 8 inputs need to react at hardware speeds, like an 8 input AND gate. Thanks for the quick response.

    -Geoff
  • Mike GreenMike Green Posts: 23,101
    edited 2006-11-07 05:09
    The Propeller is great for the type of thing you want to do. Since you can read all 8 inputs at a time (which you can also do with the Stamp), it's easy to do high speed logic (50ns per instruction though), but then you'd still have 7 other processors to do serial input, etc.
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-11-07 14:24
    The Javelin implements serial I/O using 'background' tasks, so it too will support this 'interrupt driven' approach.
Sign In or Register to comment.