time required for SHIFTIN on a BS2
davejames
Posts: 4,047
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
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
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.
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔