Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

DC MOTORS

Small DC motors are easy to model and control. Fortunately for us, they can be reduced to simple terms
so our control algorithms are easy to code. The permanent magnet DC motor can be modeled as a
device that produces torque proportional to the current flowing through it. It also produced a voltage
proportional to the rotational velocity. One last bit of modeling completes the picture: there is a small
series resistance in the model. Hence, if one stalls a motor, the current draw and torque produced will be
the supply voltage divided by the resistance.

Commonly one reads that the RPM of a motor is proportional to the voltage across it’s terminals – and for
most purposes that is true: at any given voltage, the motor will spin up in speed until the generator portion
of the motor model matches the supply voltage. At that point no more current will flow into the motor and it
will produce zero torque. Of course, there is some amount of friction, so there will be some amount of
torque required to spin the motor, thus some amount of current needed. This current causes a voltage
drop across the small series resistance in our motor model. This voltage drop takes away from supply
voltage and causes the motor to spin a bit slower than the supply voltage would indicate.

In industrial controllers one typically sees a variety of control methods: constant speed, where the applied
voltage is "adjusted" for the IR voltage drop across the internal resistance (the controller measures the
current though the motor, calculates the voltage drop across the internal resistance and bumps the supply
voltage to compensate); Constant torque, which is simply a constant current supply, and the incremental
encoder or tachometer feedback systems which, of course, give absolute control over position and speed.

PWM
A typical way to control small DC motors is via PWM, which stands for Pulse Width Modulation. PWM
comes in a variety of flavors. The only flavor that I have used has a fixed frequency with a variable on/off
cycle. The hardware in Dilbert and Dilbert II has a selectable 8, 9 or 10 bit PWM. The "on" portion of the
cycle can be set to any value from 0 to 2^n-1, or, for 8 bit PWM: 0-255. This means that there are 255
steps between 0% and 100% on, during a PWM cycle. As mentioned earlier the Dilbert’s both use locked-
antiphase drive, which means that the control range is really –127 to +128. I find that 127 steps of power
control are more than adequate for controlling small motors.

H-Bridge
The H-Bridge is the primary means for driving a small DC motor in the forward and reverse directions. A
typical small motor driver chip is the L293D or the L298. These are very old designs, but they are cheap
and work well. There are lots of newer chips available, but, fundamentally, they all do the same thing:
They have a direction input and an enable. By selecting the appropriate directions for the two sides of the
H-bridge and enabling the outputs, the computer can control the direction of the motor. By switching the
direction and the enable bits the controller can control the direction as well as the amount of power
delivered to the motor

There are fundamentally two ways to drive a small motor with a PWM signal: Sign-Magnitude and
Locked-antiphase.

Sign-Magnitude
In sign-magnitude the controller sets the direction with the directions bits and then varies the amount of
power to the motor with the PWM signal. Typically switching the ENABLE bit of the H-Bridge driver does
this. The ratio of ON to OFF determines the amount of power going to the motor.

There is an alternative way to drive the motor: The Enable bit is left ON all the time. One half of the H-
Bridge is set forward or backwards and the PWM signal drives the other half of the bridge. The effect of
this technique is that the motor is alternatively driven and shorted with the ratio set by the PWM signal

Locked-antiphase
Locked-antiphase is similar to the second version of Sign-Magnitude in that the enable line is always ON.
The PWM signal is used to switch both sides of the H-Bridge such that the motor is driven forward or
backwards at all times.

Because both forward and reverse are determined by one signal line the amount of control available is
only ½ the apparent PWM control range: Those numbers below 50% duty cycle are reverse and those
above are forward.

One of the big advantages to locked-antiphase is that only one line is needed to completely control the H-
Bridge motor driver. If you have an I/O constrained MCU, this might be a good option.

Brake vs. Coast


When a DC motor is spinning, it generates a voltage across the terminals, much like a generator. This
voltage is a characteristic of the motor and can be found in the specification sheets as something like
Volts/RPM. This voltage is also called the Back Electro-Motive Force (EMF). Back EMF can be used to
re-charge the power source of the motor control circuit, or, it can be used to brake the spinning of the
motor. With an H-Bridge this is accomplished by driving both sides of the H-Bridge the same direction. It
is essentially shorting the motor terminals together.

On the L293, and similar devices, the ENABLE bit serves to disconnect the driver from the motor. When
this happens, the motor simply spins and generates a voltage. The only time this voltage might be turned
into a current is if the back-EMF exceeds the supply voltage and the forward voltage drop of the
protection diodes in the H-Bridge driver. When the driver is ENABLED and shorting the motor terminals
together, they are not really shorted together: in fact, one is held high, or low, and the other one conducts
through the protection diodes in the driver. So, the motor will generate current and brake as long as the
back-EMF is greater than one diode + one Vce voltage drop (about 1.1v).

When in brake mode, the motor tends to resist turning. Shorting the terminals together is essentially
connecting a very low impedance load to the motor. When a battery is connected to the motor, it too looks
like low impedance because, regardless of the current flow or direction, the battery voltage stays the
same. The definition of impedance is R = delta V/delta I. Since the delta V stays constant (ideal battery)
the resistance (impedance) is zero. The reason the motor only spins up to a certain amount is that the
Back-EMF counters the voltage of the battery until there is nothing left to drive current through the motor.

When driving a motor with a PWM signal if one uses Locked-Antiphase, or the second Sign-Magnitude
technique, the motor is always connected to a low impedance source (either shorted through the
protection diodes, or connected to the supply voltage). The result is that for a given speed the motor will
tend to resist speeding up or slowing down for exactly the same reasons that shorting the terminals
together cause the motor to be in brake mode.

You might also like