Laboratory Virtual Instrument Engineering Workbench (LabVIEW) is a design platform developed by National Instruments. It uses a visual programming language named 'G' that helps the developers in graphically building the systems. The text-based code is replaced by graphical icons. The systems are built with a combination of software and hardware. The developers can add hardware and represent complex logic on the diagram. Structures are important while building complex logic for the diagrams. In this post, you will learn about various structures available in LabVIEW. You can also get to know how to use these structures.
The structures in LabVIEW contain sections of graphical code. They control and determine when and how the code should be run in a virtual instrument (VI). A structure can be referred to as a graphical representation of a loop. It helps in iterating a piece of code as many times as we want.
Wish to make a career in the world of Labview? Start with Labview Training !
Open LabVIEW, and open the Front Panel. Click on the 'View' option from the top menu and select 'Functions'. Choose the 'Programming' option and click on the 'Structures' icon. You will get a list of all the structures of LabVIEW. To use a structure, drag and drop them on to the block diagram.
LabVIEW offers different kinds of structures that serve different purposes. Here is the list of structures that are available in LabVIEW.
Let's discuss in detail each of these structures and how to implement them.
The While loop structure continues to execute a programme until a stop condition is met. When a STOP button is clicked, the while loop structure is used to keep the application continuing. Until the created value equals 50 or the STOP condition is met, and the while loop structure continues to execute and generate new values.
Using a for loop structure, the programme is repeated a specified number of times. N is the count terminal in the For loop, and “i” is the iteration terminal. Each time the loop runs, the value of "i" shifts from 0 to N-1.
A For loop might not execute sometimes in a VI when the condition is not met. We can change a While loop to a For loop. To do so, right-click on the border of the While loop and select the 'Replace with For Loop' option from the shortcut menu.
A sequence structure is utilized whenever we need a program to run in a sequential manner. The order of execution is not always under your control in LabVIEW. When a subsequent computation depends on a prior one, we are confident that it will happen in the proper sequence. However, we will not be able to control the sequence of calculations when they are being done in parallel. Calculations are compelled to occur in a predetermined sequence using a sequence structure.
In the flat sequence structure, the block diagram contains all of the frames. The structure could require a huge amount of space if there are many frames.
A flat structure is very flexible. When a frame is added or deleted, it will resize automatically. We can change a flat sequence to a stacked sequence. If we do that, all the input terminals of the frames will be moved to the first frame of the stacked sequence. When we change the stacked sequence to a flat sequence, we have to move the wires of the first frame to their original locations, i.e., individual frames.
Top 30 labview interview questions and answers for 2020!
All of the frames in a stacked sequence structure are arranged sequentially but are layered on top of one another, much like a case structure.
Case structures are more commonly employed in the scenarios when the user or the program need to make a decision. These decisions are classified into two options: either true or false.
Whenever executed, just one condition will be executed i.e., true or false.
The following block diagram explains the functionalities of the case structure:
Following is the true condition case block diagram. From the LabVIEW front end, the user will have the ability to enter a value in "X." (that can be viewed on the block diagram’s left-hand side).
Following is the case block diagram for False condition:
In LabVIEW, run the above program entering the positive value from LabVIEW’s front end and then a negative value is entered from LabVIEW’s front end.
In this case, a true condition case structure result is shown in the LabVIEW front panel.
Then a negative value is displayed as a result within the LabVIEW’s front panel.
The steps to use a diagram disable structure are as follows:
Step 1: From the structures menu, choose the diagram disabled structure.
step 2: Place the code that you wish to run inside the disabled structure's disable frame.
Step 3: The developer must do a right-click on the diagram's border to disable the structure for adding more frames.
step 4: choose an option from the shortcut menu.
step 5-Only one frame at a time can be enabled.
step 6-To enable a frame then the developer need to right click on the disable structure diagram and choose the option “ Enable this subdiagram” from the shortcut menu (as shown below)
step 7: A single frame can only be activated at a time.
step 8: The developer must right-click on the diagram's disabled structure and choose "Enable this subdiagram" from the shortcut menu in order to enable the frame.
When we have some subdiagrams to execute depending on a condition, we can use a conditional disable structure. We can disable a subdiagram on the block diagram, so it executes based on a user-defined condition. Place a conditional disable structure on the block diagram, and add a subdiagram to it. Right-click on the border of the structure and select the 'Edit Condition For This Subdiagram' option.
We will get a configure condition dialog box where we can configure conditions. It also provides pre-defined symbols to configure conditions. We will have a selector label to scroll through the available subdiagrams in the structure. When we delete the structure, the subdiagrams won't get deleted.
In this post, we have explained in detail about all the structures in LabVIEW. Using structures will make the programming easy for developers. LabVIEW has introduced them, so the developers can execute the subdiagrams according to their needs. Try out different structures in the development of VI in LabVIEW.
Batch starts on 5th Jun 2023, Weekday batch
Batch starts on 9th Jun 2023, Fast Track batch
Batch starts on 13th Jun 2023, Weekday batch
Following are some of the main types of structures that are used in Lab VIEW:
An enumerated type is made up of a string labels list and their associated integer values. In LabVIEW, it is managed as an unsigned integer.
An event structure is a basic structure with numerous sub diagrams, among which one is runtime-selectively executed. The structure keeps waiting until something happens or until the timeout expires. It consumes no CPU time when it is waiting.
Following are the 6 different types of structures:
A cluster is comparable to record or a struct in the text based programming languages. Identical to arrays, a cluster could only store one of the two types of data: a control or an indicator and cannot include both.