Introduction to Lab VIEW Chris Thompson Introduction What

Introduction to Lab. VIEW Chris Thompson

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

What is Lab. VIEW? • Lab. VIEW is a graphical programming language. • Lab. VIEW programs are called Virtual Instruments; VI’s. • The user interface is the Front Panel. • The Block Diagram contains the graphical programming code. • Lab. VIEW uses graphical dataflow programming.

Project Explorer • The Project Explorer is a container for all of the VI’s and other resources required for a Lab. VIEW application.

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.

VI Block Diagram • The Block Diagram is the code that executes when the program runs.

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.

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.

Commonly Used Lab. VIEW 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

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.

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.

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.

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.

Case Structures • A Case Structure contains two or more sub-diagrams. • The Case Selector label contains the name of case.

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.

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).

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.

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