Avayanic Electronics Articles

 

Bipolar Stepper Microstepping Controller (Using the A3977)

 

 

Large DC Motor Controller (Using the TD340I)

 

 

11 RC Servo Controller

 

 

Inductive Load Driving

 

 

 

 

|<<>>|

11 RC Servo Controller

Although there are more than enough articles on RC Servo controlling, I wanted to explain how I implemented my SS-PortaSC11 controller.

Introduction:

RC Servos are one of the most versatile motors commercially available. Because of the internal closed loop control, these motors can not only work as positional devices, but when properly modified, they can also work as speed controlled motors.

Implementing DC motors with position and speed control, is no longer Alien Technology. Anybody can do it by putting a few chips together and programming a microcontroller. But RC Servos are already working and neatly packed, removing the hazzle of coming up with this portion of a robotic design or motion control application. And they are simply ready to be mechanically interfaced to practically anything!

There is only one little problem with RC Servo interfacing and it has to do with the signal needed to control the device. Ten years ago, this was a real problem. Today, it is the stuff we laugh at. Even a kinder garden kid could do it! Heck, I bet in a few years they will do RC servo programming, before they learn how to write their names on electric paper (I tell you, its coming!).

The “Not So” Science Behind the Servo:

You must have read this a few billion times before on all the magazines there are out there (Servo, Nuts and Volts, Make, Circuit Cellar, etc.). A servo receives a signal from a remote control (DUH! Is that why they are called RC servos?). This signal is nothing but a periodic square wave with a single piece of information: its pulse width. The pulse width determines the position as shown on the picture below.

 
Servo PWM

I could keep on boring you with all the details, but as I said, this has been documented far too many times. I just want to add one important detail. We can easily generate this PWM signal with any microcontroller today. Use an Output Compare module, and WALAS! There you go. Unfortunately, timer modules are not infinite. And in some microcontroller, there is just not enough of them.

We want to control as many RC servos as there is I/O pins on our micro. I assure you, there is no microcontroller on the market with a timer module per I/O pin. It would be ridiculously expensive! The good news is we do not need them.

The RC servo PWM can be nested as shown below. WHOA! Nested? Most people would have wanted to generate all the PWM signals for the servos, at the same time. But the truth is, Servos are forgiving enough to allow for a little delay from one pulse to the next. Any other DC motor with close loop would not have tolerated this PWM style. Be warned that this works with RC Servos because although we call their control pulse a PWM pulse, in reality this not true PWM (I will explain PWM on my DC motor and stepper motor control articles).

 
PWM Signal Generation
 
RC Servo Interface

Connecting the Servos:

I wish all the circuits in this life were as straight forward as the RC servos. Man! Are they easy or what?

Simply connect 5V power, ground and the PWM signal from the microcontroller. That’s it! The complexity (if any) comes from the firmware generating the PWM signal. Everything else is taken care by the Servo itself.

The System:

As can be seen on the schematic below, the implementation of a multiple RC Servo controller is one of the most simple circuits you will ever find. There is hardly any components that you need, other than the microcontroller and the Servos themselves. In this implementation, I used a few resistors and caps for the serial communication and protocol parameter selection. There is also a voltage regulator and a reset manager.

Well guess what? If you are using the ATTiny2313, there is no need for the MC34064 reset manager circuitry. There is no need for the external oscillator either. And if you supply a regulated 5V (or 3.3V if you desire), you can get rid of the LM7805 regulator and caps, as well.

JEEZ! This has to be the simplest of all the microcontroller applications on the planet! (don’t forget the MCU cap, though. This is intended for noise on the power supply line and is good practice to include it on every design)

CLICK on the schematic for a larger picture. CLICK HERE for PDF version download.

 
SS-PortaSC11 Schematic

The Implementation:

As always, I first developed a prototype board using one of my AVR208PB project boards. Again, this implementation is very simple. I then went and did a first board called the SS-PortaSC11.

WARNING: I am not certain whether other designers are making this flag imminent, but here it goes so that you don’t commit the same mistake as I did. The RC Servos work with 5V. The microcontroller can also work with 5V. It is extremely tempting to save on resources and have the microcontroller and the RC Servos connected to the same power plane. ERR!!! Don’t do this. The RC Servos will draw a lot of current (specially when driving anything more than two of them) and the microcontroller will enter reset.

That is why, on my implementation I have a power plane for the servos, and the regulated voltage for the microcontroller. This little mistake cost me an entire revision and a few weeks of redoing the circuit, so be warned. It is not trivial!

 
SS-PortaSC11 Prototype and Final Board

Like Father, Like Son! The prototype, and the final product. I want to add at this point that the SS-PortaSC11 is a great board to do much more than just RC Servo controlling. Think about it! It is a board that houses a microcontroller to a bunch of pins. Just change the firmware, and this board can be an output controller. Or maybe an LED driver (I used this on my R2D2 for one of the mood sensors with fiber optics). You can also do range finder sensor interfacing by using the timer Input Capture and Output compares on the ATTiny2313. How about an input controller for IR applications or a bunch of bumper switches? You name it! It is just a microcontroller with pins! Can it get any easier?

The Firmware:

I wanted my RC Servo controller to do the following:

  1. Control up to 11 RC servos
  2. Enable each RC servo control independently. Each servo has an enable bit. Servos which are disabled, do not get their PWM output to them.
  3. Program the rate of change. Instead of quickly jumping from one position to the next, how about scaling the change through time? Before, you would have had to send numerous messages to move the servo slowly. With programmable change rate, this is taken care of.

All of the intricacies concerning how the design work, can be best studied on the data sheet. The following files can be downloaded from:.

Product Information @ Avayan Electronics

SS-PortaSC11 Datasheet

Download

Super Stepper Architecture Data Sheet

Download

AT90S2313 Source File (Code)

Download

AT90S2313 Hex File (Assembled)

Download

SS-PortaSC11 Gerber Files

Download

Extra Links:

Here are some powerful links having to do with RC Servos.

  • Servo City Buy any possible Servo you can think of.
  • Futaba Servos by class, size, etc
  • Hitec Servos and products