User Manual
6. The Maestro Scripting Language
A script is a sequence of commands that is executed by the Maestro. Commands can set servo
targets, speeds, and accelerations, retrieve input values, and perform mathematical computations.
Basic control structures – looping and conditionals – are available for use in making complicated
scripts. The Maestro script language is a simple stack-based language very similar to FORTH, and
scripts compile to a compact bytecode in which commands and subroutine calls each take just a single
byte. A basic editor/debugger is available in the Script tab of the Maestro Control Center application.
6.a. Maestro Script Language Basics
Commands and the stack
A program in the Maestro script language consists of a sequence of commands which act on a stack of
values. Values in the stack are integers from -32768 to +32767. On the Micro Maestro 6-channel servo
controller, there is room for up to 32 values on the stack, while on the Mini Maestro servo controllers
there is room for up to 126 values on the stack. Commands always act on the topmost values of
the stack and leave their results on the top of the stack. The simplest kind of commands are literals,
numerical values that are placed directly onto the stack. For example, the program “-10 20 35 0” puts
the values -10, 20, 35, and 0 sequentially onto the stack, so that it looks like this:
value
3 0
2 35
1 20
0 -10
A more complicated command is the PLUS command, which adds the top two numbers, leaving the
result on the top of the stack. Suppose the numbers 1, 2, 4, and 7 are sequentially placed on the stack,
and the PLUS command is run. The following table shows the result:
before after
3 7
2 4 11
1 2 2
0 1 1
Pololu Maestro Servo Controller User’s Guide © 2001–2019 Pololu Corporation
6. The Maestro Scripting Language Page 69 of 102










