Motor driver

kinds of motor drivers

There are many kinds of motor drivers, each one specialized to drive its own type of motors:

• servo motor controller
• stepper motor controller
• DC motor controller ("brushed")
• AC motor controller ("brushless")
• BLDC motor controller ("brushless DC"), often called an "ESC"
• ... (todo: fill in the other kinds) ...

In all cases, we have an electric motor that has wires coming out of it. At any one instant, the motor controller connects each wire to either the Hi voltage on the + side of the battery, or to the Lo voltage on the - side of the battery, or neither. When we tell the motor controller to make the motor go "forwards" or "backwards" or "fast" or "slow", the motor controller changes which wire is connected to which end of the battery (or not connected at all). Some motor controllers switch the connections thousands of times per second in some modes.

A DC motor controller that is 'reversible' generally uses an 'H bridge'. This 'H-bridge' uses four output drivers in a configuration that resembles an H where the load is the cross bar in the middle. The lines on either side of the load (the downward strokes in the H) represent a series connection of a pull-up driver and a pull-down driver. This allows each terminal of the load to be connected to either the positive supply rail, or the negative supply rail. This allows a positive, negative or zero voltage difference across the load. This load voltage is then utilized to provide the desired control required of the motor. The various combinations can give a 'forwards' torque on a DC motor, a 'backwards' torque on the same motor, can allow the motor to free-wheel (without any applied torque) or can provide a locking of the motor such that it resists any attempt to rotate it.

A single phase AC motor is generally driven in the same way as a DC motor, however instead of operating the motor drive as a constant DC voltage (in either the 'forward' or 'reverse' direction) the AC motor is driven by an approximation to a sinewave. This approximation is created using the H bridge and driving it with a PWM input such that both the positive and negative voltage periods are the same. This is normally achieved either using a sawtooth waveform compared against a sine wave reference, or is done using a lookup table in a microcontroller.

```      +Vhigh      +Vhigh
|           |
...-o[pFET   pFET]o-...
|           |
+--(motor)--+
|           |
...-|[nFET   nFET]|-...
|           |
GND         GND

H bridge built from 2 nFETs and 2 pFETs.
```
Push Pull Transistor Circuit: one half-bridge. (Fixme: show the flyback diodes, and convert to the more common MOSFET drive transistors ... also replace the resistive "load" with a (M) motor symbol.)

A similar method is used to drive multiphase (3-phase) AC motors, however instead of just using an H bridge, only a half H bridge is used per phase (3 half-bridges). Each phases half bridge is then driven in the same manner as for the single phase motor, with a phase difference between the phases as appropriate.

Most stepper motor controllers uses 2 independent H bridges (4 half-bridges) for the 2 independent coils of a stepper motor. Each possible state (one bridge driving current one way, the other way, or free-floating) of both bridges gives 4 "full steps", 4 "half-steps" between the full steps. The "microstepping" motor controllers use PWM to gradually change in a sine-wave-like manner from adjacent full-steps and half-steps.

((fill in more details here...))

BLDC

It appears that most modern small electric aircraft, such as multi-rotor helicopters, use so-called "brushless DC motors", each one driven by its own "BLDC ESC". (These are easily recognized -- BLDC motors have exactly 3 equally-fat wires that go into them, which come from the BLDC ESC -- as opposed to most electric aircraft a few years ago, which used brushed DC motors with exactly 2 equally-fat wires).

While it is probably not cost-effective to build your own BLDC motor or BLDC ESC, many of us are insatiably curious about what goes on inside these things, and so build one anyway:

• "Proposal for a high-speed serial (spi/i2c) arduino-based ESC for quadrotor/multi-rotor projects": designed specifically for academic research in stability and controls analysis of quadcopters. The goals are apparently (a) open-source and easy to reprogram, so other academics can replicate the experiments and make improvements, (b) low-latency quick response for (hopefully) better quadcopter stability, (c) lower cost than an Open-BLDC.[1]
• Open-BLDC Project wiki: "a completely Open-Source BrushLess Direct Current motor controller also known as Electronic Speed Controller (ESC)." "Open-BLDC has ... many additional sensors to make Vector control possible. The goal is also to make the best possible controller and not the smallest or cheapest." http://open-bldc.org/
• Wikipedia: brushless DC electric motor
• Atmel AVR444: Sensorless control of 3-phase brushless DC motors using ATmega48 (also works without change for ATmega88 and ATmega168). Assumes you've already read Atmel AVR443: Sensor-based control of three phase Brushless DC motor
• AVR194: Brushless DC Motor Control using ATmega32M1: BLDC motor control application using Hall effect position sensors to control commutation sequence.
• MikroKopter brushless motor controller: was designed to give lower latency than off-the-shelf PWM ESCs.[2]
• OpenServo Brushless DC Servo: "The thing that will make our board different from other ESC's is that we are closing the feedback loop with a ... outside position reference." [3]
• the FroBoard design (brushless DC motor control) seems to be open hardware.

noise control

Many motors make sparks when the brushes make or break contact. This causes lots of electrical noise ("brush noise"). Your TV-watching neighbors won't be happy if you allow this noise to leak out.

Some people fix this by slapping a .1uF cap across the motor leads. (photo of noise-control capacitor on a Open Servo).

"Sparks emit RF energy from DC to daylight as I was once told by an EMC expert." -- HydraRaptor: "DC to daylight". More details: HydraRaptor: "GM3 motor suppressor"

current sense

Often people want to measure the current going through the motor.

See current sense for several different techniques.

tolerance against software bugs

Some motor controller circuits are such that, if the software accidentally sets the "wrong" pins hi or lo, you get a short circuit through the output drivers. This will generally cause a high current to flow, due to the low on state resistance of the output drivers, which may destroy other electronic components before finally blowing the supply fuse.

Other motor controller circuits are such that, if the software accidentally sets the "wrong" pins hi or lo, the worst that could happen is the motor spins the wrong way. These circuits are designed so that, no matter what the inputs, it is impossible to get a short circuit through the output drivers. Between "one branch on" and "the other branch on", there is a minimum "blanking time" which has "both branches off". This guarantees that we never have "both branches on" (short circuit).

Guess which type of design I prefer?

FET driver

What do you put between the CPU output pins and the 4 FETs of the H bridge?

The simplest solution is to use 2 lo-side nFETs and 2 hi-side pFETs, and use a power supply for the motor that has the same voltage as the CPU power supply, and drive the 4 FETs directly using 2 CPU output pins. One of those output pins connects to the gates of the left side and controls whether the left leg of the motor is Hi or Lo. The other output pin connects to the gates of the right side and controls whether the right leg of the motor is Hi or Lo.

But alas, that circuit won't work for any of the following situations:

• you want to run the motor off a much higher voltage -- say 12 V.
• you want to use 4 nFETs (because they are slightly cheaper, and it's simpler to stock one kind of FET rather than 2 kinds) rather than 2 nFETs and 2 pFETs. You need a "nFET high side driver". There are several clever circuits for generating a "Vpp" voltage that is higher than your motor power supply voltage; "Vpp" is needed to turn high-side nFETs completely on.
• you want more isolation between the "noisy" motor power supply and the "quiet" CPU power supply.
• you are driving a large FET with high gate capacitance, and your CPU output pins can't source or sink enough current to turn the FET on and off fast enough.
• You want a hardware-enforced blanking time as alluded to earlier.

There are many "MOSFET driver" chips designed to drive the gate pin of large discrete MOSFET transistors. In no particular order, a few such MOSFET driver chips are: Microchip TC4423A, TC4424A, TC4425A, MCP1407, On Semi ADP3120A, Fairchild FAN73711, etc.