Buck Converter: Closed-Loop Configuration

A buck converter given below has the following parameters: $V_{in}=10\,V$, $V_{out}=5\,V$, $R=5\,\Omega$, $L=2.5\,mH$, $C=220\,\mu F$, and switching frequency of $10\,$kHz. The small-signal transfer function of the converter is given by $$ G_{vd}(s)=\frac{V_{in}}{LCs^2+\displaystyle\frac{L}{R}s+1} $$ The converter is operated in a closed-loop configuration as shown below. Design a PID controller to achieve a first order response in step voltage with a time constant of $10\,$ms.
In [1]:
from IPython.display import Image
Image(filename =r'buck_cl_1_fig_1.png', width=350)
Out[1]:
No description has been provided for this image
In [2]:
# run this cell to view the circuit file.
%pycat buck_cl_1_orig.in

We now replace the strings \$Kp, \$Ki, etc with the values of our choice by running the python script given below. It takes an existing circuit file buck_cl_1_orig.in and produces a new circuit file buck_cl_1.in, after replacing \$Kp, \$Ki, etc with the values of our choice.

In [3]:
import gseim_calc as calc

Vin = 10.0
V1 = 5.0
V2 = 8.0
L = 2.5e-3
C = 220.0e-6
R = 5.0
tstep1 = 50e-3
tstep2 = 50.01e-3

s_Vin = ("%11.4E"%Vin).strip()
s_V1 = ("%11.4E"%V1).strip()
s_V2 = ("%11.4E"%V2).strip()
s_L = ("%11.4E"%L).strip()
s_C = ("%11.4E"%C).strip()
s_R = ("%11.4E"%R).strip()
s_tstep1 = ("%11.4E"%tstep1).strip()
s_tstep2 = ("%11.4E"%tstep2).strip()

Ki = 5.0 # to be changed by user
Kp = 8.0e-3 # to be changed by user
Kd = 2.0e-6 # to be changed by user

s_Ki = ("%11.4E"%Ki).strip()
s_Kp = ("%11.4E"%Kp).strip()
s_Kd = ("%11.4E"%Kd).strip()

l = [
  ('$Vin', s_Vin),
  ('$V1', s_V1),
  ('$V2', s_V2),
  ('$L', s_L),
  ('$C', s_C),
  ('$R', s_R),
  ('$Ki', s_Ki),
  ('$Kp', s_Kp),
  ('$Kd', s_Kd),
  ('$tstep1', s_tstep1),
  ('$tstep2', s_tstep2),
]
calc.replace_strings_1("buck_cl_1_orig.in", "buck_cl_1.in", l)
print('buck_cl_1.in is ready for execution')
buck_cl_1.in is ready for execution
Execute the following cell to run GSEIM on buck_cl_1.in.
In [4]:
import os
import dos_unix
# uncomment for windows:
#dos_unix.d2u("buck_cl_1.in")
os.system('run_gseim buck_cl_1.in')
Circuit: filename = buck_cl_1.in
main: calling solve_sss
solve_sss starting: sss_n_st: 4
solve_sss_ex: sss_iter_newton=0, rhs_sss_norm=5.1754e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=1, rhs_sss_norm=5.0948e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=2, rhs_sss_norm=3.3556e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=3, rhs_sss_norm=2.6388e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=4, rhs_sss_norm=2.1147e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=5, rhs_sss_norm=1.7080e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=6, rhs_sss_norm=1.3684e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=7, rhs_sss_norm=1.0963e-02, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=8, rhs_sss_norm=8.7752e-03, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=9, rhs_sss_norm=7.0270e-03, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=10, rhs_sss_norm=5.6264e-03, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=11, rhs_sss_norm=4.5045e-03, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=12, rhs_sss_norm=7.3134e-05, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=13, rhs_sss_norm=2.8320e-08, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=14, rhs_sss_norm=7.9925e-12, sss_period_1_compute=2.0000e-04
solve_sss_ex: sss_iter_newton=15, rhs_sss_norm=8.6019e-16, sss_period_1_compute=2.0000e-04
solve_sss_ex: calling sss_solve_trns_ex for one more trns step
Transient simulation starts...
i=0
i=1000
main: i_solve = 1
main: calling solve_trns
Transient simulation starts...
i=0
i=10000
i=20000
i=30000
i=40000
i=50000
i=60000
i=70000
GSEIM: Program completed.
Out[4]:
0
In [5]:
# plot Vref(t) and v_out(t)

import gseim_calc as calc

plot_1 = calc.gseim_plot_single(2)

plot_1.l_plots[0].i_slv = 1
plot_1.l_plots[0].i_out = 0
plot_1.l_plots[0].var_name = "v_out"
plot_1.l_plots[0].plot_type = "X-time"
plot_1.l_plots[0].label = "$V_{out}$"
plot_1.l_plots[0].color = "dodgerblue"

plot_1.l_plots[1].i_slv = 1
plot_1.l_plots[1].i_out = 0
plot_1.l_plots[1].var_name = "Vref"
plot_1.l_plots[1].plot_type = "X-time"
plot_1.l_plots[1].label = "$V^{ref}$"
plot_1.l_plots[1].color = "blue"
plot_1.l_plots[1].linewidth = 0.7

plot_1.y_label = ""
plot_1.legend_flag = True
plot_1.legend_position = 'upper left'

calc.plot_single_time(
   infile='buck_cl_1.in',
   t_mult=1e3,
   x_size=5.5,
   y_size=2.5,
   x_label='time (msec)',
   label_font_size=11,
   legend_fontsize=10,
   t_start=0.0,
   t_end=200.0e-3,
   t_offset=0.0,
   plot_1=plot_1)
filename: buck_cl_1.dat
No description has been provided for this image
In [6]:
# estimate the time constant from Vo_avg(t)

import numpy as np
import gseim_calc as calc

slv = calc.slv("buck_cl_1.in")
i_slv = 1
i_out = 0
filename = slv.l_filename_all[i_slv][i_out]
print('filename:', filename)
u = np.loadtxt(filename)
t = u[:, 0]
v_out = slv.get_array_double(i_slv,i_out,"v_out",u)
T = 1/10e3

l1 = calc.avg_rms_1(t, v_out, T)
t_np   = np.array(l1[0])
vo_avg = np.array(l1[1])
vp = (vo_avg-V1)/(V2-V1)

# v(t)-V1 = (V2-V1)*(1-exp((t-tstep)/tau))
#
# v(t)-V1
# ------- = (1-exp((t-tstep))/tau)
#  V2-V1

flag_cross = False

for k, v0 in enumerate(vp):
    if v0 >= 0.6321:
        flag_cross = True
        t_cross = t_np[k]
        break

if flag_cross:
    print('t_cross:', "%11.4E"%t_cross)
    tau = t_cross-tstep1
    print('tau:', "%11.4E"%tau)
else:
    print('t_cross not found, cannot estimate tau')
filename: buck_cl_1.dat
t_cross:  7.0250E-02
tau:  2.0250E-02

This notebook was contributed by Prof. Nakul Narayanan K, Govt. Engineering College, Thrissur. He may be contacted at nakul@gectcr.ac.in.

In [ ]: