Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Maestro Arduino Servo Range Question

I am trying to figure out how to use the full range (180 degrees) of the servo on my robot using the Maestro Micro 6-channel Servo Controller. I have been doing various tests in a simplified environment so that I can learn what I need to do. I started with DavidEGrayson’s code from this forum post: Pololu maestro and arduino again.
David mentions that this code assumes a target range between 4000 and 8000. I’m not sure where the 4000 to 8000 comes from or how it’s applied in the code. I assume it may be for a servo that is controlled with a range of 1000 to 4000 milliseconds. In my case, I have a Hitech Servo HS-422 (servocity.com/html/hs-422_super_sport_.html), which has an input range of 600 to 2400 microseconds for 0 to 180 degrees

Here is my code.

void setup()
{
  Serial3.begin(9600);   // set up Serial communication with Maestro Micro 6-channel Servo Controller
                         // Serial Port #3 on Arduino Mega 2560
}

void loop()
{

  set_target(1,0);
  
  delay(1000);

  set_target(1,180);

  delay(1000);

}

void set_target(unsigned char servo, unsigned int servo_position){
  
  int target = map(servo_position,0,180,2400,9600);

  //Send a Pololu Protocol command
  Serial3.print(0xAA,BYTE); //start byte
  Serial3.print(0x0C,BYTE); //device id
  Serial3.print(0x04,BYTE); //command number
  Serial3.print(servo,BYTE); //servo number
  Serial3.print(target & 0x7F, BYTE);  
  Serial3.print((target >> 7) & 0x7F,BYTE);
}

Note that I’m using an Arduino Mega and I’m using the hardware serial #3. Also, I’m feeding an angle in degrees (0 to 180 degrees) into the function and then mapping it to the quarter-microseconds.

This sketch (and all the other variations I’ve tried) causes the servo to move 90 degrees rather than 180. Plugging in 4000 to 8000 microseconds (i.e. after removing the map function) also causes it to travel 0 to 90 degrees.

I don’t know how to change this little sketch to correspond to my 600-2400 microsecond range servo (2400 to 9600 quarter-micro-second range).

Can someone help me?

It appears that I should be able to use the Maestro Control Center software to configure the range to match my servo, which should theoretically solve the problem I’ve described above (I think). I’ve installed the software on my Windows XP machine. But when I plug the Maestro Micro 6 Servo Controller into my USB port nothing happens. Normally when you plug in a USB device a window pops up and asks to configure it, or at least it becomes visible in the status bar in the bottom right corner, but in this case nothing happens. I’ve tried it on two different computers. I’ve looked through the manual, and it appears that the OS should recognize it when I plug it in. Am I overlooking something? Is there something I need to do in order to get XP to recognize the Maestro has been plugged into the USB port?

I solved my problem.

In order for the Maestro to be recognized by the USB port, I needed to provide power to it on its power pins. This probably sounds obvious, but many USB devices draw power from the USB cable itself, so I didn’t think I needed to provide separate power to the Maestro in order for it to connect to the computer. So, in order for it to work, I provide power to the power pins from my Arduino (which is plugged into the computer on a different USB port), then I plug in the Maestro’s USB port. Once I did that, the Maestro lit up and the OS recognized the Maestro.

I then used the Control Center software to change the millisecond range to 600-2400 for my Hitec servos and then my code immediately started working the way I wanted it to.

Hello.

We have a FAQ about adjusting the servo range that you might want to check out. 4000 and 8000 are numbers with units of quarter microseconds, so they correspond to 1ms and 2ms.

I am glad you got it working. The Maestro should not require external power to be recognized by a computer when plugged into USB. How did you connect power to it? Have you made any modifications to the power connections on the board with jumpers or wires?

- Ryan