Arduino Uno - Micro Maestro

Hello,

I have succesfully connected my servo (HS785HB) to the micro maestro and if I test it with my PC everything is okay.

But if I now try to connect the maestro the the Arduino I can not get the servo moving.

I have connected the 5V and GND from the Arduino to the maestro. Power for the servo comes from a battery.
Pin 7 of the arduino is used to perform a reset of the maestro.
The device ID is set to 0 by the PC software.

The yellow LED flashes 2 times each second.

I use the following code on my Arduino:

#include <SoftwareSerial.h>
#define txPin 4 
#define rxPin 3

SoftwareSerial mySerial(rxPin, txPin);
void setup()// run once, when the sketch starts
{
  pinMode(7,OUTPUT);
  pinMode(7,HIGH);
  delay(50);
  pinMode(7,LOW);
  
  mySerial.begin(9600);
  delay(1000);  
}

void loop()
{
   delay(1000);
   set_target(0, 8000);
   delay(1000);
   set_target(0, 4000);
}


void set_target(unsigned char servo, unsigned int target)
{
    mySerial.write(0xAA); //start byte
    mySerial.write((byte)0x00); //device id
    mySerial.write(0x84); //command number
    mySerial.write(servo); //servo number
    mySerial.write(target & 0x7F);
    mySerial.write((target >> 7) & 0x7F);
}

Is there anything wrong in my code or whats going on?

Thanks
Stefan


Hello.

What serial mode is your Maestro configured to be in? You can see this in the Serial Settings tab of the software.

–David

Hello,

The device ist set to “UART, fixed baud rate: 9600”

It looks like you are leaving pin 7 low, which is connected to the Maestro’s reset line, so that would prevent the Maestro from running. You said the LED was blinking twice per second though, which would mean the Maestro was running, so I’m not sure what is happening. Please try bringing the reset line high some time before the end of your setup() function.

Also, this shouldn’t cause the problem, but your serial bytes are not quite right. Please try replacing those lines with this:

    mySerial.write(0xAA); //start byte
    mySerial.write(12); //device id (assuming it is still at the default value)
    mySerial.write(0x04); //command number with MSB cleared
    mySerial.write(servo); //servo number
    mySerial.write(target & 0x7F);
    mySerial.write((target >> 7) & 0x7F);

–David

Thanks for your help. I could now solve the problem. Now I have 3 functions to set the target. Each for a different protocol.

Is there an existing library to communicate with the maestro through an arduino?

Sorry but I have one more question.

In the PC tool I have set a minimum of 688 and a maximum of 2496.
How can I convert these values to drive the servo with the pololu protocol? What values do I have to set?

Thanks.
Stefan

edit: okay i did check it with the pc tool. everything is okay now. i only have to multiply the value by 4.

I am glad you were able to solve your problem, Stefan. No, we do not have an Arduino library for the Maestro.

–David