Problems with Maestro script

Hello !

I have problem with this script:

goto main_loop
sub button
4 get_position 500 less_than
return
sub wait_for_button_press
wait_for_button_open_10ms
wait_for_button_closed_10ms
return
sub wait_for_button_open_10ms
get_ms # put the current time on the stack
begin
button
if
drop get_ms
else
get_ms over minus 10 greater_than
if drop return endif
endif
repeat
sub wait_for_button_closed_10ms
get_ms
begin
button
if
get_ms over minus 10 greater_than
if drop return endif
else
drop get_ms
endif
repeat

main_loop:
begin
500 6624 6624 6624 6624 6000 frame_0…3_5 # Frame 0
500 8699 frame_0 # Frame 1
500 8699 frame_1 # Frame 2
500 8699 frame_2 # Frame 3
500 8699 frame_3 # Frame 4
500 4466 frame_0 # Frame 5
500 4466 frame_1 # Frame 6
500 4466 frame_2 # Frame 7
500 4466 frame_3 # Frame 8
repeat

sub frame_0…3_5
wait_for_button_press
5 servo
3 servo
2 servo
1 servo
0 servo
100 delay
return
sub frame_0

wait_for_button_press
0 servo
100 delay
return

sub frame_1
wait_for_button_press
1 servo
100 delay
return

sub frame_2
wait_for_button_press
2 servo
100 delay
return

sub frame_3
wait_for_button_press
3 servo
100 delay
return

I want to rotate successively 4 servos at the command of a button.

It runs three cycles. At step 27 (the beginning of the 4th cycle) I get the error ox0040.

Can you help me ?

Thank you very very much !

Hello.

I moved your post to its own thread since it didn’t seem connected to the others.

It looks like you are specifying your delay parameter twice for each subroutine (once in your main BEGIN/REPEAT loop and once inside each subroutine). This means that after each subroutine there is a leftover value on the stack that is not getting used, eventually causing a stack overflow. Can you try either removing the 500 that starts each line in your BEGIN/REPEAT loop or removing the 100 before each delay in your subroutines?

Brandon

Hello Mr. Brandon !

You are great !

Thanks for the prompt response !
Both indicated variants work.

But:

I want to use this program to synchronize multiple robot arms.

For this, I think, is important to keep that 500 at the beginning of each line in the BEGIN/REPEAT loop (which will then be modified depending on how big the move is).

But the elimination of the value before each delay in the subroutines leads me to a slowdown of the orders (I think a delay without specified value, automatically implies a delay of 1 sec.).

After me, a solution would be if in the compiled code I would change the delay code (08) in a lower value.

But I do not know how to do it.

Could you suggest a possibility, or another variant ?

I have to tell you that I am in the beginning using the controller maestro and I’m not too advanced in programming.

Thanks a lot and good wishes !

Florin

Hello.

The 500 and 100 values that you are referring to are both intended to be used with the DELAY command to specify the duration in milliseconds, but the DELAY command only takes one argument. So, for example, when you remove the 100 value in each subroutine, the delays are all using the 500, resulting in a 500ms delay. You can reduce this delay by simply reducing 500. You can change each 500 in your main BEGIN/REPEAT loop to different values to specify the duration for each subroutine individually.

Please note that the DELAY command does not have a default behavior if you do not specify a value. If there is a value on the stack, it will use that value, otherwise it will trigger an error.

Brandon