class: title-slide count: false .logo-title[] ## ELECTENG 311 # Electronics Systems Design ### Closed Loop Controller Design .TitleAuthor[Duleepa J Thrimawithana] --- layout: true name: template_slide .logo-slide[] .footer[[Duleepa J Thrimawithana](https://www.linkedin.com/in/duleepajt), Department of Electrical, Computer and Software Engineering (2021)] --- name: S1 # Learning Objectives - Why do we need closed loop control? - Behavior of a closed loop controller - Steady-state error - Impact of gain on steady-state error - Stability of the controller - PI controllers - Peak current mode control - UC3843 control IC - Functional diagram of a UC3843 - How is peak current mode control achieved? - How to setup the oscillator? - How do we provide a feedback of current? --- class: title-slide layout: false count: false .logo-title[] # Closed-Loop Control ### An Introduction --- layout: true name: template_slide .logo-slide[] .footer[[Duleepa J Thrimawithana](https://www.linkedin.com/in/duleepajt), Department of Electrical, Computer and Software Engineering (2021)] --- name: S2 # Open-Loop Control (PI) .center[
] - If we know precise details of our flyback converter, then for example, using a microcontroller we can generate the correct D for the switch to achieve our target output - We call this type of control **open-loop control** as we do not monitor the converter to deduce D we should be operating at - In real life, component values are not exact and the load resistance will change, making it impossible to know D needed for a specific V
out
[since](https://uoa-ee311.github.io/presentations/AnalogL1/presentation.html#23), \\[ V\_{out} = \sqrt{ {R\_{Load}}/ \left({2f\_s L\_p} \right) } \, V\_{in}D \\] --- name: S3 # Open-Loop Control (PII) .center[
] - A flyback can be modelled as a black box, which takes D as the input and produce V
out
as the output - In the simplest form, ignoring the impact of energy storage elements, this black box mathematically can be represented as a transfer function, T
flybk
, where, \\[ \frac {V\_{out}} {D} = \sqrt{ \frac {R\_{Load}} {2f\_s L\_p} } \, V\_{in} = T\_{flybk} \\] - As an example, if R
Load
changes by twice then V
out
will change by 1.41 times unless we change D --- name: S4 # Demo: Open-Loop Control .questions[ Lets consider the same flyback converter from previous lecture where V
in
=20V, L
p
=5µH, f
s
=100kHz and R
load
=100Ω. If D is held at 0.5 by a microcontroller then it will be generating a 100V output. What will be the output if R
load
increases to 200Ω? Is there a way for the microcontroller to learn the load has changed? ] .center[
] --- name: S5 # Closed-Loop Control & Feedback .center[
] - One way to know if the load or other circuit parameters that impacts V
out
has changed is to measure V
out
and use this information inside the microcontroller to help deduce an appropriate D to use - This means we monitor and use V
out
as a **feedback** to **control** V
out
- We call this type of control **closed-loop** control - There are many ways to use V
out
feedback to derive D but it is not a straightforward task - This is because V
out
is not only a function of R
load
but it also depends on other circuit parameters - A feedback of just only V
out
would not tell us which of those parameters have changed --- name: S6 # Error Voltage .center[
] - As the first step, we can compare the feedback of V
out
with our target or the **reference** V
out
, V
ref
, to determine if D needs to be increased or reduced - V
ref
- V
out
is referred to as the **error voltage**, V
err
- Note that V
out
is directly proportional to D in a flyback converter - A negative V
err
therefore tells that D needs to be reduced - A positive V
err
therefore tells that D needs to be increased - How do we deduce by how much to reduce/increase D by? --- name: S7 # Proportional Controller .center[
] - Since V
out
is proportional to D, we can apply a **proportional gain**, K
p
to V
err
to deduce an approximate D - Looking at [T
flybk
](#S3) we could see that the proportion D needs to be change by depends on which parameter changed - To find which value of K
p
to use, lets express V
out
as a function of K
p
\\[ V\_{out} = V\_{err} K\_{p} T\_{flybk} = \left( V\_{ref} - V\_{out} \right) K\_{p} T\_{flybk} \quad \Rightarrow \quad V\_{out} = V\_{ref} \frac {K\_p T\_{flybk}} {1 + K\_p T\_{flybk}} \\] --- name: S8 # Proportional Gain - K
p
.center[
] - From our [analysis](#S7), we could see that if K
p
is chosen to be large such that K
p
T
flybk
>> 1, then V
out
≈ V
ref
- We could also observe this in our system diagram where D = K
p
V
err
- Since 0 ≤ D ≤ 1, larger the K
p
smaller the V
err
- Thus, a proportional controller with a sufficiently large K
p
will help achieve an V
out
that closely follow a target voltage set by V
ref
- How large can K
p
be and would there be any adverse issues using a large K
p
? --- name: S9 # Demo: Closed-Loop Proportional Control .questions[ Lets consider the same flyback converter where V
in
=20V, L
p
=5µH, f
s
=100kHz and R
load
=100Ω. The simplified T
flybk
we derived ignoring the impact of energy storage elements thus equates to 200. In your design, the user will set V
ref
to program the required V
out
. Explore how K
p
impacts the ability of V
out
to follow V
ref
. If R
load
doubles, how much does V
err
change by? ] .center[
] --- name: S10 # Instability (PI) - V
ref
can be modelled as a sinusoidal signal to emulate a user changing V
ref
to set different V
out
values - Disturbances we make to the system, e.g., changing V
ref
or R
load
, can be considered to generate a spectrum of frequencies - In a real flyback converter, to store energy in L
p
and to charge/discharge C
o
takes time, and thus a change in D does not result in an immediate change in V
out
- The oversimplified T
flybk
ignored these delays - Lets exaggerate these delays and assume that at the frequency of V
ref
the flyback converter introduce a half-cycle delay (i.e. 180
0
delay) - A 180
0
delay to a sinusoidal wave represents a negative gain - Thus, T
flybk
at this specific frequency can be written as -T
flybk
- Note, |T
flybk
| at this frequency might be much less than, \\[ T\_{flybk} = \sqrt{ {R\_{Load}} / ({2f\_s L\_p} }) \, V\_{in} \\] --- name: S11 # Instability (PII) .center[
] - We can express V
out
under the specific conditions mentioned in the previous slide, \\[ V\_{out} = -V\_{ref} \frac {K\_p T\_{flybk}} {1 - K\_p T\_{flybk}} \\] - From this analysis we can see that V
out
tends to infinity when K
p
T
flybk
approaches 1 - Thus to ensure the closed-loop controlled system is **stable**, K
p
needs to be sufficiently small and satisfy K
p
T
flybk
< 1, if T
flybk
introduce a 180
0
delay at a certain frequency - In real life, T
flybk
will have a frequency dependent gain and a phase --- name: S12 # Demo: Instability .questions[ Lets consider the same flyback converter where V
in
=20V, L
p
=5µH, f
s
=100kHz and R
load
=100Ω. V
ref
is modelled as a sinusoidal wave with a 1kHz frequency to represent a user requesting different V
out
values. Lets assume T
flybk
is -10 at 1kHz. Explore how K
p
impacts the stability of the system. ] .center[
] --- name: S13 # Sensitivity to Noise .center[
] - A flyback converter, like any other SMPS, generate significant electromagnetic noise during operation - In addition, V
out
itself has a ripple across it that results from the physical nature of the circuit - A larger K
p
can amplify these unwanted components to a point that they interfere with the closed-loop controller operation - Both the noise and V
out
ripple components couples in with the closed-loop controller mainly though the feedback signal - The selected K
p
must ensure the system is not reacting to noise --- name: S14 # Integral Controller .center[
] - With a proportional controller, we cannot ensure that V
out
is exactly the same as V
ref
(i.e., V
err
= 0) - To avoid this drawback, we can employ an integral controller, which derives D by integrating V
err
over time \\[ D = K\_i \int {V\_{err}} \, \mathrm{d}t \\] - D settles at the correct value as the integrator accumulates the error until V
err
= 0 --- name: S15 # Integral Gain - K
i
.center[
] - Regardless what the **integral gain**, K
i
, is set to, an integral controller achieves 0 steady-state error - A larger K
i
helps the controller to reach steady-state faster - An integral controller introduces a 90
0
phase delay into the system - Together with the phase delay introduced by the flyback converter, this could lead to system reaching instability faster - Care must be taken to ensure the system is stable when using an integral controller --- name: S16 # Demo: Integral Controller .questions[ Lets consider the same flyback converter where V
in
=20V, L
p
=5µH, f
s
=100kHz and R
load
=100Ω. In your design, the user will set V
ref
to program the required V
out
. Explore how K
i
impacts the performance of the controller under a few different V
ref
and R
load
settings. ] .center[
] --- name: S17 # Proportional Integral Controller (PI) .center[
] - We can combine the proportional and the integral controllers to implement a much better controller - This type of controllers are referred to as Proportional Integral or **PI** controllers - K
p
sets the **proportional gain** while K
i
sets the **integral gain** \\[ D = K\_p V\_{err} + K\_i \int {V\_{err}} \, \mathrm{d}t \\] - Increasing K
p
and K
i
helps V
out
to reach towards the target faster but can create overshoot --- name: S18 # Proportional Integral Controller (PII) .left-column[ - Though the integral term in a PI eliminates steady-state error, it adds a phase delay to the system pushing it towards instability - Larger K
i
thus lead to longer settling time - To understand how K
p
and K
i
impacts the closed-loop operation, we can use the S-domain transfer function of a PI controller, \\[ D = K\_p V\_{err} + \frac {K\_i } {s} V\_{err} \quad \Rightarrow \quad \frac {D} {V\_{err}} = T\_{PI} = K\_p + \frac {K\_i } {s} \\] - To help sketch T
PI
bode plot, we can rewrite as, \\[ T\_{PI} = K\_p \frac { s + K\_i / K\_p} {s} = K\_p \frac { s + \omega\_z } {s} \quad \text {where} \quad \omega\_z = \frac {K\_i} {K\_p} \\] - ω
z
sets the frequency at which phase delay drops to 0
0
] .right-column[
] --- name: S19 # Demo: PI Controller .questions[ Lets consider the same flyback converter where V
in
=20V, L
p
=5µH, f
s
=100kHz and R
load
=100Ω. In your design, the user will set V
ref
to program the required V
out
. Explore how K
i
and K
p
impacts the performance of the controller under a few different R
load
settings. Here, we are stepping V
ref
from 100V to 150V at 0.5s. ] .center[
] --- name: S20 # Peak Current Model Controller (PI) .center[
] - Our [analysis of a flyback converter](https://uoa-ee311.github.io/presentations/AnalogL1/presentation.html#16) showed that I
Lp(pk)
is proportional to D \\[ I\_{Lp(pk)} = \frac{V\_{in}}{L\_p} DT\_{s} \quad \Rightarrow \quad D = \frac {f\_s L\_p} {V\_{in}} I\_{Lp(pk)} \\] - As such, instead of directly controlling D, we can control I
Lp(pk)
to achieve a similar outcome - This is **peak current mode control** and is a very common/preferred control method - The output of the PI controller now sets the reference peak current, I
Lp(pk)_ref
--- name: S21 # Peak Current Model Controller (PII) .center[
] - A comparator is commonly used to compare I
Lp
fed to its non-inverting input with I
Lp(pk)_ref
fed to its inverting input - When I
Lp
rises above I
Lp(pk)_ref
, comparator outputs 0 indicating switch should be turned-off - A latch is typically used to hold the off-state of the switch until the end of the time-period - An oscillator connected to the latch sets the switching frequency - Since I
Lp(pk)
provide additional information we can now improve the functionality (e.g., implement input over current protection) --- class: title-slide layout: false count: false .logo-title[] # The UC3843 Controller IC ### Operating Principles --- layout: true name: template_slide .logo-slide[] .footer[[Duleepa J Thrimawithana](https://www.linkedin.com/in/duleepajt), Department of Electrical, Computer and Software Engineering (2021)] --- name: S22 # Proposed Controller Implementation .center[
] - In your project, we will use a UC3843 peak current mode controller IC to drive S
p
in order to generate V
out
requested by the user - The PI controller will be implemented on an ATmega328PB and it will generate I
Lp(pk)_ref
for the UC3843 - Since ATmega328PB does not have a digital-to-analog converter (DAC), we will use its PWM unit with an RC filter to implement a DAC --- name: S23 # UC3843 Functional Diagram .center[
] --- name: S24 # Internal Power Supply Circuitry .center[
] - To power the IC connect a voltage source between VCC (+) and GNG (-) pins - Needs to be more than 8.4V as the undervoltage lockout (UVLO) protection will otherwise turn-off due to insufficient input voltage - Input voltage needs to be less than 30V to avoid damaging the IC - 15V to 20V is a good input voltage to aim for - IC generates its own 5V to power internal circuitry and this is also available at VREF - IC also generate its own 2.5V as a reference but this is not made available for us to use --- name: S25 # Output Circuitry .center[
] - We call this output circuit configuration a **Totem Pole** or a **Push-Pull** configuration - OUTPUT pin can be connected directly to the gate of the MOSFET switch used in our flyback converter through a small resistor - This resistor limits the current drawn from OUTPUT pin to less than 1A - The output of the control circuitry determines if the OUTPUT pin is 0V or VCC - If control circuitry sends logic '1' OUTPUT is 0V (i.e., MOSFET switch is off) - If control circuitry sends logic '0' OUTPUT is VCC (i.e., MOSFET switch is on) --- name: S26 # Control Circuitry - Oscillator .center[
] - Connecting a resistor, R
T
, and a capacitor, C
T
, at the RT/CT pin configures the oscillator to operate at the required PWM frequency, f
s
- Voltage at the RT/CT pin is a sawtooth waveform that has a frequency f
s
- Every time this sawtooth waveform reach its peak voltage the oscillator generates an output pulse that 'sets' the PWM latch - When PWM latch is 'set' it outputs logic '0' making the 'OR' gate output a logic '0' causing MOSFET switch of the flyback converter to turn-on --- name: S27 # Selecting R
T
& C
T
Values .center[
] - The values of R
T
and C
T
determines f
s
(i.e., PWM frequency) - The [datasheet](https://www.ti.com/lit/ds/symlink/uc3843.pdf?ts=1627207030483&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FUC3843) provides a plot that shows the relation between R
T
, C
T
and f
s
- E.g., To setup a 100kHz we can use a 1nF capacitor for C
T
and approximately a 18kΩ resistor for R
T
- Once you connect the selected R
T
and C
T
, the UC3843 will generate a PWM signal at the OUTPUT pin - The duty-cycle, D, of this PWM signal is controlled by the internal comparator that compares I
Lp
with I
Lp(pk)_ref
we generate from the ATmega328PB --- name: S28 # Control Circuitry - OpAmp (PI) .center[
] - The UC3843 has an internal OpAmp to produce I
Lp(pk)_ref
at the inverting input to the comparator - Though we don't need it for our design, we cannot by pass it - The non-inverting terminal of this OpAmp is supplied internally with 2.5V - The inverting terminal, VFB, is available for us to configure it as an inverting amplifier - We do this by connecting resistors R
op1
and R
op2
- We will supply the PI controller output coming from the ATmega328PB to this OpAmp through R
op1
--- name: S29 # Control Circuitry - OpAmp (PII) .center[
] - The output of the OpAmp, V
pi_out
, is a scaled version of V
pi_in
generated by the ATmega328PB, \\[ V\_{pi\\\_out} = 2.5 + \left( 2.5 - V\_{pi\\\_in} \right) R\_{op2}/R\_{op1} \\] - The output from our ATmega328PB (i.e., V
pi_in
) is going to be in the range 1V to about 4V - So lets set R
op1
= 4.7kΩ and R
op2
= 10kΩ in our project (i.e., V
pi_out
= 7.8V - 2.1V
pi_in
) - In this case V
pi_out
changes roughly from 0V to 5V when V
pi_in
changes from 4V to 1V --- name: S30 # Control Circuitry - Comparator (PI) .center[
] - 1.4V is subtracted from V
pi_out
and divided by 3 before feeding to the inverting input of comparator - This sets I
Lp(pk)_ref
and its maximum value is clamped to 1V by a Zener diode - When the voltage at ISENS pin exceeds I
Lp(pk)_ref
, the comparator outputs 1 to reset the latch - When PWM latch is 'reset' it outputs logic '1' making the 'OR' gate output a logic '1' causing MOSFET switch of the flyback converter to turn-off - When the PI controller output, V
pi_in
is 1V (i.e., V
pi_out
≈ 5V), I
Lp(pk)_ref
will be 1V --- name: S31 # Control Circuitry - Comparator (PII) .center[
] - When the PI controller output, V
pi_in
is 4V (i.e., V
pi_out
≈ 0V), I
Lp(pk)_ref
will be 0V - This means I
Lp(pk)_ref
will be a value between 0V and 1V - However, in the generic current mode controller implementation we investigated [earlier](#S21) a larger V
pi_in
should result in a larger peak current - This issue is introduced because V
pi_in
goes through the inverting OpAmp in the UC3843 - We can account for this in our ATmega328PB program --- name: S32 # Designing the Current Sensor (PI) .left-column-50[
] .right-column-50[ - A measurement of I
Lp
needs to be provided at the ISENS pin to enable UC3843 to control I
Lp(pk)
- A current sense resistor, R
i
, can be used to measure I
in
, which is the same as I
Lp
, \\[ V\_{ILp} = I\_{in}R\_i = I\_{Lp}R\_i \\] - Since the maximum value of I
Lp(pk)_ref
is 1V, the **maximum I
Lp(pk)
** allowed is, \\[ I\_{Lp(pk)\\\_{max}} = 1 / R\_i \\] - We should design I
Lp(pk)_max
to be larger than maximum I
Lp(pk)
of our design ] --- name: S33 # Designing the Current Sensor (PII) .left-column-50[
] .right-column-50[ - V
ILp
measurement in practice will have a significant noise content - A RC lowpass filter is used to filter this noise before feeding V
ILp
to ISENSE - Filter needs to pass I
Lp
, which is at f
s
, without attenuation - So the cutoff frequency of the filter could be at about 100 times f
s
\\[ \frac {1} {2 \pi R\_{if}C\_{if} } \geqslant 100f\_s \\] - For practical reasons C
if
should be 100pF or larger ] --- name: S34 # The Recommended Design .zoom15[ .center[
] ] --- name: S35 # Improvements to Consider - While keeping f
s
at 100kHz, can we reduce the size of the transformer? - How small can it be? - Can we reduce the loss in R
i
? - What options are there to reduce loss in R
i
? - Do we need the isolated power module, U2, to power the ATmega328PB? - Can we not power it from V
out
? - Why is the ATmega328PB on the isolated side of the circuit? - Would the design simplifies if the ATmeag328PB is on the input side of the circuit? - Do we need the digital isolator, IC1, in the design? - Are there cost effective alternatives? - Can we design the circuit without the digital isolator? - If so how can we isolate the V
out
measurement? - What other improvements can we do? --- class: title-slide layout: false count: false .logo-title[] # Questions?