HW 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

CONTROL AND AUTOMATION ENGINEERING DEPARTMENT

COMPUTER CONTROLLED SYSTEMS

2023-2024 SPRING SEMESTER

PROJECT 1

TEAM MEMBERS:
Mehmet Hüseyin Kılınçkıran 040190503
Furkan Yüksel 040210747
İsmail Tuna Kurt 040190618
Oğuzhan Buda 040200612
Project 1 17.03.2024

QUESTION 1

A)

ÿ +5 ẏ+ 6 y=2 u (1)

Equation 1 is our base equation. We assume initial conditions are zero, and apply
Laplace Transform for both sides in Equation 2

s 2 Y (s)+5 sY ( s)+6 Y (s)=2 U (s) (2)

If we apply basic operations we find G(s) in Equation 3.

Y ( s) 2
G(s)= = 2 (3)
U (s) s +5 s+6

Transform function T(s) is shown in Equation 4

T (s)=GZOH (s)∗G( s) (4)

Zero order hold function is described in Equation 5

Ts
1−e
GZOH (s)= (5)
s

Multiply ZOH function with T(s) and imply simple fraction operations Equation 6

Ts
1−e 2 A B C
T ( s)= ∗( 2 )=1−e Ts⋅( + + ) (6)
s s +5 s +6 s s+2 s+ 3

2
Project 1 17.03.2024

After mathematical operations T(s) find as in Equation 7

Ts 1/3 1 2/3
T (s)=1−e ⋅( − + ) (7)
s s+2 s+ 3

Applying the Z transform to the elements of T(s) separetely in Equation 8

Ts −1 Z−1
Ζ {1−e }=1−Z =
Z
1/3 1 Z
Ζ{ }= ⋅( )
s 3 Z−1
1 Z (8)
Ζ{ }=
s+2 Z−e 2 T
2/3 2 Z
Ζ{ }= ⋅( )
s+3 3 Z−e(−3 T)

Combining the equations in Equation 8 results to Equation 9.

Z−1 Z Z 2Z
Ζ {T (s)}= ⋅( − + ) (9)
Z 3 Z−3 Z −e(−2 T )
3 Z−3 e
(−3T )

Sampling period T = 0.1s, substituting in Equation 10 and using the Matlab script in
Text 1 brings the results in Equation 10, the Z transform of differential equation in
Equation 1.

T = 0.1;
z = tf('z',T)

TZ = minreal(1/3- ...
(z-1)/(z-0.818)+ ...
(2*z-2)/(3*z-2.22))
Text 1: Matlab script 1

0.008667 Z +0.007107
T ( Z )= (10)
Z 2−1.558 Z +0.6053

3
Project 1 17.03.2024

B)

To find the difference equation the transfer function is equalized to the input/output in
equation 11.

Y (Z ) 0.008667 Z+ 0.007107
= (11)
U (Z ) Z 2−1.558 Z +0.6053

Y (Z ) 0.008667 Z+ 0.007107
= (12)
U (Z ) Z 2−1.558 Z +0.6053

So the difference equation can be written as in equation 14.

Z 2 Y (Z )=1.558 ZY (Z )−0.6053 Y ( Z)+0.008667 ZU (Z)+0.007107 U ( Z) (13)

y (k )=1.558 y ( k−1)−0.6053 y (k −2)+ 0.008667u (k −1)+0.007107 u(k−2) (14)

4
Project 1 17.03.2024

C)

The Matlab code used is given in the Text 2

clc ; clear ; close all ;


syms z
Ts = 0.1;
z = tf('z',Ts) ;
Gzz = (0.008667*z + 0.007107)/(z^2-1.558*z+0.6053)
k = 0:1:200;
u = ones (1 , length ( k ) ) ;
y (1) = 0.008667;
y (2) = 0.029277;
y (3) = 0.056141431;
l = k * Ts ; % because of the sampling 0.1
for i =4:(length(k))
y (i) = 1.558*y(i-1)-0.6053*y(i-2)+0.008667*u(i-
1)+0.007107* u(i-2);
end
figure (1) ; clf ; hold on ; xlabel ( ' time ') ; ylabel
( ' amplitude ') ;
step ( Gzz , 'b ') ; grid on ;
plot (l ,y , 'r-x' , 'LineWidth' ,1) ; legend ( ' Step
tesponse of Gz ' , 'Difference Equaitons Response ');

Text 1: Matlab script 1

The output in figure 1 is obtained as the output of Matlab code above in the Text 1.

Figure 1: The impulse response of the system


Project 1 17.03.2024

QUESTION 2

A)

Block reduction method and rules are used in order of Eq.15, Eq.16, Eq.17, Eq.18,
Eq.19, Eq.20, Eq.21.

y (k )=1.558 y ( k−1)−0.6053 y (k −2)+ 0.008667u (k −1)+0.007107 u(k−2) (15)

E( s)=R (s)−C( s) (16)

R* (s)⋅G1 (s )⋅G2 (s)−C* ( s)⋅G1 ( s)⋅G2 (s)−C * (s)⋅H (s )⋅G2 (s)=C( s) (17)

* * * * *
( R (s)⋅G1 (s )⋅G2 (s )−C ( s)⋅G1 ( s)⋅G 2 ( s)−C (s )⋅H (s )⋅G2 (s )) =(C(s)) (18)

R* ( s)⋅(G1 (s)⋅G2 (s))* =C* (s)⋅G1 (s)⋅G2 (s)−C * (s)⋅H (s )⋅G2 (s)+C * (s ) (19)

* * * * *
R ( s)⋅(G 1 (s)⋅G2 (s)) =C (s)⋅G 1 (s)⋅G2 (s)−C (s)⋅H (s )⋅G2 (s)+C (s ) (20)

R* (s)⋅G1 G*2 (s)=C * (s )⋅(G1 G*2 (s )+ H (s)G*2 (s )+ 1) (21)

In Eq.22, the transfer function of the system is reached. And applied Z transform to
Eq.22 reaches the discrete time closed loop transfer function in Eq.23

* *
R (s ) G 1 G2 (s)
*
= * * (22)
C (s) G 1 G 2 (s)+ H (s)G 2 (s )+1

R (Z) G1 G2 (Z )
= (23)
C (Z) G1 G 2 (Z)+ H (s)G 2(Z )+1

6
Project 1 17.03.2024

B)

Block reduction method and rules are used in order of Eq.24, Eq.25, Eq.26

* * *
((R (s)−(C ( s)⋅H (s)) ⋅D2 ( s))⋅D 1 (s )−(C (s)⋅H ( s)) ⋅D 2 (s))⋅G(s)=C ( s) (24)

R* (s)⋅D1 (s )⋅G(s )−CH * (s)⋅D2(s)⋅D 1( s)⋅G(s)−CH * (s)⋅D2 ( s)⋅G(s)=C ( s) (25)

* * * * * * *
R (s)⋅D 1 G ( s)−CH (s)⋅D 2 D 1 G (s )−CH (s)⋅D2 G ( s)=C (s) (26)

*
C (s)
T (Z )= * (27)
R (s )

In equation 26, T(Z) is not obtained because of the CH*(s) term.

QUESTION 3

A)

Eq. 28 is the question.

x (k +2)−1.2 x(k +1)+ 0.35 x ( k)=u(k + 2) (28)

The theorem in the Eq. 29 will be applied to Eq.28


n n
Z {X (k + n)}=Z ⋅X ( Z)−Z ⋅X (0)−Z
(n−1)
⋅X (1)−...−Z⋅X (n−1) (29)

Eq.29 theorem applied to Eq.28 in Eq.30

2 2 2 2
Z X (Z)−Z X (0)−Z X (1)−1.2 ZX ( Z)−1.2 ZX (0)+ 0.35 X ( Z)=Z U ( Z )−Z U (0)−ZU (1)
(30)

7
Project 1 17.03.2024

The fractional part in X(z) and its residues are found in Eq. 31, Eq.32, Eq.33

3 2
Z + 2.2 Z −2.2 Z
X (Z)= 3 2 (31)
Z −2.2 Z +1.55 Z−0.35

A B C
X (Z)=1+ + + (32)
Z−1 Z−0.7 Z−0.5

A=6.66 , B=1.98 ,C=−4.25 (33)

If the found residue coefficients are replaced, Eq. 34 emerges.

6.66 1.98 4.25


X ( Z)=1+ + − (34)
Z−1 Z−0.7 Z−0.5

Inverse Z Transform of Eq.34 will be calculated separately in Eq.35, Eq.36, Eq.37,


Eq.38, Eq.39,

−1 −1 −1 6.66 −1 1.98 −1 −4.25


Z {X (Z)}=Z {1}+ Z { }+ Z { }−Z { } (35)
Z−1 Z−0.7 Z−0.5

Z −1 {1}= δ (k ) (36)

6.66 Z 1
=6.66⋅Z −1 =6.66⋅Z −1
Z−1 Z−1 1−Z −1 (37)
6.66
Z−1 { }=6.66 u(k −1)
Z−1

8
Project 1 17.03.2024

1.98 −1 Z
=Z ⋅1.98⋅( )
Z−0.7 Z −0.7
(38)
−1 1.98 (k−1)
Z { }=1.98⋅0.7
Z−0.7

1.98 Z
=Z −1⋅1.98⋅( )
Z−0.7 Z −0.7
(39)
1.98
Z −1 { }=1.98⋅0.7(k−1)
Z−0.7

Final result of x(k) is found in the Eq. 40.

−1 −1 −1 6.66 −1 1.98 −1 −4.25


Z {X (Z)}=Z {1}+ Z { }+ Z { }−Z { } (40)
Z−1 Z−0.7 Z−0.5

B)
Separated into residues of X(s) in Eq.41

3 s+6 A B
X (s)= = + (41)
( s+ 3)(s +6) s+3 s +6

A found -1 and B found 4, substituting in Eq.42

−1 4
X ( s)= + (42)
s+3 s+ 6

Inverse Z Transform applied in Eq.44 and found Z domain of Eq.41

−1 4
Z {X (s )}=Z { + }→ (43)
s +3 s+6

−1 4 −Z 4Z
Z {X (s )}=Z { + }→ + (44)
s +3 s+6 Z−e (−3 T )
Z−e(−6 T )

9
Project 1 17.03.2024

C)
Analytically calculate the z-transform of the expression given in Eq.45

(−Ts)
1−e 2
X (s)= 2 (45)
s (s +a)

Separate the z-transform of the part with polynomial numerator and denominator is
taken by dividing X(s) into two parts in Eq.46.

X (s)=1−e
(−Ts)
⋅F (s) (46)

Fractions of F (s) are as follows in Eq.47

2 A B C
F( s)= = + + (47)
(s⋅(s +a) ) s (s +a) (s+ a)
2 2

The residuals are as in Eq.48

2 −2 −2
A= , B= , C= 2 (48)
a 2
a a

(−Ts)
1−e 2
X (s)= ⋅( ) (49)
s (s +a)2

Z transform of X(s) calculated in Eq 50, Eq.51, Eq.52, Eq.53 in order.

2 2 2
Z {X (s )}=Z {1−e(−Ts)⋅( 2
− 2
− 2 )} (50)
(a ⋅s) (a⋅( s+a) ) (a ⋅(s +a))

Ts
Z =e →Z {1−e
(−Ts)
}=1−Z
−1
(51)

10
Project 1 17.03.2024

2 2
⋅T⋅e (−aT)⋅Z−1 2
⋅1
−1 2 1 a a (52)
Z {X (s )}=1−Z ⋅( 2 1
− (−aT ) −1 2
− (−aT) −1
)
a 1−Z ( 1−e Z ) 1−e Z

Z Transform of X(s) found in Eq. 53

2 2 −1 T⋅e(−aT)⋅Z−1 2 1
Z {X (s )}= 2
− ⋅(1−Z ) (−aT ) −1 2
− 2⋅(1−Z−1 ) (53)
a a
(−aT) −1
(1−e Z ) a 1−e Z

11

You might also like