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

Pololu Forum

Mini Maestro 12 overflow error

Hi

I want to communicate an Arduino Mega with my MiniMaestro via Serial port. The idea is that the maestro stays doing nothing until it receives a command from the arduino. Once the maestro finishes doing the subroutine I want the maestro to go back to do nothing. The communication is working well, the problem is when the subroutine has ended and the maestro goes back to do nothing. When I run the script, the part of the script in which maestro does nothing works well, but when it returns back to that part of the script after doing a subroutine the overflow error is triggered. It says that 126 of 126 levels are used. This is the code. I get it from the arduino examples that come with the library. What am I doing wrong? I tried also blinking a led instead of doing nothing, but it still triggers the same error.

# Don't do anything by default.
begin
  led
repeat

# Subroutine 0
sub alternate_mid_to_high
    6000 0 servo
    1000 delay
    7000 0 servo
    1000 delay
  return

# Subroutine 1
# Expects the delay time to be on the top of the stack
sub alternate_mid_to_low
  begin
    6000 0 servo
    1000 delay
    5000 0 servo
    1000 delay
  repeat

sub led  
  900 100
  led_on delay
  led_off delay
  return

Hello.

It sounds like you are using the ‚ÄúRestart script at subroutine‚ÄĚ command from your Arduino Mega, and telling the Maestro to restart at subroutine 0. If that is the case, please note that when the Maestro finishes the subroutine and reaches the return command, it will not know where to return to (i.e. since it was restarted it does not have knowledge of where it was).

If you truly want the Maestro to ‚Äúdo nothing‚ÄĚ when it is not running a subroutine, you can end your subroutines with a quit command instead of return.

If you want the Maestro to go back to blinking the LED as it looks like you are trying to do, you could change your led subroutine to loop endlessly and call it at the end of your other subroutines (before the return command), like this:

# Subroutine 0
sub alternate_mid_to_high
    6000 0 servo
    1000 delay
    7000 0 servo
    1000 delay
  led		#enter the led subroutine before reaching the return command
  return


sub led  
  begin		#add a begin command to start the loop
    900 100
    led_on delay
    led_off delay
  repeat		#and change return to repeat to close the loop

Brandon

Thanks BrandonM! Your explanation was great! Thanks to you now the code is running perfectly.

1 Like