Documentos de Académico
Documentos de Profesional
Documentos de Cultura
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.
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.
Figura 2: Gráfica de la función de transferencia junto al obtenido con los datos de data_veloc.ma t
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.
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.
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;
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
En la tabla 1 se muestran los resultados y se observa que cumplio con las especificaciones
indicadas.
Simulación
% Overshoot ---
Implementación:
En la figura 7 se puede apreciar el diagrama de bloques implementados en Simulink junto a
los bloques del qube.
A continuación se muestra la velocidad de la carga no lineal obtenida del scope del simulink:
Con el uso de las herramientas del scope, se encuentran los siguientes parámetros de
desempeño.
Implementación
% Overshoot --
Tiempo pico --
Tabla 2: Parámetros de desempeño de la implementación
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)
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)
% Matrices
A=[0.9532 0.1;0 1];
B=[0.1; 1];
C=[1 0];
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
Parámetros de desempeño
% Overshoot ---
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
Implementación
% Overshoot --
Tiempo pico --
Tabla 3: Parámetros de desempeño de la implementación
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.
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];
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];
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.
Para la simulación no fue posible controlar la señal, hubo un overshoot muy grande.
Asimismo, no logró subir lo necesario.
Implementación:
En la figura 16 se puede apreciar el diagrama de bloques implementados en Simulink junto a
los bloques del qube.
A continuación se muestra la velocidad de la carga no lineal obtenida del scope del simulink
% Overshoot ---
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)
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
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.