Maestro won't run sequence and returns error code 0x0100 when trying to trigger sequence from Raspberry Pi

Problem: Maestro won’t run sequence and returns error code 0x0100 when trying to trigger sequence from Raspberry Pi

I have a Mini Maestro 12 being used to control 6 servos to move eyes and eyelids on an animatronic head and also to switch on/off leds within the eyes.

I have programmed a single sequence using the Pololu Maestro Control centre on a windows PC.
The serial mode is set to “USB Dual Port”
This sequence can be saved to the Maestro and played without any errors.
See settings file maestro_settings.txt attached.

The Maestro needs to be triggered by a python script running on a Raspberry Pi 3.
The Raspberry Pi has been setup with the Maestro python code using instructions from https://github.com/FRC4564/Maestro.

I can communicate with the Maestro and move one of the servos using the following code on the Rasberry Pi without any errors or issues.

# testServo.py code in python
# Assumes the maestro python files are in a subdirectory call Maestro of  /home/pi
import maestro
import time

# Initialize the Maestro controller
# Replace 'COM3' with your specific serial port (e.g., '/dev/ttyACM0' for Linux) 
servo = maestro.Controller('/dev/ttyACM0')

# Set acceleration for servo 0 (optional, 0 for unrestricted)
servo.setAccel(2, 4) 

# Set speed for servo 0 (optional, 0 for unrestricted)
servo.setSpeed(2, 10) 

# Set target position for servo 0 (e.g., 6000 for center position)
# Target values are typically in quarter-microseconds (e.g., 4000 = 1ms, 8000 = 2ms)
servo.setTarget(2, 6000) 

# Pause to allow the servo to move
time.sleep(1.5) 

# Move to another position
servo.setTarget(2, 4000) 
time.sleep(1.5)

# Close the connection to the Maestro
servo.close()

However if I run the following code to trigger the sequence(0) :

# test.py code in python
	# Assumes the maestro python files are in a subdirectory call Maestro of  /home/pi
	import maestro
	servo = maestro.Controller('/dev/ttyACM0')
	# where (0) is the script number saved to the maestro board
	servo.runScriptSub(0)
	servo.close()

The red LED on the Maestro board lights up and the sequence stored on the board does not activate.

I can return the error code and clear the error using the attached getMaestroErrors.py file.
Which returns
Maestro Error Flags: 0x00100
Maestro Error cleared.

Which turns off the red LED on the Maestro board.

This was working in the past but after replacing some servos and reinstalling the OS and all the software on the Raspberry Pi, I can’t get it to work again.
When it worked previously the red LED on the Maestro board would appear but it still triggered the sequence and it moved the servos as expected.
I have also tried another new Mini Maestro 12 board and a new Raspberry Pi.

I am at a loss as to what I am doing wrong so any guidance would be appreciated.
Thank you.

John
files attached:
maestro_settings.txt
testServo.py
test.py
getMaestroErrors.py

getMaestroErrors.py (1.6 KB)
maestro_settings.txt (5.9 KB)
test.py (327 Bytes)
testServo.py (847 Bytes)

Hello, John.

I am sorry to hear you are having problems with getting your Maestro script to run from your Raspberry Pi; thank you for including a thorough explanation of the problem and what you have tried so far.

It looks like you are probably trying to start your script from the beginning, but since it is not declared as a subroutine your servo.runScriptSub(0) is actually starting at frame_0..11 (the first subroutine declared). To have it start at the beginning, you can add sub main_loop before begin and a quit after repeat (although it shouldn’t ever reach that part of the code). Could you try that and see if it fixes the problem?

Brandon

Hi Brandon,

Thank you for the response. It didn’t work directly but it made me try
something else which did work.
I was using the Copy Sequence to Script button in the Maestro Control
Center which created the following which doesn’t work:

# Sequence 0
begin
   2500 5964 5984 4887 7451 4555 7569
   0 0 0 0 0 0 frame_0..11 # Frame 0
   2000 6179 5944 5984 5279 6000 6000 frame_2..7 # Frame 1
   1500 6943 7980 5846 6336 4633 6414 frame_0..5 # Frame 2
   1500 5964 5984 frame_0_1 # Frame 3
   500 4868 7471 3968 7804 frame_2..5 # Frame 4
   1000 6747 5494 5338 5905 frame_2..5 # Frame 5
   1500 3968 3968 7745 4300 6355 4242 frame_0..5 # Frame 6
   500 5944 5944 4026 7706 3968 7373 frame_0..5 # Frame 7
   1000 5807 6081 5865 5729 frame_2..5 # Frame 8
   1500 7256 7608 frame_0_1 # Frame 9
   1000 5984 5964 6727 5455 6551 4927 frame_0..5 # Frame 10
   500 4183 7432 4105 7393 frame_2..5 # Frame 11
   3000 7941 3968 7510 4555 frame_2..5 # Frame 12
   1000 4046 7788 4222 8000 0 0 frame_2..7 # Frame 13
repeat

I then, for no apparent reason but desperation, used the Copy all
Sequences to Script
button which added

# Sequence 0
*sub Sequence_0*
   2500 5964 5984 4887 7451 4555 7569
   0 0 0 0 0 0 frame_0..11 # Frame 0
   2000 6179 5944 5984 5279 6000 6000 frame_2..7 # Frame 1
   1500 6943 7980 5846 6336 4633 6414 frame_0..5 # Frame 2
   1500 5964 5984 frame_0_1 # Frame 3
   500 4868 7471 3968 7804 frame_2..5 # Frame 4
   1000 6747 5494 5338 5905 frame_2..5 # Frame 5
   1500 3968 3968 7745 4300 6355 4242 frame_0..5 # Frame 6
   500 5944 5944 4026 7706 3968 7373 frame_0..5 # Frame 7
   1000 5807 6081 5865 5729 frame_2..5 # Frame 8
   1500 7256 7608 frame_0_1 # Frame 9
   1000 5984 5964 6727 5455 6551 4927 frame_0..5 # Frame 10
   500 4183 7432 4105 7393 frame_2..5 # Frame 11
   3000 7941 3968 7510 4555 frame_2..5 # Frame 12
   1000 4046 7788 4222 8000 0 0 frame_2..7 # Frame 13
*  return*

I applied the settings and it now works.
It still turns on the error LED with error code 0x0080 but it doesn’t
appear to stop it working.

Thank you for your help, this was causing more stress than you can imagine.

Kind regards,
John Balthazar

I am glad to hear you got it working how you want!

The 0x0080 error is a Script call stack error (i.e. bit 7), which occurs when a bug in the user script has caused the call stack to overflow or underflow. It is probably happening when the script reaches the return command at the end of Sequence_0. Since your script started at this subroutine, there is nowhere for it to return to. If that’s the cause, replacing the return command with a quit command should fix it.

Brandon

Hi Brandon,
That fixed it! No red LED on the Maestro now.
Thank you again for your prompt response, your replies were most helpful.

Kind regards,
John Balthazar

1 Like

This works on my Pi 5

from Maestro import maestro
import time

servo = maestro.Controller('/dev/ttyACM0')
channel = 1

# Set full speed (0 = fastest)
servo.setAccel(channel, 5)  # optional, smooth acceleration
servo.setSpeed(channel, 0)

# Sweep from min → center → max
positions = [4000, 6000, 8000]

while True:
    for pos in positions:
        print(f"Moving to {pos}")
        servo.setTarget(channel, pos)
        time.sleep(0.5)