34
Dennis C. Erickson ~ Senior Mentor for Teams 1510 and 2898 1

First fare 2011 lab-view overview

Embed Size (px)

Citation preview

Page 1: First fare 2011 lab-view overview

Dennis C. Erickson ~ Senior Mentor for Teams 1510 and 2898

1  

Page 2: First fare 2011 lab-view overview

Working  with  National  Instrument’s  Hardware  and  Software  

 Specifically:  

Software  ~  LabVIEW  Hardware  ~  cRIO  

2  

Page 3: First fare 2011 lab-view overview

LabVIEW  VI  =  Virtual  Instrument  

EW  =  Engineering  Workstation    

VI  =  Virtual  Instrument  or  in  other  languages  “Routine”,  SubVI  =  Subroutine  

3  

Page 4: First fare 2011 lab-view overview

• Graphical  Interface  (Not  Text  Based)  • Dataflow  (All  inputs  must  be  updated  before  VI  –  Virtual  Instrument  –  executes)  • Self  Documenting  (You  know  what  the  code  does)    

4  

Page 5: First fare 2011 lab-view overview

• Portable  Code  (VIs  are  easily  reused)  • Advanced  set  of  diagnostic  tools;  probes,  execution  highlighting,  error  reporting,  ability  to  surround  the  code  with  a  “virtual  world  simulation  environment”  for  testing.  

5  

Page 6: First fare 2011 lab-view overview

• Perfectly  tailored  for  NI  hardware  • Automatically  handles  multiple  cores    and  threads  • Easily  compiles  to  RT  (Real-­‐time)  Operating  Systems  and  FPGA  (Field  Programmable  Gate  Arrays)  used  in  the  cRIO  processor  

6  

Page 7: First fare 2011 lab-view overview

While  it  is  entirely  possible  to  win  a  contest  with  a  robot  that  is  “bare  bones”  the  better  goal  is  to  learn  how  to  do  things  along  the  way  that  may  or  may  not  be  used.  

   

7  

Page 8: First fare 2011 lab-view overview

8  

Page 9: First fare 2011 lab-view overview

This  section  offers  a  brief  short  course  on  the  language  LabVIEW  

 

9  

Page 10: First fare 2011 lab-view overview

Launch  LabVIEW  to  create  a  new  project  

10  

Page 11: First fare 2011 lab-view overview

Name  your  project  .  You  might  for  example  use  your  team  name  and  year  in  the  name:  i.e.,  “Team  1510  for  2010  Robot  Project”    Be  sure  that  you  enter  your  team  IP  in  the  following  format:  10.15.10.02  

11  

Page 12: First fare 2011 lab-view overview

Adding  a  VI  to  your  project:  If  its  new,  then  right-­‐click  to  “VI”  and  select  and  name  it.    If  adding  an  existing  one  select  the  menu  item  “Add”.  

12  

Page 13: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

13  

Numerical  Controls  and  Indicators  

Page 14: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

14  

Booleans  

Page 15: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

15  

Strings  and  Paths  

Page 16: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

16  

Arrays,  Clusters,  Matrices  and  Dialog  Boxes  

Page 17: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

17  

List  Boxes,  Tables  and  Trees  

Page 18: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

18  

2D,  3D  Digital  

Charts  and  Graphs  and  Special  Plots  

Page 19: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Front  Panel  

19  

Rings  and  Enums  

Page 20: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Diagram  

20  

Structures  

Page 21: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Diagram  

21  

Arrays  

Page 22: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Diagram  

22  

Structures,  Classes  and  Variants  

Page 23: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Diagram  

23  

Numerics,  Booleans  and  Files  

Page 24: First fare 2011 lab-view overview

Some  example  controls  and  indicators  for  the  Diagram  

24  

Hundreds  of  other  functions  

Timing,  Dialog  Boxes,  Waveforms,  etc,  etc  

Page 25: First fare 2011 lab-view overview

Testing  the  Joystick  Power  Function  VI  

25  

Task:    Test  the  VI  with  1000  simulated  Joystick  positions  from  0  to  +1  to  0  to  -­‐1  (White  Line)  and  create  9  plots  with  the  following  function:    Plotn  =  (motor  speed)m  

 Where:    Plotn  =  a  series  of  plots  (9  total)  Motor  speed  =  voltage  input  to  the  motor  (from  1  to  -­‐1)  m  =  power  function  (use  to  alter  the  forward  sensitivity  of  the  Joystick)    

Page 26: First fare 2011 lab-view overview

This  discussion  touches  on  the  following  principle  areas:  

 • The  cRIO  hardware  (The  Brain)  • The  Sensors,  Motors  and  Actuators  that  can  be  used    • The  DS  Drive  Station  (Link  from  the  User  to  the  robot’s  brain)  

       

26  

Page 27: First fare 2011 lab-view overview

cRIO  –  Compact  Real-­‐time  Input/Output    A  PAC  (Programmable  Automation  Controller)  which  is  an  industrial  controller  that  is  used  in  advanced  systems  incorporating  software  capabilities  such  as  control,  communication,  data  logging,  and  signal  processing  requiring  rugged  hardware  performing  logic,  motion,  process  control,  and  vision.  For  FIRST  applications,  ideal  for  robot  building.  

27  

A  fully  populated  cRIO  example  

Page 28: First fare 2011 lab-view overview

Real-­‐time  operating  system  

28  

FPGA  –  Field  Programmable  Gate  Array  located  under  the  cRIO  chassis  

cRIO  connected  to  a  Laptop  

Page 29: First fare 2011 lab-view overview

The  following  Example  code  shows  how  to  create  an  environment  to  test  and  calibrate  VI  modules.  In  this  case  we  are  testing  the  Camera  Servo  motors  

29  

First  Initialize  the  test  (note  the  “Data  Dependency”  wire)  

Next  run  the  test  in  a  While  loop.  Note  the  Loop  Sweep  constant  which  defines  the  loop    cycle  (20ms).  Here  the  loop  is  stopped  using  the  Stop  Test?  command    

Finally  End  the  test  by  closing  all  references,  etc.  Again  note  the  Data  Dependency  and  use  of  a  Frame  structure  as  the  SubVI  has  no  wired  input  to  use  

Page 30: First fare 2011 lab-view overview

The  following  slides  start  with  a  State  Chart  to  show  what  the  State  Diagram  will  do.  The  next  slides  show  the  State  Diagram  created.  

30  

Page 31: First fare 2011 lab-view overview

31  

The  Application  starts  by  selecting  the  Initialize  Test  State  (case).  Note  that  we  check  for  errors  and  if  the  Stop  Test?  Button  is  pressed.  Note  that  the  Enum  (far  left  constant  control)  has  3  possible  states;  Initialize  Test,  Run  Test  and  End  Test  

State  diagrams  are  extremely  useful  in  creating  small  or  large  applications.  Since  LabVIEW  is  a  DataFlow  language,  this  approach  adds  to  the  robustness  of  the  application  

Page 32: First fare 2011 lab-view overview

32  

Next  if  no  errors,  run  the  While  loop  until  an  error  happens  or  the  Stop  Test?  Button  is  pressed  the  go  to  the  next  State  

These  slides  show  a  typical  State  Diagram  that  tests  camera  servos.  Note  the  inputs  from  the  joystick  and  a  smoothing  control  to  test  filtering.  

Page 33: First fare 2011 lab-view overview

One  of  the  interesting  features  of  the  State  Diagram  is  confining  the  application  code  to  one  screen,  thus  self  documenting  code  

33  

Finally,  there  has  been  an  error  or  the  Stop  Test?  Button  has  been  pressed  so  end  the  test  by  closing  references,  etc.  Note  that  now  the  Boolean  constant  is  now  TRUE  which  stops  the  loop  

Page 34: First fare 2011 lab-view overview

Dennis C. Erickson - [email protected]