control and simula/on in labview

22
Control and Simula.on in LabVIEW HansPe:er Halvorsen, M.Sc.

Upload: phunghanh

Post on 06-Jan-2017

244 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Control and Simula/on in LabVIEW

Control  and  Simula.on  in  LabVIEW  

Hans-­‐Pe:er  Halvorsen,  M.Sc.  

Page 2: Control and Simula/on in LabVIEW
Page 3: Control and Simula/on in LabVIEW

Hardware  

cRIO  

ZigBee  

Vision  System  

Arduino  

USB-­‐6008  

Wi-­‐Fi  DAQ  

TC-­‐01  

NOx  Sensor  

Pt-­‐100  

Air  Heater  

Water  Tank  

Page 4: Control and Simula/on in LabVIEW

LabVIEW  Installa.on  Download  the  soUware  here:    h:ps://lumen.ni.com/nicif/us/acadevallvdl/content.xhtml      These  are  the  main  modules  we  use  in  the  different  courses  at  Telemark  University  College:  •  LabVIEW  (LabVIEW  Professional  Development  System  32-­‐Bit:  English)  •  LabVIEW  MathScript  RT  Module  •  LabVIEW  Control  Design  and  Simula>on  Module  •  LabVIEW  PID  and  Fuzzy  Logic  Toolkit  •  LabVIEW  System  Iden>fica>on  Toolkit  •  NI-­‐DAQmx  Note!  These  packages  are  separate  downloads!  Make  sure  to  download  and  install  all  of  them!  Select  the  SoUware  in  the  “August  2013”  column  (LabVIEW  2013).    

Note!  The  Serial  Number  is  in  Fronter!  

Page 5: Control and Simula/on in LabVIEW

LabVIEW  Training  

•  LabVIEW  Training  for  Students  (Na.onal  Instruments):

h:p://www.ni.com/academic/students/learn-­‐labview/    

•  LabVIEW  Course:  h:p://home.hit.no/~hansha/?training=labview    

 

Page 6: Control and Simula/on in LabVIEW

Control  and  Simula.on  in  LabVIEW  Control  Design  &  Simula.on  Pale:e  in  LabVIEW  

Simula.on  Pale:e  in  LabVIEW   PID  Pale:e  in  LabVIEW  

Control  Design  Pale:e  in  LabVIEW  

Students:  Check  that  you  have  all  these  pale:es  

Page 7: Control and Simula/on in LabVIEW

LabVIEW  Control  and  Simula.on  Example  

We  are  going  to  learn  to  create  such  a  system!  

Page 8: Control and Simula/on in LabVIEW

Simula.on  in  LabVIEW  Simula.on  Pale:e  in  LabVIEW  

Simula>on  Loop:  Similar  to  a  While  Loop,  but  cusomized  for  used  together  with  the  Simula.on  Blocks  available  in  LabVIEW    

Different  Simula.on  Blocks    by  Category  •  Con.nuous  Systems  •  Discrete  Systems  •  Nonlinar  Systems  •  etc.  

h:p://home.hit.no/%7Efinnh/videos/sim_module/sim_pale:e_overview/sim_pale:e_overview.html    

Simula>on  PaleJe  Video  (15  minutes)  

Page 9: Control and Simula/on in LabVIEW

Simula.on  Example  

Students:  Implement  and  Simulate    this  system  in  LabVIEW  

Page 10: Control and Simula/on in LabVIEW

Simula.on  Example  -­‐  Configura.on  In  the  example  the  following  simula.on  parameters  could  be  used  (right-­‐click  on  the  Simula.on  Loop  border  and  select  “Configure  Simula.on  parameters…”):    

Page 11: Control and Simula/on in LabVIEW

Simula.on  Example  -­‐  Solu.ons  

Step  Response   We  see  the  Step  Response  is  as  expected!  

Page 12: Control and Simula/on in LabVIEW

PID  Control  in  LabVIEW  PID  Pale:e  in  LabVIEW  (PID  Toolkit)  

Note!  The  func.ons  “PID.vi”  and  “PID  Advanced.vi”  requires  that  Ti  and  Td  is  in  minutes,  while  it’s  normal  to  use  seconds  as  the  unit  for  these  parameters.  You  can  use  the  following  piece  of  code  in  order  to  transform  them:  This  means  we  entervalues  for  Ti  and  Td  in  secons  on  the  Front  Panel  and  the  values  are  converted  to  minutes  in  the  code.  

Alterna>ve  1:   Alterna>ve  2:  

This  alterna.ve  uses  seconds!  

Page 13: Control and Simula/on in LabVIEW

PID  Example  

Students:  Replace  u  in  the  previous  example  with  the  built-­‐in  PID  Controller  (use  Alterna.ve  2)  

Page 14: Control and Simula/on in LabVIEW

PID  Example  -­‐  Solu.ons  

Front  Panel:  

Page 15: Control and Simula/on in LabVIEW

PID  Example  -­‐  Solu.ons  

Block  Diagram:  

Page 16: Control and Simula/on in LabVIEW

PID  Example  –  Con.nuous  Simula.on  

Students:  Run  your  Simula.on  with  these  changes  

Add  a  Stop  Bu:on  and  a  “Halt  Simula.on”  block  

Right-­‐click  on  the  Simula.on  Loop  border  and  select  “Configure  Simula.on  Parameters…”  

Page 17: Control and Simula/on in LabVIEW

PID  Example  –  Con.nuous  Simula.on  -­‐  Solu.on  

Page 18: Control and Simula/on in LabVIEW

Create  a  Subsystem  of  this  part  

Simula.on  Subsystem  A  Way  to  structure  your  code,  similar  to  SubVIs  

Students:  Change  your  code  above  where  you  create  a  Simula.on  Sub  System  for  your  Process  

File  -­‐>  New…  This  is  the  recommended  way  to  do  it!  –  You  can  easly  reuse  your  Subsystems  in  different  VIs  and  your  code  becomes  more  structured!  

Page 19: Control and Simula/on in LabVIEW

Simula.on  Subsystem  -­‐  Solu.ons  

Page 20: Control and Simula/on in LabVIEW

Simula.on  Subsystem  –  Solu.ons2  

Simula.on  Sub  Systems  

Now  your  code  has  become  really  simple  to  understand!  

Page 21: Control and Simula/on in LabVIEW

Simula.ons  using  a  While  Loop  The  Simula.on  Loop  has  some  drawbacks/is  more  complicated  to  use  than  an  ordinary  While  Loop.  If  we  use  simulata.on  Subsystems,  we  can  use  them  inside  a  While  Loop  instead!    

So  for  real  applica.ons  that  involves  more  than  just  simula.ons,  I  recommend  to  use  a  While  Loop  instead  of  a  Simula.on  Loop.  

Simula.on  Subsystems  

Page 22: Control and Simula/on in LabVIEW

Hans-­‐PeJer  Halvorsen,  M.Sc.  Telemark  University  College  Faculty  of  Technology  Department  of  Electrical  Engineering,  Informa>on  Technology  and  Cyberne>cs  

   E-­‐mail:  [email protected]  Blog:  hJp://home.hit.no/~hansha/    

22