## How PWM works?

Interested in Robotics? Here's the place to be.
suniljha
Posts: 28
Joined: Fri Jan 02, 2004 1:01 am
Location: India
Contact:

### How PWM works?

Hi!
Though I have tested PWM for DC motor speed control and it works fine. Thanks a lot for all help provided by members here. Now I have one curiosity to know scientifically how actually PWM works for an inductive load? Here I am looking for some physics and electrical information which can explain working of PWM with different duty cycle across an inductor. How this give average current across load?<p>Looking for help!
regards
Sunil Jha

cato
Posts: 366
Joined: Sun Sep 07, 2003 1:01 am
Contact:

### Re: How PWM works?

Inductors oppose CHANGE in the current flow through them. When you apply a voltage across and inductor, the current flow is very small because as current begins to flow magnetic field are produced. The expansion of the magnetic field opposes the voltage and current flow in the adjacent turns of the coil. In a motor, the expanding magnetic field also pushes on the rotor causing it to move. As time progresses the current increases and the magnetic field becomes stronger until the only thing limiting the current flow is the resistance of the wire that makes up the coil (and the output impedance of the voltage source you are using to apply the voltage). <p>When you turn off the voltage, the magnetic field begins to collapse. The collapsing magnetic field continues to push electrons (or charge carriesr) in the direction they were flowing. Energy is stored in the magnetic field and is releases through this collapsing process. <p>On analogy is to thing of the inductor as a stiff rubber tube that you are trying to force water through. At first the passage is small and the water flow is low. However, the applied pressure forces the tube to expand and more water can flow. When the pressure is removed the tube collapses, but has to push the water in the tube out of the way before the tube can return to its original shape.<p>So, when you apply pulses (at high frequency compared to the inductance of the inductor), the first pulse starts current flowing. The current continues to increase until the pulse is shut off. When the first pulse is removed the magnetic field continues to push electrons. The next pulse comes along before the magnetic field totally collapses and the current flow begins to increase.<p>The resulting current flow is ripply DC. The longer the pulses or the higher the duty cycle, the higher the the average current flow, and the higher the speed and/or torque of the motor. The higher the pulse frequency the shorter the ripples in the current flow.<p>That help?

MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

### Re: How PWM works?

Hello again Sunil,<p>When you have an inductor in series with
a resistance (resistance is the load) the
average current though the load is the same
as the average current though the load
as if the inductor was a short. In other
words, it depends on the ohmic resistance
of the load and the pulse voltage and the
duty cycle.<p>For example, say we feed the system with
10v pulses and we have a resistor load of
10 ohms and we use a 50% duty cycle.
The average current is 10v/10ohms * 0.50
which comes out to 0.5 amps.<p>If we had 20v pulses then it would be
20/10 * 0.50 which comes out to 1 amp.<p>The formula is D*Vp/R
where
D is the duty cycle
Vp is the peak pulse voltage
R is the ohmic resistance of the load<p>Note it doesnt matter what the value of
the inductor is. The only difference
the value of inductance makes is the
'ripple' in the current wave...higher
inductance means less ripple.<p>Also, motors contain an equivalent inductance
already and a resistance.<p>Also note that the pulse driver either has
it's output PULLED to 0v dc when off or
possibly a reverse connected diode to catch
the negative swing of the inductor.
Without one or the other the output transistor
blows out from over voltage.<p>Also, if you are dealing with a small system where
you are using a small motor there is nothing
wrong with using a linear drive circuit.
You dont have to bother with pulse generation
that way.
For feedback you can measure the 'back emf' of
the motor.<p>
Take care,
Al
LEDs vs Bulbs, LEDs are winning.

cato
Posts: 366
Joined: Sun Sep 07, 2003 1:01 am
Contact:

### Re: How PWM works?

That is incorrect. Even if you assume the inductor has zero resistance, it still has a non zero inductive impedance which plays a roll in limiting the current.

MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

### Re: How PWM works?

Hello cato,<p>I think you should take another look and not
confuse the dc value with ac components.
Remember an inductor is a short to dc.
The average dc acts like pure dc to this circuit.<p>Let's take another look...<p>Vdc=Vp/R*D
where
Vp is the height of the pulses
R is the resistance
D is the duty cycle<p>It's easy to prove using a circuit simulation program by
driving a series inductor and resistor with a pulse source
and looking at the current wave.<p>Another way would be to use the time domain equation of
the series RL circuit:
I=(E/R)*(1-exp(-(R/L)*tp)) + I0*(exp(-(R/L)*tp))
where
I is current
E is pulse height voltage
R is resistance
L is inductance (Henries)
tp is the time period (either for on or for off)
I0 is the initial current
exp(x) is short for e^x<p>You can use that equation repeatedly in a loop to find
the final dc value if you average over say 1000 cycles and
set I0=I after each calculation (because the new initial
current comes from the last old current value).
For pulse 'on' times set E=Vp (pulse height voltage)
and for pulse 'off' times set E=0.
For a 50% duty cycle set tp=5e-6 (5us), but
for say a 25% duty cycle when 'on' set tp=5e-6 and
when 'off' set tp=15e-6. This gives the correct
ratio of on to off time periods.
A typical value of L might be 10mH.<p>
Another somewhat more elegant solution requires some
familiarity with Laplace transforms and operations...<p>The Laplace transform for the circuit with a step voltage
and initial current i(0) is:
-- I(s)=(E/L)/(s(s+a))+i(0)/(s+a)
-- where a=R/L and i(0) is initial current<p>The Laplace transform for the drive pulse source with
on time=k1 and off time=k2 and pulses above
zero of height E volts is:
-- V(s)=(E/s)*(1-exp(-s*k1))/(1-exp(-s*k2))<p>With i(0)=0 (circuit first turned on) the total transform is:
-- I(s)=[(E/L)/(s(s+a))]*[(1-exp(-s*k1))/(1-exp(-s*k2))]
by taking i(0)=0 and replacing the step voltage source with the
pulsed voltage source.<p>To find the final dc value of I we take the limit of s*I(s) as
s approaches zero:
-- lim I(s) {s-->0}=lim( [(E/L)/(s+a)]*[(1-exp(-s*k1))/(1-exp(-s*k2))] ) {s->0}
which can be written:
-- lim I(s) {s-->0} = lim[(E/L)/(s+a)] * lim[(1-exp(-s*k1))/(1-exp(-s*k2))]
so
-- lim I(s) = (E/L)/(R/L) * (k1/k2) = (E/R)*(k1/k2)<p>Note that since k1/k2 is simply the duty cycle D we can write
the final value as:
-- Vdc=(E/R)*D
where again:
Vdc is the average dc value after say 10 time constants
E is the pulse height voltage (rectangular pulses)
R is the resistance
D is the duty cycle<p>All these methods have the same result.<p>It's also interesting to note that if i(0) is not equal to zero
amps it still does not contribute to the final value because
the limit of that part of the equation goes to zero as s goes
to zero. The final value is still D*E/R.<p>Take care,
Al<p>ADDED LATER: Edited some typos <p>[ January 13, 2004: Message edited by: MrAl ]</p>
LEDs vs Bulbs, LEDs are winning.

cato
Posts: 366
Joined: Sun Sep 07, 2003 1:01 am
Contact:

### Re: How PWM works?

The subject is PWM. I'm pretty sure if the system is designed properly, the pulses are short compared to the time constant of the inductor. Therefore, inductive reactance is involved.<p>[ January 14, 2004: Message edited by: cato ]</p>

Ron H
Posts: 360
Joined: Tue Dec 18, 2001 1:01 am
Location: Boise, ID
Contact:

### Re: How PWM works?

I think Cato is right. Aren't we talking about an inductor that is driven by a switch?<p>[ January 14, 2004: Message edited by: RonH ]</p>

cato
Posts: 366
Joined: Sun Sep 07, 2003 1:01 am
Contact:

### Re: How PWM works?

Thanks for the back up Ron. I was startin to feel kinda lonely.

Will
Posts: 310
Joined: Tue Feb 11, 2003 1:01 am
Location: Katy Texas
Contact:

### Re: How PWM works?

Cato i right about the inductive reactance i.e. If the switch period is short compared to the time constant of the indictive circuit. The rise rate of the current in an inductor is almost linear for the first part of a time constant so if you had an inductive time constant 100 times the length of the switch period then the current could only rise to (A first order guess) about 1.0 % of the final value. Remember - The time constant is the time it woould take for the current to rise to the final value if the rate of increase of the current at time = 0 was maintained - which it wouldnt be of course because the rate of current increase is proportional to the difference between the instantaneous current and the final current.
This is a good thread - I myself would like to know how, with such a circuit, you could calculate the average current for any given Mark/Space ratio of the PWM. If it were a purely resistive circuit then the average current would be directly proportional to the Mark/Space ratio.<p> Will
BB

MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

### Re: How PWM works?

Hello again,<p>
You guys really need to get circuit analysis programs arent that hard to learn how to use.<p>
Let's look at this from another angle...<p>The input pulses can be broken down into a number of
ac components plus a single dc component. To get
the response to this input the responses to all the
individual components are summed. To get the
response to each component the current is
I=E/(R+jwL)
by substituting each component in turn for E.<p>Looking at that equation you might recognize wL as the reactance xL,
so that
xL=wL=2*pi*freq<p>Now, for each ac component the frequency is substituted for
'freq' in that equation, but what about for dc?
There is no frequency for a dc voltage, therefore the
reactance xL is zero:
xL=2*pi*freq=0<p>This means the dc component gets through the inductor without
change.<p>Knowing this, all we have to do is find the average value
of the pulsing wave. This is easy to find:
VavgDC=Vp*Ton/(Ton+Toff)
where Vp is the height of the pulsing wave.
This can be written as:
VavgDC=Vp*D
where
D is the duty cycle.<p>Since the inductor has zero reactance at zero frequency,
this dc value passes through without change, so the output
dc is equal to the input dc:
Vavg=Vp*D<p>Now to get the current, we divide Vavg by R to get Iavg:
Iavg=Vavg/R=Vp*D/R<p>So AGAIN we end up with
Iavg=Vp*D/R<p>which is the exact same formula that the other two methods
provided <p>Note also that it doesnt matter what the ratio of
the time period to the resistor/inductor time
constant is either. The dc component acts as
a battery that doesnt affect the average dc
output.<p>Take care,
Al
LEDs vs Bulbs, LEDs are winning.

Ron H
Posts: 360
Joined: Tue Dec 18, 2001 1:01 am
Location: Boise, ID
Contact:

### Re: How PWM works?

Mr Al, I do have a circuit analysis program. I even used it to back up my statement. Too bad we can't post graphics here (at least I can't). I have put the schematic, inductor current waveform, and the average current at this site. This was done on Linear Technology's SwitcherCAD III, which is a free, no strings attached, uncastrated Spice-based simulator. Maybe you should avail yourself of it, Al. I don't have any argument with your math. The problem is that you are assuming a constant resistance source, and PWM, AFAIK, uses switches. Using constant resistance defeats the purpose of PWM, which include high efficiency and higher torque (for a motor), or so I'm told.

cato
Posts: 366
Joined: Sun Sep 07, 2003 1:01 am
Contact:

### Re: How PWM works?

Keeeewl.... Can you increase the sweep on the scope so we only get 2 or 3 cycles? Can you superimpose the Pulse waveform or maybe the voltage across M1 and or L1?

cato
Posts: 366
Joined: Sun Sep 07, 2003 1:01 am
Contact:

### Re: How PWM works?

MrAI -
As you point out "To get the response to this input the responses to all the
individual components are summed." <p>However, you didn't sum them. You only looked at the DC component.....

Ron H
Posts: 360
Joined: Tue Dec 18, 2001 1:01 am
Location: Boise, ID
Contact:

### Re: How PWM works?

<blockquote><font size="1" face="Verdana, Helvetica, sans-serif">quote:</font><hr>Originally posted by cato:
Keeeewl.... Can you increase the sweep on the scope so we only get 2 or 3 cycles? Can you superimpose the Pulse waveform or maybe the voltage across M1 and or L1?<hr></blockquote>
I gave you the links to do it yourself. Go for it, man! Expand your horizons! MrAl
Posts: 3862
Joined: Fri Jan 11, 2002 1:01 am
Location: NewJersey
Contact:

### Re: How PWM works?

Hello again,<p>RonH:
That's a neat circuit there and thanks for taking the time to present
it in a form which can be easily accessed. The main problem however
is that that is NOT the circuit to which i was referring to. The
circuit i was referring to is the kind of circuit you usually
encounter for motor driving applications, the half bridge.
To simulate a half bridge you can simply use a pulse source
(as you have in your circuit) that drives the inductor/resistor
circuit and you dont even need a separate voltage source.<p>Your circuit is interesting and perhaps even useful, but notice
that it requires a 200v transistor to drive a 10v motor! Why
is that? It's because there may be times when the voltage
across the transistor goes very high. Using a half bridge allows
a much more conservatively rated transistor to be used...much closer
to the rating of the motor...which also means higher efficiency
because low voltage MOSFETS can have lower RDS(on) resistance
and the technique doesnt waste power in a discharging resistance.
I wont argue that this is of prime importance for every motor
driving application (such as low current ones) but try to drive
a 100v motor with that circuit and you'll need to find a 2000v
rated MOSFET. Good luck there guy Just in case you do
find one though, maybe your circuit can double as a combination
motor driver/bug zapper <p>Also, how do you define the duty cycle with that circuit?
You cant say the duty cycle is the same as the duty cycle of
the pulse source (in that schematic) because that's not what
appears at the output of the transistor switch. When the
transistor turns off the output goes to a voltage that
is higher then the battery voltage. This means you cant
define the duty cycle the same way you can with a half
bridge or simply a pulse source.<p>If you would like to, you can repeat your experiment with
a pulse source (as in your schematic) driving the inductor
and resistor. You dont need the diode, 180 ohm resistor or
battery to do this.<p>cato:
QUOTE:
"However, you didn't sum them. You only looked at the DC component..."
Yes i did sum them, and the ac components dont contribute to the
dc result. The ac components cause the ripple part, which goes
a little above the dc average and a little below the dc average.
You've really have got to understand how the dc component differs
from the ac component. The dc component passes through the
inductor without change because its reactance to dc is zero.<p>
Take care,
Al
LEDs vs Bulbs, LEDs are winning.

### Who is online

Users browsing this forum: No registered users and 1 guest