0% found this document useful (0 votes)
19 views10 pages

Control Loop Design in PSIM Tutorial

The document is a tutorial on designing control loops using script functions in Altair PSIM, specifically for a buck converter. It details the design of both inner current and outer voltage loops, including the necessary parameters and scripts for implementation. The tutorial also includes Bode plots and time-domain simulations to demonstrate the effectiveness of the designed control loops.

Uploaded by

Vanshika Jindal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views10 pages

Control Loop Design in PSIM Tutorial

The document is a tutorial on designing control loops using script functions in Altair PSIM, specifically for a buck converter. It details the design of both inner current and outer voltage loops, including the necessary parameters and scripts for implementation. The tutorial also includes Bode plots and time-domain simulations to demonstrate the effectiveness of the designed control loops.

Uploaded by

Vanshika Jindal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Control Loop Design Using Script Functions

Altair PSIM Tutorial

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us
Altair PSIM Tutorial / Control Loop Design Using Script Functions

PSIM’s script functions provide the capability for users to design control loops and display the
Bode plots of the plant, controller, and loop transfer functions.
In this tutorial, design of the inner current loop and outer voltage loop of a buck converter using
script functions is described. The control block diagram is shown below.
Vin
+
Gv(s) Gi(s) Limiter Kpwm(s)
iLref(s)
Vref(s) ev(s) ei(s) Power Stage VO(s)
vma(s)
+ + PWM Filter
Load
fsw
i_fb(s) Inner loop: current feedback
Ksen_i

V_fb(s) Outer loop: voltage feedback


Ksen_v

For more information on how to use script functions, please refer to the document “Tutorial – How
to User Script [Link]”.

Buck Converter Circuit

The buck converter is shown below:


Q1 V Vo
L1 ksen_i

i_fb
Q2 ksen_v
Vin C1 R1 V_fb

The operating conditions are:


Vin = 250 V; Vo = 100 V
L1 = 200 uH; C1 = 245 uF; R1 = 0.6 Ohm
Current and voltage sensors: ksen_i = 1/165; ksen_v = 1/100
Switching frequency: fsw = 20 kHz
There are two control loops: inner current loop, and outer voltage loop. The first step is to design
the inner current loop. After that, the voltage loop will be designed.

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 2
Altair PSIM Tutorial / Control Loop Design Using Script Functions

Current Loop Design

The buck converter with the inner current loop is shown below.
Q1 V Vo
iL L1 ksen_i

+ i_fb
Q1 Q2 ksen_v
Vin Q2 Vos C1 R1 V_fb

Vma
V
Kpi_i
1 PI
Q1
Tpi_i
Q2
i_fb
fsw

A PI controller is used for the current loop. The following script is used to design the PI parameters.

// Buck converter - current loop design


PI = 3.14159;

// Parameters
Vin = 250;
L1 = 200u;
C1 = 245u;
R1 = 0.6;

Ksen_i = 1/165;
Ksen_v = 1/100;

// PWM gain: Kpwm = Vin/Vcarrier, with Vcarrier = 1


Kpwm = Vin;

fsw = 20k;

// Desired current loop gain-cross-over frequency fx_i and phase margin

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 3
Altair PSIM Tutorial / Control Loop Design Using Script Functions

fx_i = 2k;
phase_margin_i = 64; // in deg.

// Current PI controller
Kpi_i = 1.30253;
Tpi_i = 140.9973u;

// Plant: Hi(s) = iL / Vos


Hi = formula(1/(s*L1 + R1/(s*R1*C1+1)));

// Current PI: Gi = Ki * (1+sTi) / (sTi)


Gi = formula(Kpi_i*(1+s*Tpi_i)/(s*Tpi_i))

// Current loop transfer function Ti_loop


Ti_loop = Hi*Gi*Ksen_i*Kpwm

// Find Ti_loop at fx_i


s_fx_i = Complex(0, 2*PI*fx_i);
Ti_loop_fx = eval(Ti_loop, s=s_fx_i);
Ti_loop_fx_amp = abs(Ti_loop_fx);
Ti_loop_fx_angle = angle(Ti_loop_fx)*180/PI; // in deg.

phase_margin = 180+Ti_loop_fx_angle; // in deg.

// Bode plot
wmin = 100 *2*PI;
wmax = 50e3 *2*PI;
Freq_rad = ArrayLog(wmin, wmax); // frequency array (rad/sec) from wmin to wmax, in
log scale
Freq_Hz = Freq_rad/(2*PI); // frequency array (Hz) from fmin to fmax, in log scale

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 4
Altair PSIM Tutorial / Control Loop Design Using Script Functions

s = Complex(0, Freq_rad); // Laplace operator

BodePlot("Current Controller", Freq_Hz, Hi, Gi, Ti_loop); // generate Bode plots for
Hi(s), Gi(s), and GiHi(s)

The script functions are highlighted in blue for easy inspection. The script does the following:
₋ Define the plant transfer function Hi(s) = iL / Vos. This expression is obtained from
derivation.
₋ Define the PI controller transfer function Gi(s).
₋ Obtain the current loop transfer function Ti_loop(s), which is equal to Hi(s)*Gi(s), multiplied
by the rest of the gains in the circuit.
₋ With a switching frequency of 20kHz, let’s set the desired gain-cross-over frequency at
2kHz and the phase margin at 64 deg. Through trial-and-error, first adjust Tpi_i manually
until the phase margin is 64 deg. Then adjust Kpi_i until the loop transfer function amplitude
Ti_loop_fx_amp is 1.
From the procedure above, we obtain: Kpi_i = 1.30253, and Tpi_i = 140.9973u. The Bode plots
Hi(s), Gi(s), and Ti_loop(s) are shown below on the left.

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 5
Altair PSIM Tutorial / Control Loop Design Using Script Functions

I(L1)

200

150

100

50

0 0.0005 0.001 0.0015 0.002


Time (s)

The Bode plots show that the current loop has the desired gain-cross-over frequency and phase
margin.
Using the designed PI parameters, we can perform the time-domain simulation. The current
waveform is shown above on the right. The waveform shows a good dynamic response.

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 6
Altair PSIM Tutorial / Control Loop Design Using Script Functions

Voltage Loop Design

After the current loop is designed, we can proceed to design the voltage loop. The buck converter
with both the current loop and voltage loop is shown below.
Q1 V Vo
iL L1 ksen_i

+ i_fb
Q1 Q2 ksen_v
Vin Q2 Vos C1 R1 V_fb

Vma
Iref
V
Kpi_v V Kpi_i
Vref PI PI
Q1
Tpi_v Tpi_i
Q2
V_fb i_fb
fsw

A PI controller is used for the voltage loop. To design the PI parameters, the following script is
written.
// Buck converter - current loop and voltage loop design
PI = 3.14159;

// Parameters
Vin = 250;
L1 = 200u;
C1 = 245u;
R1 = 0.6;

ksen_i = 1/165;
ksen_v = 1/100;

// PWM gain: Kpwm = Vin/Vcarrier, with Vcarrier=1


Kpwm = Vin;

fsw = 20k;

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 7
Altair PSIM Tutorial / Control Loop Design Using Script Functions

// Desired current loop gain-cross-over frequency fx_i and phase margin


fx_i = 2k;
phase_magin_i = 64; // in deg.

// Current PI controller
Kpi_i = 1.30253;
Tpi_i = 140.9973u;

// Desired voltage loop gain-cross-over frequency fx_v and phase margin


fx_v = 500;
phase_magin_v = 60; // in deg

// Voltage loop PI controller


Kpi_v = 0.042;
Tpi_v = 12.34u

//------------------- Current Loop ----------------------


// Plant: Hi(s) = iL / Vos
Hi = formula(1/(s*L1 + R1/(s*R1*C1+1)));

// Current loop PI: Gi = Ki * (1+sTi) / (sTi)


Gi = formula(Kpi_i*(1+s*Tpi_i)/(s*Tpi_i))

// Current loop transfer function Ti_loop


Ti_loop = Hi*Gi*ksen_i*Kpwm

// Current closed loop transfer function Tic_loop


Tic_loop = 1/ksen_i*(Ti_loop/(1+Ti_loop));

//------------------- Voltage Loop ----------------------

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 8
Altair PSIM Tutorial / Control Loop Design Using Script Functions

// Plant: Hv(s) = Vo / iL
Hv = formula(R1/(s*R1*C1+1));

// Voltage loop PI: Gv = Kv * (1+sTv) / (sTv)


Gv = formula(Kpi_v*(1+s*Tpi_v)/(s*Tpi_v))

// Voltage loop transfer function Tv_loop


Tv_loop = Hv*Gv*ksen_v*Tic_loop

// Find Ti_loop at fx_v


s_fx = Complex(0, 2*PI*fx_v);
Tv_loop_fx = eval(Tv_loop, s=s_fx);
Tv_loop_fx_amp = abs(Tv_loop_fx);
Tv_loop_fx_angle = angle(Tv_loop_fx)*180/PI; // in deg.

phase_margin = 180+Tv_loop_fx_angle; // in deg.

// Bode plot
wmin = 100 *2*PI;
wmax = 50e3 *2*PI;
Freq_rad = ArrayLog(wmin, wmax); // frequency array (rad/sec) from wmin to wmax, in
log scale
Freq_Hz = Freq_rad/(2*PI); // frequency array (Hz) from fmin to fmax, in log scale

s = Complex(0, Freq_rad); // Laplace operator

BodePlot("Current Controller", Freq_Hz, Tic_loop, Gv, Tv_loop); // generate Bode plots

In the script, the closed loop transfer function of the current loop, Tic_loop(s), is obtained and is
used for the design of the outer voltage loop.
Let’s set the desired gain-cross-over frequency at 500Hz and the phase margin at 60 deg. for the
voltage loop. The process of designing the voltage PI parameters is similar to that of the current

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 9
Altair PSIM Tutorial / Control Loop Design Using Script Functions

loop. That is, through trial-and-error, adjust Tpi_v until the phase margin is 60 deg. Then adjust
Kpi_v until the gain Tv_loop_fx_amp is 1.
We obtain: Kpi_v = 0.042, and Tpi_i = 12.34u. The Bode plots of Tic_loop(s), Gv(s), and
Tv_loop(s) are shown below on the left.

Vo

120

100

80

60

40

20

Iref*165 I(L1)

200

150

100

50

0 0.001 0.002 0.003 0.004


Time (s)

The Bode plots show that the voltage loop has the desired gain-cross-over frequency and phase
margin.
Using the designed voltage loop PI parameters, we can perform the time-domain simulation. The
voltage and current waveform are shown above on the right. The waveforms show a good dynamic
response.
This example demonstrates that PSIM’s script functions provide a very powerful way to perform
various calculations, including control loop design.

© Altair Engineering, Inc. All Rights Reserved. / [Link] / Nasdaq: ALTR / Contact Us 10

You might also like