Mentor

## PWM for motor control

I recently encountered (not for the first time) a situation in which a PWM output from a microcontroller is sent to a MOSFET bridge that drives a motor (a very high current, inductive load). I started to wonder exactly WHY it is that the duty cycle of the PWM controls the motor speed. I know that the average of the waveform is proportional to the duty cycle, but it seemed strange that the load would behave as though it were being exposed to the average voltage when in fact it was effectively being exposed to a rapidly time-varying one. Then I read something that hinted that the inductive load was somehow providing a smoothing effect. I figured that if I could just solve the system and figure out the current through the motor as a function of time, I'd be set. After all...

...presumably the current through the motor is proportional to its speed (if somebody knows otherwise, please let me know!)...

...so I modelled the system as a series RL circuit with a square wave voltage source v(t) (is this reasonable?)

I set up the typical DE:

$$v(t) = i(t)R + L\frac{di(t)}{dt}$$

After solving using an integrating factor, you get:

$$i(t) = \frac{e^{-\frac{R}{L}t}}{L}\int_0^t e^{\frac{R}{L}\tau} v(\tau)\, d\tau$$

I guess we can define the square wave piecewise, letting it have period T and duty cycle D where D is a number between 0 and 1 telling you for what fraction of the period it's high:

$$v(t) = V_{max}, \ \ \ \ 0 \leq t \leq DT$$
$$v(t) = 0, \ \ \ \ DT \leq t \leq T$$
$$v(t+T) = v(t)$$

So what's i(t)? if t = T, the integral only goes over one square pulse:

$$i(T) = \frac{e^{-\frac{R}{L}T}}{L}\int_0^{DT} V_{max} e^{\frac{R}{L}\tau} \, d\tau$$

Now it took me a while, but I finally figured that at some *arbitrary* time t, the integral will have gone over n square pulses where:

$$n = \left \lceil \frac{t}{T} \right\rceil$$

That's all well and good, but I don't know how to calculate that to get some sensible result for i(t). The integral works out to:

$$i(t) = n\frac{e^{-\frac{R}{L}t}}{R}V_{max} e^{\frac{R}{L}DT}$$

So...what do I do now? Ideally I'd like to get the result that i(t) is constant and equal to

$$D\frac{V_{max}}{R}$$

That would be *awesome*, because it would mean that the current is a fraction of the max that could be drawn, the fraction being determined by the duty cycle, and everything would make sense. But I don't know how to get there.

1. Does anybody know how to solve this math problem?

2. Am I thinking about this in the right way? Because I can't think of any other way that "PWM duty cycle controls motor speed" remotely makes any sort of sense.

 PhysOrg.com engineering news on PhysOrg.com >> Company pioneering new types of material for 3-D printer 'ink'>> Student-built innovations to help improve and save lives>> Researchers use light projector and single-pixel detectors to create 3-D images
 Mentor Something just struck me when I was considering a simpler example (a PWM light dimmer) http://www.physicsforums.com/showthread.php?t=268283 Does this work as a good qualitative explanation for the *motor* as well? Still, it doesn't quite cut it. In the lightbulb, it doesn't matter that the current drops to zero during the off portion of the cycle, because we can't perceive it. Or maybe it doesn't drop to zero, due to back emf...in which case we're back to where we started...trying to solve for i(t) to figure out exactly what happens! Can somebody help me do the math?

Recognitions:
Gold Member
 ...so I modelled the system as a series RL circuit with a square wave voltage source v(t) (is this reasonable?)
I'm no expert but I think you will need to model using a fourier integral. Since a pulse v(t) is the sum of all frequencies each having their own phase.

Blog Entries: 1
Recognitions:

## PWM for motor control

 Quote by cepheid Something just struck me when I was considering a simpler example (a PWM light dimmer) http://www.physicsforums.com/showthread.php?t=268283 Does this work as a good qualitative explanation for the *motor* as well? Still, it doesn't quite cut it. In the lightbulb, it doesn't matter that the current drops to zero during the off portion of the cycle, because we can't perceive it. Or maybe it doesn't drop to zero, due to back emf...in which case we're back to where we started...trying to solve for i(t) to figure out exactly what happens! Can somebody help me do the math?
I won't address the mathematical points of this discussion, but as for the qualitative hand-wavy arguments, well...

In the case of a motor driver driving a motor, the motor (and wheel, and robot / car, etc.) all have a certain (rotational) inertia. If the motor driver frequency were low enough, you would see the motor stop and go in jerky motions. But go above this critical frequency, and only smooth motion results.

In the case of an (incandescent) light, if you assume that the number of photons emitted might be high or zero (in reality, you receive a portion of the sine waveform), but you receive some total number of photons at your eyes every 1/30 of a second or so--roughly the upper limit of your eyes' 'sampling frequency'. As a result, you see the average of the intensity. For all of us, 50/60 Hz AC driven incandescent lights look continuous, despite a zero crossing 120 times a second--this might be due to the incandescent lights' inductance--but someone else would have to confirm that. Fluorescent lights are able to respond fast enough that they do flicker at 100/120 Hz. For most of us, this is imperceptible, but I know people who are driven crazy by fluorescents because they're able to see this constant flickering--or some beat frequency, at least.

If you're familiar with communications and the Nyquist theorem, these are both sort of physical manifestations of that.

Mentor
 Quote by MATLABdude In the case of a motor driver driving a motor, the motor (and wheel, and robot / car, etc.) all have a certain (rotational) inertia. If the motor driver frequency were low enough, you would see the motor stop and go in jerky motions. But go above this critical frequency, and only smooth motion results.
Yeah, that's a really good point, and I can't believe I didn't think of it. For this reason, the steadiness of i(t) doesn't matter quite as much, and so I've abandoned the mathematical analysis (I have other things to do).

 Quote by MATLABdude If you're familiar with communications and the Nyquist theorem, these are both sort of physical manifestations of that.
Yes I am, and we have since discussed this further in the other thread as well. Thank you very much for your remarks!

 Energy=power X time In a pulse width modulation circuit, you are not varying the power put into a load, that stays the same, but you are varying the time it is applied to it, thus varying the total energy delivered.

 Quote by famousken Energy=power X time In a pulse width modulation circuit, you are not varying the power put into a load, that stays the same, but you are varying the time it is applied to it, thus varying the total energy delivered.
You can't really change one without changing the other in this case. Average the power and it certainly changes with duty cycle.

 average, yes, which is factors time into the equation.