You are on page 1of 42

Diseño por medio del Lugar

geométrico de las Raíces usando


Matlab

Dr. Luis Sánchez


MATLAB Control System Toolbox Root Locus Design GUI
MATLAB Control System Toolbox contains two Root Locus design GUI, sisotool and
rltool. These are two interactive design tools for the analysis and design of the single-
input single-output (SISO) linear time-invariant (LTI) control systems. sisotool opens the
SISO Design Tool with Root Locus View and Bode diagram. rltool opens the SISO
Design Tool with only Root Locus view on. These GUI allows you to design
compensators by interacting with the root locus, Bode, and Nichols plots of the open-loop
system. To load an empty SISO Design Tool at MATLAB prompt type:

>> 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:

A. Load a model from the MATLAB workspace.


B. Load a model from a MAT-file
C. Load the model from the SIMULINK diagram

Similarly, rltool opens SISO Design Tool with only the Root
Locus View.

Following examples are used to demonstrate some of the features


of the Root Locus Design.
Ejemplo 01
In the control system shown Gc ( s) is a proportional controller, K .
R( s) 1 C (s)
Gc ( s ) G p ( s) 
 s ( s  2)( s  5)

Using rltool determine the following:

(a) Range of for system stability.


(b) Value of for the complex dominant-poles damping ration of
0.6. For this value of obtain the step response and the time-
domain specifications.
>> Gp = tf(1, [1 7 10 0])
>> rltool

An empty SISO Design Tool opens as shown.


The rltool by default assumes that the compensator is in the forward
path. The FS button toggles between two configurations, placing
the compensator in the feedback or forward path as shown above.
Select Import Model under the File menu. This opens the Import
System Data dialog box, which is shown below. All the available
models will appear in the Model Listbox: The Blocks are coded as F
(A preamplifier), G (Plant model) H (Sensor), K (Compensator) with
default values of 1.
The Other button toggles between the two configurations. Click OK. The root locus
and open-loop Bode diagrams are displayed in the plot regions. The red squares on
the loci represents the closed-loop poles corresponding to gain set point (default
value C(s) = 1).
(a) To find the value of for marginal stability drag the closed-loop pole
along the locus to the -axis intersect. Turn on the Mouse Zoom and drag
the mouse to draw a box around the pole. When the mouse is released,
root locus will zoom in on the selected region. Drag the pole to this
accurate position.
(b) To find the gain for damping ratio of 0.6, drag the complex pole until
the damping ratio displayed in the bottom panel is in the neighborhood of
0.6. Then zoom in and drag the pole until damping ratio is 0.6. The result is
as shown.
From Tools Menu select Loop responses/Close-Loop Step to obtain the
step response. Right-click on the plot, and select Characteristics and then
Rise Time and Peak Overshoot. Left click on the blue dots, this will
display the time-domain specifications shown in the Figure below.
Ejemplo 01
Dado el sistema de la figura, que opera con un factor de
amortiguamiento relativo de 0.174, demuestre que la adición de un
compensador integral ideal reduce a cero el error en estado estable
para una entrada escalón, sin afectar de manera apreciable la
respuesta transitoria.
Ejemplo 02

design a PD controller to yield 16%


overshoot with a threefold reduction in
settling time.
Ejemplo 03

Design a controller (PID) so that the system can operate with


a peak time that is 2/3 of uncompensated system, at 20% OS,
and steady-state error of 0 for a step input
Ejercicio 01

Use MATLAB’s interactive root locus design tools to perform pole


placement, we will consider a unity-feedback control system for the
plant.

The design specifications for the closed-loop step response are:


To graph additional pole constraints, it is necessary to right-click in
the unshaded region of the complex plane (whereas right-clicking
inside a shaded region will bring up the wrong context menu).
To specify a rise-time specification, one must first convert the
specified maximum rise time (tr*) to a critical value of the
undamped natural frequency (ωn*). Using the following aprox.
PID Control con Matlab

Dr. Luis Sánchez


Control PID
we will consider the following unity feedback system:

The output of a PID controller, equal to the control input to the


plant, in the time-domain is as follows:

The transfer function of a PID controller is found by taking the


Laplace transform before.

Kp= Proportional gain Ki= Integral gain Kd= Derivative gain


PID en Matlab
We can define a PID controller in MATLAB using the transfer
function directly, for example:
>>Kp = 1; Ki = 1; Kd = 1;
>>s = tf('s');
>>C = Kp + Ki/s + Kd*s
Alternatively, we may use MATLAB's pid controller
object to generate an equivalent continuous-time controller
as follows:
>>C = pid(Kp,Ki,Kd)

Let's convert the pid object to a transfer function to see that it


yields the same result as above:
>>tf(C)
The Characteristics of PID Controllers
A proportional controller (Kp) will have the effect of reducing
the rise time and will reduce but never eliminate the steady-state
error. An integral control (Ki) will have the effect of eliminating
the steady-state error for a constant or step input, but it may
make the transient response slower. A derivative control (Kd)
will have the effect of increasing the stability of the system,
reducing the overshoot, and improving the transient response.
SETTLING
CL RESPONSE RISE TIME OVERSHOOT S-S ERROR
TIME
Kp Decrease Increase Small Change Decrease
Ki Decrease Increase Increase Eliminate
Kd Small Change Decrease Decrease No Change

Note that these correlations may not be exactly accurate,


because Kp, Ki, and Kd are dependent on each other.
General Tips for Designing a PID
Controller
When you are designing a PID controller for a given
system, follow the steps shown below to obtain a
desired response.
• Obtain the time response of the system without
controller and determine what needs to be improved
• Add a proportional control to improve the rise time
• Add a derivative control to improve the overshoot
• Add an integral control to eliminate the steady-state
error
• Adjust each of Kp, Ki, and Kd until you obtain a
desired overall response
Ejemplo: Control PID-DC Motor Speed
A common actuator in control systems is the DC motor. It
directly provides rotary motion and, coupled with wheels
or drums and cables, can provide translational motion. The
electric circuit of the armature and the free-body diagram
of the rotor are shown in the following figure:
Parámetros físicos para nuestro ejemplo son:
(J) Moment of inertia of the rotor 0.01 kg.m^2
(b) Motor viscous friction constant 0.1 N.m.s
(Ke) Electromotive force constant 0.01 V/rad/sec
(Kt) Motor torque constant 0.01 N.m/Amp
(R) Electric resistance 1 Ohm
(L) Electric inductance 0.5 H

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

• Settling time less than 0.040 seconds


• Overshoot less than 16%
• No steady-state error, even in the presence of a
step disturbance input

Now let's design a PID controller and add it into the


system. First create a new m-file and type in the
following commands (refer to main problem for the
details of getting these commands).
J = 3.2284E-6;
b = 3.5077E-6;
K = 0.0274; R = 4;
L = 2.75E-6;
s = tf('s');
P_motor = K/(s*((J*s+b)*(L*s+R)+K^2));

Recall that the transfer function for a PID controller


has the following form.
Proportional control
Let's first try using a proportional controller with gain ranging
from 1 to 21. An array of LTI models, each with a different
proportional gain, can be built using a for loop. The closed-loop
transfer functions can be generated using the feedback
command. Add the following code to the end of your m-file and
run it in the MATLAB command window:

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.

Kp = 21; Ki = 500; Kd = 0.05; for i = 1:3 C(:,:,i) =


pid(Kp,Ki,Kd); Kd = Kd + 0.1; end sys_cl =
feedback(C*P_motor,1); t = 0:0.001:0.1; 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, K_i = 500
and Different Values of K_d') legend('K_d = 0.05', 'K_d =
0.15', 'K_d = 0.25')
Let's see what happened to the step disturbance response, change
the following commands in your m-file and re-run at the
command line.
dist_cl = feedback(P_motor,C); t = 0:0.001:0.2;
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, K_i = 500 and Different values
of K_d') legend('K_d = 0.05', 'K_d = 0.15', 'K_d = 0.25')
PDI en Simulink
Sintonización de PID de forma
sencilla
https://es.mathworks.com/videos/control-design-made-easy-
93051.html?s_tid=srchtitle

https://es.mathworks.com/videos/data-driven-control-design-a-controller-
when-plant-model-is-not-available-
82028.html?elqsid=1599760163330&potential_use=Education

You might also like