calculating gain and phase from transfer functions

21
1 Calculating Gain and Phase from Transfer Functions MECH 3140 Lecture #

Upload: others

Post on 22-Nov-2021

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Calculating Gain and Phase from Transfer Functions

1

Calculating Gain and Phase from Transfer Functions

MECH 3140Lecture #

Page 2: Calculating Gain and Phase from Transfer Functions

Transfer Functions

โ€ข A differential equation ๐‘“๐‘“ ๐‘ฅ๐‘ฅ, ๏ฟฝฬ‡๏ฟฝ๐‘ฅ, ๏ฟฝฬˆ๏ฟฝ๐‘ฅ, โ€ฆ = ๐‘ข๐‘ข(๐‘ก๐‘ก), has ๐‘ข๐‘ข ๐‘ก๐‘ก as the input to the system with the output ๐‘ฅ๐‘ฅ

โ€ข Recall that transfer functions are simply the Laplace Transform representation of a differential equation from input to output:

๐ป๐ป(๐‘ ๐‘ ) =๐‘‹๐‘‹(๐‘ ๐‘ )๐‘ข๐‘ข(๐‘ ๐‘ )

โ€ข Therefore it can be used to find the Gain and Phase between the input and output

2

Page 3: Calculating Gain and Phase from Transfer Functions

Gain and Phase

โ€ข The gain and phase are found by calculating the gain and angle of the transfer function evaluates at jฯ‰

๐บ๐บ ๐œ”๐œ” = ๐ป๐ป(๐‘—๐‘—๐œ”๐œ”) =๐‘›๐‘›๐‘ข๐‘ข๐‘›๐‘›(๐‘—๐‘—๐œ”๐œ”)๐‘‘๐‘‘๐‘‘๐‘‘๐‘›๐‘›(๐‘—๐‘—๐œ”๐œ”)

โˆ… ๐œ”๐œ” = โˆ ๐ป๐ป ๐‘—๐‘—๐œ”๐œ” = โˆ ๐‘›๐‘›๐‘ข๐‘ข๐‘›๐‘› ๐‘—๐‘—๐œ”๐œ” โˆ’ โˆ ๐‘‘๐‘‘๐‘‘๐‘‘๐‘›๐‘› ๐‘—๐‘—๐œ”๐œ”

3

Page 4: Calculating Gain and Phase from Transfer Functions

Example #1 (solving the Diff Eq)

Fall 2019 Exam #1, Bonus Problem:๏ฟฝฬ‡๏ฟฝ๐‘ฅ + ๐‘ฅ๐‘ฅ = ฬ‡๐‘“๐‘“ + ๐‘“๐‘“ ๐‘“๐‘“ ๐œ”๐œ” = sin(๐œ”๐œ”๐‘ก๐‘ก)

Recall we can represent a sinusoid in the following format:

๐‘“๐‘“ = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ1๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

๐‘ฅ๐‘ฅ = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ๐ป๐ป๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

Then taking the derivatives:๏ฟฝฬ‡๏ฟฝ๐‘ฅ = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ๐ป๐ป๐‘—๐‘—๐œ”๐œ”๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”ฬ‡๐‘“๐‘“ = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ1๐‘—๐‘—๐œ”๐œ”๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ๐ป๐ป๐‘—๐‘—๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ” + ๐ป๐ป๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ” = 1๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ” + 1๐‘—๐‘—๐œ”๐œ”๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

4

Page 5: Calculating Gain and Phase from Transfer Functions

Example #1 (solving the Diff Eq)

Solving for H (which is the output):๐ป๐ป =

๐‘—๐‘—๐œ”๐œ” + 1๐‘—๐‘—๐œ”๐œ” + 1

๐บ๐บ =๐ป๐ป๐‘ˆ๐‘ˆ

=๐œ”๐œ”2 + 12

๐œ”๐œ”2 + 12= 1

5

Page 6: Calculating Gain and Phase from Transfer Functions

Example #1 (using Transfer Function)

Fall 2019 Exam #1, Bonus Problem:๏ฟฝฬ‡๏ฟฝ๐‘ฅ + ๐‘ฅ๐‘ฅ = ฬ‡๐‘“๐‘“ + ๐‘“๐‘“ ๐‘“๐‘“ ๐œ”๐œ” = sin(๐œ”๐œ”๐‘ก๐‘ก)

Take the Laplace of the entire equation and setting initial conditions to zero (since we are solving for the transfer function):

๐‘ ๐‘ ๐‘‹๐‘‹ ๐‘ ๐‘  + ๐‘‹๐‘‹ ๐‘ ๐‘  = ๐‘ ๐‘ ๐‘ ๐‘  ๐‘ ๐‘  + ๐‘ ๐‘ (๐‘ ๐‘ )

๐‘‹๐‘‹ ๐‘ ๐‘  ๐‘ ๐‘  + 1 = ๐‘ ๐‘ (๐‘ ๐‘ )(๐‘ ๐‘  + 1)

๐‘‹๐‘‹(๐‘ ๐‘ )๐‘ ๐‘ (๐‘ ๐‘ )

=๐‘ ๐‘  + 1๐‘ ๐‘  + 1

6

Page 7: Calculating Gain and Phase from Transfer Functions

Example #1 (using Transfer Function)

Now, to find the gain simply evaluate the transfer function at jฯ‰

๐‘‹๐‘‹(๐‘ ๐‘ )๐‘ ๐‘ (๐‘ ๐‘ )

=๐‘ ๐‘  + 1๐‘ ๐‘  + 1

๐บ๐บ =๐‘—๐‘—๐œ”๐œ” + 1๐‘—๐‘—๐œ”๐œ” + 1

=๐œ”๐œ”2 + 12

๐œ”๐œ”2 + 12= 1

7

Page 8: Calculating Gain and Phase from Transfer Functions

Example #2 (solving the Diff Eq)

Spring 2020 Exam #1, Bonus Problem:๏ฟฝฬˆ๏ฟฝ๐‘ฅ + 25๐‘ฅ๐‘ฅ = ๐‘ข๐‘ข(t)

Recall we can represent a sinusoid in the following format:

๐‘ข๐‘ข = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ๐‘ˆ๐‘ˆ๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

๐‘ฅ๐‘ฅ = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ๐ป๐ป๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

Then taking the derivatives:๏ฟฝฬ‡๏ฟฝ๐‘ฅ = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝ๐ป๐ป๐‘—๐‘—๐œ”๐œ”๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

๏ฟฝฬˆ๏ฟฝ๐‘ฅ = ๐ผ๐ผ๐‘›๐‘› ๏ฟฝ ๏ฟฝ๐ป๐ป(๐‘—๐‘—๐œ”๐œ”)2๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ” = ๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝโˆ’๐ป๐ป๐œ”๐œ”2๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”

๐ผ๐ผ๐‘›๐‘›๏ฟฝ ๏ฟฝโˆ’๐ป๐ป๐œ”๐œ”2๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ” + 25๐ป๐ป๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ” = ๐‘ˆ๐‘ˆ๐‘‘๐‘‘๐‘—๐‘—๐œ”๐œ”๐œ”๐œ”8

Page 9: Calculating Gain and Phase from Transfer Functions

Example #2 (solving the Diff Eq)

Solving for H (which is the output):๐ป๐ป =

๐‘ˆ๐‘ˆโˆ’๐œ”๐œ”2 + 25

๐บ๐บ =๐ป๐ป๐‘ˆ๐‘ˆ

=1

25 โˆ’ ๐œ”๐œ”2

9

Page 10: Calculating Gain and Phase from Transfer Functions

Example #2 (using Transfer Function)

Spring 2020 Exam #1, Bonus Problem:๏ฟฝฬˆ๏ฟฝ๐‘ฅ + 25๐‘ฅ๐‘ฅ = ๐‘ข๐‘ข(t)

Take the Laplace of the entire equation and setting initial conditions to zero (since we are solving for the transfer function):

๐‘ ๐‘ 2๐‘‹๐‘‹ ๐‘ ๐‘  + 25๐‘‹๐‘‹ ๐‘ ๐‘  = ๐‘ˆ๐‘ˆ(๐‘ ๐‘ )

๐‘‹๐‘‹ ๐‘ ๐‘  ๐‘ ๐‘ 2 + 25 = ๐‘ˆ๐‘ˆ(๐‘ ๐‘ )

๐‘‹๐‘‹(๐‘ ๐‘ )๐‘ˆ๐‘ˆ(๐‘ ๐‘ )

=1

๐‘ ๐‘ 2 + 25

10

Page 11: Calculating Gain and Phase from Transfer Functions

Example #2 (using Transfer Function)

Now, to find the gain simply evaluate the transfer function at jฯ‰

๐‘‹๐‘‹(๐‘ ๐‘ )๐‘ˆ๐‘ˆ(๐‘ ๐‘ )

=1

๐‘ ๐‘ 2 + 25

๐บ๐บ =1

(๐‘—๐‘—๐œ”๐œ”)2+25=

125 โˆ’๐œ”๐œ”2

11

Page 12: Calculating Gain and Phase from Transfer Functions

Calculating Gain and Phase in Matlab

12

โ€ข Matlab uses transfer functions to calculate gain and phase and generate bode plots

โ€ข Recall that there are 2 ways to plot data logarithmicallyโ€“ 1) Plot on a log scaleโ€“ 2) Take the log of the data & plot on normal scaleโ€“ Matlab does both (just to be annoying or to

ensure you can do both โ€“ actually its just the standard of how bode plots are shown).

Page 13: Calculating Gain and Phase from Transfer Functions

Calculating Gain and Phase in Matlab

13

โ€ข Matlab plots the Gain in decibels (db):1 ๐‘‘๐‘‘๐‘‘๐‘‘ = 20๐‘™๐‘™๐‘™๐‘™๐‘™๐‘™10(๐บ๐บ)

โ€ข Note the following about db:G=0 db (Gain=1, output=input)G>0 db (Gain>1, output>input)G<0 db (Gain<1, output<input

Page 14: Calculating Gain and Phase from Transfer Functions

Calculating Gain and Phase in Matlab

14

โ€ข Matlab code:>> num=1;>> den=[1 0 25]; % ๐‘ ๐‘ 2 + 0๐‘ ๐‘  + 25>> sys=tf(num,den)>>bode(sys)

โ€ข If you want the actual gain you can do:>>[gain, phase, freq]=bode(sys)

Page 15: Calculating Gain and Phase from Transfer Functions

Calculating Gain and Phase in Matlab

15

โ€ข Note the spike at ฯ‰=5 rad/s

Page 16: Calculating Gain and Phase from Transfer Functions

Example #3

16

โ€ข PI Cruise Control from a few lectures ago:๐‘›๐‘›๏ฟฝฬ‡๏ฟฝ๐‘‰ + ๐‘‘๐‘‘๐‘‰๐‘‰ = ๐‘ ๐‘ 

๐พ๐พ๐‘๐‘๐‘‘๐‘‘ + ๐พ๐พ๐ผ๐ผ ๏ฟฝ๐‘‘๐‘‘๐‘‘๐‘‘๐‘ก๐‘ก = ๐‘ ๐‘ 

โ€“ Taking the laplace of each equation (with IC=0 and e=r-v):

๐‘›๐‘›๐‘ ๐‘ ๐‘‰๐‘‰(๐‘ ๐‘ ) + ๐‘‘๐‘‘๐‘‰๐‘‰(๐‘ ๐‘ ) = ๐‘ ๐‘ (๐‘ ๐‘ )

๐พ๐พ๐พ๐พ ๐‘…๐‘… ๐‘ ๐‘  โˆ’ ๐‘‰๐‘‰ ๐‘ ๐‘  + ๐พ๐พ๐ผ๐ผ๐‘ ๐‘ 

(๐‘…๐‘… ๐‘ ๐‘  โˆ’ ๐‘‰๐‘‰ ๐‘ ๐‘  ) = ๐‘ ๐‘ (๐‘ ๐‘ )

Page 17: Calculating Gain and Phase from Transfer Functions

Example #3

17

โ€“ Substituting in F(s) and collecting terms

๐‘‰๐‘‰ ๐‘ ๐‘  ๐‘›๐‘›๐‘ ๐‘  + ๐‘‘๐‘‘ + ๐พ๐พ๐‘๐‘ +๐พ๐พ๐ผ๐ผ๐‘ ๐‘ 

= ๐‘…๐‘… ๐‘ ๐‘  ๐พ๐พ๐‘๐‘ +๐พ๐พ๐ผ๐ผ๐‘ ๐‘ 

โ€“ Then solving for the transfer function:

๐‘‰๐‘‰ ๐‘ ๐‘ ๐‘…๐‘…(๐‘ ๐‘ )

=๐พ๐พ๐‘๐‘ + ๐พ๐พ๐ผ๐ผ

๐‘ ๐‘ ๐‘›๐‘›๐‘ ๐‘  + ๐‘‘๐‘‘ + ๐พ๐พ๐‘๐‘ + ๐พ๐พ๐ผ๐ผ

๐‘ ๐‘ 

=๐พ๐พ๐‘๐‘๐‘ ๐‘  + ๐พ๐พ๐ผ๐ผ

๐‘›๐‘›๐‘ ๐‘ 2 + (๐‘‘๐‘‘ + ๐พ๐พ๐‘๐‘)๐‘ ๐‘  + ๐พ๐พ๐ผ๐ผ

Page 18: Calculating Gain and Phase from Transfer Functions

Example #3

18

โ€ข This is called the closed loop transfer functionโ€“ It is from the reference input to the velocity

outputโ€“ Notice the DC Gain is one (which means for a

constant reference, the steady state velocity will equal the reference

โ€“ Notice the PI controller adds a โ€œzeroโ€ (root in the numerator) and a โ€œpoleโ€

โ€ข So the total order is 2nd order (2 poles or 2nd order denominator)

Page 19: Calculating Gain and Phase from Transfer Functions

Example #3

19

Now to find the gain and phase:

โ€“ ๐บ๐บ ๐œ”๐œ” = ๐พ๐พ๐‘๐‘๐‘—๐‘—๐œ”๐œ”+๐พ๐พ๐ผ๐ผ๐‘š๐‘š ๐‘—๐‘—๐œ”๐œ” 2+(๐พ๐พ๐‘๐‘+๐‘๐‘) ๐‘—๐‘—๐œ”๐œ” +๐พ๐พ๐ผ๐ผ

=(๐พ๐พ๐‘๐‘๐œ”๐œ”)2+(๐พ๐พ๐ผ๐ผ)2

(๐พ๐พ๐‘๐‘๐œ”๐œ”+๐‘๐‘๐œ”๐œ”)2+(๐พ๐พ๐ผ๐ผโˆ’๐‘š๐‘š๐œ”๐œ”2)2

โ€“ โˆ… ๐œ”๐œ” = ๐‘ก๐‘ก๐‘ก๐‘ก๐‘›๐‘›โˆ’1 ๐พ๐พ๐‘๐‘๐œ”๐œ”๐พ๐พ๐ผ๐ผ

โˆ’ ๐‘ก๐‘ก๐‘ก๐‘ก๐‘›๐‘›โˆ’1 ๐พ๐พ๐‘๐‘๐œ”๐œ”+๐‘๐‘๐œ”๐œ”๐พ๐พ๐ผ๐ผโˆ’๐‘š๐‘š๐œ”๐œ”2

Page 20: Calculating Gain and Phase from Transfer Functions

Example #3 (Bode Plot)

20

m=1800 kg (me in a mustang)b=10 Ns/m (made up)

Kp=1,589 Ns/mKi=710 N/m

Page 21: Calculating Gain and Phase from Transfer Functions

Example #3

21

Lets assume R=10sin(1t).What would the carโ€™s velocity be?

โ€“ ๐บ๐บ 1 = (1589)2+(710)2

(1599)2+(710โˆ’1800)2= 0.899

โ€“ โˆ… 1 = ๐‘ก๐‘ก๐‘ก๐‘ก๐‘›๐‘›โˆ’1 1589710

โˆ’ ๐‘ก๐‘ก๐‘ก๐‘ก๐‘›๐‘›โˆ’1 1599710โˆ’1800

= โˆ’58 ๐‘‘๐‘‘๐‘‘๐‘‘๐‘™๐‘™

๐‘‰๐‘‰ ๐‘ก๐‘ก = 8.99sin(1๐‘ก๐‘ก โˆ’ 1.019)