Podešavanje regulatora buck konvertora

da pređemo na vektorsku grafiku . . .

In [1]:
%plot inline -f "svg"

da importujemo prethodno izveden model buck konvertora za rc = 0.01 ohm i rl = 0.01 ohm, najmanje prigušen, najteži za podešavanje, izvođenje modela je na sajtu, http://tnt.etf.bg.ac.rs/~ms1ee2/averaged-models-ccm.zip; samo copy-paste

In [2]:
L = 10e-6;
C = 1000e-6;
rc = 0.01;
rl = 0.01;
G = 0;

A1 = [-(G*rc*rl+rl+rc)/(L*(G*rc+1)), -1/(L*(G*rc+1)); 1/(C*(G*rc+1)), -G/(C*(G*rc+1))];
B1 = [1/L, rc/(L*(G*rc+1)); 0, -1/(C*(G*rc+1))];
C1 = [rc/(G*rc+1), 1/(G*rc+1); 1, 0];
D1 = [0, -rc/(G*rc+1); 0, 0];

A2 = [-(G*rc*rl+rl+rc)/(L*(G*rc+1)), -1/(L*(G*rc+1)); 1/(C*(G*rc+1)), -G/(C*(G*rc+1))];
B2 = [0, rc/(L*(G*rc+1)); 0, -1/(C*(G*rc+1))];
C2 = [rc/(G*rc+1), 1/(G*rc+1); 0, 0];
D2 = [0, -rc/(G*rc+1); 0, 0];

# we are done with the parameters, variable names will be reused


# DC Operating point, specify

Vin = 10;
Iout = 2;
D0 = 0.5;

U0 = [Vin; Iout];

# Averaged matrices

A = D0 * A1 + (1 - D0) * A2;
B = D0 * B1 + (1 - D0) * B2;
C = D0 * C1 + (1 - D0) * C2;
D = D0 * D1 + (1 - D0) * D2;


# DC model

X0 = -inv(A) * B * U0;


# Remaining AC model vectors

E = (A1 - A2) * X0 + (B1 - B2) * U0;
F = (C1 - C2) * X0 + (D1 - D2) * U0;

# Expand B and D matrices to cover for d hat

B = [B E];
D = [D F];



# let's use the control package

pkg load control

# form the state space model

converter = ss(A, B, C, D);

# get the transfer functions

Hs = tf(converter)
Transfer function 'Hs' from input 'u1' to output ...

         500 s + 5e+07    
 y1:  --------------------
      s^2 + 2000 s + 1e+08

           2.5e+04 s      
 y2:  --------------------
      s^2 + 2000 s + 1e+08

Transfer function 'Hs' from input 'u2' to output ...

      -0.01 s^2 - 1010 s - 1e+06
 y1:  --------------------------
         s^2 + 2000 s + 1e+08   

         500 s + 5e+07    
 y2:  --------------------
      s^2 + 2000 s + 1e+08

Transfer function 'Hs' from input 'u3' to output ...

        1e+04 s + 1e+09   
 y1:  --------------------
      s^2 + 2000 s + 1e+08

      2 s^2 + 5.04e+05 s + 2e+08
 y2:  --------------------------
         s^2 + 2000 s + 1e+08   

Continuous-time model.

izdvojimo funkciju prenosa $\frac{\widehat{v}_{OUT}}{\widehat{d}}$:

In [3]:
T0 = Hs(1,3)
Transfer function 'T0' from input 'u1' to output ...

        1e+04 s + 1e+09   
 y1:  --------------------
      s^2 + 2000 s + 1e+08

Continuous-time model.

na šta ta funkcija prenosa liči? to je funkcija prenosa u otvorenoj sprezi, polazna

In [4]:
bode(T0)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40 -20 0 20 103 104 105 106 Magnitude [dB] Bode Diagram gnuplot_plot_1a -150 -100 -50 0 103 104 105 106 Phase [deg] Frequency [rad/s] T0 T0

da nađemo $\omega_C$, $f_C$ i marginu faze, pretraživanjem; posle će biti razvijena i funkcija za to

In [5]:
[mag, pha, w] = bode(T0);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  33655.34976
fc =  5356.4
pm =  22.330

imamo diskretne vrednosti za $\omega$; kakve su susedne vrednosti amplitude?

In [6]:
T01 = 20 * log10(mag(i))
T02 = 20 * log10(mag(i+1))
T01 =  0.16825
T02 = -0.082186

nije tako loše nađena nula, mada može i bolje, ili numerički ili linearnom interpolacijom

gde bi bili polovi u otvorenoj sprezi?

In [7]:
pzmap(feedback(T0))
legend('location', 'northwest')
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40000 -20000 0 20000 40000 -120000 -100000 -80000 -60000 -40000 -20000 0 Imaginary Axis Real Axis Pole-Zero Map gnuplot_plot_1a gnuplot_plot_2a

i kakav bi bio step odziv?

In [8]:
step(feedback(T0))
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.5 1 1.5 0 0.0002 0.0004 0.0006 0.0008 y1 Time [s] Step Response gnuplot_plot_1a

mnogo oscilacija, ne baš brzo, greška ustaljenog stanja

prvi regulator, po receptu

postavljamo $\omega_C$; nađemo amplitudu $T_0$ na željenom $\omega_C$ i podesimo $k$ da amplituda postane 1

In [9]:
fc = 10e3
k = 1 / abs(T0(2 * pi * fc))
fc =  10000
k =  3.2598

da nemamo analitički oblik $T_0$, već samo eksperimentalne rezultate, ovo bi išlo pretraživanjem!

funkcija prenosa u otvorenoj sprezi kada smo odredili $k$

In [10]:
T1 = k * T0
Transfer function 'T1' from input 'u1' to output ...

      3.26e+04 s + 3.26e+09
 y1:  ---------------------
      s^2 + 2000 s + 1e+08 

Continuous-time model.
In [11]:
bode(T1)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -20 0 20 40 103 104 105 106 Magnitude [dB] Bode Diagram gnuplot_plot_1a -150 -100 -50 0 103 104 105 106 Phase [deg] Frequency [rad/s] T1 T1

da vidimo šta smo uradili, koliko je sada $\omega_C$ i phase margin (pm, $\varphi_m$)?

In [12]:
[mag, pha, w] = bode(T1);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  62747.32130
fc =  9986.5
pm =  33.980

kako bi to izgledalo u closed loop?

In [13]:
H1 = feedback(T1)
Transfer function 'H1' from input 'u1' to output ...

         3.26e+04 s + 3.26e+09   
 y1:  ---------------------------
      s^2 + 3.46e+04 s + 3.36e+09

Continuous-time model.

a step response?

In [14]:
step(H1)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 1.2 1.4 0 5e-05 0.0001 0.00015 0.0002 0.00025 0.0003 y1 Time [s] Step Response H1 H1

mnogo ringinga i greška ustaljenog stanja, mada ne mnogo velika

da podesimo marginu faze, lead kompenzator, predavanja . . .

In [15]:
finalpm = 58
philead = finalpm - pm
pl = pi / 180 * philead;
t = tan(pl);
p = t + sqrt(1 + t^2);
Hlead = 1 / p * tf([p / wc, 1], [1 / (p * wc), 1])
finalpm =  58
philead =  24.020

Transfer function 'Hlead' from input 'u1' to output ...

      1.594e-05 s + 0.6492
 y1:  --------------------
        1.035e-05 s + 1   

Continuous-time model.

povežemo sada lead kompenzator, ciljna margina 58 stepeni . . . nova open loop transfer function je $T_2$

In [16]:
T2 = series(Hlead, T1)
Transfer function 'T2' from input 'u1' to output ...

         0.5195 s^2 + 7.311e+04 s + 2.116e+09   
 y1:  ------------------------------------------
      1.035e-05 s^3 + 1.021 s^2 + 3035 s + 1e+08

Continuous-time model.
In [17]:
bode(T2)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -20 0 20 40 103 104 105 106 Magnitude [dB] Bode Diagram gnuplot_plot_1a -150 -100 -50 0 103 104 105 106 Phase [deg] Frequency [rad/s] T2 T2

da proverimo šta smo uradili

In [18]:
[mag, pha, w] = bode(T2);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  62747.32130
fc =  9986.5
pm =  58.000

manje više to je to; $f_C$ je dobro kakvim je metodom određeno, . . . biće još rada na tome

kako je to u closed loop?

In [19]:
H2 = feedback(T2)
Transfer function 'H2' from input 'u1' to output ...

             0.5195 s^2 + 7.311e+04 s + 2.116e+09       
 y1:  --------------------------------------------------
      1.035e-05 s^3 + 1.54 s^2 + 7.615e+04 s + 2.216e+09

Continuous-time model.

gde su polovi i nule u zatvorenoj sprezi?

In [20]:
pzmap(H2)
legend('location', 'northwest')
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40000 -20000 0 20000 40000 -120000 -100000 -80000 -60000 -40000 -20000 Imaginary Axis Real Axis Pole-Zero Map H2 H2 gnuplot_plot_2a

kakav je odskočni (step) odziv?

In [21]:
step(H2)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 1.2 0 5e-05 0.0001 0.00015 0.0002 y1 Time [s] Step Response H2 H2

standardno; malo smiren ringing, povecana greška ustaljenog stanja, to je ono što zna da uradi lead kompenzator; nije baš kao na tabli za taj Q faktor; jasno što nije, nije ni ta funkcija prenosa kao ona na tabli; ipak, liči!

da kažemo da je ringing ok; idemo da popravimo grešku ustaljenog stanja lag kompenzatorom; sve prema uputstvu sa sajta, koristimo PI regulator kao lag kompenzator

In [22]:
wl = wc / 10;
Hlag = parallel(1, tf([wl], [1 0]))
Transfer function 'Hlag' from input 'u1' to output ...

      s + 6275
 y1:  --------
         s    

Continuous-time model.

dodamo lag kompenzator i dobijamo:

In [23]:
T3 = series(Hlag, T2)
Transfer function 'T3' from input 'u1' to output ...

      0.5195 s^3 + 7.637e+04 s^2 + 2.575e+09 s + 1.328e+13
 y1:  ----------------------------------------------------
         1.035e-05 s^4 + 1.021 s^3 + 3035 s^2 + 1e+08 s   

Continuous-time model.

to je open loop funkcija prenosa; kako izgleda?

In [24]:
bode(T3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -20 0 20 40 60 102 103 104 105 106 Magnitude [dB] Bode Diagram gnuplot_plot_1a -160 -140 -120 -100 -80 -60 102 103 104 105 106 Phase [deg] Frequency [rad/s] T3 T3

da vidimo šta smo uradili?

In [25]:
[mag, pha, w] = bode(T3);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  62747.32130
fc =  9986.5
pm =  52.289

to je manje više ono što smo hteli!

kako to izgleda u zatvorenoj sprezi?

In [26]:
H3 = feedback(T3)
Transfer function 'H3' from input 'u1' to output ...

             0.5195 s^3 + 7.637e+04 s^2 + 2.575e+09 s + 1.328e+13       
 y1:  ------------------------------------------------------------------
      1.035e-05 s^4 + 1.54 s^3 + 7.941e+04 s^2 + 2.675e+09 s + 1.328e+13

Continuous-time model.

raspored polova

In [27]:
pzmap(H3)
legend('location', 'northwest')
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -60000 -40000 -20000 0 20000 40000 60000 -100000 -80000 -60000 -40000 -20000 0 Imaginary Axis Real Axis Pole-Zero Map H3 H3 gnuplot_plot_2a

i step odziv

In [28]:
step(H3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 1.2 0 0.0002 0.0004 0.0006 0.0008 y1 Time [s] Step Response H3 H3

malo jači ringing od očekivanog, ali to je načelno to!

bode plot u zatvorenoj sprezi:

In [29]:
bode(H3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -25 -20 -15 -10 -5 0 102 103 104 105 106 Magnitude [dB] Bode Diagram gnuplot_plot_1a -80 -60 -40 -20 0 102 103 104 105 106 Phase [deg] Frequency [rad/s] H3 H3

do koje frekvencije imamo dobar tracking?

zabave radi, kako izgleda komprimovani Nyquist po mom algoritmu za finalno dobijenu funkciju prenosa u otvorenoj sprezi?

In [30]:
dodato_nestabilnih_polova = pypass(T3)
dodato_nestabilnih_polova = 0
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -2 -1 0 1 2 -2 -1 0 1 2 gnuplot_plot_1a gnuplot_plot_2a gnuplot_plot_3a gnuplot_plot_4a gnuplot_plot_5a

cute!

drugi regulator, smanjujemo ringing

motiv: da probamo da smanjimo ringing? dižem marginu faze na 76 stepni, puštam još 6 stepeni lufta (književno: margine) da ih pokvari lag kompenzator; šta smoimali od ranije? neće se promeniti pojačanje koje doteruje $\omega_C$

In [31]:
[mag, pha, w] = bode(T1);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  62747.32130
fc =  9986.5
pm =  33.980

da podesimo lead kompenzator za novu marginu faze . . .

In [32]:
finalpm = 82
philead = finalpm - pm
pl = pi / 180 * philead;
t = tan(pl);
p = t + sqrt(1 + t^2);
Hlead = 1 / p * tf([p / wc, 1], [1 / (p * wc), 1])
finalpm =  82
philead =  48.020

Transfer function 'Hlead' from input 'u1' to output ...

      1.594e-05 s + 0.3837
 y1:  --------------------
        6.114e-06 s + 1   

Continuous-time model.

povežemo lead kopenzator . . .

In [33]:
T2 = series(Hlead, T1)
Transfer function 'T2' from input 'u1' to output ...

         0.5195 s^2 + 6.446e+04 s + 1.251e+09   
 y1:  ------------------------------------------
      6.114e-06 s^3 + 1.012 s^2 + 2611 s + 1e+08

Continuous-time model.
In [34]:
bode(T2)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40 -20 0 20 40 103 104 105 106 107 Magnitude [dB] Bode Diagram gnuplot_plot_1a -120 -100 -80 -60 -40 -20 0 103 104 105 106 107 Phase [deg] Frequency [rad/s] T2 T2

da proverimo šta smo uradili? ovo se već ponavlja, ima smisla napraviti funkciju koja traži $\omega_C$ i fazu na $\omega_C$, uz linearnu interpolaciju da popravi rezultat; može i analitički, ali možda bolje ne, da se ostavi prostor za snimljena kružna pojačanja kao ulaz

In [35]:
[mag, pha, w] = bode(T2);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  62458.44712
fc =  9940.6
pm =  81.890

da vidimo closed loop response . . .

In [36]:
H2 = feedback(T2)
Transfer function 'H2' from input 'u1' to output ...

             0.5195 s^2 + 6.446e+04 s + 1.251e+09        
 y1:  ---------------------------------------------------
      6.114e-06 s^3 + 1.532 s^2 + 6.707e+04 s + 1.351e+09

Continuous-time model.
In [37]:
step(H2)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 0 5e-05 0.0001 0.00015 0.0002 0.00025 0.0003 y1 Time [s] Step Response H2 H2

smanjen ringing, povećana greška ustaljenog stanja; očekivano, to je ono što lead kompenzator radi

dodajemo lag kompenzator, recept sa predavanja, . . .

In [38]:
wl = wc / 10;
Hlag = parallel(1, tf([wl], [1 0]))
Transfer function 'Hlag' from input 'u1' to output ...

      s + 6246
 y1:  --------
         s    

Continuous-time model.

dobijamo open loop transfer function:

In [39]:
T3 = series(Hlag, T2)
Transfer function 'T3' from input 'u1' to output ...

      0.5195 s^3 + 6.77e+04 s^2 + 1.653e+09 s + 7.812e+12
 y1:  ---------------------------------------------------
        6.114e-06 s^4 + 1.012 s^3 + 2611 s^2 + 1e+08 s   

Continuous-time model.
In [40]:
bode(T3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40 -20 0 20 40 60 102 103 104 105 106 107 Magnitude [dB] Bode Diagram gnuplot_plot_1a -160 -140 -120 -100 -80 -60 -40 102 103 104 105 106 107 Phase [deg] Frequency [rad/s] T3 T3

da proverimo šta smo uradili?

In [41]:
[mag, pha, w] = bode(T3);
for i = 1 : length(mag) - 1
    if log(mag(i)) > 0 && log(mag(i + 1)) < 0
        wc = w(i);
        break
    endif
endfor
wc
fc = wc / (2 * pi)
pm = 180 + pha(i)
wc =  62458.44712
fc =  9940.6
pm =  76.179

to je to, ono što smo hteli!

da vidimo kako je ovo u zatvorenoj petlji?

In [42]:
H3 = feedback(T3)
Transfer function 'H3' from input 'u1' to output ...

              0.5195 s^3 + 6.77e+04 s^2 + 1.653e+09 s + 7.812e+12        
 y1:  -------------------------------------------------------------------
      6.114e-06 s^4 + 1.532 s^3 + 7.031e+04 s^2 + 1.753e+09 s + 7.812e+12

Continuous-time model.

dođosmo do četvrtog reda: drugog reda sistem, još jedan red za lead kompenzator, još jedan red za lag kompenzator

In [43]:
step(H3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 1.2 0 0.0002 0.0004 0.0006 0.0008 0.001 y1 Time [s] Step Response H3 H3

bolji step response od prethodnog, posmatrajte tačku 1.2, vidi se razlika, manji overshoot

da vidimo closed loop Bode plot? do koje frekvencije je tracking dobar?

In [44]:
bode(H3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40 -30 -20 -10 0 102 103 104 105 106 107 Magnitude [dB] Bode Diagram gnuplot_plot_1a -80 -60 -40 -20 0 102 103 104 105 106 107 Phase [deg] Frequency [rad/s] H3 H3

raspored nula i polova na kraju?

In [45]:
pzmap(H3)
legend('location', 'northwest')
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -30000 -20000 -10000 0 10000 20000 30000 -250000 -200000 -150000 -100000 -50000 0 Imaginary Axis Real Axis Pole-Zero Map H3 H3 gnuplot_plot_2a

kako izgleda komprimovani Nyquist za dobijeni open loop transfer function?

In [46]:
dodato_nestabilnih_polova = pypass(T3)
dodato_nestabilnih_polova = 0
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -2 -1 0 1 2 -2 -1 0 1 2 gnuplot_plot_1a gnuplot_plot_2a gnuplot_plot_3a gnuplot_plot_4a gnuplot_plot_5a

sve očekivano, povećana margina faze, stabilno

treći regulator, hoću još da smanjim ringing

idemo na marginu faze od 90 stepeni; uz to, uvodimo funkciju koja računa $\omega_C$ i fazu na $\omega_C$; dodata je i linearna interpolacija, da dobijemo tačniji rezultat; može i bolje, samo nema potrebe, a ovakav metod omogućava i merena kružna pojačanja kao ulaz, ne samo analitički opisane funkcije

da počnemo od početka, sa $T_0$, da lepo nađemo $\omega_C$

In [47]:
T0
Transfer function 'T0' from input 'u1' to output ...

        1e+04 s + 1e+09   
 y1:  --------------------
      s^2 + 2000 s + 1e+08

Continuous-time model.

ovo je ta nova funkcija, atwc(), imate je u direktorijumu

In [48]:
[wc, fc, pm] = atwc(T0)
wc =  33970.52928
fc =  5406.6
pm =  22.451

da nađemo pojačanje $k$

In [49]:
k = 1 / abs(T0(2 * pi * 10e3))
k =  3.2598

da ubacimo element pojačanja . . .

In [50]:
T1 = series(k, T0)
Transfer function 'T1' from input 'u1' to output ...

      3.26e+04 s + 3.26e+09
 y1:  ---------------------
      s^2 + 2000 s + 1e+08 

Continuous-time model.

da vidimo šta smo uradili?

In [51]:
[wc, fc, pm] = atwc(T1)
wc =  62832.53734
fc =  10000.10890
pm =  34.013

ovo je mnogo bolje nego pre, tačnije; postavljamo marginu faze 96 stepeni za lead kompenzator, ostavljamo 6 stepeni lufta za lag kompenzator, ciljna margina faze je 90 stepeni

In [52]:
finalpm = 96
philead = finalpm - pm
pl = pi / 180 * philead;
t = tan(pl);
p = t + sqrt(1 + t^2);
Hlead = 1 / p * tf([p / wc, 1], [1 / (p * wc), 1])
finalpm =  96
philead =  61.987

Transfer function 'Hlead' from input 'u1' to output ...

      1.592e-05 s + 0.2494
 y1:  --------------------
         3.97e-06 s + 1   

Continuous-time model.

kako izgleda frekvencijska karakteristika ovog kompenzatora?

In [53]:
bode(Hlead)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -10 -5 0 5 10 103 104 105 106 107 Magnitude [dB] Bode Diagram gnuplot_plot_1a 0 10 20 30 40 50 60 103 104 105 106 107 Phase [deg] Frequency [rad/s] Hlead Hlead

da dodamo kompenzator i proverimo efekte . . .

In [54]:
T2 = series(Hlead, T1)
Transfer function 'T2' from input 'u1' to output ...

        0.5188 s^2 + 6.001e+04 s + 8.131e+08   
 y1:  -----------------------------------------
      3.97e-06 s^3 + 1.008 s^2 + 2397 s + 1e+08

Continuous-time model.
In [55]:
bode(T2)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -40 -20 0 20 102 103 104 105 106 107 Magnitude [dB] Bode Diagram gnuplot_plot_1a -120 -100 -80 -60 -40 -20 0 102 103 104 105 106 107 Phase [deg] Frequency [rad/s] T2 T2

provera:

In [56]:
[wc, fc, pm] = atwc(T2)
wc =  62836.24029
fc =  10000.69825
pm =  96.000

to je tačno ono što smo hteli!

da vidimo closed loop response sada?

In [57]:
H2 = feedback(T2)
Transfer function 'H2' from input 'u1' to output ...

             0.5188 s^2 + 6.001e+04 s + 8.131e+08       
 y1:  --------------------------------------------------
      3.97e-06 s^3 + 1.527 s^2 + 6.241e+04 s + 9.131e+08

Continuous-time model.
In [58]:
step(H2)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 0 5e-05 0.0001 0.00015 0.0002 0.00025 0.0003 y1 Time [s] Step Response H2 H2

to je to, smanjena margina faze je popravila step response! samo, steady state error je dodatno povećan; uobičajen efekat lead kompenzatora: što veća popravka faze, to veća pokvarka pojačanja na niskim frekvencijama i greške ustaljenog stanja

dodajemo lag kompenzator

In [59]:
wl = wc / 10;
Hlag = parallel(1, tf([wl], [1 0]))
Transfer function 'Hlag' from input 'u1' to output ...

      s + 6284
 y1:  --------
         s    

Continuous-time model.

da povežemo lag kompenzator, open loop transfer function postaje:

In [60]:
T3 = series(Hlag, T2)
Transfer function 'T3' from input 'u1' to output ...

      0.5188 s^3 + 6.327e+04 s^2 + 1.19e+09 s + 5.11e+12
 y1:  --------------------------------------------------
        3.97e-06 s^4 + 1.008 s^3 + 2397 s^2 + 1e+08 s   

Continuous-time model.

opet sistem četvrtog reda; da proverimo šta smo uradili?

In [61]:
[wc, fc, pm] = atwc(T3)
wc =  63188.78900
fc =  10056.80812
pm =  90.453

da, to je to!

da vidimo closed loop response?

In [62]:
H3 = feedback(T3)
Transfer function 'H3' from input 'u1' to output ...

             0.5188 s^3 + 6.327e+04 s^2 + 1.19e+09 s + 5.11e+12       
 y1:  ----------------------------------------------------------------
      3.97e-06 s^4 + 1.527 s^3 + 6.567e+04 s^2 + 1.29e+09 s + 5.11e+12

Continuous-time model.
In [63]:
step(H3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 0 0.2 0.4 0.6 0.8 1 0 0.0002 0.0004 0.0006 0.0008 0.001 y1 Time [s] Step Response H3 H3

sve očekivano! dodatno smanjen ringing! nije kao po knjizi za sistem drugog reda, ali sistem i nije drugog reda!

closed loop Bode plot, do koje frekvencije je tracking dobar?

In [64]:
bode(H3)
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -30 -20 -10 0 102 103 104 105 106 107 Magnitude [dB] Bode Diagram gnuplot_plot_1a -80 -60 -40 -20 0 102 103 104 105 106 107 Phase [deg] Frequency [rad/s] H3 H3

konačni raspored polova?

In [65]:
pzmap(H3)
legend('location', 'northwest')
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -20000 -10000 0 10000 20000 -350000 -300000 -250000 -200000 -150000 -100000 -50000 0 Imaginary Axis Real Axis Pole-Zero Map H3 H3 gnuplot_plot_2a

da dodamo i komprimovan open loop Nyquist plot?

In [66]:
dodato_nestabilnih_polova = pypass(T3)
dodato_nestabilnih_polova = 0
Gnuplot Produced by GNUPLOT 5.2 patchlevel 8 -2 -1 0 1 2 -2 -1 0 1 2 gnuplot_plot_1a gnuplot_plot_2a gnuplot_plot_3a gnuplot_plot_4a gnuplot_plot_5a

da, to je to! povećana margina faze, smanjen ringing; zadovoljni smo, ali . . .

ovde nije kraj! proverite sistem na tranzijente od znacaja, tipa 20% step u ulaznom naponu ili potrošač sa 50% na 75%, ili . . . pogledajte nelinearna ograničenja, da ne izlazi $d$ izvan opsega (puno), $0 \le d \le 1$ ili neka druga komponenta ne ide u zasićenje? ako ide, smanjite $\omega_C$ i krenite iz početka . . .

pokušajte sve ovo da uradite ručno; shvatićete značaj softverskih alata u elektronici!