Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to LabVIEW

Similar presentations


Presentation on theme: "Introduction to LabVIEW"— Presentation transcript:

1 Introduction to LabVIEW
Chris Thompson

2 Introduction What is LabVIEW? Project Explorer VI Front Panel
Block Diagram Icon and Connector Pane Data Types While Loops For Loops Case Structures Arrays Clusters Polymorphism

3 What is LabVIEW? LabVIEW is a graphical programming language.
LabVIEW programs are called Virtual Instruments; VI’s. The user interface is the Front Panel. The Block Diagram contains the graphical programming code. LabVIEW uses graphical dataflow programming. originally created to control scientific instrumentation and simplify data collection. A VI can be a stand alone program or a sub-program used inside of another VI. The user interface allows interaction between the program user and the software. Also known as the source code. data flows through nodes on the block diagram determining execution order

4 Project Explorer The Project Explorer is a container for all of the VI’s and other resources required for a LabVIEW application. The default project for the FIRST control system has the Main.VI which has a basic program pre-built that can be modified to perform all of the functionality required for the robot. Any new VI’s created can be added to the project.

5 VI Front Panel The Front Panel contains controls and indicators to operate the program and provide a display of data or information generated by the program. Controls can be numerical inputs, switches, string inputs, etc. Indicators are graphs, LED’s, gauges, etc.

6 VI Block Diagram The Block Diagram is the code that executes when the program runs. The block diagram contains a terminal for each control and indicator on the front panel plus any functions or operators in the code that interact with the front panel objects. The terminals, functions, and operators are connected with wires that the programmer adds to define the sequence of operations.

7 Exercise 1 Lets create a simple VI to create and display a random number between 0 and 10. Start a new VI: FILE>NEW VI… Place a Numeric Indicator on the Front Panel On the Block Diagram, add a Random Number and a Multiply function from the Numeric Palette. Right click on one input of the Multiply function and select CREATE>CONSTANT, and type 10 to set the value. Wire the rest of the diagram and run the program. Controls palette Functions palette Help window

8 Icon and Connector Pane
The VI Icon can be customized for your application. The Connector Pane allows you to connect your VI to other VI’s. These are located in the upper right corner of the front panel The Icon Editor within LabVIEW permits you to customize the icon. Open it by double clicking on the icon. The Connector Pane terminals are wired to controls and indicators on the front panel to provide connections externally to the VI.

9 Commonly Used LabVIEW Data Types
Numeric Floating Point Single, Double, Extended precision Signed Integer Byte (8 bit), Word (16 bit), Long (32 bit) Unsigned Integer Byte (8 bit), Word (16 bit), Long (32 bit) Boolean – True or False String – one or more ASCII characters Enums – Enumerated preset list

10 While Loops A While Loop is a code structure that executes repeatedly until a condition is met. The Iteration Terminal provides a count of the number of times the loop has executed. A While Loop always executes at least one time. The code for the condition terminal must be inside the loop.

11 Exercise 2 Let’s modify our Random Number program to generate a number once every second. On the Block Diagram, place While Loop enclosing all of the previously added functions. Right click Condition Terminal input and select CREATE>CONTROL. Place a Wait function inside the While Loop from the Timing Palette. Right click the input terminal to the Wait function and select CREATE>CONSTANT. Type 1000 to set the value of the constant to 1000 milliseconds. The VI will now generate a new random number every second until stop is pressed.

12 For Loops A For Loop is a code structure that executes a defined number of times. The Count Terminal determines how many times the loop executes.

13 Exercise 3 Let’s make a VI that averages 10 random numbers.
Start a new VI, place a Numeric Indicator on the Front Panel. Create a For Loop and wire a constant to the Count Terminal set to 10. Place a Random Number, Multiply, and Add functions inside the loop. Add a Shift Register by right clicking on the For Loop border and selecting ADD SHIFT REGISTER. Wire everything to generate a number between 0 and 10 every time the loop runs and add it to the previous iteration. Add functions outside the loop to divide by 10 and display on the Front Panel Indicator. Show diagram to let them complete wiring Demonstrate execution highlighting on the block diagram Mention probes as well

14 Case Structures A Case Structure contains two or more sub-diagrams.
The Case Selector label contains the name of case. The selector terminal can be wired with a Boolean, integer, string, or enum data type A default case should be set to deal with out of range values that may be input to the selector terminal.

15 Arrays An Array is a data structure consisting of elements and dimensions. Elements are the data that make up the array. Dimensions are length, height, or depth of the array. An Array can have one or more dimensions. Example of a 1 dimensional and 2 dimensional array. There is a complete palette of functions specifically for processing arrays.

16 Clusters A Cluster is a data structure that contains data elements of mixed types. The Error Cluster is commonly used in most VI’s for error handling. This cluster contains a Boolean (status), a numeric (code), and a string (source).

17 Polymorphism A VI can be designed to do different functions depending on the data that is wired to them. The FRC has a number of these types of VI’s, so in most cases you will need to select the correct variation for your application.

18 What to do Next Practice Coding!!
Download LabVIEW from the FRC site, activate it with the team code. Purchase a LabVIEW Home license from Digilent for $50. Use LabVIEW to write programs for Arduino or Raspberry Pi. Go to LabVIEW MakerSpace and download the LINX toolkit. LabVIEW Physical Computing kit from Digilent has license and a Pi, USB, and SD card for $89.


Download ppt "Introduction to LabVIEW"

Similar presentations


Ads by Google