Report Phase 1
Report Phase 1
Phase 1
Prof. Kebriaei
December 24, 2022
Shiva Shakeri
1
Contents
1. Introduction 3
4. Equilibrium Points 5
5. Linearization 6
6. State-Space Analysis 7
7. Transfer Function 10
8. PID Controller 11
Appendix A. 20
2
1. Introduction
Magnetic levitation system is known as electro-mechanical systems in which an object is
levitate in speci c region without using any support. Now a days this technology is spreading
over a wide range because of its contact-less and friction-less properties as it removes energy
losses which occur due to friction. Since this technology was developed, researchers have
analyzed a large number of such systems. In the analysis of such systems most of the work has
been done on designing of controller as they require appropriate control action and are more
complex, such as State space controller, feedback linearization is used to control the position of
ball. However, there are mostly highly non-linear systems and open loop unstable. This
nonlinearity and unstability feature of magnetic levitation systems makes their control and
modeling very challenging.
The problem of controlling the magnetic eld by control method is taken up to levitate a metal
hollow sphere, here. The control problem is to supply controlled position of the ball such that the
magnetic force on the levitated body and gravitational force acting on it are exactly equal. Thus
the magnetic levitation system is inherently unstable without any control action.
The objective of the work can be directed to design controller considering the linear model as
well as nonlinear model. The controller designed is validated by simulating and implementing on
real time system.
3
fi
fi
2. Magnetic Levitation System
2.1. Model Diagram
An overview of the general structure of a magnetic levitation system can be found in
Figure 1. Basically, an electromagnet and a metal ball make up the core of this system.
4
N ×s
fv Air Resistance(Friction) 0.04
m
y⋆ Output Operating Point 0.06m
As a result of writing the dynamic and physical equations for this system, we can nd the
state equations as follows.
x·1 = x 2
x 32 fv x 2
x·2 = − g + c
M 0.1 − x1
− M {y = [1,0,0]x
x·3 = L1 (−R x3 + u)
4. Equilibrium Points
At equilibrium points, the system doesn't change at all, and that means that the
parameters of the system should be equal to zero at that point. In order to nd the equilibrium
points of the system, we set the state equations to zero. Appendix A contains the Matlab code for
this part.
x2 = 0
c x 32 fv x 2
−g + M 0.1 − x1
− M
=0
1
L
(−R x3 + u) = 0
5
fi
fi
x2 = 0
0.3 x 32 0.04x 2
−9.8 + 0.491 0.1 − 0.06
− 0.491
=0
1
0.2
(−50x3 + u) = 0
By solving the equations, x1, x 2, and x3 are:
x1 = 0.06 x1 = 0.06
x2 = 0 ,and x2 = 0
x3 = − 0.800983 x3 = 0.800983
There are two values of x3, which show the current, meaning that the current can flow
clockwise or counterclockwise. The next section of the problem will be solved using the positive
value of the current flow.
5. Linearization
In order to determine a state-space equation for the system, the system has to be
linearized. Assume that x·1 = f (x1, x 2, x3), x·2 = g(x1, x 2, x3), and x·3 = h(x1, x 2, x3). Appendix A
contains the Matlab code for this part. The Jacobian Matrix is:
∂f ∂f ∂f
∂x1 ∂x 2 ∂x3 0 1 0
∂g ∂g ∂g 0.611x 32 1.222x3
A= ∂x1 ∂x 2 ∂x3
→A= −0.0814
(0.1 − x1) 2 −0.1 − x1
∂h ∂h ∂h 0 0 −250
∂x1 ∂x 2 ∂x3
In order to linearize the system, the equilibrium points take place in the Jacobian Matrix.
0 1 0 0 1 0
A1 = 245 −0.0814 −24.47 , A2 = 245 −0.0814 24.47
0 0 −250 0 0 −250
0 1 0 0 0 1 0 0
·x = 245 −0.0814 −24.47 x + 0 u, x· = 245 −0.0814 24.47 x + 0 u
1 1
0 0 −250 L
0 0 −250 L
6
λ1 = − 250 λ1 = − 250
eig(A1) = λ 2 = − 15.7, eig(A2 ) = λ 2 = − 15.7
λ3 = 15.61 λ3 = 15.61
The eigenvalues of the linearized matrix are both real positive and negative values.
Therefore, the linearized system is unstable and the equilibrium points for the non-linear system
is also unstable.
6. State-Space Analysis
Controllability and observability of control systems are two of the major concepts of
modern control system theory. These concepts were introduced by R. Kalman in 1960. The
following are some de nitions that can be used to describe them. Appendix A contains the
Matlab code for this part.
6.1. Controllability
As a result of applying the theorem 1, we can determine whether the system is
controllable.
0 1 0 0 0
A1B = 245 −0.0814 −24.47 0 = −122.35
0 0 −250 5 −1250
0 1 0 0 0
A2 B = 245 −0.0814 24.47 0 = 122.35
0 0 −250 5 −1250
7
fi
245 −0.0814 −24.47 0 −122.35
A12 B = −19.943 245 6119.5 0 = 30597.45
0 0 62500 5 312500
6.2. Observability
By using the theorem 2, one can determine the observability of a system.
0 1 0
CA1 = [1 0 0] 245 −0.0814 −24.47 = [0 1 0]
0 0 −250
0 1 0
CA2 = [1 0 0] 245 −0.0814 24.47 = [0 1 0]
0 0 −250
8
245 −0.0814 24.47
CA22 = [1 0 0] −19.943 245 6119.5 = [245 −0.0814 24.47]
0 0 62500
1 0 0 1 0 0
→ Φo1 = 0 1 0 , Φo2 = 0 1 0
245 −0.0814 −24.47 245 −0.0814 24.47
The observability matrix has the rank 3 and its vectors are linearly independent. Therefore
the matrix Φo spans the n-dimensional space and the system is always observable.
A(t − t0 ) A 2(t − t0 )2 A k (t − t0 )k
e A(t−t0 ) = exp[A(t − t0 )] = I + + +…+
1! 2! k!
Therefore, the matrix exp[A(t − t0 )] is squared and its dimensions equals to the dimensions
of matrix A. This matrix is called “state-transition matrix,” and is shown by:
Φ(t) = e At = exp[At]
e At = ℒ−1[(sI − A)−1]
9
By applying this formula to the system:
−1
s −1 0
e A1t −1
= ℒ ( −245 s + 0.0814 24.47 )
0 0 s + 250
0 1 0 λ1 = − 250
A1 = 245 −0.0814 −24.47 , eig(A1) = λ 2 = − 15.7
0 0 −250 λ3 = 15.61
1948496.6721e (At) + (265.61A 2 e −15.7t − 31.31A 2 e −250t − 234.3A 2 e 15.61t + 62256.33Ae −15.7t − 2.82Ae −250t−
(62253.51A e 15.61t − 1036542.5Ie −15.7t + 76733.279Ie −250t − 919627.5Ie 15.61t = 0
7. Transfer Function
The transfer function of an linearized system x· = A x + Bu, and y = Cx is
−1
s −1 0 0 −60073.7
g1(s) = [1 0 0] −245 s + 0.0814 24.47 0 =
(491s 3 + 122790s 2 − 110295s − 30073750)
0 0 s + 250 5
−1
s −1 0 0 60073.7
g1(s) = [1 0 0] −245 s + 0.0814 −24.47 0 =
(491s 3 + 122790s 2 − 110295s − 30073750)
0 0 s + 250 5
The system has no zeros, and the poles of the both transfer functions are −250, −15.69,
and 15.69. Appendix A contains the Matlab code for this part.
10
8. PID Controller
8.1. Introduction
A proportional–integral–derivative controller (PID controller or three-term controller) is a
control loop mechanism employing feedback that is widely used in industrial control systems
and a variety of other applications requiring continuously modulated control. A PID controller
continuously calculates an error value as the difference between a desired setpoint (SP) and a
measured process variable (PV) and applies a correction based on proportional, integral, and
derivative terms (denoted P, I, and D respectively), hence the name.
11
Y(s) −60073.7
g1(s) = =
X(s) (491s + 122790s 2 − 110295s − 30073750)
3
Y(s) 60073.7
g2(s) = =
X(s) (491s 3 + 122790s 2 − 110295s − 30073750)
The step responses of two systems (g1 and g2) is shown in Fig. 4 and Fig. 5 respectively.
The proportional controller (Kp) reduces the rise time, increases the overshoot, and reduces
the steady-state error. The closed-loop transfer function of our unity-feedback system with a
proportional controller is the following:
12
KpG (s) 60037.7 + Kp
T (s) = =
1 + KpG (s) (491s 3 + 122790s 2 − 110295s + (−30073750 + Kp)
The step response of this system when Kp = 500 is shown in Fig 7 and Fig 8.
The step response of this system when Kp = 1600 for G2 is shown in Fig 9.
In Fig. 9 it is shown that the range of step response’s amplitude is more bounded by
choosing the right proportional constant, but as the above figures show, the system is still
unstable.
13
Figure 9. Step Response of
(Kp = 1600)G2
Now, let's take a look at PD control. The addition of derivative control (Kd) tends to reduce
both the overshoot and the settling time. The closed loop transfer function of the given system
with a PD controller is:
The step response of this system when Kp = 1600 and Kd = 500 for G2 is shown in Fig. 10.
The stepinfo() in this system will be in table 2.
RiseTime 0.5010
SettlingTime 1.2261
SettlingMin 1.3100
SettlingMax 1.4549
Overshoot 0
Undershoot 0
Peak 1.4549
PeakTime 3.0464
14
Figure 10. Step Response of T3
By setting the PID constants Kp = 1600, Ki = 2600, and Kd = 245, the step response of the
system is shown in Fig. 11.
The stepinfo() in this system will be in table 3.
RiseTime 0.0117
SettlingTime 1.1550
SettlingMin 0.9167
SettlingMax 1.3107
Overshoot 31.0718
Undershoot 0
Peak 1.3107
PeakTime 0.3212
15
Figure 11. Step Response of T4
Rising time, settling time, and steady-state error are small, but there exists a large value of
overshoot.
16
9. Non-Linear Model Results in Simulink
The non-linear model of the Magnetic Levitation System is designed in Simulink and it’s
shown in Fig. 12. The parameters are assigned by the values in Table. 1.
The completed system is shown in Fig. 13. The input is considered as step and the 3D
simulation of ball transition in the system is in the output to show better vision of this system.
First, the ball’s position can be seen in Fig. 13, where the ball’s position is 0 based on the
definition of output in section 2.
17
Figure 14. Ball’s Position T=0.00 Figure 17. Ball’s Position T=10.00
In the next step the PID controller is added to the system(Fig. 15.) The PID block in Matlab
is added and is tuned as Fig. 16. By adding the PID controller to the system, the ball moves
upward and stays stable at the position shown in Fig. 17.
18
Next, the step responses of position, velocity, and current(states) are shown in Fig. 18, Fig.
19, and Fig. 20 respectively.
Figure 18. Ball’s Position Step Response Figure 19. Ball’s Speed Step Response
In section 4, the equilibrium points were calculated. The stable values of x1 as the ball’s
position was 0.06, x 2 was 0, and x3 as the winding’s current was 0.8009. The above figures
confirm that the system with the designed PID controller will have those values when it’s stable.
19
Appendix A.
Matlab codes of project sections exist in this appendix.
R = 50;
L = 0.2;
g = 9.8;
M = 0.491;
c = 0.3;
fv = 0.04;
eq1 = x2 == 0;
eq2 = x1 == 0.06;
eq3 = -g+(c/M)*(x3^2/(0.1-x1))-(fv*x2/M) == 0;
eq4 = (1/L)*(-R*x3+u) == 0;
sol.x1
sol.x2
sol.x3
ans =
3/50
3/50
ans =
0
0
ans =
-(7*7365^(1/2))/750
(7*7365^(1/2))/750
20
2. Linearization (5)
f = x2;
g = -g+(c/M)*(x3^2/(0.1-x1))-(fv*x2/M);
h = (1/L)*(-R*x3+u);
eigA1 = eig(A_1)
eigA2 = eig(A_2)
A=
[ 0, 1, 0]
[(300*x3^2)/(491*(x1 - 1/10)^2), -40/491, -(600*x3)/(491*(x1 - 1/10))]
[ 0, 0, -250]
A_1 =
[ 0, 1, 0]
[245, -40/491, -(140*7365^(1/2))/491]
[ 0, 0, -250]
A_2 =
[ 0, 1, 0]
[245, -40/491, (140*7365^(1/2))/491]
[ 0, 0, -250]
eigA1 =
-250
- (3*6562805^(1/2))/491 - 20/491
(3*6562805^(1/2))/491 - 20/491
eigA2 =
-250
- (3*6562805^(1/2))/491 - 20/491
(3*6562805^(1/2))/491 - 20/491
21
3. State-Space Analysis (6)
% Controllability
% We can also use the command "ctrb(A, B)"
B = [0; 0; 5];
A_1B = A_1 * B;
A_2B = A_2 * B;
A_12B = A_1^2 * B;
A_22B = A_2^2 * B;
det_Phi_c1 = det(Phi_c1)
det_Phi_c2 = det(Phi_c2)
% Observability
% We can also use the command "obsv(A, C)"
C = [1 0 0];
A_1C = C * A_1;
A_2C = C * A_2;
A_12C = C * A_1^2;
A_22C = C * A_2^2;
rank_Phi_o1 = rank(Phi_o1)
rank_Phi_o2 = rank(Phi_o2)
eA1t = ilaplace(inv((s*eye(size(A_1,1))-A_1)))
eA2t = ilaplace(inv((s*eye(size(A_2,1))-A_2)))
22
Phi_c1 =
[0, 0, -(700*7365^(1/2))/491]
[0, -(700*7365^(1/2))/491, (85953000*7365^(1/2))/241081]
[5, -1250, 312500]
Phi_c2 =
[0, 0, (700*7365^(1/2))/491]
[0, (700*7365^(1/2))/491, -(85953000*7365^(1/2))/241081]
[5, -1250, 312500]
det_Phi_c1 =
-36750000/491
det_Phi_c2 =
-36750000/491
Phi_o1 =
[ 1, 0, 0]
[ 0, 1, 0]
[245, -40/491, -(140*7365^(1/2))/491]
Phi_o2 =
[ 1, 0, 0]
[ 0, 1, 0]
[245, -40/491, (140*7365^(1/2))/491]
rank_Phi_o1 =
rank_Phi_o2 =
23
eA1t =
[exp(-(20*t)/491)*(cosh((3*6562805^(1/2)*t)/491) + (4*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/
491))/3937683), (491*6562805^(1/2)*exp(-(20*t)/491)*sinh((3*6562805^(1/2)*t)/
491))/19688415, (4*7365^(1/2)*exp(-(20*t)/491)*(cosh((3*6562805^(1/2)*t)/491) -
(8182*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/491))/1312561))/873063 - (4*7365^(1/2)*exp(-250*t))/
873063]
[ (24059*6562805^(1/2)*exp(-(20*t)/491)*sinh((3*6562805^(1/2)*t)/491))/3937683,
exp(-(20*t)/491)*(cosh((3*6562805^(1/2)*t)/491) - (4*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/491))/
3937683), (1000*7365^(1/2)*exp(-250*t))/873063 - (1000*7365^(1/2)*exp(-(20*t)/
491)*(cosh((3*6562805^(1/2)*t)/491) - (8353*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/491))/
328140250))/873063]
[ 0,
0,
exp(-250*t)]
eA2t =
[exp(-(20*t)/491)*(cosh((3*6562805^(1/2)*t)/491) + (4*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/
491))/3937683), (491*6562805^(1/2)*exp(-(20*t)/491)*sinh((3*6562805^(1/2)*t)/
491))/19688415, (4*7365^(1/2)*exp(-250*t))/873063 - (4*7365^(1/2)*exp(-(20*t)/
491)*(cosh((3*6562805^(1/2)*t)/491) - (8182*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/491))/
1312561))/873063]
[ (24059*6562805^(1/2)*exp(-(20*t)/491)*sinh((3*6562805^(1/2)*t)/491))/3937683,
exp(-(20*t)/491)*(cosh((3*6562805^(1/2)*t)/491) - (4*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/491))/
3937683), (1000*7365^(1/2)*exp(-(20*t)/491)*(cosh((3*6562805^(1/2)*t)/491) -
(8353*6562805^(1/2)*sinh((3*6562805^(1/2)*t)/491))/328140250))/873063 -
(1000*7365^(1/2)*exp(-250*t))/873063]
[ 0,
0,
exp(-250*t)]
24
4. Transfer Function (7)
g1 = C * (inv((s*eye(size(A_1,1))-A_1))) * B
g2 = C * (inv((s*eye(size(A_2,1))-A_2))) * B
g1 =
g2 =
ans =
-250
- (3*6562805^(1/2))/491 - 20/491
(3*6562805^(1/2))/491 - 20/491
25
5. PID Controller
t = 0:0.01:2;
figure;
step(G1, t)
title('Step Response Open Loop G1')
figure;
step(G2, t)
title('Step Response Open Loop G2')
% P
Kp = 1600;
C = pid(Kp);
T1 = feedback(C*G1,1);
T2 = feedback(C*G2,1);
figure;
step(T1,t)
title('Step Response Closed Loop Kp.G1')
figure;
step(T2,t)
title('Step Response Closed Loop Kp.G2')
%PD
Kp = 1600;
Kd = 500;
C = pid(Kp,0,Kd);
T3 = feedback(C*G2,1);
figure;
stepinfo(T3)
step(T3,t)
title('Step Response Closed Loop Kd.Kp.G2')
%PID
Kp = 1600;
Ki = 2600;
Kd = 245;
C = pid(Kp,Ki,Kd);
T4 = feedback(C*G2,1);
figure;
stepinfo(T4)
step(T4,t)
title('Step Response Closed Loop Kd.Ki.Kp.G2')
26