Shop OBEX P1 Docs P2 Docs Learn Events
How is code overhead determined? — Parallax Forums

How is code overhead determined?

cutsrockcutsrock Posts: 32
edited 2007-11-23 20:16 in BASIC Stamp
Page 82 of "Robotics with the Boe-Bot" shows the use of code overhead to calculate exactly how long this code will make the servo turn.
FOR counter = 1 TO 100
PULSOUT 13, 850
PAUSE 20
NEXT
"Each time through the loop, the·PULSOUT command lasts 1.7ms., the PAUSE command lasts 20 ms., and it takes about 1.3 ms., for the loop to execute."· The 1.3 ms., is referenced as "code overhead".
My question is how was/is the code overhead determined?


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
EPIC FAILURE -·When everyday run-of-the-mill failure just isn't good enough.

Comments

  • NetHogNetHog Posts: 104
    edited 2007-11-22 22:23
    I don't know how the author did it, but you can do some metrics like this... wire up an LED to, say, pin 0, and:
    HIGH 0
    FOR counter = 0 TO 65535 ' assumes counter1 is a Word
    PAUSE 1
    NEXT
    LOW 0

    this should, in theory, with no overhead, take 65536ms (about 66 seconds). It will probably take about 2-3 minutes to run.
    Let's say, with a stopwatch, we calculate it takes 145-155 seconds to run (+/- 5 seconds for reaction time).
    145 seconds is 145000 ms 155 seconds is 155000ms
    Divide this by 65536 (iterations), each iteration is 2.2-2.36 ms (given our stopwatch accuracy)
    Since 1ms was spent pausing, this is 1.2-1.36ms overhead.

    of course, the more accurately you measure this, or the higher amount of iterations, the more accurate you can calculate the overhead.
  • cutsrockcutsrock Posts: 32
    edited 2007-11-23 02:59
    Thanks NetHog. Will give it a go.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EPIC FAILURE -·When everyday run-of-the-mill failure just isn't good enough.
  • ZootZoot Posts: 2,227
    edited 2007-11-23 09:02
    You might also take a look at this page, where Tracy Allen measured execution times of Stamp instructions with a 'scope:

    emesystems.com/BS2speed.htm

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
  • cutsrockcutsrock Posts: 32
    edited 2007-11-23 16:06
    Thanks, Zoot. I read through Tracy's paper and book marked it for future reference. Very helpful.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    EPIC FAILURE -·When everyday run-of-the-mill failure just isn't good enough.
  • NetHogNetHog Posts: 104
    edited 2007-11-23 17:42
    A very good paper. Thanks Zoot.
  • ZootZoot Posts: 2,227
    edited 2007-11-23 20:16
    Thank Dr. Tracy Allen smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST
Sign In or Register to comment.