sesion_labview

58
Laboratorio de Instrumentación Mecatrónica ITESM Chihuahua

Transcript of sesion_labview

Page 1: sesion_labview

Laboratorio de Instrumentación Mecatrónica

ITESM Chihuahua

Page 2: sesion_labview

Introduccion a LabVIEW

Laboratorio de Instrumentación Mecatrónica

2

Page 3: sesion_labview

3

LabVIEWLabVIEW is a highly productive development environment that engineers and scientists use for graphical programming and unprecedented hardware integration to rapidly design and deploy measurement and control systems. Within this flexible platform, engineers scale from design to test and from small to large systems while reusing IP and refining their processes to achieve maximum performance.

Page 4: sesion_labview

4

LabVIEWLabVIEW programs are called virtual instruments, or VIs, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeters

In LabVIEW, you build a user interface, or front panel, with controls and indicators.

After you build the user interface, you add code using VIs and structures to control the front panel objects. The block diagram contains this code.

Page 5: sesion_labview

5

LabVIEW – Front Panel – The UI

Page 6: sesion_labview

6

LabVIEW – Block Diagram – The Code

Page 7: sesion_labview

7

LabVIEW - HardwareYou can use LabVIEW to communicate with hardware such as :

data acquisition devices,(DAQ) vision and motion control devices, GPIB instruments, (General Purpose Instrument

Bus) PXI instruments, (PCI eXtensions for

Instrumentation) VXI instruments (VMEbus eXtensions for

Instrumentation) RS232 instruments, (ANSI/EIA-232 Standard, is the

serial connection found on IBM-compatible PCs) RS485 instruments, ( EIA-485 Standard, is an

improvement over RS-422. RS-422 is the serial connection used on Apple Macintosh computers)

Page 8: sesion_labview

8

LabVIEWLabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data, as well as tools to help you troubleshoot code you write.

Page 9: sesion_labview

9

LabVIEW – DAQ Devices12-Bit, 10 kS/s Low-Cost Multifunction DAQ

The National Instruments USB-6008 provides basic data acquisition functionality for applications such as simple data logging, portable measurements, and academic lab experiments. It is affordable for student use, but powerful enough for more sophisticated measurement applications. 

Page 10: sesion_labview

10

LabVIEW – GPIB or RS232 devices

Agilent 34401A Multimeter

1000 readings/s direct to GPIBThe 34401ª can send up to 1,000 readings/sdirectly across GPIB in user-friendlyASCII format.You also get both GPIB and RS-232interfaces as standard features.

Page 11: sesion_labview

11

NI - Software

NI-DAQmx NI-VISA

NI-DAQmx driver software and additional measurement services software included with every NI-DAQmx supported DAQ device provide: A single programming interface

for programming analog input, analog output, digital I/O, & counters on hundreds of multifunction DAQ hardware devices.

The same VIs and functions in NI LabVIEW, NI LabWindowsTM/CVI1, Visual Basic1, Visual Studio .NET1, and C/C++.

The Virtual Instrument Software Architecture (VISA) is a standard for configuring, programming, and troubleshooting instrumentation systems comprising GPIB, VXI, PXI, Serial, Ethernet, and/or USB interfaces. VISA provides the programming interface between the hardware and development environments such as LabVIEW, LabWindows/CVI, and Measurement Studio for Microsoft Visual Studio

Page 12: sesion_labview

12

NI LabVIEW Enviroment Basics Front Panel Controls Palette Controls and Indicators Block Diagram Terminals Functions Palette

http://www.ni.com/gettingstarted/labviewbasics/environment.htm

Page 13: sesion_labview

13

Front PanelWhen you open a new or existing VI, the front panel window of the VI appears. The front panel window is the user interface for the VI.

Page 14: sesion_labview

14

Front Panel

1  Front Panel Window

2  Toolbar 3 Controls Palette

Page 15: sesion_labview

15

Controls Palette

The Controls palette contains the controls and indicators you use to create the front panel. You access the Controls palette from the front panel window by selecting View»Controls Palette or by right clicking on any empty space in the front panel window.

Page 16: sesion_labview

16

Block DiagramBlock diagram objects include terminals, subVIs, functions, constants, structures, and wires, which transfer data among other block diagram objects. The block diagram window contains this graphical source code.

Page 17: sesion_labview

17

Block Diagram1  Indicator Terminals

2  Wires 3  Nodes 4 Control Terminals

Page 18: sesion_labview

18

TerminalsObjects on the front panel window appear as terminals on the block diagram.

Terminals are entry and exit ports that exchange information between the front panel and block diagram. Terminals are analogous to parameters and constants in text-based programming languages.

Types of terminals include control or indicator terminals and node terminals. Control and indicator terminals belong to front panel controls and indicators.

Page 19: sesion_labview

19

TerminalsControl and indicator terminals belong to front panel controls and indicators. Data you enter into the front panel controls enter the block diagram through the control terminals.

1  Controls 2  Indicator 3 Constant

Page 20: sesion_labview

20

Block Diagram NodesNodes are objects on the block diagram that have inputs and/or outputs and perform operations when a VI runs.

They are analogous to statements, operators, functions, and subroutines in text-based programming languages. Nodes can be functions, subVIs, Express VIs, or structures.

Structures are process control elements, such as Case structures, For Loops, or While Loops.

Page 21: sesion_labview

21

Functions

Functions are the fundamental operating elements of LabVIEW.

Functions do not have front panel windows or block diagram windows but do have connector panes.

Double-clicking a function only selects the function. A function has a pale yellow background on its icon.

Page 22: sesion_labview

22

SubVIsAfter you build a VI, you can use it in another VI.

A VI called from the block diagram of another VI is called a subVI. You can reuse a subVI in other VIs. To create a subVI, you need to build a connector pane and create an icon.

A subVI node corresponds to a subroutine call in text-based programming languages.

The node is not the subVI itself, just as a subroutine call statement in a program is not the subroutine itself. A block diagram that contains several identical subVI nodes calls the same subVI several times.

Page 23: sesion_labview

23

SubVIsThe subVI controls and indicators receive data from and return data to the block diagram of the calling VI.

When you double-click a subVI on the block diagram, its front panel window appears.

The front panel includes controls and indicators.

The block diagram includes wires, icons, functions, possibly subVIs, and other LabVIEW objects.

Page 24: sesion_labview

24

SubVIs

To use a VI as a subVI, you need to build a connector pane.

The connector pane is a set of terminals on the icon that corresponds to the controls and indicators of that VI, similar to the parameter list of a function call in text-based programming languages

Page 25: sesion_labview

25

Express VIs

Express VIs are nodes that require minimal wiring because you configure them with dialog boxes.

Use Express VIs for common measurement tasks.

Refer to the Express VIs topic of the LabVIEW Help for more information about Express VIs.

Page 26: sesion_labview

26

Functions PaletteThe Functions palette contains the VIs, functions and constants you use to create the block diagram. You access the Functions palette from the block diagram by selecting View»Functions Palette. The Functions palette is broken into various categories; you can show and hide categories to suit your needs.

Page 27: sesion_labview

27

Search PaletteWhen you select View»Controls or View»Functions to open the Controls and Functions palettes, two buttons appear at the top of the palette.

Page 28: sesion_labview

28

Page 29: sesion_labview

29

Graphical Programminghttp://www.ni.com/gettingstarted/labviewbasics/dataflow.htm

Watch the video:

Data Flow Programming Basics

Video:In LabVIEW graphical programming, the order in which code executes is determined by the way that data gets transferred across wires on the block diagram. That’s

called data flow programming.

http://link.brightcove.com/services/player/bcpid1523544664001?bckey=AQ~~,AAABNMyTt4E~,zX_oRi5kDcwYjRdQ0uLi-4wtWm_sYURl&bclid=0&bctid=1553773230001

Page 30: sesion_labview

30

Data Flow Programming in LabVIEWLabVIEW follows a dataflow model for running VIs.

A block diagram node executes when it receives all required inputs. When a node executes, it produces output data and passes the data to the next node in the dataflow path.

The movement of data through the nodes determines the execution order of the VIs and functions on the block diagram.

Page 31: sesion_labview

31

Data Flow Programming in LabVIEWFor a dataflow programming example, consider a block diagram that adds two numbers and then subtracts 50.00 from the result of the addition. In this case, the block diagram executes from left to right, not because the objects are placed in that order, but because the Subtract function cannot execute until the Add function finishes executing and passes the data to the Subtract function. Remember that a node executes only when data are available at all of its input terminals and supplies data to the output terminals only when the node finishes execution.

Page 32: sesion_labview

32

Data Flow Programming in LabVIEW

Page 33: sesion_labview

33

Data Flow Programming in LabVIEWIn Example 2 consider which code segment would execute first—the Add, Random Number, or Divide function. You cannot know because inputs to the Add and Divide functions are available at the same time, and the Random Number function has no inputs.

In a situation where one code segment must execute before another, and no data dependency exists between the functions, use other programming methods, such as sequence structures or error clusters, to force the order of execution.

Page 34: sesion_labview

34

Data Flow Programming in LabVIEW

Page 35: sesion_labview

35

Graphical Programminghttp://www.ni.com/gettingstarted/labviewbasics/dataflow.htm

Watch the video:

LabVIEW Data Types

Video:Numerics, text strings and Booleans are all examples of

different LabVIEW data types.  Each one is represented by a different wire colors, and different functions are available to let you convert between data types.

http://link.brightcove.com/services/player/bcpid1523544664001?bckey=AQ~~,AAABNMyTt4E~,zX_oRi5kDcwYjRdQ0uLi-4wtWm_sYURl&bclid=0&bctid=1553449588001

Page 36: sesion_labview

36

WiresYou transfer data among block diagram objects through wires.

In previous examples, wires connect the control and indicator terminals to the Add and Subtract function.  

Each wire has a single data source, but you can wire it to many VIs and functions that read the data.

Wires are different colors, styles, and thicknesses, depending on their data types.

Page 37: sesion_labview

37

WiresA broken wire appears as a dashed black line with a red X in the middle, as shown below.

Broken wires occur for a variety of reasons, such as when you try to wire two objects with incompatible data types.

Page 38: sesion_labview

38

Wires

Page 39: sesion_labview

39

Common Tools in LabVIEWYou can create, modify and debug VIs using the tools provided by LabVIEW.

A tool is a special operating mode of the mouse cursor.

The operating mode of the cursor corresponds to the icon of the tool selected. LabVIEW chooses which tool to select based on the current location of the mouse

Page 40: sesion_labview

40

Tools Palette

Automatic Tool Selector

Page 41: sesion_labview

41

Automatic Tool SelectorThe top item in the Tools palette is the Automatic Tool Selection button. When you select this, LabVIEW automatically chooses a tool based on the location of your cursor. You can turn off automatic tool selection by deselecting the item or by selecting another item in the palette.

If you were to compare the tools in LabVIEW to common household tools, the individual tools listed below would represent a screwdriver, a knife, and a corkscrew, and the automatic tool selector would be a Swiss army knife, capable of accomplishing all tasks.

Page 42: sesion_labview

42

Operating ToolUse the Operating tool to change the values of a control. For example, in Figure the Operating tool moves the pointer on the Horizontal Pointer Slide. When the mouse hovers over the pointer, the cursor automatically accesses the Operating tool.

Page 43: sesion_labview

43

Positioning ToolUse the Positioning tool to select or resize objects. For example, in Figure  the Positioning tool selects the Number of Measurements numeric control. After selecting an object, you can move, copy, or delete the object. When the mouse hovers over the edge of an object, the cursor automatically accesses the Positioning tool.

Page 44: sesion_labview

44

Labeling ToolUse the Labeling tool to enter text in a control, to edit text, and to create free labels. For example, in Figure  the Labeling tool enters text in the Number of Measurements numeric control. When the mouse hovers over the interior of the control, the cursor automatically accesses the Labeling tool. Click once to place a cursor inside the control. Then double-click to select the current text.

Page 45: sesion_labview

45

Wiring ToolUse the Wiring tool to wire objects together on the block diagram. For example, in Figure  the Wiring tool wires the Number of Measurements terminal to the count terminal of the For Loop.

The Wiring tool works mainly with the block diagram window and when you create a connector pane on the front panel window.

Page 46: sesion_labview

46

Shortcut MenuAll LabVIEW objects have associated shortcut menus, also known as context menus, pop-up menus, and right-click menus. As you create a VI, use the shortcut menu items to change the appearance or behavior of front panel and block diagram objects. To access the shortcut menu, right-click the object.

Page 47: sesion_labview

47

Property Dialog BoxesObjects in the front panel window also have property dialog boxes that you can use to change the look or behavior of the objects. Right-click an object and select Properties from the shortcut menu to access the property dialog box for an object. Figure  shows the property dialog box for a meter. The options available on the property dialog box for an object are similar to the options available on the shortcut menu for that object.

Page 48: sesion_labview

48

Front Panel Window Toolbar

Page 49: sesion_labview

49

Front Panel Window Toolbar

Page 50: sesion_labview

50

Block Diagram Window Toolbar

Click the Clean Up Diagram button to automatically reroute all existing wires and rearrange objects on the block diagram to generate a cleaner layout. To configure the clean up options, selectTools»Options to display the Options dialog box and select Block Diagram: Cleanup from the Category list.

Page 51: sesion_labview

51

Learn NI LabVIEW Basics Debugging Tools in NI LabVIEWhttp://www.ni.com/gettingstarted/labviewbasics/debug.htm Data Structures in NI LabVIEWhttp://www.ni.com/gettingstarted/labviewbasics/datastructures.htm Execution Structures in NI LabVIEWhttp://www.ni.com/gettingstarted/labviewbasics/exestructures.htm Passing Data Between Loop Iterations in NI

LabVIEWhttp://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm Handling Errors in NI LabVIEWhttp://www.ni.com/gettingstarted/labviewbasics/handlingerrors.htm

Page 53: sesion_labview

53

Begin Your Application – Video Demos Taking a Measurement with Your Computer Generating a Signal with Your Computer Logging Data with a USB Data Acquisition Device Real-Time Signal Processing and Analysis on Measurement Data Using Counters and Digital I/O on USB Data Acquisition Devices Automatically Generating Reports for Measurement Data Monitoring and Alarm Generating with Your Computer Building a PID Controller with Your Computer Configuring a Start Trigger on a USB Data Acquisition Device Building a Graphical User Interface (GUI) for Data Acquisition

Applications

http://www.ni.com/gettingstarted/beginapplication.htm

Page 54: sesion_labview

54

Getting Started NI-DAQmxGetting Started with NI-DAQmx: Getting Started with NI-DAQmx Programming in LabVIEW

Learn 10 Functions in NI-DAQmx and Handle 80% of your Data Acquisition Applications

Building an Analog Input VI in NI-DAQmx Building an Analog Output VI in NI-DAQmx Building a Counter Input VI in NI-DAQmx Building a Digital Input VI in NI-DAQmx

http://www.ni.com/white-paper/5468/en

Page 55: sesion_labview

55

NI-VISA

You can use NI-VISA (Virtual Instrument Software Architecture) to communicate with most instrumentation buses including GPIB, USB, Serial, and Ethernet. It provides a consistent and easy to use command set to communicate with a variety of instruments.

NI-VISA Overview

http://www.ni.com/white-paper/3702/en

Page 56: sesion_labview

56

Instrumental Control Fundamentals Series

Serial Instrument Control Tutorial

Serial is a common device communication protocol for instrument control because most computers and many remote instruments include at least one serial port.

http://www.ni.com/white-paper/2897/en

Page 57: sesion_labview

57

Instrumental Control Fundamentals Series

Instrument Control in LabVIEW Tutorial

This tutorial will cover how to control your instrument in LabVIEW using the following tools: instrument drivers, the Instrument I/O Assistant, and the VISA Application Programming Interface (API).

http://www.ni.com/white-paper/3511/en

Page 58: sesion_labview

58