Arduino and Micro Maestro 6-Ch

Hi!

So I’ve read allot of the previous forum posts but I’m still having some trouble and have some questions.

II’ve got my Micro Maestro (usb) hooked up to a Arduino Mega. I’ve configured it with the windows software for UART Fixed baud rate 57692 (what it sets to when I put in 57600) with a 1000-2000 time range.

I’ve got +12V from a supply coming into the Arduino Vin and the +5V Vout powering both the chip and servos, and all my grounds are grouped. I’ve got the maestro RX pin connected to the Arduino TX (pin1), and I’m running with this code, cobbled together from various sources:

const int servo0 = 0;  
const int servo1 = 1;  

void setup() {
  Serial.begin(57692);
  servoSetSpeed(servo0,200);
  servoSetSpeed(servo1,20);

}
 
void loop() {
  
  int H=8000;
  int L=4000;
  delay(1000);
  servoMove(servo0,L);
  servoMove(servo1,H);
  delay(1000);
  servoMove(servo0,H);
  servoMove(servo1,L);
}

void servoMove(int servo, int pos)
{

  char cmd[6];
  cmd[0] = 0xAA;  // start byte
  cmd[1] = 0x00;  // device id
  cmd[2] = 0x04;  // command number
  cmd[3] = servo; //servo number
  cmd[4]=pos & 0x7F;
  cmd[5]=(pos>>7) & 0x7F;
  for ( int i = 0; i < 6; i++ ){
    Serial.write(cmd[i]);
  }
}

void servoSetSpeed(int servo, int speed){

   char cmd[6];
   cmd[0] = 0xAA;     // start byte
   cmd[1] = 0x00;     // device id
   cmd[2] = 0x07;     // command number
   cmd[3] = servo;
   cmd[4]=speed & 0x7F;
   cmd[5]=(speed>>7) & 0x7F;
   for ( int i = 0; i < 6; i++ ){
      Serial.write(cmd[i]);
   }
}

Problems:
*Even with the Windows control software I can’t seem to get full rotation from my servos
*The speed. Although one servo is set to a slower speed, it will only move that slowly randomly, otherwise it moves at full speed.
*The red LED flashes when I attach the arduino TX to the maestro RX
*When the USB programing cable (to the arduino) is plugged in, it works. When I have the Arduino USB cable unplugged from the computer the servos move sporadicly

I suspect that all these problems are related. But I can’t see how.

Questions:
*How do I set the servo to go to a specific angle, whenever I try a value other than 4000 or 8000 the motion is erratic.

Thanks!

Hello.

It sounds like you are trying to power the Maestro processor and the servos from the Arduino Mega’s 5 V regulator. I wouldn’t expect the regulator on the Arduino Mega to be capable of that; it can probably only supply a few hundred mA at most and you should ideally have 1 A per servo. A pack of AA batteries would be a better choice. I think most of your problems would go away if you got a better power supply.

Regarding the speed limit: Are you saying that you would expect the servo to slowly move back and forth, but occasionally it will randomly move at full speed? That could happen if the Maestro is getting reset, and the Maestro is likely to have brown-out reset problems because of the way you are powering things.

Do you have the Arduino’s GND connected to the Maestro’s GND?

Please see the Maestro FAQ entitled “How do I use my Maestro servo controller to get the maximum possible range of motion from my servo?” on this page:
pololu.com/catalog/product/1350/faqs

–David

Hi David,

Thanks for the reply, and happy New Year.

Thanks for the advice about the power supplies. So I’m now powering the Mestro and the Arduino with 12V from a bench supply and the servos with a separate output at 6V. All the grounds are tied together. That appears to have static red LED problem.

However, my servos are still not acting as expected given the code below.

First off with only one servo plugged in it does move back an forth between two angles, however when it arrives at final angle it then move back and forth a few degrees before stopping. When I let it run for a about 1min it stopps entirely, and I need to reset the power.

However, if I have two servos plugged in they both move with small random movements, and sometimes one stops and the other makes a rapid movement to one if the final angles.

I’ve tried new servos of the same make and model and they act similarly.

Regarding the range of motion. I followed the information in the FAQ and even using the provided software have been unable to get the servo to move its full range. This is less of a problem given the erratic behavior.

Any additional help you could provide?

Thanks,

const int servo0 = 0;  
const int servo1 = 1;  

void setup() {
  Serial.begin(57600);
//  servoSetSpeed(servo0,200);
//  servoSetSpeed(servo1,200);

}
 
void loop() {
  
  int H=8000;
  int L=4000;
  delay(3000);
  servoMove(servo0,L);
  servoMove(servo1,L);
  delay(3000);
  servoMove(servo0,H);
  servoMove(servo1,H);
}

void servoMove(int servo, int pos)
{

  char cmd[6];
  cmd[0] = 0xAA;  // start byte
  cmd[1] = 0x00;  // device id
  cmd[2] = 0x04;  // command number
  cmd[3] = servo; //servo number
  cmd[4]=pos & 0x7F;
  cmd[5]=(pos>>7) & 0x7F;
  for ( int i = 0; i < 6; i++ ){
    Serial.write(cmd[i]);
  }
}

void servoSetSpeed(int servo, int speed){

   char cmd[6];
   cmd[0] = 0xAA;     // start byte
   cmd[1] = 0x00;     // device id
   cmd[2] = 0x07;     // command number
   cmd[3] = servo;
   cmd[4]=speed & 0x7F;
   cmd[5]=(speed>>7) & 0x7F;
   for ( int i = 0; i < 6; i++ ){
      Serial.write(cmd[i]);
   }
}

Hello.

I am glad you are making progress. The behavior you describe is not normal. I think it is probably caused by some problem with your power suppply, servos, or how you wired things together. How much current does the 6V output supply, and can you give us more information about it? What model of servos are you using, and have you been able to use them without problems in another context? Could you post some pictures of your wiring? If you had to solder anything, a close-up of your solder joints would be good.

–David