1

For a simple AM, we multiply a low frequency message signal ( \$\sin(t)\$) with a high frequency carrier (\$\sin(10^6t)\$) to produce two high frequency signals :
$$\sin(t)*\sin(10^6t) = \dfrac{1}{2}\left(\cos[(10^6+1)t] + \cos[(10^6-1)t] \right)$$

I'm hoping there exists a similar formula when we do PWM, but wiki and other sources talk about many other things except a formula like above. So I'm posting this question here. How to represent the output of the comparator waveform mathematically ? Like, the input modulating signal is \$\sin(t)\$, and the input triangular waveform may be some piecewise linear function ? Then what will be the expression for the comparator output ? I mean exactly what frequencies does the output contain ? enter image description here

AgentS
  • 591
  • 6
  • 18
  • 2
    On time domain this is difficult, there is no standard math notation for "rectangular waveform with varying duty-cycle". A comparator function can be generically written as *sgn* of a difference. But on frequency domain you can get a more general understanding of the spectral peaks. Look after "PWM Bessel peaks" on google. This is a good hit:https://pdfs.semanticscholar.org/7e5b/9378d9100f66cebf496aa4e9b6514f88da77.pdf . Another one: https://bib.irb.hr/datoteka/824164.Mrcela_Sumina_Sunde_A_generalized_time_domain_PWM_spectrum_calculation_method.pdf – Vicente Cunha Jun 07 '18 at 01:40
  • @VicenteCunha Thank you. I'm going through that pdf.. It seems they're using \$sgn\$ for the polarity of output, nice.. – AgentS Jun 07 '18 at 01:45

3 Answers3

3

I was looking for an answer to the same question. With help of your picture with the carrier and comparator, I might have a solution:

In time domain, a sawtooth wave can be described as: $$ sawtooth (t) = A \cdot \biggl( \dfrac{t} {T} - \text{floor} \Bigl( \dfrac{t} {T} \Bigr) \biggr) $$

where \$t\$ is the time, \$T\$ the period and \$A\$ the amplitude.

(Probably superfluous, \$\text{floor}(x)\$ rounds \$x\$ down to the closest integer, e.g. \$\text{floor}(2.75)=2\$ ).

For the purpose of comparison (the comparator of your picture), both signals should between the same values, let's choose 0 and 1. (You could also choose -1 and 1).

Therefore, for the carrier signal, choose amplitude \$A = 1\$ and period \$ T = \dfrac{1} {F_{carrier}} \$

$$ carrier(t) = \biggl( F_{carrier} \cdot t - \text{floor} \bigl( F_{carrier} \cdot t \bigr) \biggr) $$

Next, the message signal needs to be fit between 0 and 1. In case of \$\sin(t)\$ this becomes

$$ message(t) = \dfrac{1} {2} + \dfrac{1} {2} \sin(t) $$

The comparator function can mathematically be expressed using \$\text{sgn}(x)\$, so the pulse width modulated wave becomes

$$ pwm(t) = \text{sgn} \Bigl( message(t)-carrier(t) \Bigr)$$


I used this to describe an Arbitrary Behavioral Voltage Source in Spice. I needed to adjust the simulation step size to 1/100 of the the carried period time to get decent results.

You can also express a sawtooth wave as function of arctan and cot, check:

Greenonline
  • 2,064
  • 7
  • 23
  • 38
Huisman
  • 10,594
  • 2
  • 19
  • 40
2

I'm hoping there exists a similar formula when we do PWM

Yes there is. Look at the upper waveform in the picture below: -

enter image description here

Picture source.

It has a mathematical expression for the harmonics produced based on pulse width k and period T. Note that d = k/T. Now look at the formula below (taken from that picture): -

$$a_n = \dfrac{2A}{n\pi}\cdot \sin(n\pi d)$$

Note that \$a_0\$ is just the dc content of the signal.

So your modulation signal amplitude (instantaneous) defines the value of d hence it defines the spectrum of the resulting PWM signal.

Andy aka
  • 434,556
  • 28
  • 351
  • 777
  • *"I'm hoping there exists ... Yes there is"* --- No there isn't (in any case, not that I'm aware of, and not what you explained in this answer). The spectrum of a square wave with duty cycle *d* shows the spectrum of a *DC signal* modulated. The *intuition* is that if the signal changes value very slowly compared to the PWM frequency, then it will exhibit the behaviour of a DC signal (but careful: this is similar to the argument that (historically) led engineers to believe that FM modulation would have extra-low bandwidth, when it turned out to be exactly the opposite!) – Cal-linux Oct 10 '18 at 12:23
  • @Cal-linux and what historical evidence about FM do you have that shows engineers to be unaware about the spectrum of FM. I think you are being needlessly harsh here. – Andy aka Oct 10 '18 at 13:19
  • Perhaps I was. Regarding the FM history: after posting I actually thought about that; in my Analog Communications course, our teacher told us that (that the motivating intuition for FM was the "arbitrarily low" bandwidth), but true: for all I know, that may be just an "engineering urban legend". Maybe a better phrasing would be: your argument is akin to thinking that FM would produce a signal with arbitrarily low bandwidth, just by looking at the effect when considering an "instantaneous" signal value. – Cal-linux Oct 10 '18 at 23:52
  • Please don't paraphrase me by talking about FM. I am stating reality about a PWM signal and you are arguing about the maths. You are actually wrong. – Andy aka Oct 11 '18 at 07:29
  • I'm not paraphrasing anyone --- I'm just presenting an analogy to indicate why your answer (as an answer to this thread's question) is incorrect; notice the emphasis on "as an answer to this question" --- as far as the specific statements you make, nothing in what you say is factually incorrect, of course. Not sure why you seem bothered that I'm talking about the maths, when the subject of this thread specifically asks for a mathematical expression. – Cal-linux Oct 11 '18 at 14:20
  • So I think you must have missed what I said in my final sentence: *your modulation signal amplitude (instantaneous) defines the value of d hence it defines the spectrum of the resulting PWM signal* – Andy aka Oct 11 '18 at 15:22
  • No, I didn't miss that --- that is *precisely* what prompted my response, and precisely what is "wrong" about your answer; if the signal is DC, then all is fine and the spectrum is as you describe; as soon as the signal value changes over time, the argument is entirely invalidated, and the spectrum you show does not correspond to the PWM signal. Looking carefully, the OP wanted a closed-form description of the PWM signal *in the time domain*, so we better stop our discussion, which is actually off-topic for this post. – Cal-linux Oct 11 '18 at 16:25
  • Then you are misreading my words because at any one instant the spectrum is defined by the instantaneous value of the modulation signal and, in the next instant that has changed because the modulation has changed. What other reason would I have for posting the details in the answer. Regarding stopping our discussion, I am defending my answer that you are unable to read properly. – Andy aka Oct 11 '18 at 18:09
  • _" at any one instant the spectrum is defined by the instantaneous value of the modulation signal"_ --- The thing is, this statement is so profoundly and absolutely incorrect, that I'm actually baffled to see such thing coming from you (from whom I usually receive excellent answers whenever I've posted questions here). A spectrum is defined for a *function*, not for a particular value of a function (i.e., a spectrum is only defined for the complete x(t) for _t_ from −∞ to +∞). It does not make sense to talk about "at this precise instant of time, the spectrum is .... ". – Cal-linux Oct 11 '18 at 22:30
0

When modulation Vpp matches triangle Vpp you get 0 to 100% duty cycle and both are within the input Vcm range.

The challenge for fine tuning, if needed , comes from having precise input levels and null or low input offset.

The output frequency is chosen just high enough to prevent LED flicker or motor aliasing with commutation. Usually around 1kHz to 10kHz in some uC with built in PWM or 20kHz to 5MHz for SMPS buck regulators or say >=50kHz for class D audio.

A square wave has only odd harmonics and a narrow pulse has every harmonic up to the period of the pulse and then repeating harmonics up to the period matching the rise time.

Tony Stewart EE75
  • 1
  • 3
  • 54
  • 182
  • Oh so for the frequency of triangle wave, we have to also consider the devices that we connect the PWM signal output to. Good to know. As of now, I don't know fourier much but if I understand correctly, a narrow pulse width contains the maximum sinusoid frequency whose period equals the pulse width. Is that right ? Thank you :) – AgentS Jun 07 '18 at 01:54
  • If the output frequency depends on the pulse width, then it contains all the frequencies, because the comparator output can contain *any* pulse width. This seems like an issue for bandwidth ? – AgentS Jun 07 '18 at 01:57
  • Yes the Bandwidth is very high but in an unlimited channel, no sweat, so just limited by rise time so not efficient for BW but cheap and efficient for power – Tony Stewart EE75 Jun 07 '18 at 03:13