Maestro script for simultaneous and identical servo actions

Hi all,

I am using a example script from the maestro controller servo users guide: The one with the single pushbutton that explains how to use the wait_for_button_press command. I took it over as it (except for the the assigment of channels) and it works fine.
The only thing is that instead of one servo, I need to have two servos doing exactly the same action at exactly the same time. My servos are on channel 1 and 2. My button is on channel 18.
How should I modify the script? I realize the answer is probably obvious, but I am new to this, so thanks for helping out.

[code]goto main_loop # Run the main loop when the script starts (see below).

This subroutine returns 1 if the button is pressed, 0 otherwise.

To convert the input value (0-1023) to a digital value (0 or 1) representing

the state of the button, we make a comparison to an arbitrary threshold (500).

This subroutine puts a logical value of 1 or a 0 on the stack, depending

on whether the button is pressed or not.

sub button
18 get_position 500 less_than
return

This subroutine uses the BUTTON subroutine above to wait for a button press,

including a small delay to eliminate noise or bounces on the input.

sub wait_for_button_press
wait_for_button_open_10ms
wait_for_button_closed_10ms
return

Wait for the button to be NOT pressed for at least 10 ms.

sub wait_for_button_open_10ms
get_ms # put the current time on the stack
begin
# reset the time on the stack if it is pressed
button
if
drop get_ms
else
get_ms over minus 10 greater_than
if drop return endif
endif
repeat

Wait for the button to be pressed for at least 10 ms.

sub wait_for_button_closed_10ms
get_ms
begin
# reset the time on the stack if it is not pressed
button
if
get_ms over minus 10 greater_than
if drop return endif
else
drop get_ms
endif
repeat

An example of how to use wait_for_button_press is shown below:

Uses WAIT_FOR_BUTTON_PRESS to allow a user to step through

a sequence of positions on servo 1.

main_loop:
begin
4000 frame
8000 frame
repeat

sub frame
wait_for_button_press
1 servo
return[/code]

Hello.

To move two servos at once, you could modify your main_loop and frame subroutine to the following:

main_loop:
begin
  4000 4000 frame	// put values onto the stack (4000, 4000) call frame subroutine
  8000 8000 frame	// put values onto the stack (8000, 8000) call frame subroutine
repeat

sub frame
  wait_for_button_press
  1 servo
  2 servo	// move servo connected to channel 2
  return

Since you are new to using the Maestro scripting language, I recommend looking at the “Command Reference” section in the Maestro User’s Guide to get a better understanding of the commands, particularly the SERVO command. Also, it might be useful for you to step through the script using the “Step Script” button in the “Script” tab of the Maestro Control Center to see the affect of each line of code.

Alternatively, if you really want your servos to always do the same exact thing, you should be able to connect the signal wires from both servos to the same Maestro channel with something like a Servo Y-Cable.

- Amanda