Exercise 1a: Transfer functions (Solutions)

EE4107 -&shy;β Cybernetics Advanced Exercise 1a: Transfer functions (Solutions) Transfer functions Transfer functions are a model form based on the Laplace transform. Transfer functions are very useful in analysis and design of linear dynamic systems. A general Transfer function is on the form: π» π =
π¦(π )
π’(π )
Where π¦ is the output and π’ is the input. A general transfer function can be written on the following general form: π» π  =
ππ’πππππ‘ππ(π )
π! π  ! + π!!! π  !!! + β― + π! π  + π!
=
πππππππππ‘ππ(π )
π! π  ! + π!!! π  !!! + β― + π! π  + π!
The Numerators of transfer function models describe the locations of the zeros of the system, while the Denominators of transfer function models describe the locations of the poles of the system. Differential Equations While the transfer function gives an external in-&shy;βout representation of a system, will the differential equations of a system give an internal representation of a system. We can find the transfer function from the differential equation by using Laplace and Laplace transformation pairs. Likewise, we can find the differential equation from the transfer function using inverse Laplace. The following transformation pair is much used: Differentiation: 1.order systems: π₯ βΊ π π₯(π ) For higher order systems: π₯ (!) βΊ π  ! π₯(π ) Faculty of Technology, Postboks 203, Kj&oslash;lnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
2 Integration: π₯βΊ
1
π₯(π ) π
Time-&shy;βdelay: π’ π‘ − π βΊ π’(π )π !!&quot; Static Time-&shy;βresponse In some cases we want to find the constant value π¦! of the time response when the time π‘ → ∞. We can then use the final value theorem (sluttverditeoremet): π¦! = lim π¦ π‘ = lim π  β π¦(π ) !→!
!→!
MathScript MathScript has several functions for creating transfer functions: Function tf Sys_order1 Sys_order2 step Description Example Creates system model in transfer function form. You also can use this function to state-&shy;βspace models to transfer function form. Constructs the components of a first-&shy;βorder system model based on a gain, time constant, and delay that you specify. You can use this function to create either a state-&shy;βspace model or a transfer function model, depending on the output parameters you specify. Constructs the components of a second-&shy;βorder system model based on a damping ratio and natural frequency you specify. You can use this function to create either a state-&shy;βspace model or a transfer function model, depending on the output parameters you specify. Creates a step response plot of the system model. You also can use this function to return the step response of the model outputs. If the model is in state-&shy;βspace form, you also can use this function to return the step response of the model states. This function assumes the initial model states are zero. If you do not specify an output, this function creates a plot. Example: Given the following transfer function: π» π  =
1
π +1
In MathScript we will use the following code: % Define Transfer function
&gt;den=[1, 1, 1];
&gt;H = tf(num, den)
&gt;K = 1;
&gt;tau = 1;
&gt;H = sys_order1(K, tau)
&gt;dr = 0.5
&gt;wn = 20
&gt;[num, den] = sys_order2(wn, dr)
&gt;SysTF = tf(num, den)
&gt;num=[1,1];
&gt;den=[1,-1,3];
&gt;H=tf(num,den);
&gt;t=[0:0.01:10];
&gt;step(H,t);
3 num = [1];
den = [1, 1];
H = tf(num, den)
% Step Response
step(H)
This gives the following step response: A general transfer function can be written on the following general form: π» π  =
ππ’πππππ‘ππ(π )
π! π  ! + π!!! π  !!! + β― + π! π  + π!
=
πππππππππ‘ππ(π )
π! π  ! + π!!! π  !!! + β― + π! π  + π!
The Numerators of transfer function models describe the locations of the zeros of the system, while the Denominators of transfer function models describe the locations of the poles of the system. In MathScript we can define such a transfer function using the built-&shy;βin tf function as follows: num = [bm, bm_1, bm_2, … , b1, b0];
den = [an, an_1, an_2, … , a1, a0];
H = tf(num, den)
Task 1: Differential equations to Transfer functions Task 1.1 Given the following differential equation: π₯ = −0.5π₯ + 2π’ Find the following transfer function: EE4107 -&shy;β Cybernetics Advanced 4 π» π  =
π₯(π )
π’(π )
Solution: Laplace gives: π π₯(π ) = −0.5π₯(π ) + 2π’(π ) Further: π π₯ π  + 0.5π₯(π ) = 2π’(π ) Further: π₯ π  (π  + 0.5) = 2π’(π ) Further: π₯ π
2
4
=
=
π’(π ) π  + 0.5 2π  + 1
This gives: π» π  =
π₯ π
4
=
π’(π ) 2π  + 1
Task 1.2 Given the following 2.order differential equation: π¦ + π¦ + 5π¦ = 5π₯ Find the following transfer function: π» π  =
π¦(π )
π₯(π )
Solution: We get: π  ! π¦ π  + π π¦ π  + 5π¦ π  = 5π π₯(π ) Further: π¦ π  [π  ! + π  + 5] = 5π π₯(π ) This gives the following transfer function: π¦ π
5π
= !
π₯(π ) π  + π  + 5
EE4107 -&shy;β Cybernetics Advanced 5 Task 2: Transfer functions to differential equatons Given the following system: π» π  =
π₯(π )
3
=
π’(π ) 0.5π  + 1
Task 2.1 Find the differential equation from the transfer function above. Solution: We get: π₯(π ) 0.5π  + 1 = 3π’(π ) Further: 0.5π π₯ π  + π₯(π ) = 3π’(π ) Inverse Laplace gives: 0.5π₯ + π₯ = 3π’ This gives the following differential equation: π₯ = −2π₯ + 6π’ Task 2.2 Draw a block diagram of the system. Solution: We can draw the following block diagram: EE4107 -&shy;β Cybernetics Advanced 6 Note! Even when the system is in the time plane we normally use the symbol are commonly used for the integrator are: or Task 3: 2.order system Given the following transfer function: π» π  =
π¦(π )
2π  + 3
= !
π’(π ) π  + 4π  + 3
Task 3.1 Find the differential equation for the system. Solution: We do as follows: π¦ π  π  ! + 4π  + 3 = π’ π  [2π  + 3] This gives: π  ! π¦ π  + 4π π¦ π  + 3π¦ π  = 2π π’ π  + 3π’(π ) This gives the following differential equation: π¦ + 4π¦ + 3π¦ = 2π’ + 3π’ Note! We have used the rule: π₯ (!) βΊ π  ! π₯(π ) Task 4: Static Time-&shy;βresponse Task 4.1 Given the following system: π»(π ) =
π¦(π )
3
=
π’(π ) 2π  + 1
Find the static time-&shy;βresponse. We will use a step for the control signal (π’ π‘ = 1). Note! The Laplace Transformation pair for a step is as follows: EE4107 -&shy;β Cybernetics Advanced . Other symbols that 7 1
⇔ 1 π
Solution: We have: π¦(π )
3
=
π’(π ) 2π  + 1
π»(π ) =
Meaning that: π¦(π ) =
3
π’(π ) 2π  + 1
!
where π’ π  = !
This means: π¦ π  =
3
1
3
β =
2π  + 1 π
2π  + 1 π
Then we use the final value theorem (sluttverditeoremet): π¦! = lim π¦ π‘ = lim π  β π¦ π  = lim π
!→!
!→!
!→!
3
3
3
= lim =
= 3 2π  + 1 π  !→! 2π  + 1 2 β 0 + 1
Task 4.2 Given the following system: π»(π ) =
π¦(π )
6(π  + 1)
=
π’(π ) 9π  + 0.25
Find the static time-&shy;βresponse. We will use a step for the control signal (π’ π‘ = 1). Solution: We get: π¦(π ) =
6(π  + 1)
π’(π ) 9π  + 0.25
!
where π’ π  = !
This means: π¦ π  =
6(π  + 1)
9π  + 0.25 π
EE4107 -&shy;β Cybernetics Advanced 8 Then we get using the final value theorem: π¦! = lim π¦ π‘ = lim π  β π¦ π  = lim π
!→!
!→!
!→!
6 π +1
6(π  + 1)
6(0 + 1)
6
= lim =
=
= 24 9π  + 0.25 π  !→! 9π  + 0.25
9 β 0 + 0.25
0.25
Task 5: 1.order transfer functions Given the following system: π»(π ) =
π¦(π )
2
=
π’(π ) 4π  + 1
Task 5.1 What are the values for the gain πΎ and the time constant π for this system? Sketch the step response for the system using “pen and paper”. Find the step response using MathScript and compare the result with your sketch. Solutions: Gain πΎ and the time-&shy;βconstant π : πΎ = 2 π = 4 Step response for a 1.order system: MathScript: clear
EE4107 -&shy;β Cybernetics Advanced 9 clc
K=2;
T=4;
num=[K];
den=[T, 1];
H = tf(num, den);
step(H)
This gives the following plot: For a 1.order system with time-&shy;βdelay we have: Task 5.2 EE4107 -&shy;β Cybernetics Advanced 10 Find the differential equation from the transfer function above and draw a block diagram of the system (“pen and paper”). Solutions: For a 1.order system in general we have: π»(π ) =
π¦(π )
πΎ
=
π’(π ) ππ  + 1
or: π¦ π  =
πΎ
π’(π ) ππ  + 1
Which gives: π¦ π  (ππ  + 1) = πΎπ’(π ) ππ π¦ π  + π¦(π ) = πΎπ’(π ) In the time domain we get the following differential equation (using Inverse Laplace): π¦=
1
(−π¦ + πΎπ’) π
We can draw the following block diagram of the system: Where πΎ = 2 and π = 4 for our system: Note! Even when the system is in the time plane we normally use the symbol are commonly used for the integrator are: or . Task 5.3 EE4107 -&shy;β Cybernetics Advanced . Other symbols that 11 From the block diagram in Task 1.2, find the transfer function π» (π ) =
(The answer shall of course be π» (π ) =
!(!)
!(!)
=
!
!!!!
!(!)
!(!)
) Solutions: From the block diagram in the previous task we get the following transfer function: 1
0.25 β
π¦ π
π  = 0.5 = 2 π» π  =
=2β
1 π  + 0.25 4π  + 1
π’ π
1 + 0.25 β
π
As expected, the result is the same as the transfer function given in Task 1.1. Note! We have used both the serial and feedback rules that yield for block diagram reduction. Task 5.4 Find the solution for the differential equation and plot it (“pen and paper”). We will use a step for the control signal (π’ π‘ = 1). Note! The Laplace Transformation pair for a step is as follows: 1
⇔ 1 π
Tip! You also need to use the following Laplace transform pair: πΎ
⇔ πΎ(1 − π !!/! ) ππ  + 1 π
Compare to the results from Task 1.1. Solutions: EE4107 -&shy;β Cybernetics Advanced 12 For a 1.order system in general we have: π»(π ) =
π¦(π )
πΎ
=
π’(π ) ππ  + 1
Here we will find the mathematical expression for the step response (π¦(π‘)): π¦ π  = π» π  π’(π ) Where π’ π  =
π
π
We use inverse Laplace and find the corresponding transformation pair in order to find π¦(π‘)). π¦ π  =
πΎ
π
β ππ  + 1 π
We use the following Laplace transform pair: πΎ
⇔ πΎ(1 − π !!/! ) ππ  + 1 π
This gives: π¦ π‘ = πΎπ(1 − π !!/! ) Setting πΎ = 2, π = 4 and π = 1 gives: π¦ π‘ = 2(1 − π
!
! ! !
) We can plot this in MathScript: clear
clc
K=2;
T=4;
U=1;
t=0:0.1:20;
% Method 1 - Transfer Function
num=[K];
den=[T, 1];
H = tf(num, den);
figure(1)
step(H, t)
EE4107 -&shy;β Cybernetics Advanced 13 % Method 2 - Plot the solution of the differential equation
y = K*U*(1-exp(-t/T));
figure(2)
plot(t,y)
We get the same results (of course). Task 6: Transfer functions in MathScript Define the following transfer functions in MathScript. Task 6.1 Given the following transfer function: π»(π ) =
2π  ! + 3π  + 4
5π  + 9
Solutions: MathScript Code: num = [2, 3, 4];
den = [5, 9];
H = tf(num, den)
Task 6.2 Given the following transfer function: 4π  ! + 3π  + 4
π»(π ) =
5π  ! + 9
Solutions: MathScript Code: num = [4, 0, 0, 3, 4];
den = [5, 0, 9];
H = tf(num, den)
Note! If some of the orders are missing, we just put in zeros. The transfer function above can be rewritten as: π»(π ) =
4π  ! + 0 β π  ! + 0 β π  ! + 3π  + 4
5π  ! + 0 β π  + 9
Task 6.3 Given the following transfer function: EE4107 -&shy;β Cybernetics Advanced 14 π»(π ) =
7 + 3π  + 2π  !
5π  + 6π  !
Solutions: We need to rewrite the transfer function to get it in correct orders: π»(π ) =
2π  ! + 3π  + 7
6π  ! + 5π
MathScript Code: num = [2, 3, 7];
den = [6, 5, 0];
H = tf(num, den)
Task 7: Differential equations to Transfer functions Task 7.1 Given the following differential equation: π₯ = −0.5π₯ + 2π’ Find the following transfer function: π» π  =
π₯(π )
π’(π )
Solution: Laplace gives: π π₯(π ) = −0.5π₯(π ) + 2π’(π ) Further: π π₯ π  + 0.5π₯(π ) = 2π’(π ) Further: π₯ π  (π  + 0.5) = 2π’(π ) Further: π₯ π
2
4
=
=
π’(π ) π  + 0.5 2π  + 1
This gives: π» π  =
π₯ π
4
=
π’(π ) 2π  + 1
EE4107 -&shy;β Cybernetics Advanced 15 Task 8: PI Controller A PI controller is defined as: π’(π‘) = πΎ! π +
πΎ!
π!
!
!
πππ Where u is the controller output and π is the control error: π π‘ = π π‘ − π¦(π‘) Task 8.1 Find the transfer function for the PI Controller: π»! π  =
π’(π )
π(π )
Solutions: Using Laplace gives: π’ π  = πΎ! π π  +
πΎ! 1
β π π  π! π
Then we get: π»! π  =
πΎ! πΎ! π! π  πΎ! πΎ! π! π  + πΎ! πΎ! (π! π  + 1)
π’(π )
= πΎ! +
=
+
=
=
π(π )
π! π
π! π
π! π
π! π
π! π
This gives the following transfer function for the PI controller: π»! π  =
π’(π ) πΎ! (π! π  + 1)
=
π(π )
π! π