0% found this document useful (0 votes)
14 views

Second Test Control 2

Uploaded by

sergio.vera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Second Test Control 2

Uploaded by

sergio.vera
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Second exam control 2

1st Sergio Vera Leon


Ingenierı́a Mecatronica
2167318
[email protected]

Abstract—In the second exam 3 problems where pre-


sented, the objective of the task is to find controllers and
observers for each plant using the control law, this is to
done using computational tools like Matlab and Simulink
to compute the outputs and give conclusions about the
outcome
Resumen—En el segundo examen se presentaron 3 pro-
blemas, el objetivo de la tarea es encontrar controladores y
observadores para cada planta utilizando la ley de control,
esto se hace utilizando herramientas computacionales como
Matlab y Simulink para calcular los resultados y dar
conclusiones sobre el resultado.
Index Terms—Control, Process, Variables, Space state,
Discrete, Continuous, Poles, Control law, Observer, Trans-
fer function, Simulation

I. I NTRODUCTION
Figura 1. Plant in space state
The control law is useful in a lot of cases, using this
law a plant can be controlled using only one input and
one output because a software tool is used to compute
and simulate the behavior of the plant, there is no need
to feedback all the state variables, this approach gives a
lot of advantages against the traditional approach, using
this law almost every plant can be controlled.
The main goal in this document is to evaluate the
plants presented, interpret them and design the contro-
llers to obtain the desired outputs in the right way

II. T HEORETICAL BACKGROUND


Figura 2. Plant in transfer function
A. System in multiple representations
The first step is to interpret and analyze the given
plant, if its given in transfer function the goal is to pass
it to space state, if its already given in space state its
useful in some cases to have it in transfer function to
visually analyze some aspects of the system.1, 2

B. Characteristics of the system


The second step would be to see if the system is
controllable and observable, this is done to know is
its worth to carry on with the task of designing the
Figura 3. Controlability of a system example
controller. 3, 4,5
Figura 4. Observability of a system example
Figura 7. Desired poles of the plant

Figura 8. Controller example, in this case is a reference follower

gains of the system Kp and Ki 8,9,10.

Figura 5. Pole-Zero map of the example plant


E. Observer
The next step is to implement an observer to simulate
the behavior of the plant and extract the needed data to
C. Desired system control it 11.
Next the desired transfer function and its consequent
poles are found and the characteristic equation for a F. Simulation
second order The last step is to simulate the plant in Simulink to
s2 + 2δωn + ω 2 see the behavior of the plant with the controller 11.
, 6, 7 III. F IRST QUESTION
D. Controller and observer The first question was about finding a Non-minimum
The next step is to implement the desired controller phase third order system and implementing a controller,
and the observer in code to find the values of the control an observer and then the same has to be done but in

Figura 9. Kp gain of the controller

Figura 6. Desired parameters of the plant Figura 10. Ki gain of the controller
Figura 11. Observer and its poles

Figura 14. Code output 2

Figura 12. Simulation block diagram

discrete time. the code output is showed in the next


figures
As we can see in 34, the outputs of the plants ins
continuous and discrete time are different because the
time domain, if we want a correct approximation of a real
life scenario, the best approach is to have a continuous
plant but a discrete control system, also if we see 35 we
can see that the control action is lower for the continuous
plant with discrete controller.
IV. S ECOND QUESTION
The second question was not solved totally, the incom-
plete code is found in the annex section, the code output
is shown in the following images ( 36, 37,38,39,40)
V. T HIRD QUESTION Figura 15. Code output 3

The third question consists in choosing a plant, any


plant, and implement a controller, an observer and then
passing this to the discrete time. The code is found in the
annex section The outputs can be found in the images
from 41 to ??
As we can see in V, the outputs of the plants in
continuous and discrete time are different because the

Figura 16. Code output 4


Figura 13. Code output 1
Figura 17. Code output 5
Figura 23. Code output 11

Figura 24. Code output 12

Figura 18. Code output 6

Figura 25. Code output 13

Figura 19. Code output 7


Figura 26. Code output 14

Figura 20. Code output 8

Figura 27. Code output 15

Figura 21. Code output 9

Figura 22. Code output 10


Figura 28. Code output 16
Figura 34. Simulation outputs
Figura 29. Code output 16

Figura 30. Simulation block diagram 1

Figura 35. Simulation outputs

Figura 31. Simulation block diagram 2

Figura 32. Simulation block diagram 3

Figura 36. Incomplete code part 1

Figura 37. Incomplete code part 2


Figura 33. Simulation block diagram 4
Figura 42. Code output 2

Figura 38. Incomplete code part 3

Figura 43. Code output 3

Figura 39. Incomplete code part 4

Figura 44. Code output 4

Figura 40. Incomplete code part 5

Figura 45. Code output 5

Figura 46. Code output 6


Figura 41. Code output 1
Figura 54. Code output 14

Figura 47. Code output 7

Figura 48. Code output 8 Figura 55. Code output 15

Figura 49. Code output 9


Figura 56. Code output 16

Figura 50. Code output 10

Figura 57. Code output 16

Figura 51. Code output 11

Figura 58. Simulation block diagram 1

Figura 52. Code output 12

Figura 53. Code output 13


Figura 59. Simulation block diagram 2
questions are extracted from [1]
R EFERENCIAS
[1] J. T. Andrade, “Curso: Control 2,” Enero-Junio 2024.

Figura 60. Simulation block diagram 3

Figura 61. Simulation block diagram 4

time domain, if we want a correct approximation of a real


life scenario, the best approach is to have a continuous
plant but a discrete control system, also if we see graph
of the control action we can see that the control action
is much lower for the continuous plant with discrete
controller so we can say that if the plant has a heating
element to control temperature, the heating element is
not going to be overcharged and the energy consumption
of the system is going to be inside normal operating
values. All the theory and codes needed to solve the

[b]

[b]
Figura 62. Outputs of the systems and control actions
A P ÉNDICE

% # Para el sistema

a=[0,1,0,0;0,-5,0,0;0,0,0,1;0,0,0,-2]
b=[0,0;0.5,0;0,0;0,0.5]
c=[1,0,0,0;0,0,1,0]
d = [0,0;0,0]
% pd=[-1,-2]
%%
% Comando para controlabilidad
co=ctrb(a,b)
rangoco=rank(co)
if rangoco==length(a)
disp ("el sistema es controlable")
else disp ("el sistema no es controlable")
end
%%
% Comando para observabilidad
ob=obsv(a,c)
rangoob=rank(ob)
if rangoob==length(a)
disp ("el sistema es observable")
else disp ("el sistema no es observable")
end
%%
% Hallo cita
cita= abs(log (0.1))/(sqrt((piˆ2 + (log (0.1))ˆ2)))
ts= 38
%%
% Hallo wn
wn= 4/(cita * ts)
Listing 1: Second question code part 1
%%
% Ec deseada es sˆ2+(2*cita*wn)+wnˆ2
%
% Escribo la EC deseada

N = 1
D = [1 (2*cita*wn) wnˆ2]
format long
ecdes= tf(N,D)
%%
% Saco polos deseados

polos = roots(D)
p1= polos(1:1)
p2= polos(2:2)
pd=[p1 p2]
%%
% Seguidor multivariable
%
% Seguidor

aa=[a,zeros(4,1);-c,0]
ba=[b;zeros(2,2)]
pda=[pd,-20,-25,-30]
kt=place(aa,ba,pda)
kp=kt(1:1,1:4)
ki=kt(1:1,5:6)
%%
% Observador

po=[-20,-21,-22,-23]
h=place(a',c',po)
h=h'
Listing 2: Second question code part 2
% # Para el sistema
a=[0,1,0,0;3,0,0,2;0,0,0,1;0,-2,-3,0]
b=[0;1;0;0]
c=[1,0,0,0]
d=[0]
%%
% Paso a funcion de transferencia
[num,den]=ss2tf(a,b,c,0)
ft=tf(num,den)
stability = isstable(ft)
if stability ==1
disp ("El sistema es estable")
else disp ("El sistema es inestable")
end
polosGc=pole(ft)
pzplot(ft)
% Comando para controlabilidad
co=ctrb(a,b)
rangoco=rank(co)
if rangoco==length(a)
disp ("el sistema es controlable")
else disp ("el sistema no es controlable")
end
% Comando para observabilidad
ob=obsv(a,c)
rangoob=rank(ob)
if rangoob==length(a)
disp ("el sistema es observable")
else disp ("el sistema no es observable")
end
% Graficar la salida y para una entrada escalon
step(ft)

Listing 3: Third question code part 1


% Hallar la EC deseada
%
% Hallo cita
cita= abs(log (0.1))/(sqrt((piˆ2 + (log (0.1))ˆ2)))
ts= 8
% Hallo wn
wn= 4/(cita * ts)
% Ec deseada es sˆ2+(2*cita*wn)+wnˆ2
N = 1
D = [1 (2*cita*wn) wnˆ2]
format long
ecdes= tf(N,D)
% Saco polos deseados
polos = roots(D)
p1= polos(1:1)
p2= polos(2:2)
pd=[p1 p2]
% Seguidor
aa=[a,zeros(4,1);-c,0]
ba=[b;0]
pda=[pd,-20,-25,-30]
kt=place(aa,ba,pda)
kp=kt(1:1,1:4)
ki=kt(1:1,5:5)
% Observador
po=[-20,-21,-22,-23]
h=place(a',c',po)
h=h'
Listing 4: Third question code part 2
% Paso a discreto el sistema
%% Pasando a tiempo discreto
tm=0.5;
[adis,bdis,cdis,ddis]=c2dm(a,b,c,d,tm,'zoh')
% Paso a discreto los polos deseados
polo1disdes=exp(pd(1)*tm)
polo2disdes=exp(pd(2)*tm)
polosdiscredes=[polo1disdes,polo2disdes]
% Seguidor discreto
polosdiscredesaum=[polosdiscredes,exp(-1*tm),exp(-2*tm),exp(-3*tm)]
aadis=[adis,zeros(4,1);-cdis,1]
badis=[bdis;0]
ktdis=place(aadis,badis,polosdiscredesaum)
kpdis=ktdis(1:1,1:4)
kidis=ktdis(1:1,5:5)
% Observador discreto
polosobservadordis=[exp(-1*tm),exp(-2*tm),exp(-3*tm),exp(-4*tm)];
hdis=place(adis',cdis',polosobservadordis)
hdis=hdis'
% Observador discreto clasico
[numu,denu]=ss2tf(a-h*c,b,kp,0)
[numy,deny]=ss2tf(a-h*c,h,kp,0)
gu=tf(numu,denu)
gy=tf(numy,deny)
% Simulacion
SEGUIDOR_OBSERVADOR_CON_DIS
Listing 5: Third question code part 3

You might also like