How is code overhead determined?
cutsrock
Posts: 32
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.
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
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.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
EPIC FAILURE -·When everyday run-of-the-mill failure just isn't good enough.
emesystems.com/BS2speed.htm
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
EPIC FAILURE -·When everyday run-of-the-mill failure just isn't good enough.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST