Controlling Micro Maestro using Adafruit M0 Feather Express or Arduino Uno

’m having trouble getting the Arduino code for the Micro Maestro through an Arduino Uno or an Adafruit M0 Feather Express. My goal is to control two servos using the Adafruit M0 Feather Express.

Code

I’m trying out a simple Arudino sketch to set the target to 1500 then move to 500 after a short delay. But the Maestro does not respond. It moves to the last position used in the Maestro control center software.

Here’s the modified version of in the Maestro’s Arduino examples folder:

#include <PololuMaestro.h>

#ifdef SERIAL_PORT_HARDWARE_OPEN
  #define maestroSerial SERIAL_PORT_HARDWARE_OPEN
#else
  #include <SoftwareSerial.h>
  SoftwareSerial maestroSerial(10, 11);
#endif


MicroMaestro maestro(maestroSerial);
//MiniMaestro maestro(maestroSerial);

void setup()
{
  // Set the serial baud rate.
  maestroSerial.begin(9600);
  Serial.begin(9600);
}

void loop()
{
  Serial.println("Setting target servo 1 to 1500");
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  maestro.setTarget(0, 1500);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW

 
  // Set the target of channel 0 to 500, and wait 1 second.
	Serial.println("Setting target servo 0 to 1000");
	digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  maestro.setTarget(0, 1000);
  delay(1000);
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
}

This results in no change in the PWM values and the servos do not move. The yellow LED is solid for a bit then blinking.

Setup

  • Arduino Uno or Adafruit M0 Feather Express
    • Rx line is connected to an Adafruit level shifter (TXB0104) low voltage line. Since both boards output 3.3V and the Maestro takes in 5V.
    • 3.3V, GND, lines connected to appropriate pins on level shifters low voltage side
  • Adafruit TXB0104 Level shifter
    • High inputs connected to Micro Maestro GND, RX and TX lines
    • Output Enable (OE) pin connected to 3.3V line.
  • Micro Maestro
    • Batt and GND lines connected to a bench top power supply configured for 5V.
    • Port 0 is connected to Actobotics PWM display that displays a number for the PWM output. Or its connected to a Hitec D645MW Servo.
    • Maestro’s VIN serial line is connected to Batt 5V rail.
    • Maestro configured to operate at fixed baud rate of 9600

Troubleshooting

  • Micro Maestro works as expected while connected to USB to Maestro Control Center software. I’m able to move the slider and change the PWM values. Additionally, when servos are connected they move to the new target values. I’m able to set the speed and acceleration also.
  • I’ve connected the Arudino Uno and the Adafruit M0 Feather express to one another to see if one can set the commands over the Tx line and receive the command on the other board. Data is sent, but I have not tried to decode the protocol.
  • Within the sketch, I’ve tried sending the Pololo Maestro Compact Protocol commands directly as HEX using this code:
void setup() {
  // initialize both serial ports:
  Serial.begin(9600);
  Serial1.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  Serial.println("Sending Data across Tx pin");
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on
  delay(100);                       // wait for a second
  // Pololu compact commands from user guide
  Serial1.write(0x84);
  Serial1.write(0x00);
  Serial1.write(0x70);
  Serial1.write(0x2E);
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off
  delay(1000);
}

This results in the yellow LED being solid for a bit then blinking.

  • I’ve tried to connect a Raspberry Pi directly to serial and run the maestro.py code found at: https://github.com/FRC4564/Maestro . Maestro configured to dual mode in control center. There is no movement on the servos. Additionally, the red light on the Maestro is solid. In Maestro control center this shows up as a Serial Protocol Error.
  • I’ve tried runing the umaestro.py (also from [https://github.com/FRC4564/Maestro]) in CircuitPython on the Adafruit M0 Feather Express. This results are the same as the Raspberry Pi.

I would love some additional troubleshooting steps. Or do I just have a bad board that doesn’t accept commands over the RX lines?

Hello.

Thank you for including so much information about what you have tried so far. The first thing I noticed was that it looks like you are sending your target positions in units of microseconds. The setTarget() command uses units of quarter-microseconds like Maestro scripts, so to set the target to 1500us, you would call maestro.setTarget(0, 6000). Since your target values were likely lower than the minimum configured for that channel, the Maestro would have used the configured minimum (992us by default) for both of your setTarget() commands.

If changing that does not work, could you try running the unmodified “Basic.ino” example from the library to see if you get any response from channel 0 on the Maestro? If you get no response could you post some pictures of your setup that show all of your connections, as well as your Maestro settings file? You can save your Maestro settings file by selecting the “Save settings file…” option in the “File” drop-down menu of the Maestro Control Center while the Maestro is connected.

Brandon

@BrandonM,

That worked. You are right I was inputting the PWM values directly. I ran the basic.ino and the Smooth motion example. They worked perfectly.

Thanks for catching my silly mistake.

Hopefully,I’ll be able to stick this controller into the next round of prototypes I send out to the field.

2 Likes