Shop OBEX P1 Docs P2 Docs Learn Events
Controlling Servo Run Time with FOR ... NEXT — Parallax Forums

Controlling Servo Run Time with FOR ... NEXT

CodeOfficerCodeOfficer Posts: 3
edited 2006-09-04 16:00 in BASIC Stamp
I picked up a USB BOE-Bot a bit ago, and I'm doing the exercises in the "Robotics with the BOE-Bot" book.

I'm kinda stumped on the subject of Controlling Servo Run Time in FOR ... NEXT loops.

Specifically, page 82 gives the following example:

FOR counter = 1 TO 100
   PULSOUT 13, 850
   PAUSE 20
NEXT


Its explained that each PULSOUT command last for 1.7ms (I get this), and each PAUSE command lasts for 20ms (totally obvious to me) ... but then its quickly stated that it takes 1.3ms for the loop to execute. I'm not sure where this number comes from. Anyone have a quick answer?

Thanks!

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-04 15:30
    Scott Edwards did some work on detailing exactly how long each PBasic keyword takes to execute. That's where that number comes from. Basically, it takes around 300 uSecs for each PBasic token to execute. So the FOR, PULSOUT, PAUSE, and NEXT add up to 4 x 300 uSec == 1.2 mSec (or ~ 1.3 mSec).
  • CodeOfficerCodeOfficer Posts: 3
    edited 2006-09-04 15:35
    AHA! tha makes sense!

    I must have missed that being explained in the book prior to this chapter/example. Thanks for the quick reply Alan.

    Is there a place I can read the work Scott had done?
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-09-04 15:45
    Sure. Though apparently I got it wrong, it's not Scott Edwards site, it's Tracy Allen at EMESystems.com (very good site, by the way).

    http://www.emesys.com/BS2index.htm
  • CodeOfficerCodeOfficer Posts: 3
    edited 2006-09-04 16:00
    Great site indeed, many thanks!

    here's the URL for anyone else who'd want it: www.emesys.com/BS2speed.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.codeofficer.com

    Post Edited (CodeOfficer) : 9/4/2006 4:30:17 PM GMT
Sign In or Register to comment.