Iam not sure what i have to change in the code or what iam missing there, to get it work with Micro Maestro 6-Channel USB controller. Looks like my contoller use COM port 21 and 22.
I have changed python code to use port 21 and it seems to connect when i run it (cant connect with Maestro Control Senter same time). Tried port 22 too but no luck.
I can control servos with UscCmd.exe and --list shows me:
1 Maestro USB servo controller device found: #00022983
First of all, if you haven’t done so already, please go into the Maestro Control Center and set the Serial Mode to be “USB Dual Port”. This tells the Maestro to listen for serial commands coming to its Command Port, which is one of the two virtual COM ports it presents to the PC.
You don’t need to change the code for loading the serial port library or opening the serial port, but you do need to change the code that decides which bytes to send to the port, because the Maestro uses a different serial protocol than the Pololu USB 16-Servo Controller.
Do you understand what the code above does? You will need to modify the bytes specified there to be Maestro serial commands. The Maestro’s serial protocol is described in the Serial Interface section of the Maestro User’s Guide. The main command you will want to use is called “Set Target”.
Got it working now with Python using siple os.system(“UscCmd --servo 0,4500”). Iam not using direct hex because i didnt find easy way to calculate hex values i want… is there any tools? I didnt find how to see position in hex values from UscCmd tool.
Now i have another question. Is it possible to add steps without knowing previous position? Like if the status position is 4500 and i want to add +500 and servo should go to position 5000.
Tried to UscCmd --servo 0,+500 but it goes to 500
serialBytes[0] = 0x84; // Command byte: Set Target.
serialBytes[1] = channel; // First data byte holds channel number.
serialBytes[2] = target & 0x7F; // Second byte holds the lower 7 bits of target.
serialBytes[3] = (target >> 7) & 0x7F; // Third data byte holds the bits 7-13 of target.
You should be able to understand what this code does and convert it to Python. Python has bitwise operators >> and & just like C. You might need to change the syntax used for assigning to an array, and remove the semicolons and comments.
No, we don’t provide an easy way to do that. You can just make an array of 6 integers in your program to keep track of the current targets of the servos.
Well the hard way is to run “UscCmd --status”, parse the output to figure out the current target of the servo, then add the number to it in your program, then run “UscCmd” to set the target. I would not do this. I don’t think this will “speed up” anything.
The array of integers is a much better idea. You should be able to write a Python function that takes care of the details for you so your code can be clean. An example use of such a function would look like this:
servo_target_add(0, 300) # Increases the target of servo 0 by 300.