EE4107 -Ββ Cybernetics Advanced
Faculty of Technology, Postboks 203, KjΓΈlnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
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-Ββ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:
π₯(!) βΊ π !π₯(π )
2
EE4107 -Ββ Cybernetics Advanced
Integration:
π₯βΊ1π π₯(π )
Time-Ββdelay:
π’ π‘ β π βΊ π’(π )π!!"
Static Time-Ββ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 Description Example tf Creates system model in transfer function form. You also can
use this function to state-Ββspace models to transfer function form.
>num=[1]; >den=[1, 1, 1]; >H = tf(num, den)
Sys_order1 Constructs the components of a first-Ββorder system model based on a gain, time constant, and delay that you specify. You can use this function to create either a state-Ββspace model or a transfer function model, depending on the output parameters you specify.
>K = 1; >tau = 1; >H = sys_order1(K, tau)
Sys_order2 Constructs the components of a second-Ββorder system model based on a damping ratio and natural frequency you specify. You can use this function to create either a state-Ββspace model or a transfer function model, depending on the output parameters you specify.
>dr = 0.5 >wn = 20 >[num, den] = sys_order2(wn, dr) >SysTF = tf(num, den)
step 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-Ββ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.
>num=[1,1]; >den=[1,-1,3]; >H=tf(num,den); >t=[0:0.01:10]; >step(H,t);
Example:
Given the following transfer function:
π» π =1
π + 1
In MathScript we will use the following code:
% Define Transfer function
3
EE4107 -Ββ Cybernetics Advanced
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-Ββ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:
4
EE4107 -Ββ Cybernetics Advanced
π» π =π₯(π )π’(π )
Solution:
Laplace gives:
π π₯(π ) = β0.5π₯(π ) + 2π’(π )
Further:
π π₯ π + 0.5π₯(π ) = 2π’(π )
Further:
π₯ π (π + 0.5) = 2π’(π )
Further:
π₯ π π’(π )
=2
π + 0.5=
42π + 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
5
EE4107 -Ββ Cybernetics Advanced
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:
6
EE4107 -Ββ Cybernetics Advanced
Note! Even when the system is in the time plane we normally use the symbol . Other symbols that
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-Ββresponse
Task 4.1
Given the following system:
π»(π ) =π¦(π )π’(π )
=3
2π + 1
Find the static time-Ββresponse.
We will use a step for the control signal (π’ π‘ = 1).
Note! The Laplace Transformation pair for a step is as follows:
7
EE4107 -Ββ Cybernetics Advanced
1π β 1
Solution:
We have:
π»(π ) =π¦(π )π’(π )
=3
2π + 1
Meaning that:
π¦(π ) =3
2π + 1π’(π )
where π’ π = !!
This means:
π¦ π =3
2π + 1β1π =
32π + 1 π
Then we use the final value theorem (sluttverditeoremet):
π¦! = lim!β!
π¦ π‘ = lim!β!
π β π¦ π = lim!β!
π 3
2π + 1 π = lim
!β!
32π + 1
=3
2 β 0 + 1= 3
Task 4.2
Given the following system:
π»(π ) =π¦(π )π’(π )
=6(π + 1)9π + 0.25
Find the static time-Ββ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 π
8
EE4107 -Ββ Cybernetics Advanced
Then we get using the final value theorem:
π¦! = lim!β!
π¦ π‘ = lim!β!
π β π¦ π = lim!β!
π 6 π + 19π + 0.25 π
= lim!β!
6(π + 1)9π + 0.25
=6(0 + 1)9 β 0 + 0.25
=6
0.25= 24
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-Ββconstant π:
πΎ = 2
π = 4
Step response for a 1.order system:
MathScript:
clear
9
EE4107 -Ββ Cybernetics Advanced
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-Ββdelay we have:
Task 5.2
10
EE4107 -Ββ Cybernetics Advanced
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 . Other symbols that
are commonly used for the integrator are: or .
Task 5.3
11
EE4107 -Ββ Cybernetics Advanced
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:
π» π =π¦ π π’ π
= 2 β0.25 β 1π
1 + 0.25 β 1π =
0.5π + 0.25
=2
4π + 1
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:
12
EE4107 -Ββ Cybernetics Advanced
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)
13
EE4107 -Ββ Cybernetics Advanced
% 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π + 45π ! + 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:
14
EE4107 -Ββ Cybernetics Advanced
π»(π ) =7 + 3π + 2π !
5π + 6π !
Solutions:
We need to rewrite the transfer function to get it in correct orders:
π»(π ) =2π ! + 3π + 76π ! + 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
π + 0.5=
42π + 1
This gives:
π» π =π₯ π π’(π )
=4
2π + 1
15
EE4107 -Ββ Cybernetics Advanced
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)
π!π
Additional Resources
β’ http://home.hit.no/~hansha/?lab=mathscript
Here you will find tutorials, additional exercises, etc.