code execution time
Hi, i am looking for answers of questions below. Someone can help ??
1. From datasheet, program execution speed for BS2 is 4000 instructions/sec. How does it come?
2. On Robotics with the Boe Bot chapter 2, page 83, there is a time calculation for servo code.
1.7 ms - pulse duration 850
1.3 ms - pulse duration 650
20 ms - pause duration
1.6 ms - code overhead - what does it mean ?
-ichoel-
"There is sky over the sky"
1. From datasheet, program execution speed for BS2 is 4000 instructions/sec. How does it come?
2. On Robotics with the Boe Bot chapter 2, page 83, there is a time calculation for servo code.
1.7 ms - pulse duration 850
1.3 ms - pulse duration 650
20 ms - pause duration
1.6 ms - code overhead - what does it mean ?
-ichoel-
"There is sky over the sky"
Comments
1) Someone at Parallax took a look at the source code for the Stamp Basic interpreter and estimated the execution time for typical interpretive instructions. The simple statements like HIGH / LOW / TOGGLE, GOTO, and IF / THEN typically compile into a one or two instructions. Arithmetic operations like + , -, =, < would compile into one or two instructions.
2) The units for the PULSOUT (as described in the manual) are 2us for the BS2. If you have a "PULSOUT 11,1370", then you will get a pulse on pin 11 of 2.74ms (2us x 1370).
In the program fragment shown, there's probably a "PAUSE 20" which results in a 20ms pause in program execution. Servo motors require a control pulse roughly every 20ms and the PAUSE is used to create that timing.
Code overhead is the approximate execution time of all of the statements used in the loop or program fragment of interest other than the actual timed operation of the statements. For example, if you have a PULSOUT followed by a PAUSE, they both specify a time for execution, but there's some additional time (overhead) for the Basic interpreter to get the instruction codes out of program memory and interpret them. There may also be some control statements like FOR / NEXT or IF / THEN that surround the timed statements. They are considered overhead as well since they don't result in a specific time interval, but they do take some time to execute.
-ichoel-
"There is sky over the sky"
I don't know for certain if that's exactly how they did it, but this is the way I'd come up with that number.