Shop OBEX P1 Docs P2 Docs Learn Events
Question: BS2 need PAUSE accurate to the microsecond? — Parallax Forums

Question: BS2 need PAUSE accurate to the microsecond?

rh3drh3d Posts: 14
edited 2010-03-09 17:58 in BASIC Stamp
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."

Thoughts?·

Thanks

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-09 17:56
    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. Click on the app-notes link at the bottom of the page.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-09 17:58
    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.

    -Phil
Sign In or Register to comment.