# PD compensator matlab

I have a little problem which I cannot understand, control theory is not my specialty but I have been reading on it lately.

I have a buck-boost converter which I modeled on matlab and I am trying to control it with a PD compensator. However, I cannot achieve what is asked in the example namely a crossing frequency of less than 20 KHz and a phase margin of at least 52 degrees.

I suspect I might need to add an extra pole in the PD transfer function but I do not know how to choose the particular pole.

Here is my matlab code so far:

%%Clear
clear all
clc

%%Uncompensated
Tu0 = [10.417];
num = Tu0*[-6.51e-6 1];
denom = [1.72e-8  3.25e-5 1];
Tu = tf(num, denom);

%Compensator (PD)
Gc0 = [0.37];
num2 = Gc0*[5.06e-4 1];
denom2 = [1.54e-7 1];
Ts = tf(num2, denom2);

%Compensated loop gain
Tf = Tu* Ts;

%%Bode Plot
bode(Tu)
%bode(Ts)
grid on
hold on
bode(Tf)

%Stability numbers
[Gm,Pm,Wgm,Wpm] = margin(Tf);
GainFreq = Wgm / (2*pi)
GainMargin = Gm
CrossoverFreq = Wpm /(2*pi) %Crossover frequency has to be less than 10% of the switching frequency: fc <20 KHz
PhaseMargin = Pm  %Phase Margin of at least 52


Thank you in advance for any hint!

• Do you have the Control System Designer app for matlab? I was able to meet thosre requirements using the PID and the Optimization Based tuners. Will add my results as answer shortly... Commented Apr 20, 2018 at 1:43
• I actually have never used simulink, I am solving it with 'a pen and paper'. I am simply using the theory from the Chapter 9 of "Fundamentals of Power electronics" and computing the bode diagrams just like in the code above. Commented Apr 20, 2018 at 1:55

$$C(s) = 2.27\times10^{-5} (s+1.49\times10^4)$$