0% found this document useful (0 votes)
547 views

Lab View Core 1 Course Manual

Lab View Core 1 Course Manual Manual Instrumentatie Virtuala

Uploaded by

Beatrice Secosan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
547 views

Lab View Core 1 Course Manual

Lab View Core 1 Course Manual Manual Instrumentatie Virtuala

Uploaded by

Beatrice Secosan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 162
5 i a ee ee ee oe oe oe ee oe oe oe | LabVIEW™ Core 1 Course Manual Course Software Version 2010 August 2010 Edition Part Number 325290B-01 Copyright ‘© 1993-2010 National Instruments Corporation. llrightsreserved. Under the copyright las, this publication may not be reproduced or transmitted in any form, electranic or mechanical, including Photocopying, recording, storing in an information retrieval system, or translating, in whole ar in part, without the prior writen consent of National Instruments Corporation National Instruments respects the intellectual property of others, and we ask our users todo the same. NI software is protected by Copyright and other intellectual property laws. Where NI software may be used to reproduce software or other materials belonging to ‘others, you may use NI software ony to reproduce materials that you may reproduce in accordance withthe terms of any applicable licanse or other legal restriction. For components used in USI (Xerces G++, ICU, HDFS, 064, Stingray, and STLpon), the following copyright stipulations apply. For a listing ofthe conditions and disclaimers, refer to either the usECopy=ights . chim or the Copyrights topic in your software Xerces C++. Tis product includes software that was developed by the Apache Software Foundation (nt tp: www. apache .org/). Copyright 1999 The Apache Software Foundation, Al rights reserved, ICU. Copyright 1995-2008 Intemational Business Machines Corporation and others, Al rights reserved, HDF. NCSA HOFS (Hierarchical Data Format §) Software Library and Utilities Copyright 1998, 1999, 2000, 2001, 2003 by the Board of Trustees ofthe University of Ilinols. Alright reserved. ‘664, Copyright © 2004-2006, Matthew Wilson and Synesis Software. All Rights Reserved. ‘Stingray. This software includes Stingray software developed by the Rogue Wave Software division of Quovads, inc Copyright 1995-2006, Quovadx, Inc.All Rights Reserved, STLport. Copyright 1999-2003 Boris Fomitcnev ‘Trademarks CVI, LabVIEW, Nationa Instruments, NI i.com, the National Instruments corporate logo, and the Eagle logo are trademarks of National Instruments Corporation. Refer tothe Trademark Information at ni. com/ trademarks for other National Instruments trademarks, The mark LabWindows is used under a license from Microsoft Corporation. Windows isa registered trademark of Microsoft Corporation inthe United States and other countries. Other product and company names mentioned herein are trademarks or rade names of ther respective companies. "Members ofthe National Instruments Aliance Partner Program are business entities independent from National Instruments and have ‘no agency, partnership, or joint-venture relationship with National Instruments Patents For patents covering National Instruments productsAechnology, refer tothe appropriate location: Help»Patents in your software, the patents. txt file on your media, or the National Instruments Patent Notice at ni .com/patents. Worldwide Technical Suppor and Product Intormation National instruments Corporate Headquarters 1500 North Mopac Expressway Austin, Texas 78759-3504 USA Tel: 512 683 0100 Worldwide Offices Australia 1800 300 800, Aust 43662 4579900, Belgium 32 (0) 2787 0020 Brazil $5 113262 3599, Canada 800433 348, hina 86 21 5050 9800, Czech Republic 420 24 235 775, Denmark 45 45 6 2600, Finland 388 (0) 9728 72511, France 01 $7 66 24 24, Germany 49 89 7413130, India 91 80 41190000, Israel 972 3 6393737, Htaly 39 02 4130927 Japan 0120827196, Korea 8202 451 3400, Lebanon 96 (0) 13828 28, Malaysia 100887710 Mexico O80 0100793, Netherlands 31 (0) 348 433466, New Zealand O800 $53 322, Norway 47 (0) 6690 76 60, Poland 4822 328 9010, Portugal 351 210 311 210, Russia 7495 783 6851, Singapore 1800 2265886, Slovenia 3863425 4200, ‘South Africa 27.0 11 805 8197. Spain 3491 640 0085, Sweden 46 (0) 8 587 895 00, Switzerland 41 56 2005151 Taiwan $86 02 2377 2209, Thailand 662 2786777, Turkey 90 212 2793031, United Kingdom 44 (0) 1638 823548 For further support information, refer tothe Additional Information and Resources appendix. To comment on National Instruments ‘documentation, refer to the National Insiruments Web site at ni .com/info and enter the Info Code feedback. Contents Student Guide NI Certification... Course Description a What You Need to Get Started ee eer Installing the Course Software Course Goals... i Course Convention: 7 - seveseooene Xd ™moOnD> Lesson 1 Setting Up Hardware DAQ Hardware... Using DAQ Software Instrument Contra... GPIB Serial Port Communication... Using Instrument Control Software Course Project... 1-12 soe LH12 114 ommonm> Lesson 2 Navigating LabVIEW Virtual Instruments (VIs).. Parts of a VI Starting a V! Project Explorer. Front Panel... Block Diagram Searching for Controls, VIs and Functions... Selecting a Tool... Dataflow. Building a Simple VI rrmommoomD> Lesson 3 Troubleshooting and Debugging Vis LabVIEW Help Utilities... Correcting Broken VIs.. Debugging Techniques Undefined or Unexpected Dat: Error Checking and Error Handlin; MOO D> (© National instruments Corporation i LabVIEW Core 1 Course Manual ‘contents Lesson 4 Implementing a VI Lesson 5 Relating Data A. Arrays... TROMmOO RD C. Type Definitions Front Panel Design. LabVIEW Data Type: Documenting Code While Loops.. For Loops. Timing a VI. Iterative Data Transfer Plotting Data...... Case Structures .. B. Clusters Lesson 6 Managing Resources Understanding File VO... Understanding High-Level File /O. Understanding Low-Level File 1/0. DAQ Programming... Instrument Control Programmin Using Instrument Drivers. ™mOOR> Lesson 7 Developing Modular Applications ‘A. Understanding Modularity 2.0 1-2 B. Building the Icon and Connector Pane . Td 19 C. Using SubVIs.... Lesson 8 Common Design Techniques and Patterns ‘A. Using Sequential Programming... B. Using State Programming. Si Machine: D. Using Parallelism LabVIEW Core 1 Course Manual wv ricom AARAAA AAP RRA ALS 8 8 8 VPUUVUVIEEUUUVUEUEEDBEUKES Contents Lesson 9 Using Variables A. Parallelism... B. Variables..... C. Functional Global Variables D. Race Conditions... 9-2 9-4 9-14 9-17 Appendix A Measurement Fundamentals A. Using Computer-Based Measurement Systems A2 B. Understanding Measurement Concepts wd C. Increasing Measurement Quality A-12 Appendix B Additional Information and Resources Glossary Index © Nationa Irstruments Corporation ’ LabVIEW Core 1 Course Marual ‘9 G©CGCGCHEHGKEHEUEREUVHOUHKTUUVUHTUUUUEY Student Guide ‘Thank you for purchasing the LabVIEW Core I course kit. You can begin developing an application soon after you complete this course. This course manual and the accompanying software are used in the three-day, hands-on LabVIEW Core I course. You can apply the full purchase of this course kit toward the corresponding course registration fee if you register within 90 days of purchasing the kit. Visit ni .com/training for online course schedules, syllabi, training centers, and class registration, A. NI Certification ‘The LabVIEW Core 1 course is part of a series of courses designed to build your proficiency with LabVIEW and help you prepare for NI LabVIEW Associate Developer exam. The following illustration shows the courses that are part of the LabVIEW training series. Refer to ni .com/training for more information about NI Certi Now User Experienced User ‘Advanced User Courses LabVIEW Core 1° ‘Managing Sotware LabVIEW Core 2° Engineering in LabVIEW LabVIEW 00? System Design| ‘Advanced Architectures in LabVIEW Certtications Other Courses LabVIEW Instrument Control LabVIEW FPGA LabVIEW Connectivity LabVIEW Machine Vision Modular instruments Series LabVIEW Performance LabVIEW Real-Time LabVIEW DAQ and Signal Consitioning “cove courses ae tong recommend to realize maximum product gains when using LabVIEW, (© Nationa Instruments Corporation vi LabVIEW Core 1 Course Manual Student Guide B. Course Description The LabVIEW Core I course teaches you programming concepts, techniques, features, VIs, and functions you can use to create test and measurement, data acquisition, instrument control, datalogging, measurement analysis, and report generation applications. This course manual assumes that you are familiar with Windows and that you have experience writing algorithms in the form of flowcharts or block diagrams. The course and exercise manuals are divided into lessons, described as follows. In the course manual, each lesson consists of the following: * An introduction that describes the purpose of the lesson and what you will learn + A description of the topics in the lesson + A summary quiz that tests and reinforces important concepts and skills taught in the lesson In the exercise manual, each lesson consists of the following: + Asset of exercises to reinforce those topics + Some lessons include optional and challenge exercise sections or a set of additional exercises to complete if time permits BZ Note For course and exercise manual updates and corrections, refer to ni .com/info and enter the Info Code Core. {LaDVIEW Gore 1 Course Manual Several exercises use one of the following National Instruments hardware products + A plug-in multifunction data acquisition (DAQ) device connected to a DAQ Signal Accessory or BNC-2120 containing a temperature sensor, function generator, and LEDs + A GPIB interface connected to an NI Instrument Simulator If you do not have this hardware, you still can complete the exercises. Alternate instructions are provided for completing the exercises without hardware. Exercises that explicitly require hardware are indicated with an icon, shown at left. You also can substitute other hardware for those previously mentioned, For example, you can use a GPIB instrument in place of the NI Instrument Simulator, or another National Instruments DAQ device connected to a signal source, such as a function generator. LPR PPAPRPAMRPROPHAOHRRARARARK AR K1 Sereeceeceeueeee eee eeuvueddy Student Guide C. What You Need to Get Started Suggested Reading Course Materials The suggested reading material ensure that all students have a minimum knowledge of key theories and concepts related to the LabVIEW Core I course. To get the most out of this course, complete all the suggested reading material prior to the first day of class. To access cach of the following suggested reading materials, refer to nfo and enter the Info Code that corresponds to each topic: ni.com/ Q1 LabVIEW Core | - The Software Development Method (Info Code: so£tDev) Q Introduction to Data Acquisition (Info Code: DAQ) Q. GPIB Instrument Control Tutorial (Info Code: GPIB) Serial Communication Overview (Info Code: seria1) Before you use this course manual, ensure you have all the following items: Q Windows XP or later installed on your computer. The course is optimized for Windows XP. Multifunction DAQ device configured as Dev1 using Measurement & Automation Explorer (MAX) DAQ Signal Accessory or BNC-2120, wires, and cable GPIB interface NI Instrument Simulator and power supply LabVIEW Full or Professional Development System 2010 or later DAQmx 9.1.5 or later NI-488.2 2.7.3 or later GO 0 0 ooo A serial cable o A GPIB cable (© National instruments Corporation a LabVIEW Gore 1 Course Manual Student Guide Q LabVIEW Core | course CD, which installs the following folders: Folder Name Description Exercises Folder for saving Vis created during the course and for completing certain course exercises; also includes subVIs necessary for some exercises and zip file (nidevsim. zip) containing the LabVIEW instrument driver for the NI Instrument Simulator Solutions Folder containing the solutions to all the course exercises D. Installing the Course Software Complete the followi ing steps to install the course software. 1, Insert the course CD in your computer. 2. Install the Exercises and Solutions files to the desired location. BZ Note Folder names in angle brackets, such as , refer to folders on the root directory of your computer. LabVIEW Core 1 Course Manual x com PRPAPPPPRFAfiffAsggsgsss Ce ee oe ee E. Course Goals Student Guide This course prepares you to do the following: Understand front panels, block diagrams, icons, and connector panes Use the programming structures and data types that exist in LabVIEW Use various editing and debugging techniques Create and save VIs so you can use them as subVIs Display and log data Create applications that use plug-in DAQ devices Create applications that use serial port and GPIB instruments This course does not describe the following: (© Nationa! instruments Corporation Every built-in VI, function, or object; refer to the LabVIEW Help for more information about Lab VIEW features not described in this course Analog-to-digital (A/D) theory Operation of the serial port Operation of the GPIB bus Developing an instrument driver Developing a complete application for any student in the class; refer to the NI Example Finder, available by selecting Help»Find Examples, for example VIs you can use and incorporate into VIs you create ” LabVIEW Gore 1 Course Manual Student uae F. Course Conventions g bas italic monospace monospace bold Platform LabVIEW Gore 1 Course Manuat ‘The following conventions appear in this course manual: The » symbol leads you through nested menu items and dialog box options to a final action. The sequence Tools»Instrumentation»Find Instrument Drivers directs you to drop down the Tools menu, select the Instrumentation item, and finally select the Find Instrument Drivers option. This icon denotes a tip, which alerts you to advisory information. This icon denotes a note, which alerts you to important information, This icon denotes a caution, which advises you of precautions to take to avoid injury, data loss, or a system crash. This icon indicates that an exercise requires a plug-in GPIB interface or DAQ device. Bold text denotes items that you must select or click in the software, such as menu items and dialog box options. Bold text also denotes parameter names, controls and buttons on the front panel, dialog boxes, sections of dialog boxes, menu names, and palette names. Italic text denotes variables, emphasis, a cross-reference, or an introduction toakey concept. Italic text also denotes text that is a placeholder for a word or value that you must supply. Text in this font denotes text or characters that you enter from the keyboard, sections of code, programming examples, and syntax examples. This font also is used for the proper names of disk drives, paths, directories, programs, subprograms, subroutines, device names, functions, operations, variables filenames, and extensions. Text in this font denotes the messages and responses that the computer automatically prints to the screen, This font also emphasizes lines of code that are different from the other examples. Text in this font denotes a specific platform and indicates that the text following it applies only to that platform. ee ee ee ee ee es ee | Setting Up Hardware Topics LabVIEW is a graphical programming environment used by engineers and scientists to develop sophisticated measurement, test, and control systems. LabVIEW can integrate with a wide variety of hardware devices. In this course, you will interact with DAQ, GPIB, and serial hardware. This lesson describes the basics of DAQ, GPIB, and serial hardware and the configuration of hardware in the Measurement & Automation Explorer. DAQ Hardware Using DAQ Software Instrument Control GPIB Serial Port Communication Using Instrument Control Software azmoam> Course Project (© Nationa instruments Gerporation a] LabVIEW Core 1 Course Manual Lesson 1 ‘Setting Up Hardware A. DAQ Hardware {LABVIEW Core 1 Course Manual ‘A data acquisition (DAQ) system uses a data acquisition device to pass a conditioned electrical signal to a computer for software analysis and data logging. You can choose a data acquisition device that uses a PCI bus, a PCI Express bus, a PXI bus, or the computer USB or IEEE 1394 port. This section explains the hardware used in a data acquisition system and how to configure the devices. A typical DAQ system has three basic types of hardware —a terminal block, acable, and a DAQ device, as shown in Figure 1-1. ® = |= — pe pe 4 ena im E Pog ©» SX 2 1 Signal 4 DAQ Device 2. Terminal Block 5 Computer 3. Cable Figure 1-1. Typical DAQ System After you have converted a physical phenomenon into a measurable signal with or without signal conditioning, you need to acquire that signal. To acquire a signal, you need a terminal block, a cable, a DAQ device, and a computer. This hardware combination can transform a standard computer into a measurement and automation system. 12 icon PUUEEEBKEEEKEUNHDEUEEEUUETe Lesson Setting Up Hardware Using a Terminal Block and Cable A terminal block provides a place to connect signals. It consists of screw or spring terminals for connecting signals and a connector for attaching a cable to connect the terminal block to a DAQ device. Terminal blocks have 100, 68, or 50 terminals. The type of terminal block you should choose depends on two factors—the device and the number of signals you are measuring. A terminal block with 68 terminals offers more ground terminals to connect a signal to than a terminal block with 50 terminals. Having more ground terminals prevents the need to overlap wires to reach a ground terminal, which can cause interference between the signals. Terminal blocks can be shielded or non-shielded. Shielded terminal blocks offer better protection against noise. Some terminal blocks contain extra features, such as cold-junction compensation, that are necessary to properly measure a thermocouple. A cable transports the signal from the terminal block to the DAQ device. Cables come in 100-, 68-, and 50-pin configurations. Choose a configuration depending on the terminal block and the DAQ device you are using. Cables, like terminal blocks, are shielded or non-shielded. Refer to the DAQ section of the National Instruments catalog or to ni. com/ products for more information about specific types of terminal blocks and cables, (© Nationa Instruments Corporation 19 {LADVIEW Core 1 Course Manval Lesson 1 Sting Up Hardware DAQ Signal Accessory Figure 1-2 shows the DAQ Signal Accessory, one of the terminal blocks you can use for this course. Quscratue A Encoder 8/1. Relay 0105 ‘200mA Max 4 =| : oH z = 28 Puleosrey g : 3 ag joj— 5 2 2 omtarTocee [rani |o|— t g| ie Digital Port m o}— 7 g & e000 [| °o- s 3 é 321 0 ag fol 3 2 g Frequency Frequonoy "Counts g ee a een) 2, 00H eH ow ‘Analog Analog Function "Temp Sensor Gute In Goneratoe Noise eRe on( HH on Tomp Figure 1-2. DAQ Signal Accessory The DAQ Signal Accessory is a customized terminal block designed for learning purposes. It has three different cable connectors to accommodate many different DAQ devices and spring terminals to connect signals. You can access three analog input channels, one of which is connected to the temperature sensor, and two analog output channels. The DAQ Signal Accessory includes a function generator with a switch to select the frequency range of the signal, and a frequency knob. The function generator can produce a sine wave or a square wave. A connection to ground is located between the sine wave and square wave terminal. LABVIEW Core 1 Course Manual re] i.com SeeoeCeeeeevueveeeeueesee ede Lesson 1 Setting Up Hardware A digital trigger button produces a TTL pulse for triggering analog input or output. When you press the trigger button, the signal goes from +5 V 100 V and returns to +5 V when you release the button. Four LEDs connect to the first four digital lines on the DAQ device. The LEDs use reverse logic, so when the digital line is high, the LED is off and vice versa. The DAQ Signal Accessory has a quadrature encoder that produces two pulse trains when you tun the encoder knob. Terminals are provided for the input and output signals of two counters on the DAQ device. The DAQ Signal Accessory also has a relay, a thermocouple input, and a microphone jack. BNC-2120 Figure 1-3 shows the BNC-2120, which has similar features as the DAQ Signal Accessory and can also be used to complete the exercises in this course. (© National nsruments Corporation 18 LabVIEW Core 1 Course Manual waa TNs ZA ancond +—@) @ [ @ BS @ L +e aS BS ES 9 = AS f= Bs ~@ BS Ge Bs ae Bs Re 1 RES/BNC Switch (Al 3) 13 Sine/Triangle Waveform Switch 2 Resistor Measurement Screw Terminals. 14 Frequency Adjust Knob & Thermocouple input Connector 18 ampltude Aust Knob 4 Temperature Reference 16 Digital /O Screw Terminals 5 BNC/Temp. Ref. Switch (Al 0) 17 Digital VO LEDs 6 BNC/Thermocouple Switch (Al 1) 18 User-Defined Screw Terminals 7 Analog Input BNC Connectors 19 User-Defined BNC Connectors 8 FS/GS Switches 20 Timing VO Screw Terminals 9 Analog Output BNC Connector 21 Quadrature Encoder Screw Terminals 10 Frequency Range Selection Switch 22 Quadrature Encoder Knob 11 SinorTnangle BNC Connector 23 Timing 1 BNO Connector 12 TTL Square Wave BNC Connector 24 Power Indicator LED {LABVIEW Core 1 Course Manual Figure 1-3, BNC-2120 sicom . eo ee eo re iY Lesson 1 Setting Up Hardware Using DAQ Devices Analog Input Most DAQ devices have four standard elements—analog input, analog output, digital /O, and counters. You can transfer the signal you measure with the DAQ device to the computer through a variety of different bus structures. For example, you can use a DAQ device that plugs into the PCI or PCI Express bus of a computer, a DAQ device connected to the PCMCIA socket of a laptop, or a DAQ. device connected to the USB port of a computer. You also can use PX1/CompactPCI to create a portable, versatile, and rugged measurement system, If you do not have a DAQ device, you can simulate one in Measurement & Automation Explorer (MAX) to complete your software testing. You lea to simulate a device in the Simulating a DAQ Device section of this lesson. Refer to the DAQ section of the NI catalog or to ni. com/products for more information about specific types of DAQ devices. Analog input is the process of measuring an analog signal and transferring the measurement to a computer for analysis, display or storage. An analog signal is a signal that varies continuously. Analog input is most commonly used to measure voltage or current. You can use many types of devices to perform analog input, such as multifunction DAQ (MIO) devices, high-speed digitizers, digital multimeters (DMMs) and Dynamic Signal Acquisition (DSA) devices. Acquiring an analog signal with a computer requires a process known as analog-to-digital conversion, which takes an electrical signal and translates it into digital data so that a computer can process it. Analog-to-digital converters (ADCs) are circuit components that convert a voltage level into a series of ones and zeroes ADCs sample the analog signal on each rising or falling edge of a sample clock. In each cycle, the ADC takes a snapshot of the analog signal, so that the signal can be measured and converted into a digital value. A sample clock controls the rate at which samples of the input signal are taken. Because the incoming, or unknown signal is a real world signal with infinite precision, the ADC approximates the signal with fixed precision. After the ADC obtains this approximation, the approximation can be converted to a series of digital values. Some conversion methods do not require this step, because the conversion generates a digital value directly as the ADC reaches the approximation. (© Nationa instruments Corporation 7 LabVIEW Core 1 Course Manual Lesson 1 Setting Up Hardware Analog Output Analog output is the process of generating electrical signals from your computer. Analog output is generated by performing digital-to-analog (D/A) conversions. The available analog output types for a task are voltage and current. To perform a voltage or current task, a compatible device must be installed that can generate that form of signal Digital-to-analog conversion is the opposite of analog-to-digital conversion. In digital-to-analog conversion, the computer generates the data. The data might have been acquired earlier using analog input or may have been generated by software on the computer. A digital-to-analog converter (DAC) accepts this data and uses it to vary the voltage on an output pin over time, ‘The DAC generates an analog signal that the DAC can send to other devices or circuits A DAC hasan update clock that tells the DAC when to generate a new value. ‘The function of the update clock is similar to the function of the sample clock for an ADC. At each cycle the clock, the DAC converts a digital value to an analog voltage and creates an output as a voltage on a pin, When used with a high speed clock, the DAC can create a signal that appears to vary constantly and smoothly. Digital /0 Digital signals are electrical signals that transfer digital data over a wire. These signals typically have only two states—on and off, also known as high and low, or 1 and 0. When sending a digital signal across a wire, the sender applies a voltage to the wire and the receiver uses the voltage level to determine the value being sent. The voltage ranges for each digital value depend on the voltage level standard being used. Digital signals have many uses; the simplest application of a digital signal is controlling or measuring digital or finite state devices such as switches and LEDs. Digital signals also can transfer data; you can use them to program devices or communicate between devices. In addition, you can use digital signals as clocks or triggers to control or synchronize other measurements. You can use the digital lines in a DAQ device to acquire a digital value. This, acquisition is based on software timing. On some devices, you can configure the lines individually to either measure or generate digital samples. Each line corresponds to a channel in the task. ‘You can use the digital port(s) in a DAQ device to acquire a digital value from a collection of digital lines, This acquisition is based on software timing. You can configure the ports individually to either measure or generate digital samples. Each port corresponds to a channel in the task. LabVIEW Core 1 Course Manual 18 icon PeeeeneeeeeueueneeeueeCeuEEE SE Counters Lesson 1 Setting Up Haraware A counter is a digital timing device. You typically use counters for event counting, frequency measurement, period measurement, position measurement, and pulse generation. When you configure a counter for simple event counting, the counter increments when an active edge is received on the source. In order for the counter to increment on an active edge, the counter must be armed or started. A counter has a fixed number it can count to as determined by the resolution of the counter. For example, a 24-bit counter can count to: ‘2¢Counter Resolution 24 — | = 16,777,215 When a 24-bit counter reaches the value of 16,777,215, it has reached the terminal count. The next active edge forces the counter to roll over and start, at 0. B. Using DAQ Software Using NI-DAQ National Instruments data acquisition devices have a driver engine that communicates between the device and the application software. There are two different driver engines to choose from: NI-DAQmx and Traditional NI-DAQ. You can use LabVIEW to communicate with these driver engines. In addition, you can use MAX to configure your data acquisition devices. In this section, you learn about the driver engines and about using MAX to configure your data acquisition device. NI-DAQ 7.x contains two NI-DAQ drivers—Traditional NI-DAQ (Legacy) and NI-DAQmx—each with its own application programming interface (API, hardware configuration, and software configuration. NI-DAQ 8.0 and later come with only NI-DAQmx, the replacement for Traditional NI-DAQ (Legacy). ‘+ Traditional NI-DAQ (Legacy) is an upgrade to NI-DAQ 6.9.x, the earlier version of NI-DAQ. Traditional NI-DAQ (Legacy) has the same VIs and functions and works the same way as NI-DAQ 6.9.x. You can use Traditional NI-DAQ (Legacy) on the same computer as NI-DAQmx, which you cannot do with NI-DAQ 6.9.x. However, you cannot use Traditional NI-DAQ (Legacy) on Windows Vista + NEDAQmx is the latest NI-DAQ driver with new Vis, functions, and development tools for controlling measurement devices. The advantages of NI-DAQmx over previous versions of NI-DAQ include the DAQ Assistant for configuring channels and measurement tasks for a device: increased performance, including faster single-point analog /O and (© National instruments Corporation 19 LabVIEW Core 1 Course Manual Lesson 1 Setting Up Hardware multithreading; and a simpler API for creating DAQ applications using fewer functions and Vis than earlier versions of NI-DAQ. EY Note (Windows) LabVIEW supports NI-DAQmx and the DAQ Assistant. (Mac 0S) LabVIEW supports NI-DAQmx Base but not the DAQ Assistant, (Linux) Lab VIEW supports NI-DAQmx but not the DAQ Assistant, Traditional NI-DAQ (Legacy) and NI-DAQmx support different sets of devices. Refer to Data Acquisition (DAQ) Hardware on the National Instruments Web site for the list of supported devices DAQ Hardware Configuration LabVIEW Core # Course Manual Before using a data acquisition device, you must confirm that the software can communicate with the device by configuring the devices. The devices are already configured for the computers in this class. Windows The Windows Configuration Manager keeps track of all the hardware installed in the computer, including National Instruments DAQ devices. If you have a Plug & Play (PnP) device, such as an E Series MIO device, the Windows Configuration Manager automatically detects and configures the device. If you have a non-PnP device, or legacy device, you must configure the device manually using the Add New Hardware option in the Windows ‘Control Panel. You can verify the Windows Configuration by accessing the Devic Manager. You can see Data Acquisition Devices, which lists all DAQ devices installed in the computer. Double-click a DAQ device to display a dialog box with tabbed pages. The General tab displays overall information regarding the device. The Driver tab specifies the driver version and location for the DAQ device. The Details tab contains additional information about hardware configuration, The Resources tab specifies the system resources to the device such as interrupt levels, DMA, and base address for software-configurable devices. 110 ricom SOUS EREEECRECEEUNTEUIEUeEIEs Lesson} Setting Up Hardware Measurement & Automation Explorer MAX establishes all device and channel configuration parameters. After installing a DAQ device in the computer, you must run this configuration utility. MAX reads the information the Device Manager records in the Windows Registry and assigns a logical device number to each DAQ device. Use the device number to refer to the device in LabVIEW. Access MAX by double-clicking the icon on the desktop or selecting Tools»Measurement & Automation Explorer in LabVIEW. The following window is the primary MAX window. MAX is also the means for SCXI and SCC configuration, National Instruments Measurement & Automation memes Explorer + Qtr ‘What is Measurement & Autom bxplorer? | Secere to your National Instrments products, What do you want to do? Figure 1-4. The Primary MAX Window The device parameters that you can set using the configuration utility depend on the device. MAX saves the logical device number and the configuration parameters in the Windows Registry. The plug and play capability of Windows automatically detects and configures switchless DAQ devices, such as the NI PCI-6024E, when you install a device in the computer. Scales You can configure custom scales for your measurements. This is very useful when working with sensors, It allows you to bring a scaled value into your pplication without having to work directly with the raw values. For example, in this course you use a temperature sensor that represents temperature with a voltage. The conversion equation for the temperature is: Voltage x 100 = Celsius. After a scale is set, you can use it in your application program, providing the temperature value, rather than the voltage. (© National instruments Corporation nt LabVIEW Core 5 Course Manual Lesson 1 Seting Up Hardware Simulating a DAQ Device You can create NI-DAQmex simulated devices in NI-DAQmx 7.4 or later, Using NI-DAQmx simulated devices, you can try NI products in your application without the hardware. When you later acquire the hardware, you can import the NI-DAQmx simulated device configuration to the physical device using the MAX Portable Configuration Wizard. With NI-DAQmx simulated devices, you also can export a physical device configuration onto a system that does not have the physical device installed. Then, using the NI-DAQmx simulated device, you can work on your applications on a portable system and upon returning to the original system, you can easily import your application work. C. Instrument Control D. GPIB When you use a PC to automate a test system, you are not limited to the type of instrument you can control. You can mix and match instruments from various categories. The most common categories of instrument interfaces are GPIB, serial, and modular instruments. Additional types of instruments include image acquisition, motion control, USB, Ethernet, parallel port, NI-CAN, and other devices. When you use PCs to control instruments, you need to understand properties of the instrument, such as the communication protocols to use. Refer to the instrument documentation for information about the properties of an instrument, LABVIEW Core 1 Course Manual ‘The ANSVIEEE Standard 488.1-1987, also known as General Purpose Interface Bus (GPIB), describes a standard interface for communication between instruments and controllers from various vendors. GPIB, or General Purpose Interface Bus, instruments offer test and manufacturing engineers the widest selection of vendors and instruments for general-purpose to specialized vertical market test applications. GPIB instruments are often used as stand-alone benchtop instruments where ‘measurements are taken by hand. You can automate these measurements by using a PC to control the GPIB instruments. IEEE 488.1 contains information about electrical, mechanical, and functional specifications. The ANSI/IEEE Standard 488.2-1992 extends IEEE 488.1 by defining a bus communication protocol, a common set of data codes and formats, and a generic set of common device commands. 142 ricom RRAARAARARRAARARRARARARRAAR AAR VPUUVNI HEU REUEUREHAUREEWYUUDEEUEUE EY Lesson 1 Setting Up Hardware GPIB is a digital, 8-bit parallel communication interface with data transfer rates of 1 Mbyte/s and higher, using a three-wire handshake, The bus supports one system controller, usually a computer, and up to 14 additional instruments. The GPIB protocol categorizes devices as controllers, talkers, or listeners to determine which device has active control of the bus. Each device has a unique GPIB primary address between 0 and 30. The Controller defines the communication links, responds to devices that request service, sends GPIB commands, and passes/receives control of the bus, Controllers instruct Talkers to talk and to place data on the GPIB. You can address only one device at a time to talk. The Controller addresses the Listener to listen and to read data from the GPIB. You can address several devices to listen. Data Transfer Termination Data Transfer Rate BY Note Refer ‘Termination informs listeners that all data has been transferred. You can terminate a GPIB data transfer in the following three ways: * The GPIB includes an End Or Identify (EOI) hardware line that can be asserted with the last data byte. This is the preferred method. + Place a specific end-of-string (EOS) character at the end of the data string itself. Some instruments use this method instead of or in addition to the EOI line assertion. * The listener counts the bytes transferred by handshaking and stops reading when the listener reaches a byte count limit. This method is often a default termination method because the transfer stops on the logical OR of EOI, EOS (if used) in conjunction with the byte count. As aprecaution, the byte count on the listener is often set higher than the expected byte count so as not to miss any samples. To achieve the high data transfer rate that the GPIB was designed for, you must limit the number of devices on the bus and the physical distance between devices. You can obtain faster data rates with HS488 devices and controllers. HS488 is an extension to GPIB that most NI controllers support. to the National Instruments GPIB support Web site at ni .com/support/ gpibsupp . htm for more information about GPIB. (© National instruments Corporation 113) LABVIEW Core 1 Course Manual ‘Lesson 1 Sting Up Haroware E. Serial Port Communication LabVIEW Core t Course Manual Serial communication transmits data between a computer and a peripheral device, such as a programmable instrument or another computer. Serial communication uses a transmitter to send data one bit at a time over a single communication line to a receiver. Use this method when data transfer rates are low or you must transfer data over long distances. Most computers have one or more serial ports, so you do not need any extra hardware other than a cable to connect the instrument to the computer or to connect two computers to each other, 1_AS-232 Instrument 2 _AS-232 Cable 3. Serial Port Figure 1-5. Serial Instrument Example ‘You must specify four parameters for serial communication: the baud rate of the transmission, the number of data bits that encode a character, the sense of the optional parity bit, and the number of stop bits. A character frame packages each transmitted character as a single start bit followed by the data bits. Baud rate is a measure of how fast data moves between instruments that use serial communication. Data bits are transmitted upside down and backwards, which means that inverted logic is used and the order of transmission is from least significant bit (LSB) to most significant bit (MSB). To interpret the data bits in a character frame, you must read from right to left and read 1 for negative voltage and 0 for positive voltage. An optional parity bit follows the data bits in the character frame. The parity bit, if present, also follows inverted logic. This bit is included as a means of error checking. You specify ahead of time for the parity of the transmission to be even or odd. If you choose for the parity to be oda, the parity bit is set in such a way so the number of Is add up to make an odd number among the data bits and the parity bit 14 icom RRA ARARAARARARARAAHRARARAR ee + SPeevueeceeaeeueue ee eg ee : Lesson 1 Seting Up Hardware The last part of a character frame consists of 1, 1.5, or 2 stop bits that are always represented by a negative voltage. If no further characters are transmitted, the line stays in the negative (MARK) condition. The transmission of the next character frame, if any, begins with a start bit of positive (SPACE) voltage. The following figure shows a typical character frame encoding the letter m. Space Mark lie Start Data Party SE tate eit Bis Bi | Bie [EAL ae BitTime Character Frame Figure 1-6. Character Frame for the letter m RS-232 uses only two voltage states, called MARK and SPACE. In such a two-state coding scheme, the baud rate is identical to the maximum number of bits of information, including control bits, that are transmitted per second. MARK is a negative voltage, and SPACE is positive. The previous illustration shows how the idealized signal looks on an oscilloscope. The following is the truth table for RS-232: Signal > +3 V=0 Signal <-3 V=1 ‘The output signal level usually swings between +12 V and —12 V. The dead area between +3 V and -3 V is designed to absorb line noise. AA start bit signals the beginning of each character frame. It isa transition from negative (MARK) to positive (SPACE) voltage. Its duration in seconds is the reciprocal of the baud rate. If the instrument is transmitting at 9,600 baud, the duration of the start bit and each subsequent bit is about 0.104 ms. The entire character frame of eleven bits would be transmitted in about 1.146 ms, Interpreting the data bits for the transmission yields 1101101 (binary) or 6D (hex). An ASCII conversion table shows that this is the letter m. This transmission uses odd parity. There are five ones among the data bits, already an odd number, so the parity bit is set to 0. © Nationa instaments Corporation 145 LabVIEW Core t Course Manuat Lesson 1 Sting Up Hardware Data Transfer Rate You can calculate the maximum transmission rate in characters per second for a given communication setting by dividing the baud rate by the bits per character frame. In the previous example, there are a total of eleven bits per character frame. If the transmission rate is set at 9,600 baud, you get 9,600/1 1 = 872 characters per second, Notice that this is the maximum character transmission rate. The hardware on one end or the other of the serial Link might not be able to reach these rates, for various reasons. Serial Port Standards The following examples are the most common recommended standards of serial port communication: + RS232 (ANSVEIA-232 Standard) is used for many purposes, such as connecting a mouse, printer, or modem. It also is used with industrial instrumentation. Because of improvements in line drivers and cables, applications often increase the performance of RS232 beyond the ance and speed in the standards list. RS232 is limited to point-to-point connections between PC serial ports and devices. + RS422 (AIA RS422A Standard) uses a differential electrical signal as opposed to the unbalanced (single-ended) signals referenced to ground with RS232. Differential transmission, which uses two lines each to transmit and receive signals, results in greater noise immunity and longer transmission distances as compared to RS232. + RS485 (EIA-485 Standard) is a variation of RS422 that allows you to connect up to 32 devices to a single port and define the necessary electrical characteristics to ensure adequate signal voltages under ‘maximum load. With this enhanced multidrop capability, you can create networks of devices connected to a single RS485 serial port. The noise immunity and multidrop capability make RS485 an attractive choice in industrial applications that require many distributed devices networked to a PC or other controller for data collection and other operations. F. Using Instrument Control Software Rote GPIB drivers are a ‘The software architecture for instrument control using LabVIEW is similar to the architecture for DAQ, Instrument interfaces such as GPIB include a set of drivers. Use MAX to configure the interface. drivers are available on the LabVIEW Installer CD-ROM and most GPIB wailable for download at ni .com/support /gpib/versions .htm. ‘Always install the newest version of these drivers unless otherwise instructed in the release notes. LabVIEW Core 1 Course Manual 146 ico AAAARAAAAARARRARAARARKRL SUUUEEEEEEUEEHEEHKEEUUUESE Lesson 1 Setting Up Hardware Use MAX to configure and test the GPIB interface. MAX interacts with the various diagnostic and configuration tools installed with the driver and also with the Windows Registry and Device Manager. The driver-level software is in the form of a DLL and contains all the functions that directly communicate with the GPIB interface. The Instrument /O VIs and functions directly call the driver software. Open MAX by double-clicking the icon on the desktop or by selecting ‘Tools»Measurement & Automation Explorer in LabVIEW. The following example shows a GPIB interface in MAX after clicking the Scan For Instruments button on the toolbar. I GPWO (CLG) “Measurement & Aulomation Explorer | re cat vow Teos Feb neg] Boone Bo Remotes Senter intone aa eine aes 2 MP oenes dives “toe ‘ae ig omni terse ttn i (a Fevunent | © BB Hardware Model ra2R + Ga Nomar owvens swt haber cages | grat syten cert) | Ssouonan | ates Several ettngs | 3 Gisstmre | opinetea om 2 eh toner pny Rates ° + Q tenet Seca Adee c syaen alr a | voTmene renee) sscplra a BA termnaton settings: | sestoacesine Tumomesesiness a a Padre a Sopale SREOL Wen ES on te Weircedseenge rote clea eet EN hen o eT 2 600re)_ |v ‘erected neuen (Granmeno 2 ne Natt sean: 2m an Sarl nce Sate RB Figure 1-7. GPIB interface in Measurement & Automation Explorer (© Nationa! instruments Corporation “7 LaDVIEW Gore 1 Course Marual Lesson 1 Setting Up Hardware Configure the objects listed in MAX by right-clicking each item and selecting an option from the shortcut menu. You learn to use MAX to configure and communicate with a GPIB instrument in an exercise. G. Course Project Inputs Outputs LabVIEW Core 1 Course Manual Throughout this course, the course project illustrates concepts, both as hands-on exercises and as a case study. The project meets the following requirements: 1, Acquires a temperature every half a second 2. Analyzes each temperature to determine if the temperature is too high or too low 3. Alerts the user if there is a danger of heat stroke or freeze 4, Displays the data to the user 5. Logs the data if a warning occurs 6. If the user does not stop the program, the entire process repeats ‘The course project has the following inputs and outputs. * Current Temperature (T) + High Temperature Limit (X) + Low Temperature Limit (Y) + Stop + Warning Levels: Heatstroke Warning, No Warning, Freeze Warning * Current Temperature Display * Data Log File 18 rigom AARARRARAARAAA RAR ARAB Ce ee ee eo ee eo Lesson 1 Setting Up Hardware One state transition diagram, shown in Figure 1-8, is chosen so that all students may follow the same instruction set. This state transition diagram. is chosen because it successfully solves the problem and it has parts that can be effectively used to demonstrate course concepts. However, it may not be the best solution to the problem. a ( titatco A q \ S wasn a 2 (Sy ee Vi baeg and ‘Stop = FALSE Figure 1-8. Project State Transition Diagram (© Nationa Instruments Corporation 149 LabVIEW Core 1 Course Manual Lesson 1 Setting Up Hardware Heatstroke | Warning} as \ LabVIEW Core 1 Course Manual Figure 1-9 shows an example of an alternate state transition diagram. This state transition diagram also solves the problem very effectively. One of the major differences between these two diagrams is how they can be expanded for future functionality. In the state transition diagram in Figure 1-8, you can modify the diagram to include warning states for other physical phenomena, such as wind, pressure, and humidity. In the state transition diagram in Figure 1-9, you can add other layers of temperature warnings. The possible future changes you expect to your program affect which diagram you choose. Time Elapsed = TRUE / — { Time check } Time Elapsed = FALSE vere? \ } TOT (ee) (mn) NA NY Figure 1-9. Project State Transition Diagram Alternate 120 nicom FRRARR ARAFAT RAR RAHA RAR SVCP COSC eeeeeeeeeeesu Self-Review: Quiz lesson 8% ing Up Hardware 1. (© National instruments Corporation You can use the Measurement & Automation Explorer (MAX) to examine, configure, and test your DAQ device and GPIB instruments, a. b. True False Which of the following are benefits of instrument control? a, b, c d Automate processes Save time One platform for multiple tasks Limited to only one type of instrument 124 LabVIEW Core 1 Course Manus) SEUFKKEUEKEEUETEKH UU UEeUuY Lesson 1 Setting Up Hardware Self-Review: Quiz Answers (© Nationa instruments Corporation You can use the Measurement & Automation Explorer (MAX) to examine, configure, and test your DAQ device and GPIB instruments. a. True b. False Which of the following are benefits of instrument control? a, Automate processes b. Save time ¢. One platform for multiple tasks 4d. Limited to only one type of instrument 123 LabVIEW Core f Course Manual SUPRURPUUREEUUUUENUUYUYUUUUU Navigating LabVIEW Topics © This lesson introduces how to navigate the LabVIEW environment. This includes using the menus, toolbars, palettes, tools, help, and common dialog boxes of LabVIEW. You also learn how to run a VI and gain a general understanding of a front panel and block diagram. At the end of this lesson, you create a simple VI that acquires, analyzes, and presents data Virtual Instruments (VIs) Parts of a VI Starting a VI ap> Project Explorer Front Panel Block Diagram Searching for Controls, VIs and Functions ZammS Selecting a Tool Dataflow Building a Simple VI © Nationa instruments Corporation at LabVIEW Core 1 Course Manual Lesson 2 Navigating LabviEW A. Virtual Instruments (Vis) LabVIEW programs are called virtual instruments, or Vis, because their appearance and operation imitate physical instruments, such as oscilloscopes and multimeter. LabVIEW contains a comprehensive set of tools for acquiring, analyzing, displaying, and storing data, as well as tools to help you troubleshoot code you write. B. Parts of a VI LabVIEW Vis contain three main components—the front panel window, the block diagram, and the icon/connector pane Front Panel Window The front panel window is the user interface for the VI. Figure 2-1 shows an example of a front panel window. You create the front panel window with controls and indicators, which are the interactive input and output terminals of the VI, respectively. 1D Using Temperature vi Front Panei Doe Figure 2-1. Vi Front Panel LabVIEW Coe 1 Course Menus! 22 icom OPP PRA PARRA RAAR ARR R RE V"VUuVU VM UUUUVUEUEUUEEEUEUueyueeuue Lesson 2 Navigating Labview Block Diagram Window After you create the front panel window, you add code using graphical representations of functions to control the front panel objects. Figure 2-2 shows an example of a block diagram window. The block diagram window contains this graphical source code. Front panel objects appear as terminals on the block diagram, ive. vi Block Diagram Ee_ER ew Blond Gpeae Tool Winlon Ib Figure 2-2. Block Diagram Icon and Connector Pane The Icon and Connector pane allows you to use and view a VI in another VI. A VI that is used in another VI is called a subVI, which is similar to a function in a text-based programming language. To use a VI as a subVI, it must have an icon and a connector pane. = Every VI displays an icon in the upper right corner of the front panel % window and block diagram window. An example of the default icon is shown at left. An icon is a graphical representation of a VI. The icon can contain both text and images. If you use a VI as a subVI, the icon identifies the subVI on the block diagram of the VI. The default icon contains a ‘number that indicates how many new VIs you opened after launching LabVIEW. q To use a VI as a subVI, you need to build a connector pane, shown at left. A 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. Access the connector pane by right-clicking the icon in the upper right corner of the front panel window. You cannot access the connector pane from the icon in the block diagram window. (© National instruments Corporation 23 LabVIEW Core $ Course Manual Lesson 2 Navigating LabVIEW C. Starting a VI ‘When you launch LabVIEW, the Getting Started window appears. Use this, window to create new Vs and projects, select among the most recently opened LabVIEW files, find examples, and search the LabVIEW Help. You also can access information and resources to help you learn about LabVIEW, such as specific manuals, help topics, and resources at ni .com/ manuals. ‘The Getting Started window closes when you open an existing file or create a new file. You can display the window by selecting View»Getting Started Window. EGoiting Started le Operate ods He Et LabVIEW new Letest roman om aba ae taba acon Bd on tra ane Pera (9) Bre Taio Resouces _ nine Support [kd Weather Station Iyproj ae ee Shing oo Koonce | ah resi ee Supt | weather staton ut ae trom tin tated yh ab AEW Lae ito Aorta restores pra narumen overs LabVIEW Core 1 Course Manual Figure 2-3. LabVIEW Getting Started Window You can configure LabVIEW to open a new, blank VI on launch instead of displaying the window. Select Tools»Options, select Environment from the Category list, and place a checkmark in the Skip Getting Started window on launch checkbox. 24 ‘com BUECKER KEKEKCKEKEKEKEKEEES Lesson 2 Navigating abVIEW FZ Note ‘The items in the Getting Started window vary depending on which version of LabVIEW and which toolkits you install. Creating or Oper 19 a VI or Project You can begin in Lab VIEW by starting from a blank VI or project, opening an existing VI or project and modifying it, or opening a template from which to begin your new VI or project. Creating New Projects and Vis To open a new project from the Getting Started window, select Empty Project in the New list. A new, unnamed project opens, and you can add files to and save the project. To open anew, blank VI that is not associated with a project, select Blank VI in the New list in the Getting Started window. Creating a VI from a Template Select File»New to display the New dialog box, which lists the built-in VI templates. You also can display the New dialog box by clicking the New link in the Getting Started window. Gposenrom be Patani) Srestancasmer Dory Poa) rcejsnecensmen some ei 'S) te Actin ane eee, (© Nationa instruments Corporation 25 LabVIEW Gore 1 Course Manual Lesson 2 Navigating LabViEW Opening an Existing VI Select Browse in the Open list in the Getting Started window to navigate to and open an existing VI. @ Tip. The Vis you edit in this course are located in the \LabVIEW core 1 directory. As the VI loads, a status dialog box similar to the following example might appear. Weather Seton UL Load: towed (chon abvIEW Cove 1\coase Project suparing esate Wares. Figure 2-5. Dialog Box Indicating the Status of Loading Vis The Loading section lists the subVIs of the VIas they load into memory and shows the number of subVIs loaded into memory so far. You can cancel the load at any time by clicking the Stop button. If LabVIEW cannot immediately locate a subVI, it begins searching through all directories specified by the VI search path. You can edit the VI search path by selecting Tools»Options and selecting Paths from the Category list. ‘You can have LabVIEW ignore a subVI by clicking the Ignore Item button, or you can click the Browse button to search for the missing subVI. LaVIEW Gore 1 Course Manual 26 rion AFRARRARARARAARARARARARARAR TR. VUUUUUUUEUUEUVUEUECEKCKEKEEEES Lesson 2 Navigating LabviEW Saving a VI To save a new VI, select File»Save. If you already saved your VI, select File»Save As to access the Save As dialog box. From the Save As dialog box, you can create a copy of the VI, or delete the original VI and replace it with the new one. Save “Weather a | ovina te (C\SohtioLabMEW Cove Ces ProjectWeather Statin ULM © py ony oni =a) © Substate copy for oranat Coors. ool lb co A Unies arterrenafie nenertoaerts tec. (Oreste uapened dk copy ‘rade mney ay wot be comet Open additional copy ‘ath ongnal and copy wlte memory Copy mutt have ne nae, > gg) ae neae e ik A) Upsies a afeencr esa menay to refer to the nen ane, [as ° Duplicate hierarchy to new location GR] ore telstra mt orale Figure 2-6. Save As Dialog Box BZ Note Refer to the Save As Dialog Box topic of the LabVIEW Help for detailed information about each option in the Save As dialog box. (© National instruments Corporation ar LaDWIEW Gore 1 Course Manual BPUUHTHTUUNEUUUUUUUUEUUEUUUs Lesson 2 Navigating LadviEW Saving a VI To save a new VI, select File»Save. If you already saved your VI, select File»Save As to access the Save As dialog box. From the Save As dialog box, you can create a copy of the VI, or delete the original VI and replace it with the new one. [BSc "Weather Station Uv Ae tne (CSL abvEW Cove couse Pojeclieatier Staion UL Copy rate copy ends © Substitute copy fr original Copy wk bein mevory.Crgnal wl be dosed, Ay Uptaesarofrenere ls emamery totter tothe copy. Oreste unopened disk copy ‘ral le neery. Copy wat Be peed 00pm adie copy eth org ec copy wb henry. Copy mt have re ae © gp) Rename-renanete ond Be) tesa cntereng tes never treet nena, ° Duplicate learchy to new location Eg] oy seven retin 6) anon, D> Referencing es nmenary fexres| cer Figure 2-6. Save As Dialog Box BZ Note Refer to the Save As Dialog Box topic of the LabVIEW Help for detailed information about each option in the Save As dialog box. (© National Instruments Corporation 27 LabVIEW Core 1 Course Manual Lesson2 Navigating VIEW D. Project Explorer Use projects to group together LabVIEW files and non-LabVIEW files, create build specifications, and deploy or download files to targets. When you save a project, LabVIEW creates a project file (. lvpro3), which includes references to files in the project, configuration information, build information, deployment information, and so on. You must use a project to build applications and shared libraries. You also must use a project to work with a real-time (RT), field-programmable gate ray (FPGA), or personal digital assistant (PDA) target. Refer to the specific module documentation for more information about using projects with the LabVIEW Real-Time, FPGA, and PDA modules. Project Explorer Window Use the Project Explorer window to create and edit LabVIEW projects. Select File»New Project to display the Project Explorer window. You also can select Project»New Project or select Empty Project in the New dialog box to display the Project Explorer window. ‘The Project Explorer window includes the following items by default: + Project root—Contains all other items in the Project Explorer window. This label on the project root includes the filename for the project. + My Computer—Represents the local computer as a target in the project. + Dependencies—Includes items that VIs under a target require. + Build Specifications—Includes build configurations for source distributions and other types of builds available in LabVIEW toolkits and modules. If you have the LabVIEW Professional Development System or Application Builder installed, you can use Build Specifications to configure stand-alone applications, shared libraries, installers, and zip files. @ Tip A targeris any device that can run a VI. When you add another target to the project, LabVIEW creates an additional item in the Project Explorer window to represent the target. Each target also includes Dependencies and Build Specifications sections. You can add files under each target. LaDVIEW Gore 1 Course Manual 28 ricom AARRA AR ARBRE SER EVETETHEEEEUECUECEEUEES Lesson 2 Navigating LabVIEW Project-Related Toolbars Use the Standard, Project, Build, and Source Control toolbar buttons to perform operations in a LabVIEW project. The toolbars are available at the top of the Project Explorer window, as shown in Figure 2-7. You might need to expand the Project Explorer window to view all of the toolbars. {i icject Explorer Weathed Station ivproj* Be ER ton Dom cpeatd| Toe hd Tb cai [se be | ome TH Peed Weaiersaiskea —<——— = Mcomue | ‘ak Weather ttn ut | Im} etre wares. my Tonperatre Satori 1) Wesher tation states 4 Dependents —— bald spectators ——— ®OOE 1 Standard Toolbar 5 Project Root 2 Project Toolbar 6 Target 3 Build Toolbar 7 Dependencies 4 Source Control Toolbar 8 Build Specifications Figure 2-7. Project Explorer Window Tip The Source Control toolbar is only available if you have source control configured in LabVIEW. You can show or hide toolbars by selecting View»Toolbars and selecting the toolbars you want to show or hide. You can also right-click an open area on the toolbar and select the toolbars you want to show or hide. (© National instruments Corporation 29 {LABVIEW Gore 1 Course Manua} Lesson2 Navigating LabVIEW Creating a LabVIEW Project Adding Existing Fil RY Note After automaticall LabVIEW Core 1 Course Manual Complete the following steps to create a project. 1, Select File»New Project to display the Project Explorer window. You can also select Project»Empty Project in the New dialog box to display the Project Explorer window. 2. Add items you want to include in the project under a target. 3. Select File»Save Project to save the project. jes To A Project You can add existing files to a project. Use the My Computer item (or other target) in the Project Explorer window to add files such as VIs or text files, to a LabVIEW project. You can add items to a project in the following ways: + Right-click My Computer and select Add» File from the shortcut menu toadd a file, You also can select Project»Add To Project»File from the Project Explorer menu to add a file. + Right-click the target and select Add»Folder (Auto-populating) from the shortcut menu to add an auto-populating folder. You also can select Project»Add To Project»Add Folder (Auto-populating) to add an auto-populating folder. LabVIEW continuously monitors and updates the folder according to changes made in the project and on disk + Right-click the target and select Add»Folder (Snapshot) from the shortcut menu to add a virtual folder. You also can select Project»Add To Project»Add Folder (Snapshot) to add a virtual folder. When you select a directory on disk, LabVIEW creates a new virtual folder in the project with the same name as the directory on disk. LabVIEW also creates project items that represent the contents of the entire directory including files and contents of subdirectories. Selecting a folder on disk adds contents of the entire folder, including files and contents of subfolders, you add a virtual folder on disk to a project, LabVIEW does not 'y update the folder in the project if you make changes to the folder on disk. + Right-click the target and select New» VI from the shortcut menu to add anew, blank VI. You also can select File»New VI or Project»Add To Project»New VI to add a new, blank VI. + Select the VI icon in the upper right corer of a front panel or block diagram window and drag the icon to the target. + Select an item or folder from the file system on your computer and drag it to the target. 2.10 scam PODHOR PROP HRHRA RR HRHRHSS evvvuvuvuevvd’esBse vBUuUUEUEUEUUuUuUuT Lesson 2 Navigating LabVIEW Removing Items from a Project ‘You can remove items from the Project Explorer window in the following ways: + Right-click the item you want to remove and select Remove from Project from the shortcut menu. + Select the item you want to remove and press . + Select the item you want to remove and click the Remove From Project button on the Standard toolbar. FY Note Removing an item from a project does not delete the item on disk. ° e > ig Items in a Project ‘The Project Explorer window includes two pages, the Items page and the Files page. The Items page displays the project items as they exist in the project tree. The Files page displays the project items that have a corresponding file on disk. You can organize filenames and folders on this page. Project operations on the Files page both reflect and update the contents on disk. You can switch from one page to the other by right-clicking a folder or item under a target and selecting Show in Items View or Show in Files View from the shortcut menu. Use folders to organize items in the Project Explorer window. You can add two types of folders to a LabVIEW project, virtual folders and auto-populating folders. Virtual folders organize project items. Right-click a target in the Project Explorer and select New» Virtual Folder from the shortcut menu to create a new virtual folder. Auto-populating folders update in real time to reflect the contents of folders on disk. Add an auto-populating folder to the project to view project items as they appear on disk. Auto-populating folders are visible only on the Items page of the Project Explorer window. You can view the disk contents of an auto-populating folder but you cannot perform disk operations such as renaming, reorganizing, and removing project items. To perform disk operations of items in an auto-populating folder, use the Files page of the Project Explorer window. The Files page displays the location of project folders on disk. Project operations on the Files page both update and reflect the contents of the folder on disk. Likewise, LabVIEW automatically updates the auto-populating folder in the project if you make changes to the folder on disk outside of LabVIEW. You can arrange items in a folder. Right-click a folder and select Arrange By»Name from the shortcut menu to arrange items in alphabetical order. Right-click a folder and select Arrange By»Type from the shortcut menu to arrange items by file type. {© Nationa Instruments Corporation 24 LabVIEW Gore 1 Course Manual Lesson 2 Navigating LabVIEW Viewing Files in a Project Saving a Project EY Note Make project. LabVIEW Core 1 Course Manual When you add a file to a LabVIEW project, LabVIEW includes a reference to the file on disk. Right-click a file in the Project Explorer window and select Open from the shortcut menu to open the file in its default editor. Right-click the project and select View»Full Paths from the shortcut menu to view where files that a project references are saved on disk. Use the Project File Information dialog box to view where files that a project references are located on disk and in the Project Explorer window. Select Project»File Information to display the Project File Information dialog box. You also can right-click the project and select Views Information from the shortcut menu to display the Project File Information dialog box. You can save a LabVIEW project in the following ways: + Select File»Save Project + Select Project»Save Project. + Right-click the project and select Save from the shortcut menu, + Click the Save Project button on the Project toolbar. You must save new, unsaved files in a project before you can save the project. When you save a project, LabVIEW does not save dependencies as, part of the project file. a backup copy of a project when you prepare to make major revisions to the 212 icom PBRORARPAARAARAARARRARARARARF ee Lesson2 Navigating LabviEW E. Front Panel ‘When 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. Figure 2-8 shows an example of a front panel window. ->{ 1H Using Temperature viFroni Panel C Te GR lew Bond Gee loos Udon Ib [8] « [My] arvana aa ID, 3 @ Enoess een 0 70 eho 900 100 1 Front Panel Window 2 Toolbar 3 Controls Palette Figure 2-8. Example of a Front Panel Controls and Indicators You create the front panel with controls and indicators, which are the interactive input and output terminals of the VI, respectively. Controls are knobs, push buttons, dials, and other input devices. Indicators are graphs, LEDs and other displays. Controls simulate instrument input devices and supply data to the block diagram of the VI. Indicators simulate instrument output devices and display data the block diagram acquires or generates. Figure 2-8 has the following objects: two controls: Number of Measurements and Delay(sec). It has one indicator: an XY graph named ‘Temperature Graph. ‘The user can change the input value for the Number of Measurements and Delay(sec) controls. The user can see the value generated by the VI on the Temperature Graph indicator, The VI generates the values for the \dicators based on the code created on the block diagram. You learn about this in the Numeric Controls and Indicators section. (© National instruments Corporation 243 LabVIEW Core 1 Course Manual Lesson2 Navigating LabVIEW LabVIEW Gore 1 Course Manual Every control or indicator has a data type associated with it. For example, the Delay(sec) horizontal slide is a numeric data type. The most commonly used data types are numeric, Boolean value and string. You learn about other data types in Lesson 4, Implementing a VI. Numeric Controls and Indicators The numeric data type can represent numbers of various types, such as integer or real. The two common numeric objects are the numeric control and the numeric indicator, as shown in Figure 2-9. Objects such as meters and dials also represent numeric data. 1 Increment/Decrement Buttons 3 Numeric Indicator 2 Numeric Control Figure 2-9. Numeric Controls and Indicators To enter or change values in a numeric control, click the increment and decrement buttons with the Operating tool or double-click the number with either the Labeling tool or the Operating tool, enter a new number, and press the key. Boolean Controls and Indicators The Boolean data type represents data that only has two possible states, such as TRUE and FALSE or ON and OFF. Use Boolean controls and indicators to enter and display Boolean values. Boolean objects simulate switches, push buttons, and LEDs. The vertical toggle switch and the round LED Boolean objects are shown in Figure 2-10. Wesea ogi ioch | awaleo 4 ° Figure 2-10. Boolean Controls and Indicators 246 ricom BPRUEVUEUEVUERPEUUUUEEEEEEUES Lesson? Navigating LabVIEW String Controls and Indicators The string data type is a sequence of ASCII characters. Use string controls to receive text from the user such as a password or user name. Use string indicators to display text to the user. The most common string objects are tables and text entry boxes as shown in Figure 2-11. String Control Receive text rom the user here. ‘String Indicator Display text to the user here. For large amounts of text, adda scral bar Figure 2-11. String Controls and Indicators (© Nationa Instruments Corpration 245 LabVIEW Core 1 Course Manual Lesson 2 Navigating LabVIEW Controls Palette {LabVIEW Coe 1 Course Manuat 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. The Controls palette is broken into various categories; you can expose some or all of these categories to suit your needs. Figure 2-12 shows a Controls palette with all of the categories exposed and the Modern category expanded. During this course, you work exclusively in the Modern category. fol im Siem — sergaFath aa Kd un fale orzl Design &Smtion NET bate Sepa Processna eons sar Contre Sect a Cnt Change le Paks. Figure 2-12. Controls Palette To view or hide categories (subpalettes), select the Customize button on the palette, and select or deselect in the Change Visible Categories option. 246 ico QDOGHRHRHRRHHRKRARRERRARRH Suvyeueeeeeeeeeeeeeeeees Lesson 2 Navigating LabVIEW Shortcut Menus All LabVIEW objects have associated shortcut menus, also known a 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. Figure 2-13 shows a shortcut menu for a meter. ale ems > vate! Fe Teme optn Change ta contre rt ate Descpon and Tp. Sto ero elace Data Operations dvarced Fe Corral to Fare Sele Objet wth are ‘Adapt To Sace Represrtaton eplay Forma core Seale » Testes Figure 2-13. Shortcut Menu for a Meter (© National Instruments Corporation nr {LabVIEW ore 5 Course Manual Property Dialog Boxes Objects in the front panel window also have property dialog boxes that Yo8 can use to change the look or behavior of the objects. Right-click an object snd select Properties from the shortcut menu to access the property dialog box for an object. Figure 2-14 shows the property dialog box for the meter chown in Figure 2-13. The options available on the property dialog box for an object are similar to the options available on the shorteut menu for that object. “epesrance | OataRange | Scale | Farmatandfrecson Text labels Donne Label caption Elvebie vee | vt | led Ste eres mbes Comtode roves an es Dison stdin) | on ‘Shon wereneklderenert BANS sven vou to th Figure 2-14. Property Dialog Box for a Meter You can select multiple objects on the front panel or the block diagrar and edit any properties the objects share. To select multiple objects, use ‘he Positioning tool to drag a selection rectangle around all of the objects you want to edit or hold down the key while clicking each object Right-click an object from the selection and select Properties from the sre ntout menu to display the Properties dialog box. The Properties dialog pox only displays tabs and properties thatthe objects you select share, Select similar objects to display more tabs and properties. Iryou select objects that donot share any common properties, the Properties dialog box does not display any tabs or properties. LaDviEW Core Course Manual 248 VPuvuvuIVVIVTTUVUVVUUEUUEECEUTUe ei Lesson2 Navigating LabVIEW Front Panel Window Toolbar Each window has a toolbar associated with it. Use the front panel window toolbar buttons to run and edit the VI. The following toolbar appears on the front panel window 21a] 6 2] Click the Run button to run a VI. LabVIEW compiles the VI, if necessary. You can run a VI if the Run button appears as a solid white arrow, shown at left. The solid white arrow also indicates you can use the VI as a subVI if you create a connector pane for the VI. 1368 Application Font fg] 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. Ifthe VI that is running is subVI, the Run button appears as shown at left. The Run button appears broken when the VI you are creating or editing contains errors. If the Run button still appears broken after you finish wiring the block diagram, the VI is broken and cannot run, Click this button to play the Error list window, which lists all errors and warnings. His] & Click the Run Continuously button to run the VI until you abort or pause execution. You also can click the button again to disable continuous running, While the VI runs, the Abort Execution button appears. Click this button to stop the VI immediately if there is no other way to stop the VIL If more than one running top-level VI uses the VI, the button is dimmed. > @ fw Caution The Abort Execution button stops the VI immediately, before the VI finishes the current iteration. Aborting a VI that uses external resources, such as external hardware, might leave the resources in an unknown state by not resetting or releasing them properly. Design VIs with a stop button to avoid this problem. in] Click the Pause button to pause a running VI. When you click the Pause button, LabVIEW highlights on the block diagram the location where you paused execution, and the Pause button appears red. Click the Pause button again to continue running the VI. (Deteemainrar Je] Sclect the Text Settings pull-down menu to change the font settings for the selected portions of the VI, including size, style, and color. Select the Align Objects pull-down menu to align objects along axes, including vertical, top edge, left, and so on. (© Nationa Instruments Corporation 219 “LabVIEW Core t Course Manual [3] (e) i Tip The key on the numeric keypad ends a text entry, while the main key adds anew line. To modify this behavior, select Tools»Options, select the Environment from the Category list, and place a checkmark in the End text entry with Enter key option. LabVIEW Core 1 Course Manual 220 nicom Lesson 2 Navigating LabviEW Select the Distribute Objects pull-down menu to space objects evenly, including gaps, compression, and so on. Select the Resize Objects pull-down menu to resize multiple front panel objects to the same size. Select the Reorder pull-down menu when you have objects that overlap each other and you want to define which one is in front or back of another. Select one of the objects with the Positioning tool and then select from Move Forward, Move Backward, Move To Front, and Move To Back. Select the Show Context Help Window button to toggle the display of the Context Help window. Enter Text appears to remind you that a new value is available to replace an old value. The Enter Text button disappears when you click it, press the key, or click the front panel or block diagram workspace. SEFSFVUFEVHHNHUHHUVHKNHUVIOUuUIUd Lesson2 Navigating LabviEW F. Block Diagram Block diagram objects include terminals, subVIs, functions, constants, structures, and wires, which transfer data among other block diagram objects. = $9 additsub vi Front Panel Ge Eh few Bont Operate Toos \iniow He ‘pt Aepiaten Fore ceil) Te or Font Geen GO ae ef W)D eof [sree = : pas a (+f Bo 1 Indicator Terminals 2 Wires ‘3 Nodes 4 Control Terminals Terminals (© National instruments Corparation 221 Figure 2-15. Example of a Block Diagram and Corresponding Front Panel Objects 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 pane! controls and indicators. Data you enter into the front panel controls (a and b in the previous front panel) enter the block diagram through the control terminals, The data then enter the Add and Subtract functions. When the Add and Subtract functions complete their calculations, they produce new data values. The data values flow to the indicator terminals, where they update the front panel indicators (a+b and a-b in the previous front panel). LabVIEW Gore 1 Course Manual Lesson 2 Navigating LabviEW > LabVIEW Core § Course Manual The terminals in Figure 2-15 belong to four front panel controls and indicators. Because terminals represent the inputs and outputs of your VI, subVIs and functions also have terminals shown at left, For example, the connector panes of the Add and Subtract functions have three node terminals. To display the terminals of the function on the block diagram, right-click the function node and select Visible Items»Terminals from the shorteut menu. Controls, Indicators, and Constants Controls, indicators, and constants behave as inputs and outputs of the block diagram algorithm. Consider the implementation of the algorithm for the area of a triangle: Area = .5 * Base * Height In this algorithm, Base and Height are inputs and Area is an output, as shown in Figure 2-16. Figure 2-16. Area of a Triangle Front Panel The user will not change or access the constant .5, so it will not appear on the front panel unless included as documentation of the algorithm. 22 ico Raa Ree RRR eee eee eee ee eee | Lesson 2 Navigating LabVIEW Figure 2-17 shows a possible implementation of this algorithm on a LabVIEW block diagram. This block diagram has four different terminals created by two controls, one constant, and one indicator. Base (cm) — Height cm) | Tanguay Muir cay 7 fe] — f 1 Contos 2 Indicator 3 Constant Figure 2-17. Area of a Triangle Block Diagram with Icon Terminal View Notice that the Base (em) and Height (em) block diagram terminals have a different appearance from the Area (em?) terminal. There are two distinguishing characteristics between a control and an indicator on the block diagram. The first is an arrow on the terminal that indicates the direction of data flow. The controls have arrows showing the data leaving the terminal, whereas the indicator has an arrow showing the data entering the terminal. The second distinguishing characteristic is the border around the terminal. Controls have a thick border and indicators have a thin border. You can view terminals with or without icon view. Figure 2-18 shows the same block diagram without using the icon view of the terminals; however, (Determines the area of atiang. Base (cm) Triangular Mute Height (cm) =e Figure 2-18. Area of a Triangle Block Diagram without Icon Terminal View © Nationa instuments Corporation 228 LabVIEW Core 1 Course Manual Lesson 2 Navigating LabVIEW Block Diagram Nodes LabVIEW Gore 1 Course Manus Nodes 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, or structures, Structures are process control elements, such as Case structures, For Loops, or While Loops. The Add and Subtract functions in the Figure 2-15 are function nodes. 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. SubVis SubVIs are VIs that you create to use inside of another VI or that you access on the Functions palette 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. The upper right corer of the front panel window and block diagram window displays the icon for the VI. This is the icon that appears when you place the VI ona block diagram as a subVI. SubVIs also can be Express VIs. Express Vis are nodes that require minimal wiring because you configure them with dialog boxes, Use Express Vis for common measurement tasks. You can save the configuration of an Express Vlas a subVI. Refer to the Express Vis topic of the LabVIEW Help for more information about creating a subVI from an Express VI configuration LabVIEW uses colored icons to distinguish between Express VIs and other Vis on the block diagram. Icons for Express VIs appear on the block diagram as icons surrounded by a blue field whereas subVI icons have a yellow field. 224 com SPCC eeeeeeeeeeeueueege Lesson 2 Navigating LabVIEW Expandable Nodes versus Icons You can display Vis and Express VIs as icons or as expandable nodes. Expandable nodes appear as icons surrounded by a colored field. SubVIs appear with a yellow field, and Express VIs appear with a blue field. Use icons if you want to conserve space on the block diagram. Use expandable nodes to make wiring easier and to aid in documenting block diagrams. By default, subVIs appear as icons on the block diagram, and Express VIs. appear as expandable nodes. To display a subVI or Express VI as an expandable node, right-click the subVI or Express VI and remove the checkmark next to the View As Icon shortcut menu item You can resize the expandable node to make wiring even easier, but it also takes a large amount of space on the block diagram. Complete the following steps to resize a node on the block diagram: 1. Move the Positioning tool over the node. Resizing handles appear at the top and bottom of the node. 2. Move the cursor over a resizing handle to change the cursor to the resizing cursor. 3. Use the resizing cursor to drag the border of the node down to display additional terminals. 4, Release the mouse button. To cancel a resizing operation, drag the node border past the block diagram window before you release the mouse button. Figure 2-19 shows the Basic Function Generator VI as a resized expandable node. Figure 2-19. Basic Function Generator VI in Different Display Modes (© Nationa Instruments Corporation 225 LabVIEW Gore 1 Course Manuat Lesson 2 Navigating LabVIEW ZB_Note_Iryou display a subVI or Express VI as an expandable node, you cannot display the terminals for that node and you cannot enable database access for that node. Wires ig ‘You transfer data among block diagram objects through Figure 2-15, 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. A broken wire appears as a dashed black line with a red X in the middle, as shown at left. Broken wires occur for a variety of reasons, such as when you try to wire two objects with incompatible data types. Table 2-1 shows the most common wire types. Table 2-1. Common Wire Types Scalar 1D Array 2D Array Color Numeric — Orange (floating-point), Blue (integer) Boolean an mmm — | Green String weoreen ‘enenoneone revevooven | Pink LabVIEW Core 5 Course Manual In LabVIEW, you use wires to connect multiple terminals together to pass data in a VI. You must connect the wires to inputs and outputs that are compatible with the data that is transferred with the wire. For example, you cannot wire an array output to a numeric input. In addition the direction of the wires must be correct. You must connect the wires to only one input and at least one output, For example, you cannot wire two indicators together. ‘The components that determine wiring compatibility include the data type of the control and/or the indicator and the data type of the terminal. Data Types Data types indicate what objects, inputs, and outputs you can wire together. For example, if a switch has a green border, you can wire a switch to any input with a green label on an Express VI. If a knob has an orange border, you can wire a knob to any input with an orange label. However, you cannot wire an orange knob to an input with a green label. Notice the wires are the same color as the terminal. 2.26 icom AAR ARR RR ARR ARR ARR ARR AR SOCeeeeeeeeee ee eeee ee es Functions Palette Lesson2 Navigating Labview Automatically Wiring Objects As you move a selected object close to other objects on the block diagram, LabVIEW draws temporary wires to show you valid connections. When you release the mouse button to place the object on the block diagram, LabVIEW automatically connects the wires. You also can automatically wire objects already on the block diagram, LabVIEW connects the terminals that best match and does not connect the terminals that do not match. Toggle automatic wiring by pressing the spacebar while you move an object using the Positioning tool. By default, automatic wiring is enabled when you select an object from the Functions palette or when you copy an object already on the block diagram by pressing the key and dragging the object. Automatic wiring is disabled by default when you use the Positioning tool to move an object already on the block diagram. You can adjust the automatic wiring settings by selecting Tools»Options and selecting Block Diagram from the Category list. Manually Wiring Objects When you pass the Wiring tool over a terminal, a tip strip appears with the name of the terminal. In addition, the terminal blinks in the Context Help window and on the icon to help you verify that you are wiring to the correct terminal. To wire objects together, pass the Wiring tool over the first terminal, click, pass the cursor over the second terminal, and click again. After wiring, you can right-click the wire and select Clean Up Wire from the shortcut menu to have LabVIEW automatically choose a path for the wire. If you have broken wires to remove, press to delete all the broken wires on the block diagram, ‘The 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. Figure 2-20 shows a Funetions palette with all of the categories ‘exposed and the Programming category expanded. During this course, you work mostly in the Programming category, but you also use other categories, or subpalettes. (© National instruments Corporation par LABVIEW Core 1 Course Manual Lesson2 Navigating LabVIEW Gal a Instrument 0 Vision and Motion —_ Mathematics ‘Signal Processing ‘Data Communication tivity Design & Simulation Express ‘Addons > Favorites| User ibraies |) Select a ML. Figure 2-20. Functions Palette To view or hide categories, click the Customize button on the palette, and select or deselect the Change Visible Palettes option. Block Diagram Toolbar When you run a VI, buttons appear on the block diagram toolbar that you can use to debug the VI. The following toolbar appears on the block diagram. >[e] oN Pa Click the Highlight Execution button to display an animation of the block diagram execution when you run the VI. Notice the flow of data through the block diagram. Click the button again to disable execution highlighting. (e[balP ios Tam Appicabon Font J Click the Retain Wire Values button to save the wire values at each point in the flow of execution so that when you place a probe on the wire you can immediately retain the most recent value of the data that passed through the wire. You must successfully run the VI at least once before you can retain the wire values. LabVIEW Core 1 Course Manual 228 nivcom mma ee AR RAR AAAAAAARARARARKR (PARR RRR RRR Ree eee ee ee Oe &) Lesson 2 Navigating LabVIEW Click the Step Into button to open a node and pause. When you click the Step Into button again, it executes the first action and pauses at the next action of the subVI or structure. You also can press the and down arrow keys. Single-stepping through a VI steps through the VI node by node. Each node blinks to denote when it is ready to execute Click the Step Over button to execute a node and pause at the next node. ‘You also can press the and right arrow keys. By stepping over the node, you execute the node without single-stepping through the node. Click the Step Out button to finish executing the current node and pause. When the VI finishes executing, the Step Out button is dimmed. You also can press the and up arrow keys. By stepping out of a node, you complete single-stepping through the node and navigate to the next node. 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, select Tools»Options to display the Options dialog box and select Block Diagram from the Category list. You can configure the settings in the Block Diagram Cleanup section. The Warning button appears if a VI includes a warning and you placed a checkmark in the Show Warnings checkbox in the Error List window. Awwarning indicates there is a potential problem with the block diagram, but it does not stop the VI from running. (© National instruments Corporation 229 LabVIEW Core 1 Course Manual Lesson 2 Navigating LabviEW G. Searching for Controls, Vis and Functions [Restonee] “LabVIEW Core 1 Course Manual ‘When you select View»Controls or View»Functions to open the Controls and Funetions palettes, two buttons appear at the top of the palette. Search—Changes the palette to search mode so you can perform text-based searches to locate controls, VIs, or functions on the palettes. While a palette is in search mode, click the Return button to exit search mode and return to the palette. Customize—Provides options for selecting a format for the current palette, showing and hiding categories for all palettes, and sorting items in the Text and Tree formats alphabetically. Select Options from the shortcut menu to display the Controls/Funetions Palettes page of the Options dialog box, in which you can select a format for all palettes. This button appears only if you click the thumbtack in the upper left corner of a palette to pin the palette. Until you are familiar with the location of VIs and functions, search for the function or VI using the Search button. For example, if you want to find the Random Number function, click the Search button on the Funetions palette toolbar and start typing Random Number in the text box at the top of the palette. LabVIEW lists all matching items that either start with or contain the text you typed. You can click one of the search results and drag it to the block diagram, as shown in Figure 2-21. radars rai [aos indians Reser tomar) Steet ‘Secnecincnsne a) rat im roan sees foeksoarnan ooops oe sierra snistSoa is m2 Steen cme ior erce Figure 2-21. Searching for an Object in the Functions Palette 2.30 com OOOOH RAHR SHAD HH SUCFEHCCECEKCKCKCKEKEKTKEKV EEG lesson 2 Navigating LabVIEW Double-click the search result to highlight its location on the palette. If the object is one you need to use frequently, you can add it to your Favorites category. Right-click the object on the palette and select Add Item to Favorites, as shown in Figure 2-22. Began ¥ Nossonert 10 rte Soaocsing > > ¥ coe Cesc bes besten > Faciter » score > vierutewes > Pawanrng > Moserenant JO > Inaranere 10 ison and Moton © Matbemstce Caerie ee > bb > Pe > Signal rocesshg bata Conmunestin > connecoity > corre besqn& Suton > Earess 8 > adore > User branes Seb ai Figure 2-22. Adding an Item to the Favorites Category of a Palette © National struments Corporation 2st LabVIEW Gore 1 Course Manual Lesson 2 Navigating LabVIEW H. Selecting a Tool You 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. Figure 2-23. Tools Palette Tip You can manually choose the tool you need by selecting it on the Tools palette. Select View»Tools Palette to display the Tools palette. LabVIEW Core 1 Course Manu 232 com PRAPAAPPRPAPRARAMHRMAKeaange ea, Pesce eeeeeeeeeeee eee ede Operating Tool * Lesson 2 Navigating LabVIEW When the mouse cursor changes to the icon shown at left, the Operating tool is in operation. Use the Operating tool to change the values of a control. For example, in Figure 2-24 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. Ble_Eat Yew Some Operate Tob Window le [Bla] & [i] [ie seveovroe —~ ibe eens oo 20 40 eo a wo resort | Figure 2-24. Using the Operating Too! ‘The Operating tool is mostly used on the front panel window, but you also can use the Operating tool on the block diagram window to change the value of a Boolean constant. © Nationa Instruments Corporation 2.33 LabVIEW Core 1 Course Manual LabVIEW Core 1 Course Manual 234 icon (esson2 Navigating LabviEW When the mouse cursor changes to the icon shown at left, the Positioning tool is in operation. Use the Positioning tool to select or resize objects. For example, in Figure 2-25 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 {5 Using Temperatire’vi Front Panel Ge_Eat tow Bot parse Tos une eb (218) » [i] [xremesenroe en 0 70 ———————7= 00 100 20 xo «60 sho wo Wo bo 90 imo Figure 2-25. Using the Positioning Too! to Select an Object SEGRE UU Lesson 2 Navigating LabVIEW If the mouse hovers over a resizing node of an object, the cursor mode changes to show that you can resize the object, as shown in Figure 2-26. Notice that the cursor is hovering over a comer of the XY Graph ata resizing node, and the cursor mode changes to a double-sided arrow =) oo 20 40 60 80 100 Figure 2-26. Using the Positioning Tool to Resize an Object You can use the Positioning tool on both the front panel window and the block diagram. (© Nationa Instruments Corporation 2.35 LabVIEW Core 1 Course Manua! 2 Navigating Labview Labeling Tool L LabVIEW Gore 1 Course Manual When the mouse cursor changes to the icon shown at left, the Labeling tool is in operation. Use the Labeling tool to enter text in a control, to edit text, and to create free labels. For example, in Figure 2-27 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. ‘sing Temperature. vi Front Panel Te Gs Yew Bort Goer loos Union Ese El Ble] [nee cemcmnrer —~ Joe OPH ebercl teanesnarts ay (tc) | fle aa | po 20 4D 60 8b 190 ecu “reoret a so. 65.0 | | i a | © 04 ods eere ag ete aeeataraeee ate a gral do 160 ao xo We ho wo we wo wo sho Figure 2-27. Using the Labeling Tool When you are not in a specific area of a front panel window or block diagram window that accesses a certain mouse mode, the cursor appears as cross-hairs, If automatic tool selection is enabled, you can double-click any ‘open space to access the Labeling tool and create a free label 296 icon QMQOeAAaeAReRARRARAAAAi ht Laa RRR RRR eee ee eee eee ee Lesson 2 Navigating LabVIEW Wiring Tool > When the mouse cursor changes to the icon shown at left, the Wiring tool is in operation. Use the Wiring tool to wire objects together on the block diagram, For example, in Figure 2-28 the Wiring tool wires the Number of Measurements terminal to the count terminal of the For Loop. When the ‘mouse hovers over the exit or entry point of a terminal or over a wire, the cursor automatically accesses the Wiring tool. ‘Fy Using Temperature vi Block Diagram * Bie ER tow Blood pate Toos inion Seb Amber of Messrements ety (ne) Figure 2-28. Using the Wiring Too! ‘The Wiring tool works mainly with the block diagram window and when you create a connector pane on the front panel window. (© National Instruments Corporation 2ar LabVIEW Gore 1 Course Manuas Lesson 2 Navigating LabVIEW 7 Other Tools Accessed from the Palette ‘You can access the Operating, Positioning, Labeling, and Wiring tools directly from the Tools palette, rather than using the Automatic tool selection mode. Select View»Tools Palette to access the Tools palette. Figure 2-29. The Tools Palette ‘The top item in the Tools palette is the Automatic Tool Selection button. When this is selected, Lab VIEW 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. There are some additional tools on the palette, as described below: Use the Object Shortcut Menu tool to access an object shortcut menu with the left mouse button. Use the Scrolling tool to scroll through windows without using scrollbars. Use the Breakpoint tool to set breakpoints on VIs, functions, nodes, wires, and structures to pause execution at that location. Use the Probe tool to create probes on wires on the block diagram. Use the Probe tool to check intermediate values in a VI that produces questionable or unexpected results. bal [= [el Use the Color Copy tool to copy colors for pasting with the Coloring tool. Use the Coloring too! to color an object. The Coloring tool also displays the current foreground and background color settings. LabVIEW Core 1 Course Manual 298 icon SESE EUVUEVEUEUUEUUEEHEEEKeKeEs Dataflow Lesson 2 Navigating LabVIEW LabVIEW 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. Visual Basic, C++, JAVA, and most other text-based programming languages follow a control flow model of program execution. In control flow, the sequential order of program elements determines the execution order of a program. For a dataflow programming example, consider a block diagram that adds two numbers and then subtracts 50.00 from the result of the addition, as shown in Figure 2-30. 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. Figure 2-30. Datatlow Programming Example (© National instruments Corporation 2.99 LABVIEW Core 1 Course Manat Lesson 2 Navigating Labview LabVIEW Core 1 Course Manual In Figure 2-31, 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 error clusters, to force the order of execution. Refer to Lesson 5, Relating Data, for more information about error clusters. Figure 2-31. Dataflow Example for Multiple Code Segments 240 icon TAHKRARhRAAAAARARARAR RAR A SERENE KEKCKEKEKKEKKEKKEES - Lesson 2 Navigating LabVIEW J. Building a Simple VI Most LabVIEW Vis have three main tasks—acquiring some sort of data, analyzing the acquired data, and presenting the result, When each of these parts are simple, you can complete the entire VI using very few objects on the block diagram. Express VIs are designed specifically for completing ‘common, frequently used operations. In this section, you learn about some Express Vis that acquire, analyze, and present data. Then you learn to create a simple VI that uses these three tasks, as shown in Figure 2-32. Gian he eee “El Acquire Analyze Present. vi Front Panel Dee) Te ow Dont Gpwate [eos _Whdow Ib = (ela [wll ceosrs FeO] [BI ; | pagassiae | x ase spa Waveform raph Figure 2-32. Acquire, Analyze, and Present Example Front Panel Window and Block Diagram Window (© National instruments Corporation at LabVIEW Gore 1 Gourse Manual Lesson2 Navigating LabVIEW Acquire Analyze LabVIEW Gore 1 Course Manual On the Funetions palette, the Express Vis are grouped together in the Express category. Express VIs use the dynamic data type to pass data between Express VIs. Express VIs used for the Acquire task include the following: DAQ Assistant, Instrument /O Assistant, Simulate Signal, and Read from Measurement File. DAQ Assistant s data through a data acquisition device. You must use this Express VI frequently throughout this course. Until you Jearn more about data acquisition, you only use one channel of the data acquisition device, cH0. This channel is connected to a temperature sensor on the DAQ Signal Accessory. You can touch the temperature sensor to change the temperature the sensor reads. Instrument 1/0 Assistant The Instrument I/O Assistant acquires instrument control data, usually from a GPIB or serial interf Simulate Signal The Simulate Signal Express VI generates simulated data such as a sine wave. Read From Measurement File The Read From Measurement File Express VI reads a file that was created using the Write To Measurement File Express VI. It specifically reads LVM or TDM file formats. This Express VI does not read ASCII files. Refer to Lesson 6, Managing Resources, for more information on reading data from a file. Express VIs used for the Analyze task include the following—Amplitude and Level Measurements, Statistics, Tone Measurements, and so on. Amplitude and Level Measurements ‘The Amplitude and Level Measurements Express VI performs voltage measurements on a signal. These include DC, rms, maximum peak. minimum peak, peak to peak, cycle average, and cycle rms measurements. 242 icon Present i] Lesson 2 Navigating LabVIEW Statistics ‘The Statistics Express VI calculates statistical data from a waveform, ‘This includes mean, sum, standard deviation, and extreme values. Spectral Measurements The Spectral Measurements Express VI performs spectral measurement on a waveform, such as magnitude and power spectral density. Tone Measurements ‘The Tone Measurements Express VI searches for a single tone with the highest frequency or highest amplitude. It also finds the frequency and amplitude of a single tone. Filter The Filter Express VI processes a signal through filters and windows. Filters used include the following: Highpass, Lowpass, Bandpass, Bandstop, and Smoothing. Windows used include Butterworth, Chebyshev, Inverse Chebyshev, Elliptical, and Bessel. Present results by using Express VIs that perform a function, such as the Write to Measurement File Express VI, or indicators that present data on the front panel window. The most commonly used indicators for this task include the Waveform Chart, the Waveform Graph, and the XY Graph. Common Express VIs include the Write to Measurement File Express V1, the Build Text Express VI, the DAQ Assistant, and the Instrument /O Assistant. In this case, the DAQ Assistant and the Instrument /O Assistant provide output data from the computer to the DAQ device or an external instrument. Write to Measurement File The Write to Measurement File Express VI writes in LVM or TDMS file format. Refer to Lesson 6, Managing Resources, for more information on writing to measurement files. Build Text The Build Text Express VI creates text, usually for displaying on the front panel window or exporting to a file or instrument. Refer to Lesson 6, Managing Resources, for more information on creating strings. (© National instruments Corporation 243 LaDVIEW Core 1 Course Manual Lesson 2 Navigating LabVIEW Running a VI a Run Button Errors LabVIEW Core 1 Course Manual 2a After you configure the Express VIs and wire them together, you can run the VI. When you finish creating your VI, click the Run button on the toolbar to execute the VI While the VI is running, the Run button icon changes to the figure shown at left. After the execution completes, the Run button icon changes back to its original state, and the front panel indicators contain data. If a VI does not run, itis a broken, or nonexecutable, VI. The Run button appears broken when the VI you are creating or editing contains errors, If the button still appears broken when you finish wiring the block diagram, the VI is broken and cannot run. Generally, this means that a required input is not wired, or a wire is broken. Press the broken run button to access the Error list window. The Error list window lists each error and describes the problem. You can double-click an error to go directly to the error. Refer to Lesson 3, Troubleshooting and Debugging Vis, for more information on debugging VIs. Boooeoroaeenge gs § HHH BURBUEUREUEUEUVEUVEEEUeoeunUuuduaay Lesson 2 Navigating LABVIEW Self-Review: Quiz Refer to Figure 2-33 to answer the following quiz questions, Number 1 (Gace Number 2 Result 1 =P—p— & Figure 2-33. Dataflow Questions 1. Which function executes first: Add or Subtract? a. Add b. Subtract c. Unknown Which function executes first: Sine or Divide? a. Sine b. Divide c. Unknown 3. Which function executes first: Random Number, Divide or Add? a. Random Number b. Divide c. Add d. Unknown 4. Which function executes last: Random Number, Subtract or Add? a. Random Number b. Subtract ec. Add 4. Unknown What are the three parts of a VI? Front panel window Block diagram window Project Icon/connector pane ae oe © Nationa Instruments Corporation 25 {LADWIEW Core 1 Course Manust eee vvVvVvUNuUNvUuUVUuUeVUuueIVUJu UY Lesson 2 Navigating LabVIEW Self-Review: Quiz Answers 1. Which function executes first: Add or Subtract? a. Add b. Subtract ¢. Unknown Which function executes first: Sine or Divide? a. Sine b. Divide c. Unknown 3. Which function executes first? Random Number . Divide c. Add 4d. Unknown 4. Which function executes last: Random, Subtract or Add? a. Random Number b. Subtract c. Add 4. Unknown 5. What are the three parts of a VI? a. Front panel window b. Block diagram window c. Project d. Icon/connector pane {© Nationa Instruments Corporation 2a LabVIEW Core 1 Course Manual SUUUUUUUUUEUUUUUEUUUUuUeUUs Troubleshooting and Debugging Vis Torun a VI, you must wire all the subVIs, functions, and structures with the correct data types for the terminals. Sometimes a VI produces data or runs in a way you do not expect. You can use LabVIEW to configure how a VI runs and to identify problems with block diagram organization or with the data passing through the block diagram, Topics LabVIEW Help Utilities . Correcting Broken VIs Debugging Techniques Undefined or Unexpected Data moaw> Error Checking and Error Handling (© Nationa Instruments Corporation ot LabVIEW Core # Course Manual Lesson 9 Troubleshooting and Debugging Vis A. LabVIEW Help Utilities Use the Context Help window, the LabVIEW Help, and the NI Example Finder to help you create and edit VIs. Refer to the LabVIEW Help and manuals for more information about LabVIEW. Context Help Window {LabVIEW Cor 1 Course Manual The Context Help window displays basic information about LabVIEW objects when you move the cursor over each object. To toggle display of the Context Help window select Help»Show Context Help, press the 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 Help window displays the icon for subVIs, functions, constants, controls, and indicators, with wires attached to each terminal. When you move the cursor over dialog box options, the Context Help window displays descriptions of those options. In the Context Help window, the labels of required terminals appear bold, recommended terminals appear as plain text, and optional terminals appear dimmed. The labels of optional terminals do not appear if you click the Hide Optional Terminals and Full Path button in the Context Help window. Read From Spreadsheet File.vi format (4:39 ——— ‘em fe patho Path fie path (dialog # erty) So avons ‘nanber oF rows (ait) — fp fest roe Lark after read (chars) transpose (noi) tor Reads a speofed number oF les or rows from a numeric text Fle begining ‘2 pecied character offset and converts the data toa 20, singe-precson ‘ray of numbers, Detailed help Figure 3-1. Context Help Window Click the Show Optional Terminals and Full Path button located on the lower left corner of the Context Help window to display the optional terminals of a connector pane and to display the full path to a VI. Optional terminals are shown by wire stubs, informing you that other connections exist. The detailed mode displays all terminals, as shown in Figure 3-2. 32 com IPRA RRRARARABRARARARARARA DZ PSECU EY Lesson 9 Troubleshooting and Debugging Vis [content Help C).aments\LabVIEW 6.0} visib\ Utility \file.b\Read From Spreadsheet File.vi foxmat (1:31) ——— fle path daog F emeey) ew le path (Not A Path. alton umber of rows a1) — fest ro sits LL ark ater read (chars) inaccharacterjrow (rai | cor” Reads a specied nunber of Ines or rs Fram a numeri tex fle begrning at spoched character offset and converts the datato 20, single-prection aay of rmbers. Detailed help Figure 3-2. Detailed Context Help Window Bl Click the Lock Context Help button to lock the current contents of the Context Help window. When the contents are locked, moving the cursor over another object does not change the contents of the window. To unlock the window, click the button again. You also can access this option from the Help menu. If a corresponding LabVIEW Help topic exists for an object the Context Help window describes, a blue Detailed help link appears in the Context Help window. Also, the More Help button is enabled. Click the link or the bution to display the LabVIEW Help for more information about the object. LabVIEW Help You can access the LabVIEW Help by clicking the More Help button in the Context Help window, selecting Help»LabVIEW Help, or clicking the blue Detailed Help link in the Context Help window. You also can right-click an object and select Help from the shortcut menu, ‘The LabVIEW Help contains detailed descriptions of most palettes, menus, tools, Vis, and functions. The LabVIEW Help also includes step-by-step instructions for using Lab VIEW features. The LabVIEW Help includes links to the following resources: + LabVIEW Documentation Resources, which describes online and print documents to help new and experienced users and includes PDF versions of all LabVIEW manuals. + Technical support resources on the National Instruments Web site, such as the NI Developer Zone, the KnowledgeBase, and the Product Manuals Library. (© Nationa Instruments orporation 33 {LabVIEW Core 1 Course Manaat Lesson 3 Troubleshooting and Debugging Vis NI Example Finder Use the NI Example Finder to browse or search examples installed on your computer or on the NI Developer Zone at ni. com/zone. These examples demonstrate how to use LabVIEW to perform a wide variety of test, measurement, control, and design tasks. Select Help»Find Examples or click the Find Examples link in the Examples section of the Getting Started window to launch the NI Example Finder. Examples can show you how to use specific VIs or functions. You can right-click a VI or function on the block diagram or on a pinned palette and select Examples from the shortcut menu to display a help topic with links to examples for that VI or function, You can modify an example VI to fit an application, or you can copy and paste from one or more examples into a VI that you create Ni xample Finder BS Bowe exch | Sat Ciedckansconlets pent “Jann rd recess Ss "Sjasang er teres Ou Sconmunctng nthe esenene : Stecrte Coes ut Srndonerese Shine etn tet = Sissy asians LabVIEW Zone} | Sv rane seoreneacioe] || Dyemenny Bowens tykatne Sporn ansieisng cs Soraganmatcaly Coin is Sooke ween Stocks antec Not nae ore accra Figure 3-3. NI Example Finder LABVIEW Core # Course Manual a4 com ee ee ee eo ee ee ee re er er er . Lesson Troubleshooting and Debupging Vis B. Correcting Broken Vis Ifa VI does not run, it is a broken, or nonexecutable, VI. The Run button appears broken when the VI you are creating or editing contains errors. Ifthe button still appears broken when you finish wiring the block diagram, the VI is broken and cannot run. Finding Causes for Broken Vis Warnings do not prevent you from running a VI. They are designed to help you avoid potential problems in VIs. Errors, however, can break a VI. You must resolve any errors before you can run the VI. Click the broken Run button or select View»Error List to find out why a VIis broken. The Error list window lists all the errors. The Items with errors section lists the names of all items in memory, such as VIs and project libraries that have errors. If two or more items have the same name, this section shows the specific application instance for each item. The errors and warnings section lists the errors and warnings for the VI you select in the Items with errors section. The Details section describes the errors and in some cases recommends how to correct the errors. Click the Help button to display a topic in the LabVIEW Help that describes the error in detail and includes step-by-step instructions for correcting the error. Click the Show Error button or double-click the error description to highlight the area on the block diagram or front panel that contains the error. (Bieverit ‘av cet eric it erm a arate, a) | Sebo feecaiefetiralcison ono Cs) Cee IC | Figure 3-4. Example of the Error List Dialog Box (© Nationa Instruments Corporation 35 LabVIEW Core 1 Course Manual Lesson Troubleshooting and Debugging Vis Common Causes of Broken Vis The following list contains common reasons why a VI is broken while you edit it: The block diagram contains a broken wire because of a mismatch of data types or a loose, unconnected end, Refer to the Correcting Broken Wires topic of the LabVIEW Help for information about correcting broken wires. A required block diagram terminal is unwired. Refer to the Using Wires to Link Block Diagram Objects topic of the LabVIEW Help for information about setting required inputs and outputs. A subV1 is broken or you edited its connector pane after you placed its icon on the block diagram of the VI. Refer to the Creating SubVIs topic of the LabVIEW Help for information about subVIs. C. Debugging Techniques LaDVIEW Core 1 Course Manual Ifa VIis not broken, but you get unexpected data, you can use the following techniques to identify and correct problems with the VI or the block diagram data flow: Wire the error in and error out parameters at the bottom of most built-in Vis and functions. These parameters detect errors encountered in each node on the block diagram and indicate if and where an error occurred. You also can use these parameters in the VIs you build To eliminate all VI warnings, select View»Error List and place a checkmark in the Show Warnings checkbox to see all warnings for the VI. Determine the causes and correct them in the VI. Use the Positioning tool to triple-click a wire to highlight its entire path and to ensure that the wires connect to the proper terminals. Use the Context Help window to check the default values for each function and subV1 on the block diagram. VIs and functions pass default values if recommended or optional inputs are unwired. For example, a Boolean input might be set to TRUE if unwired. Use the Find dialog box to search for subVIs, text, and other objects to correct throughout the VI. Select View»VI Hierarchy to find unwired subVIs. Unlike unwired functions, unwired Vis do not always generate errors unless you configure an input to be required. If you mistakenly place an unwired subVI on the block diagram, it executes when the block diagram does. Consequently, the VI might perform extra actions. Use execution highlighting to watch the data move through the block jagram, 36 icon (© Nationa Instruments Corporation Lesson 3 Toubleshootng and Debugging Vis Single-step through the VI to view each action of the VI on the block diagram, Use the Probe tool to observe intermediate data values and to check the error output of Vs and functions, especially those performing /O. Click the Retain Wire Values button on the block diagram toolbar to retain wire values for use with probes. This feature allows you to easily check values of data that last passed through any wire, Use breakpoints to pause execution, so you can single-step or insert probes. Suspend the execution of a subVI to edit values of controls and indicators, to control the number of times it runs, or to go back to the beginning of the execution of the subVI Determine if the data that one function or subVI passes is undefined. This often happens with numbers. For example, at one point in the VI an operation could have divided a number by zero, thus returning Inf (infinity), whereas subsequent functions or subVIs were expecting numbers. If the VI runs more slowly than expected, confirm that you turned off execution highlighting in subVIs. Also, close subVI front panels and block diagrams when you are not using them because open windows can affect execution speed. Check the representation of controls and indicators to see if you are receiving overflow because you converted a floating-point number to an integer or an integer to a smaller integer. For example, you might wire a 16-bit integer to a function that only accepts 8-bit integers. This causes the function to convert the 16-bit integer to an 8-bit representation, potentially causing a loss of data. Determine if any For Loops inadvertently execute zero iterations and produce empty arrays. Verify you initialized shift registers properly unless you intend them to save data from one execution of the loop to another. Check the cluster element order at the source and destination points. LabVIEW detects data type and cluster size mismatches at edit time, but it does not detect mismatches of elements of the same type. Check the node execution order. Check that the VI does not contain hidden subVIs. You inadvertently might have hidden a subVI by placing one directly on top of another node or by decreasing the size of a structure without keeping the subVI in view. a7 LabVIEW Core 1 Course Manual Lesson 3 Troubleshooting and Debupging Vis * Check the inventory of subVIs the VI uses against the results of View»Browse Relationships»This VI’s SubVIs and View»Browse Relationships» Unopened SubVIs to determine if any extra subVIs exist, Also open the VI Hierarchy window to see the subVIs for a VI. To help avoid incorrect results caused by hidden Vis, specify that inputs to Vis are required. Execution Highlighting a View an animation of the execution of the block diagram by clicking the Highlight Execution button. Execution highlighting shows the movement of data on the block diagram from one node to another using bubbles that move along the wires. Use execution highlighting in conjunction with single-stepping to see how data values move from node to node through a VI. (MathScript RT Module) In MathScript Nodes, execution highlighting shows the progression from one line of script to another using a blue arrow that blinks next to the line that is executing currently. TJ Nole Execution highlighting greatly reduces the speed at which the VI runs. (i adaesub. tock Dlgram * Te Ee Yor font ous Tow whi =| esenieiz 2 ee Figure 3-5. Example of Execution Highlighting in Use Single-Stepping Single-step through a VI to view each action of the VI on the block diagram as the VI runs. The single-stepping buttons, shown as follows, affect execution only in a VI or subVI in single-step mode Slopinio Slop Over Step Out LabVIEW Core 1 Course Manus} 38 icon SESE EEKHKTHHKEEHGTKeeeTS Fen Probe Tools & Lesson 3 Troubleshooting and Debugging Vis Enter single-step mode by clicking the Step Into or Step Over button on the block diagram toolbar. Move the cursor over the Step Into, Step Over, or Step Out button to view a tip strip that describes the next step if you click that button. You can single-step through subVIs or run them normally. When you single-step through a VI, nodes blink to indicate they are ready to execute. If you single-step through a VI with execution highlighting on, an execution glyph appears on the icons of the subVIs that are currently running. Use the Probe tool to check intermediate values on a wire as a VI runs. Use the Probe tool if you have a complicated block diagram with a series of operations, any one of which might return incorrect data. Use the Probe tool with execution highlighting, single-stepping, and breakpoints to determine if and where data is incorrect. If data is available, the probe immediately updates and displays the data in the Probe Watch Window during execution highlighting, single-stepping, or when you pause at a breakpoint. When execution pauses at a node because of single-stepping or a breakpoint, you also can probe the wire that just executed to see the value that flowed through that wire. Types of Probes You can check intermediate values on a wire when a VI runs by using a generic probe, by using an indicator on the Controls palette to view the data, by using a supplied probe, by using a customized supplied probe, or by creating a new probe. FJ Note (MathScript RT Module) You can view the data in a script in a MathScript Node as a VI runs by using a LabVIEW MathScript probe. Generic Use the generic probe to view the data that passes through a wire. Right-click a wire and select Custom Probe»Generie Probe from the shortcut menu to use the generic probe. The generic probe displays the data. You cannot configure the generic probe to respond to the data. LabVIEW displays the generic probe when you right-click a wire and select Probe, unless you already specified a custom or supplied probe for the data type. (© Nationa Instruments Gorporation 39 LabVIEW Core t Course Manual Lesson 3 Troubleshooting and Debugging Vis . LaDVIEW Core 1 Course Manual You can debug a custom probe similar to a VI. However, a probe cannot probe its own block diagram, nor the block diagram of any of its subVIs. When debugging probes, use the generic probe. Using Indicators to View Data You also can use an indicator to view the data that passes through a wire. For example, if you view numeric data, you can use a chart within the probe to view the data, Right-click a wire, select Custom Probe»Controls from the shortcut menu, and select the indicator you want to use. You also can click the Select a Control icon on the Controls palette and select any custom control or type definition saved on the computer or in a shared directory on a server. LabVIEW treats type definitions as custom controls when you use them to view probed data, If the data type of the indicator you select does not match the data type of the wire you right-clicked, LabVIEW does not place the indicator on the wire. Supplied Supplied probes are VIs that display comprehensive information about the data that passes through a wire. For example, the VI Refnum Probe returns information about the VI name, the VI path, and the hex value of the reference, You also can use a supplied probe to respond based on the data that flows through the wire. For example, use an Error probe on an error cluster to receive the status, code, source, and description of the error and specify if you want to set a conditional breakpoint if an error or warning occurs. The supplied probes appear at the top of the Custom Probe shortcut menu. Right-click a wire and select Custom Probe from the shortcut menu to select a supplied probe. Only probes that match the data type of the wire you right-click appear on the shortcut menu. Refer to the Using Supplied Probes V1 in the labview\examples\ general \probes . 11b for an example of using supplied probes. Custom Use the Create New Probe dialog box to create a probe based on an existing probe or to create a new probe. Right-click a wire and select Custom Probe»New from the shortcut menu to display the Create New Probe dialog box. Create a probe when you want to have more control over how LabVIEW probes the data that flows through a wire, When you create a new probe, the data type of the probe matches the data type of the wire you right-clicked. If you want to edit the probe you created, you must open it from the directory where you saved it. 340 ricom Poggsgggeaggaeststdad a htt oo eww Ve oO COC CeCe CCC COG Gd Gg @ Lesson 3 Troubleshooting and Debuaging Vis After you select a probe from the Custom Probe shortcut menu, navigate to itusing the Select a Control palette option, or create a new probe using the Create New Probe dialog box, that probe becomes the default probe for that data type, and LabVIEW loads that probe when you right-click a wire and select Probe from the shortcut menu. LabVIEW only loads probes that exactly match the data type of the wire you right-click. That is, a double precision floating-point numeric probe cannot probe a 32-bit unsigned integer wire even though LabVIEW can convert the data. Note If you want a custom probe to be the default probe for a particular data type, save the probe in the user. 1ib\_probes \default directory. Do not save probes in the vi. 1ib\_probes directory because LabVIEW overwrites those files when you upgrade or reinstall. Breakpoints ie] (© Nationa instruments Corporation on Use the Breakpoint tool to place a breakpoint on a VI, node, or wire and Pause execution at that location. When you set a breakpoint on a wire, execution pauses after data passes through the wire and the Pause button appears red. Place a breakpoint on the block diagram to pause execution after all nodes on the block diagram execute. The block diagram border appears red and blinks to reflect the placement of a breakpoint. When a VI pauses at a breakpoint, LabVIEW brings the block diagram to the front and uses a marquee to highlight the node, wire, or line of script that contains the breakpoint. When you move the cursor over an existing breakpoint, the black area of the Breakpoint tool cursor appears white. When you reach a breakpoint during execution, the VI pauses and the Pause button appears red. You can take the following actions: + Single-step through execution using the single-stepping buttons. + Probe wires to check intermediate values. * Change the values of front panel controls * Click the Pause button to continue running to the next breakpoint or until the VI finishes running. LabVIEW Core # Course Manual Lesson 3 Troubleshooting and Debugging Vis Suspending Execution LabVIEW Core 1 Course Mant Suspend execution of a subVI to edit values of controls and indicators, to control the number of times the subVI runs before returning to the caller, or to go back to the beginning of the execution of the subVI. You can cause all calls to a subVI to start with execution suspended, or you can suspend a specific call to a subVI To suspend all calls to a subVI, open the subVI and select Operate»Suspend when Called. The subVI automatically suspends when another VI calls it. If you select this menu item when single-stepping, the subVI does not suspend immediately. The subVI suspends when it is called. To suspend a specific subVI call, right-click the subVI node on the block diagram and select SubVI Node Setup from the shortcut menu. Place a checkmark in the Suspend when called checkbox to suspend execution only at that instance of the subVI. The VI Hierarchy window, which you display by selecting View» VI Hierarchy, indicates whether a VI is paused or suspended. An arrow glyph indicates a VI that is running regularly or single-stepping, A pause glyph indicates a paused or suspended VI A green pause glyph, or a hollow glyph in black and white, indicates a VI that pauses when called. A red pause glyph, or a solid glyph in black and white, indicates a VI that is currently paused. An exclamation point glyph indicates that the subVI is suspended. ‘A VI can be suspended and paused at the same time. Determining the Current Instance of a SubVI When you pause a subVI, the Call list pull-down menu on the toolbar lists the chain of callers from the top-level VI down to the subVI. This list is not the same list you see when you select View»Browse Relationships»This VI's Callers, which lists all calling Vis regardless of whether they are currently running. Use the Call list menu to determine the current instance of the subVI if the block diagram contains more than one instance. When you select a VI from the Calll list menu, its block diagram opens and LabVIEW highlights the current instance of the subVI You also can use the Call Chain function to view the chain of callers from the current VI to the top-level VI. a igor THOOQCORDORHRHARADRKATT VPUVUVVIVUIVVUUUVI CEU lesson3_ Troubleshooting and Debugging Vis D. Undefined or Unexpected Data Undefined data, which are wan (not a number) or Ing (infinity), invalidate all subsequent operations. Floating-point operations return the following two symbolic values that indicate faulty computations or meaningless results: + NaN (not a number) represents a floating-point value that invalid operations produce, such as taking the square root of a negative number. + Ing (infinity) represents a floating-point value that valid operations produce, such as dividing a number by zero, LabVIEW does not check for overflow or underflow conditions on integer values. Overflow and underflow for floating-point numbers is in accordance IEEE 754, Standard for Binary Floating-Point Arithmetic. Floating-point operations propagate Naw and tn£ reliably, When you explicitly or implicitly convert an or Iné to integers or Boolean values, the values become meaningless. For example, dividing | by zero produces In£. Converting Inf toa 16-bit integer produces the value 32,767, which appears to be a normal value. Before you convert data to integer data types, use the Probe tool to check intermediate floating-point values for validity. Check for NaN by wiring the Comparison function, Not A Number/Path/Refnum?, to the value you suspect is invalid. Do not rely on special values such as NaN, Inf, or empty arrays to determine if a VI produces undefined data. Instead, confirm that the VI produces defined data by making the VI report an error if it encounters a situation that is likely to produce undefined data For example, if you create a VI that uses an incoming array to auto-index a For Loop, determine what you want the VI to do when the input array is empty. Either produce an output error code, substitute defined data for the value that the loop creates, or use a Case structure that does not execute the For Loop if the array is empty. E. Error Checking and Error Handling No matter how confident you are in the VI you create, you cannot predict every problem a user can encounter. Without a mechanism to check for errors, you know only that the VI does not work properly. Error checking tells you why and where errors occur. (© National nstuments Corporation 3.13 LabVIEW Core 1 Course Manual Lesson Troubleshooting ang Debugging Vis Automatic Error Handling Each error has a numeric code and a corresponding error message. By default, LabVIEW automatically handles any error when a VI runs by suspending execution, highlighting the subVI or function where the error ‘occurred, and displaying an error dialog box. To disable automatic error handling for the current VI, select File» VI Properties and select Execution from the Category pull-down menu. To disable automatic error handling for any new, blank VIs you create, select Tools»Options and select Block Diagram from the Category list. To disable automatic error handling for a subVI or function within a VI, wire its error out parameter to the error in parameter of another subV1 or function or to an error out indicator. Manual Error Handling LaBVIEW Core 1 Course Manual You can choose other error handling methods. For example, if an /O VI on the block diagram times out, you might not want the entire application to stop and display an error dialog box. You also might want the VI to retry for acertain period of time. In LabVIEW, you can make these error handling decisions on the block diagram of the VI Use the LabVIEW error handling VIs and functions on the Dialog & User Interface palette and the error in and error out parameters of most VIs and functions to manage errors. For example, if LabVIEW encounters an error, you can display the error message in different kinds of dialog boxes. Use error handling in conjunction with the debugging tools to find and manage errors. Vis and functions return errors in one of two ways—with numeric error codes or with an error cluster. Typically, functions use numeric error codes, and Vis use an error cluster, usually with error inputs and outputs. Error clusters typically provide the same standard error in and standard error out functionality. When you perform any kind of input and output (I/O), consider the possibility that errors might occur. Almost all I/O functions return error information, Include error checking in VIs, especially for /O operations (ile, serial, instrumentation, data acquisition, and communication), and provide a mechanism to handle errors appropriately a4 rico PSR KKEKEEEEEEKCKTEEUY Lesson 3 Troubleshooting and Debugging Vis Use the Lab VIEW error handling VIs, functions, and parameters to manage errors. For example, if LabVIEW encounters an error, you can display the error message in a dialog box. Or you can fix the error programmatically then erase the error by wiring the error out output of the subVI or function to the error in input of the Clear Errors VI. Use error handling in conjunction with the debugging tools to find and manage errors. National Instruments strongly recommends using error handling. Error Clusters Use the error cluster controls and indicators to create error inputs and outputs in subVIs. ‘The error in and error out clusters include the following components of information: + status is a Boolean value that reports TRU! + code is a 32-bit signed integer that identifies the error numerically. A nonzero error code coupled with a status of FALSE signals a warning rather than a error. if an error occurred. + source is a string that identifies where the error occurred. Error handling in LabVIEW follows the dataflow model. Just as data values flow through a VI, so can error information. Wire the error information from the beginning of the VI to the end. Include an error handler VI at the end of the VI to determine if the VI ran without errors. Use the error in and error out clusters in each VI-you use or build to pass the error information through the VI As the VI runs, LabVIEW tests for errors at each execution node. If LabVIEW does not find any errors, the node executes normally. If LabVIEW detects an error, the node passes the error to the next node without executing that part of the code. The next node does the same thing, and so on. At the end of the execution flow, LabVIEW reports the error. Explain Error When an error occurs, right-click within the cluster border and select Explain Error from the shortcut menu to open the Explain Error dialog box. The Explain Error dialog box contains information about the error. ‘The shortcut menu includes an Explain Warning option if the VI contains warnings but no errors. You also can access the Explain Error dialog box from the Help»Explain Error menu, (© National instruments Corporation 345 LabVIEW Gore Course Manual Se@eeuvuveeeeveueee eee ee eee eG a” = Pe] oO i o Lesson 3 Troubleshooting and Debugging Vis Quiz 1 {© National Instruments Corporation How do you disable automatic error handling? a. Enable execution highlighting. b. Wire the error out cluster of a subVI to the error in cluster of another subVI. ¢. Place a checkmark in the Show Warnings checkbox of the Error list window. Which of the following are the contents of the error cluster? a. Status: Boolean b. Error: String c. Code: 32-bit integer d. Source: String wr LaDVEW Core 1 Course Manual YUU VUNUNUUEUUOUEUvUueUuUuUvuvueueUuUuUulag Lesson 3 Trovbeshootng and Debugging Vis Self Review: Quiz Answers (© National instruments Corporation How do you disable automatic error handling? a. Enable execution highlighting b. Wire the error out cluster of a subVI to the error in cluster of another subV1. ¢. Place a checkmark in the Show Warnings checkbox of the Error List window. Which of the following are the contents of the error cluster? a. Status: Boolean Error: String ©. Code: 32-bit integer . Source: String 3.19 {LabVIEW Core 1 Course Manual VPuwuvvvuvevueevueuvUueeNeUueUuUuUuUuUueUvVUU YU UD UD Implementing a VI This lesson teaches you how to implement code in LabVIEW. These skills include designing a user interface, choosing a data type, documenting your code, using looping structures such as While Loops and For Loops, adding software timing to your code, displaying your data as a plot, and making decisions in your code using a Case structure. Topics A. Front Panel Design B. LabVIEW Data Types C. Documenting Code D. While Loops E. For Loops F. Timing a VI G. Iterative Data Transfer H, Plotting Data I. Case Structures (© National instruments Corporation a LabVIEW Core 1 Course Manual Lesson 4 Implementing a Vt A. Front Panel Design In the design phase of the software development method, you identify the inputs and outputs of the problem. This identification leads directly to the design of the front panel window. You can retrieve the inputs of the problem using the following methods: + acquiring from a device such as a data acquisition device or a multimeter + reading directly from a file + manipulating controls You can display the outputs of the problem with indicators, such as graphs, charts, or LEDs, or log the outputs to a file. You also can output data to a device using signal generation, Lessons about data acquisition, signal generation, and file logging appear later in this course. Designing Controls and Indicators LabVIEW Core 1 Course Manual When choosing controls and indicators, make sure that they are appropriate for the task you want to perform. For example, when you want to determine the frequency of a sine wave, choose a dial control, or when you want to display temperature, choose a thermometer indicator. Labels and Captions Make sure to label controls and indicators clearly. These labels help users identify the purpose of each control and indicator. Also, clear labeling helps you document your code on the block diagram. Control and indicator labels correspond to the names of terminals on the block diagram. Captions help you describe a front panel control. Captions do not appear on the block diagram. Using captions allows you to document the user interface without cluttering the block diagram with additional text. For example, in the Weather Station, you must provide an upper boundary for the temperature level. If the temperature rises above this level, the Weather Station indicates a heatstroke warning. You could call this control Upper Temperature Limit (Celsius). However, this label would occupy unnecessary space on the block diagram. Instead, use a caption for the control Upper Temperature Limit (Celsius) and use the label to create a shorter description for the block diagram, such as Upper Temp. 42 icon eo @ 6: 8 6 8 8 8 8 6 86 6 6 6 8 he 6 86 6 ea 6 fe a ee ee eo oe oe ee ee er et ee oe Lesson 4 Implementing a V1 Control and Indicator Options You can set default values for controls. Figure 4-1 shows a default value of 35 °C. By setting a default value, you can assume a reasonable value for a VIif the user does not set another value during run-time. To set the default value, complete the following steps: 1. Enter the desired value. 2. Right-click the control and select Data Operations»Make Current Value Default from the shortcut menu, © Upper Temperature Lin (Celsius) pester? rea: iss (ees Front Panel Window Block Diagram Figure 4-1. Setting Default Values You also can hide and view items on controls and indicators. For example, in Figure 4-2, you can see both the caption and the label, However, you only need to see the caption. To hide the label, right-click the control and select Visible Items»Label as shown in Figure 4-2. ® ® Tame oa Tesora tne Ena) —- oe. redtente Peo Chaps toineatr ita was Cetten ao ene Darenct — Raine Ca cpeats fowwe Repesmnten > Oat ge Proms oo. 1 Before Hiding the Label 2 Alter Hiding the Label Figure 4-2. Hiding a Front Panel Label © Natona struments Coporton “6 {abEW Core 1 Cause al Lesson 4 Implementing a VI Using Color Proper use of color can improve the appearance and functionality of your user interface. Using too many colors, however, can result in color clashes that cause the user interface to look too busy and distracting. LabVIEW provides a color picker that can aid in selecting appropriate colors. Select the Coloring tool and right-click an object or workspace to display the color picker. The top of the color picker contains a grayscale spectrum and a box you can use to create transparent objects, The second spectrum contains muted colors that are well suited to backgrounds and front panel objects. The third spectrum contains colors that are well suited for highlights. Moving your cursor vertically from the background colors to the highlight colors helps you select appropriate highlight colors for a specific background color. The following tips are helpful for color matching: + Use the default Lab VIEW colors. LabVIEW also substitutes colors similarly to how it substitutes fonts. If one of the colors of the V1 is unavailable, LabVIEW replaces it with the closest match. You also can use system colors to adapt the appearance of a front panel window to the system colors of any computer that runs the VI + Start with a gray scheme. Select one or two shades of gray and choose highlight colors that contrast well against the background. + Add highlight colors sparingly—on plots, abort buttons, and perhaps the slider thumbs—for important settings. Small objects need brighter colors and more contrast than larger objects. + Use differences in contrast more often that differences in color. Color-blind users find it difficult to discern objects when differences are in color rather than contrast. + Use spacing to group objects instead of grouping by matching colors. + Good places to learn about color are stand-alone hardware instrument panels, maps, and magazines. * Choose objects from the System category of the Controls palette if you ‘want your front panel controls to use the system colors. Spacing and Alignment LabVIEW Core 1 Course Manual White space and alignment are probably the most important techniques for grouping and separation, The more items that your eye can find on a line, the cleaner and more cohesive the organization seems. When items are on a line, the eye follows the line from left to right or top to bottom. This is, related to the script direction. Although some cultures view items right to lef, almost all follow top to bottom. 4 icon D2gQgT ERE HHH Severe seeseseeeeeeeseeeeeugs Text and Fonts Lesson 4 Implementing a V1 Use the following guidelines to design the front panel to serve as a user interface: + Do not place objects too closely together. Leave some blank space between objects to make the front panel easier to read. Blank space also prevents users from accidentally clicking the wrong control or button. + Do not place objects on top of other objects, Even partially covering a control or indicator with a label or other object slows down screen updates and can make the control or indicator flicker. + Use dividing lines between menu sections, as shown in Figure 4-3, to help you find the items quickly and strengthen the relationship between the items in the sections. ® ® Ee eo = we Qpen. Cirle Open... Cirle ‘Ghose Chew eS cen Save CireS- —"—_ | *.c ons soe Saves... Save with Options. Save All Revert. i oan Aevet Print A sewn cae es Page Setup. Recently Opened Files > Pint. Esit Cube Bint Windows. Cte Mi Properties. Calat Recently Opened Files > Exit Cte 1 Good Menu 2 Bad Menu Figure 4-3. Good and Bad Menu Examples Text is easier to read and information is more easily understood when displayed in an orderly way. Use the default LabVIEW fonts. For instance, LabVIEW defines its built-in fonts as the default system fonts. When you move Vis between platforms, LabVIEW automatically updates its built-in fonts so that they match the default system font of the current platform. Additionally, if you attempt to open a VI that uses an unavailable font, LabVIEW substitutes the closest match. For example, if you attempt to open (© Nationa! instruments Corporation 45 LabVIEW Covet Course Manuat Lesson 4 g Implementing a Vi a VI that uses the Arial font on a computer that does not have the Arial font, LabVIEW substitutes a similar, installed font. Using too many font s disorganized. Instead, use two or three different sizes of the same font, Serif’ help people to recognize whole words from a distance. If you are Jes can make your front panel window look busy and using more than one size of a font, make sure the sizes are noticeably different. If not, it may look like a mistake. Similarly, if you use ‘two different fonts, make sure they are distinct. Design your user interface with larger fonts and more contrast for industrial operator stations. Glare from lighting or the need to read information from a distance can make normal fonts difficult to read. Also, remember that touch screens generally require larger fonts and more spacing between selection items. Note If fonts do not exist on a target machine, substituted fonts can cause the user interface to appear skewed. User Interface Tips and Tools LabVIEW Core 1 Course Manual ‘Some of the built-in LabVIEW tools for making user-friendly front panel windows include system controls, tab controls, decorations, menus, and automatic resizing of front panel objects. System Controls A common user interface technique is to display dialog boxes at appropriate times to interact with the user. You can make a VI behave like a dialog box by selecting File»VI Properties, selecting the Window Appearance category, and selecting the Dialog option. Use the system controls and indicators located on the System palette in dialog boxes you create. The system controls change appearance depending on which platform you run the VI. When you run the VI on a different platform, the system controls adapt their color and appearance to match the standard dialog box controls for that platform. System controls typically ignore all colors except transparent. If you are integrating a graph or non-system control into the front panel windows, match them by hiding some borders or selecting colors similar to the system colors. 46 icon QOTKERERRRRER GHA FURR KEEDEEEEKEEEES Lesson 4 Implementing 2 V1 Tab Controls Physical instruments usually have good user interfaces. Borrow heavily from their design principles, but use smaller or more efficient controls, such as ring controls or tab controls, where appropriate. Use tab controls to overlap front panel controls and indicators in a smaller area, To add additional pages to a tab control, right-click a tab and select Add Page Before or Add Page After from the shortcut menu. Relabel the tabs with the Labeling tool, and place front panel objects on the appropriate pages. The terminals for these objects are available on the block diagram, as are terminals for any other front panel object (except Decorations). You can wire the enumerated control terminal of the tab control to the selector of a Case structure to produce cleaner block diagrams. With this method you associate each page of the tab control with a subdiagram in the Case structure. You place the control and indicator terminals from each page of the tab control—as well as the block diagram nodes and wires associated with those terminals—into the subdiagrams of the Case structure. Decorations Use the decorations located on the Decorations palette to group or separate objects with boxes, lines, or arrows. Menus Use custom menus to present front panel functionality in an orderly way and in a relatively small space. Using small amounts of space leaves room on the front panel for critical controls and indicators, items for beginners, items needed for productivity, and items that do not fit well into menus. You also can create keyboard shortcuts for menu items. To create a run-time shortcut menu for front panel objects, right-click the front panel object and select Advanced»Run-Time Shortcut Menu»Edit. To create a custom run-time menu for your VI, select Edit»Run-Time Menu, Automatic Resizing of Front Panel Objects Use the File» VI Properties» Window Size options to set the minimum size of a window, maintain the window proportion during screen changes, and set front panel objects to resize in two different modes. When you design a VI, consider whether the front panel can display on computers with different screen resolutions. Select File»VI Properties, select Window Size in the Category pull-down menu, and place a checkmark in the Maintain proportions of window for different monitor resolutions checkbox to ‘maintain front panel window proportions relative to the screen resolution. (© Nationa Instruments Corporation ar LabVIEW Core 1 Course Mansa! Lesson 4 Implementing a Vr B. LabVIEW Data Types Terminals LABVIEW Core 1 Course Manual Many different data types exist for data, You already learned about numeric, Boolean, and string data types in Lesson 2, Navigating LabVIEW. Other data types include the enumerated data type, dynamic data, and others. Even within numeric data types, there are different data types, such as whole numbers or fractional numbers. ‘The block diagram terminals visually communicate to the user some information about the data type they represent. For example, in Figure 4-4, Height (cm) is a double-precision, floating-point numeric. This is indicated by the color of the terminal, orange, and by the text shown on the terminal, | Base (om) Area (cm2) TWangulr Mtiper | Figure 4-4. Terminal Data Type Example 43 com CORLOTRRRARRARRAR RAR Re PURE VEKETETEEKEEEKKTKEEEEES Lesson 4 Implementing a V Numeric Data Types The numeric data type represents numbers of various types. To change the representation type of a number, right-click the control, indicator, or constant, and select Representation, as shown in Figure 4-5. Numeric fa Reet Wile Items > Find Control Hide Control Change to Indicator Change to Constant Description and Tip ‘Numeric Palette Create Data Operations Figure 4-5. Numeric Representation When you wire two or more numeric inputs of different representations to a function, the function usually returns the data in the larger, or wider, representation. The functions coerce the smaller representations to the ‘widest representation before execution and LabVIEW places a coercion dot on the terminal where the conversion takes place. The numeric data type includes the following subcategories of representation—floating-point numbers, signed integers, unsigned integers, and complex numbers, © National Instruments Corporation 49 LabVIEW Core 1 Course Manual Lesson 4 Implementing a VI Floating-Point Numbers Floating-point numbers represent fractional numbers. In LabVIEW, floating-point numbers are represented with the color orange. Single-precision (SGL)—Single-precision, floating-point numbers have 32-bit IEEE single-precision format. Use single-precision, floating-point numbers to save memory and avoid overflowing the range of the numbers. Double-precision (DBL)—Double-precision, floating-point numbers have 64-bit IEEE double-precision format. Double-precision is the default format for numeric objects. For most situations, use double-precision, floating-point numbers. Extended-precision (EXT)—In memory, the size and precision of extended-precision numbers vary depending on the platform. In Windows, they have 80-bit IEEE extended-precision format. Fixed-Point Data Type he fixed-point data type is a numeric data type that represents a set of rational numbers using binary digits, or bits. Unlike the floating-point data type, which allows the total number of bits LabVIEW uses to represent numbers to vary, you can configure fixed-point numbers to always use a specific number of bits. Hardware and targets that only can store and process data with a limited or fixed number of bits then can store and process the numbers. You can specify the range and precision of fixed-point numbers. BJ Note To represent a rational number using the fixed-point data type, the denominator of the rational number must be a power of 2, because the binary number system is a base-2 number system. LaDVIEW Core 1 Gourse Manual Use the fixed-point data type when you do not need the dynamic functionality of floating-point representation or when you want to work with a target that does not support floating-point arithmetic, such as an FPGA target. Specify the encoding, word length, and integer word length of a fixed-point number when you want the number to conform to a certain bit size. Encoding—The binary encoding of the fixed-point number. You can select signed or unsigned, If you select signed, the sign bit is always the first bit in the bit string that represents the data. Word length—The total number of bits in the bit string that LabVIEW uses, to represent all possible values of the fixed-point data. LabVIEW accepts a maximum word length of 64 bits. Certain targets might limit data to smaller word lengths. If you open a VI on a target and the VI contains fixed-point 410 com RAR hh fH wwe ewwewewevwevWvwevsevewvwvvevewvewvwvevwvvVwVvweVweVvweoMvweOUNGr OY Lesson 4 Implementing a VI data with larger word lengths than the target can accept, the VI contains broken wires. Refer to the documentation for a target to determine the maximum word length the target accepts. Integer word length—The number of integer bits in the bit string that LabVIEW uses to represent all possible values of the fixed-point data, or, given an initial position to the left or right of the most significant bit, the number of bits to shift the binary point to reach the most significant bit. The integer word length can be larger than the word length, and can be positive or negative. Integers Integers represent whole numbers, Signed integers can be positive or negative. Use the unsigned integer data types when you know the integer is always positive, In LabVIEW, integers are represented with the color blue. When LabVIEW converts floating-point numbers to integers, the VI rounds to the nearest even integer. For example, LabVIEW rounds 2.5 to 2 and rounds 3.5 to 4. Byte (18)—Byte integer numbers have 8 bits of storage and a range of 128 to 127. ‘Word (116)—Word integer numbers have 16 bits of storage and a range of -32,768 to 32,767. Long (132)—Long integer numbers have 32 bits of storage and a range of -2,147,483,648 to 2,147,483,647. In most cases, it is best to use a 32-bit integer. Quad (164)—Quad integer numbers have 64 bits of storage and a range of -1e19 to 1e19. Byte (U8)—Byte unsigned integer numbers have 8 bits of storage and a range of 0 to 255. Word (U16)—Word unsigned integer numbers have 16 bits of storage and a range of 0 to 65,535, Long (U32)—Long unsigned integer numbers have 32 bits of storage and a range of 0 to 4,294,967,295. Quad (U64}—Quad unsigned integer numbers have 64 bits of storage and a range of 0 to 2e19, (© National Instruments Corporation + LabVIEW Core ¥ Course Manual Lesson 4 implementing a v1 Boolean Values LABVIEW Core 1 Course Manual Complex Numbers Complex numbers are represented by two values linked together in memory—one representing the real part and one representing the imaginary part. In LabVIEW, because complex numbers are a type of floating-point number, complex numbers are also represented with the color orange. Complex Single (CSG)—Complex single-precision, floating-point numbers consist of real and imaginary values in 32, single-precision format. Complex Double (CDB)—Complex double-precision, floating-point numbers consist of real and imaginary values in 64-bit IEEE double-precision format, Complex Extended (CXT)—Complex extended-precision, floating-point numbers consist of real and imaginary values in IEEE extended-precision format. In memory, the size and precision of extended-precision numbers vary depending on the platform. In Windows, they have 80-bit IEEE. extended-precision format. LabVIEW stores Boolean data as 8-bit values. If the 8-bit value is zero, the Boolean value is FALSE. Any nonzero value represents TRUE. In LabVIEW, the color green represents Boolean data. Boolean values also have a mechanical action associated with them. The two major actions are latch and switch. You can select from the following button behaviors: * Switch when pressed—Changes the control value each time you click it with the Operating tool. The frequency with which the VI reads the control does not affect this behavior. + Switch when released—Changes the control value only after you release the mouse button during a mouse click within the graphical boundary of the control. The frequency with which the VI reads the control does not affect this behavior. + Switch until released—Changes the control value when you click itand retains the new value until you release the mouse button. At this time, the control reverts to its default value, similar to the operation of a door buzzer. The frequency with which the VI reads the control does not affect this behavior. You cannot select this behavior for a radio buttons control. an icon Bas eee ave eee ames eevee eee eae eee eee eee eee ec eee ee SER TEKEFKKTKEEVEKEEKTKTERKCESG Lesson 4 Implementing a 1 + Latch when pressed—Changes the control value when you click it and retains the new value until the VI reads it once. At this point, the control reverts to its default value even if you keep pressing the mouse button. This behavior is similar to a circuit breaker and is useful for stopping a While Loop or for getting the VI to perform an aetion only once each ime you set the control. You cannot select this behavior for a radio buttons control. + Latch when released—Changes the control value only after you release the mouse button within the graphical boundary of the control. When the VI reads it once, the control reverts to its default value. This behavior works in the same manner as dialog box buttons and system buttons, You cannot select this behavior for a radio buttons control. + Latch until released—Changes the control value when you click it and retains the value until the VI reads it once or you release the mouse button, depending on which one occurs last. You cannot select this behavior for a radio buttons control To learn more about mechanical action, experiment with the Mechanical Action of Booleans VI in the NI Example Finder. Visible hems Find Terminal Change to Indicator Description and Tp... Create Replace Data Operations Advanced Fit Control to Pane Seale Object with Pane Mechanical Acton 7}! Latch When Released Release Text Fu] Pes] PF poe) eed Properties Figure 4-6. Boolean Mechanical Action (© Nationa Instruments Corporation 413 {LabVIEW Core # Course Manual Lesson 4 Implementing a Vt Strings A string is a sequence of displayable or non-displayable ASCII characters. Strings provide a platform-independent format for information and data, Some of the more common applications of strings include the following: * Creating simple text messages. * Controlling instruments by sending text commands to the instrument and returning data values in the form of either ASCII or binary strings which you then convert to numeric values. + Storing numeric data to disk. To store numeric data in an ASCII file, you must first convert numeric data to strings before writing the data to a disk file. + Instructing or prompting the user with dialog boxes. On the front panel, strings appear as tables, text entry boxes, and labels, LabVIEW includes built-in VIs and functions you can use to manipulate strings, including formatting strings, parsing strings, and other editing. Refer to the ASCII Codes topic for more information about ASCII codes and conversion functions. In LabVIEW, strings are represented with the color pink. Right-click a string control or indicator on the front panel to select from the display types shown in the following table. The table also shows an example message in each display type. Display Type Description Message Normal Display Displays printable characters using the font of the control. Non-displayable characters generally appear as boxes. ‘There are four display types. \ is a backslash. “V Codes Display Displays backslash codes for all non-displayable characters. ‘There\sare\sfour\sdisplay\ stypes. \n\\\sis\sa\ sbackslash. Password Display Displays an asterisk (*) for each character including spaces. Hex Display Displays the ASCII value of each character in hex instead of the character itself. 5468 6572 6520 6172 6520 666F 7572 2064 6973 706C 6179 2074 7970 6573 2E0A 5c20 6973 2061 2062 6163 6B73 6C61 7368 2E LabVIEW Core 1 Course Manual 46 @ @@6@ 6660066 6 6666 68666 6 6 6 6 a | SRF TEEKEKETKEEKCKTEEEEUS Enums Lesson 4 implementing a Vt LabVIEW stores strings as a pointer to a structure that contains a 4-byte length value followed by a ID array of byte integers (8-bit characters), ‘An enum (enumerated control, constant or indicator) is a combination of data types. An enum represents a pair of values, a string and a numeric, where the enum can be one of a list of values. For example, if you created an enum type called Month, the possible value pairs fora Month variable are January-0, February-1, and so on through December- 1. Figure 4-7 shows an example of these data pairs in the Properties dialog box for an enumerated control. ‘EF Enum Properties: Month bg) ‘epewence | Data Type | Oevloy Format [Eaton | Docamertaton | Ostadl«{r'| Figure 4-7. Properties for the Month Enumerated Control (© Nationa latruments Corporation 415 LABVIEW Core 1 Course Manual Lesson 4 Implementing a Vt Enums are useful because it is easier to manipulate numbers on the block diagram than strings. Figure 4-8 shows the Month enumerated control, the selection of a data pair in the enumerated control, and the corresponding block diagram terminal. February March Apri May Dune uy August September October November December 1 Front Panel Control 2 Selecting an Item 3 Biock Diagram Terminal Dynamic cy ED LabVIEW Gore 1 Course Manual Figure 4-8. Month Enumerated Control ‘The dynamic data type stores the information generated or acquired by an Express VI. The dynamic data type appears as a dark blue terminal, shown at lefi. Most Express VIs accept and/or return the dynamic data type. You can wire the dynamic data type to any indicator or input that accepts numeric, waveform, or Boolean data. Wire the dynamic data type to an indicator that can best present the data. Indicators include graphs, charts, or numeric indicators. Most other VIs and functions in LabVIEW do not accept the dynamic data type. To use a built-in VI or function to analyze or process the data the dynamic data type includes, you must convert the dynamic data type. Use the Convert from Dynamic Data Express VI to convert the dynamic data type to numeric, Boolean, waveform, and array data types for use with other Vis and functions. When you place the Convert from Dynamic Data Express VI on the block diagram, the Configure Convert from Dynamic Data dialog box appears. The Configure Convert from Dynamic Data dialog box displays options that let you specify how you want to format the data that the Convert from Dynamic Data Express VI returns. 416 com FTVyyrveevvUvvevUvVveUeEeUveEEUEeERECECBECaeT aT SG . Lesson 4 Implementing a Vi When you wire a dynamic data type to an array indicator, LabVIEW automatically adds the Convert from Dynamic Data Express VI to the block diagram. Double-click the Convert from Dynamic Data Express VI to open the Configure Convert from Dynamic Data dialog box to control how the data appears in the array. C. Documenting Code Professional developers who maintain and modify VIs know the value of good documentation. Document the block diagram well to ease future modification of the code. In addition, document the front panel window well to explain the purpose of the VI and the front panel objects. Use tip strips, descriptions, VI Properties, and good design to document front panel windows. Tip Strips and Descriptions VI Properties Tip strips are brief descriptions that appear when you move the cursor over acontrol or indicator while a VI runs. For example, you might add a tip strip to indicate that a temperature is in degrees Celsius or explain how an input works in an algorithm. Descriptions provide additional information about specific controls and indicators. Descriptions appear in the Context Help window when you move the cursor over the object. To add tip strips and descriptions to controls, right-click the control or indicator and select Description and Tip from the shortcut menu. Use the Documentation component of the VI Properties dialog box to create VI descriptions and to link from VIs to HTML files or to compiled help files. To display VI Properties right-click the VI icon on the front panel or block diagram and select VI Properties from the shortcut menu or select File»VI Properties. Then select Documentation from the Categories drop-down menu. You cannot access this dialog box while a VI runs, This page includes the following components: * VI description—Contains the text that appears in the Context Help window if you move the cursor over the VI icon, Use and tags around any text in the description you want to format as bold. You also ccan use the VI Description property to edit the VI description programmatically. + Help tag—Contains the HTML filename or index keyword of the topic you want to link to in a compiled help file. You also can use the Help:Document Tag property to set the help tag programmatically. (© National Instruments Corporation 47 LabVIEW Gore 1 Course Manual Lesson 4 Implomentiag a VI + Help path—Contains the path to the HTML file or to the compiled help file you want to link to from the Context Help window. If this field is, empty, the Detailed help link does not appear in the Context Help window, and the Detailed help button is dimmed. + Browse—Displays a file dialog box to use to navigate to an HTML file or to a compiled help file to use as the Help path. Naming Controls and Indicators Giving controls and indicators logical and descriptive names adds usability to front panels. For example, if you name a control Temperature, user may not know which units to use. However, naming a control ‘Temperature °C adds more information to the front panel. You now know to enter temperatures in metric units. Graphical Programming While the graphical nature of LabVIEW aids in self-documentation of block diagrams, extra comments are helpful when modifying your VIs in the future. There are two types of block diagram comments—comments that describe the function or operation of algorithms and comments that explain the purpose of data that passes through wires. Both types of comments are shown in the following block diagram. You can insert standard labels with the Labeling tool, or by inserting a free label from the Functions» Programming»Structures»Decorations subpalette. By default, free labels have a yellow background color. Dom a > Process Variables > ea] —[Teaperatun (i ‘ulate the contra ouput For the Rx vessel temperatuxe| ire Data] Figu 4-9. Documenting a Block Diagram Use the following guidelines for commenting your VIs: + Use comments on the block diagram to explain what the code is doing. + While LabVIEW code can be self-documenting because it is graphical, use free labels to describe how the block diagram functions. ‘LabVIEW Core 1 Course Manual +18 com "@ @@ @eee+ e@eeee eegeee ea eee ea. SCCCCCCPeeeeeeeeeceeSeueed Lesson 4 Implementing V1 * Do not show labels on function and subVI calls because they tend to be large and unwieldy. A developer looking at the block diagram can find the name of a function or subVI by using the Context Help window. * Use small free labels with white backgrounds to label long wires to identify their use. Labeling wires is useful for wires coming from shift registers and for long wires that span the entire block diagram.Refer to the Case Structures section of this lesson for more information about shift registers. + Label structures to specify the main functionality of the structure. * Label constants to specify the nature of the constant. + Use free labels to document algorithms that you use on the block diagrams, If you use an algorithm from a book or other reference, provide the reference information. D. While Loops Similar to a Do Loop or a Repeat-Until Loop in text-based programming languages, a While Loop, shown in Figure 4-10, executes a subdiagram until a condition occurs. The following illustration shows a While Loop in LabVIEW, a flowchart equivalent of the While Loop functionality, and a pseudo code example of the functionality of the While Loop. No Repeat Constion| met? nes Condition mee: ® 1 LabVIEW While Loop 2 Flowchart 3 Pseudo Code Figure 4-10. While Loop ‘The While Loop is located on the Structures palette. Select the While Loop from the palette then use the cursor to drag a selection rectangle around the section of the block diagram you want to repeat. When you release the mouse button, a While Loop boundary encloses the section you selected. (© Nationa Instruments Corporation 419 LabVIEW Gore 1 Course Manual Lesson 4 Implementing a VI Add block diagram objects to the While Loop by dragging and dropping them inside the While Loop. @ Tip. The While Loop always executes at least once. LabVIEW Gore 1 Course Manual ‘The While Loop executes the subdiagram until the conditional terminal, an input terminal, receives a specific Boolean value. The conditional terminal in a While Loop behaves the same as in a For Loop with a conditional terminal. However, because the For Loop also includes a set iteration count, it does not run infinitely if the condition never occurs. The While Loop does not include a set iteration count and runs infinitely if the condition never occurs. Ifaconditional terminal is Stop if True, you place the terminal of a Boolean control outside a While Loop, and the control is FALSE when the loop starts, you cause an infinite loop, as shown in the following example. You also cause an infinite loop if the conditional terminal is Continue if True and the control outside the loop is set to TRUE. Changing the value of the control does not stop the infinite loop because the value is only read once, before the loop starts. To stop an infinite loop, you must abort the VI by clicking the Abort Execution button on the toolbar. You also can perform basic error handling using the conditional terminal of a While Loop. When you wire an error cluster to the conditional terminal, only the True or False value of the status parameter of the error cluster passes to the terminal. Also, the Stop if True and Continue if True shortcut ‘menu items change to Stop if Error and Continue while Error. The iteration terminal is an output terminal that contains the number of completed iterations. The iteration count for the Whi Loop always starts at zero. 420 icom CRE RRR RRR RRR eee eee eee | Structure Tunnels Lesson4 Implementing a VI In the following block diagram, the While Loop executes until the Random Number function output is greater than or equal to 0.9 and the Enable control is Prue. The And function returns True only if both inputs are ‘rue. Otherwise, it returns False In the following example, there is an increased probability of an infinite loop. Generally, the desired behavior is to have one condition met to stop the loop, rather than requiring both conditions to be met. Figure 4-11. Possible Infinite Loop Tunnels feed data into and out of structures. The tunnel appears as a solid block on the border of the While Loop. The block is the color of the data type wired to the tunnel. Data pass out of a loop after the loop terminates. ‘When a tunnel passes data into a loop, the loop executes only after data arrive at the tunnel. In the following block diagram, the iteration terminal is connected to a tunnel. The value in the tunnel does not get passed to the Iterations indicator until the While Loop finishes executing. enable Figure 4-12. While Loop Tunnel Only the last value of the iteration terminal displays in the Iterations indicator. (© National instruments Corporation 421 LabVIEW Core 1 Course Manual Lesson 4 Implementing a Vi Using While Loops for Error Handling LabVIEW Core 1 Course Manual ‘You can wire an error cluster to the conditional terminal of a While Loop or a For Loop with a conditional terminal to stop the iteration of the loop. If you wire the error cluster to the conditional terminal, only the TRUE or FALSE value of the status parameter of the error cluster passes to the terminal. If'an error occurs, the loop stops. In a For Loop with a conditional terminal, you also must wire a value to the count terminal or auto-index an input array to set a maximum number of iterations. The For Loop executes until an error occurs or until the number of set iterations completes. If you wire an error cluster to the conditional terminal, the shortcut menu items Stop if True and Continue if True change to Stop on Error and Continue while Error. In Figure 4-13, the error cluster and a stop button are used together to determine when to stop the loop. This is the recommended method for stopping most loops. Figure 4-13. Stopping a While Loop 422 icon DOPRHHHRHARAARARAAAAAAAAGsH SPOT TTEECEEEKEEKETEEEEEES E. For Loops Lesson 4 Implementing a V1 ‘A For Loop, shown as follows, executes a subdiagram a set number of times. Figure 4-14 shows a For Loop in LabVIEW, a flowchart equivalent of the For Loop functionality, and a pseudo code example of the functionality of the For Loop. nevo9) Uotit isn Bd T LabVIEW For Loop 2 Flowchart 3 Pseudo Code Figure 4-14, For Loop The For Loop is located on the Structures palette. You also can place a While Loop on the block diagram, right-click the border of the While Loop, and select Replace with For Loop from the shortcut menu to change a While Loop to a For Loop. The count terminal is an input terminal whose value indicates how many times to repeat the subdiagram. ‘The iteration terminal is an output terminal that contains the number of completed iterations. The iteration count for the For Loop always starts at zero. The For Loop differs from the While Loop in that the For Loop executes a set number of times. A While Loop stops executing the subdiagram only if the value at the conditional terminal exists. (© Nationa Instruments Corporation 423 LabVIEW Core t Course Manual Lesson 4 Implementing a VI : The For Loop in Figure 4-15 generates a random number every second for 100 seconds and displays the random numbers in a numeric indicator. [ f& apd nunbr (1) Randontarber teseatr a Figure 4-15. For Loop Example Adding a Conditional Terminal to a For Loop If necessary, you can add a conditional terminal to configure a For Loop to stop when a Boolean condition or an error occurs. A For Loop with a conditional terminal executes until the condition occurs or until al iterations are complete, whichever happens first. For Loops you configure for a conditional exit have a red glyph in the count terminal as well as a conditional terminal in the lower right comer. After you configure the For Loop to exit conditionally, the loop appears similar to Figure 4-16. ‘The following For Loop generates a random number every second until 100 seconds has passed or the user clicks the stop button. Figure 4-16. For Loop Configured for a Conditional Exit LaDVIEW Core # Course Manual 424 (ae @ 6 6 6 6 6. PUREE KTKTTEKEKKEEKCEEEY ‘Lesson 4 implementing 2 VI To add a conditional terminal to a For Loop, right-click on the For Loop border and select Conditional Terminal from the shortcut menu. Then wire the conditional terminal and the count terminal. apo tanbe (01) | sagan “ible Rome » bee Desctn and Te. se restzort | severine*| $ ‘Conditional Terninal | Resa wenWieicc | tenontoioe | id shee Reiter Figure 4-17. Adding a Conditional Terminal to a For Loop Numeric Conversion LabVIEW can represent numeric data types as signed or unsigned integers, floating-point numeric values, or complex numeric values, as discussed in the LabVIEW Dara Types section of this lesson. Normally, when you wire different representation types to the inputs of a function, the function returns an output in the larger or wider format. If you use a signed integer with an unsigned integer, it will coerce to the unsigned integer. If you use an unsigned integer with a floating point, it will coerce to the floating point. If you use a floating point number with a complex number, it will coerce to the complex number. If you use two numbers of the same type with different bit widths, LabVIEW will coerce to the larger of the two bit widths. If the number of bits is the same, LabVIEW chooses unsigned over signed integers. For example, if you wire a DBL and an 132 to a Multiply function, the result is a DBL, as shown in Figure 4-18. LabVIEW coerces the 32-bit signed integer because it uses fewer bits than the double- floating-point numeric value. The lower input of the Mu shows a red dot, called a coercion dot, that indicates LabVIEW coerced the data. (© Nationa Instruments Corporation 425 LabVIEW Core 1 Course Manual Lesson 4 Implementing a V1 DBL Numeric 132 Numeric 1 Coercion Dot Figure 4-18. Numeric Conversion Example However, the For Loop count terminal works in the opposite manner. If you wire a double-precision, floating-point numeric value to the 32-bit count terminal, LabVIEW coerces the larger numeric value to a 32-bit signed integer. Although the conversion is contrary to normal conversion standards, it is necessary, because a For Loop can only execute an integer number of times. 1 Coercion Dot LabVIEW Gore { Course Manual Figure 4-19. Coercion on a For Loop For better performance, avoid coercion by using matching data types or programmatically converting to matching data types, as shown in Figure 4-20. 7 lp age @ o Figure 4-20. Avoiding Coercion By Using Matching Data Types 426 icon QORGERAARRARGRRRGRR AER SH (RRR RRR RRR RR Ree Ree eee F. Timing a VI Lesson 4 implementing a Vi Wait Functions © When a loop finishes executing an iteration, itimmediately begins executing the next iteration, unless it reaches a stop condition, Most often, you need to control the iteration frequency or timing. For example, if you are acquiring data, and you want to acquire the data once every 10 seconds, you need a way to time the loop iterations so they occur once every 10 seconds. Even if you do not need the execution to occur at a certain frequency, you need to provide the processor with time to complete other tasks, such as responding to the user interface. This section introduces some methods for timing your loops. Place a wait function inside a loop to allow a VI to sleep for a set amount of time. This allows your processor to address other tasks during the wait time. Wait functions use the millisecond clock of the operating system. The Wait Until Next ms Multiple function monitors a millisecond counter and waits until the millisecond counter reaches a multiple of the amount you specify. Use this function to synchronize activities. Place this function ina loop to control the loop execution rate. For this function to be effective, your code execution time must be less than the time specified for this function. The execution rate for the first iteration of the loop is indeterminate. ‘The Wait (ms) function waits until the millisecond counter counts to an amount equal to the input you specify. This function guarantees that the loop execution rate is at least the amount of the input you specify. FY Note The ‘Time Delay Express VI behaves similarly to the Wait (ms) function with the addition of built-in error clusters. Refer to Lesson 3, Troubleshooting and Debugging Vis, for more information about error clusters. Elapsed Time In some cases, it is useful to determine how much time elapses after some point in your VI. The Elapsed Time Express VI indicates the amount of time that elapses after the specified start time. This Express VI keeps track of time while the VI continues to execute. This Express VI does not provide the processor with time to complete other tasks. You will use the Elapsed Time Express V1 in the Weather Station course project. (© National Instruments Corporation 427 LabVIEW Gore 1 Course Menus! Lesson 4 implementing 2 V1 G. Iterative Data Transfer When programming with loops, you often must access data from previous iterations of the loop in LabVIEW. For example, if you are acquiring one piece of data in each iteration of a loop and must average every five pieces of data, you must retain the data from previous iterations of the loop. BY Note Feedback Nodes are another method for retaining information from a previous iteration. Refer to the Feedback Node topic of the LabVIEW Help for more information about Feedback Nodes, LaDVIEW Gore 1 Course Manual Shift registers are similar to static variables in text-based programming languages. Use shift registers when you want to pass values from previous iterations through the loop to the next iteration. A shift register appears as a pair of terminals directly opposite each other on the vertical sides of the loop border. The terminal on the right side of the loop contains an up arrow and stores. data on the completion of an iteration. LabVIEW transfers the data connected to the right side of the register to the next iteration. After the loop executes, the terminal on the right side of the loop returns the last value stored in the shift register. Create a shift register by right-clicking the left or right border of a loop and selecting Add Shift Register from the shortcut menu. A shift register transfers any data type and automatically changes to the data type of the first object wired to the shift register. The data you wire to the terminals of each shift register must be the same type. You can add more than one shift register to a loop. If you have multiple operations that use previous iteration values within your loop, use multiple shift registers to store the data values from those different processes in the structure, as shown in the following figure. 428 com Ce ee eo eo oo rs r- s | ‘Lesson 4 Implementing a VI Figure 4-21. Using Multiple Shift Registers Initializing Shift Registers Initializing a shift register resets the value the shift register passes to the first iteration of the loop when the VI runs. Initialize a shift register by wiring a control or constant to the shift register terminal on the left side of the loop, as shown in Figure 4-22. lincrement 5 Figure 4-22. Initialized Shift Register In Figure 4-22, the For Loop executes five times, incrementing the value the shift register carries by one each time. Afier five iterations of the For Loop. the shift register passes the final value, 5, to the indicator and the VI quits. Each time you run the VI, the shift register begins with a value of 0. If you do not initialize the shift register, the loop uses the value written to the shift register when the loop last executed or, if the loop has never executed, the default value for the data type. © National rstruments Corporation 429 LabVIEW Core 1 Course Manual Lesson Inpomeninga vi : Use an uninitialized shift register to preserve state information between subsequent executions of a VI. Figure 4-23 shows an uninitialized shift register. fincrement, f—_>—__—_ ps2] a o Figure 4-23. Uninitiaized Shift Register In Figure 4-23, the For Loop executes five times, incrementing the value the shift register carries by one each time. The frst time you run the VI, the shift register begins with a value of 0, which is the default value for a 32-bit integer. After five iterations of the For Loop, the shift register passes the final value, 5, to the indicator, and the VI quits. The next time you run the « VI. the shift register begins with a value of 5, which was the last value from the previous execution. After five iterations of the For Loop, the shift register passes the final value, 10, to the indicator. If you run the VI again, registers retain the value of the previous iteration until you close the VI. LabVIEW Core Course Manual 430 ‘icon Ra RR RRR RRR RRR eee eee Lesson4 Implementing a V Stacked Shift Registers Stacked shift registers let you access data from previous loop iterations. Stacked shift registers remember values from multiple previous iterations and carry those values to the next iterations. To create a stacked shift register, right-click the left terminal and select Add Element from the shortcut menu Stacked shift registers can occur only on the left side of the loop because the right terminal transfers the data generated from only the current iteration to the next iteration, as shown in Figure 4-24 Figure 4-24. Using Stacked Shift Registers If you add another element to the left terminal in the previous block diagram, values from the last two iterations carry over to the next iteration, with the most recent iteration value stored in the top shift register. The bottom terminal stores the data passed to it from the previous iteration, (© Nationa instruments Corporation 430 LABVIEW Core 1 Course Manual Lesson 4 Implementing a VI H. Plotting Dat: Waveform Charts LabVIEW Core t Couse Manual a You already used charts and graphs to plot simple data. This section explains more about using and customizing charts and graphs. ‘The waveform chart is a special type of numeric indicator that displays one or more plots of data typically acquired at a constant rate. Waveform charts can display single or multiple plots. Figure 4-25 shows the elements of a multiplot waveform chart. Two plots are displayed: Raw Data and Running Avg. Pe Wavelorn Chart © 1 Label ‘3 X-scale 5 Graph Palette 2 Y-scale 4 Scale Legend 6 Plot Legend Figure 4-25. Waveform Charts Configure how the chart updates to display new data. Right-click the chart and select Advanced»Update Mode from the shortcut menu to set the chart update mode. The chart uses the following modes to display data: + Strip Chart—Shows running data continuously scrolling from left to right across the chart with old data on the left and new data on the right. A strip chart is similar to a paper tape strip chart recorder. Strip Chart is the default update mode. 432 com RAARAAARARARRAARRAAAR ARES! Lesson 4 Implementing a V1 + Scope Chart—Shows one item of data, such as a pulse or wave, scrolling partway across the chart from left to right, For each new value, the chart plots the value to the right of the last value. When the plot reaches the right border of the plotting area, LabVIEW erases the plot and begins plotting again from the left border. The retracing display of a scope chart is similar to an oscilloscope. + Sweep Chart—Works similarly to a scope chart except it shows the old data on the right and the new data on the left separated by a vertical line. LabVIEW does not erase the plot in a sweep chart when the plot reaches the right border of the plotting area, A sweep chart is similar to an EKG display. Figure 4-26 shows an example of each chart update mode. The scope chart and sweep chart have retracing displays similar to an oscilloscope. Because retracing a plot requires less overhead, the scope chart and the sweep chart display plots significantly faster than the strip chart. ae Tans er = . = | S| a 5 Lael || Figure 4-26. Chart Update Modes Wiring Charts You can wire a scalar output directly to a waveform chart, The waveform chart terminal shown in Figure 4-27 matches the input data type. Figure 4-27. Wiring a Single Plot to a Waveform Chart (© Nationa instruments Corporation 433 LaVIEW Gore 1 Course Manual Lesson 4 Implementing a i Waveform charts can display multiple plots together using the Bundle function located on the Cluster, Class & Variant palette. In Figure 4-28, the Bundle function bundles the outputs of the three VIs to plot on the waveform chart. Figure 4-28. Wiring Multiple Plots to a Waveform Chart The waveform chart terminal changes to match the output of the Bundle function. To add more plots, use the Positioning tool to resize the Bundle function. Refer to Lesson 5, Relating Data, for more information about the Bundle function. Waveform Graphs ‘Vis with a graph usually collect the data in an array and then plot the data to the graph. Figure 4-29 shows the elements of a graph. > wovetam ce O- mommy © g 1 Plot Legend 4 Mini-Grid Mark 7 Cursor Legend 10 Y-Scale 2 Cursor 5 Scale Legend 8 Graph Palette 11 Label 3. Grid Mark 6 Cursor Mover 9 X-Scale Figure 4-29. Waveform Graph LabVIEW Gore 1 Course Manuai 44 ico PROP AR RRA AR LER Ree eee eee ee ee ee ee ‘Lesson 4 implementing a VI ‘The graphs located on the Graph Indicators palette include the waveform graph and XY graph. The waveform graph plots only single-valued functions, as in y = £ (3c), with points evenly distributed along the x-axis, such as acquired time-varying waveforms. XY graphs display any set of points, evenly sampled or not. Resize the plot legend to display multiple plots. Use multiple plots to save space on the front panel and to make comparisons between plots. XY and waveform graphs automatically adapt to multiple plots. Single Plot Waveform Graphs ‘The waveform graph accepts several data types for single-plot waveform graphs. The graph accepts a single array of values, interprets the data as points on the graph, and increments the x index by one starting at x = 0. The graph accepts a cluster of an initial x value, a delta x, and an array of y data. The graph also accepts the waveform data type, which carries the data, start time, and delta t of a waveform. Refer to the Waveform Graph VI in the labview\examples\general\ graphs\gengraph.11b for examples of the data types that a waveform graph accepts. Multiplot Waveform Graphs The waveform graph accepts several data types for displaying multiple plots. The waveform graph accepts a 2D array of values, where each row of the array is a ingle plot. The graph interprets the data as points on the graph and increments the x index by one, starting at x = 0, Wire a 2D array data type to the graph, right-click the graph, and select Transpose Array from the shortcut menu to handle each column of the array as a plot. This is particularly useful when you sample multiple channels from a DAQ device because the device can return the data as 2D arrays with each channel stored as a separate column. Refer to the (Y) Multi Plot | graph in the Waveform Graph VI in the labview\examples\general \graphs\gengraph. 11» for an example of a graph that accepts this data type. ‘The waveform graph also accepts a cluster of an initial x value, a delta x value, and a 2D array of y data. The graph interprets the y data as points on the graph and increments the x index by delta x, starting at the initial x value. ‘This data type is useful for displaying multiple signals that are sampled at the same regular rate. Refer to the (Xo = 10, dX = 2, Y) Multi Plot 2 graph in the Waveform Graph VI in the labview\examples\general\ graphs\gengraph . 11b for an example of a graph that accepts this data type. (© National instruments Corporation 435 LabVIEW Core 1 Course Manual Lesson 4 Implementing a Vt LabVIEW Gore 1 Course Manual The waveform graph accepts a plot array where the array contains clusters, Each cluster contains a 1D array that contains the y data. The inner array describes the points in a plot, and the outer array has one cluster for each plot. The front panel in Figure 4-30 shows this array of the y cluster. ‘aay l cutee Figure 4-30. Array of the y Cluster Use a plot array instead of a 2D array if the number of elements in each plot is different. For example, when you sample data from several channels using different time amounts from each channel, use this data structure instead of a 2D array because each row of a 2D array must have the same number of elements. The number of elements in the interior arrays of an array of clusters can vary. Refer to the (Y) Multi Plot 2 graph in the Waveform Graph V1 in the labview\examples\general\graphs\gengraph. 11b for an example of a graph that accepts this data type. ‘The waveform graph accepts a cluster of an initial x value, a delta x value, and an array that contains clusters. Each cluster contains a 1D array that contains the y data. You use the Bundle function to bundle the arrays into clusters and you use the Build Array function to build the resulting clusters into an array. You also can use the Build Cluster Array function, which creates arrays of clusters that contain the inputs you specify. Refer to the (Xo = 10, dX =2, Y) Multi Plot 3 graph in the Waveform Graph VI in the labview\examples\general \graphs \gengraph. 11b for an ‘example of a graph that accepts this data type. The waveform graph accepts an array of clusters of an x value, a delta x value, and an array of y data. This is the most general of the multiple-plot waveform graph data types because you can indicate a unique starting point and increment for the x-scale of each plot. Refer to the (Xo = 10, dX = 2, Y) Multi Plot I graph in the Waveform Graph VI in the Laioview\examples\ general\graphs\gengraph. 11b for an example of a graph that accepts this data type. The waveform graph also accepts the dynamic data type, which is for use with Express Vis. In addition to the data associated with a signal, the dynamic data type includes attributes that provide information about the signal, such as the name of the signal or the date and time the data was acquired. Attributes specify how the signal appears on the waveform graph. When the dynamic data type includes multiple channels, the graph displays aplot for each channel and automatically formats the plot legend and x-scale time stamp. 436 icom ‘eee ene eogeaanen ee eae eae an ae ae @ ea. VPUUUUDUUEUUEEEUEEEEEEUCCES Lesson4 Implementing a V1 Single Plot XY Graphs The XY graph accepts three data types for single-plot XY graphs. The XY graph accepts a cluster that contains an.x array and a y array. Refer to the (X and Y arrays) Single Plot graph in the XY Graph VI in the Labview\ examples \general \graphs \gengraph. 11 foran example ofa graph that accepts this data type. The XY graph also accepts an array of points, where a point is a cluster that contains an x value and a y value. Refer to the (Array of Pts) Single Plot graph in the XY Graph VI in the labview\examples\general\ graphs \gengraph.11b for an example of a graph that accepts this data type. The XY graph also accepts an array of complex data, in which the real partis plotted on the x-axis and the imaginary part is plotted on the y-axis. Multiplot XY Graphs The XY graph accepts three data types for displaying multiple plots. The XY graph accepts an array of plots, where a plot is a cluster that contains an x array and a y array. Refer to the (X and Y arrays) Multi Plot graph in the XY Graph V1 in the labview\examples\general\graphs\ gengraph. 11b for an example of a graph that accepts this data type. The XY graph also accepts an array of clusters of plots, where a plot is an array of points. A point is a cluster that contains an x value and a y value. Refer to the (Array of Pts) Multi Plot graph in the XY Graph VI in the labview\examples\general graphs \gengraph. 11» for an example of a graph that accepts this data type. The XY graph also accepts an array of clusters of plots, where a plot is an array of complex data, in which the real partis plotted on the x-axis and the imaginary partis plotted on the y-axis. (© National instruments Corporation 437 LabVIEW Core 1 Course Manual is Boolean, the structure has a True case and a False case. If the selector terminal is an integer, string, or enumerated type value, the structure can have any number of cases. BZ Note By default, string values you wire to the selector terminal are case sensitive. To allow case-insensitive matches, wire a string value to the selector terminal, right-click the border of the Case structure, and select Case Insensitive Match from the shortcut menu. If you do not specify a default case for the Case structure to handle out-of-range values, you must explicitly list every possible input value. For example, if the selector is an integer and you specify cases for 1, 2, and 3, you must specify a default case to execute if the input value is 4 or any other unspecified integer value. BZ Note You cannot specify a default case if you wire a Boolean control to the selector. If you right-click the case selector label, Make This The Default Case does not appear in the shortcut menu. Make the Boolean control TRUE or FALSE to determine which case to execute. To convert a Case structure to a Stacked Sequence structure, right-click the Case Sequence structure and select Replace with Stacked Sequence from the shortcut menu, LabVIEW Core 1 Course Manual 438 icon Lesson implementing |. Case Structures ‘A Case structure has two or more subdiagrams, or cases. = Only one subdiagram is le at a time, and the structure executes only one case at a time. An input value determines which subdiagram executes. The Case structure is similar to switch statements or if...then...else statements in text-based programming languages. The case selector label at the top of the Case structure contains the name of the selector value that corresponds to the case in the center and decrement and increment arrows on each side. Click the decrement and increment arrows to scroll through the available cases. You also can click the down arrow next to the case name and select a case from the pull-down menu. a Wire an input value, or selector, to the selector terminal to determine which case executes. ‘You must wire an integer, Boolean value, string, or enumerated type value to the selector terminal. You can position the selector terminal anywhere on the left border of the Case structure. If the data type of the selector terminal ee Selecting a Case Lesson4 Implementing 2 Vi Right-click the Case structure border to add, duplicate, remove, or rearrange cases, and to select a default case. Figure 4-31 shows a VI that uses a Case structure to execute different code dependent on whether a user selects °C or °F for temperature units. The top block diagram shows the True case in the foreground. In the middle block diagram, the False case is selected. To select a case, enter the value in the case selector identifier or use the Labeling tool to edit the values. After you select another case, that case displays on the block diagram, as shown in the bottom block diagram of Figure 4-31. Figure 4-31. Changing the Case View of a Case Structure If you enter a selector value that is not the same type as the object wired to the selector terminal, the value appears red. This indicates that the VI will not run until you delete or edit the value. Also, because of the possible round-off error inherent in floating-point arithmetic, you cannot use floating-point numbers as case selector values. If you wire a floating-point value to the case, LabVIEW rounds the value to the nearest integer. If you type a floating-point value in the case selector label, the value appears red to indicate that you must delete or edit the value before the structure can execute (© National instruments Corporation 439 LabVIEW Core 1 Course Manual Lesson Input and Output Tunnels Examples LabVIEW Gore 1 Course Manual You can create multiple input and output tunnels for a Case structure. Inputs are available to all cases, but cases do not need to use each input. However, you must define an output tunnel for each case. Consider the following example: a Case structure on the block diagram has an output tunnel, but in at least one of the cases, there is no output value wired to the tunnel. If you run this case, LabVIEW does not know what value to return for the output, LabVIEW indicates this error by leaving the center of the tunnel white. The unwired case might not be the case that is, currently visible on the block diagram. To correct this error, display the case(s) that contain(s) the unwired output tunnel and wire an output to the tunnel. You also can right-click the output tunnel and select Use Default If Unwired from the shortcut menu to use the default value for the tunnel data type for all unwired tunnels. When the output is wired in all cases, the output tunnel is a solid color. Avoid using the Use Default If Unwired option. Using this option does not document the block diagram well, and can confuse other programmers using your code. The Use Default If Unwired option also makes debugging code difficult. If you use this option, be aware that the default value used is the default value for the data type that is wired to the tunnel. For example, if the tunnel is a Boolean data type, the default value is FALSE. Refer to Table 4-1 for a list of default values for data types. Table 4-1. Data Type Default Values Data Type Default Value Numeric 0 Boolean FALSE Suing empty ("") | In the following examples, the numeric values pass through tunnels to the Case structure and are either added or subtracted, depending on the value wired to the selector terminal 40 ‘com S2ea RRR RRR RRR Ree ee eee Oe Oe Lesson 4 Inpementing a VI Boolean Case Structure Figure 4-32 shows a Boolean Case structure. The cases overlap each other to simplify the illustration. Figure 4-32. Boolean Case Structure Ifthe Boolean control wired to the selector terminal is True, the VI adds the numeric values. Otherwise, the VI subtracts the numeric values. In situations where you are simply choosing between two values based on a boolean input, a Select statement can be used rather than a Boolean Case structure. Integer Case Structure Figure 4-33 shows an integer Case structure. Figure 4-33. Integer Case Structure Integer is a text ring control located on the Text Controls palette that associates numeric values with text items, If the Integer wired to the selector terminal is 0 (add), the VI adds the numeric values. If the value is 1 (subtract), the VI subtracts the numeric values. If Integer is any other value than 0 (add) or 1 (subtract), the VI adds the numeric values, because that is the default case. (© National Instruments Corporation 1 {LaDVIEW Core 1 Course Manuas Lesson4 Implementing a LabVIEW Gore 1 Course Manual String Case Structure Figure 4-34 shows a string Case structure. Figure 4-34. String Case Structure If String is ada, the VI adds the numeric values. If String is subtract, the VI subtracts the numeric values. Enumerated Case Structure Figure 4-35 shows an enumerated Case structure, Figure 4-35. Enumerated Case Structure An enumerated type control gives users a list of items from which to select. The data type of an enumerated type control includes information about the numeric values and string labels in the control. The case selector displays the string label for each item in the enumerated type control when you select Add Case For Every Value from the Case structure shortcut menu. The Case structure executes the appropriate case subdiagram based on the current item in the enumerated type control. In the previous block diagram, if Enum is ada, the VI adds the numeric values. If Enum is subtract, the VI subtracts the numeric values 440 si.com Saisie eee eg ecm eeeeR cAsecmeeeeeee MMMM A rcmcceAMMMe eo to ee tot Lesson 4 smplementing 2 V1 Using Case Structures for Error Handling The following example shows a Case structure where an error cluster defines the cases. RES ease |nesrenet rie | Hoven Gach Sn PeotieIfy ence (roetre) Figure 4-37. Error Case When you wire an error cluster to the selector terminal of a Case structure, the case selector label displays two cases—Brror andNo Error—and the border of the Case structure changes color—red for Error and green for No Error. If an error occurs, the Case structure executes the Error subdiagram, ‘When you wire an error cluster to the selection terminal, the Case structure recognizes only the status Boolean element of the cluster. (© National instruments Corporation +43 LABVIEW Core 1 Course Manual SS&eeoewvwveovreurvuuvueuvuuvuuvoUuU YY Lesson 4 Implementing a VI Self-Review: Quiz 1. Which identifies the control or indicator on the block diagram? a. Caption b. Location c. Label 4. Value 2. Which structure must run at least one time? a. While Loop b. For Loop 3. Which is only available on the block diagram? a. Control b. Constant c. Indicator 4 . Connector pane 4, Which mechanical action causes a Boolean control in the False state to change to True when you click it and stay True until you release it and LabVIEW has read the value? a. Switch until released b, Switch when released c. Latch until released d. Latch when released (© National nstrumonts Corporation 445 L2DVIEW Core 1 Course Manual PeececcecCeeeeeueeeese eee GY Lesson 4 Implementing a VI Quiz Answers 1. Which identifies the control or indicator on the block diagram? a. Caption b. Location c. Label d. Value 2. Which structure must run at least one time? a. While Loop b. For Loop 3. Which is only available on the block diagram? a, Control b. Constant c. Indicator . Connector pane 4, Which mechanical action causes a Boolean control in the False state to change to True when you click it and stay True until you release it and LabVIEW has read the value? a. Switch until released b. Switch when released c. Latch until released d. Latch when released (© National nstuments Corporation “a7 LabVIEW Gore 1 Course Manual BPURUUBUVEUVUEUUUEUUUEeueuuU Relating Data Sometimes it is beneficial to group data related to one another. Use arrays and clusters to group related data in LabVIEW. Arrays combine data of the same data type into one data structure, and clusters combine data of multiple data types into one data structure. Use type definitions to define custom arrays and clusters. This lesson explains arrays, clusters, and type definitions, and applications where using these can be beneficial. Topics A. Arrays B. Clusters C. Type Definitions © Naton stamens Coporaion + (EW Core 1 ouse Mana! Lesson 5 Relating Data A. Arrays An array consists of elements and dimensions. Elements are the data that make up the array. A dimension is the length, height, or depth of an array. Anarray can have one or more dimensions and as many as (25!) — 1 elements per dimension, memory permitting. You can build arrays of numeric, Boolean, path, string, waveform, and cluster data types. Consider using arrays when you work with a collection of similar data and when you perform repetitive computations. Arrays are ideal for storing data you collect from waveforms or data generated in loops, where each iteration of a loop produces one element of the array. FJ Note Array indexes in LabVIEW are zero-based. The index of the first element in the array, regardless of its dimension, is zero. LabVIEW Gore 1 Course Manual Restrictions You cannot create arrays of arrays, However, you can use a multidimensional array or create an array of clusters where each cluster contains one or more arrays. Also, you cannot create an array of subpanel controls, tab controls, NET controls, ActiveX controls, charts, or multiplot XY graphs. Refer to the clusters section of this lesson for more information about clusters. ‘An example of a simple array is a text array that lists the twelve months of the year. LabVIEW represents this as a 1D array of strings with twelve elements. Array elements are ordered. An array uses an index so you can readily access any particular element. The index is zero-based, which means it is in the range 0 to m ~ 1, where n is the number of elements in the array. For example, n = 12 for the twelve months of the year, so the index ranges from 0 to 11. March is the third month, so it has an index of 2. 52 com RERRERRARRARARARAAAAARARGS, ee ee et Lesson Relating Data Figure 5-1 shows an example of an array of numerics, The first element shown in the array (3.00) is at index 1, and the second element (1.00) is at index 2. The element at index 0 is not shown in this image, because element | is selected in the index display. The element selected in the index display always refers to the element shown in the upper left corner of the clement display. 1 _ Index Display 2 Element Display Figure 5-1. Array Control of Numerics Creating Array Controls and Indicators Create an array control or indicator on the front panel by adding an array shell to the front panel, as shown in the following front panel, and dragging a data object or element, which can be a numeric, Boolean, string, path, refnum, or cluster control or indicator, into the array shell. Figure 5-2. Placing a Numeric Control in an Array Shell If you attempt to drag an invalid control or indicator into the array shell, you are unable to place the control or indicator in the array shell ‘You must insert an object in the array shell before you use the array on the block diagram. Otherwise, the array terminal appears black with an empty bracket and has no data type associated with it (© Nationa Instruments Corporation 53 LabVIEW Gore 1 Course Manual Lesson 5 LabVIEW Core 1 Course Manual Relating Data Two-Dimensional Arrays The previous examples use 1D arrays. A 2D array stores elements in a grid, Itrequires a column index and a row index to locate an element, both of which are zero-based. Figure 5-3 shows an 8 column by 8 row 2D array, which contains 8 x 8 = 64 elements. Column Index Opa aa or Oat Row index Figure 5-3. 20 Array To add a multidimensional array to the front panel, right-click the index display and select Add Dimension from the shortcut menu. You also can resize the index display until you have as many dimensions as you want. Initializing Arrays You can initialize an array or leave it unitialized. When an array is initialized, you defined the number of elements in each dimension and the contents of each element. An uninitialized array contains a fixed number of dimensions but no elements. Figure 5-4 shows an uninitialized 2D array control. Notice that the elements are all dimmed. This indicates that the array is uninitialized. Figure 5-4. 2D Uninitialized Array a ricom PRR RR ARR RR Lesson Relating Cate In Figure 5-5, six elements are initialized, Figure 5-5. An initialized 20 Array with Six Elements Ina 2D array, after you initialize an element in a row, the remaining elements in that row are initialized and populated with the default value for the data type. For example, in Figure 5-6, if you enter 4 into the clement in the first column, third row, the elements in the second and third column in the third row are automatically populated with a 0. Figure 5-6, An Array That Has Been Autopopulated with Zeroes Creating Array Constants To create an array constant on the block diagram, select an array constant on the Functions palette, place the array shell on the block diagram, and place a string constant, numeric constant, a Boolean constant, or cluster constant in the array shell. You can use an array constant to store constant data or as a basis for comparison with another array. Auto-Indexing Array Inputs Ifyou wire an array to or from a For Loop or While Loop, you can link each iteration of the loop to an element in that array by enabling auto-indexing The tunnel image changes from a solid square to the image to indicate auto-indexing. Right-click the tunnel and select Enable Indexing or Disable Indexing from the shortcut menu to toggle the state of the tunnel (© Nationa Instruments Corporation 55 LADWIEW Core 1 Course Manual Lesson 5 Relating Data LabVIEW Core Course Manual Array Inputs If you enable auto-indexing on an array wired to a For Loop input terminal, LabVIEW sets the count terminal to the array size so you do not need to wire the count terminal. Because you can use For Loops to process arrays ‘one element at a time, LabVIEW enables auto-indexing by default for every array you wire to a For Loop. You can disable auto-indexing if you do not need to process arrays one element at a time. In Figure 5-7, the For Loop executes a number of times equal to the number of elements in the array. Normally, if the count terminal of the For Loop is not wired, the run arrow is broken. However, in this case the run arrow is not broken. (iit ind np Bick Digan icles Ge ER Sew Bone Grae Tob naw Bb =| pele (Eafe * [Sereremenree sox) Figure 5-7. Array Used to Set For Loop Count Ifyou enable auto-indexing for more than one tunnel or if you wire the count terminal, the actual number of iterations becomes the smaller of the choices. For example, if two auto-indexed arrays enter the loop, with 10 and 20 elements respectively, and you wire a value of 15 to the count terminal, the loop still only executes 10 times, indexing all elements of the first array but only the first 10 elements of the second array. 56 ico PQRRRALAAAA APP iBSSCeseeeeeeeeeeeeeeeeveagse Lesson 5 Relating Data Array Outputs When you auto-index an array output tunnel, the output array receives anew element from every iteration of the loop. Therefore, auto-indexed output arrays are always equal in size to the number of iterations. The wire from the output tunnel to the array indicator becomes thicker as it changes to an array at the loop border, and the output tunnel contains square brackets representing an array, as shown Figure 5-8, Random Number (0-1) Figure 5-8. Auto-Indexed Output Right-click the tunnel at the loop border and select Enable Indexing ot Disable Indexing from the shortcut menu to enable or disable auto-indexing, Auto-indexing for While Loops is disabled by default. For example, disable auto-indexing if you need only the last value passed out of the tunnel. Creating Two-Dimensional Arrays ‘You can use two For Loops, nested one inside the other, to create a 2D array. The outer For Loop creates the row elements, and the inner For Loop creates the column elements, as shown in Figure 5-9, Figure §-9. Creating a 2D Array (© Nationa Instruments Corporation 87 {LabVIEW Core 1 Course Manual Lesson 5 Relating Data B. Clusters Clusters group data elements of mixed types. An example of a cluster is the LabVIEW error cluster, which combines a Boolean value, a numeric value, and a string, A cluster is similar to a record or a struct in text-based programming languages. Bundling several data elements into clusters eliminates wire clutter on the block diagram and reduces the number of connector pane terminals that subVIs need. The connector pane has, at most, 28 terminals. If your front panel contains more than 28 controls and indicators that you want to pass to another VI, group some of them into a cluster and assign the cluster to a terminal on the connector pane. Most clusters on the block diagram have a pink wire pattern and data type terminal. Error clusters have a dark yellow wire pattern and data type terminal. Clusters of numeric values, sometimes referred to as points, have a brown wire pattern and data type terminal. You can wire brown numeric clusters to Numeric functions, such as Add or Square Root, to perform the same operation simultaneously on all elements of the cluster. Order of Cluster Elements Although cluster and array elements are both ordered, you must unbundle all cluster elements at once using the Unbundle function. You can use the Unbundle By Name function to unbundle cluster elements by name. If you use the Unbundle by Name function, each cluster element must have a label. Clusters also differ from arrays in that they are a fixed size. Like an array, a cluster is either a control or an indicator. A cluster cannot contain a mixture of controls and indicators. Creating Cluster Controls and Indicators LabVIEW Core 5 Course Manual Create a cluster control or indicator on the front panel by adding a cluster shell to the front panel, as shown in the following front panel, and dragging a data object or element, which can be a numeric, Boolean, string, path, refnum, array, or cluster control or indicator, into the cluster shell. Resize the cluster shell by dragging the cursor while you place the cluster shell. 58 icon ppp a eae a ease saa aaaa a a ¢ ¢| @e@eegceeeeceeedeseeaeeeeucaud Lesson Relating Data Figure 5-10. Creation of a Cluster Control Figure 5-11 is an example of a cluster containing three controls: a string, a Boolean switch, and a numeric. A cluster is either a control or an indicator; it cannot contain a mixture of controls and indicators. sae eotunet? ‘ime Figure 5-11. Cluster Control Example Creating Cluster Constants Cluster Order To create a cluster constant on the block diagram, select a cluster constant on the Functions palette, place the cluster shell on the block diagram, and place a string constant, numeric constant, a Boolean constant, or cluster constant in the cluster shell. You can use a cluster constant to store constant data or as a basis for comparison with another cluster. If you have a cluster control or indicator on the front panel window and you want to create a cluster constant containing the same elements on the block diagram, you can either drag that cluster from the front panel window to the block diagram or right-click the cluster on the block diagram and select Create»Constant from the shortcut menu. Cluster elements have a logical order unrelated to their position in the shell. ‘The first object you place in the cluster is element 0, the second is element 1, and so on. If you delete an element, the order adjusts automatically. The cluster order determines the order in which the elements appear as terminals on the Bundle and Unbundle functions on the block diagram. You can view and modify the cluster order by right-clicking the cluster border and selecting Reorder Controls In Cluster from the shortcut menu. (© Nationa! instruments Corporation 59 LabVIEW Core 1 Course Manval Lesson Relating Data The toolbar and cluster change, as shown in Figure 5-12. 1 Confirm Button 3 Cluster Order Cursor 5 New Order 2 Cancel Button 4 Current Order Figure 5-12. Reordering a Cluster The white box on each element shows its current place in the cluster order. The black box shows the new place in the order for an element. To set the order of a cluster element, enter the new order number in the Click to set to text box and click the element. The cluster order of the element changes, and the cluster order of other elements adjusts. Save the changes by clicking the Confirm button on the toolbar. Revert to the original order by clicking the Cancel button. Using Cluster Functions LabVIEW Core 1 Course Manual Use the Cluster functions to create and manipulate clusters. For example, you can perform tasks similar to the following: + Extract individual data elements from a cluster. * Add individual data elements to a cluster. * Break a cluster out into its individual data elements. Use the Bundle function to assemble a cluster, use the Bundle function and Bundle by Name function to modify a cluster, and use the Unbundle function and the Unbundle by Name function to disassemble clusters, You also can place the Bundle, Bundle by Name, Unbundle, and Unbundle by Name functions on the block diagram by right-clicking a cluster terminal on the block diagram and selecting Cluster, Class & Variant Palette from the shortcut menu. The Bundle and Unbundle functions automatically 510 icom RRRARARARARAARAARAARARARARAR, Lesson Relating Data contain the correct number of terminals. The Bundle by Name and Unbundle by Name functions appear with the first element in the cluster. Use the Positioning tool to resize the Bundle by Name and Unbundle by Name functions to show the other elements of the cluster. Assembling Clusters Use the Bundle function to assemble a cluster from individual elements or to change the values of individual elements in an existing cluster without having to specify new values for all elements. Use the Positioning tool to resize the function or right-click an element input and select Add Input from the shortcut menu, ew coneand nto chaste areas) ‘rca cee Figure 5-13. Assembling a Cluster on the Block Diagram Modifying a Cluster If you wire the cluster input, you can wire only the elements you want to change. For example, the Input Cluster shown in Figure 5-14 contains three controls. Figure 5-14. Bundle Used to Modify a Cluster If you know the cluster order, you can use the Bundle function to change the Command value by wiring the elements shown in Figure 5-14, You can also use the Bundle by Name function to replace or access labeled elements of an existing cluster. The Bundle by Name function works like the Bundle function, but instead of referencing cluster elements by their cluster order, it references them by their owned labels. You can access only elements with owned labels. The number of inputs does not need to match the number of elements in output cluster. (© National instruments Corporation 511 LabVIEW Core 5 Course Manual Lesson 5 LabVIEW Core 1 Course Manual Rotating Data Use the Operating too! to click an input terminal and select an element from the pull-down menu. You also can right-click the input and select the element from the Select Item shortcut menu. In Figure 5-15, you can use the Bundle by Name function to update the values of Command and Function with the values of New Command and New Function. npr chster New command Sunde By Hare Figure 5-15. Bundle By Name Used to Modify a Cluster Use the Bundle by Name function for data structures that might change during development. If you add a new element to the cluster or modify its order, you do not need to rewire the Bundle by Name function because the names are still valid. Disassembling Clusters Use the Unbundle function to split a cluster into its individual elements. Use the Unbundle by Name function to return the cluster elements whose names you specify. The number of output terminals does not depend on the number of elements in the input cluster. Use the Operating tool to click an output terminal and select an element from the pull-down menu. You also can right-click the output terminal and select the element from the Select Item shortcut menu. For example, if you use the Unbundle function with the cluster in Figure 5-16, it has four output terminals that correspond to the four controls in the cluster. You must know the cluster order so you can associate the correct Boolean terminal of the unbundled cluster with the corresponding switch in the cluster. In this example, the elements are ordered from top to bottom starting with element 0. If you use the Unbundle by Name function, you can have an arbitrary number of output terminals and access individual elements by name in any order. 512 ‘icon ‘Peper PrePHRAAAARARARARAAR eg: ee | Error Clusters Lesson 5 Relating Data opicare Chater Figure 5-16. Unbundle and Unbundle By Name LabVIEW contains a custom cluster called the error cluster. LabVIEW uses error clusters to pass error information. An error cluster contains the following elements: + status—Boolean value that reports TRUE if an error occurred, + code—32-bit signed integer that identifies the error numerically. + source—String that identifies where the error occurred. For more information about using error clusters, refer to Lesson 3, Troubleshooting and Debugging Vis, of this manval and the Handling Errors topic of the LabVIEW Help. (© Nationa instruments Corporation a8 LABVIEW Core $ Course Manus) Lesson § Relating Data C. Type Definitions Custom Controls SN {LabVIEW Core 5 Course Manual You can use type definitions to define custom arrays and clusters, Use custom controls and indicators to extend the available set of front panel objects. You can create custom user interface components for an application that vary cosmetically from built-in LabVIEW controls and indicators. You can save a custom control or indicator you created in a directory or LLB and use the custom control or indicator on other front panels. You also can create an icon for the custom control or indicator and add it to the Controls palette. Refer to the Creating Custom Controls, Indicators, and Type Definitions topic of the LabVIEW Help for more information about creating and using custom controls and type definition: Use the Control Editor window to customize controls and indicators. For example, you can change the size, color, and relative position of the elements of a control or indicator and import images into the control or indicator. You can display the Control Editor window in the following ways: + Right-click a front panel control or indicator and select Advanced» Customize from the shortcut menu. ‘= Use the Positioning tool to select a front panel control or indicator and select Edit»Customize Control. ‘+ Use the New dialog box. ‘The Control Editor appears with the selected front panel object in its window. The Control Editor has two modes, edit mode and customize mode. ‘The Control Editor window toolbar indicates whether you are in edit mode or incustomize mode. The Control Editor window opens in edit mode. Click the Change to Customize Mode button to change to customize mode. To change back to edit mode, click the Change to Edit Mode button. You also ‘can switch between modes by selecting Operate»Change to Customize Mode or Operate»Change to Edit Mode. Use edit mode to change the size or color of a control or indicator and to select options from its shortcut menu, just as you do in edit mode on a front panel. Use customize mode to make extensive changes to controls or indicators by changing the individual parts of a control or indicator. 514 ‘com SS@eueeeeeeeeeeeee edd & G Lesson Relating Data Edit Mode In the edit mode, you can right-click the control and manipulate its settings as you would in the LabVIEW programming environment. Flee eT | T @ ® 1 Edit Mode 5 Distribute Objects 2 Type Definition Status 6 Resize Objects 3 Text 7 Reorder Objects 4. Align Objects Customize Mode In the customize mode, you can move the individual components of the control around with respect to each other. For a listing of what you can manipulate in customize mode, select Window»Show Parts Window. Z| [contrat +] [et areicaton Fort = ][Box [ae i fo Ed ® z ® ®©®@ 1 Customize Mode 5 Distribute Objects 2 Type Definition Status 6 Resize Objects 3 Text 7 Reorder Objects 4 Align Objects One way to customize a control is to change its type definition status. You can save a control as a control, a type definition, or a strict type definition, depending on the selection visible in the Type Def. Status ring. The control option is the same as a control you would select from the Controls palette. You can modify it in any way you need to, and each copy you make and change retains its individual properties. Saving Custom Controls After creating a custom control, you can save it for use later. By default, controls saved on disk have a . ct 1 extension. You also can use the Control Editor to save controls with your own default settings. For example, you can use the Control Editor to modify the defaults of a waveform graph, save it, and later recall it in other VIs © National instauments Corporation 515 LabVIEW Gore 1 Course Manual, Lesson 5 Relating Data Type Definitions LabVIEW Core 1 Course Manual Use type definitions and strict type definitions to link all the instances of a custom control or indicator to a saved custom control or indicator file. You ‘can make changes to all instances of the custom control ot indicator by editing only the saved custom control or indicator file, which is useful if you use the same custom control or indicator in several VIs. When you place a custom control or indicator in a VI, no connection exists between the custom control or indicator you saved and the instance of the custom control or indicator in the VI. Each instance of a custom control or indicator is a separate, independent copy. Therefore, changes you make toa custom control or indicator file do not affect VIs already using that custom control or indicator. If you want to link instances of a custom control or indicator to the custom control or indicator file, save the custom control or indicator as a type definition or strict type definition, All instances of a type definition or a strict type definition link to the original file from which you created them. When you save a custom control or indicator as a type definition or strict type definition, any data type changes you make to the type definition or strict type definition affect all instances of the type definition or strict type definition in all the VIs that use it. Also, cosmetic changes you make to a strict type definition affect all instances of the strict type definition on the front panel. ‘Type definitions identify the correct data type for each instance of a custom control or indicator. When the data type of a type definition changes, all instances of the type definition automatically update. In other words, the data type of the instances of the type definition change in each VI where the lype definition is used. However, because type definitions identify only the data type, only the values that are part of the data type update. For example, on numeric controls, the data range is not part of the data type. Therefore, type definitions for numeric controls do not define the data range for the instances of the type definitions. Also, because the item names in ring controls do not define the data type, changes to ring control item names in aa type definition do not change the item names in instances of the type definition. However, if you change the item names in the type definition for an enumerated type control, the instances update because the item names are part of the data type. An instance of a type definition can have its own unique caption, label, description, tip strip, default value, size, color, or style of control or indicator, such as a knob instead of a slide. 516 icon TOGRERERRER RA ee oe oe eo et oe Oe er ee ee ee ee er | Lesson Relating Data If you change the data type in a type definition, LabVIEW converts the old default value in instances of the type definition to the new data type, if possible. LabVIEW cannot preserve the instance default value if the data type changes to an incompatible type, such as replacing a numeric control or indicator with a string control or indicator. When the data type of a type definition changes to a data type incompatible with the previous type definition, LabVIEW sets the default value of instances to the default value you specify in the . ct1 file. If you do not specify a default value, LabVIEW uses the default value for the data type. For example, if you change a type definition from a numeric to a string type, LabVIEW replaces any default values associated with the old numeric data type with empty strings. Strict Type Definitions A strict type definition forces everything about an instance to be identical to the strict type definition, except the caption, label, description, tip strip, and default value. As with type definitions, the data type of a strict type definition remains the same everywhere you use the strict type definition. Strict type definitions also define other values, such as range checking on numeric controls and the item names in ring controls. The only VI Server properties available for strict type definitions are those that affect the appearance of the control or indicator, such as Visible, Disabled, Key Focus, Blinking, Position, and Bounds. You cannot prevent an instance of a strict type definition from automatically updating unless you remove the link between the instance and the strict type definition. ‘Type definitions and strict type definitions create a custom control using a cluster of many controls. If you need to add a new control and pass a new value to every subVI, you can add the new control to the custom control cluster. This substitutes having to add the new control to the front panel of each subVI and making new wires and terminals. (© Nationa instruments Corporation oa LabVIEW Goro f Course Manual Se ee ie i ee ee ee ee ee ee ee oe oe er ee | Lesson Relating Data Self-Review: Quiz You can create an array of arrays. a. True b. False You have two input arrays wired to a For Loop. Auto-indexing is enabled on both tunnels. One array has 10 elements, the second array has five elements. A value of 7 is wired to the Count terminal, as shown in Figure 5-17. What is the value of the Iterations indicator after running this VI? fay JOeker ray eae) Rewene deo aey o oo fs p {© National instruments Corporation Figure 5-17. What is the Value of the Iteration Indicator? You customize a control, select Control from the Control Type pull-down menu, and save the control as a .ct1 file. You then use an instance of the custom control on your front panel window, If you open the .ct1 file and modify the control, does the control on the front panel window change? a. Yes b. No You are inputting data that represents a circle. The circle data includes three double precision numerics: x position, y position and radius. In the future, you might need to expand all instances of the circle data to include the color of the circle, represented as an integer. How should you represent the circle on your front panel window? a. Three separate controls for the two positions and the radius. b. A cluster containing all of the data. c. A custom control containing a cluster, 4. A type definition containing a cluster. e. An array with three elements. 519 LabVIEW Gore 1 Course Manual a ee oe ee i ee | Lesson Relating Dat Self-Review: Quiz Answers 1. You can create an array of arrays. a. True b. False You cannot drag an array data type into an array shell. However, you can create two-dimensional arrays, You have two input arrays wired to a For Loop. Auto-indexing is enabled on both tunnels, One array has 10 elements, the second array has five elements. A value of 7 is wired to the Count terminal, as shown in the following figure. What is the value of the Iterations indicator after running this VI? Figure 5-18. What is the value of the Iteration indicator? Value of Iterations = 4 LabVIEW does not exceed the array size. This helps to protect against programming error. LabVIEW mathematical functions work the same way—if you wire a 10 clement array to the x input of the Add function, and a 5 element array to the y input of the Add function, the output is a 5 element array. Although the for loop runs 5 times, the iterations are zero based, therefore the value of the Iterations indicators is 4. 3. You customize a control, select Control from the Control Type pull-down menu, and save the control as a .ct file. You then use an instance of the custom control on your front panel window. If you open the .ct 1 file and modify the control, does the control on the front panel window change? a. Yes b. No (© National instruments Corporation 52 LabVIEW Core 1 Course Manual Lesson Relating Data LABVIEW Core 1 Course Manual You are inputting data that represents a circle. The circle data includes three double precision numerics: x position, y position and radius. In the future, you might need to expand all instances of the circle data to include the color of the circle, represented as an integer. How should you represent the circle on your front panel window? a. Three separate controls for the two positions and the radius. b. Accluster containing all of the data. c. A custom control containing a cluster. d. A type definition containing a cluster. e. An array with three elements. 522 icom

You might also like