Introduction To LabVIEW - Halvorsen.blog

1y ago
7 Views
2 Downloads
5.16 MB
117 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Kelvin Chao
Transcription

https://www.halvorsen.blogIntroduction to LabVIEWHans-Petter ramming/labview/

Introduction to LabVIEWHans-Petter HalvorsenCopyright 2017E-Mail: hans.p.halvorsen@usn.noWeb: og

PrefaceThis document explains the basic concepts of LabVIEW.You find additional resources, code, etc. ing/labview/iii

Table of ContentsPreface . iiiTable of Contents . iv12Introduction . 11.1Dataflow Programming . 11.2Graphical Programming . 11.3Benefits . 2Start using LabVIEW . 42.1The LabVIEW Environment . 42.2Front Panel . 52.3Block Diagram . 72.4Controls Palette . 102.4.1Numeric Sub Palette . 122.4.2Boolean Sub Palette . 122.4.3String & Path Sub Palette . 132.5Function Palette. 132.6Tools Palette . 142.7Wiring . 162.8Toolbar. 162.9Execution . 172.10The Objects short-cut menu . 182.11Dataflow Programming . 192.12Help . 20Exercises . 20iv

vTable of Contents3Sub VIs . 243.1Create New Sub VI from Scratch. 253.1.1Input and Output SubVI Connectors . 263.1.2Icon Editor . 283.2Create Sub VI from existing code . 293.3Using Sub VIs . 30Exercises . 314Customize LabVIEW. 33Exercises . 345Loops and Structures . 355.1Loops. 355.1.1For Loop. 365.1.2While Loop . 375.2Structures . 385.2.1Case Structure . 385.2.2Sequence Structure . 395.2.3Event Structure . 40Exercises . 426Troubleshooting and Debugging . 456.1How to find errors . 456.2Highlight Execution . 456.3Probes . 466.4Breakpoints . 476.5Step into/over/out debugging . 48Exercises . 48Tutorial: An Introduction to LabVIEW

viTable of Contents7Working with Data . 507.1Arrays . 507.1.1Auto-Indexing . 507.1.2Array Functions . 517.2Cluster . 537.2.1Cluster Order . 547.2.2Cluster Elements. 55Exercises . 568Working with Strings . 58Exercises . 609Error Handling . 629.1Finding Error . 629.2Error Wiring . 629.3Error Handling in SubVIs . 639.4Error Handling . 64Exercises . 6510Working with Projects . 6610.1Project Explorer. 6610.2Deployment. 67Exercises . 6911Design Techniques. 7111.1Force Program Flow . 7111.2Shift Register . 7211.3State Programming Architecture . 7311.4Multiple Loops/Parallel programming . 75Tutorial: An Introduction to LabVIEW

viiTable of Contents11.5Templates. 77Exercises . 7812User Interface . 8012.1VI Properties . 81Exercises . 8413Plotting Data. 8513.1Customizing . 87Exercises . 8914Tips & Tricks . 9114.110 functions you need to know about . 9114.2The 10 most useful Short-cuts . 9615Example Application . 9716Additional Exercises . 10117What’s Next? . 10617.1My Blog . 10617.2Tutorials . 10617.3Additional Resources . 10617.4Examples . 107Quick Reference . 108Tutorial: An Introduction to LabVIEW

1 IntroductionLabVIEW (short for Laboratory Virtual Instrumentation Engineering Workbench) is aplatform and development environment for a visual programming language from NationalInstruments. The graphical language is named "G". Originally released for the AppleMacintosh in 1986, LabVIEW is commonly used for data acquisition, instrument control, andindustrial automation on a variety of platforms including Microsoft Windows, various flavorsof UNIX, Linux, and Mac OS X. The latest version of LabVIEW is version LabVIEW 2011. VisitNational Instruments at www.ni.com.The code files have the extension “.vi”, which is an abbreviation for “Virtual Instrument”.LabVIEW offers lots of additional Add-Ons and Toolkits.1.1 Dataflow ProgrammingThe programming language used in LabVIEW, also referred to as G, is a dataflowprogramming language. Execution is determined by the structure of a graphical blockdiagram (the LV-source code) on which the programmer connects different function-nodesby drawing wires. These wires propagate variables and any node can execute as soon as allits input data become available. Since this might be the case for multiple nodessimultaneously, G is inherently capable of parallel execution. Multi-processing and multithreading hardware is automatically exploited by the built-in scheduler, which multiplexesmultiple OS threads over the nodes ready for execution.1.2 Graphical ProgrammingLabVIEW ties the creation of user interfaces (called front panels) into the development cycle.LabVIEW programs/subroutines are called virtual instruments (VIs). Each VI has threecomponents: a block diagram, a front panel, and a connector panel. The last is used torepresent the VI in the block diagrams of other, calling VIs. Controls and indicators on thefront panel allow an operator to input data into or extract data from a running virtualinstrument. However, the front panel can also serve as a programmatic interface. Thus avirtual instrument can either be run as a program, with the front panel serving as a userinterface, or, when dropped as a node onto the block diagram, the front panel defines theinputs and outputs for the given node through the connector pane. This implies each VI canbe easily tested before being embedded as a subroutine into a larger program.1

2IntroductionThe graphical approach also allows non-programmers to build programs simply by draggingand dropping virtual representations of lab equipment with which they are already familiar.The LabVIEW programming environment, with the included examples and thedocumentation, makes it simple to create small applications. This is a benefit on one side,but there is also a certain danger of underestimating the expertise needed for good quality"G" programming. For complex algorithms or large-scale code, it is important that theprogrammer possess an extensive knowledge of the special LabVIEW syntax and thetopology of its memory management. The most advanced LabVIEW development systemsoffer the possibility of building stand-alone applications. Furthermore, it is possible to createdistributed applications, which communicate by a client/server scheme, and are thereforeeasier to implement due to the inherently parallel nature of G-code.1.3 BenefitsOne benefit of LabVIEW over other development environments is the extensive support foraccessing instrumentation hardware. Drivers and abstraction layers for many different typesof instruments and buses are included or are available for inclusion. These presentthemselves as graphical nodes. The abstraction layers offer standard software interfaces tocommunicate with hardware devices. The provided driver interfaces save programdevelopment time. The sales pitch of National Instruments is, therefore, that even peoplewith limited coding experience can write programs and deploy test solutions in a reducedtime frame when compared to more conventional or competing systems. A new hardwaredriver topology (DAQmxBase), which consists mainly of G-coded components with only afew register calls through NI Measurement Hardware DDK (Driver Development Kit)functions, provides platform independent hardware access to numerous data acquisitionand instrumentation devices. The DAQmxBase driver is available for LabVIEW on Windows,Mac OS X and Linux platforms.This document introducing the following themes: Start using LabVIEWo The LabVIEW Environmento Front Panel and Block Diagramo Palettes: Control Palette, Functions Palette, Tools Paletteo Data Typeso Property NodesSub VIsLoops and StructuresTroubleshooting and DebuggingWorking with DataTutorial: An Introduction to LabVIEW

3Introduction o Arrays§ Array Functionso ClusterWorking with StringsError HandlingWorking with Projects using Project ExplorerDesign Techniqueso Shift Registero State Machineo Multiple LoopsUser InterfacePlotting DataDeployment: Building Executable Applications (.exe)Introduction to Add-Ons and Toolkitso Briefly explanations o More detail about Control and Simulation Module in laterIntroduction to DAQ - Data Acquisitiono MAX – Measurement and Automation Explorero NI-DAQmxQuick Reference with Keyboard Short-cutsFor more information about LabVIEW, visit my Blog:https://www.halvorsen.blogTutorial: An Introduction to LabVIEW

2 Start using LabVIEWThis chapter explains the basic concepts in LabVIEW.The topics are as follows: The LabVIEW EnvironmentFront Panel and Block DiagramPalettes: Control Palette, Functions Palette, Tools PaletteData TypesProperty Nodes2.1 The LabVIEW EnvironmentLabVIEW programs are called Virtual Instruments, or VIs, because their appearance andoperation imitate physical instruments, such as oscilloscopes and multimeters. LabVIEWcontains a comprehensive set of tools for acquiring analyzing, displaying, and storing data, aswell as tools to help you troubleshoot your code.When opening LabVIEW, you first come to the “Getting Started” window.4

5Start using LabVIEWIn order to create a new VI, select “Blank VI” or in order to create a new LabVIEW project,select “Empty project”.When you open a blank VI, an untitled front panel window appears. This window displaysthe front panel and is one of the two LabVIEW windows you use to build a VI. The otherwindow contains the block diagram. The sections below describe the front panel and theblock diagram.2.2 Front PanelWhen you have created a new VI or selected an existing VI, the Front Panel and the BlockDiagram for that specific VI will appear.In LabVIEW, you build a user interface, or front panel, with controls and indicators. Controlsare knobs, push buttons, dials, and other input devices. Indicators are graphs, LEDs, andother displays.You build the front panel with controls and indicators, which are the interactive input andoutput terminals of the VI, respectively. Controls are knobs, push buttons, dials, and otherinput devices. Indicators are graphs, LEDs, and other displays. Controls simulate instrumentTutorial: An Introduction to LabVIEW

6Start using LabVIEWinput devices and supply data to the block diagram of the VI. Indicators simulate instrumentoutput devices and display data the block diagram acquires or generates.E.g., a “Numeric” can either be a “Numeric Control” or a “Numeric Indicator”, as seen below.I you select a “Numeric Control”, it can easy be changed to an “Numeric Indicator” by rightclick on the object an select “Change to Indicator”Or opposite, I you select a “Numeric Indicator”, it can easy be changed to an “NumericControl” by right click on the object an select “Change to Control”Tutorial: An Introduction to LabVIEW

7Start using LabVIEWThe difference between a “Numeric Control” and a “Numeric Indicator” is that for a“Numeric Control” you may enter a value, while the “Numeric Indicator” is read-only, i.e.,you may only read the value, not change it.The appearance is also slightly different, the “Numeric Control” has an increment and andecrement button in front, while the “Numeric Indicator” has a darker background color inorder to indicate that its read-only.2.3 Block DiagramAfter you build the user interface, you add code using VIs and structures to control the frontpanel objects. The block diagram contains this code. In some ways, the block diagramresembles a flowchart.Tutorial: An Introduction to LabVIEW

8Start using LabVIEWAfter you build the front panel, you add code using graphical representations of functions tocontrol the front panel objects. The block diagram contains this graphical source code. Frontpanel objects appear as terminals, on the block diagram. Block diagram objects includeterminals, SubVIs, functions, constants, structures, and wires, which transfer data amongother block diagram objects.The Figure below shows a front panel and its corresponding block diagram with front paneland block diagram components.Tutorial: An Introduction to LabVIEW

9Start using LabVIEWThe different components are as follows:1. Toolbar2. Owned Label3. Numeric Control4. Free Label5. Numeric Control Terminal6. Knob Terminal7. Numeric Constant8. Multiply Function9. Icon10. Knob Control11. Plot Legend12. XY GraphTutorial: An Introduction to LabVIEW

10Start using LabVIEW13. Wire Data Path14. XY Graph Terminal15. Bundle Function16. SubVI17. For Loop Structure2.4 Controls PaletteThe Controls and Functions palettes contain sub palettes of objects you can use to create aVI. When you click a sub palette icon, the entire palette changes to the sub palette youselected. To use an object on the palettes, click the object and place it on the front panel orblock diagram. The Controls palette is available only on the front panel. The Controls palettecontains the controls and indicators you use to build the front panel.The most used Sub Palettes are the Numeric Sub Palette, the Boolean Sub Palette and theString & Path Sub Palette.You may change the appearance and the contents of the Controls palette:Tutorial: An Introduction to LabVIEW

11Start using LabVIEWYou may Pin the palette, so it is always visible, just click the little pin buttonupper left corner of the palette:in theIf you want to change the content and appearance of the palette, click the “View” button.Here you may change the way the palette should look.If you click “Change Visible Categories ” you may change which Categories you want to havevisible.Tutorial: An Introduction to LabVIEW

122.4.1Start using LabVIEWNumeric Sub Palette“Numerical Control” and “Numerical Indicator” are the most used objects in the numeric subpalette.2.4.2Boolean Sub PaletteThis palette has lots of different buttons you may use. OK, Cancel and Stop buttons areuseful.Tutorial: An Introduction to LabVIEW

132.4.3Start using LabVIEWString & Path Sub PaletteIn the String and Path palette we have String Controls, Combo Box, etc.2.5 Function PaletteThe Functions palette is available only on the block diagram. The Functions palette containsthe VIs and functions you use to build the block diagram.Tutorial: An Introduction to LabVIEW

14Start using LabVIEW2.6 Tools PaletteYou can create, modify, and debug VIs using the tools located on the floating Tools palette.The Tools palette is available on both the front panel and the block diagram. A tool is aspecial operating mode of the mouse cursor. The cursor corresponds to the icon of the toolselected in the Tools palette. Use the tools to operate and modify front panel and blockdiagram objects.Tutorial: An Introduction to LabVIEW

15Start using LabVIEWThe Tools palette is available from the View menu:If you make sure “Automatic wiring” is disabled (I recommend you do so!) you may usethe Tab key on your keyboard in order to switch between the most common tools.The most used tools are:Use the Operating tool, shown at left, to change the values of a control or selectthe text within a control. The Operating tool changes to the icon shown at left when itmoves over a text control, such as a numeric or string control.Use the Positioning tool, shown at left, to select, move, or resize objects. ThePositioning tool changes to resizing handles when it moves over the edge of a resizableobject.Use the Labeling tool, shown at left, to edit text and create free labels. TheLabeling tool changes to the following iconwhen you create free labels.Use the Wiring tool, shown at left, to wire objects together on the block diagram.Tutorial: An Introduction to LabVIEW

16Start using LabVIEW2.7 WiringIn order to create the logical flow between the object on the Block Diagram, you need to usethe Wiring tool in order to connect the different objects together.Use the Wiring tool to wire objects together on the block diagram.Available Keyboard Shortcuts when dealing with Wiring:Ctrl-B is very useful. This short-cut removes all broken wires on the Block Diagram.2.8 ToolbarBelow we see the LabVIEW Toolbar:The behaviors of the different buttons are as follows:Tutorial: An Introduction to LabVIEW

17Start using LabVIEWClick the Run button to run a VI. LabVIEW compiles the VI, if necessary. You can run a VIif the Run button appears as a solid white arrow. The solid white arrow, shown above, alsoindicates you can use the VI as a subVI if you create a connector pane for the VI.While the VI runs, the Run button appears as shown at left if the VI is a top-level VI,meaning it has no callers and therefore is not a subVI.If the VI that is running is a subVI, the Run button appears as shown at left.The Run button appears broken, shown at left, when the VI you are creating or editingcontains errors. If the Run button still appears broken after you finish wiring the blockdiagram, the VI is broken and cannot run. Click this button to display the Error list window,which lists all errors and warnings.Click the Run Continuously button, shown at left, to run the VI until you abort or pauseexecution. You also can click the button again to disable continuous running.While the VI runs, the Abort Execution button, shown at left, appears. Click this buttonto stop the VI immediately if there is no other way to stop the VI. If more than one runningtop-level VI uses the VI, the button is dimmed.Note: Avoid using the Abort Execution button to stop a VI. Either let the VI complete its dataow or design a method to stop the VI programmatically. By doing so, the VI is at a knownstate. For example, place a button on the front panel that stops the VI when you click it.Click the Pause button, shown at left, to pause a running VI. When you click the Pausebutton, LabVIEW highlights on the block diagram the location where you paused execution,and the Pause button appears red. Click the button again to continue running the VI.2.9 ExecutionIn addition to the Toolbar buttons above the following Keyboard Shortcuts are availablewhen dealing with Execution:Tutorial: An Introduction to LabVIEW

182.10Start using LabVIEWThe Objects short-cut menuThe most often-used menu is the object shortcut menu. All LabVIEW objects and emptyspace on the front panel and block diagram have associated shortcut menus. Use theshortcut menu items to change the look or behavior of front panel and block diagramobjects. To access the shortcut menu, right-click the object, front panel, or block diagram.The Numeric control has the following short-cut/right-click menu:The short-cut menu will be different for the different controls or objects.Tutorial: An Introduction to LabVIEW

192.11Start using LabVIEWDataflow ProgrammingLabVIEW follows a dataflow model for running VIs. A block diagram node executes when allits inputs are available. When a node completes execution, it supplies data to its outputterminals and passes the output data to the next node in the dataflow path.Visual Basic, C /C#, Java, and most other text-based programming languages follow acontrol flow model of program execution. In control flow, the sequential order of programelements determines the execution order of a program.Example: Dataflow ProgrammingThe Example shows a block diagram that adds two numbers and then subtracts 50.00 fromthe result of the addition. In this case, the block diagram executes from left to right, notbecause the objects are placed in that order, but because the Subtract function cannotexecute until the Add function finishes executing and passes the data to the Subtractfunction. Remember that a node executes only when data are available at all of its inputterminals, and it supplies data to its output terminals only when it finishes execution.Example: Dataflow ProgrammingIn this example, consider which code segment would execute first-the Add, RandomNumber, or Divide function. You cannot know because inputs to the Add and Dividefunctions are available at the same time, and the Random Number function has no inputs. Ina situation where one code segment must execute before another and no data dependencyTutorial: An Introduction to LabVIEW

20Start using LabVIEWexists between the functions, use other programming methods, such as error clusters, toforce the order of execution.2.12HelpThe Context Help window (Ctrl H) displays basic information about LabVIEW objectswhen you move the cursor over each object. The Context Help window is visible by default.To toggle display of the Context Help window, select Help-Show Context Help, press the CtrlH keys, or click the Show Context Help Window button on the toolbar.When you move the cursor over front panel and block diagram objects, the Context Helpwindow displays the icon for subVIs, functions, constants, controls, and indicators, withwires attached to each terminal. When you move the cursor over dialog box options, theContext

5 Start using LabVIEW Tutorial: An Introduction to LabVIEW In order to create a new VI, select "Blank VI" or in order to create a new LabVIEW project, select "Empty project". When you open a blank VI, an untitled front panel window appears. This window displays the front panel and is one of the two LabVIEW windows you use to build a VI.

Related Documents:

Certified LabVIEW Architect Exam LabVIEW Core 1 LabVIEW Core 3 LabVIEW Core 2 Managing Software Engineering in LabVIEW Advanced Architectures in LabVIEW LabVIEW Connectivity Object-Oriented Design and Programming in LabVIEW LabVIEW Performance LabVIEW Real-Time 1

examples. So launch LabVIEW and explore the LabVIEW environment as you read this section. 1.3.1 Starting LabVIEW . If your version of LabVIEW was installed using the default installation procedure, launch LabVIEW by selecting All Programs National Instruments LabVIEW 2013 (or LabVIEW 2014) LabVIEW 2013 (or LabVIEW 2014) from the Start menu .

DAQ device/hardware 3. Driver software 4. Your software application (Application software) NI DAQmx Driver Your App created with LabVIEW NI TC-01 Thermocouple Device or NI USB 6008 DAQ Device Sensors, etc. Using TC-01 in LabVIEW Hans-Petter Halvorsen, M.Sc. TC-01 Hans-Petter Halvorsen, M.Sc. How-To use TC -01 with LabVIEW USB

Labview Exercises for Labview 7.0 Installation of Labview: 1. Install the Labview 7.0 software and drivers onto your computer. These files can be found by mapping a network drive to \\poohbah\labview, and by running the ‗autorun‘ file in the ‗Labview 7‘ folder. The serial num

This Tutorial shows how we can use Arduino in combination with the LabVIEW Programming environment “LabVIEW LINX Toolkit” is an add-on for LabVIEW which makes it possible to program the Arduino device using LabVIEW In that way we can create Data Logging Appli

in LabVIEW Object-Oriented Design & Programming in LabVIEW LabVIEW Learning Path LabVIEW Core 1 LabVIEW Getting Started LabVIEW LabVIEW Core 3 Core 2. Student Guide x ni.com C.What You Need to Get Started Befor

Sound and Vibration Measurement Suite Sound and Vibration Toolkit LabVIEW Internet Toolkit LabVIEW Advanced Signal Processing Toolkit . LabVIEW Report Generation Toolkit for Microsoft Office LabVIEW Database Connectivity Toolkit LabVIEW DataFinder Toolkit LabVIEW S

Bharat Law House Pvt. Ltd. 02 14 Taxmann Publications (P) Ltd. Taxmann’s Wealth-Tax Act, Securities Translation Tax & Banking Transaction Tax 10692-10694 Taxmann 03 15 Mathura, M S et al. Compilation of the Maharashtra Value Added Tax Act, 2002 10695-10697 Maharashtra Sales Tax VAT News 03 Drafting, Pleadings & Conveyancing Sr. No. Author Title Acc. No. Publisher Total No. of Copies 1 Sen, B .