Sunday, 30 December 2012

Controlling servos from a computer


The Pololu Maestro is a tiny USB device that, amongst other things, lets you control servos from a computer via an USB connection. To be more precise, it can control anything that is driven by a regular RC PWM signal, like an ESC controlling a brushless motor for example.

A Pololu Micro-Maestro (6 channels) controlling a servo

The device comes with a program that lets you try it out and play with the connected servos. It's called the Maestro Control Center. Even more interestingly, the device can be easily controlled by code. There are two approaches for that:
  • the native USB interface 
  • and the serial interface

The first one is available in C# and provides access to all the functionalities of the Maestro. The second one is available for any langage that can talk to a COM port, but it offers only a subset of the functionalities.

I gave the Serial Interface a go based on the Pololu examples, and once I saw I could do what I wanted I wrapped everything up in a nice cross-platform C++ library for everyone to use. I called it Polstro (a fusion of "Pololu" and "Maestro"). 

I tested it on a Windows desktop PC and a Raspberry PI. And it seems to work pretty well!

A Raspberry PI controlling a servo


Besides manufacturing sweet little devices, Jan at Pololu also keeps a blog where he shares his RC-electronics wisdom. I found his posts on servos very useful and interesting: