Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

Labview programming basics Tutorial-for loop,while loop,case structure

This Labview programming language tutorial covers for loop, while loop and case structure in labview. This labview tutorial covers following topics:
Labview data types
Creating SubVI
Creating Array and Array operations
Cluster concepts in labview
Various plots in labview
File I/Os
For loop,while loop and case structure
Local variable vs Global variable concepts

While Loop

More than often, we would like an action to repeat until a condition is satisfied; for example, we may want to accept data from the user until the variable provided is of a particular value. At which point we will stop the loop so that it will not process any data further. This is the application where while loop is used.

A While Loop executes the functions it contains until the conditional terminal receives a specific Boolean value either 'True' or 'False'.

This conditional terminal will Stop If True(SYMBOL: red circle in square ) by default. Another terminal is conditional terminal referred as Continue If True, is also available by right click on the conditional terminal. Hence while loop can be used based on boolean control (true or false).

There is another terminal called the iteration terminal, which is an output terminal (SYMBOL: i letter in blue lined square ). Every run of the While Loop is considered as 1 iteration. This terminal as mentioned returns the no. of iterations completed during while loop execution and after the execution. The iteration terminal initializes with zero during start. Hence after first iteration it returns zero.

For Loop

A For Loop similar to While Loop is also a loop structure. The main difference is that For Loop performs as many iterations as provided by its count terminal (SYMBOL: N letter in blue lined square).

for loop conditional terminal

The for loop conditional terminal can be inserted by right clicking it. This terminal takes a boolean value. It instructs the for loop to execute the next iteration or break the for loop without executing the next iterations. This is shown in the figure. Download the example labview VI mentioned below which covers for loops without and with a conditional terminal.

Case Structure

case structure boolean operations in labview

You place the Case structure on the block diagram by selecting it from the Structures subpalette of the Functions palette. You can either enclose nodes with the Case structure or drag nodes inside the structure.

The Case structure is same as conventional if...then...else statements used in text-based programming languages. Only one case executes based on the value wired to the selector terminal. The selector terminal can be numeric or boolean or string. If the data type is Boolean, the structure has a True case and a False case. The case structure can have up to 231-1 cases in numeric or string data types are used.

One can create boolean case structure as well as numeric Case structure. Above figure depicts boolean operations and below figure depicts numeric operations.

case structure numeric operations in labview

REMEMBER FOLLOWING POINTS for programming using case structure:
➨Connect the case port, it is must.
➨Decide and program the case condition.
➨More cases can be added by right clicking the existing one.
➨All the terminals should be connected for all the cases of the structure.

Download Labview Source codes of this loops and case structure

Download For Loop example labview VI
Download While Loop example labview VI
Download Case Structure example labview VI

Related Links

•   What is Labview
•   National Instruments Labview
•   Download Labview, http://www.ni.com/downloads/products/


Useful Links to Labview Source codes

Refer following as well as links mentioned on left side panel for useful labview source codes.

Hex to Binary labview VI      Decimal to Binary labview VI
Number Generator labview VI      Binary to Decimal labview VI
Binary number generator     modulator-demodulator
FFT     up and down sample

Cellular Telecommunications Tutorials -
RF Wireless World

WLAN  802.11ac  802.11ad  wimax  Zigbee  z-wave  GSM  LTE  UMTS  Bluetooth  UWB  IoT  satellite  Antenna  RADAR 

Share this page

Translate this page