You are on page 1of 42

VIRTUAL INSTRUMENTATION

INTRODUCTION TO VIRTUAL INSTRUMENTATION

PROGRAMMING TECHNIQUES
1.9 - Case and Sequence Structures

Prepared by,
S.BOOBALAN
(Assistant Professor/EEE)
Date: 02-08-2022
OVERVIEW : Programming Techniques
02-07-2019

• VI’s and sub-VI’s


• Loops and charts
• Arrays
• Clusters
• Graphs
• Case & sequence structures
• Formula nodes
• Local and global variable
• String & file input.
Loops & Structures 2 July 2019

A. Loops
• For Loop
• While Loop
• While Loop
• Do While
B. Decision Making
• Case Structure
• Event Structure
• Sequence Structure
• Timed Structure
02-07-2019

Flowchart for If Else…


Decision Making 02-07-2019

Case Structure
02-07-2019
02-07-2019

Example 1: Comparison of Two Numbers


Execution Part
• True Condition
• Addition of Two No’s

• False Condition
• Subtraction of Two No’s
• Step 1: Select and Drop TWO Numeric Controller From control02-07-2019
palette

• Step 2: Select and Drop One Numeric Indicator From control


palette
• Step 3: Select case structure from function palette in Block diagram 02-07-2019
• Step 4: Select the case for True Condition from the top of the rectangular box
02-07-2019
• Step 5: Select Add function from function palette using Numeric Sub VI 02-07-2019

• Step 6: wire it as per your Data Flow Diagram


• Step 7: Select Sub function from function palette using Numeric Sub VI 02-07-2019

• Step 8: wire it as per your Data Flow Diagram


• Step 10: Run the Program 02-07-2019

• True Condition
• Step 9: Run the Program 02-07-2019

False Condition
02-07-2019

Example 2:

Boolean operation in Case


Structure
02-07-2019
• Step 1: Select and Drop TWO Numeric Controller From control02-07-2019
palette

• Step 2: Select and Drop One Numeric Indicator From control


palette
• Step 3: Select case structure from function palette in Block diagram 02-07-2019
• Step 4: Select the case for True Condition from the top of the rectangular box
02-07-2019
Step 5: Select Add function from function palette using Numeric Sub VI
02-07-2019
Step 6: wire it as per your Data Flow Diagram
Step 5: Select Add function from function palette using Numeric Sub VI
02-07-2019
Step 6: wire it as per your Data Flow Diagram
Step 5: Run the Program 02-07-2019
02-07-2019

Types of STRUCTURES

• SEQUENCE STRUCTURES
• Flat Sequence Structure
• Stacked Sequence Structure

• CUSTOMIZING STRUCTURES
• Placing Structures on the Block Diagram
• Placing Objects inside Structures
02-07-2019

Loops
• For Loop
• While Loop
• While
• Do - While
For Loop in LabVIEW
02-07-2019
Flow chart - For Loop
02-07-2019
02-07-2019

Example 1: Simple Random no Generation


02-07-2019
02-07-2019

For Loop in LabVIEW


02-07-2019

• The value in the count terminal ‘N’ (an input terminal) indicates
how many times to repeat the sub-diagram.

• Set the count explicitly by wiring a value from outside the loop to
the left or top side

• The iteration terminal ‘i’ (an output terminal) contains the


number of completed iterations

• The iteration count always starts at zero. During the first


iteration, the iteration terminal returns 0.
Ex. 1: Sum of 10 Natural Numbers using For Loop
02-07-2019

SUM OF FIRST 10 NUMBERS


• Step 1: Create For Loop in Block Diagram form

Function Palette >> Structure >> For Loop


02-07-2019

• Step 2: Create the No of Iteration from N Terminal


02-07-2019

• Step 3: Create the Sum Function and Indicator


• Step 4: ADD SHIFT Register form 02-07-2019

Right click on LOOP structure and ADD SHIFT REGISTER


02-07-2019
• Step 5: Complete the loop with wiring tool
Step 6: Complete Block Diagram and Front Panel Window 02-07-2019
Ex.2 Flashing LED For EVEN Numbers using 02-07-2019

For LOOP in LabVIEW


02-07-2019
02-07-2019

Ex.3 List out the EVEN Numbers & ODD Numbers


using
For LOOP in LabVIEW
02-07-2019
Recall…Summary

You might also like