1.38 How to find closed loop step response to a plant with a PID controller?

Find and plot the step response of the plant \(\frac {1}{s^2+2s+1}\) connected to a PID controller with \(P=10, I=3.7, D=0.7\). Use negative closed loopback.

Mathematica

plant= TransferFunctionModel[1/(s^2 + 2*s + 1),s]; 
kip  = 10; ki = 3.7; kid = 0.7; 
pid  = TransferFunctionModel[ 
          (kip*s + ki + kid*s^2)/s, s]; 
openLoop   = SystemsModelSeriesConnect[ 
   TransferFunctionModel[plant], pid]; 
closedLoop = SystemsModelFeedbackConnect[ 
                  openLoop]; 
input  = UnitStep[t]; 
output = OutputResponse[closedLoop, input, t]; 
 
Plot[{input, output}, {t, 0, 5}, PlotRange -> 
 All, GridLines -> Automatic, 
 GridLinesStyle -> Directive[LightGray, Dashed], 
 Frame -> True, 
 FrameLabel -> {{"y(t)", None}, 
    {"t (sec)", "Step response"}}, 
 BaseStyle -> 12]
 

pict

 

Matlab

close all; clear; 
s        = tf('s'); 
plant    = 1/(s^2 + 2*s + 1) 
kip      = 10; ki = 3.7; kid = 0.7; 
thePID   = pid(kip,kid,kid); 
BLKSYS   = append(thePID,plant); 
Q        = [2 1; 1 -2]; 
closedLoop = connect(BLKSYS,Q,1,2); 
[y,t]   = step(closedLoop); 
plot(t(1:140),y(1:140)); 
xlabel('t (sec)'); ylabel('y(t)'); 
title('step response'); 
grid
 

pict