beautypg.com

Servo, led, and other output commands, C. example scripts, Getting started: blinking an led – Pololu Maestro User Manual

Page 56

background image

Servo, LED, and other output commands

command

stack

effect

description

SPEED

-2

sets the speed of the channel specified by the top element to the value in the
second element (see

Section 4.e

)

ACCELERATION

-2

sets the acceleration of the channel specified by the top element to the value in
the second element (see

Section 4.e

)

GET_POSITION

-1,+1 gets the position of the channel specified by the top element

GET_MOVING_STATE +1

true if any servos that are limited by speed or acceleration settings are still
moving

SERVO

-2

sets the target of the channel specified by the top element to the value in the
second element, in units of 0.25 μs

SERVO_8BIT

-2

sets the target of the channel specified by the top element to the value in the
second element, which should be a value from 0 to 254 (see the Mini SSC
command in

Section 5.e

)

LED_ON

none

turns the red LED on

LED_OFF

none

turns the red LED off (assuming no errors bits are set)

PWM

-2

(Mini Maestro 12, 18, and 24 only) enables the PWM output channel, with
the period specified by the top element and the on time specified by the second
element, both in units of 1/48 μs (see

Section 4.a

for more information about

PWM)

SERIAL_SEND_BYTE

-1

(Mini Maestro 12, 18, and 24 only) removes the top number from the stack,
interprets it as a single byte, and sends that byte to the TTL serial output (TX)

6.c. Example Scripts
Getting started: blinking an LED

The following script will cause the red LED on the Maestro to blink once per second:

# Blinks the red LED once per second.

begin

led_on

100 delay

led_off

900 delay

repeat

It is a good idea to try stepping through this script before doing anything further with scripts on the Maestro. In
particular, pay attention to how the command “100” puts the number 100 on the stack, and the DELAY command
consumes that number. In the Maestro scripting language, arguments to commands always need to be placed on the
stack before the commands that use them, which makes the language seem backwards compared to other languages.
It also means that you can arrange your code in a variety of different ways. For example, this program is equivalent
to the one above:

# Blinks the red LED once per second.

begin

900 100

Pololu Maestro Servo Controller User's Guide

© 2001–2014 Pololu Corporation

6. The Maestro Scripting Language

Page 56 of 73