Exercise 9 - Frequency Response Analysis -...

21
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 9: Frequency Response Analysis (Solutions) The Gain Margin, GM (Δ), the Phase Margin, PM () and the crossover frequencies, ! and !"# are found in a Bode diagram as illustrated below: is the gain margin frequency, in radians/second. A gain margin frequency indicates where the model phase crosses 180 degrees. GM (Δ) is the gain margin of the system. is phase margin frequency, in radians/second. A phase margin frequency indicates where the model magnitude crosses 0 decibels. PM () is the phase margin of the system. Note! and are called the crossoverfrequencies The definitions are as follows: Gain Crossoverfrequency : ! = 1 = 0 Phase Crossoverfrequency : !"# = 180 ! Gain Margin GM (): = !"# Phase margin PM ():

Transcript of Exercise 9 - Frequency Response Analysis -...

Page 1: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

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  9:  Frequency  Response  Analysis  (Solutions)  The  Gain  Margin,  GM  (Δ𝐾),  the  Phase  Margin,  PM  (𝜑)  and  the  cross-­‐over  frequencies,  𝜔!  and  𝜔!"#  are  found  in  a  Bode  diagram  as  illustrated  below:  

 

𝝎𝟏𝟖𝟎  is  the  gain  margin  frequency,  in  radians/second.  A  gain  margin  frequency  indicates  where  the  model  phase  crosses  -­‐180  degrees.        GM  (Δ𝐾)  is  the  gain  margin  of  the  system.      𝝎𝒄  is  phase  margin  frequency,  in  radians/second.  A  phase  margin  frequency  indicates  where  the  model  magnitude  crosses  0  decibels.      PM  (𝜑)  is  the  phase  margin  of  the  system.  

Note!  𝝎𝟏𝟖𝟎    and  𝝎𝒄  are  called  the  crossover-­‐frequencies  

The  definitions  are  as  follows:  

Gain  Crossover-­‐frequency  -­‐  𝝎𝒄  :  

  𝐿 𝑗𝜔! = 1 = 0𝑑𝐵  

Phase  Crossover-­‐frequency  -­‐  𝝎𝟏𝟖𝟎  :  

 ∠𝐿 𝑗𝜔!"# = −180!  

Gain  Margin  -­‐  GM  (𝚫𝑲):  

𝐺𝑀   𝑑𝐵 = − 𝐿 𝑗𝜔!"#   𝑑𝐵  

Phase  margin  PM  (𝝋):    

Page 2: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

2  

EE4107  -­‐  Cybernetics  Advanced  

 

𝑃𝑀 = 180! +  ∠𝐿(𝑗𝜔!)  

We  have  that:  

1.  Asymptotically  stable  system:  𝝎𝒄 < 𝝎𝟏𝟖𝟎  

2.  Marginally  stable  system:  𝝎𝒄 = 𝝎𝟏𝟖𝟎  

3.  Unstable  system:  𝝎𝒄 > 𝝎𝟏𝟖𝟎  

MathScript  has  several  built-­‐in  functions  for  Frequency  response,  e.g.:  

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)

bode   Creates  the  Bode  magnitude  and  Bode  phase  plots  of  a  system  model.  You  also  can  use  this  function  to  return  the  magnitude  and  phase  values  of  a  model  at  frequencies  you  specify.  If  you  do  not  specify  an  output,  this  function  creates  a  plot.  

>num=[4]; >den=[2, 1]; >H = tf(num, den) >bode(H)

bodemag   Creates  the  Bode  magnitude  plot  of  a  system  model.  If  you  do  not  specify  an  output,  this  function  creates  a  plot.  

>[mag, wout] = bodemag(SysIn) >[mag, wout] = bodemag(SysIn, [wmin wmax]) >[mag, wout] = bodemag(SysIn, wlist)

semilogx   Generates  a  plot  with  a  logarithmic  x-­‐scale.   >semilogx(w, gain)

log10   Computes  the  base  10  logarithm  of  the  input  elements.  The  base  10  logarithm  of  zero  is  -­‐inf.  

>log(x)

atan   Computes  the  arctangent  of  x   >atan(x)

series   Connects  two  system  models  in  series  to  produce  a  model  SysSer  with  input  and  output  connections  you  specify  

>Hseries = series(H1,H2)

feedback   Connects  two  system  models  together  to  produce  a  closed-­‐loop  model  using  negative  or  positive  feedback  connections  

>SysClosed = feedback(SysIn_1, SysIn_2)

bode   Creates  the  Bode  magnitude  and  Bode  phase  plots  of  a  system  model.  You  also  can  use  this  function  to  return  the  magnitude  and  phase  values  of  a  model  at  frequencies  you  specify.  If  you  do  not  specify  an  output,  this  function  creates  a  plot.  

>num=[4]; >den=[2, 1]; >H = tf(num, den) >bode(H)

bodemag   Creates  the  Bode  magnitude  plot  of  a  system  model.  If  you  do  not  specify  an  output,  this  function  creates  a  plot.  

>[mag, wout] = bodemag(SysIn) >[mag, wout] = bodemag(SysIn, [wmin wmax]) >[mag, wout] = bodemag(SysIn, wlist)

margin   Calculates  and/or  plots  the  smallest  gain  and  phase  margins  of  a  single-­‐input  single-­‐output  (SISO)  system  model.  The  gain  margin  indicates  where  the  frequency  response  crosses  at  0  decibels.  The  phase  margin  indicates  where  the  frequency  response  crosses  -­‐180  degrees.  Use  the  margins  function  to  return  all  gain  and  phase  margins  of  a  SISO  model.  

>num = [1] >den = [1, 5, 6] >H = tf(num, den) margin(H) >[gmf, gm, pmf, pm] = margin(H)

Task  1:  Stability  Analysis  

Given  the  following  transfer  function:  

𝐿 𝑆 =1

𝑠 𝑠 + 1 !  

Task  1.1  

Use  the  standard  bode  function  in  MathScript  to  plot  the  frequency  response  in  a  Bode  diagram.    

Page 3: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

3  

EE4107  -­‐  Cybernetics  Advanced  

 

Find  the  following:  

• The  crossover-­‐frequencies  𝜔!  and  𝜔!"#  • The  gain  margin,  GM  (Δ𝐾)  • The  phase  margin,  PM  (𝜑)  

Print  out  the  Bode  diagram  and  illustrate  how  you  find  𝜔!,  𝜔!"#  Δ𝐾,  𝜑  from  the  diagram  

Solutions:  

MathScript  Code  for  creating  Bode  diagram:  

clear clc % Transfer unction num=[1]; den1=[1,0]; den2=[1,1] den3=[1,1] den = conv(den1,conv(den2,den3)); H = tf(num, den) % Bode Diagram bode(H) subplot(2,1,1) grid on subplot(2,1,2) grid on

Note!  In  order  to  define  the  denominator  (𝑠 𝑠 + 1 !),  we  can  use  the  conv  function  as  shown  above,  or  we  can  manually  calculate:  

𝑠 𝑠 + 1 ! = 𝑠! + 2𝑠! + 𝑠  

and  use  like  this:  

den=[1,2,1,0]

Since  we  are  going  to  find  𝜔!  ,  𝜔!"#,  Δ𝐾  and  𝜑  from  the  plot,  it  is  a  good  idea  to  rescale  the  𝑥  and  𝑦  axes:  

bode(H) subplot(2,1,1) grid on axis([0.1, 10, -40, 50]) subplot(2,1,2) grid on axis([0.1, 10, -200, -100])

Page 4: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

4  

EE4107  -­‐  Cybernetics  Advanced  

 

Note!  You  can  also  do  this  manually  by  clicking  on  the  𝑥  and  𝑦  axes  on  the  plot.  

From  the  graph  above  we  find  the  following  (an  image  editor  is  used  to  draw  on  the  chart):  

 

So  the  results  are  as  follows:  

𝜔! ≈ 0.7  

𝜔!"# ≈ 1  

𝐺𝑀 ≈ 6  𝑑𝐵  

𝑃𝑀 ≈ 20°  

Task  1.2  

Now  you  shall  use  the  margin  function  in  MathScript  instead.    

Example:  

margin(H);

→  Here  you  will  plot  a  Bode  diagram  where    𝜔!,  𝜔!"#  Δ𝐾,  𝜑  will  be  illustrated  

and:  

[gm, pm, w180, wc] = margin(H);

→  Here  you  will  get  the  numerical  values  for  𝜔!,  𝜔!"#  Δ𝐾,  𝜑.  

Page 5: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

5  

EE4107  -­‐  Cybernetics  Advanced  

 

Compare  your  results  with  the  previous  subtask.  

Solutions:  

We  use  margin  in  2  different  ways:  

… margin(H) [gm, pm, w180, wc] = margin(H);

Note!  Using  “help  margin”  in  MathScript  does  not  give  the  correct  information  about  the  return  parameters  return  by  the  margin  function!!  The  correct  is:  

[gm, pm, w180, wc] = margin(H);

Using  margin(H)  makes  the  gm,  fm,  gmf  and  pmf  automatically  plotted  in  the  Bode  diagram:  

 

Using  [gm,  pm,  w180,  wc]  =  margin(H)  gives  numerical  values:  

wc =

0.6823

w180 =

0.9993

gm_dB =

Page 6: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

6  

EE4107  -­‐  Cybernetics  Advanced  

 

6.0086

pm =

21.3864

Note!  gm  has  to  be  converted  to  dB.  

gm_dB = 20*log10(gm)

Summarizing,  the  results  are  as  follows:  

𝝎𝒄 = 𝟎.𝟔𝟖  

𝝎𝟏𝟖𝟎 = 𝟏  

𝑮𝑴 = 𝟔  𝒅𝑩  

𝑷𝑴 = 𝟐𝟏°  

Note!  We  see  that  the  system  is  an  asymptotically  stable  system  because  𝝎𝒄 < 𝝎𝟏𝟖𝟎  

Task  1.3  

Find  the  poles  for  the  system.  Draw  the  poles  in  the  imaginary  plane.  Is  the  system  stable?  

Discuss  the  results.  

Solutions:  

Poles:  

𝑝! = 0, 𝑝! = 𝑝! = −1  

In  the  imaginary  plane:  

 

MathScript  code:  

… poles(H)

Page 7: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

7  

EE4107  -­‐  Cybernetics  Advanced  

 

pzmap(H)

Note!  We  see  from  the  poles  as  well  that  the  system  is  an  asymptotically  stable  system.  

Total  MathScript  Code  for  Task  1.1-­‐1.3:  

clear, clc % Transfer function num=[1]; den1=[1,0]; den2=[1,1] den3=[1,1] den = conv(den1,conv(den2,den3)); H = tf(num, den) poles(H) figure(1) pzmap(H) % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2) grid on % Margins and Phases wlist=[0.01, 0.1, 0.2, 0.5, 1, 10, 100]; [mag, phase,w] = bode(H, wlist); magdB=20*log10(mag); %convert to dB % [mag, phase,w] = bode(H); mag_data = [w, magdB] phase_data = [w, phase] % Crossover Frequency------------------------------------- figure(3) margin(H) [gm, pm, w180, wc] = margin(H); wc

Page 8: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

8  

EE4107  -­‐  Cybernetics  Advanced  

 

w180 % Convert to dB. gm_dB = 20*log10(gm) pm

Task  2:  Stability  Analysis  with  time-­‐delay  

Given  the  following  system  with  time-­‐delay:  

𝐿 𝑠 =2.5𝑒!!

3𝑠 + 1  

Task  2.1  

Use  the  standard  bode  function  in  MathScript  to  plot  the  frequency  response  in  a  Bode  diagram.    

Find  the  following:  

• The  crossover-­‐frequencies  𝜔!  and  𝜔!"#  • The  gain  margin,  GM  (Δ𝐾)  • The  phase  margin,  PM  (𝜑)  

Print  out  the  Bode  diagram  and  illustrate  how  you  find  𝜔!,  𝜔!"#  Δ𝐾,  𝜑  from  the  diagram  

Task  2.2  

Now  you  shall  use  the  margin  function  in  MathScript  instead.    

Compare  your  results  with  the  previous  subtask.  

Task  2.3  

Find  the  poles  for  the  system.  Draw  the  poles  in  the  imaginary  plane.  Is  the  system  stable?  

Discuss  the  results.  

Solutions  for  Task  2.1-­‐2.3:  

MathScript  Code:  

clear, clc s=tf('s'); K=2.5; T=3; H1=tf(K/(T*s+1)); delay=1; H=set(H1,'inputdelay',delay);

Page 9: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

9  

EE4107  -­‐  Cybernetics  Advanced  

 

bode(H); subplot(2,1,1) grid on subplot(2,1,2) grid on margin(H) [gm, pm, w180, wc] = margin(H); wc w180 % Convert to dB. gm_dB = 20*log10(gm) pm

Ordinary  Bode  Plot  using  the  bode  function  (I  have  manually  adjusted  the  scaling):  

 

→  We  have  to  find  GM,  PM,  wc  and  w180  manually  from  the  plot.  

We  can  use  the  margin  function  (gm,  fm,  gmf  and  pmf  are  automatically  plotted  in  the  Bode  chart)  as  well:  

Page 10: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

10  

EE4107  -­‐  Cybernetics  Advanced  

 

 

Using  

[gm, pm, w180, wc] = margin(H);

gives:  

wc =

0.7638

w180 =

1.756

gm_dB =

6.6279

pm =

69.8178

Note!  gm  has  to  be  converted  to  dB.  

gm_dB = 20*log10(gm)

So  the  results  are  as  follows:  

𝝎𝒄 = 𝟎.𝟕𝟔  

𝝎𝟏𝟖𝟎 = 𝟏.𝟕𝟔  

𝑮𝑴 = 𝟔.𝟔  𝒅𝑩  

𝑷𝑴 = 𝟕𝟎°  

Page 11: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

11  

EE4107  -­‐  Cybernetics  Advanced  

 

We  see  that  the  system  is  an  asymptotically  stable  system  because  𝝎𝒄 < 𝝎𝟏𝟖𝟎  

 

Task  3:  Control  System  

Given  the  following  system:  

Process  transfer  function:  

𝐻! =𝐾𝑠𝑒!!"  

Where  𝐾 = !!!",  where  𝐾! = 0,556,  𝐴 = 13,4,  𝜚 = 145  and  𝜏 = 250  

Measurement  (sensor)  transfer  function:  

𝐻! = 𝐾!  

Where  Km  =  1  %/m.  

Controller  transfer  function  (PI  Controller):  

𝐻! = 𝐾! +𝐾!𝑇!𝑠

 

Set  𝐾𝑝   =  1.5  og  𝑇𝑖   =  1000𝑠.  

Task  3.1  

Define  the  different  transfer  functions  in  MathScript.  

𝐻!  

𝐻!  

𝐻!  

Solutions:  

We  define  the  different  transfer  functions.  There  are  multiple  ways  to  define  the  different  transfer  functions,  and  we  will  show  some  alternative  solutions.  

The  tricky  part  is  the  time  delay  𝑒!!"  in  the  process  transfer  function.  Here  we  can  use  different  approaches  and  different  functions.  We  can  use  the  built-­‐in  sys_order1,  we  can  use  the  built-­‐in  pade  function  or  create  our  own  Pade’  approximation  (e.g.  a  1.order  or  2.order  approximation).  

Method1:  

Here  we  use  combinations  of  functions  tf  and  sys_order1.  

Page 12: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

12  

EE4107  -­‐  Cybernetics  Advanced  

 

clear clc close all % Model parameters: Ks=0.556; %(kg/s)/% A=13.4; %m2 rho=145; %kg/m3 transportdelay=250; %sec %Defining the process transfer function: K=Ks/(rho*A); num1 = [K]; den1 = [1, 0]; H1 = tf(num1, den1); H2 = sys_order1(1, 0, transportdelay); disp('Process:') Hp = series(H1, H2) % Defining sensor transfer function: Km=1; %percent per meter disp('Sensor:') Hs=tf(Km) % Defining controller transfer function: Kp=1.5; Ti=1000; num = Kp*[Ti, 1]; den = [Ti, 0]; disp('Controller:') Hc = tf(num,den)

Note!  

𝐻! = 𝐾! +𝐾!𝑇!𝑠

=𝐾!𝑇!𝑠 + 𝐾!

𝑇!𝑠=𝐾!(𝑇!𝑠 + 1)

𝑇!𝑠  

We  can  also  use  the  pade  function  in  order  to  create  a  Pade’approximation:  

n=5; % Order of Pade approximation H2 = pade(transportdelay, n)

Or  we  can  create  our  own  Pade  approximation  and  then  use  the  tf  function:  

% 2.order approx. using tf k1=transportdelay/2; k2=transportdelay^2/12; num=[k2, -k1, 1];

Page 13: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

13  

EE4107  -­‐  Cybernetics  Advanced  

 

den=[k2, k1, 1]; H2=tf(num, den)

For  a  2.order  Pade’  approximation  (𝒏 = 𝟐)  we  get  the  following  transfer  function:  

We  get:  

𝑒!!" ≈1 − 𝑘!𝑠 + 𝑘!𝑠!

1 + 𝑘!𝑠 + 𝑘!𝑠!  

Where:  

𝑘! =𝜏2  

𝑘! =𝜏!

12  

Method  2:  

This  is  a  new  method  we  haven’t  used  before.  We  define  s  as  the  Laplace  operator  and  then  we  can  use  s  directly  in  our  equations.  

clear clc close all s=tf('s'); %Model parameters: Ks=0.556; %(kg/s)/% A=13.4; %m2 rho=145; %kg/m3 transportdelay=250; %sec %Defining the process transfer function: K=Ks/(rho*A); padeorder=5; %Order of Pade-approximation of time-delay. Order 5 is usually ok. Hp1=set(tf(K/s),'inputdelay',transportdelay);%Including transportdelay in process transfer function Hp=pade(Hp1,padeorder);%Deriving process transfer function incl. Pade-approx of time-delay %Defining sensor transfer function: Km=1; Hs=tf(Km); %Defining sensor transfer function (just a gain in this example) %Defining controller transfer function: Kp=1.5; Ti=1000; Hc=Kp+Kp/(Ti*s); %PI controller transfer function

Task  3.2  

Page 14: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

14  

EE4107  -­‐  Cybernetics  Advanced  

 

Set  up  the  mathematical  expression  and  define  the  Loop  transfer  function  𝑳(𝒔).  

Tip!  Use  the  built-­‐in  function  series  in  Mathscript.  

 

Set  up  the  mathematical  expression  and  define  the  Sensitivity  transfer  function  𝑺(𝒔)  

Tip!  Use  the  built-­‐in  function  feedback  in  Mathscript.  

 

Set  up  the  mathematical  expression  and  define  the  Tracking  transfer  function  𝑻(𝒔)  

Solutions:  

Control  system:  

 

Defining  𝐿(𝑠):    

𝐿 𝑠 = 𝐻!𝐻!𝐻!  

We  get  the  following  compact  system:  

 

MathScript  Code:  

Page 15: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

15  

EE4107  -­‐  Cybernetics  Advanced  

 

% Calculating loop tranfer function L=series(Hc,series(Hp,Hs)); %Calculating tracking transfer function T=feedback(L,1); % Calculating sensitivity transfer function S=1-T;

Task  3.3  

Plot  the  Loop  transfer  function  𝐿(𝑠),  the  Tracking  transfer  function  𝑇(𝑠)  and  the  Sensitivity  transfer  function  𝑆(𝑠)  in  a  Bode  diagram.  Use,  e.g.,  the  bodemag  function  in  MathScript.  

Discuss  the  results.  

Solutions:  

Code:  

% Bode Diagram figure(1) bodemag(L,T,S) grid

Bode  diagram:  

 

Task  3.4  

Based  on  the  Bode  diagram  of  𝐿(𝑠),  𝑇(𝑠)  𝑆(𝑠),  find  the  different  bandwidths  𝜔! ,𝜔! ,𝜔!  (see  the  sketch  below).  

Page 16: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

16  

EE4107  -­‐  Cybernetics  Advanced  

 

 

Where  we  have  the  following  definitions:  

𝝎𝒄  –  crossover-­‐frequency  –  the  frequency  where  the  gain  of  the  Loop  transfer  function  𝐿(𝑗𝜔)  has  the  value:  

1 = 0𝑑𝐵  

𝝎𝒕  –  the  frequency  where  the  gain  of  the  Tracking  function  𝑇(𝑗𝜔)  has  the  value:  

12≈ 0.71 = −3𝑑𝐵  

𝝎𝒔  -­‐  the  frequency  where  the  gain  of  the  Sensitivity  transfer  function  𝑆(𝑗𝜔)  has  the  value:  

1 −12≈ 0.29 = −11𝑑𝐵  

Discuss  the  results.  

Solutions:  

Values  for  𝜔! ,𝜔! ,𝜔!  can  be  found  in  the  plot  as  shown  below  (We  change  the  scaling  for  more  details):  

Page 17: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

17  

EE4107  -­‐  Cybernetics  Advanced  

 

 

We  get  the  following  values:  

𝝎𝒄 = 𝟎.𝟎𝟎𝟎𝟕𝟑  𝒓𝒂𝒅/𝒔  

𝝎𝒔 = 𝟎.𝟎𝟎𝟎𝟑𝟐  𝒓𝒂𝒅/𝒔  

𝝎𝒕 = 𝟎.𝟎𝟎𝟏𝟐  𝒓𝒂𝒅/𝒔  

Task  3.5  

Plot  the  step  response  for  the  Tracking  transfer  function  𝑇(𝑠)  

Discuss  the  results.  

Solutions:  

MathScript  Code:  

% Simulating step response for control system (tracking transfer function) figure(2) step(T) grid

Plot:  

Page 18: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

18  

EE4107  -­‐  Cybernetics  Advanced  

 

 

We  see  that  the  system  is  asymptotically  stable.  

Task  3.6  

Find  the  stability  margins  (GM,  PM)  of  the  system  (𝐿(𝑠)).    

Discuss  the  results.  

Solutions:  

MathScript  Code:  

% Calcutating stability margins and crossover frequencies: [gm, pm, w180, wc] = margin(L) % Plotting L and stability margins and crossover frequencies in Bode diagram figure(3) margin(L) grid

This  gives:  

Page 19: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

19  

EE4107  -­‐  Cybernetics  Advanced  

 

 

Shown  in  the  Output  Window  of  Mathscript:  

 

GM=12.764,  and  PM  =  25.645  deg.        

𝜔! < 𝜔!"#  →  The  system  is  asymptotically  stable  

GM  is  ok,  but  PM  somewhat  too  small  (should  have  been  at  least  30  deg).  May  try  to  increase  𝑇!  to  e.g.  1200s.  Decreasing  𝐾!  does  not  help  (normally  it  does,  but  it  can  be  shown  that  for  this  system,  containing  two  integrators  in  series  (PI  controller  and  process),  reducing  gain  may  actually  reduce  stability  (normally  the  stability  is  increased  if  gain  is  reduced).  

Below  we  see  the  complete  code  for  the  Task:  

clear clc close all

Page 20: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

20  

EE4107  -­‐  Cybernetics  Advanced  

 

% Model parameters: Ks=0.556; %(kg/s)/% A=13.4; %m2 rho=145; %kg/m3 transportdelay=250; %sec %Defining the process transfer function: K=Ks/(rho*A); num1 = [K]; den1 = [1, 0]; H1 = tf(num1, den1); H2 = sys_order1(1, 0, transportdelay); disp('Process:') Hp = series(H1, H2) % Defining sensor transfer function: Km=1; %percent per meter disp('Sensor:') Hs=tf(Km) % Defining controller transfer function: Kp=1.5; Ti=1000; num = Kp*[Ti, 1]; den = [Ti, 0]; disp('Controller:') Hc = tf(num,den) % Calculating loop tranfer function L=series(Hc,series(Hp,Hs)); %Calculating tracking transfer function T=feedback(L,1); % Calculating sensitivity transfer function S=1-T; % Bode Diagram figure(1) bodemag(L,T,S) grid % Simulating step response for control system (tracking transfer function) figure(2)

Page 21: Exercise 9 - Frequency Response Analysis - Solutionshome.hit.no/~hansha/documents/subjects/EE4107/exercises/solutions... · % Bode Plot figure(2) bode(H) subplot(2,1,1) grid on subplot(2,1,2)

21  

EE4107  -­‐  Cybernetics  Advanced  

 

step(T) grid % Calcutating stability margins and crossover frequencies: [gm, pm, w180, wc] = margin(L) % Plotting L and stability margins and crossover frequencies in Bode diagram figure(3) margin(L) grid

 

Additional  Resources  

• http://home.hit.no/~hansha/?lab=mathscript

Here you will find tutorials, additional exercises, etc.