Presentation is loading. Please wait.

Presentation is loading. Please wait.

LabVIEW Basics Dustin Cruise. Who is this guy? Graduate Student in Mechanical Engineering at Purdue University Specialty Areas: Combustion Control Systems.

Similar presentations


Presentation on theme: "LabVIEW Basics Dustin Cruise. Who is this guy? Graduate Student in Mechanical Engineering at Purdue University Specialty Areas: Combustion Control Systems."— Presentation transcript:

1 LabVIEW Basics Dustin Cruise

2 Who is this guy? Graduate Student in Mechanical Engineering at Purdue University Specialty Areas: Combustion Control Systems I work in a lab burning things and using lasers I use LabVIEW a lot in my research Sensors Actuators Data Acquisition and Analysis Image Capture and Machine Vision

3 Topics Today LabVIEW Introduction Getting Started Programming – Projects, VIs – Dataflow and execution control… Troubleshooting tools Resources

4 LABVIEW INTRODUCTION

5 Virtual Instruments LabVIEW is a programming language! It is a full- fledged programming language, unlike many graphical “languages” which are not really complete. Historically, LabVIEW was designed by National Instruments to make life easier for engineers and scientists wanting to put together instrumentation – Advantage over other software is built-in analysis tools It is meant to be easy to use… – But you can’t program it exactly like C or other more traditional languages. It is a Dataflow, not a procedural language.

6 GETTING STARTED PROGRAMING VIs, variables, indicators, functions

7 Project Tree and Virtual Instruments Project Tree – Organizes and links VIs to hardware Components of a VI: – Front panel: You can put “indicators” and “controls” here Super useful! Buttons, LEDs, graphs, dials, anything you want! Caution though: charts can require a lot of processor and memory – Block diagram: Computational stuff goes here. This is the “code” part! Where the magic happens.

8 LabVIEW Block Diagram Example Startup Main Application Shutdown

9 Variables/Signals Variables/signals – people will use these terms interchangeably – Travel on wires – Basic types: Boolean – True or False (green wire) Numeric (integer) – negative or positive, ie -4, -25535, +5390584 (blue wire) Double – decimal number, like 0.3423423, 65.0232 (orange wire) String – array of characters that travel together, like a word or sentence…i.e. ‘this is a string’ (pink wire) – More types: Just wait! We’ll get there…

10 Quiz Time ‘I love LabVIEW’ is an example of a: – String – Double – Integer – Boolean How about 0.4234? See? This stuff is easy! Relax!

11 WHEN DO THINGS HAPPEN? Data flow and execution control

12 Dataflow Things happen in order…sort of. But what’s the order when you just have things strung together? Sometimes, it is hard to tell. Let’s talk about the rules with a little demonstration.

13 Quiz What’s the order in which events will happen in the following code?

14 Execution Control While Loops – Loop until condition is met For Loops – Loop a number of times Timing a VI – Waits/delays – Timed loops  USE FOR TIME CRITICAL THINGS LIKE CONTROL LOOPS!

15 Execution Control Case Statements – Use these to switch between possible code branches; i.e. do this or this other thing based on the value of a switch Boolean operations – Logic operations

16 Relating Data Arrays – All of same type, traveling together – Multiple dimensions possible Clusters – Multiple types bundled together – Can address by signal name Type Definitions – Kinda like object oriented programming…not going to cover it very much here, but it can be useful

17 Modularity SubVIs are super helpful in keeping code clean. – Simple example Be careful that you know how they will behave…especially when you put loops in SubVIs. – Stay organized, add descriptions

18 Some tricky questions What about…parallel loops? – This can be hairy. What can help? – Simple example with local variables to stop two parallel loops. – Local variables help you when everything is on the same block diagram…handy. – Global variables are used when running multiple VIs; different block diagrams.

19 TROUBLESHOOTING TOOLS!

20 Problems we can have Bad algorithms Timing not behaving the way we’d like Race conditions Anything you can imagine

21 Diagnosing problems Probes Execution Highlighting PLOT PLOT PLOT PLOT PLOT PLOT – CHARTS ARE THE BEST! – KEY ADVANTAGE OF LABVIEW!

22 Designing code to avoid problems Use simplest code problem to accomplish a task – THINK ABOUT THE CODE BEFORE YOU START PROGRAMMING! – Flowcharts/pseudocode not always the best…due to Dataflow you sometimes want to work backwards! – Practice on simple examples!

23 Dealing with Timing Problems Since LabVIEW is a implicitly and unavoidably multithreaded language, embrace it! It is super fun! – Hint: Use Queues and Error Clusters to control execution timing. What are these? Use advanced code structures like state machines!

24 How to learn LabVIEW The secret to learning LabVIEW… is doing LabVIEW. Build a library of examples as you come across them – Most likely, what you’re trying to do has already been done before – Try to explain what each piece of an example VI does. It doesn’t work to just glance over Get familiar with resources

25 Resources FIRST’s getting started documentation that comes with the control system (available online as well) – Search for FRC LabVIEW NI and lots of things come up. FRCmastery.com NI Examples found in Help menu NI.com Effective LabVIEW Programming, Thomas J. Bress

26 Examples Opening – Test Rig

27 Things I didn’t cover today A lot of multithreading things. Queues, semaphores, notifiers, lots of stuff here. But be careful. Robot Specifics Any of the really awesome math and IO functions that LabVIEW already has built in

28 Wait! What about the robot? Oh yeah! FIRST, NI, and WPI have collaborated to nicely give us a great setup FRC cRIO (on Robot) and Dashboard Project Templates

29 What does robot code look like? Pretty much the same. Even bigger focus on determinism. – Need to think a lot about how timing works, when things happen, in what order. Teleop vs. Autonomous Tying in to the field system…

30 Tying things together Explore the libraries, both NI and FRC/WPI. Controling ! Plotting the motion!


Download ppt "LabVIEW Basics Dustin Cruise. Who is this guy? Graduate Student in Mechanical Engineering at Purdue University Specialty Areas: Combustion Control Systems."

Similar presentations


Ads by Google