Simplest python command

Hi,

I’m try to get through the firsts hoops here, so please bear with me - very new to this.
In order to test communication with the Mini Maestro 24 through the virtual COM port (with Python); I’m using this very short command:

import serial
import c4d

def main():
    ser = serial.Serial(2)
    ser.baudrate = 9600
    
    ser.write(chr(0x84)+chr(0x17)+chr(0x40)+chr(0x3E))

if __name__=='__main__':
    main()

Very simple command; Set target (0x84) to an LED connected to channel 23 (0x17), attempting to set it to 8000 (0x40, 0x3E).
The serial module is imported, and the communication to port COM3 is successful, as there are no error thrown in the console. However, when I execute the code, the green LED on the Mini Meastro blinks (it’s on, and at execution it goes off quickly and goes back on) but nothing happens - the LED connected to channel 23 doesn’t light on.

Anyone knows what I’m doing wrong? What does a quick blink of the green LED on the mini maestro mean? And why doesn’t my LED turn on!?
The Mini Maestro is set to USB dual port, and everything works fine from the Maestro Control Center. I made sure no script is running on startup, too.

Thanks,

-A

Hello, alevesque.

Since the green LED is blinks, it means you are succeeding in sending USB data of some kind to the Maestro. USB Dual Port is the correct serial mode. Your 4-byte serial Set Target command looks good. Maybe you are sending the bytes to the wrong serial port. Are you in Linux? Try this code:

import serial
serial.Serial("/dev/ttyACM0").write("\x84\x17\x40\x3E")

It sounds like you want short commands, so I have simplified this as much as possible. I haven’t tested it though.

If that doesn’t work, try changing “/dev/ttyACM0” to “/dev/ttyACM1”.

I assumed you are using Linux, but if you are actually using Windows, change “/dev/ttyACM0” to “COM3” or whatever COM port your Maestro’s Command Port is on according to your Device Manager.

–David

Amazing!

You saved me, David! I am unsing windows, actually - but you pointed me toward the source of the problem: I wasn’t using the right port!
It was sending bytes to the TTL port, instead of the command port. So the pololu was indeed receiving something (hence the led blinking), but not at the right place.

Changing serial.Serial(2) to serial.Serial(3) solved it!

Woah, now that I got that working… not much is in the way. Very exciting stuff, thank you so much.
That allows me to control the board from within Cinema 4D (a 3D animation software), and either command servo movement according to the 3D model movement in real-time, or simply capture the arm motion in the timeline for further post-production use.

Yeah!

-A