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

Pololu Forum

Maestro Stack Overflow

As a newbie, I’m sure this question has been asked many times, however I’m not find a solution to my issue when reviewing past posts.

I’m using an 18 channel Maestro and have set up to very basic sequences, both of which work well when executed from the Pololu Maestro Control Center. When executing them from Arduino code, I get the stack overflow/underflow error.

Any guidance would be greatly appreciated!

My Maestro Script…


### Sequence subroutines: ###

# Front HP Sequence 1
sub Front_HP_Sequence_1
  500 3968 0 0 0 0 0 
  0 0 0 0 0 0 
  0 0 0 0 0 0 frame_0..17 # Move Front HP Up
  500 8000 frame_0 # Move Front HP Down
  return
# Front HP Sequence 2
sub Front_HP_Sequence_2
  500 6903 5533 6328 5320 6004 5868 
  0 0 0 0 0 0 
  0 0 0 0 0 0 frame_0..17 # Frame 0
  500 6444 4711 frame_0_1 # Frame 1
  return

sub frame_0..17
  17 servo
  16 servo
  15 servo
  14 servo
  13 servo
  12 servo
  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
  0 servo
  delay
  return

sub frame_0_1
  1 servo
  0 servo
  delay
  return

Hello.

It looks like all of your subroutines end in RETURN commands, but as explained in the “Serial Script Commands” section of the Maestro user’s guide, they should not end this way if you want to start them through serial commands since there is nowhere to return to. Instead, they should end with a QUIT command.

- Patrick

1 Like

Thank you so much, that resolved the problem. Side question… This code was generated by the control center, would there be a better format that should be used?

When you say the code was generated by the control center, I am presuming you mean that you used the Maestro Control Center’s sequencer. The sequencer certainly has its limitations, but if your Maestro is doing what you want it to do, then I do not think it is worth changing your code.

However, you could always program Maestro scripts yourself if you ever have a need where the sequencer is too limiting or if you just want to develop your programming skills. You can learn more about what would be involved with that by reading “The Maestro Scripting Language” section of the user’s guide. Also, the Maestro scripting language is very similar to a stack-based programming language called Forth so you might find resources pertaining to Forth useful.

- Patrick

Thanks Patrick, you’ve been very helpful!!!

1 Like