Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Servo Controller and arduino Delay problem

Im new here and not sure the proper way to post scripts so here it goes.

I have this script in my maestro

begin
repeat

Sequence 0

sub sequence0
begin
1000 8000 3968 0 0 0 0
0 0 0 0 0 0 frame_0…11 # Frame 0
1000 3968 8000 frame_0_1 # Frame 1
1000 5984 5944 frame_0_1 # Frame 2
1000 5984 5944 frame_0_1 # Frame 3
quit
repeat

sub frame_0…11
11 servo
10 servo
9 servo
8 servo
7 servo
6 servo
5 servo
4 servo
3 servo
2 servo
1 servo
0 servo
delay
return

sub frame_0_1
1 servo
0 servo
delay
return

Then I have this is the arduino

// Play Animation number 0
if (button1_state != button1_last_state){
button1_last_state = button1_state;
maestro.restartScript(0);

#ifdef enable_debug
    Serial.print("Button 1: ");
    Serial.println(remote.button1);
  #endif

When I push the button the servos move to the first position and then there is a pause and then the servos move to the last two positions.

What is causing the delay?

Thanks,

Matt

Hello.

From your Maestro code, it looks like you should be seeing a one second delay between Frame 0 and Frame 1, a one second delay between Frame 1 and Frame 2, then Frame 2 and Frame 3 are the same (so you should not see any change). The delays are cause by the delay commands in your subroutines, which are using the final stack value of 1000 to control how long the script delays in milliseconds. (Note that the final stack value is the first values you list when you call a subroutine.) You can check out “The Maestro Scripting Language” section of the user’s guide for more information.

If you are seeing different behavior, could you please post a video of your system running the Maestro script so we can see what it is doing?

-Patrick

Thanks for the quick reply. I am getting a slightly different result. I will post a video later this afternoon. When i press the button I am getting the first servo position and then a 2 to 3 second delay. Then it does the second movement and pauses for the 1 second time and does the third movement.