[Resolved] Micro maestro + arduino uno serial don't work

Hi,

I have buy an Micro maestro and i want to play with my two servos with my arduino Uno.

I have connected TX maestro pin to arduino pin 4 and RX maestro pin to arduino pin 5 and gnd maestro pin to gnd arduino pin.
My first servo is connected to channel 0 ans second servo is connected to channel 1.
I can play with my servos with Pololu pc software and work fine. The device id is 12 and connection set to UART baud rate 9600.
Micro maestro is powered with 6V batterie and i have connected the vin pin of maestro to the pwr pin (batterie) of maestro itself.

I use this simple code:

#include <SoftwareSerial.h>
#define TXPIN 4
#define RXPIN 5

#define HONRIZONTAL 0
#define VERTICAL 1

SoftwareSerial maestro(RXPIN, TXPIN);
void setup()// run once, when the sketch starts
{
  // Define the appropriate input/output pins
  pinMode(RXPIN, INPUT);
  pinMode(TXPIN, OUTPUT);
  maestro.begin(9600);
  delay(1000);  
}
void loop()
{
  move();
}

void move() {
  
  settarget(HONRIZONTAL, 90);
  delay(1000);
  settarget(VERTICAL, 90);
  delay(1000);
}

//Send a Set Target command to the Maestro.
//Target is in units of quarter microseconds, so the normal range is 4000 to 8000.
void settarget(unsigned char servo, unsigned int target)
{
  target = map(target, 0, 180, 4000, 8000);
  maestro.write(0xAA); //start byte
  maestro.write(12) ; //device id
  maestro.write(0x04); //command number
  maestro.write(servo); //servo number
  maestro.write(target & 0x7F);
  maestro.write((target >> 7) & 0x7F);
}

But he don’t want to work :frowning: I don’t understand where is my error?
Th e yellow led blink 2/3 times per second and it’s all.

Can you help me please?

Hello.

It looks like you have connected the Arduino’s designated TX pin to the Maestro’s TX pin. That will not work and could possibly damage the boards, because both TX pins are outputs. You should start off with just a simple connection between the GNDs and a connection from the Arduino’s TX (4) to the Maestro’s RX.

–David

Hi David,

Thank you for your quick response.
It work better since i have plugged arduino TX and maestro RX (shame on me :blush: )
It work a little better because my servos move now. :slight_smile: But he don’t move like i want (i’m not sure to the target values to used). I don’t now if my process is the good:
1/ I connect my servo1 on channel 0 and servo2 on channel 1 of micro maestro.
2/ I connect maestro on usb cable and open Pololu maestro control center
3/ In the channel setting tab, i put min and max value for my servos (min & max values before the servo rotation arrives at the top and force)
4/ I apply and do my test in the status tab (i test min / max with the slidebar) (work fine for me, i can rotate normaly servos head to x at x+180° approx with no resistance)
For information i obtains min value: 528 / max value: 2304 / 8 bit neutral: 1500 / 8 bit range (+/-): 476.25 / period: 10ms / mode servo / on error : off
5/And i writte this values in my arduino code: target = map(target, 0, 180, 528, 2304);

But when i start arduino, my servo move only to 1° from left and righ.
I don’t understand what is my error in this case? :frowning:

#include <SoftwareSerial.h>
#define TXPIN 4
#define RXPIN 5

#define HONRIZONTAL 0

SoftwareSerial maestro(RXPIN, TXPIN);
void setup()// run once, when the sketch starts
{
  // Define the appropriate input/output pins
  pinMode(RXPIN, INPUT);
  pinMode(TXPIN, OUTPUT);
  maestro.begin(9600);
  delay(1000);  
}
void loop()
{
  move();
}

void move() {
  
  settarget(HONRIZONTAL, 0);
  delay(3000);
  settarget(HONRIZONTAL, 180);
  delay(3000);
}

//Send a Set Target command to the Maestro.
//Target is in units of quarter microseconds, so the normal range is 4000 to 8000.
void settarget(unsigned char servo, unsigned int target)
{
  target = map(target, 0, 180, 528, 2304);
  maestro.write(0xAA); //start byte
  maestro.write(0x0C) ; //device id
  maestro.write(0x04); //command number
  maestro.write(servo); //servo number
  maestro.write(target & 0x7F);
  maestro.write((target >> 7) & 0x7F);
}

Thank you for explaining the details of what you did. The units of the target in the Maestro’s Set Target command are quarter-microseconds so you need to multiply by four. Try this:

target = map(target, 0, 180, 528*4, 2304*4);

–David

Hi David,

Thank you very much for your precious help. It work better now :smiley:
I can use my tilt/pan module on my robot.
I think i’ll post a quick help guide on my blog to explain how to use micro maestro beacause i think it is not obvious to use (for a beginner like me).

See my blog for more informations (french blog): darylrobotproject.wordpress.com/

Thank! :slight_smile: