EMI Lab04 - updated
EMI Lab04 - updated
EMI Lab04 - updated
Lab Report # 04
Submitted by:
Name:
Roll No:
Submitted to:
Engr. Muhammad Zain Ul Abideen
EXPERIMENT NO 04:
Analysis of Different Structures and Waveforms parameters using
LabVIEW
OBJECTIVE:
To become familiarize with various structures i.e. While loop, for loop, Case
structures, Flat sequences and Shift Registers.
Measurement of different parameters for standard AC signals using LabVIEW.
TOOL REQUIRED:
Computer/Laptop
LabVIEW Software
DISCUSSION:
What is “while loop”?
A While Loop is a structure that repeats a section of code until a condition is met. It is
comparable to a Do Loop or a Repeat-Until Loop in traditional programming language.
The While Loop, shown in the following illustration, is a resizable box you use to execute the
diagram inside it until the Boolean value passed to the conditional terminal (an input
terminal) is FALSE. The VI checks the conditional terminal at the end of each iteration;
therefore, the While Loop always executes at least once. The iteration terminal is an output
numeric terminal that outputs the number of times the loop has executed. However, the
iteration count always starts at zero, so if the loop runs once, the iteration terminal outputs 0.
The following illustration shows a While Loop in LabVIEW, a flowchart equivalent of the
While Loop functionality, and a pseudo code example of the functionality of the While Loop.
The While Loop is located on the Structures palette. 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.
Example:
The For Loop in Figure generates a random number every second for 100 seconds and displays
the random numbers in a numeric indicator.
Example:
In the following examples, the numeric values pass through tunnels to the Case structure and
are either added or subtracted, depending on the value wired to the selector terminal.
Flat Sequence:
Consists of one or more sub diagrams, or frames, that execute sequentially. Use the Flat
Sequence structure to ensure that a sub diagram executes before or after another sub diagram.
Data flow for the Flat Sequence structure differs from data flow for other structures. Frames
in a Flat Sequence structure execute from left to right and when all data values wired to a
frame are available. The data leaves each frame as the frame finishes executing. This means
the input of one frame can depend on the output of another frame.
Unlike in the Stacked Sequence structure, you do not need to use sequence locals to pass
data from frame to frame in the Flat Sequence structure. Since the Flat Sequence structure
displays each frame on the block diagram, you can wire from frame to frame without using
sequence locals and without hiding code.
When you add or delete frames in a Flat Sequence structure, the structure resizes
automatically.
You cannot drag tunnels across the frames of a Flat Sequence structure.
To avoid overusing Flat Sequence structures, attempt to control the data flow of your VI
by establishing data dependency or using flow-through parameters.
Example:
Shift Registers:
Example:
a). Current and previous value without initialing shift register value.
b). Current and previous two values by initializing shift register with 0.
c). Current and previous two values by initializing shift register with 0 and sum of iteration
values in front panel..
Waveform Analysis:
Important parameters of the AC waveform are Vpeak, Vpeak-peak, VRMS, Vave. Amplitude, better
known as its Maximum or Peak value represented by the terms, Vmax for voltage or Imax for
current. The peak value is the greatest value of either voltage or current that the waveform
reaches during each half cycle measured from the zero baseline. Unlike a DC voltage or
current which has a steady state that can be measured or calculated using Ohm’s Law, an
alternating quantity is constantly changing its value over time. A virtual instrument can be
programmed in LabVIEW to measure important parameters of any AC waveform.
PROCEDURE:
In the following exercise, you will build a VI that generates a signal and displays that signal
in a graph and give its +Vpeak, -Vpeak, Vpeak-peak, VRMS, and Vave value. When you complete the
exercises, the front panel of the VI will look similar to the front panel in Figure 1.
Open a new VI. You can open a blank VI by selecting File≫ New VI.
Then you will see front panel and block diagram panel.
Right click on block diagram panel and select the different blocks according to the
given block diagram.
By using selected different blocks construct a complete block diagram.
Create indicators to the required measuring blocks.
Give the standard ac signals of amplitude 5 & 10 and frequency 50Hz as input.
By double clicking on the simulate signal block change the wave forms to sine,
square, triangular, and sawtooth to display different waveforms.
Run the program.
Note down the results from Front panel.
Attach snapshot of your block diagram and front panel for each type of waveform
with lab report.
5
Square
10
5
Triangular
10
5
Sawtooth
10
LAB TASKS
Q1) Create a VI using “for loop”, taking loop count as 100, one Boolean indicator (LED)
which turns “ON” when (Loop count % 2 == 0) with a delay of 1 second for each iteration.
QUESTIONS:
1. Briefly describe Amplitude and Level Measurements Express VI can perform which
voltage measurements on a signal?
Ans: The Amplitude and Level Measurements Express VI in LabVIEW can perform the
following voltage measurements on a signal:
1. Peak Voltage - Measures the maximum positive or negative amplitude of the signal.
2. RMS Voltage - Provides the root mean square value, which is an indicator of the signal's
power.
3. Average Voltage - Computes the average voltage over time, often used for DC components.
4. Peak-to-Peak Voltage - Measures the difference between the highest and lowest points of
the signal.
Ans To build a VI that takes voltage, current, and phase angle and outputs apparent, active, and
reactive power in LabVIEW, follow these steps:
1. Inputs: Create numeric controls for voltage (V), current (I), and phase angle (θ).
2. Apparent Power (S): Calculate using S=V×I
3. Active Power (P): Calculate using P=V×I×cos(θ).
4. Reactive Power (Q): Calculate using Q=V×I×sin(θ).
5. Outputs: Display the calculated values for apparent power (S), active power (P), and
reactive power (Q) using numeric indicators.
Ans: We use Flat Sequences in LabVIEW to ensure that certain parts of the code execute in a
specific, sequential order. This structure is helpful when you need to control the execution flow
of code that must happen step-by-step, especially when one operation depends on the completion
of a previous one.
While Loop: Executes repeatedly until a specified condition is met (stop condition). The
number of iterations is unknown beforehand.
For Loop: Executes a set number of iterations based on a predefined count (N). The loop
runs exactly N times.
Structurally, both loops look similar but have distinct terminal conditions: the While Loop has a
stop condition, while the For Loop has an iteration count terminal.
Ans: The purpose of using an Enum in LabVIEW is to create a list of predefined options or
named values that represent specific states or choices. It enhances code readability and helps
reduce errors by limiting inputs to valid, descriptive selections, often used in case structures or for
control selections in a user interface
Ans: The Flat Sequence structure or the Stacked Sequence structure in LabVIEW is used to
perform different events sequentially. These structures ensure that code executes in a specific
order, with each frame of the sequence running after the previous one is completed.
CONCLUSION:
In LabVIEW, the use of different programming structures such as While Loops, For
Loops, Case Structures, Flat Sequences, and Shift Registers allows for effective
control of data flow and execution logic in measurement and analysis tasks. Each
structure serves a distinct purpose:
Application
When analyzing different parameters for standard AC signals using LabVIEW, these
structures can be applied as follows:
By combining these structures, users can create robust and efficient LabVIEW
applications that measure, analyze, and visualize the parameters of AC signals,
leading to enhanced understanding and control in various engineering and scientific
contexts.