Exercise 1a: Transfer functions (Solutions)

advertisement
EE4107 -­β€ 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-­β€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ølnes ring 56, N-3901 Porsgrunn, Norway. Tel: +47 35 57 50 00 Fax: +47 35 57 54 01
2 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 tf Sys_order1 Sys_order2 step Description Example Creates system model in transfer function form. You also can use this function to state-­β€space models to transfer function form. 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. 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. 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. Example: Given the following transfer function: 𝐻 𝑠 =
1
𝑠+1
In MathScript we will use the following code: % Define Transfer function
EE4107 -­β€ Cybernetics Advanced >num=[1];
>den=[1, 1, 1];
>H = tf(num, den)
>K = 1;
>tau = 1;
>H = sys_order1(K, tau)
>dr = 0.5
>wn = 20
>[num, den] = sys_order2(wn, dr)
>SysTF = tf(num, den)
>num=[1,1];
>den=[1,-1,3];
>H=tf(num,den);
>t=[0:0.01:10];
>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-­β€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 -­β€ 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 -­β€ 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 -­β€ 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-­β€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: EE4107 -­β€ 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-­β€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 -­β€ 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-­β€constant 𝑇 : 𝐾 = 2 𝑇 = 4 Step response for a 1.order system: MathScript: clear
EE4107 -­β€ 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-­β€delay we have: Task 5.2 EE4107 -­β€ 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 -­β€ 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 -­β€ 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 -­β€ 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 -­β€ 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 -­β€ 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)
=
𝑒(𝑠)
𝑇! 𝑠
Additional Resources •
http://home.hit.no/~hansha/?lab=mathscript
Here you will find tutorials, additional exercises, etc.
EE4107 -­β€ Cybernetics Advanced 
Download