Mini maestro USB Servo Controller and C++


i bought the “Mini Maestro 12-Channel Servo USB Controller” 4 Days ago and i find it amazing :smiley: But now i’ve got a Problem. I use the controller to controll my RC-Car from the PC.
But there is the Point… i can’t figure out, why the Servos nearly react instantly when i’m using the “Pololu Maestro Controll Center” (when i pull the pointer), but if i use “usccmd” in my C++ Programm (or console) it has a reaction time about 0,5-1 sekond, which is defenitly to slow, when i want to controll my RC-Car (with my Joystick) :frowning:

i usually use commands like “usccmd --servo 0,8000”.

I think it sould be faster, when i use the UsbWrapper.dll and usc.dll, but as described in this topic

there are no .lib or include files, so that i can’t use them :cry: and when i want to use the MaestroEasyExample.cpp i’ve got the Problem that the TrySetTarget() Funktion is defined somewhere else… when i wan’t to copy the function into the MaestroEasyExample.cpp he needs the other two Functions, which are in the MainWindow.h :confused: when i copy them into the MaestroEasyExample.cpp he needs the whole namespace Pololu { … } crap and this drops again errors :imp:

so you see i’m a bit confused and i don’t now what to do… is there an other way to controll the servos from C++ that fast, as they are controlled with the Controll Center?
or has someone compiled a .lib that i can use in my Project?
(or can you publish the Memory Adresses of the “pointers” so that i can change the values with my Programm?)

greetings from europe,

Yes, there is significant overhead when starting up UscCmd or shutting it down so it is not really intended to be used for rapid updates or real-time control. In my experience though, it has been faster than 0.5 seconds, but that depends on your computer.

What kind of C++ are you using? If you are writing managed (.NET) C++ then you can easily use them the same way you would use any other .NET assembly. If you are writing unmanaged C++, then you probably can’t use them.

The example entitled “MaestroEasyExampleCpp” in the Pololu USB SDK should compile just fine without any modifications. I tested it Visual Studio 2008. Did you follow the instructions from the USB SDK’s readme? If those instructions don’t work for you, please tell me the first step that doesn’t work and what error messages you get.

If you can’t our native USB libraries working then you could send commands to the Maestro via the virtual COM port instead. Be sure to put your maestro in USB Dual Port serial mode first. Consult the Maestro User’s Guide for information on the serial command protocol that the Maestro uses. Search for something like “serial port c++” online and you will find examples for how to send and receive bytes from a serial port.


Here’s an example [libusb] linux/windows set position with unmanaged C++
Assuming you’re using windows you’ll want to look into the windows back-end of libsub

thank you for the replies!

i thought the way of “carrotSnack” would be the easiest, so i tried his way.

i had to modify “protocol.h” like this:

typedef unsigned int u32;
typedef unsigned short int u16;
typedef unsigned char u8;
typedef signed short int s16;

enum jrkCommand
    COMMAND_MOTOR_OFF                  = 0xFF,

as Visual Studio 2010 C++ can’t compile the binary 0b10000000 etc. so i changed it to HEX.
i included the libusb (the windows version) and used the code you postet here [libusb] linux/windows set position with unmanaged C++ with the change from (ushort) to (unsigned short).

But my servos don’t move :open_mouth: i changed my controller to USB Dual Port with the Maestro controll center, but theres no reaction when i use my C++ programm oÔ
what values does Position accept? i tried the values of the controll center (1000-2000)

EDIT: i’m sure that the mini maestro 12-Channel usb servo controller gets the command, as everytime i use “setTarget(Position,Servo)” the green LED flashes one time. I also tryied the values from usccmd (4000-8000) -> no reaction just a flashing LED.

EDIT2: now i did the same over Serial-Port :confused: i send the Bytes 0x84, 0x02, 0x70, 0x2E (from the Documentation) to the controller(in my Case COM3 with Baudrate 9600), but again the Green LED just flashes one Time and the Servo does not move :confused: There’s also no error :open_mouth:

What channel is your servo connected to?

Let’s work on your COM port program.

Could you try simplifying your program to the simplest possible thing that should work but doesn’t and post it here? Also, explain why you chose COM3 (the Maestro has multiple COM ports). Also, before you post, try using the Maestro control center to see if your command had any effect. You should move the servo on channel 2 to a position that is NOT 1500 us, then send the serial command, and see if the servo’s position changes back to 1500 us as expected.


ok here my code:

#include "stdafx.h"
#using <system.dll>

using namespace std;
using namespace System;
using namespace System::IO;
using namespace System::IO::Ports;

int _tmain(int argc, _TCHAR* argv[])
	array<Byte>^ serialBytes = gcnew array<Byte>(4);
	serialBytes[0] = 0x84; // Command byte: Set Target.
	serialBytes[1] = 0x00; // First data byte holds channel number.
	serialBytes[2] = 0x70; // Second byte holds the lower 7 bits of target.
	serialBytes[3] = 0x2E; // Third data byte holds the bits 7-13 of target.

	SerialPort^ test = gcnew SerialPort(L"COM3",9600);
	test->Write(serialBytes, 0, 4);

	return 0;

i choose COM3, because in the Hardware-Manager (from Windows) it shows me that this is the USB-Servo Controller Command Port. COM4 would be the TTL Port. My servo is at channel 0.
i changed the value of the servo to 1800 in the Controll Center. Then i changed the Controller to USB Dual Port and then i closed the Maestro Controll Center.
When i run my Programm the green LED flashes again, but the servo does not move.

test->Write(serialBytes, 0, 3);

You are only writing 3 bytes. Try writing all 4.


ouh **** sorry :blush:

i though 0,1,2,3 would be 4 :confused:
your right i put the value to 4 and it works :smiley:

but here it is 1:32 am so i will test tomorrow(or tonight^^) how this works with my joystick :slight_smile:

Best regards,

EDIT: the Serial Version is great! now the servos react enough sensetive and fast to controll my RC-Car (a off-road one with up to 40mph^^) from my PC :smiley: