Clase Diseño Por Medio Del LGR Usando Matlab
Clase Diseño Por Medio Del LGR Usando Matlab
Clase Diseño Por Medio Del LGR Usando Matlab
>> rltool
>> sisotool
sisotool can also be called with additional arguments. For example,
sisotool(Gp), or sisotool(Gp, Gc). Where Gp is the plant object
model and Gc is the compensator object model.
You can import SISO LTI model into the Root Locus Design as
follows:
Similarly, rltool opens SISO Design Tool with only the Root
Locus View.
Torque (T):
T Kti
La fuerza electromotriz de
retroceso (e): .
e Ke
Requerimientos de diseño
For a 1-rad/sec step reference, the design criteria are the following.
• Settling time less than 2 seconds
• Overshoot less than 5%
• Steady-state error less than 1%
J = 0.01; b = 0.1; K = 0.01; R = 1; L = 0.5;
s = tf('s');
P_motor = K/((J*s+b)*(L*s+R)+K^2);
sys = feedback(P_motor,1);
t = 0:0.01:5; step(sys,t)
grid
figure
Proportional control
Kp = 100; C = pid(Kp);
sys_cl = feedback(C*P_motor,1);
t = 0:0.01:5; step(sys_cl,t)
grid
title('Step Respons with
Proportional Control')
PID control
The addiction an integral term will eliminate the steady-state error to a
step reference and a derivative term will often reduce the overshoot.
Let's try a PID controller with small Ki and Kd.
Kp = 75; Ki = 1; Kd = 1; C = pid(Kp,Ki,Kd);
sys_cl = feedback(C*P_motor,1);
step(sys_cl,[0:1:200]);
title('PID Control with Small Ki and Small Kd')
Modifique las ganancias
In this case, the long tail on the step response graph is due to the fact that the
integral gain is small and, therefore, it takes a long time for the integral action to
build up and eliminate the steady-state error. This process can be speed up by
increasing the value of Ki. Change Ki to 200 as in the following. Rerun the file
and you should get the plot shown below. Again the annotations are added by
right-clicking on the figure and choosing Characteristics from the resulting
menu.
Kp = 100; Ki = 200;
Kd = 1; C = pid(Kp,Ki,Kd);
sys_cl =
feedback(C*P_motor,1);
step(sys_cl, 0:0.01:4) grid on
title('PID Control with Large
Ki and Small Kd')
As expected, the steady-state error is now eliminated much more
quickly than before. However, the large Ki has greatly increased
the overshoot. Let's increase Kd in an attempt to reduce the
overshoot. Go back to the m-file and change Kd to 10 as shown in
the following. Rerun your m-file and the plot shown below should
be generated.
Kp = 100; Ki = 200; Kd =
10; C = pid(Kp,Ki,Kd);
sys_cl =
feedback(C*P_motor,1);
step(sys_cl, 0:0.01:4) grid
title('PID Control …
with Large Ki …
and Large Kd')
Automatic PID Tuning
MATLAB provides tools for automatically choosing optimal PID
gains which makes the trial and error process described above
unnecessary. You can access the tuning algorithm directly
using pidtune or through a nice graphical user interface (GUI)
using pidtool.
pidtuner(P,'p')
Ejemplo 02 Control PID de un sistema de control de
posición con una perturbación d
Requerimientos de diseño
Kp = 1;
for i = 1:3
C(:,:,i) = pid(Kp);
Kp = Kp + 10;
end
sys_cl = feedback(C*P_motor,1);
Now let's see what the step responses look like. Add the following
code to the end of your m-file and again run it in the command
window. You should generate the plot shown in the figure below.
t = 0:0.001:0.2;
step(sys_cl(:,:,1),sys_cl(:,:,2),sys_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a …
Step Reference with
Different Values of K_p')
legend('K_p = 1', …
'K_p = 11', 'K_p = 21')
Let's also consider the system's response to a step disturbance. In this case, we
will assume a reference of zero and look at the how the system responds to the
disturbance by itself.
dist_cl = feedback(P_motor,C);
step(dist_cl(:,:,1), dist_cl(:,:,2), dist_cl(:,:,3), t)
ylabel('Position, \theta (radians)') title('Response to a
Step Disturbance with Different Values of K_p')
legend('K_p = 1',
… 'K_p = 11','K_p = 21')
PI control
Let's first try a PI controller to get rid of the steady-state error due to
the disturbance. We will set Kp = 21 and test integral gains
Ki ranging from 100 to 500. Change your m-file to the following and
run in the command window. You should generate a figure like the
one shown below.
Kp = 21; Ki = 100;
for i = 1:5
C(:,:,i) = pid(Kp,Ki); Ki = Ki + 200;
end
sys_cl = feedback(C*P_motor,1); t = 0:0.001:0.4;
step(sys_cl(:,:,1), sys_cl(:,:,2), sys_cl(:,:,3), t)
ylabel('Position, \theta (radians)')
title('Response to a Step Reference with K_p = 21 and
Different Values of K_i')
legend('K_i = 100', 'K_i = 300', 'K_i = 500')
Now let's see what happened to the step disturbance response.
Change the following commands in your m-file and re-run in the
command window. You should generate a plot like the one shown
in the figure below.
dist_cl = feedback(P_motor,C); step(dist_cl(:,:,1),
dist_cl(:,:,2), dist_cl(:,:,3), t) ylabel('Position, \theta
(radians)')
title('Response to a Step Disturbance with K_p = 21 and
Different Values …
of K_i')
legend('K_i = 100', …
'K_i = 300', 'K_i = 500')
PID control
Adding a derivative term to the controller means that we now have
all three terms of the PID controller. We will investigate derivative
gains Kd ranging from 0.05 to 0.25. Go back to the m-file and
make the following changes. Running the altered m-file will
generate a graph like the one shown below.
https://es.mathworks.com/videos/data-driven-control-design-a-controller-
when-plant-model-is-not-available-
82028.html?elqsid=1599760163330&potential_use=Education