i bought the “Mini Maestro 12-Channel Servo USB Controller” 4 Days ago and i find it amazing 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)
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 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 when i copy them into the MaestroEasyExample.cpp he needs the whole namespace Pololu { … } crap and this drops again errors
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?)
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.
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_GET_VARIABLE = 0x80, BITMASK_FOR_COMMAND_GET_VARIABLE = 0xC0,
COMMAND_GET_STATUS_FLAGS_HALTING = 0xA0+19,
COMMAND_GET_STATUS_FLAGS_OCCURRED = 0xA0+21,
COMMAND_SET_TARGET = 0xC0, BITMASK_FOR_COMMAND_SET_TARGET = 0xE0,
COMMAND_SET_TARGET_LOW_RES_REVERSE = 0xE0,
COMMAND_SET_TARGET_LOW_RES_FORWARD = 0xE1,
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 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 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 There’s also no error
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.
#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->Open();
test->Write(serialBytes, 0, 4);
test->Close();
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.