View Full Version : Question: BS2 need PAUSE accurate to the microsecond?

03-10-2010, 12:46 AM
Hey all,

The PAUSE function seems accurate to the millisecond.· Does any know if its possible to get this accurate to the micro second or is there a different function I should be using?

In looking at the·manual it would appear I may be out of luck...·
"the delays produced by PAUSE are as accurate as the ceramic-resonator time base.· When you use PAUSE in timing-critical applications, keep in mind the relatively low speed of the PBasic interpreter.· This is the time required for the basic stamp to read and interpret an instruction stored in the EEPROM."



Mike Green
03-10-2010, 12:56 AM
There is no PAUSE or similar statement that works with microsecond accuracy. Given that the minimum statement execution time is on the order of 100s of microseconds and there's not a precise breakdown of the execution time of the various interpretive codes, more precise delays may not be useful. That said, you can use the PULSOUT statement to provide delays on the order of a few microseconds by "outputting" a pulse to an otherwise unused I/O pin. The PULSOUT statement can produce a pulse width to a resolution of 2us with a BS2 (read the description in the Manual) and the statement pauses while the pulse is being generated.

There's a good discussion of Stamp execution times at www.emesystems.com (http://www.emesystems.com). Click on the app-notes link at the bottom of the page.

Phil Pilgrim (PhiPi)
03-10-2010, 12:58 AM
You can use PULSOUT on an unused pin for sub- and fractional-millisecond pauses. But you need to consider the PBASIC interpreter's overhead in your delay computations; and that usually has to be done empirically.