User Manual
This program is 29 bytes long, with 3 bytes used per position and 14 bytes of overhead. Note that
we could get the same efficiency if we used the SERVO_8BIT command, which takes a one-byte
argument from 0 to 254. We can go even smaller by putting all of the numbers together:
If you step through this version program, you will also notice that all five numbers are placed on the
stack in a single step: this is because the compiler can use a single command to put multiple numbers
on the stack. Using a single command for multiple numbers saves space: we are now down to just 26
bytes. Only 12 bytes are used for the 5 frames, for an average of 2.4 bytes per frame. This is probably
compact enough – by duplicating this structure we could fit 420 different positions into the 1024-byte
program memory of the Micro Maestro. However, the code can get even smaller. Consider this script,
which uses 31 frames to make a smooth back-and-forth motion:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Move servo 0 to five different positions, in a loop.
begin
40 frame
50 frame
60 frame
70 frame
80 frame
repeat
# loads a frame specified in 25 us units
sub frame
100 times
0 servo
500 delay
return
1
2
3
4
5
6
7
8
9
10
11
12
# Move servo 0 to five different positions, in a loop.
begin
80 70 60 50 40
frame frame frame frame frame
repeat
# loads a frame specified in 25 us units
sub frame
100 times
0 servo
500 delay
return
?
?
Pololu Maestro Servo Controller User’s Guide © 2001–2019 Pololu Corporation
6. The Maestro Scripting Language Page 80 of 102










