Está en la página 1de 20

Universidad de Ingeniería y Tecnología

Department of Electrical Engineering

Lab of Process Control N° 04


Instructors: Arturo Rojas
Ayrton Nieves, Frank Salazar

Lab 4: Predictive Control

Team members:
Marko Puchuri
Bruno Mixán
Jim Fabián Gonzales

Lima, Perú
2021 – 2
Predictive control of a brushed DC electric motor
Lab 4 – Predictive Control

1. Objectives
Design Model-Based predictive control (MBPC) and LQR predictive control systems.
Implement MBPC and LQR predictive control systems.

2. Hardware and Software


No Description Quantity
1 Plants [09] 1
2 Quarc software for Matlab 1
3 PID Tuner guide
4 data_veloc

3. Procedure

1. Show the procedure to obtain the Transfer function (Follow the PID Tuner guide) using the
data from the file data_veloc.mat. Do not use either an offset or a time delay for
estimation. Use the auto-estimation tool and show the percentage of estimation. Compare
the graph obtained using the transfer function with the graph generated by the data given
in data_veloc.mat.

En la Figura 1, se muestra la matriz de data_veloc. En la primera columna se muestra el


tiempo recorrido, en la segunda, el voltaje de entrada y en la tercera, la velocidad en dicho
tiempo. Se asume un tiempo de muestreo de 0.002 segundos debido a la razón del tiempo en
la matriz de datos.

Figura 1: Matriz data_veloc.mat

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

En la figura 2, se muestra el gráfico de datos de la matriz data_veloc y el gráfico obtenido con


el PID Tuner. Este tiene un porcentaje de estimación del 98.64%

Figura 2: Gráfica de la función de transferencia junto al obtenido con los datos de data_veloc.ma t

En la Figura 3, se muestra la función de transferencia obtenida con el PID TUNER.

Figura 3: Función de transferencia

En el listing 1, se muestra el código que se usó para la lectura de datos.

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

clear all; close all; clc;


load('data_veloc.mat')
EntradaV=data_O(:,2);
T=0.002;
Velocidad=data_O(:,3);
FTL0=iddata(Velocidad,EntradaV,T);
tiempo=data_O(:,1);
K=21.324;
tau=1.5239;
plot(tiempo,Velocidad), grid on, title('data given in dataveloc.mat'),
xlabel('tiempo (Seg)'), ylabel('Velocidad')

Listing 1: Código para la lectura de datos y con el K y tau obtenidos del PID TUNER

En la figura 4 se muestra el gráfico de los datos obtenidos del archivo .mat. Este tiene igual
forma al del visto en la figura 2 en el que están ambos.

Figura 4: data given in dataveloc.mat

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

2. Simulate and implement the MBPC control system to control the speed of the nonlinear
load attached to the servomotor of the plant [9]. Use Simulink, the MATLAB Function block
and a step signal with a value of 16 rad/s as the reference. Control specifications required:
percent overshoot < 2%, settling time < 10 s and steady state error < 2%. Compare the
simulation and implementation. Specify the control parameters obtained (percent
overshoot, settling time and steady state error). Use an implementation time of 15 s and
not limit the data points in the scopes.

Simulación:
En la figura 5, se muestra el simulink que se usó para la simulación del MBPC control system.
La función de transferencia es el mismo del inciso anterior.

Figura 5: Simulink simulación MBPC control system.

En la Figura 6, se muestra la respuesta obtenida luego de 15 segundos. Se observa en la


simulación que el sistema llegó a controlarse con las especificaciones requeridas.

Figura 6: Respuesta de la simulación MBPC control System

En el listing 2, se muestra el código que conlleva el bloque de función speedqube de la figura


4. Dentro de la función se muestra los valores de la función de transferencia del inciso
anterior y los valores de tiempo de muestro, alfa y lambda.

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

function u = speedqube(W1,y,y1,u1,up1)
K=21.324;
tau=1.5239;
T=0.4; alf = 0.78; lam = 0.1;
b1=(K*exp(T/tau) - K)/exp(T/tau);
a1=-1/exp(T/tau);
% RESPUESTA AL ESCALON
g1=b1;
g2=-a1*g1+b1;
g3=-a1*g2+b1;
g4=-a1*g3+b1;
g5=-a1*g4+b1;
g6=-a1*g5+b1;
g7=-a1*g6+b1;
g8=-a1*g7+b1;
g9=-a1*g8+b1;
g10=-a1*g9+b1;
g11=-a1*g10+b1;
g12=-a1*g10+b1;
% CONDICIONES INICIALES
up=up1; u=u1; y=y1; yfp=0;
% LAZO DE CONTROL
W2=W1; W3=W1; W4=W1; W5=W1; W6=W1;
W7=W1; W8=W1; W9=W1; W10=W1; W11=W1; W12=W1;
r1=alf*y+(1-alf)*W1;
r2=alf*r1+(1-alf)*W1;
r3=alf*r2+(1-alf)*W1;
r4=alf*r3+(1-alf)*W1;
r5=alf*r4+(1-alf)*W1;
r6=alf*r5+(1-alf)*W1;
r7=alf*r6+(1-alf)*W1;
r8=alf*r7+(1-alf)*W1;
r9=alf*r8+(1-alf)*W1;
r10=alf*r9+(1-alf)*W1;
r11=alf*r10+(1-alf)*W1;
r12=alf*r11+(1-alf)*W1;

yf1=-a1*yfp+(b1)*up;
yf2=-a1*yf1+(b1)*up;
yf3=-a1*yf2+(b1)*up;
yf4=-a1*yf3+(b1)*up;
yf5=-a1*yf4+(b1)*up;
yf6=-a1*yf5+(b1)*up;
yf7=-a1*yf6+(b1)*up;
yf8=-a1*yf7+(b1)*up;
yf9=-a1*yf8+(b1)*up;
yf10=-a1*yf9+(b1)*up;
yf11=-a1*yf10+(b1)*up;

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

yf12=-a1*yf11+(b1)*up;
% LEY DE CONTROL
du = (g1*(r1-yf1)+g2*(r2-yf2) + g3*(r3-yf3)+g4*(r4-yf4) + ...
g5*(r5-yf5)+g6*(r6-yf6) + g7*(r7-yf7)+g8*(r8-yf8) + ...
g9*(r9-yf9)+ g10*(r10-yf10) + g11*(r11-yf11)+ g12*(r12-yf12))/...
(g1^2+ g1^2 + g3^2+ g4^2 + g5^2 + g6^2 + g7^2 + ...
g8^2 + g9^2 + g10^2 + g11^2 + g12^2 + lam);
u = u + du; up=u; % LEY DE CONTROL ACTUAL
end

Listing 2: Bloque de función speedqube.

En la tabla 1 se muestran los resultados y se observa que cumplio con las especificaciones
indicadas.

Simulación

Tiempo de establecimiento 8 seg (a 15.84)

Error en estado estacionario 0%

% Overshoot ---

Tiempo pico ---


Tabla 1: Parámetros de desempeño de la simulación

Implementación:
En la figura 7 se puede apreciar el diagrama de bloques implementados en Simulink junto a
los bloques del qube.

Figura 7: Diagrama de bloques en Simulink

Se cambiaron los siguientes parámetros:


● Periodo: T=0.4;

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

● Alfa: alf = 0.745;


● Lamba: lam = 0.1;

A continuación se muestra la velocidad de la carga no lineal obtenida del scope del simulink:

Figura 8: Respuesta de la simulación MBPC control System

Con el uso de las herramientas del scope, se encuentran los siguientes parámetros de
desempeño.
Implementación

Tiempo de establecimiento 5.67 seg (a 15.84)

Error en estado estacionario 0%

% Overshoot --

Tiempo pico --
Tabla 2: Parámetros de desempeño de la implementación

Finalmente se muestra el qube operando.

Figura 9: Imagen del qube durante la implementación

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

3. Simulate and implement the speed LQR predictive control of the Qube [plant [9]] with
nonlinear load. Use a step signal with a value of 16 rad/s as reference. Use Simulink, the
MATLAB Function block. Compare the simulation and implementation. Specify the control
parameters obtained (percent overshoot, settling time and steady state error). Use an
implementation time of 15 s and not limit the data points in the scopes.

Simulación:
Debido a que se utiliza la función de transferencia usando la transformada z, se halla su
discretización con el código mostrado en el listing 3.

s=tf('s');
K=21.324;
tau=1.5239;
T=0.02;

G=K/(1+tau*s);
Gd=c2d(G,T)

Listing 3: Código de iniciación

En la figura 10 se muestra el diagrama en simulink que se usó. Se trabajó usando la función


de transferencia con transformada z.

Figura 10: Simulink de la consigna 3

La frecuencia con la que se trabaja se redujo de 0.002 a 0.02, ya que la señal no lograba subir.
Dentro del bloque función speed_lqr se tiene el código mostrado en el listing 4.

function u = speed_lqr(x,reference)

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

% Matrices
A=[0.9532 0.1;0 1];
B=[0.1; 1];
C=[1 0];

% Horizonte: 10 - las matrices son con ese rango

CA=[C*A;C*A^2;C*A^3;C*A^4;C*A^5;C*A^6;C*A^7;C*A^8;C*A^9;C*A^10];

ABC=[...
C*B 0 0 0 0 0 0 0 0 0;
C*A*B C*B 0 0 0 0 0 0 0 0;
C*A^2*B C*A*B C*B 0 0 0 0 0 0 0;
C*A^3*B C*A^2*B C*A*B C*B 0 0 0 0 0 0;
C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0 0 0 0;
C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0 0 0;
C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0 0;
C*A^7*B C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0;
C*A^8*B C*A^7*B C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0;
C*A^9*B C*A^8*B C*A^7*B C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B];

G = ABC(:,1:1);
I=eye(1);
lambda = 0.001;

H = (inv(G'*G + lambda*I))*G';

yp = CA*x;
e = reference - yp; % error
dU = H*e; du = dU(1);
u = du;
end

Listing 4: Bloque de función speed_lqr

Se logró los siguientes resultados, mostrados en la figura 11.

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

Figura 11: Simulación de la consigna 3

A continuación, en la tabla 3 se muestran los parámetros de desempeño que se obtuvieron


de la figura 7.

Parámetros de desempeño

Tiempo de establecimiento 1.91 seg (para 15.84)

Error en estado estacionario 0%

% Overshoot ---

Tiempo pico ---


Tabla 3: Parámetros de desempeño de la simulación

Implementación:

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

En la figura 12 se puede apreciar el diagrama de bloques implementados en Simulink junto a


los bloques del qube.

Figura 12: Diagrama de bloques para la implementación

Dado que no lograba controlar a pesar de cambiar los parámetros, se optó por cambiar
ligeramente las matrices de estado. Esto se hizo manteniendo el porcentaje de estimación
respecto a la gráfica obtenida del archivo .mat
A=[1 0.1;0 1];
B=[0.1; 1];
C=[1 0];
Se usaron los siguientes parámetros:
c=2;
lambda = 0.001;

A continuación se muestra la velocidad de la carga no lineal obtenida del scope del simulink:

Figura 13: Gráfica obtenida del scope del diagrama de bloques de la figura 12

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

Se sacan los siguientes parámetros de desempeño

Implementación

Tiempo de establecimiento 0.6 seg (a 15.84)

Error en estado estacionario 0%

% Overshoot --

Tiempo pico --
Tabla 3: Parámetros de desempeño de la implementación

Finalmente se muestra el qube operando.

Figura 13: Imagen del qube durante la implementación

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

4. Simulate and implement the position LQR predictive control of the Qube [plant [9]] with
nonlinear load. Use Simulink, the MATLAB Function block and a signal generator with a
square wave for reference with a frequency of 0.125 Hz and an amplitude of 10. Compare
the simulation and implementation. Specify the control parameters obtained (percent
overshoot, settling time and steady state error). Use an implementation time of 30 s and
not limit the data points in the scopes.

Simulación:
Para realizar la simulación se utilizó el diagrama de bloques mostrado en la figura 14.

Figura 14: Diagrama en Simulink del control de posición LQR predictivo

En el listing 5 se muestra el código de la función position_lqr del bloque función incluído en el


Simulink.

function u = position_lqr(x,ref)
A=[0.9677 0 0.0492;0.0492 1 0.0012; 0 0 1];
B=[0.1149; 0; 1];
C=[1 0 0];

% Horizonte: 10 - las matrices son con ese rango

KCA=[C*A;C*A^2;C*A^3;C*A^4;C*A^5;C*A^6;C*A^7;C*A^8;C*A^9;C*A^10];
KCAB=[...
C*B 0 0 0 0 0 0 0 0 0;
C*A*B C*B 0 0 0 0 0 0 0 0;
C*A^2*B C*A*B C*B 0 0 0 0 0 0 0;
C*A^3*B C*A^2*B C*A*B C*B 0 0 0 0 0 0;
C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0 0 0 0;
C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0 0 0;
C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0 0;
C*A^7*B C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0 0;
C*A^8*B C*A^7*B C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B C*B 0;
C*A^9*B C*A^8*B C*A^7*B C*A^6*B C*A^5*B C*A^4*B C*A^3*B C*A^2*B C*A*B
C*B];

c = 1; G = KCAB(:,1:c); I=eye(c); lambda = 0.2;


H = (inv(G'*G + lambda*I))*G';

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

yp = KCA*x;
e = ref - yp; % error
dU = H*e; du = dU(1);
u = du;
end
Listing 5: Código del bloque de función para el control de la posición.

En la figura 15 se muestra la respuesta del Scope de la simulación para 30 segundos.

Figura 15: Respuesta del sistema de posición

Para la simulación no fue posible controlar la señal, hubo un overshoot muy grande.
Asimismo, no logró subir lo necesario.

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

Implementación:
En la figura 16 se puede apreciar el diagrama de bloques implementados en Simulink junto a
los bloques del qube.

Figura 16: Diagrama en Simulink del control de posición LQR predictivo

Se utilizaron los siguientes parámetros por trial and error y matrices:


Matrices:
A=[1 0 0.05;0.05 1 0.0012; 0 0 1];
B=[0.1149; 0; 1];
C=[1 0 0];
Parámetros:
c = 1;
lambda = 2.5;

A continuación se muestra la velocidad de la carga no lineal obtenida del scope del simulink

Figura 17: Diagrama en Simulink del control de posición LQR predictivo

A continuación, en la tabla 4 se muestran los parámetros de desempeño que se obtuvieron


de la figura 17.

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

Tabla 3: Parámetros de desempeño

Tiempo de establecimiento 0.712 s

Error en estado estacionario 6%

% Overshoot ---

Tiempo pico ----


Tabla 4: Parámetros de desempeño de la implementación

Finalmente se muestra el qube operando.

Figura 18: Imagen del qube durante la implementación

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

4. Observations
Este laboratorio nos ayudó a entender cómo implementar y simular
controladores en sistemas o reales, junto a ello se aprendió qué
parámetros cambiar para poder obtener la respuesta con
especificaciones puntuales. Asimismo, para poder realizar estas
experiencias, se recomienda utilizar filtros y saturadores, debido a que
la señal de la salida que se obtiene tiene un ruido considerable, lo cual
puede alterar los resultados. Además, esto es conveniente para proteger
al equipo y a los usuarios de daños por las posibles oscilaciones de gran
magnitud. Finalmente, se pudo observar que el módulo qube tiene
bastante ruido al tener una carga no lineal y se pudo deducir que esto se
agrava proporcionalmente al tamaño e irregularidad de la misma.

5. Conclusions
● Se logró simular e implementar en las tres consignas los diagramas de
bloques en simulink de cada uno.
● Se logró controlar sin tener overshoot en las 3 implementaciones.
● Se logró conseguir las implementaciones con las especificaciones
requeridas.
● Se logró diseñar controladores utilizando los métodos MBPC y LQR
predictivo para poder controlar la velocidad y la posición de un motor
DC.

References
1. Plant manuals [09]
2. Presentation of SISO and MIMO Predictive Control
1. PID Tuner guide and data_veloc (with nonlinear load)

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

Evaluation Rubric

Competence b1: Capacity for designing and developing experiments (level 1).

Semeste
Course: Feedback Control Systems 1
r:
Applicati
Activity: Lab 4 Predictive Control onweeks 8-9
:
Student (last and
Period 2021-2
first names)
The student
The student receives Elaborated & Ayrton Nieves, Frank
10/2021 hands in the 10/21
the rubric on applied by Salazar
report on
Evaluation Documents
Laboratory: X Workshop Project: Work: Others

Very Unaccep
EVALUATION CRITERIA Good Fair
good -table
PRE LAB
Procedure to obtain the Transfer function of the speed and position
Simulate the MBPC control system to control the speed of the
nonlinear load and manages to fulfill what is required.
Simulate the speed LQR predictive control of the Qube [plant [9]] with
nonlinear load and manages to fulfill what is required.
Simulate the position LQR predictive control of the Qube [plant [9]]
with nonlinear load and manages to fulfill what is required.
LAB EXPERIMENTS
Implement the MBPC control system to control the speed of the
nonlinear load and manages to fulfill what is required. Compare with
simulation.
Implement the speed LQR predictive control of the Qube [plant [9]]
with nonlinear load and manages to fulfill what is required. Compare
with simulation.
Implement the position LQR predictive control of the Qube [plant [9]]
with nonlinear load and manages to fulfill what is required. Compare
with simulation.
WORKTEAM REPORT
Responding the questions on time and with good speaking, writing,
orthography, semantics, clear and concise ideas, images and suitable
schemes. Analyze every figure that is presented.
Total Grade

Universidad de Ingeniería y Tecnología - UTEC


Lab 4 – Predictive Control

Comments on the student:

Dimension Very good Good Fair Unacceptable


Test It recognizes and Recognizes and exposes Recognizes and It does not
exposes, in a clear and the theoretical concepts exposes only some recognize or use
synthetic way, the on which the proposed of the concepts, concepts or
theoretical concepts on objectives are based and presenting theories in the
which the proposed those on which the problems in work to be done.
objectives are based and practical experience to be understanding and /
those on which the carried out is based. or explaining them.
practical experience to
be carried out is based.

Lab The procedures to be The procedures to be The procedures to It does not


experimen followed in the followed in the be followed in the identify, describe,
t laboratory practice are laboratory practice are laboratory practice or list the
clearly and precisely described and listed; and are described and procedures to be
described and listed; and these are coherent to listed. followed in the
these are the optimal achieve the objectives laboratory
ones to achieve the and account for the practice.
objectives and account subject matter analyzed.
for the subject matter
analyzed.
Workteam Reports and explains in a Reports and explains the Reports and Only reports and
report synthetic and clear way obtained objectives, partially explains exposes
all the obtained recognizing potentialities the proposed objectives.
objectives, recognizing and limitations of the objectives, not
the potential and work done. recognizing
limitations of the work potentialities and
done. limitations of the
work done.

Student He/She is 100% engaged He/She is 50% engaged in He/She is 20% He/She is not
attitude in the session lab, in the the session lab, in the engaged in the cooperative,
material and is 100% material and is 50% session lab, in the optimistic, or
enthusiastic about enthusiastic about material and is not constructive.
learning, He/She is able learning, not about enthusiastic about He/she is not
to learn from mistakes getting a particular grade. learning. Rarely, responsible and
and seeks improvement. He/She could learn from he/she could learn do not care about
mistakes and might seeks from mistakes and learning.
improvement. might seeks
improvement.

Universidad de Ingeniería y Tecnología - UTEC

También podría gustarte