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

Micro maestro - delaying problem


Hello. I have problem with delays on my maestro mini 12. Delays are 3 times slower then they should be.

I’m having delays in seconds. I did that like it is described in example script:

sub seconds
  begin dup while
    1 minus 1000 milliseconds #another subroutine to include other subroutines
  drop return

sub milliseconds
  begin dup while
  1 minus 1 delay
  button_check #subroutine to check if button is pressed
  battery_check #subroutine to check if battery is low
  led_blink #led-on 50 milliseconds every 3 seconds
drop return

The problem appeared when I added led_blink subroutine:

sub led-blink
  get_ms 5 peek minus
  4 peek less_than
    8000 8 servo
    4000 8 servo
    get_ms 5 peek minus
    3 peek greater_than
      get_ms 5 poke

And here are variables to go first on stack when the script starts:


I’m assuming that my script is to complex and demanding for maestro to process it in real time.
Is there some other way to control LEDs and Servos independently and to check button presses in between delays?
I can even post the whole script if someone is willing to take a look at it and maybe offer some solution to my problem.

Thank you


I forgot to add repeat command in milliseconds subroutine



It is not clear to me if you are saying that you solved your problem by adding a REPEAT command or if you are just making a correction to your first post. If you are still having the problem can you post your entire script? Also, can you describe what you expect to happen and what actually happens?



Hi Brandon.
I wrote a part of script that is making me problems from my head and I forgot to close the loop. It does not solve the problem. Repeat should be before drop return.
Yesterday I measured my delays with stopwatch and they are actualy 4 times slower. Temporarily I solved the problem by adding “4 divide” before begin command of milliseconds subroutine.

If I post the whole script, you would probably want me to add comments on each part of the script.
Since I don’t have them (in English) it will take me some time to translate them so you can understand.
Please let me know if you would want to see the whole script.

How do I post a script or parts of it to be seen as script and not as normal text?


Hello again.

I did some comments in my script and I am posting it as a file.
Before you try to solve my problem I would like to shortly explain for what I am am using it for,
so you can visualize it and maybe understand what I am trying to achieve.

I am competing in free-flight modelcompetitions.
These airplane models are not radio-controlled.
They are flight preset.

They are towed in air by 50 meter slimrope. The rope is attached on a hook.

When I have it in the air attached on a hook, I can go around with it and search for a thermal air.
And when I feel that plane is pulling me up, I can detach the rope and the plane starts to fly.

On competition it is the time of flight that counts. A timekeeper is measuring time till the plane touches
ground or reaches a maximum of 180 seconds of flight (might very).

Because the plane flies by itself, it goes in the wind direction.
Sometimes (in the strong wind) it goes a few kilometers. To be able to see it so far, I have installed an LED.

If it goes away to far, then I have to
search for it. Sometimes a plane lands somewhere for example in the
cornfields and is hard to find.
But when I am near it, I can search for it with RC button (with it, I can also end a flight if the plane
goes towards the trees for example)

And here is my problem:

In my script I am trying to achieve that servos and LED are working indepentently.
LED blinks every 3000 milliseconds for 50 milliseconds during the flight of the plane
and servos are working with delays. These delays are set in the BUNT and FLIGHT subroutines.

Maybe I place the wrong place to call an led-blink-flight subroutine. Even if I remove a call for this
subroutine and leave the other two (you will see in the script), it is still not delaying servos as it should.
Then the delays are slower for a lesser factor which is better but also not good.

Sorry for the long introduction, but it maybe helps you to find a problem and solution.
Also, I might have used some wrong terms in this post because we don’t speak English where I live.

Thanks and have fun because I already gave up.

FREE FLIGHT - F1A.txt (8.6 KB)


Thank you for the additional information and for posting your script.

From your description of the problem and looking through your code, I suspect the problem you are seeing is mostly within your milliseconds subroutine. For the while loop in this subroutine to work correctly, all commands (other than 1 delay) would have to happen in a negligible amount of time, especially since they run with every loop. For example, even without the led-blink-flight subroutine being called, the RC-button subroutine, low-battery subroutine, and IF statements probably take around 2ms to process, so your while loop would be taking about 3ms or so for each loop instead of the 1ms being assumed.

One way to solve this would be to use the same kind of non-blocking delay that you do inside of the led-blink-flight for the milliseconds subroutine (instead of using the while loop to count down a timer). Since this uses GET_MS to measure the time that has passed, it wouldn’t rely on the specific timing of the loop.



Thank you Brandon for a given solution. I already thought of that too, but I did not have a will to rewrite this part of the script. I will try now. Don’t know exactly where to start, but if run in to problems I will contact you.

This is my fourth plane that uses Maestro controller. It is an upgrade to my first three ones which are using 6 channel Maestro.
The script is similar, but the plane has one servo less, no LED, no beeper and no battery voltage detector. The milliseconds subroutine calls out only RC-button subroutine. One those three project I did not have the same problem.
How come?

I am very pleased that something like Maestro even exist thanks to you guys at Pololu.
Maestro has very user friendly internal scripting and customer support on this forum is the best.
Less than a year ago I bought my first Maestro and a had no knowledge on how to write a script. Now I can say that i am fairly good at it.

Thank you Brandon and to all your colleagues. Keep on the good work


I am glad you have had good experiences with the Maestro; thank you for the kind words.

I cannot say for sure why your other planes did not have the same problems, but I suspect the loop was much shorter if it did not have all the features you mentioned. Also, the PEEK and POKE commands (only available on the Mini Maestros) are more time consuming than other commands like GET_POSITION, so that might have exaggerated the problem so it was more noticeable.