Type 3 Error Compensator design adaptation from Type 2
Show older comments
My professor has given the following code for designing a Type 2 controller
Vs = 10;
fsw = 100e3;%switching frequency
L = 100e-6;
C = 100e-6;
R = 5;
Vp = 3;%PWM peak voltage
rC = 0.5;
%% given crossover frequency, fc
fco = 10e3;
wco = 2*pi*fco;
%% PWM TF
Gpwm = 1/Vp;
Gpwm_gain_in_dB = 20*log10(Gpwm)
%% Buck TF
[num,den] = tfdata(((1/(L*C))*(1+s*rC*C)) / (s^2+(1/(R*C) + (rC/L))*s+1/(L*C)))
Gf = tf(num,den);
figure()
bode(Gf)
[mag_Gf,phase_Gf,wout] = bode(Gf,wco)
mag_Gf_in_dB = 20*log10(mag_Gf)
phase_Gf
%% Finding the open Loop gain w/o controller, GM, PM
Gsw = Vs;
Gol = Gpwm * Gsw * Gf;
figure()
bode(Gol)
title('Gol')
[mag_Gol,phase_Gol] = bode(Gol,wco);
mag_Gol_in_dB = 20*log10(mag_Gol)
phase_Gol
%% Finding required gain and phase of Controller to satisfy PM of between 45 and 60
degree.
% The required gain of the compensated error amplifier = mag_Gol_in_dB + 20log(1/Vp)
CombinedGain = mag_Gol_in_dB
% The phase angle of the compensated error amplifier at the crossover frequency to
% satisfy given PM of 60 degree:
% = PM - (phase_Gol)
PM = 60;
ContPhase = PM - phase_Gf
%% Type 2 controller
R1 = 1e3
R2 = 10^(-CombinedGain/20)*R1
K = tand(ContPhase/2)
C1 = K / (2*pi*fco*R2)
C2 = 1 / (K*2*pi*fco*R2)
%% Error Amplifier Bode plot: PPT7, p43
TF_Vc_over_Vo = (1+(s*R2*C1)) / ((s^2*C1*C2*R2)+(s*(C1+C2))) / R1
wz = 1/(R2*C1)
wp = (C1+C2) / (C1*C2*R2)
figure()
bode(TF_Vc_over_Vo)
[mag_wz,phase_wz] = bode(TF_Vc_over_Vo,wz)
mag_wz_in_dB = 20*log10(mag_wz)
phase_wz
[mag_wp,phase_wp] = bode(TF_Vc_over_Vo,wp)
mag_wp_in_dB = 20*log10(mag_wp)
phase_wp
%% TF of Type 2 controller
[num,den] = tfdata((s+(1/(R2*C1)))/(R1*C2*s*(s+(1/(R2*C2))))); %(7-71)
ContTF = tf(num,den);
figure()
bode(ContTF)
[mag_ContTF,phase_ContTF] = bode(ContTF,wco);
mag_ContTF_in_dB = 20*log10(mag_ContTF)
phase_ContTF
[mag_ContTF_wz,phase_ContTF_wz] = bode(ContTF,wz)
mag_ContTF_wz_in_dB = 20*log10(mag_ContTF_wz)
phase_ContTF_wz
[mag_ContTF_wp,phase_ContTF_wp] = bode(ContTF,wp)
mag_ContTF_wp_in_dB = 20*log10(mag_ContTF_wp)
phase_ContTF_wp
figure()
bode(Gol*ContTF)
[GM,PM] = margin(Gol*ContTF)
%% Verification: Input is Vref, Output is Vout
step(5*Gol*ContTF / (1+Gol*ContTF)
I need to adapt it to a Type 3 controller, using the equations for the R and C values from the textbook

How would i change the code that i have to design a Type 3 error compensator
Answers (0)
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!