LABVIEW CORE 1 MANUAL PDF

adminComment(0)

LabVIEWTM Core 1. Course Manual. Course Software Version August Edition. Part Number B LabVIEW Core 1 Course Manual. Materials used in the instructor-led course; Printed course concepts manual; Printed exercise procedure manual; Exercise solutions on CD. Overview; Pricing . The LabVIEW Core 1 course teaches you programming concepts, Before you use this course manual, make sure you have all of the following items.


Labview Core 1 Manual Pdf

Author:RENATO KILCOYNE
Language:English, Portuguese, Arabic
Country:Sierra Leone
Genre:Health & Fitness
Pages:705
Published (Last):21.05.2016
ISBN:192-5-43523-244-9
ePub File Size:21.59 MB
PDF File Size:12.12 MB
Distribution:Free* [*Registration needed]
Downloads:42199
Uploaded by: SOFIA

The LabVIEW Core 1 Course Setup dialog box appears. 2. Click Install the course materials. 3. Follow the onscreen instructions to complete installation and . LabVIEW Core 1 Course Manual - Ebook download as PDF File .pdf), Text File .txt) or read book online. Course Manual. LabVIEW Core1 MANUAL DE haakoopmacyding.gq - Ebook download as PDF File .pdf) or read book online.

The label for the control or indicator does not change depending on the value of the control or indicator. Set the properties as shown in Figure Changing the Boolean Text for the Stop Control 1 2 1 Control label—This text identifies the terminal of the Boolean control for programming purposes.

This text does not appear on the front panel unless you select Visible.

You might also like: MEDICINAL PLANTS EBOOK

Notice the control label is Stop Button and the button text is End. Tip You can also double-click the Stop Button terminal to find the button control on the front panel.

Click the Run button to run the VI. When the VI is finished executing, the Temperature Chart displays the data. You do not need to save the VI. Making Code Readable Block diagram comments can describe the function or operation of algorithms and explain the purpose of data that passes through wires. Owned Labels Free Labels Explain data contents of wires and objects.

Describe algorithms. Move with object. Have fixed location. Have transparent backgrounds. Have pale yellow backgrounds. Default Values Setting a default value on a control or indicator can aid in future development and troubleshooting by giving the programmer an idea of the expected data for that object.

Building a Basic VI Objective: Recognize Express VIs and be able to apply them appropriately. You must use this Express VI frequently throughout this course. Simulate Signal Generates simulated data such as a sine wave. Level These include DC, rms, maximum peak, Measurements minimum peak, peak to peak, cycle average, and cycle rms measurements. Statistics Calculates statistical data from a waveform.

This includes mean, sum, standard deviation, and extreme values. Tone Searches for a single tone with the highest Measurements frequency or highest amplitude.

It also finds the frequency and amplitude of a single tone. Spectral Performs spectral measurement on a Measurements waveform, such as magnitude and power spectral density.

Filter Processes a signal through filters and windows. Filters used include the following: Highpass, Lowpass, Bandpass, Bandstop, and Smoothing. Measurement File Build Text Creates text, usually for displaying on the front panel window or exporting to a file or instrument. Circle the Express VI that is best suited to acquire a sine wave from a data acquisition device.

Circle the Express VI that is best suited to determining the average value of the acquired data. Build Text The Build Text Express VI creates text, usually for displaying on the front panel window or exporting to a file or instrument.

Waveform Graph The waveform graph displays one or more plots of evenly sampled measurements. Refer to the next page for answers to this quiz. Use the DAQ Assistant to acquire the sine wave from the data acquisition device.

Use the Statistics Express VI to determine the average value of the sine wave. Because this signal is cyclical, you could also use the Cycle Average option in the Amplitude and Level Measurements Express VI to determine the average value of the sine wave.

Scenario You need to acquire a sine wave for 0. Design The input for this problem is an analog channel of sine wave data. The outputs include a graph of the sine data, a file that logs the data, and an indicator that displays the average data value.

Flowchart The flowchart in Figure illustrates the data flow for this design. Prepare your hardware to generate a sine wave. If you are not using hardware, skip to step 2.

AI GND 3. RES- Temp. Create a blank project. Save the project as Simple AAV. Add a waveform graph to the front panel window to display the acquired data. Add a numeric indicator to the front panel window to display the average value. Note The terminals corresponding to the front panel window objects appear on the block diagram. Acquire a sine wave for 0. If you have hardware installed, follow the instructions in the Hardware Installed column to acquire the data using the DAQ Assistant.

If you do not have hardware installed, follow the instructions in the No Hardware Installed column to simulate the acquisition using the Simulate Signal Express VI.

Drop dialog box. Type DAQ Assist in the text box and 2. Place the DAQ Assistant on the block 3. Wait for the DAQ Assistant dialog box 4. Wait for the Simulate Signal dialog box to open. Select Sine for the signal type. Voltage for the measurement type. Select ai1 analog input channel 1 for 6. Set the signal frequency to Click the Finish button. In the Timing section, set the Samples per second Hz to In the Timing Settings section, select 8.

Automatic for the Number of samples. In the Timing Settings section enter 9. Enter in Rate Hz. In the Timing section, select the Simulate acquisition timing option. Click the OK button. Tip Reading samples at a rate of 1, Hz retrieves 0. Use the Statistic Express VI to determine the average value of the data acquired. Note Future exercises do not detail the directions for finding specific functions or controls in the palettes.

Use Quick Drop, the palette search feature, or the global search to locate functions and controls. Wire the data to the graph indicator. Note Future exercises do not detail the directions for wiring between objects.

Save the VI. Test 1. Switch to the front panel window of the VI. Set the graph properties to be able to view the sine wave. Click the Run button on the front panel toolbar to run the VI.

The graph indicator should display a sine wave and the Average Value indicator should display a number around zero. If the VI does not run as expected, review the implementation steps. Close the VI. End of Exercise ni. Lesson Review Refer to the figure below to answer the following quiz questions.

Which function executes first: Add or Subtract? Add b. Subtract c. Unknown 2. Sine or Divide? Sine b. Divide c. Unknown 3. Random Number, Divide or Add? Random Number b. Add d. Unknown 4. Which function executes last: Random Number, Subtract or Add? Unknown 5. If an input to a function is marked with a red dot known as coercion dot , what does the dot indicate? Data was transferred into a structure. That input has not been wired c. The wire is broken d.

The value passed into a node was converted to a different representation. Switch Until Released b. Switch When Released c.

Latch When Pressed d. Lesson Review - Answers Refer to the figure below to answer the following quiz questions. Correcting Broken VIs Objective: Recognize an unexecutable VI and restate common problems.

If the Run button appears broken when you finish wiring the block diagram, the VI is broken and cannot run.

Required terminal is unwired. Control wired to another control. Broken subVI due to unwired required terminal. Debugging Techniques Objective: Debugging Tips The following table includes a few common problems to look for when debugging your VIs. Is the numeric representation correct for your application? Do nodes execute in the correct order? Are there any hidden or unwired subVIs? Job Aid If a VI is not broken, but you get unexpected data, you can use the following checklist to identify and correct problems with the VI or the block diagram data flow: To help avoid incorrect results caused by hidden VIs, specify that inputs to VIs are required.

Execution Highlighting Single Stepping Probe Situation Debugging Tool Your VI is returning unexpected data and you Probe want to see intermediate values on the wires to find out where the problem initiates.

You want to see how data moves from one node to the next on the block diagram. You want to view each action of the VI on the block diagram.

This tool slows down how fast the VI runs so you can see the data flow through the block diagram. 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. When you reach a breakpoint during execution, the VI pauses and the Pause button appears red. You can take the following actions: Tip Always remember to turn this feature off when you are done debugging to free memory.

NaN not a number a floating-point value that invalid operations produce, such as taking the square root of a negative number Inf infinity a floating-point value that valid operations produce, such as dividing a number by zero ni. Description The VIs in this exercise check the validity of a triangle and then calculate the area. For a triangle to be valid, all three sides must have a length that is greater than zero.

You can use this method when you know the lengths of all three sides of a triangle. Therefore the correct values are as follows: Use single-stepping and execution highlighting to step through the VI. Open and examine the area and validity of a triangle VI. This VI takes input values for each of the three sides of a triangle, passes the values into a subVI that determines the area, and checks that the values entered are valid for a triangle.

Find and fix each error. The Details section describes the error and in some cases recommends how to correct the error.

In the Area of Triangle VI, notice that the formula for calculating the area of a triangle requires the sum of the sides be divided by 2. Save both VIs. Test the VI. These values are valid measurements for a triangle. Animate the flow of data through the block diagram. Notice that you can see how data flows through the wires. At the output of each node, you can see the data value displays momentarily.

Because you have enabled the Retain Wire Values button, you can probe the last value in the wire. Probe the wire values. This displays the Probe Watch Window. The input values were all positive numbers, so that means the logic is incorrect. Notice that the node returning a value of False is a Less than Zero? Notice that the Valid Triangle?

Continue debugging the subVI. Execution highlighting shows the flow of data on the block diagram from one node to another. Nodes blink to indicate they are ready to execute. Each time you click the Step Over button, the current node executes and pauses at the next node.

The subVI is paused. Click the red pause button to resume the execution of the VI. You should see a tip strip with a value of You cannot take the square root of a negative number, which is why the Area of Triangle indicator returns NaN. Tip If you cannot see the tip strip, you can click the wire to open the Probe Watch window to see the value. If you look more closely, you notice that the inputs for the subtract function are reversed.

Test the Area of Triangle VI. Troubleshooting and Debugging VIs The square root function should return a value of For each set of test values, record the area you get when you run the VI. Save and close the VI when you are finished testing. Error Handling Objective: Describe the difference between automatic and manual error handling.

Automatic vs. Typically, functions use numeric error codes, and VIs use an error cluster, usually with error inputs and outputs. Use the error cluster controls and indicators to create error inputs and outputs in subVIs. A non-zero error code is coupled with a status of FALSE signals a warning rather than an error 3 source—a string that identifies where the error occurred Errors and Warnings When an error occurs, open the Explain Error dialog box to see more information about the error.

If no error is found, it returns the first warning. At the end of your application after all error sources are merged into one error cluster, you must report errors to the user using the Simple Error Handler VI or another error reporting mechanism.

Errors and Warnings Recommendations By default, the Simple Error Handler VI displays a dialog with a description of any errors that occurred and does not report warnings. Which of the following will result in a broken run arrow? A subVI is broken b. The diagram includes a divide by zero c.

A required subVI input is unwired d. A Boolean terminal is wired to a numeric indicator 2. Which of the following are components and data types of the error cluster? Boolean b. String c. String 3. All errors have negative error codes and all warnings have positive error codes. True b. False 4. Merge Errors function concatenates error information from multiple sources. Loops Review Objective: Recognize loop structures and explain how to use them.

While Loops vs. If you use a While Loop, what is the condition that you need to stop the loop? If you use a For Loop, how many iterations does the loop need to run? Is it easier to implement a For Loop or a While Loop? Scenario 2 Acquire pressure data until the pressure is greater than or equal to psi.

Scenario 3 Acquire pressure and temperature data until both values are stable for two minutes. Scenario 4 Output a voltage ramp starting at zero, increasing incrementally by 0. For Loops - Answers Scenario 1 Acquire pressure data in a loop that executes once per second for one minute. While Loop: For Loop: Both are possible Scenario 2 Acquire pressure data until the pressure is greater than or equal to psi.

A While Loop. Although you can add a conditional terminal to a For Loop, you still need to wire a value to the count terminal. Without more information, you do not know the appropriate value to wire to the count terminal. Both are possible. While Loops Objective: Recognize tunnels and explain their purpose on a loop structure and demonstrate how to use error checking and error handling inside a loop. Tunnels Tunnels transfer data into and out of structures. Data pass out of a loop after the loop terminates.

Error Checking and Error Handling You can wire an error cluster to the conditional terminal to stop the iteration of the loop.

If an error occurs, the loop stops. Using Loops Scenario Create a VI that continuously generates random numbers between 0 and until it generates a number that matches a number selected by the user. Determine how many random numbers the VI generated before generating the matching number.

The flowchart in Figure illustrates the data flow for this design. Create a blank project and save it as Auto Match. Create a new VI in the project and save it as Auto Match. Build the front panel shown in Figure Set the properties for the Number to Match control so that the data type is a bit unsigned integer, the data range is from 0 to , the increment value is 1, and the digits of precision is 0. Set the representation of the Current Number indicator to an unsigned, bit integer and set the digits of precision for the Current Number output to 0.

Using Loops Figure Create the block diagram shown in Figure Enter a value of Because the Random Number function generates a double-precision, floating point number between 0 and 1, multiplying the number by produces a range of numbers between 0 and Otherwise, it returns TRUE. In this case, the output from Round To Nearest is a double-precision, floating point but Current Number is an integer.

Update the VI to remove the coercion dots. This inserts the To Unsigned Long Integer function on the wire. Notice that converting the output from the Round To Nearest function removes all the coercion dots on the block diagram, as shown in Figure Completed Auto Match VI 9.

Display the front panel.

LabVIEW Core1 MANUAL DE CURSO.pdf

Note If synchronous display is enabled, then every time the block diagram sends a value to the Current Number indicator, the block diagram stops executing until the front panel has updated the value of the indicator. In this exercise, you enable the synchronous display, so you can see the Current Number indicator get updated repeatedly on the front panel. Typically, the synchronous display is disabled to increase execution speed since you usually do not need to see every single updated value of an indicator on the front panel.

Change the number in the Number to Match control to a number that is in the data range, which is 0 to with an increment of 1. Run the VI. Change the Number to Match value and run the VI again. Current Number updates at every iteration of the loop because it is inside the loop. Number of Iterations updates upon completion because it is outside the loop.

To see how the VI updates the indicators, enable execution highlighting. Run the VI and observe the data flow. Turn off execution highlighting to quickly finish executing the VI. Try to match a number that is outside the data range. For Loops Objective: Demonstrate how to add a conditional terminal to a For Loop and describe how numeric conversion occurs on the For Loop count terminal. Conditional Terminal 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 all iterations are complete, whichever happens first. The following For Loop generates a random number every second until seconds has passed or until the user clicks the stop button. Count Terminal Numeric Conversion If you wire a double-precision, floating-point numeric value to the count terminal, LabVIEW converts the numeric value to a bit signed integer.

Timing a VI Objective: When a loop finishes executing an iteration, it immediately begins executing the next iteration, unless it reaches a stop condition. 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. You also want to time a loop to provide the processor with time to complete other tasks, such as processing the user interface. Wait Functions Inside a Loop Use a wait function inside a loop to accomplish the following actions: Wait Function Behavior Wait Until Next ms Multiple Monitors a millisecond counter and waits until the millisecond counter reaches a multiple of the amount you specify.

This function is synced to the system clock. Wait ms Waits until the millisecond counter counts to an amount equal to the input you specify Time Delay Express VI Similar to the Wait ms function with the addition of built-in error clusters.

Wait Until Next ms Multiple and Wait ms. This timing diagram assumes that the wait functions begin running immediately for each loop iteration and that the loop is ready to iterate as soon as the wait function finishes. Data Feedback in Loops Objective: Apply shift registers when appropriate and predict the correct value at different iterations of the loop.

Using Shift Registers When you create a shift register, the shift register reflects the data type you wire to the terminals. If you do not initialize the register, the loop uses the value written to the register when the loop last executed or it uses the default value for the data type if the loop has never executed. You can add more than one shift register to a loop for applications such as averaging data points. Creating Shift Registers Replace tunnels with shift registers when you need to transfer values from one loop iteration to the next.

If you convert a tunnel with auto-indexing enabled to a shift register on a While Loop, the wire to any node outside the loop breaks because shift registers cannot auto-index ni. Modify the VI to average the last five temperature measurements and display the running average on the waveform chart. To accomplish this, you modify this VI as follows: Notice the variation in the simulated temperature reading.

Stop the VI by clicking the Stop button on the front panel. Modify the VI to reduce the number of temperature spikes. Drag the lower resizing handle of the shift register to display four shift registers. The Thermometer Demo VI returns one temperature measurement and initializes the left shift registers before the loop starts.

Resize the function to have five terminals. Note You can create stacked shift register terminals on the left side of a loop to remember multiple previous iterations and carry those values to the next iterations. This technique is useful for averaging data points. 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.

The VI adds this value to the last four measurements stored in the left terminals of the shift register. The VI divides the result by five to find the average of the five measurements—the current measurement plus the previous four.

The VI displays the average on the waveform chart. Notice that the VI initializes the shift register with a temperature measurement. Save and close the VI and the project. Plotting Data Objective: Use data feedback in a loop to plot waveform charts.

Waveform Chart 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. The chart uses the following modes to display data: Using Loops Scenario Modify the VI from Exercise to plot both the current temperature and the running average on the same chart. In addition, allow the user to examine a portion of the plot while the data is being acquired. Design Figure shows the front panel for the existing Temperature Monitor VI and Figure shows the block diagram.

Also, expand the legend to show additional plots. To modify the block diagram in Figure , you must modify the chart terminal to accept multiple pieces of data. Use a Bundle function to combine the average temperature and the current temperature into a cluster to pass to the Temperature History terminal.

Modify the block diagram so that it resembles Figure Modify the front panel so that it resembles Figure Double-click the label to edit the plot names.

The order of the plots listed in the plot legend is the same as the order of the items wired to the Bundle function on the block diagram. Click the plot icon, select Common Plots from the menu, and choose the plot you want. Use the tools in the scale legend and the graph palette to examine the data as it generates.

Close the VI and project when you are finished. Lesson Review 1. Which structure must run at least one time? While Loop b. Arrays Objective: Identify when to use arrays and learn how to create and initialize arrays.

2012 LabVIEW Core 1 Course Manual

Arrays Array Collection of data elements that are of the same type. Elements The data that make up the array. Elements can be numeric, Boolean, path, string, waveform, and cluster data types. Dimension Length, height, or depth of the array. Arrays can have one or more dimensions and as many as -1 dimensions. The index of the first element in the array, regardless of its dimension, is zero. For example, LabVIEW represents a text array that lists the twelve months of the year as a 1D array of strings with twelve elements.

Index is zero-based, which means the range is 0 to n - 1, where n is the number of elements in the array. March is the third month, so it has an index of 2.

It requires a column index and a row index to locate an element, both of which are zero-based. Initializing Arrays An uninitialized array contains a fixed number of dimensions but no elements. An initialized defines the number of elements in each dimension and the contents of each element. Viewing Arrays 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.

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. 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,. Common Array Functions Objective: Create and manipulate arrays using built-in array functions.

Common Array Functions Functions you can use to manipulate arrays are located on the Array palette. Initialize Array Creates an n-dimensional array in which every element is initialized to the value of element.

Insert Into Array Inserts an element or subarray at the point you specify in index. Search 1D Array Searches for an element in a 1D array starting at start index. Because the search is linear, you need not sort the array before calling this function. LabVIEW stops searching as soon as the element is found.

Using Array Functions Goal: Determine what belongs in the highlighted section. Polymorphism Objective: Understand the ability of various VIs to accept input data of different data types. Polymorphism Polymorphism The ability of VIs and functions to automatically adapt to accept input data of different data types. Functions are polymorphic to varying degrees—none, some, or all of their inputs can be polymorphic. Auto-Indexing Objective: Use auto-indexed inputs and outputs to create graphs and arrays.

Auto-indexing The ability to automatically process every element in an array. Auto-Indexing If you 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. Waveform Graphs A waveform graph collects the data in an array and then plots the data to the graph.

For example, consider the following block diagram. The array Input Array contains the following elements: Because of the conditional tunnel, the Values less than 5 array contains only the elements 2, 0, 3, and 1 after this loop completes all iterations. If you wire an array to an auto-indexing tunnel on a For Loop, you do not need to wire the count N terminal. I 1 2 1 The For Loop executes the number of times equal to the number of elements in the array. Auto-Indexing Input—Different Array Sizes If the iteration count terminal is wired and arrays of different sizes are wired to auto-indexed tunnels, the actual number of iterations becomes the smallest of the choices.

I 1 1 The For Loop iterates 5 times and because the iterations are zero-based, the output is 4. The front panel of this VI is built. You complete the block diagram to practice several different techniques to manipulate arrays. Implementation 1. Open Manipulating Arrays. The front panel, shown in Figure , is already built for you. Open the block diagram and complete each of the cases that correspond to the tabs on the front panel as shown in Figures through Switch to the front panel and test the Concatenate Channels case.

Stop the VI. Boolean control is False, the array elements are added. Note This case demonstrates polymorphic functionality by adding and subtracting elements of the array. Switch to the block diagram and select the Select a Channel case. Complete the Select a Channel case as shown in Figure The output from this function is a 1D array and is the waveform you select with the Select Channel control. Switch to the front panel and test the Select a Channel case.

Switch to the block diagram and select the Waveform Data case. Complete the Waveform Data case block diagram as shown in Figure The waveform datatype is a special kind of cluster that contains additional timing information about the waveform. Notice the value from the Offset control must be coerced to be used with the waveform datatype. Note Polymorphism is the ability of VIs and functions to automatically adapt to accept input data of different data types, including arrays, scalars, and waveforms.

Navigating LabVIEW

VIs and functions are polymoprhic to varying degrees. Switch to the front panel and test the Waveform Data case. Switch to the block diagram and select the All Data Channel case. Complete the All Data Channel case as shown in Figure Each 1D array becomes a row in the 2D array. In this exercise, you have 2 elements of data for the number of rows and columns. Note The polymorphic functionality of LabVIEW functions allows you to perform the same operation on each element without extracting the Lesson 5 array elements, as you do with the two Add functions in the All Data Channel case.

Switch to the front panel and test the All Data Channel case. Switch to the block diagram and select the Waveform Subset case. Complete the Waveform Subset case as shown in Figure In this exercise, you use this function to zoom in on a subset of the waveform you generated. The default value is set to start at element 0. The default value is set to output elements. Switch to the front panel and test the Waveform Subset case. The x-axis starts at zero because the VI creates a brand new array and the graph does not know where the data was located in the original array.

Example VIs can show you how to use specific functions and programming concepts such as arrays and polymorphism. Complete the following steps to use the NI Example finder to locate example VIs that demonstrate different ways to use the Array function. Click the Search tab and enter the keyword array. Click the Search button to find VIs using that keyword. Click one of the example VIs in the search results list and read the description.

Double-click an example VI to open it. Read through the comments on the front panel and block diagram to learn more about what this example VI demonstrates. Run the example, examine the different cases, and click the Stop button to exit.

Clusters Objective: Identify when to use clusters and be able to create them. Clusters Clusters Clusters group data elements of mixed types A cluster is similar to a record or a struct in text-based programming languages.

Clusters vs. Create a Cluster Control Create a cluster control or indicator on the front panel by adding a cluster shell to the front panel and dragging a data object or element into the shell. The element can be a numeric, Boolean, string, path, refnum, array, or cluster control or indicator.

Cluster Order Cluster elements have a logical order unrelated to their position in the shell.

Recommended Posts

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.

NI recommends the following: The number of output terminals does not depend on the number of elements in the input cluster. Use Bundle when some or all cluster elements are unnamed.

I ni. Creating a Cluster on the Block Diagram Use the Bundle function to programmatically create a cluster on a block diagram. If the elements that are bundled have labels, you can access them using the Unbundle By Name function. Otherwise use the Unbundle function. The Build Array function is used to create multi-plot waveform graphs.

LabVIEW uses error clusters to pass error information. Scenario Another developer has created a VI that displays temperature warnings. This VI is part of the temperature weather station project studied throughout this course. Your task is to update this VI to use clusters instead of individual terminals for inputs and outputs.

Yes Warning? You modify the Temperature Warnings VI to receive and return data in the form of that same cluster as shown in Figure The modified VI works in a more modular fashion with other subVIs in the overall application. Open Weather Warnings. Place existing controls and indicators in a cluster named Weather Data as shown in Figure Resize the cluster so that all the elements are visible and arranged vertically as shown in Figure Reorder the items in the cluster as shown in Figure Reorder Cluster ni.

Modify the VI to receive and return cluster data. Rename the copy Weather Data In. Rename the indicator Weather Data Out. Modify the block diagram as shown in Figure to extract data from the input cluster. Temperature Warnings with Clusters Block Diagram ni. Wire the outputs of the Unbundle By Name function to the broken wires in the order shown.

Because you moved individual controls and indicators into a single cluster, you must use the Unbundle By Name function to wire the internal controls and indicators independently of each other. Display two elements and use the Operating tool to select Warning? Connect the broken wires to the Unbundle By Name inputs as shown. Note If the order of the elements in the Unbundle By Name and the Bundle By Name functions is different than what you want, you can use the Operating tool to change the order.

Save and close the Temperature Warnings VI. Run the VI and verify that the Weather Data indicator displays correct values. Type Definitions Objective: Identify and determine when to use a type definition, strict type definition, or control.

Control Options Use custom controls and indicators to extend the available set of front panel objects and to make them available on other front panels. Changes made to one control does not reflect in other controls. Creating and Identifying Type Definitions ni. Scenario As a LabVIEW developer, you can encounter situations where you need to define your own custom data types in the form of clusters and enums.

A challenge associated with using custom data types is that you may need to change them later in development. In addition, you may need to change them after they have already been used in VIs. For example, you create copies of a custom data type and use them as controls, indicators, or constants in one or more VIs. Then you realize that the custom data type needs to change. You need to add, remove, or change items in the cluster data type or the enum.

As a developer you must ask yourself the following questions: Usually, you want all the copies of the custom data type to update if you update the original custom data type.

To achieve this you need copies of the custom data types to be tied to a type definition, which is defined as follows: Type definition—A master copy of a custom data type that multiple VIs can use. Implementation In this exercise, you modify the Temperature Warnings VI that you revised in Exercise in such a way that the changes to the Weather Data custom data type propagate through the application. When complete, the Weather Station application monitors temperature and wind information.

This exercise modifies the Temperature Warnings VI. Experiment with changing an existing cluster. Make a type definition. The window looks like the front panel of a VI but it does not have a block diagram. This indicates that the indicator is not tied to the type definition.

Tie the Weather Data Out indicator to the type definition. Note You can no longer add or remove elements to or from the cluster control and indicator on the front panel. You must open the type definition and add or remove the element from the control editor window. Edit the Weather Data type definition to include unit information. Creating and Leveraging Data Structures Figure Right-click the enum and select Edit items.

Create an item for Celsius and Fahrenheit. Arrange the front panel of the VI as shown in Figure Open the Windspeed Warnings VI. Creating and Leveraging Data Structures 5. Modify the Weather Data type definition with windspeed controls as shown in Figure Modify the block diagram of the Windspeed Warnings VI to use the new Weather Data type definition instead of individual controls and indicators, as shown in Figure You can create an array of arrays.

False 2. 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? Which of the following custom control settings defines the data type of all instances of a control but allows for different colors and font styles?

Control b. Type Definition c. Strict Type Definition d. Cluster control 4. You have input data representing a circle: In the future, you might need to modify your data to include the color of the circle U What data structure should you use to represent the circle in your application?

Three separate controls for the two positions and the radius. A cluster containing all of the data. A custom control containing a cluster. A type definition containing a cluster. An array with three elements. False You cannot drag an array data type into an array shell. However, you can create two-dimensional arrays. This helps to protect against programming error. LabVIEW mathematical functions work the same way—if you wire a 10 element 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.

Case Structures Objective: Recognize and use the basic features and functionality of Case Structures. Case Structures Review Figure What is the purpose of the Case Structure? Execute one of its subdiagrams based on an input value b. Notice the wires are the same color as the terminal. Table 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.

Automatic wiring is disabled by default when you use the Positioning tool to move an object already on the block diagram. 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. Functions Palette The Functions palette contains the VIs, functions and constants you use to create the block diagram. The Functions palette is broken into various categories; you can show and hide categories to suit your needs. Figure shows a Functions 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. Functions Palette To view or hide categories, click the Customize button on the palette, and select or deselect the Change Visible Palettes option. The following toolbar appears on the block diagram. 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. You must successfully run the VI at least once before you can retain the wire values. 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.

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

A warning indicates there is a potential problem with the block diagram, but it does not stop the VI from running. 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. 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 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. Also, the More Help button is enabled. You also can right-click an object and select Help from the shortcut menu.

These examples demonstrate how to use LabVIEW to perform a wide variety of test, measurement, control, and design tasks. 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.

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.

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 Functions 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 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 Adding an Item to the Favorites Category of a Palette Similar to the Search button, you use the Quick Drop dialog box to specify a palette object by name and then place the object on the block diagram or front panel.

In addition to palette objects, you can also specify a project item by name in the Quick Drop dialog box. Type the name of the object you want to add to the block diagram or front panel. Click the location on the block diagram or front panel where you want to add the object. 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. Tools Palette Tip You can manually choose the tool you need by selecting it on the Tools palette. Use the Operating tool to change the values of a control. When the mouse hovers over the pointer, the cursor automatically accesses the Operating tool. Using the Operating Tool 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.

Positioning Tool When the mouse cursor changes to the icon shown below, the Positioning tool is in operation.

Use the Positioning tool to select or resize objects. For example, in Figure the Positioning tool selects the Number of Measurements numeric control. After selecting an object, you can move, copy, or delete the object. When the mouse hovers over the edge of an object, the cursor automatically accesses the Positioning tool. Using the Positioning Tool to Select an Object 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 Notice that the cursor is hovering over a corner of the XY Graph at a resizing node, and the cursor mode changes to a double-sided arrow.

Using the Positioning Tool to Resize an Object You can use the Positioning tool on both the front panel window and the block diagram. Use the Labeling tool to enter text in a control, to edit text, and to create free labels. For example, in Figure the Labeling tool enters text in the Number of Measurements numeric control.

When the mouse hovers over the interior of the control, the cursor automatically accesses the Labeling tool. Click once to place a cursor inside the control. Then double-click to select the current text. 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. Wiring Tool When the mouse cursor changes to the icon shown below, the Wiring tool is in operation. Use the Wiring tool to wire objects together on the block diagram. For example, in Figure the Wiring tool wires the Number of Measurements terminal to the count terminal of the For Loop. When the mouse hovers over the exit or entry point of a terminal or over a wire, the cursor automatically accesses the Wiring tool.

Using the Wiring Tool The Wiring tool works mainly with the block diagram window and when you create a connector pane on the front panel window. 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. 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 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. Use the Color Copy tool to copy colors for pasting with the Coloring tool.

Use the Coloring tool and the color picker to color an object. The Coloring tool also displays the current foreground and background color settings. Select the Coloring tool and right-click an object or workspace to display the color picker. 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. In control flow, the sequential order of program elements determines the execution order of a program.

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.

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, Creating and Leveraging Data Structures, for more information about error clusters. 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 You must use this Express VI frequently throughout this course.

Until you learn 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 BNC You can touch the temperature sensor to change the temperature the sensor reads.

LabVIEW Core 1 Training Course

Refer to Lesson 6, Managing File and Hardware Resources, for more information on reading data from a file. These include DC, rms, maximum peak, minimum peak, peak to peak, cycle average, and cycle rms measurements.

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. It also finds the frequency and amplitude of a single tone. Filters used include the following: Highpass, Lowpass, Bandpass, Bandstop, and Smoothing.

Refer to Lesson 6, Managing File and Hardware 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. While the VI is running, the Run button icon changes to the figure shown below. After the execution completes, the Run button icon changes back to its original state, and the front panel indicators contain data.

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. Quiz Refer to Figure to answer the following quiz questions. Dataflow Questions 1. Which function executes first: Add or Subtract? Add b. Subtract c. Unknown 2. Sine or Divide? Sine b.

Divide c. Unknown 3. Random Number, Divide or Add? Random Number b. Add d. Unknown 4. Which function executes last: Random Number, Subtract or Add? Unknown 5. What are the three parts of a VI? Front panel window b. Block diagram window c. Project d. Quiz Answers 1. Which function executes first? Random, Subtract or Add? 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.

Correcting Broken VIs B. Debugging Techniques C. Undefined or Unexpected Data D. 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. 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.

Debugging Techniques If a VI is 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: 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.

Determine the causes and correct them in the VI. VIs and functions pass default values if recommended or optional inputs are unwired.

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. This feature allows you to easily check values of data that last passed through any wire. Lesson 2 Troubleshooting and Debugging VIs ni.

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. Also, close subVI front panels and block diagrams when you are not using them because open windows can affect execution speed.

For example, you might wire a bit integer to a function that only accepts 8-bit integers. This causes the function to convert the bit integer to an 8-bit representation, potentially causing a loss of data.

LabVIEW detects data type and cluster size mismatches at edit time, but it does not detect mismatches of elements of the same type. 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.

To help avoid incorrect results caused by hidden VIs, specify that inputs to VIs are required. Execution Highlighting 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. Note Execution highlighting greatly reduces the speed at which the VI runs. The single-stepping buttons, shown as follows, affect execution only in a VI or subVI in single-step mode.

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 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. Tip If you want a probe to display the data that flowed through the wire during the last VI execution, click the Retain Wire Values button on the block diagram toolbar. 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.

Generic Use the generic probe to view the data that passes through a wire. 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.

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

Custom Use the Create New Probe dialog box to create a probe based on an existing probe or to create a new probe. 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. After you select a probe from the Custom Probe shortcut menu, navigate to it using 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 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. Do not save probes in the vi. 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: Suspending Execution 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.

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. Place a checkmark in the Suspend when called checkbox to suspend execution only at that instance of the subVI.

An arrow glyph indicates a VI that is running regularly or single-stepping. An exclamation point glyph indicates that the subVI is suspended. Note A VI can be suspended and paused at the same time. Use the Call list menu to determine the current instance of the subVI if the block diagram contains more than one instance. Undefined or Unexpected Data Undefined data, which are NaN not a number or Inf infinity , invalidate all subsequent operations. Floating-point operations return the following two symbolic values that indicate faulty computations or meaningless results: LabVIEW does not check for overflow or underflow conditions on integer values.

Floating-point operations propagate NaN and Inf reliably. When you explicitly or implicitly convert NaN or Inf to integers or Boolean values, the values become meaningless.

For example, dividing 1 by zero produces Inf. Converting Inf to a bit integer produces the value 32,, which appears to be a normal value. 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.

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.

Error handling is the mechanism for anticipation, detection, and resolution of warnings and errors. With error handling you quickly pinpoint the source of programming errors. Without it, you might observe unexpected behavior but struggle to find the source of the problem. Error handling is also extremely valuable when you test your application to ensure that your error reporting is meaningful and that the error handling code safely stops your application when an error occurs.

For example, during stress testing you are setting values or conditions that are beyond the normal operational capacity of your application which often result in errors. When such errors occur, you want to ensure proper shutdown of your application.

Error handling continues to be important after an application is deployed. Error handling can help detect system and environment differences—such as differences in file systems, memory, and disk resources. National Instruments strongly recommends using error handling. In the error dialog box, each error has a numeric code to identify it and a corresponding error message to display to the user. 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 subVI or function or to an error out indicator.

You also might want the VI to retry for a certain period of time. For example, if LabVIEW encounters an error, you can display the error message in different kinds of dialog boxes. For example, when an error is detected you can fix the error programmatically and then wire the error out output of the VI or function to the error in input of the Clear Errors VI.

Tip Use error handling in conjunction with the debugging tools to find and manage errors. Error Clusters 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.

Use the error cluster controls and indicators to create error inputs and outputs in subVIs. Tip All error clusters on a block diagram typically provide the same standard error in and standard error out functionality. The standard error in and error out clusters include the following components of information: Errors An error is defined as an error cluster with a status value of TRUE, regardless of the code value.

If LabVIEW detects an error, the node passes the error to the next node without executing that part of the code. Although most errors have negative code values and warnings have positive code values, this is not universally true. Therefore you should rely on both the status value and the code value to detect errors and warnings. Warnings are typically considered less severe than errors.

Even though code executes normally, it is important that you monitor warnings during development to ensure proper behavior of your application. Explain Error Dialog Box 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. Just as data values flow through a VI, so can error information.

To implement good error handling, you must determine the actions to take when an error occurs at any point in your application. To begin with, you must utilize the error terminals on functions and VIs. Since the error cluster is implemented as a flow-through parameter, you should propagate errors by wiring the error out cluster of the first node you want to execute to the error in cluster of the next node you want to execute. You must continue to do this for sequences of nodes. Any subVIs that you create should also implement this flow-through behavior.

Refer to Figure for proper use of the shift-register to propagate errors and warnings to successive loop iterations. Refer to Figure for an example of merging error information from parallel node sequences.

Merge Errors From Multiple Sources At the end of your application after all error sources are merged into one error cluster, you must report errors to the user using the Simple Error Handler VI or another error reporting mechanism.

You can select the type of dialog from the following options: This is useful if you want to have programmatic control over handling errors. After the user acknowledges the dialog box, the VI returns control to the main VI. If the user selects Stop, the VI calls the Stop function to halt execution. Each product or group of VIs defines a range of error codes. In addition to defining error code ranges, LabVIEW reserves some error code ranges for you to use in your application.

You can define custom error codes in the range of — through —, through , or , through , Some numeric error codes are used by more than one group of VIs and functions. For example, error 65 is both a serial error code, indicating a serial port timeout, and a networking error code, indicating that a network connection is already established. Quiz 1. Which of the following will result in a broken run arrow?

A subVI is broken b. The diagram includes a divide by zero c. A required subVI input is unwired d. A Boolean terminal is wired to a numeric indicator 2. Which of the following are the components and data types of the error cluster? Boolean b. String c. String 3. All errors have negative error codes and all warnings have positive error codes.

True b. False 4. Merge Errors function concatenates error information from multiple sources. Which of the following are the contents of the error cluster? 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. Front Panel Basics B. Documenting Code D.

While Loops E. For Loops F. Timing a VI G. Data Feedback in Loops H. Plotting Data — Waveform Chart I. Front Panel Basics 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. Inputs for the design can come from the following actions: 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. 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 indicator.

Labels 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, as shown in Figure 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.

Complete the following steps to set the default value of a control or indicator: Enter the desired value. Setting Default Values Tip You can also reinitialize values to their default values. 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. Lesson 3 Implementing a VI ni.

For example, in Figure , 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. Terminal Data Type Example Tip Terminal names correspond to the labels of the controls and indicators on the front panel.

Right-click a terminal and select Find control or Find indicator from the shortcut menu to locate the control or indicator on the front panel. 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 shows a shortcut menu for a control and terminal. Right-click an object and select Properties from the shortcut menu to access the property dialog box for an object.

Figure shows the property dialog box for the Height cm terminal shown in Figure The options available on the property dialog box for an object are similar to the options available on the shortcut menu for that object. Property Dialog Box for a Numeric Terminal You can select multiple objects on the front panel or the block diagram and edit any properties the objects share.

Right-click an object from the selection and select Properties from the shortcut menu to display the Properties dialog box. The Properties dialog box only displays tabs and properties that the objects you select share. Select similar objects to display more tabs and properties. If you select objects that do not share any common properties, the Properties dialog box does not display any tabs or properties. To change the representation type of a number, right-click the control, indicator, or constant, and select Representation, as shown in Figure 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. LabVIEW places a coercion dot on the terminal where the conversion takes place. Refer to Numeric Conversion for more information. The numeric data type includes the following subcategories of representation—floating-point numbers, signed integers, unsigned integers, and complex numbers. Use single-precision, floating-point numbers when memory savings are important and you will not overflow the range of the numbers Double-precision DBL —Double-precision, floating-point numbers have 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 —When you save extended-precision numbers to disk, LabVIEW stores them in a platform-independent bit format. In memory, the size and precision vary depending on the platform. Use extended-precision, floating-point numbers only when necessary.

The performance of extended-precision arithmetic vary among platforms. Fixed-Point Data Type The 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. 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. 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 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. 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.

If the value of the input is midway between two integers, the function returns the nearest even integer. Byte I8 —Byte integer numbers have 8 bits of storage and a range of — to Word I16 —Word integer numbers have 16 bits of storage and a range of —32, to 32, Long I32 —Long integer numbers have 32 bits of storage and a range of —2,,, to 2,,, In most cases, it is best to use a bit integer. Quad I64 —Quad integer numbers have 64 bits of storage and a range of —1e19 to 1e Byte U8 —Byte unsigned integer numbers have 8 bits of storage and a range of 0 to Word U16 —Word unsigned integer numbers have 16 bits of storage and a range of 0 to 65, Long U32 —Long unsigned integer numbers have 32 bits of storage and a range of 0 to 4,,, Quad U64 —Quad unsigned integer numbers have 64 bits of storage and a range of 0 to 2e Complex Numbers Complex numbers are concatenated versions of floating-point numbers with a real and an imaginary part.

In LabVIEW, because complex numbers are a type of floating-point number, complex numbers are also represented with the color orange. There are three types of complex numbers. In memory, the size and precision of extended-precision numbers vary depending on the platform. 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. LabVIEW coerces the bit signed integer because it uses fewer bits than the double-precision, floating-point numeric value.

The lower input of the Multiply function shows a red dot, called a coercion dot, that indicates LabVIEW coerced the data. Any nonzero value represents TRUE.

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: The frequency with which the VI reads the control does not affect this behavior. At this time, the control reverts to its default value, similar to the operation of a door buzzer. You cannot select this behavior for a radio buttons control. 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 action only once each time you set 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. Strings provide a platform-independent format for information and data.

Some of the more common applications of strings include the following: To store numeric data in an ASCII file, you must first convert numeric data to strings before writing the data to a disk file. LabVIEW includes built-in VIs and functions you can use to manipulate strings, including formatting strings, parsing strings, and other editing.

Right-click a string control or indicator on the front panel to select from the display types shown in the 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.

Non-displayable characters generally appear as boxes. There are four display 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 Figure shows an example of these data pairs in the Properties dialog box for an enumerated control. Figure shows the Month enumerated control, the selection of a data pair in the enumerated control, and the corresponding block diagram terminal.

The dynamic data type appears as a dark blue terminal, shown below. 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. 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.

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 Tip strips are brief descriptions that appear when you move the cursor over a control 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.

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: You also can use the Help: Document Tag property to set the help tag programmatically. If this field is empty, the Detailed help link does not appear in the Context Help window, and the Detailed help button is dimmed.

For example, if you name a control Temperature, a user may not know which units to use. 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. By default, free labels have a yellow background color. LabVIEW includes two different types of labels—owned labels and free labels. Owned labels belong to and move with a particular object and annotate that object only.

Free labels are not attached to any object, and you can create, move, rotate or delete them independently. A developer looking at the block diagram can find the name of a function or subVI by using the Context Help window.

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. If you use an algorithm from a book or other reference, provide the reference information. 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. 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. The While Loop executes the subdiagram until the conditional terminal, an input terminal, receives a specific Boolean value. However, the While Loop does not include a set iteration count and runs infinitely if the condition never occurs. If a conditional 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, as shown in Figure An Infinite Loop 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. The iteration terminal is an output terminal that contains the number of completed iterations.

The iteration count for the While Loop always starts at zero. In the following block diagram, the While Loop executes until the Random Number function output is greater than or equal to 0. The And function returns True only if both inputs are True. 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.

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 Figure , which Express VI executes last? 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.

For each set of test values, record the area you get when you run the VI. Switch to the front panel and test the Waveform Subset case. WordPress Shortcode. Building a Basic VI The diagram includes a divide by zero c.