C29 of 30
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C2 · Lesson 9 · Square waves and pulses

Rise time, ripple, tilt and averaging a PWM signal

Digital signals are square waves, and every wire and input they meet has some resistance and capacitance, so each edge becomes a little RC transient. Whether the result is a crisp square wave, a rounded one or a nearly flat average depends on one comparison: the time constant against the time between edges. The same comparison explains why a microcontroller's PWM pin can act as a cheap analog output, and why a coupling capacitor makes a long pulse sag.

  • A square wave drives a high-pass RC circuit: C in series, then R to ground. The output spikes at each edge and decays with τ = RC.
  • With τ much longer than the period, the output is the square wave with its average removed, and each flat top sags slightly: tilt.
  • With τ much shorter, only the edges get through: the circuit differentiates the square wave into spikes.

Predict

A 5 V, 20 kHz PWM signal at 30% duty is smoothed by a 10 kΩ, 1 µF low-pass. About what voltage comes out?

Name it

Edges and rise time

A step through an RC low-pass rises as 1−e−t/τ. Its 10-90% rise time is

tr=τln⁡9=2.2τ

A square wave whose half-period is several τ long comes through with rounded but complete edges; one whose half-period is shorter never reaches the top before turning around.

The periodic steady state

After many cycles, a low-pass driven by a 0 to V square wave at 50% duty swings around V/2 with a peak-to-peak ripple of

Vtanh⁡T4τ≈VT4τ(τ≫T)

For duty D, the average is DV and the ripple for τ≫T is about VD(1−D)Tτ. A PWM output plus a low-pass is a simple digital-to-analog converter, trading ripple against how quickly the output can change.

The high-pass side

Swap R and C and the circuit passes changes and blocks the average. For τ ≫ the pulse width tp, a flat pulse droops by a fraction

1−e−tp/τ≈tpτ

called tilt. For τ ≪ tp, the output is a spike at each edge: the circuit approximately differentiates its input, as the low-pass with τ ≫ T approximately integrates it.

Rise time and bandwidth

The same RC that rounds edges limits frequency response: its bandwidth is f3dB=12πτ, so tr=0.35f3dB, a rule used for scopes and amplifiers too (C4).

Worked example

A 0 to 5 V, 100 Hz square wave drives a 1 kΩ, 1 µF low-pass. Does the output reach the top, and what is its rise time?

Show the solution
  1. Time constant. τ=RC=1kΩ×1μF=1ms
  2. How far each half gets. The half-period is 5 ms = 5τ, so each half reaches 1−e−5=99.3% of the way: clean, rounded edges.
  3. Rise time. tr=2.2×1ms=2.2ms

Answer yes, each half reaches 99.3% of the way, and the rise time is 2.2 ms.

Worked example

The same filter at 1 kHz: what does the output look like?

Show the solution
  1. Compare the period with τ. Now T = 1 ms equals τ, so the output never settles: it rises and falls exponentially around 2.5 V.
  2. Ripple. Δv=5tanh⁡14=1.22V peak to peak.

Answer a rounded triangle wave around 2.5 V, with 1.22 V of ripple peak to peak.

Worked example

A microcontroller makes a voltage by filtering a 5 V PWM signal at 25% duty, 1 kHz, through an RC with τ = 100 ms. What's the output and how much does it ripple?

Show the solution
  1. Average output. With τ far longer than the 1 ms period, the capacitor settles to the average: 5×0.25=1.25V
  2. Why it ripples. During each on-time it charges slightly and during each off-time it discharges.
  3. Ripple size. For τ ≫ T the peak-to-peak ripple is about Δv≈VD(1−D)Tτ=5V×0.25×0.75×1100=9.4mV
  4. Trade-offs. A longer τ cuts the ripple but slows the response to duty changes; a two-stage filter, or a faster PWM, does better on both.

Answer the output sits at 1.25 V with about 9.4 mV of ripple peak to peak.

Check

An RC low-pass has R = 10 kΩ and C = 1 nF. What is its 10-90% rise time?

Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.

Check

A 0 to 3.3 V square wave at 10 kHz (50% duty) drives an RC low-pass with τ = 10 ms. What is the output ripple, peak to peak?

Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.

Check

A 0 to 5 V PWM signal at 10% duty is heavily low-pass filtered. What average comes out?

Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.

Check

A 0 to 3.3 V PWM signal at 20 kHz and 20% duty is filtered with τ = 20 ms. Roughly what ripple remains?

Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.

Check

A pulse 10 µs long passes through a high-pass RC with τ = 1 ms. By what percentage does its flat top droop?

Check

An RC-limited system has a 10-90% rise time of 1 ns. What is its bandwidth?

Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.

Check

A 3.3 V PWM signal at 0.25 duty is filtered by an RC whose time constant is 200 periods.

(a)

What's the output's average?

Write units the way you normally would: 1.5 V, 1500 mV and 0.0015 kV are the same answer.

(b)

About how much does it ripple, peak to peak?

Check

A PWM wave of amplitude V, duty D and period T is filtered by RC = t (t ≫ T).

Step 1

What's the average output?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why does a coupling capacitor make a long, flat pulse sag, but pass a short pulse almost unchanged?

Practice

Keep practicing

10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.