Case Project - Control System in LabVIEW.pdf

15
Telemark University College Department of Electrical Engineering, Information Technology and Cybernetics 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 Case Project Control System in LabVIEW HANSPETTER HALVORSEN, 2013.08.16

Transcript of Case Project - Control System in LabVIEW.pdf

Page 1: Case Project - Control System in LabVIEW.pdf

 

Telemark  University  College  Department  of  Electrical  Engineering,  Information  Technology  and  Cybernetics  

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

 

 

Case Project  

 

 

 

 

Control System in LabVIEW HANS-­‐PETTER  HALVORSEN,  2013.08.16  

 

Page 2: Case Project - Control System in LabVIEW.pdf

ii  

 

Table of Contents Table  of  Contents  ....................................................................................................................................  ii  

1   Modeling  ...........................................................................................................................................  3  

1.1   Air  Heater  ..................................................................................................................................  3  

1.2   Level  Tank  ..................................................................................................................................  4  

2   Simulation  .........................................................................................................................................  6  

2.1   DAQ  Device  ...............................................................................................................................  6  

2.1.1   DAQ  Assistant  ....................................................................................................................  6  

2.2   Model  Implementation  .............................................................................................................  8  

2.2.1   Model  Adjustment  .............................................................................................................  9  

3   Control  System  ...............................................................................................................................  11  

3.1   Discrete  Low-­‐pass  Filter  ..........................................................................................................  11  

3.2   Discrete  PI  Controller  ..............................................................................................................  12  

3.3   Control  System  ........................................................................................................................  12  

3.4   Controller  Tuning  ....................................................................................................................  13  

 

Page 3: Case Project - Control System in LabVIEW.pdf

3  

   

1 Modeling

1.1 Air Heater

Below  we  see  the  Air  Heater.  

 

Heater:  The  air  is  heated  by  an  electrical  heater.  The  supplied  power  is  controlled  by  an  external  voltage  signal  in  the  range   𝟎   −  𝟓  𝑽   (min  power,  max  power).    

Temperature  sensors:  Two  Pt100  temperature  elements  are  available  (some  of  the  Air  Heaters  have  only  one).  You  can  use  Temperature  sensor  1  in  this  assignment.  The  range  is   𝟏   −  𝟓  𝑽,  and  this  voltage  range  corresponds  to  the  temperature  range   𝟐𝟎   −  𝟓𝟎℃   (with  a  linear  relation).    

A  simple  mathematical  model  of  the  system  could  be:    

𝑇!"# =1𝜃!

−𝑇!"# + 𝐾!𝑢 𝑡 − 𝜃! + 𝑇!"#  

Where:  

• 𝑇!"# ℃   is  the  air  temperature  at  the  tube  outlet  • 𝑢  [𝑉]   is  the  control  signal  to  the  heater  • 𝜃!  [𝑠]   is  the  time-­‐constant  • 𝐾!  [𝑑𝑒𝑔  𝐶  /  𝑉]   is  the  heater  gain  • 𝜃!  [𝑠]   is  the  time-­‐delay  representing  air  transportation  and  sluggishness  in  the  heater  

Page 4: Case Project - Control System in LabVIEW.pdf

4     Modeling    

Control System in LabVIEW

 

• 𝑇!"# ℃   is  the  environmental  (room)  temperature.  It  is  the  temperature  in  the  outlet  air  of  the  air  tube  when  the  control  signal  to  the  heater  has  been  set  to  zero  for  relatively  long  time  (some  minutes)  

The  following  values  can  be  used:  

𝜃! = 22  𝑠𝑒𝑐  

𝜃! = 0  𝑠𝑒𝑐  

𝐾! = 3.5  ℃𝑉  

𝑇!"# = 21.5  ℃    

Note!  All  of  the  devices  are  slightly  different.  It  is  necessary  to  run  som  experiments  in  order  to  find  the  optimal  values  for  your  device.  The  procedure  is  described  later.  

1.2 Level Tank

The  LM-­‐900  Level  Tank  equipment  will  be  used  in  this  Lab  Work:  

 

Control  Signal:  A  pump  fills  the  tank  with  water  from  the  reservoir.  The  pump  speed  can  be  controlled  by  a  voltage  signal  in  the  range   0   −  5𝑉.  The  pump  can  be  controlled  by  an  external  voltage  signal  at  the  “FROM  PC”  connector.  

Measurement  Signal:  The  measurement  is  a  voltage  signal  in  the  range   0   −  5𝑉   available  at  the  “TO  PC”  connector.  This  voltage  range  corresponds  to  a  level  range  of   0   −  20  𝑐𝑚,  approximately  (unless  you  need  a  more  accurate  relation,  you  can  assume  this  range  in  your  applications).  

Page 5: Case Project - Control System in LabVIEW.pdf

5     Modeling    

Control System in LabVIEW

 

Scaling:  You  need  to  scale  the  signal   0 − 5𝑉   to   0 − 20𝑐𝑚.  The  following  linear  relationship  applies:  

𝑦 = 𝑎𝑥 + 𝑏  

A  very  simple  (linear)  model  of  the  water  tank  is  as  follows:  

𝐴!ℎ = 𝐾!𝑢−𝐹!"#  

or  

ℎ =1𝐴!

𝐾!𝑢−𝐹!"#  

Where:  

• ℎ   [𝑐𝑚]   is  the  level  in  the  water  tank  • 𝑢   [𝑉]   is  the  pump  control  signal  to  the  pump  • 𝐴!   [𝑐𝑚2]   is  the  cross-­‐sectional  area  in  the  tank  • 𝐾!   [(𝑐𝑚3/𝑠)/𝑉]   is  the  pump  gain  • 𝐹!"#   [𝑐𝑚3/𝑠]   is  the  outflow  through  the  valve  (this  outflow  can  be  modeled  more  

accurately  taking  into  account  the  valve  characteristic  expressing  the  relation  between  pressure  drop  across  the  valve  and  the  flow  through  the  valve).  

The  following  values  can  be  used:  

𝐾! = 15(𝑐𝑚!/𝑠)/𝑉  

𝐴! = 80𝑐𝑚!  

𝐹!"# = 10𝑐𝑚!/𝑠  

𝑇! = 0.1𝑠  

 

Note!  All  of  the  devices  are  slightly  different.  It  is  necessary  to  run  som  experiments  in  order  to  find  the  optimal  values  for  your  device.  The  procedure  is  described  later.  

Page 6: Case Project - Control System in LabVIEW.pdf

6  

   

2 Simulation

2.1 DAQ Device

We  we  will  use  a  USB-­‐6008  DAQ  unit  in  order  to  read  data  from  the  process  (𝑦)  to  the  PC,  and  write  data  (𝑢)  from  the  PC  to  the  process.  

 

2.1.1 DAQ Assistant

In  order  to  communicate  with  the  USB-­‐6008  DAQ  device  within  LabVIEW,  we  can  use  the  DAQ  Assistant.  Note!  The  NI-­‐DAQmx  software  needs  to  be  installed.  

The  DAQ  Assistant  is  located  from  the  Functions  palette:  “Measurement  I/O  →  NI-­‐DAQmx  →  DAQ  Assist”.  

Analog  In  Example:  

Below  we  see  a  typical  example  in  LabVIEW  where  we  read  from  the  “Analog  Input”  port  of  the  DAQ  device:  

Analog  Out  Example:  

Below  we  see  a  typical  example  in  LabVIEW  where  we  read  from  the  “Analog  Output”  port  of  the  DAQ  device:  

   

Page 7: Case Project - Control System in LabVIEW.pdf

7     Simulation    

Control System in LabVIEW

 

   

Loopback  Test  (Analog  Out  connected  to  Analog  In):  

 

Front  Panel  Example:  

 

Page 8: Case Project - Control System in LabVIEW.pdf

8     Simulation    

Control System in LabVIEW

 

2.2 Model Implementation

The  model  (Level  Tank  or  Air  Heater)  should  be  implemented  using  the  blocks  (Integrator,  Transport  Delay,  Summation,  Multiplication,  etc.)  from  the  Simulation  palette  in  LabVIEW:  

 

Air  Heater:  The  Air  Heater  model  can  be  implemented  as  a  Simulation  Sub  System:  

 

Level  Tank:  The  Level  Tank  model  can  be  implemented  as  a  Simulation  Sub  System:  

Page 9: Case Project - Control System in LabVIEW.pdf

9     Simulation    

Control System in LabVIEW

 

 

2.2.1 Model Adjustment

The  model  parameters  should  be  adjusted  by  some  simple  experiments  where  you  run  the  simulator  in  parallel  with  the  real  process.  Use  the  “Trial  and  Error”  method  in  order  to  find  the  unknown  parameters.  

The  LabVIEW  program  for  adjusting  the  parameters  could  be  like  this:  

 

This  means  that  we  plot  the  output  of  the  model  and  the  process  and  compare  them  after  a  change  in  the  control  signal.  If  they  are  “almost”  identical,  we  have  found  good  model  parameters,  if  not,  we  need  to  adjust  the  modelparameters  and  try  again.  

LabVIEW  Example:  

Page 10: Case Project - Control System in LabVIEW.pdf

10     Simulation    

Control System in LabVIEW

 

 

Front  Panel  Example:  

Page 11: Case Project - Control System in LabVIEW.pdf

11  

 

3 Control System This  is  a  typical  block  diagram  of  the  system:  

 

Since  LabVIEW  is  a  graphical  development  environment,  this  can  easly  be  implemented  in  LabVIEW.  

3.1 Discrete Low-pass Filter

Transfer  function  for  a  first-­‐order  low-­‐pass  filter  may  be  written:  

𝐻 𝑠 =1

𝑇!𝑠 + 1  

Where   𝑇!   is  the  time-­‐constant  of  the  filter.  

Create  a  discrete  low-­‐pass  filter  in  LabVIEW  using  the  Formula  Node  in  LabVIEW.  Create  a  SubVI  of  the  code.  The  user  needs  to  be  able  to  set  the  time  constant  of  the  filter   𝑇!   from  the  outside,  i.e.,  it  should  be  an  input  to  the  SubVI.  The  simulation  Time-­‐step   𝑇!   needs  also  to  be  set  from  the  outside.  

Use  the  Euler  Backward  method:  

𝑥 =𝑥! − 𝑥!!!

𝑇!  

Perform  simulations  to  make  sure  the  filter  works  as  expected.  Explain/Show  how  you  do  this.  Why  do  we  use  a  low-­‐pass  filter?  

Page 12: Case Project - Control System in LabVIEW.pdf

12     Control  System    

Control System in LabVIEW

 

3.2 Discrete PI Controller

A  continuous  time  PI  controller  may  be  written:  

𝑢 𝑡 = 𝑢! + 𝐾!𝑒 𝑡 +𝐾!𝑇!

𝑒𝑑𝜏!

!  

Where  u  is  the  controller  output  and  e  is  the  control  error:  

𝑒 𝑡 = 𝑟 𝑡 − 𝑦(𝑡)  

Create  a  discrete  PI  controller  in  LabVIEW  using  the  Formula  Node.  Create  a  SubVI  of  the  code.  

-­‐  Typical  Inputs  to  the  controller:   𝐾!, 𝑇! , 𝑦, 𝑟  

-­‐  Typical  Outputs  from  the  controller:   𝑢  

Use  the  Euler  Backward  method:  

𝑥 =𝑥! − 𝑥!!!

𝑇!  

Make  sure  the  PI  controller  works  as  expected.  

3.3 Control System

Implement  a  control  system  using  the  discrete  PI  controller  created.  Use  the  mathematical  model  of  the  system  in  the  simulations.  

You  should  also  test  our  control  system  on  the  real  process  (Level  Tank  or  Air  Heater).  

Note!  You  need  to  install  the  NI-­‐DAQ-­‐mx  driver  that  makes  it  possible  to  use  the  USB-­‐6008  device  together  with  LabVIEW.  

Set  up  hardware  and  software  according  to  the  sketch  below:  

Page 13: Case Project - Control System in LabVIEW.pdf

13     Control  System    

Control System in LabVIEW

 

 

Make  sure  to  use  your  low-­‐pass  measurement  filter  created  in  a  previous  task.  

3.4 Controller Tuning

Use  the,  e.g.,  Skogestad’s  method  in  order  to  find  proper  PI  parameters  for  the  system.    

Skogestad’s  method:  

In  this  task  we  assume  the  following  process:  

𝐻 𝑠 =𝑇!"#(𝑠)𝑢(𝑠)

=𝐾

𝑇𝑠 + 1𝑒!!"  

The  Skogestad’s  method  assumes  you  apply  a  step  on  the  input  (𝑢)  and  then  observe  the  response  and  the  output  (𝑦),  as  shown  below:  

Page 14: Case Project - Control System in LabVIEW.pdf

14     Control  System    

Control System in LabVIEW

 

 

If  we  have  a  model  of  the  system  (which  we  have  in  our  case),  we  can  use  the  following  Skogestad’s  formulas  for  finding  the  PI(D)  parameters  directly:  

 

Tip!  In  this  task  we  can  e.g.,  set   𝑇! = 10  𝑠   and   𝑐 = 1.5   (or  try  with  other  values  if  you  get  poor  PI  parameters).  

 

 

Page 15: Case Project - Control System in LabVIEW.pdf

 

 

 

 

 

 

 

  Telemark  University  College  

Faculty  of  Technology  

Kjølnes  Ring  56  

N-­‐3918  Porsgrunn,  Norway  

www.hit.no  

 

 

    Hans-­‐Petter  Halvorsen,  M.Sc.  

Telemark  University  College  

Department  of  Electrical  Engineering,  Information  Technology  and  Cybernetics  

 

E-­‐mail:  [email protected]  

Blog:  http://home.hit.no/~hansha/