LabVIEW stands for Laboratory Virtual Instrument Engineering Workbench. This tool was originally released in the year 1986 for Apple Macintosh. The programming language that is used in LabVIEW is graphical language, which is named as ‘G’. This software is predominantly used for data acquisition, industrial automation, etc.
In contrary to the general text-based programming, LabVIEW is based on graphical programming where the text-based syntax is replaced with graphical symbols and connectors.
A structure is defined as a graphical representation of a loop ( i.e., a loop is nothing but a set of code blocks that are executed based on the condition match). In reality, structures have control over the execution flow within a Virtual Instrument (VI).
There are different types of structures available within LabVIEW. We will discuss the types in detail later on in the article.
To Access a structure, the developer will have to go through the following steps:
In this section of the article, we will discuss the various structures that are available within LabVIEW. The list is as follows:
Let’s understand this structure in detail by considering an example, i.e., while loop structure will be stopped after reaching a value which is equal to 50.
Follow the below steps to create a While Loop:
Click on Functions and select Structures.
Within structures, click on Random number generator icon as shown below in the screenshot.
Select the option as “Numeric” and then select “Multiply” option as shown in the screen below:
Right-click and select Create> Now select the option as “Constant”. Create the constant as 100 in this case.
Now, select the option “Numeric” and then select the option “Round of to Infinity” as displayed in the below screenshot
[Related Article: LabVIEW Basics]
Now, click on the option “Comparison” and then select the option “Equal.”
At this point, create another constant value as 50.
Create an indicator for the output “ Round of to Infinity”
Now, join all the different blocks that we have created so far. After connecting the blocks, the entire block will look like the screen below
Now, execute the program, the while loop structure is in place and random number generator actually generates values. As soon as the random number generates 50, the while loop structure will stop generating the number.
In this case, the condition is met, so the while loop structure has successfully stopped and further it doesn't generate any number.
With the use of “wait timer” the values can be generated and seen in the LabVIEW front panel.
The wait time is actually measured in milliseconds. In this example, the wait time is about 200 milliseconds, i.e., for every 200 milliseconds, the while loop structure will generate a number.
A for loop structure is defined as a program that is executed for a designated number of times. For example, if the For loop structure is set to ‘15’ then the program will be executed for 15 times.
The following block diagram shows the set up for loop structure.
The below diagram shows the variables that we have created (i.e. Constant as N, output variable as “i”).
[Related Article: Introduction of Repetition And Loops in LabVIEW]
Once the program is executed in LabVIEW, the results will be displayed in the front panel of LabVIEW which keep on increasing till it reaches its threshold point.
In this case, the maximum limit is 14.
The output can be displayed in the front end of the LabVIEW (as shown in the below figure).
Let’s see the same below in the form diagram:
Now, execute the below logic and the output is displayed in the screen shown below.
As per the graphical representation, in order to have the calculation completed, we need to have the values available for the variable “x” and variable “y”.Once the system has both the values, then as per the sequence, the addition calculation will be executed and the output is displayed.
Within Sequence structure, we have two different subtypes available, and they are:
In a flat sequence structure, all the frames are available in the block diagram. If there are a lot of frames, then the structure may take a considerable amount of space.
In a stacked sequence structure, all the frames are in sequential order, but they are stacked on top of each other like a case structure.
[Related Article: Modular Programming In Labview ]
Case structures are widely used in the scenarios where the program or the users have to take a decision. The decision is categorized into two options, i.e. True or False.
At any point of execution, only one condition (or case, i.e. True or False) will be executed.
The case structure functionality is explained with a block diagram below:
False condition case block diagram is shown below:
Execute the above program in LabVIEW by entering a positive value from the front end of LabVIEW and after that, enter a negative value from the front end of the LabVIEW.
In this case, the result of a true condition case structure is displayed in the front panel of LabVIEW.
The result shows a negative value within the front panel of LabVIEW.
[Related Article: LabVIEW Tutorial]
The following are the steps to be followed to use a diagram disable structure:
step 1-Select the diagram disable structure from the structures menu.
step 2-Insert the code which you want to execute within the disable frame of the disabled structure.
step 3-To create additional frames, the developer has to right click on the border of the diagram disable structure.
step 4-Select one of the options from the shortcut menu ( as shown in the below figure).
step 5-Only one frame at a time can be enabled.
step 6-To enable a frame then the developer has to right click on the diagram disable structure and select the option “ Enable this subdiagram” from the shortcut menu ( as shown in the below figure)
In this article, we have highlighted the different types of structures that are available within LabVIEW for the developer to utilize based on the requirements. Unlike any other software tool, LabVIEW provides features and facilities where the developers can execute the code according to the ad-hoc needs. So, using structures has definitely reduced the burden for developers.
Free Demo for Corporate & Online Trainings.