文档库 最新最全的文档下载
当前位置:文档库 › labview_basics_1_sample

labview_basics_1_sample

S a m p l e LabVIEW TM

Basics I Introduction Course Manual Course Software Version 8.0

May 2006 Edition

Part Number 320628P-01

Copyright

? 1993–2006 National Instruments Corporation. All rights reserved. Under the copyright laws, this publication may not be reproduced or transmitted in any form, electronic or mechanical, including photocopying, recording, storing in an information retrieval system, or translating, in whole or in part, without the prior written consent

of National Instruments Corporation.

National Instruments respects the intellectual property of others, and we ask our users to do 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 only to reproduce materials that you may reproduce in accordance with the terms of any applicable license or other legal restriction.

In regards to components used in USI (Xerces C++, ICU, and HDF5), the following copyrights apply. For a listing of the conditions and disclaimers, refer to the USICopyrights.chm .

This product includes software developed by the Apache Software Foundation (http:/https://www.wendangku.net/doc/235979650.html,/).Copyright ? 1999 The Apache Software Foundation. All rights reserved.

Copyright ? 1995–2003 International Business Machines Corporation and others. All rights reserved. NCSA HDF5 (Hierarchical Data Format 5) Software Library and Utilities

Copyright 1998, 1999, 2000, 2001, 2003 by the Board of Trustees of the University of Illinois. All rights reserved.Trademarks

National Instruments, NI, https://www.wendangku.net/doc/235979650.html,, and LabVIEW are trademarks of National Instruments Corporation. Refer to the Terms of Use section on https://www.wendangku.net/doc/235979650.html,/legal for more information about National Instruments trademarks.

FireWire? is the registered trademark of Apple Computer, Inc. Other product and company names mentioned herein are trademarks or trade names of their respective companies.

Members of the National Instruments Alliance 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 products, refer to the appropriate location: Help?Patents in your software, the patents.txt file on your CD, or https://www.wendangku.net/doc/235979650.html,/legal/patents .

S a m p l e Worldwide Technical Support and Product Information https://www.wendangku.net/doc/235979650.html, National Instruments Corporate Headquarters 11500 North Mopac Expressway Austin, Texas 78759-3504USA Tel: 512 683 0100

Worldwide Offices Australia 1800300800,Austria 4306624579900,Belgium 32027570020,Brazil 551132623599,Canada 8004333488,China 862165557838, Czech Republic 420224235774, Denmark 4545762600, Finland 3850972572511, France 330148142424,Germany 490897413130,India 918041190000,Israel 972036393737,Italy 3902413091,Japan 81354722970, Korea 820234513400, Lebanon 96101332828, Malaysia 1800887710, Mexico 018000100793, Netherlands 310348433466, New Zealand 0800553322, Norway 47066907660, Poland 48223390150, Portugal 351210311210, Russia 70957836851, Singapore 180********, Slovenia 38634254200, South Africa 270118058197, Spain 34916400085, Sweden 460858789500, Switzerland 41562005151, Taiwan 8860223772222, Thailand 6622786777, United Kingdom 4401635523545For further support information, refer to the Additional Information and Resources appendix. To comment on National Instruments documentation, refer to the National Instruments Web site at https://www.wendangku.net/doc/235979650.html,/info and enter the info code feedback .

S a m

p l e ? National Instruments Corporation iii LabVIEW Introduction Course Manual Contents

Student Guide

A.

About This Manual...............................................................................................viii B.

What You Need to Get Started.............................................................................viii C.

Installing the Course Software..............................................................................ix D.

Course Goals.........................................................................................................ix E.Course Conventions. (x)

Lesson 1Problem Solving

A.Software Development Method............................................................................1-2

B.Scenario................................................................................................................1-2

C.Design...................................................................................................................1-3

D.Implementation.....................................................................................................1-6

E.Testing ..................................................................................................................1-6

F.Maintenance..........................................................................................................1-7Exercise 1-1 Software Development Method........................................................1-8

G.Course Project.......................................................................................................1-10Lesson 2Navigating LabVIEW A.Virtual Instruments (VIs)......................................................................................2-2B.Parts of a VI..........................................................................................................2-2C.Starting a VI..........................................................................................................2-4D.Project Explorer....................................................................................................2-9E.Front Panel Window.............................................................................................2-13F.Block Diagram Window.......................................................................................2-19Exercise 2-1 Concept: Exploring a VI...................................................................2-28G.Searching for Controls, VIs, and Functions..........................................................2-29Exercise 2-2 Concept: Navigating Palettes...........................................................2-31

H.Selecting a Tool....................................................................................................2-32Exercise 2-3 Concept: Selecting a Tool................................................................2-39

I.Data Flow..............................................................................................................2-43Exercise 2-4 Concept: Data Flow..........................................................................2-45

J.Building a Simple VI............................................................................................2-46Exercise 2-5 Simple AAP VI.................................................................................2-50Lesson 3

Troubleshooting and Debugging VIs

https://www.wendangku.net/doc/235979650.html,bVIEW Help Utilities.......................................................................................3-2Exercise 3-1 Concept: Using Help........................................................................3-5

B.Correcting Broken VIs..........................................................................................3-9

C.Debugging Techniques.........................................................................................3-11

S a m p l e Contents

LabVIEW Introduction Course Manual iv https://www.wendangku.net/doc/235979650.html,

D.Undefined or Unexpected Data.............................................................................3-18

E.Error Checking and Error Handling......................................................................3-19Exercise 3-2 Concept: Debugging.........................................................................3-21Lesson 4

Implementing a VI

A.Designing Front Panel Windows..........................................................................4-2

https://www.wendangku.net/doc/235979650.html,bVIEW Data Types ..........................................................................................4-9

C.Documenting Code...............................................................................................4-17Exercise 4-1 Determine Warnings VI...................................................................4-20

D.While Loops..........................................................................................................4-27Exercise 4-2 Auto Match VI..................................................................................4-30

E.For Loops..............................................................................................................4-36Exercise 4-3 Concept: While Loops versus For Loops.........................................4-39

F.Timing a VI...........................................................................................................4-42

G.Iterative Data Transfer..........................................................................................4-43Exercise 4-4 Average Temperature VI..................................................................4-46

H.Plotting Data.........................................................................................................4-50Exercise 4-5 Temperature Multiplot V

I................................................................4-56I.Case Structures .....................................................................................................4-61Exercise 4-6 Determine Warnings VI...................................................................4-67

J.Formula Nodes......................................................................................................4-72Exercise 4-7 Self-Study: Square Root VI..............................................................4-74Exercise 4-8 Self-Study: Determine Warnings VI (Challenge)............................4-78Exercise 4-9 Self-Study: Determine More Warnings VI.......................................4-81

Lesson 5

Relating Data

A.Arrays....................................................................................................................5-2Exercise 5-1 Concept: Manipulating Arrays.........................................................5-7

B.Clusters.................................................................................................................5-14Exercise 5-2 Concept: Clusters..............................................................................5-20

C.Type Definitions...................................................................................................5-25Exercise 5-3 Type Definition................................................................................5-29Lesson 6

Storing Measurement Data

A.Understanding File I/O.........................................................................................6-2

B.Understanding High-Level File I/O......................................................................6-4Exercise 6-1 Spreadsheet Example VI..................................................................6-5

C.Low-Level File I/O...............................................................................................6-8Exercise 6-2 Temperature Log VI.........................................................................6-10Exercise 6-3 Self-Study: Read VCard VI..............................................................6-13

S a m

p l e Contents

? National Instruments Corporation v LabVIEW Introduction Course Manual

Lesson 7

Developing Modular Applications

A.Understanding Modularity....................................................................................7-2

B.Building the Icon and Connector Pane.................................................................7-4

https://www.wendangku.net/doc/235979650.html,ing SubVIs........................................................................................................7-9Exercise 7-1 Determine Warnings VI...................................................................7-11Lesson 8

Acquiring Data

https://www.wendangku.net/doc/235979650.html,ing Hardware....................................................................................................8-2

https://www.wendangku.net/doc/235979650.html,municating with Hardware............................................................................8-5

C.Simulating a DAQ Device....................................................................................8-8Exercise 8-1 Concept: MAX................................................................................8-9

D.Measuring Analog Input.......................................................................................8-15Exercise 8-2 Triggered Analog Input VI...............................................................8-17

E.Generating Analog Output....................................................................................8-22

https://www.wendangku.net/doc/235979650.html,ing Counters .....................................................................................................8-24Exercise 8-3 Count Events VI ..............................................................................8-25

https://www.wendangku.net/doc/235979650.html,ing Digital I/O ..................................................................................................8-28Exercise 8-4 Optional: Digital Count VI ..............................................................8-29

Lesson 9Instrument Control https://www.wendangku.net/doc/235979650.html,ing Instrument https://www.wendangku.net/doc/235979650.html,ing https://www.wendangku.net/doc/235979650.html,ing Serial Port https://www.wendangku.net/doc/235979650.html,ing Other Interfaces..........................................................................................9-6E.Software Architecture...........................................................................................9-7Exercise 9-1 Concept: GPIB Configuration with MAX https://www.wendangku.net/doc/235979650.html,ing the Instrument I/O Assistant.......................................................................9-12Exercise 9-2 Concept: Instrument I/O Assistant https://www.wendangku.net/doc/235979650.html,ing VISA...........................................................................................................9-23Exercise 9-3 VISA Write & Read VI https://www.wendangku.net/doc/235979650.html,ing Instrument Drivers......................................................................................9-29Exercise 9-4 Concept: NI Devsim VI....................................................................9-32Lesson 10

Common Design Techniques and Patterns

https://www.wendangku.net/doc/235979650.html,ing Sequential Programming............................................................................10-2

https://www.wendangku.net/doc/235979650.html,ing State Programming.....................................................................................10-5

C.State Machines......................................................................................................10-6Exercise 10-1 State Machine VI..............................................................................10-15

https://www.wendangku.net/doc/235979650.html,ing Parallelism..................................................................................................10-21

S a m p l e Contents

LabVIEW Introduction Course Manual vi https://www.wendangku.net/doc/235979650.html, Appendix A

Analyzing and Processing Numeric Data

A.Choosing the Correct Method for Analysis..........................................................A-2

B.Analysis Categories..............................................................................................A-4Exercise A-1 Concept: Analysis Types..................................................................A-6Appendix B

Measurement Fundamentals

https://www.wendangku.net/doc/235979650.html,ing Computer-Based Measurement Systems....................................................B-2

B.Understanding Measurement Concepts................................................................B-3

C.Increasing Measurement Quality..........................................................................B-12Exercise B-1 Concepts: Measurement Fundamentals............................................B-17Appendix C CAN: Controller Area Network A.History of CAN.....................................................................................................C-2B.CAN Basics...........................................................................................................C-4Exercise C-1 Concept: CAN Device Setup............................................................C-7C.Channel Configuration..........................................................................................C-9Exercise C-2 Channel Configuration.....................................................................C-12

D.CAN APIs.............................................................................................................C-17

E.CAN Programming in LabVIEW (Channel API).................................................C-18Exercise C-3 Read and Write CAN Channels........................................................C-21Exercise C-4 Synchronize CAN & DAQ...............................................................C-26Appendix D

Additional Information and Resources

Index

Course Evaluation

S a m p l

e ? National Instruments Corporation 4-1LabVIEW Introduction Course Manual 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.

A.Designing Front Panel Windows

https://www.wendangku.net/doc/235979650.html,bVIEW 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

J.Formula Nodes

S a m p l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html,

A.Designing Front Panel Windows

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

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 https://www.wendangku.net/doc/235979650.html,bels and Captions

When creating labels for controls and indicators, make sure to label them clearly. These labels help users identify the function for 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 long names. 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 .

S a

p l Lesson 4Implementing a VI

? National Instruments Corporation 4-3LabVIEW Introduction Course Manual Control and Indicator Options

You can set default values for controls. Figure 4-2 shows a default value of 35 degrees Celsius. By setting a default value, you can assume a reasonable value for a VI if 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.

You also can hide and view items on controls and indicators. For example, in Figure 4-1, 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.

Figure 4-1. Setting Default Values 2

S a m l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html,

Figure 4-2. Hiding a Front Panel Label 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 https://www.wendangku.net/doc/235979650.html,bVIEW 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 LabVIEW colors. If a color is not available on a computer, 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.

S a m

p l e Lesson 4Implementing a VI

? National Instruments Corporation 4-5LabVIEW Introduction Course Manual

?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 and alignment 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

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 left, almost all follow top to bottom.When you design the front panel, consider how users interact with the VI and group controls and indicators logically. If several controls are related, add a decorative border around them or put them in a cluster.Centered items are less orderly than either left or right alignment. A band of white space acts as a very strong means of alignment. Centered items typically have ragged edges and the order is not as easily noticed.Do not place front panel objects too closely together. Try to leave some blank space to make the front panel easier to read. Blank space also prevents users from accidentally clicking the wrong control or button.Left-justify menus and right-justify related shortcuts as shown in Figure 4-3 on the left side: the LabVIEW File menu. Locating items in the center-justified menu as shown in the same example on the right is more difficult. Notice how the dividing lines between menu sections in the left example help you find the items quickly and strengthen the relationship between the items in the sections.

S a p l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html,

Figure 4-3. Good and Bad Menu Examples Avoid placing objects on top of other objects. Placing a label or any other object over or partially covering a control or indicator slows down screen updates and can make the control or indicator flicker.Text and Fonts

Text is easier to read and information is more easily understood when displayed in an orderly way. Use the default LabVIEW fonts. LabVIEW replaces the built-in fonts with comparable font families on different platforms. If you select a different font, LabVIEW substitutes the closest match if the font is unavailable on a https://www.wendangku.net/doc/235979650.html,ing too many font styles can make your front panel window look busy and disorganized. Instead, use two or three different sizes of the same font. Serifs help people to recognize whole words from a distance. If you are 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

S a m p l e Lesson 4Implementing a VI

? National Instruments Corporation 4-7LabVIEW Introduction Course Manual

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 https://www.wendangku.net/doc/235979650.html,er Interface Tips and Tools

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 https://www.wendangku.net/doc/235979650.html,e the system controls and indicators located on the System palette in dialog boxes you create.Because the system controls change appearance depending on which platform you run the VI, the appearance of controls in VIs you create is compatible on all LabVIEW platforms. 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.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 another page 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, or

S a m

p l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html, case, 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 on a front panel with boxes, lines, or arrows. These objects are for decoration only and do not display data.

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

S a m p l Lesson 4Implementing a VI

? National Instruments Corporation 4-9LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html,bVIEW Data Types

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.

Terminals

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, DBL .

Figure 4-4. Terminal Data Type Example 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. When you wire two or more numeric inputs of different representations to a function, the function usually returns the output in the larger or wider format. 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.

S a m p l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html, Figure 4-5. Numeric Representation The numeric data type includes the following subcategories of representation—floating-point numbers, signed integers, unsigned integers, and complex numbers. 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.

S a m p l e Lesson 4Implementing a VI

? National Instruments Corporation 4-11LabVIEW Introduction Course Manual 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 (I8)—Byte integer numbers have 8 bits of storage.

Word (I16)—Word integer numbers have 16 bits of storage.

Long (I32)—Long integer numbers have 32 bits of storage. In most cases, it is best to use a 32-bit integer.

Quad (I64)—Quad integer numbers have 64 bits of https://www.wendangku.net/doc/235979650.html,plex 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 —Complex single-precision, floating-point numbers

consist of real and imaginary values in 32-bit IEEE single-precision https://www.wendangku.net/doc/235979650.html,plex Double —Complex double-precision, floating-point numbers consist of real and imaginary values in 64-bit IEEE double-precision format. Complex Extended —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.

Boolean Values

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. Latch action is similar to a doorbell, whereas switch action is similar to a light switch. You can also define when the switch or latch occurs—when pressed, when released or until released.

S a m p l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html, To learn more about mechanical action, experiment with the Mechanical Action of Booleans VI in the NI Example Finder.

Figure 4-6. Boolean Mechanical Action 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.

?

Passing numeric data as character strings to instruments and then converting the strings 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 window, 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.In LabVIEW, strings are represented with the color pink.

S a m

Lesson 4Implementing a VI

? National Instruments Corporation 4-13LabVIEW Introduction Course Manual Right-click a front panel string control or indicator to select from the display types shown in the following table. The table also shows an example message in each display type.

LabVIEW stores strings as a pointer to a structure that contains a 4-byte length value followed by a 1D array of byte integers (8-bit characters). Enums

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 for a Month variable are January-0, February-1, and so on through December-11. Figure 4-7 shows an example of these data pairs in the Properties dialog box for an enumerated control.

S a m p l e Lesson 4Implementing a VI

LabVIEW Introduction Course Manual https://www.wendangku.net/doc/235979650.html, Figure 4-7. Properties for the Month Enumerated Control

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.

相关文档