Arduino and Maestro Polulu

Hello
I’m really so new in Robotic world but I have got Maestro Polulu 24 servo motors and Arduino Mega. I dont understand how can i control 18 servos through Arduino and Maestro Polulu?
and how can I connect them together?

Hello.

The easiest way is to have the Arduino send serial commands to the Maestro. The section titled “Connecting to a Microcontroller” in the Pololu Maestro Servo Controller User’s Guide has a wiring diagram for the hardware connections. You want to avoid using the serial port on pins 0 and 1 because that is also used to talk to the computer and program the Arduino.

Here is a blog post about using the Mini Maestro with an Arduino. The code he has there isn’t the simplest example code but the settarget function is an example of sending the set target command over serial.

- Ryan

hmm, that post is a bit elderly and there are some syntax changes if you’re using the latest version of arduino because newsoftserial is built in, not a separate library.
also i’m a she :stuck_out_tongue:

from https://github.com/nouyang/18-servo-hexapod/blob/master/pololu_aug17-2012.pde
the relevant changes are:

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

SoftwareSerial mySerial(rxPin, txPin);

void settarget(unsigned char servo, unsigned int target)
{
  target = map(target, 0, 180, 2400, 9500);
  mySerial.write(0xAA); //start byte
  mySerial.write(0x0C) ; //device id
  mySerial.write(0x04); //command number
  mySerial.write(servo); //servo number
  mySerial.write(target & 0x7F);
  mySerial.write((target >> 7) & 0x7F);
}

Hello, Orangenarwhals.

Thanks for posting the updated code, and sorry about not getting your gender right.

- Ryan

I just started using the maestro and ran into the same issue when trying to use it with my Arduino Uno. After reading through the user guide pololu.com/docs/0J40/all#5.e I decided to write a library that implements some of the main functions. Currently this is:

  • setTarget: sets the position of the servo
  • setServoSpeed: sets the speed the servo moves at
  • goHome: moves all servos connected to a device to their home position
  • getPosition: returns the current position of a servo
  • getErrors: returns information regarding the error state of servos (I have not tested this one yet).

The library, documentation and getting started code can be found here: github.com/gNSortino/PMCtrl. This is my first attempt at writing a serial interface so there may be a few issues but it’s worked out well so far. If there is interest in having me add additional calls or you would like to do this yourself let me know. I’d be happy to support this as it seems like Arduino and the Maestro are both complimentary.