"Programming, like chess, women, and music, has the power to make men happy" - Gerald Weinberg

Servo Controller - Background

Background

Accurately controlling the position of rotating elements is the heart of a motion controlled system. Often stepper motors are called upon to complete this task. Although cheap and plentiful at lower power levels, more powerful versions are expensive and difficult to source.

Steppers

Stepper motors are the norm in hobby CNC systems. Although stepper motors have limitations:

Generally must be over engineered, so that there is no possibility that the motor will lose steps.

More vibration than other motor types, as the discrete step tends to snap the rotor from one position to another.

Servos

Another device is the servo motor. This combines a standard electric motor and position feedback sensor with a controlling circuit. The electric motor can be DC (brushed) or AC (brush-less).

There are a couple of fundamental components to these servo drives:

Actual position conditioning & decoding

Desired position conditioning & decoding

Error calculation (from actual-desired)

Error filtering (PID calculation)

PWM generation

H-Bridge

Actual position conditioning & decoding
Function: This is the feedback sensor to determine the current position. They are built in to industrial servo motors, and industrial external sensors cost many $100s.Hobby Option: A low cost optical encoder can be had for US$20, and with a little effort these can be fitted to a standard permanent magnet DC motor. The output from these incremental rotary encoders, is "quadrature" encoded (two output wave forms 90 degrees out of phase). Decode quadrature input with a microcontroller.

Desired position conditioning & decoding
Function: The servo controller must be instructed of the desired position. Hobby Option: Derived from stepper motors, the defacto standard is STEP & DIRECTION signals. A "step" line is pulsed, and each pulse represents an increment or decrement depending on the state of the "direction" line. Software such as EMC2 & Mach3 can generate these signals. Decode step/direction input with a microcontroller.

Error calculation (from actual-desired)Function: From the actual and desired position, an error level must be derived. This can be done via analogue, or digital means.Hobby Option: Calculate with a microcontroller.

PWM generation
Function: From processed error calculate an output level.Hobby Option: Generate with a microcontroller. This is a logic level PWM signal (or signals) that control the H-bridge.

H-bridge
Function: Produce a high power PWM DC signal.Hobby Option: The H-bridge needs to match the motor. A simple 100mA unit can be constructed with BC548 NPN and BC558 PNP transistors. At 160A the 16 MOSFET Open Source Motor Controller project is the other extreme. Most setups will lie somewhere in between.

Options

Buy: At the hobby level Gecko (US$114) drives appear to be the norm. The Gecko (320 & 340) appear to be analogue units with gain & dampening trim-pots. A test-point reflecting the error (as voltage) is available to assist in tuning with an oscilloscope.

Build: A number of DIY controllers, Elm Chan Servo, UHU Servo, Dspic-Servo, were all designed for the specific purposes of their creator, and integrate the H-bridge into the controller PCB. The most variable component is the motor. Different uses will require different motors, and different motors have different drive requirements. It's beyond most hobbyists to modify a PCB and design their own high-power section. A modular approach, with a separate controller & H-bridge would be much more flexible. Allowing you to select a H-bridge matched to you motor.

When looking at the DIY servo controllers I found a few short commings: