Shop OBEX P1 Docs P2 Docs Learn Events
time required for SHIFTIN on a BS2 — Parallax Forums

time required for SHIFTIN on a BS2

davejamesdavejames Posts: 4,047
edited 2010-02-04 21:42 in BASIC Stamp
Hi All,

I'm exploring the pros/cons of testing the state of 10 switches via a parallel approach (dedicating 10 pins on the BS2) or by using a parallel-to-serial shift register and the SHIFTIN statement (dedicating 3 pins on the BS2).· Both methods would be inside a loop, constantly looking for switch data, and hop out to handle the switch setting then hop back into the loop.

Obviously, saving the 7 pins is a big plus.· But I'm concerned over how fast the BS2 can detect a switch being set by the serial approach.

The Program/Syntax reference mentions some timing for the SHIFTIN statement.· The book alludes to an· ~60us for one cycle.· So the first question is, am I correct in that observation?· If that's true, then I would guess to move 10 bits of data (each one representing the state of a switch) would take approx 600us.· I would also guess there is a couple hundred micro-seconds of 'overhead' for the SHIFTIN statement itself.· And of course, I'd have to figure in the time required for BS2 commands to decode the serial data and act on it.

First blush seems to indicate ~1ms.

Any body care to give me a sanity check?


Thanks much,

DJ


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-04 20:08
    A good source for Stamp timing information is www.emesystems.com. Click on the "app-notes" link at the bottom of the page.

    On a BS2, the manual gives a rate of 16Kbps which is about 60us per bit as you mentioned. You're probably correct in estimating ~1ms for a 10 bit transfer. The decoding and action once the 10 bits gets into the BS2 will be a lot more than 1ms.
  • davejamesdavejames Posts: 4,047
    edited 2010-02-04 20:19
    Mr. Green,

    Thank you for the response...I'll go check emesystems as suggested.

    It all comes down to can I tolerate a potential longer time going the serial route (and keep using a BS2) versus using a BS2p40 (costs more) with all those yummy I/Os in parallel.

    Decisions, decisions...

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-04 20:36
    Whether or not your project will work with an I/O expander is something only you can answer, but, compared to the amount of time needed to process 10 switch closures, the ~1ms needed to read the switches is small. Remember that the BS2 is slow compared to a BS2p or BS2px apart from the additional I/O pins available with a BS2p40.
  • davejamesdavejames Posts: 4,047
    edited 2010-02-04 21:42
    ...yup - thanks.

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.