S11 · Lesson 19 · Digital control of converters
Sampling the output once per period, digital PWM resolution and the output steps it allows, limit cycles and how to avoid them, the delay budget, and dithering for extra resolution
A growing share of converters are controlled by a microcontroller or a dedicated digital controller rather than an op amp and a comparator. Digital control brings programmable compensation, telemetry, nonlinear tricks and easy multi-phase management. It also brings quantization in two places, the ADC that reads the output and the digital PWM that sets the duty cycle, and delay from sampling and computation. Get the resolutions in the wrong order and the output hunts endlessly between levels; ignore the delay and the phase margin vanishes.
- The curve is the output voltage step a digital PWM can make, , for a buck from 12 V switching at the slider's frequency, against the PWM counter's clock.
- At 500 kHz and a 100 MHz clock the counter has only 200 steps per period: 60 mV per step at the output, coarser than many regulation specifications.
- Higher switching frequencies make it worse, which is why fast digital controllers need hundreds of megahertz of effective clock, or tricks like dithering and delay-line PWM.
Predict
A digital buck from 12 V switches at 500 kHz with a 100 MHz PWM clock; its ADC resolves 10 mV at the output. What happens in steady state?
The PWM can only set the output in 60 mV steps, while the ADC's bin around the setpoint is 10 mV wide. Usually no duty step lands inside it, so the integrator sees an error of one sign, steps the duty, overshoots to an error of the other sign, and steps back: a limit cycle. The cure is a PWM step finer than the ADC step, here a clock of at least 600 MHz or a few bits of dithering.
Name it
Sampling and delay
The controller samples the output once per switching period, often mid-pulse to avoid switching noise, computes a new duty cycle and loads it for the next period. The delay from sample to effect is the computation time plus about half a period for the PWM's hold, so at crossover the loop loses
of phase margin. Crossover is usually kept below for this reason. The compensator itself is designed in the s-domain and mapped to a difference equation (S9 lesson 41's Tustin method) or designed directly in z.
Digital PWM resolution
A counter clocked at can set the pulse width in steps of , so there are steps per period, bits. For a buck each step moves the output by
Limit cycles
With integral action, the output can only settle where the ADC reads zero error. If no achievable PWM level falls inside that ADC bin, the loop toggles between levels forever. The no-limit-cycle conditions are a PWM step finer than the ADC step, , and modest integral gain.
Dithering
Alternating the duty cycle between adjacent steps over a pattern of periods averages to intermediate values, adding k bits of effective resolution at the cost of a small, slow ripple that the output filter removes.
Worked example
A buck makes 1.2 V from 12 V at 500 kHz with a 100 MHz DPWM clock. What output step does the DPWM allow, and what clock would get below a 10 mV ADC step?
Show the solution
- Steps per period. which is 7.6 bits.
- Output step.
- Clock for a 10 mV step.
- How it's done. Hybrid DPWMs combine a counter with a delay line to reach such effective clocks without a 600 MHz counter.
Answer the DPWM moves the output in 60 mV steps, and getting below 10 mV would take a 600 MHz clock.
Worked example
A digital loop samples once per 200 kHz period, takes 2 µs to compute, and crosses over at 20 kHz. How much phase does the delay cost?
Show the solution
- Total delay.
- Phase lost at crossover.
- What it means. A compensator designed for 60° in the analog world would be left with under 30°, so the delay must be included in the design, or the crossover lowered.
Answer the 4.5 µs delay costs 32.4° of phase at crossover.
Worked example
The 200-step DPWM above adds a 4-period dither pattern. What effective resolution results?
Show the solution
- Intermediate values. Four periods let the average duty take three intermediate values between adjacent steps: 2 more bits.
- Effective resolution.
- The cost. The dither leaves a small ripple at well above the loop's crossover and attenuated by the LC filter.
Answer 800 effective steps (2 more bits), 15 mV per step at the output.
Check
A digital PWM counts at 200 MHz for a buck switching at 250 kHz from 48 V.
(a)
How many duty steps per period?
(b)
What output step does each give?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A digital buck from 12 V at 200 kHz has an ADC step of 20 mV at the output.
(a)
What DPWM clock is needed to avoid limit cycles without dithering?
Write units the way you normally would: 1.5 MHz, 1500 kHz and 0.0015 GHz are the same answer.
(b)
With a 100 MHz counter, how many bits of dithering would close the gap?
Check
A digital loop samples once per 200 kHz period, computes in 0.5 µs and crosses over at 20 kHz.
(a)
How much phase does the delay cost?
Check
A 200-step DPWM on a 48 V buck adds a dither pattern lasting 2 to the power 2 periods.
(a)
How many effective steps result?
(b)
What effective output step?
Write units the way you normally would: 1.5 mV, 1500 µV and 0.0015 V are the same answer.
Check
A 100 MHz counter drives a PWM at 100 kHz.
(a)
How many bits of duty resolution is that?
Check
A loop samples at 100 kHz and computes in 3 µs. Its compensator was designed for 50° of margin ignoring delay, at a crossover of 100/10 kHz.
(a)
What margin remains?
Check
Why does a digitally controlled converter with an integrator need a DPWM finer than its ADC?
Check
A digital buck from g volts switches at f with a DPWM clock c, computes in T and crosses over at x (hertz).
Step 1
What output step does one DPWM count give?
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°.
Step 2
What phase does the delay cost, in radians?
Check
Write settle(target, dpwm_step, adc_step, ki, n): simulate an integrating controller over n periods. Each period the output is the duty count times dpwm_step; the ADC reports the error rounded to a multiple of adc_step; an accumulator adds ki times the reported error, and the count is the accumulator rounded to a whole number of dpwm_steps. Start from zero and return the number of distinct outputs over the last 50 periods.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why do digital converter controllers limit their crossover to a tenth of the switching frequency or less?
A digital controller sees the output only once per switching period, needs time to compute, and can only change the duty cycle at the start of the next period, so its correction always lags the measurement by a computation time plus about half a period. That delay costs phase in proportion to frequency, so at a crossover near the switching frequency it would consume all the phase margin. Keeping the crossover well below the switching frequency keeps the delay's phase cost to some tens of degrees, which the compensator can be designed around, and it also keeps the averaged model on which the design rests accurate.
Practice
Keep practicing
9 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.