Small error in Maestro user's guide

I believe in the command reference (pololu.com/docs/0J40/6.b), the stack effect of POKE is shown incorrectly. It is shown as “-2,+1”, but it seems it should really just be “-2”: two numbers are popped from the stack, nothing is pushed. (Some value in the stack is overwritten with a new number, but the depth of the stack is not changed by that.)

It’s probably worthwhile to put an example with poke and peek in the manual, showing how easy it is to use poke and peek to implement global variables:

# start of script: create global variables
# they are simply pushed on the stack and left there for the entire script
0 # motor_mode
90 # heading

.. script ..

# subroutines for reading global variables
sub get_motor_mode
  0 peek return
sub get_heading
  1 peek return

# subroutines for setting global variables
sub set_motor_mode
  0 poke return
sub set_heading
  1 poke return

Not related: Perhaps the description of PWM in the command reference could mention how to disable the PWM output channel. It took me while to realize that 8000 8 SERVO does it.

Hello,

You are absolutely right about POKE. Thanks for the examples - we will add them to the documentation soon!

As for PWM, what do you mean by “disable”? Your command is the same as “1024 8 SERVO”, since the channel must be configured as an output, which is fine to do, but it should be the same as setting the PWM to 100% on with a command like “500 500 PWM”, right?

-Paul

I was assuming that enabling the PWM output (in the MaestroControlCenter there is checkbox for this) would incur a slight performance penalty, because the Maestro has to run a timer - so it seemed better to disable PWM when I am not using it (I’m currently using it emit beeps every now and then). In the MaestroControlCenter one can untick the PWM checkbox, so I was looking for an equivalent script command.

But perhaps the timer is running anyway and there is no reason to turn off PWM and go back to “normal” digital output mode?

The PWM Output feature of the Maestro is handled by a hardware timer which takes no CPU time, so you shouldn’t worry about disabling it. In general, we’ve optimized the Maestro enough that you will probably never have to worry about performance. :slight_smile:

–David

:slight_smile: :slight_smile: :slight_smile:
Thanks Otfried, your example opened up a new world to me. Hope it makes its way to the manual.