S9 · Lesson 21 · Resonant and repetitive control
The internal model principle: zero steady-state error for sinusoids and periodic disturbances
Lesson 10 showed that an integrator in the loop drives a constant error to zero: the controller contains a model of a constant, a pole at . A grid-tied inverter must track a 50 or 60 Hz sinusoid exactly, a disk drive must follow a track that wobbles once per revolution, and a power supply must reject ripple at the line frequency and its harmonics. An integrator can't do those perfectly, but the same idea extends: put a model of the sinusoid, a pair of poles at , inside the controller, and the loop has infinite gain at exactly that frequency. A delay line in positive feedback does it for every harmonic at once. That's the internal model principle, and it's why proportional-resonant and repetitive controllers are standard in power electronics.
- The magnitude of a proportional-resonant controller, with = 50 Hz, in dB against frequency. It's flat at except for a sharp peak, infinite in the ideal form, at 50 Hz.
- A practical version adds damping, , to widen the peak and tolerate grid-frequency drift; the dashed curve shows it with chosen by the slider.
Predict
A PI current controller in a grid inverter has a gain of 20 dB at 50 Hz in its loop. How large is the steady-state error tracking the 50 Hz reference, roughly?
With loop gain = 10 at 50 Hz, the tracking error is ≈ 1/11 ≈ 9% (less if the phase helps, more if it hurts). An integrator gives infinite gain only at DC. A resonant term with poles at ±j2π·50 gives infinite loop gain at 50 Hz and drives that error to zero, which is why grid-tied inverters use proportional-resonant control.
Name it
The internal model principle
To reject or track a signal with zero steady-state error, the loop must contain a model of that signal's generator. A constant comes from , so the loop needs an integrator. A sinusoid at comes from , so the loop needs poles at : infinite gain there, so = 0 at exactly .
Proportional-resonant control
In a rotating (dq) frame a sinusoid becomes a constant and an ordinary PI controller does the job; the PR controller is its equivalent in the stationary frame. Because an ideal resonance is infinitely narrow, a small frequency drift loses most of the benefit, so practical PR controllers use a damped form with bandwidth , and add resonant terms at selected harmonics (3rd, 5th, 7th).
Repetitive control
A periodic disturbance of period contains every harmonic of . Its generator is a delay line in positive feedback: in discrete time with samples per period,
which has poles at all roots of unity: every harmonic up to the Nyquist frequency. Placed in the loop (with a low-pass filter in the feedback for robustness, and phase-lead compensation), it learns the periodic error from cycle to cycle and cancels it. It needs samples of memory and converges over several periods.
Stability
Infinite gain at a frequency is safe only if the loop's phase there allows it. The resonant gain is limited by phase margin near , and a repetitive controller's filter limits how high the learned harmonics go, trading perfect rejection for robustness against unmodeled high-frequency dynamics.
Worked example
A loop has a gain of 10 at 50 Hz with a phase of −120°. What fraction of a 50 Hz reference appears as error, and what would a resonant term do?
Show the solution
- Loop gain as a complex number.
- Return difference. with magnitude 9.54.
- Error. of the reference, in magnitude.
- Add a resonant term. Adding makes infinite at exactly 50 Hz, so the error there is zero.
- If the grid drifts. At 49.5 Hz the error is merely small, which is why damped resonances are used.
Answer 10.5% of the reference appears as error, and a resonant term at 50 Hz makes it zero there.
Worked example
A repetitive controller rejects a 50 Hz periodic disturbance in a converter sampled at 10 kHz. How many samples of memory does it need, and how many harmonics can it address?
Show the solution
- Memory. One location for each sample in a period:
- Harmonics. The poles of sit at every multiple of 50 Hz, so it addresses up to harmonics, up to the 5 kHz Nyquist frequency.
- In practice. The filter limits it to a few kilohertz.
Answer 200 samples of memory, addressing up to 100 harmonics (in practice the Q filter limits it to a few kilohertz).
Worked example
A grid's frequency drifts to 50.5 Hz. A damped PR controller with = 100 and bandwidth = 5 rad/s is tuned to 50 Hz. How much gain does its resonant term give at 50.5 Hz, compared with its peak?
Show the solution
- The damped term. It peaks at = 100 at :
- The two frequencies.
- The denominator at ω. Its real and imaginary parts:
- Magnitude. That's still 39 dB, against 40 dB at the peak.
- Compare an undamped resonance. It would give only about so the damping keeps the gain high across the drift.
Answer 85 (39 dB) at 50.5 Hz, against 100 (40 dB) at the peak; an undamped term would give only about 16.
Check
At the reference frequency, a loop has gain 10 and phase −90°. What percentage of the reference appears as tracking error?
Check
A repetitive controller sampled at 10 kHz rejects a disturbance with a 50 Hz period. How many samples of memory does its delay line need?
Check
A repetitive controller's delay line holds N = 200 samples. Up to how many harmonics of the fundamental do its poles cover, to the Nyquist frequency?
Check
A damped PR controller with = 100 and = 2 rad/s is tuned to 50 Hz. What is its resonant term's gain at 1 Hz above 50 Hz?
Check
Why can a PI controller in a synchronous (dq) reference frame track a 50 Hz current with zero error, while the same PI in the stationary frame can't?
Check
Simulate repetitive control. A plant (a direct feedthrough for simplicity) suffers a periodic disturbance with period N = 20. The controller learns with , where (the reference is zero) and g = 0.9, starting from for the first samples. Run 40 periods and set rms_first and rms_last, the RMS error over the first and last periods.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
A grid-tied inverter with a PI current controller in the stationary frame shows a few percent of current error at 50 Hz and visible 5th and 7th harmonic distortion. Explain why, and what to change, using the internal model principle.
A PI controller contains a model only of constants (its integrator's pole at zero), so it can't drive a 50 Hz error to zero; with finite loop gain at 50 Hz, a few percent of the reference remains as error, and the grid's 5th and 7th voltage harmonics act as disturbances the loop only partly rejects. The internal model principle says the controller must contain the generators of those signals: resonant terms at 50, 250 and 350 Hz, damped to tolerate grid-frequency drift, which give very high loop gain at exactly those frequencies. Alternatively, transforming to a dq frame rotating at 50 Hz turns the fundamental into a constant for an ordinary PI, with extra frames or resonant terms for the harmonics, or a repetitive controller handles every harmonic of 50 Hz at once. Each added resonance must be checked for phase margin.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.