# AB-022 : PWM Frequency for Linear Motion Control

### Introduction

Pulse Width Modulation (or PWM) is a popular and efficient method for driving DC motors because we can control the motors with significantly fewer power losses than continuous linear regulation.

Using PWM enables control of the current in the windings and in turn the output torque, as the torque is proportional to average winding current. It follows that current will be proportional to PWM because of the torque’s linear response.

In a circuit, resistive loads will have a current that is proportional to PWM. However DC motors are more complex than resistive loads, they contain an inductance and when rotating they produce back EMF.

These factors usually mean PWM control isn’t strictly linear, the PWM frequency (not just the duty cycle) is actually quite significant for output parameters.

Basic Brushed DC Motor Equivalent Circuit

When the motor is at rest (or is rotating at a very low speed) then there is no back EMF (or it’s extremely small) and the circuit becomes simpler. In this situation, the current is limited by the resistance of the windings and the coil’s inductance.

As a side note, if the motor was operating from a regulated DC source, not PWM, then the current will be determined only by resistance as the inductance does not have an impedance with a constant source.

We’ve updated the equivalent circuit below to reflect the motor at low speed or no speed, consisting of only a series RL circuit.

DC motor equivalent circuit at rest (or low speed)

The input voltage V is equal to the sum of the voltage drop across the inductor and the voltage drop across the resistor:

$$V_{L}(t) = Ve^{-t \frac{R}{L}}$$

$$V_{R}(t) = V (1-e^{-t \frac {R}{L}})$$

The voltage across the inductor tends towards 0 as time passes, while the voltage across the resistor tends towards V. This is in keeping with the intuitive point that the inductor will only have a voltage across as long as the current in the circuit is changing — as the circuit reaches its steady-state, there is no further current change and ultimately no inductor voltage.

All series RL circuit have a time constant, usually denoted $$\tau = \frac {L}{R}$$, which is the time it takes the voltage across the component to reach $$\frac {1}{e}$$ of its final value. $$V_{L}$$ will rest at 0V, so $$\tau$$ is the time it takes for $$V_{L} = V({\frac{1}{e}})$$. Similarly $$V_{R}$$ will rest at input voltage V, so $$\tau$$ is the time takes for $$V_{R} = V({1 – \frac{1}{e}})$$.

When a voltage is applied to the circuit the inductance of L slows down the rate at which the current rises. This happens because the inductor produces a back EMF which resists the current flowing through it. This prevents the current (and hence the voltage across the resistor) from rising or falling much faster than the time constant of the circuit.

As a result, when the power supply is switched on, the current does not instantaneously reach its steady-state value, $$\frac{V}{R}$$. The rise instead takes several time-constants to complete.

Current in RL Circuit

When using PWM for DC motor control this situation repeats on every period of PWM. If the load is only resistive, the PWM frequency has no effect, but in this RL circuit, the current rise is limited by inductance.

Therefore PWM signals using higher frequencies give less time for the current to rise.

Motor current at two different PWM frequencies, both 50% duty

This means to simulate a linear response, the ‘on’ pulse time for the PWM should be greater than $$5 \tau$$, i.e. $$5 \times \frac{L}{R}$$.

For example, if our motor has a time constant $$\tau = 10 \mu s$$,  the minimum pulse width should be longer than $$50 \mu s$$.

If our minimal usable PWM duty cycle is 5%, then we should pick a frequency to ensure it is longer than $$50 \mu s$$. This gives a minimal PWM period of $$20 \times 50 \mu s = 1ms$$. A period 1ms means our maximum frequency for linear response is 1 kHz, any lower and at low duty cycles, the current does not have enough time to reach close to its steady-state value.

### Calculations for Precision Microdrives 110-003 motor

Let’s try to calculate the maximum PWM frequency which gives a linear torque response with 1% PWM resolution. For this example we are using the 110-003 Micro Core™ DC motor, you can find its technical details in the datasheet (downloadable from the product page).

Rated voltage = 1.5V

Resistance = 3.4 Ω

Inductance = 19 µH

Time constant for this motor is:

$$\tau = \frac {L}{R}$$

$$\tau = \frac{0.000019 H}{ 3.4 \Omega} = 0.0000056 s = 5.6 \mu s$$

Therefore the minimal pulse width should be longer than:

$$5.6 \mu s \times 5 = 28 \mu s$$

With a minimum PWM resolution of 1%, the minimum pulse width is:

$$28 \mu s \times 100 = 2800 \mu s$$

This determines the maximum frequency for linear response (remember this is where the inductance in the motor winding is not averaging the current to below the level that would provide the motor with maximum torque):

$$\frac {1}{0.0028s} = 357 Hz$$

So i.e. if you want maximise the torque out of the motor, drive it with DC, or a PWM with frequency of less than 357Hz (in this example).

### Testing with the Precision Microdrives 110-003 Motor

Testing Circuit for 110-003 Motor

In the above testing circuit, the motor was controlled from a PWM source on an ATmega168 which was output through a MOSFET. An LDO voltage regulator (LD1086) made 1.5V available for the motor.

The current was measured between the voltage regulator and motor, and also between the transistor source and ground. The motor shaft was stopped, to simulate normal conditions where motor works with a load.

The three screenshots below are for three different PWM frequencies: 200 Hz, 2kHz and 31.25 kHz, but our minimum duty cycle is actually 10%. This means we should see linear behaviour at frequencies below 3.571 kHz (10 times the calculated minimum frequency at 1% duty cycle). We’re expecting that both the 200 Hz and 2 kHz signals to be similar and reach close to the expected DC current, but the 31.25 kHz signal will reach a significantly lower current.

The current value in the screenshots is the average current.

Current in 110-003 with 200 Hz PWM @ 10% Duty

Current in 110-003 with 2 kHz PWM @ 10% Duty

Current in 110-003 with 31.25 kHz PWM @ 10% Duty

As we can see with 31.25 kHz, the current reaches close to 50% of the value for 2kHz. If the average current is less, this means the output torque is also less and is not a linear response.

At 2kHz the current reaches close to the maximum value (as with true DC control), so we can expect the frequency of 2 kHz to give a linear response above 10%. Similarly, with a 200Hz frequency, the peak current again reaches full value, as we expected with our calculations beforehand.

An important note is to analyse how the motor performs at lower frequencies. During our tests, we experienced some vibration and shaking on the motor shaft when powering at 200 Hz, so for a smoother drive system we would select a higher frequency.

The data and graph below make it easier to see the non-linear response at high frequencies. We’ve varied the duty cycle for the same 3 frequencies, a linear response should show a nice straight line between duty cycle and current draw. This means a change between 75% and 80% duty should yield the same change in torque (current draw) as 5% to 10%.

Motor current vs PWM duty

Motor current vs PWM Duty at different frequencies

We can see that whilst the 200 Hz and 2 kHz frequencies don’t perfectly follow the theoretical ideal (it looks like there is a slight change in gradient above ~83%), the non-linearity is much more pronounced at 31.25 kHz.

It is important to find an acceptable balance between linear behaviour, noise, and unwanted vibration. For many applications, the non-linearity at higher frequencies will not be an issue, or the benefits of the higher frequency outweigh the drawbacks.

However if your application does require a high degree of linearity from a high-frequency PWM drive signal, you could consider the following to improve performance:

1. Switching the PWM frequency when the motor is starting, reducing the frequency can give a higher output torque. It can be done with most microcontrollers which have hardware PWM generator, usually with the phase-correct mode of operation

2. Increasing PWM resolution and making a lookup table in the code for motor response. We can vary the PWM to compensate for the motor’s non-linear response

3. Adding a current sensor and making a PWM closed-loop regulator to vary the frequency or duty cycle for linear response

All of these options require additional resources or coding if possible using a lower frequency PWM makes the design simpler.