Lab 4-Software and Analysis
Lab 4-Software and Analysis
All rights reserved. Neither this resource, nor any portion of it, may be copied or reproduced in
any form or by any means without written permission of the publisher.
National Instruments respects the intellectual property of others, and we ask our readers to do
the same. This resource is protected by copyright and other intellectual property laws. Where
the software referred to in this resource may be used to reproduce software or other materials
belonging to others, you should use such software only to reproduce materials that you may
reproduce in accordance with the terms of any applicable license or other legal restriction.
All other trademarks or product names are the property of their respective owners.
Additional Disclaimers: The reader assumes all risk of use of this resource and of all
information, theories, and programs contained or described in it. This resource may contain
technical inaccuracies, typographical errors, other errors and omissions, and out-of-date
information. Neither the author nor the publisher assumes any responsibility or liability for any
errors or omissions of any kind, to update any information, or for any infringement of any patent
or other intellectual property right.
Neither the author nor the publisher makes any warranties of any kind, including without
limitation any warranty as to the sufficiency of the resource or of any information, theories, or
programs contained or described in it, and any warranty that use of any information, theories, or
programs contained or described in the resource will not infringe any patent or other intellectual
property right. THIS RESOURCE IS PROVIDED “AS IS.” ALL WARRANTIES, EITHER
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY AND ALL
IMPLIEDWARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
AND NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, ARE DISCLAIMED.
No right or license is granted by publisher or author under any patent or other intellectual
property right, expressly, or by implication or estoppel.
IN NO EVENT SHALL THE PUBLISHER OR THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, SPECIAL, INCIDENTAL, COVER, ECONOMIC, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THIS RESOURCE OR ANY INFORMATION, THEORIES, OR PROGRAMS
CONTAINED OR DESCRIBED IN IT, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES, AND EVEN IF CAUSED OR CONTRIBUTED TO BY THE NEGLIGENCE OF THE
PUBLISHER, THE AUTHOR, OR OTHERS. Applicable law may not allow the exclusion or
2
limitation of incidental or consequential damages, so the above limitation or exclusion may not
apply to you.
3
Lab 4: Software and Analysis
In this lab, you will take what you know about signals and sensors and will learn
about Data Acquisition Software (DAQ) as well as data analysis and visualization.
Data acquisition involves gathering signals from measurement sources and digitizing
the signals for storage, analysis, and presentation on a PC.
You will continue with the temperature and strain scenarios from the previous labs, and
build a software solution to the measurement scenario.
Next, you will run through some pre-built activities highlighting different analysis
techniques and software processes.
4
Figure 1 Basic Histogram
Learning Objectives
5
Required Tools and Technology
NTC 10 kΩ Thermistor
C2A-13-125LW-350 Strain Gauge
Various discrete components to
complete signal conditioning circuits
6
Expected Deliverables
Your instructor may expect you complete a lab report. Refer to your instructor for
specific requirements or templates.
7
1.1 Theory and Background
Video Summary
Application software facilitates the interaction between the computer and user
for acquiring, analyzing, and presenting measurement data
A Fast Fourier Transform converts a signal in the time domain to a signal in the
frequency domain.
Some measurement and analysis techniques include frequency and level
Statistics help to understand complex and often large amounts of data by
simplifying the data into comprehensible tables, numbers or graphs
Data visualization techniques include graphs, charts and tables.
8
Frequency, Level, Time-Domain and Statistical Analysis
Frequency
Measuring the frequency of an analog signal is similar to measuring the rate of a digital
signal. However, you cannot directly measure the frequency of an analog signal.
Software analysis of the signal is required to extract the frequency information. The
analysis is usually done by an algorithm called a Fast Fourier Transform, also called an
FFT.
In the previous lab, we saw that before an analog signal can be analyzed it needs to be
conditioned and then converted to a digital signal that a computer can read as a
sequence of data. This last step is done by sampling the signal a certain number of
times over some time-length. The sequence of numbers resulting from this sampling
usually represents voltage values of the signal at various times. Thus, the obtained
digital signal approximates the amplitude value over time. We refer to this signal
representation as time-domain representation since it approximates the amplitude at
each specific time.
However, in some cases, you need to know the frequency content of a signal rather
than the amplitudes of the individual samples. Fourier's theorem states that any
waveform in the time domain can be represented by the sum of various sines and
cosines with different frequencies. For example, consider the Nyquist vi you worked with
Lab 3. The original signal was actually the sum of three sine signals each with a
different frequency. Fourier’s theorem says that any waveform signal can be
represented in similar fashion. The elements of this sum are referred to as components
of the signal. The frequencies of these components are called the frequency
components of the signal.
As a conclusion, the same waveform can be represented in the frequency domain. The
samples of a signal obtained from a DAQ device constitute the time-domain
representation of the signal i.e. the amplitude variation over time. Computing the Fourier
Transform of this signal yields the frequency components. However, this computation is
time-consuming. The FFT (Fast Fourier Transform) is a clever algorithm that allows us
to compute the Fourier Transform at a fast rate. The FFT resolves a time waveform into
its sinusoidal components in the frequency domain. Among many other functions, the
FFT analyzer provided by the LabVIEW library takes a block of time-domain data and
returns the frequency spectrum of the data. The FFT is a digital implementation of the
9
Fourier transform. Thus, the FFT does not yield a continuous spectrum. Instead, the
FFT returns a discrete spectrum, in which the frequency content of the waveform
is resolved into a finite number of frequency lines or bins.
Coupled with the FFT in frequencies is the power spectrum. The power spectrum yields
the energy distribution of a signal across the different frequency components. This
allows us to differentiate between frequency components with a higher energy density
(usually understood as representing the actual components of the original signal) and
the those with a relatively negligible energy density (usually representing noise).
A clarifying method for seeing the capability of the power spectrum is to analyze a
signal containing a known frequency but have noise and other components added to the
signal. The power spectrum will capture the energy of the embedded periodic signal in
relation to the other components such as noise.
The FFT and the power spectrum are useful for measuring the frequency content of
signals.
Level
Measuring the level of an analog signal is similar to measuring the state of a digital
signal. The only difference is that an analog signal can be at any voltage state, whereas
a digital signal can only be at one of two states, either ON or OFF.
Peak detection is one of the most important time-domain functions performed in signal
monitoring. To clarify, peak detection is the process of finding the locations and
amplitudes of local maxima and minima in a signal that satisfies certain properties. It is
important to note that these properties can be simple or complex. For example,
requiring that a peak exceeds a certain threshold value is a simple property. However,
requiring that a peak’s shape resembles that of a prototype peak is a complex property.
More information on peak detection using LabVIEW and measurement studio can be
found here: http://www.ni.com/white-paper/3770/en/.
When considering levels, the root mean square (RMS) is also very important. The RMS
is a widely used quantity for analog signals.
The root mean square (RMS) of an input sequence equals the positive square root of
the mean of the square of the input sequence. In other words, you can square the input
sequence, take the mean of the new squared sequence, and take the square root of the
mean of the new squared sequence. The following equation yields the RMS Ψ X for an
input sequence X :
10
Equation 1-1
Equation 1-2
Please note that in the above equation Vp is the peak amplitude of the signal.
More information on statistics and calculating a variety of statistical data will be explored
next.
Statistical
Histograms
Mean
Mode
Standard Deviation
Histograms are specialized plots that capture statistical data about how many times
specific values occur. Histograms are usually plotted with the dependent variable along
the vertical axis and the independent variable along the horizontal axis. An independent
variable is one that can be changed or controlled. A dependent variable relies on the
independent variable and remains unchanged and un-manipulated. This is important
11
because if the independent variable is changed the dependent variable can be studied
to observe and record the results as it is a constant.
The mean is an average of a set of numbers. For instance, given the numbers 10, 30,
50, 150 the mean would be calculated by adding the sum of the numbers and then
dividing the sum by 4 as there are 4 numbers in the data set. In this example we
calculate the mean as such:
10 + 30 + 50 + 150 = 240
240 / 4 = 60
Therefore, the mean of this data set would be 60. This concept can be applied to any
set of numerical data.
In statistics, the mode is the number that occurs most frequently in a data set. For
instance, given the numbers 1, 1, 1, 0, 3, 4, 2, 2, 9 you can calculate the mode by
ordering the numbers in ascending order. After doing this count the number that
appears most often. This number is the mode. In the above example, the mode is 1. It is
important to note that you will sometimes find that there is more than one mode. When
this happens, the data set is said to be bimodal if there are two modes and multimodal if
more than two modes are present.
12
Check Your Understanding
Note: The following questions are meant to help you self-assess your understanding so far. You
can view the answer key for all “Check your Understanding” questions at the end of the lab.
1.1 Monitoring a temperature chamber that is never to exceed 100 degrees or go below
30 degrees, which analysis technique are we interested in?
A. Power
B. Level
C. Frequency
D. Mean
13
Data Visualization
When it comes to data processing, there are two types that need to be considered:
Real-time data processing happens almost instantaneously. Because of this, the data is
evaluated in a very short period of time. This type of processing requires a constant flow
of input in order to provide a constant flow of output.
Inline analysis implies that the data is analyzed within the same application where it is
acquired. This is generally the case when dealing with applications where decisions
have to be made during run time and the results have direct consequences on the
process, typically through the changing of parameters or executing of actions. This is
typically the case in control applications.
When dealing with inline analysis, it is important to consider the amount of data
acquired and the particular analysis routines that are performed on that data. A proper
balance must be found because they could easily become computationally intensive
and have an adverse effect on the performance of the application. This type of
processing has a single, immediate use, and then the data is no longer available.
Offline applications don’t typically have the demand for results to be obtained in real-
time fashion in order to make decisions on the process. Offline analysis applications
require only that sufficient computational resources are available. The main intent of
such applications is to identify cause and effect of variables affecting a process by
correlating multiple data sets.
It should be noted that offline processing is best for instances when you do not require
the data immediately to make a decisions based on your data. Because the data is
saved separately from the device, this means the data can be revisited as much as
14
needed. This is also beneficial because you are not limited by the constraints of the
data acquisition process as you would be in real-time processing.
1.2 Given a measurement scenario, when would saving data for processing later be
useful?
A. When you need to determine the cause and effect of multiple data sets
B. When you need immediate data results
C. When data is being analyzed within the same application from which it was
acquired
D. When using a control application
15
1.2 Finding Help
Data acquisition is a wide and deep field. It is impossible to cover all of its topics. Thus,
many of the essential topics are covered, but not all. It is essential that you know where
you could find help and more information.
LabVIEW Help
You can find help regarding any function in the palette by right-clicking the function,
then choosing Help. For instance, right-clicking the wait function and choosing Help,
yields:
16
Figure 1-3 LabVIEW Example VIs
To browse all available example VIs, click on Help in the menu bar of the Control Panel.
Then, click Find Examples. The following pop-up window will show up displaying all the
examples Vis.
17
Figure 1-5 NI Example Finder
You can browse through a hierarchy of topics on the Browse tab, or you can search for
specific topics in the Search tab.
National Instruments’ Website provides extensive support for LabVIEW users through
print and media tutorials. The following are few examples of where to get help.
The following links to series of short video tutorials covering important and basic
aspects of LabVIEW programming: http://www.ni.com/academic/students/learn-
labview//
18
The main help search page that helps you narrow your search according to
different parameters, such as topic, media, type of help, and more, can be found
here: http://www.ni.com/tutorials/
19
1.3 Implement: Voltage to Temperature Conversion in LabVIEW
So far you’ve experimented with acquiring data from a thermistor. In Lab 1 you did a
case analysis and chose a suitable thermistor that best fit your case needs. In Lab 2,
you were given one thermistor and you conditioned it by building a voltage divider. In
Lab 3 you computed the minimum temperature detected by your DAQ device from the
conditioned thermistor at 40ºC.
In this implementation, you will complete the final stage of the signal chain and convert
a conditioned signal to a representation of the temperature signal. Thus far, you’ve
acquired data as a measured voltage. In software, you need to implement a conversion
of the measured voltage back into the real-world signal, expressed in engineering units.
This process is basically an unwinding of the signal-conditioning circuit that you’ve built
as well as accounting for the sensor’s properties.
You can think of this like as the mirror image of the sensor and circuit converting a
physical phenomenon into a voltage.
To do this, you will explore a pre-built VI that converts the voltage read from the ADC
and transforms it to a temperature value expressed in ºC. This will take three steps:
First, you will use a VI that converts the voltage read from the conditioned circuit
into resistance. Your ADC gives us a voltage, but the thermistor expresses
changes in temperature by changing its resistance. This was converted to a
voltage in a voltage divider, so we need to undo that process and identify the
resistance of the thermistor.
Second, you will go through a VI that converts thermistor resistance to
temperature values. In previous labs, you’ve referred back to the sensors spec
sheet to identify how a resistance value corresponds to a temperature. This can
be implemented in software to automate the process.
Finally, you will combine these VI’s together to convert voltage read from a signal
into temperature readings. The goal is to understand how the different
components of the VI work.
20
Voltage to Resistance
1. Open the Thermistor Measurement LabVIEW project that was provided in the
courseware zip file.
2. Configure the IP address of your NI ELVIS III.
3. Open the Virtual Instrument (VI) called Voltage-Resistance Conversion.vi.
R1
R 2=
( VV −1)
¿
out
Equation 1-1
V out is the voltage read from the ADC. V ¿ was chosen to be 5 V and R1is 10 kΩ.
The following short video provides a quick introduction to the LabVIEW environment:
http://www.ni.com/academic/students/learn-labview/environment/
21
Vout: A Numeric Control that receives numeric input. It represents the voltage read by
the DAQ from the conditioned thermistor.
The following is a short video that explains Indicators, Controls, and Constants:
http://www.ni.com/academic/students/learn-labview/graphical-programming/
Note that the units of R2 and Vout are given respectively in kΩ and V. Thus, the
indicators, which will be on the Control Panel and the user will interact with, need to
reflect that. The page linked below shows you how you can manipulate units of Controls
and Indicators. http://zone.ni.com/reference/en-XX/help/371361M-
01/lvhowto/numeric_units/
4. Run the program and change the values of Vout. This would give you a feel of
what the VI does.
5. In Lab 1, you identified that a voltage of 1.683 V corresponds to a resistance of
5074 Ω. Confirm that a Vout value of 1.683 V converts to 5074 Ω in this VI.
22
The Block Diagram
The While Loop: Represented by the gray block encircling all the other components in
the VI. This loop tells the VI to execute the components inside it repetitively until the
Stop Button is pressed. Note that the Stop button icon in the Block Diagram is wired to
the stop condition of the loop; thus, allowing it to control its execution. Check this short
video that explains LabVIEW While Loop and other execution structures:
http://www.ni.com/academic/students/learn-labview/execution-structures/.
Vin and R-KOhms: Represent the two constant parameters in the above formula. They
are declared as LabVIEW Constants because their values were preset in the
conditioned circuit and they are not expected to change throughout the process of data
acquisition.
Formula: The formula for voltage to resistance conversion is implemented via two
division functions and a decrement-by-1 function. The functions can be found in the
Function Palette under the Numeric sub-palette.
V and kOhm Converters: These are two unit converters. The following link shows you
how to manipulate units of Controls and Indicators. http://zone.ni.com/reference/en-
XX/help/371361M-01/lvhowto/numeric_units/
Wait Function: Represented by the watch icon, the wait function makes sure each loop
iteration takes at least 50ms. This makes sure the loop doesn’t run continuously,
overloading the computer’s processor.
23
1.3 Fill out the following table by typing in the various numbers in the Vout control. Once
done, click the stop button.
Table 1-1
Vout R2
0
5
2
3
4.1
4.25
24
Resistance to Temperature
Next, you will investigate a VI that converts the resistance of the thermistor into
temperature values in degrees Celsius.
In Lab 2 you performed such a conversion by inspecting the table on page 9 of the
thermistor’s spec sheet. We need to automate this process. A basic way of doing this is
to import the table data. Then, for each resistance reading, have the DAQ software
retrieve the corresponding temperature from the table. Ideally, the formula should take
RT
for input a given value for and return the corresponding temperature. Furthermore,
R 25
the value returned should coincide with the value provided in the table. A mathematical
technique that helps us find such a formula is called finding a line of best fit. Consider
RT
the graph in Figure 2. The x-coordinate represents the values and y-coordinate
R 25
represents the corresponding temperature values. The x and y coordinates of each
marked point represent a pair of resistance ratio and its corresponding temperature
from the table. A function that represents this data has a graph that is:
25
Figure 1-9 Resistance to Temperature Graph
A line of best fit is a function whose graph runs extremely close to the ideal graph.
There are multiple ways to find lines of best fit, each of which does the approximation to
a certain degree of accuracy. LabVIEW provides you with a host of pre-built functions
that would calculate lines of best fit. Check out the following link for more on lines of
best fit: http://www.ni.com/white-paper/6954/en/.
For this thermistor, we have a pre-built VI that implements the line of best fit to the data
on page 9 of the spec sheet.
1. From the Thermistor Measurement LabVIEW project, open the Line of Best Fit.vi.
2. Make sure that the IP address of your NI ELVIS III is configured.
3. Run the VI.
The XY Graph has two plots. The plot named Ideal Curve (colored white) represents the
ideal line of best fit that runs through all the data points in the table. The plot names
Line of Best Fit (colored Red) represents the line of best fit we provide. Use the graph
palette zoom function to get a closer view of certain parts of the curves. This is
especially handy at places when two plots seem to coincide.
The first two columns of the table on the left of the graph contain the actual values from
the table in the spec sheet. The column entitled Calculated Temp contains the
approximated values as computed by the line of best fit equation.
26
Understanding the Block Diagram
In order to get a full description of any LabVIEW function or control right-click on it and
click Help.
27
For Loop: Computes the approximated temperature value from each resistance
ratio using the equation of the line of best fit. Below we will explain the equation.
For more on loops, please consult the link:
http://www.ni.com/academic/students/learn-labview/execution-structures/
Bundle 1, Bundle 2, and Build Array: Combines X and Y arrays into pairs, and
then combines the ideal and calculated best fit curves into a single array to be
graphed together.
Calculated Temp: Displays the values of the estimated temperature values.
The equation computes the temperature value for a given resistance ratio in two stages.
In the first stage, the equation computes an approximate value using the formula
Fit_Formula_1. At the second stage, the equation does one of two different
computations. One computation is valid for the resistance ratio values that are larger or
equal to 0.27. You can find this computation in the formula entitled Fit_Formula_2. The
second computation applies to those values larger than 0.27. You can find this
computation in the formula entitled Fit_Formula_3. The way the VI decides whether to
apply Split Diff 1 or Split Diff 2 is through the comparison function and the case
structure. If the RT/R25 – value read is larger or equal to 0.27 then the True case of the
structure is implemented. Otherwise, the False case is.
28
Figure 1-12 Fit_Formula_3.vi False (left) and Fit_Formula_2.vi True (right)
All three formulas are declared as SubVIs. The interested reader can Double-click the
formula icon to see the exact details of each formula. Declaring certain parts of a VI as
a SubVI is a great tool to simplify your block diagram. Furthermore, it has the added
advantage that comes with modular programming. For more on modular programming
and SubVIs follow the link: http://www.ni.com/white-paper/7593/en/
Resistance to Temperature
This VI converts a voltage reading from the conditioned circuit to a temperature value.
1.4 Input Vout values corresponding to the table below, and record resistance and
temperature values in the following table.
Table 1-2
29
4. Confirm, from the resistance values and the thermistor spec sheet, that the
output temperatures accurate.
5. Open the block diagram of the program and observe how the previous VIs were
combined.
30
1.4 Implement: Temperature Measurement Scenario
1. Use the Simple Acquisition VI from the ADC – Thermistor LabVIEW project
from Lab 3 as a starting point for acquiring a measured voltage from the
thermistor.
2. Combine the Voltage to Temperature code from above, to measure a live
temperature measurement.
1-5 With this implemented, what temperature value is measured from the room?
_____________________________________________________________________
_____________________________________________________________________
1-6 What resistance value does the measured value correspond to?
_____________________________________________________________________
_____________________________________________________________________
1-7 According to the thermistor spec sheet, what temperature is this? Do they match,
and are they realistic?
_____________________________________________________________________
_____________________________________________________________________
1-8 Repeat these measurements and record your observations after heating the
thermistor with your fingers by pressing on it.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
31
Monitor a heating chamber that has an internal temperature of 20°C at the
beginning of the test procedure, and determine if the heating chamber ever
exceeds 40°C.
1-9 What characteristic of the signal is this scenario interested in? How would you
complete the measurement scenario? Document your implementation.
_____________________________________________________________________
_____________________________________________________________________
32
1.5 Implement: Voltage to Strain Conversion and Measurement Scenario
In the following implementation, you will build a VI that converts the voltage read from
the ADC to strain. Refer to the conditioned signal you built in Lab 2 and the conversion
you performed in Lab 3 for the specified strain gage.
1. Find the Gage Factor GF of the strain gage. It should be printed on the back of
the package.
Build a VI that converts the voltage read from the bridge into engineering units of strain.
You implemented these calculations in Lab 3. Recall that the formula you need can be
found at: https://en.wikipedia.org/wiki/Strain_gauge.
2. Update your VI so that it receives the voltage reading from the ADC you’ve built
in Lab 3
3. Unlike the Thermistor measurement, there is one more signal conditioning stage
that you will need to account for. You built an amplifier that multiplied the voltage
output of the bridge by a gain factor.
4. In your code, you’ll need to “unwind” this amplifier by dividing the measured
voltage by the gain factor that you designed. After the voltage is divided, you’ll
have a realistic representation of the output of the bridge.
Measurement Scenario
33
second, then off for 1 second. This cycle will repeat for 24 hours. The rod has
a width of 1.5mm and a length of 24mm. However, the linear area that the
force is applied to is approximately 4mm.
You won’t actually run for 24 hours, but your code would need to be able to run for an
extended period of time. Setup your strain gauge to replicate the on-off pattern of strain,
and confirm that you can visualize 1second on and 1 second off.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
34
1.6 Simulate: Frequency Analysis in LabVIEW
The following is designed to help you understand how the FFT Power Spectrum VI
works. Before you begin it is useful to understand the various parameters affecting a
sine wave signal.
1. Open the Signal Analysis LabVIEW project that was provided in the courseware
zip file.
2. Configure the IP address of your NI ELVIS III.
3. Open the Virtual Instrument (VI) Sine Wave.vi.
Perform each of the following and at each step record the changes introduced to the
graph.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
35
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
1-11 In your own words describe the relationship between the sampling rate and the
number of samples. How do they affect the number of signal periods (number of
repetitions of full signals)? You may use your observations from above to try and check
various changes.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
Consider the signal from preceding problem. Suppose we sampled that signal 80 times
over equal intervals of time. Assume that all we knew about this signal was these 80
numbers (voltage readings) that we had. The FFT analyzer will determine from the 80
points the approximate frequency domain representation of the initial signal. While it is
useful to compute the FFT in many situations, it is enough for our purposes to look at
the power spectrum. The Power Spectrum of a signal yields the various frequency
components in a signal together with their corresponding strengths. It helps us identify
the components with large amplitude and those with a small amplitude (noise). The
LabVIEW function Power Spectrum VI does just that for us.
The following VI will help you understand the functionality of the power spectrum VI by
applying it to a signal you are familiar with, the sine signal. You will also get the chance
to incorporate multiple sine components in the signal (see lab 3, Nyquist.vi to refresh
your memory on multiple component signals), change their frequencies and amplitudes.
The program is set to sample 256 equally spaced samples of the signal.
36
1. From the same project, open the VI called FFT Power Spectrum.vi, make sure
the IP address of your NI ELVIS III is configured, and run the VI.
1-12 Initially, all component frequencies are zero; hence the signal is flat. While keeping
frequencies 1, 2 and 3 set to zero, fill out the following table with the approximate values
you read on the Power Spectrum graph.
Table 1-3
1-13 How were the values of the frequencies you’ve set reflected on the frequency axis
in the power spectrum?
_____________________________________________________________________
_____________________________________________________________________
1-14 Depending on the frequency axis settings, you might see two frequency spikes
occurring each time? It is no coincidence the power spectrum is always symmetric
across the middle (The Nyquist Frequency). For more on that see:
http://www.ni.com/white-paper/4541/en/.
_____________________________________________________________________
_____________________________________________________________________
1-15 Set two of the frequencies to 0 and the other two to two different non-zero
numbers. What happens to the powers spectrum?
_____________________________________________________________________
_____________________________________________________________________
37
1-16 What happens if you choose the same non-zero number for both frequencies?
_____________________________________________________________________
_____________________________________________________________________
1-17 Set frequency 1 to 1 and the others to zeros. Consecutively change the offset to 1,
2 and 3. What change do you observe on the power spectrum (hint: Check the power
spectrum at frequency 0)? What aspect does this change represent about the signal?
_____________________________________________________________________
_____________________________________________________________________
1-18 Set the offset to 1 and the frequencies respectively and in order to 1, 2, 3 and 7. In
your own words describe how the power spectrum help you understand the input signal
better assuming you hadn’t known the frequency components.
_____________________________________________________________________
_____________________________________________________________________
38
1.7 Simulate: Peak/Valley Analysis in LabVIEW
The following LabVIEW application is intended to familiarize you with the concept of
peak analysis. If you are not familiar, the concepts of peaks and valleys consider the
following brief explanation:
Peak Threshold and width: Consider the red horizontal line. It is called the peak
threshold. A portion of the signal is considered a peak if it starts below that threshold,
exceeds it and then returns below it. Setting the width parameter to some number
imposes an additional condition for a portion of the graph to be considered a peak.
Namely, it requires that the number of successive elements that exceed the threshold is
greater than or equal to the width.
Valley Threshold and width: Consider the blue horizontal line. It is called the valley
threshold. A portion of the signal is considered a valley if it starts above that threshold,
falls below it and then exceeds it. Setting the width parameter to some number imposes
an additional condition for a portion of the graph to be considered a valley. Namely, it is
required that the number of successive elements that fall below the threshold is greater
than or equal to the width.
39
1. From the same project, open the VI called Peak Analysis.vi, make sure the IP
address of your NI ELVIS III is configured, and run the VI.
From the same LabVIEW project open the VI called Peak Analysis.vi.
1-19 While the program is running click and drag the red line to above the value 1 and
blue line below the value -2. Keep the width set to 3. What are the numbers of peaks
and valleys detected?
Note: The peaks and valleys are respectively dotted by red and blue points.
1-20 Drag the red line to 0.1. Why is the last part of the signal (which is clearly above
that peak threshold) not selected as a peak? Would changing the width make a
difference?
_____________________________________________________________________
_____________________________________________________________________
40
1.8 Simulate: Saving Signal Data to File
LabVIEW offers a library of VIs to create data files, append and save them. The VIs
could be found in the function palette under programming – File I/O. The following pre-
built VI simulates saving a part of a signal satisfying a certain condition and triggering.
1. From the same project, open the VI called Saving Signal Data.vi, make sure the
IP address of your NI ELVIS III is configured, and run the VI.
41
Figure 1-17 Waveform Chart
The enclosing While Loop ensures that the signal is repetitively generated until the
stop button is clicked by the user. Before dynamic data can be processed by numeric
functions it needs to be converted to the proper data type first. The Convert From
Dynamic Data Express VI does the job (see Figure 1-17).
42
Using a Case Structure will allow the Write To Measurement File function to be
triggered only in the case when the condition connected to the Case Selector is true.
The condition is true if the criteria set forth in the problem given are satisfied. In other
words, the condition is true if the amplitude generated exceeds 0.9 or if the program is
already in the process of writing to a file for a time not exceeding 10s. Thus, at each
loop iteration we need to keep track of:
And the total time spent writing to the same file. Once this time exceeds the
10-second limit, the file is saved and closed and the loop proceeds to the next
iteration. In order to keep track of time, another shift register is used and
initialized to the time the While-loop starts executing (see Figure 1-19). This
shift register value is kept unchanged at each loop iteration until a new file is
created. Then, it is set to the time the file is created. Following that, at each
iteration, the Get Time function is called and the time stored in the shift
register is subtracted from the current time. This will yield the length of time
the VI has spent writing to the same file so far (see Figure 1-20).
Whether we need to create a new file and write data to it or keep writing to
the same file form the preceding loop. To this end, another shift register is
introduced and set to T(True) before the loop starts. The value of the shift
43
register is changed to false the moment a new file for writing is created. Once
writing to file is concluded (time exceeded 10s), the register is set again to
true. The value of the register is connected to the new_file and Flush
parameters of the Write To Measurement File. The Flush parameter indicates
whether the data to be saved to the Excel file from the temporary file. The
new_file parameters indicates whether the data needs to be written to a new
file or simply appended to the one already being written to. Resetting this
function saves and closes the current file it is writing to and creates another
file for writing (see Figure 1-21).
Finally, the VI needs to name the files according to the format set forth earlier. Double-
click the Write To Measurement File icon. A window will pop-up. This window will help
you configure the function.
44
Figure 1-22 Function Configuration Window
Under File Format settings, Microsoft Excel is chosen as shown in Figure 1-22.
Furthermore, Save to series of files (multiple files) is chosen. This will allow the VI to
write the data to multiple files. If this option is not chosen, the function overwrites the
same file each time it is initialized and run. The directory where the files are saved is
indicated in the path in the Filename box.
Click on Settings of Save to series of files to choose the files name format and location
set forth in the problem given (see Figure 1-23).
45
Figure 1-23 Multi-File Configuration Settings
The function will combine the name test.xls provided in Filename and the format
specified in the settings of Save to series of files to create file names in the desired
formats.
1. From the dialog box of the Write to Measurement File function choose a path to
the directory where you want the files to be saved on your computer.
2. Run the program the program for more than 20s. The Timer will help you keep
track. The files shown in Figure 1-24 were produced. The files are named
according to the proper path and name format.
Figure 1-24
46
3. Open the file test_18-05-16_1106_001 (see Figure 1-25). The column titled Time
indicated the date and time each amplitude was recorded. The untitled column
indicates the corresponding amplitudes. Note that recording did not start until the
amplitude 0.910658 was read. The time of that recording was 11:06:25.366.
Figure 1-25
According to the last entry in the file, the recording continued for 10s irrespective
of the amplitude and stopped at 11:06:35.000 (see Figure 1-26).
47
Figure 1-26 Stopping Time
4. Open the remaining files and check that the recording of data fits the criteria. The
last recorded file might not have data records for 10s in case the program was
stopped earlier.
48
1.9 Implement: Vibration
Earlier in this lab, we used the FFT Power Spectrum Analysis and Peak Analysis VI to
analyze the frequency components and peaks of a simulated signal. In this section, we
will use those techniques to analyze a real-time signal acquired from a vibration sensor.
Consider again the vibration testing scenario described in Lab 3. We go over the
description of the scenario again for the sake of convenience.
The specifics of the sensor will be covered in more detail in Lab 8. For now, it is
important to note how the sensor functions (see the figure below). When the beam is
mounted horizontally, acceleration in the vertical plane creates bending in the sensor
tape, due to the inertia of the mass at its tip. Strain in the tape creates a piezoelectric
response, which may be detected as a charge or voltage output across the electrodes
of the sensor. The sensor outputs 1Volts per 1g acceleration. We will use the sensor in
measuring vibration signals with frequency components less than 75. This is because
the resonance frequency of the sensor is 75. At this frequency, the sensor will output 5
V/g and we want to avoid that.
Figure 1-27 Vibration Sensor Figure 1-28 Sensor Required Strain Direction
The vibration signal that we would be measuring is one emitted by a computer fan.
Computer fans are well centered around their axis of rotation. Furthermore, they are
fitted within a frame that provides them with further stability when fastened to a support.
In order to obtain a vibration that would cause the required bending in the sensor’s tape,
we need the fan to emit a stronger vibration that wound cause acceleration that could
49
be detected. One way to do this is to attach a weight to one of the fan blades to disturb
the balance of the fan around its axis of rotation. We used a paper clip to do that (see
the figure below).
Figure 1-29
Another criteria to consider is to fit the fan to an object that will allow its lack of balance
to generate a wobbly movement. We attached our fan to a frame using elastic ropes
that would allow for just that.
Connecting the fan to a voltage source: The fan we used is a typical four-wire computer
fan. The easiest way to get these fans running is to:
Connect the yellow and red wires to a DC voltage source. The stronger the
voltage the higher the spin (and the frequency) of the fan would be. We used 5 V
DC source from the NI ELVIS III. You may use 10 V or 15 V depending on your
vibration device.
Connecting the sensor: Connect one electrode of the sensor to channel AI0 in the NI
ELVIS III and the other electrode to channel AI4 (see the figure below). Below we
explain the reason for connecting the wires to these channels.
50
Figure 1-30 Connecting the Sensor to NI ELVIS III
As in lab 3, we do not use any signal conditioning given that we are expecting no
frequency above the 75Hz resonance frequency.
The following VI acquires a signal from the vibration sensor. Along with displaying the
signal, it extracts the frequency components and peaks of the signal and displays them.
1. Connect the sensor to the NI ELVIS III and make sure it is installed properly in
such a way that the vibrating device is causing a bend in the sensor tape as
described in Lab 3.
2. Open the Signal Analysis LabVIEW project that was provided in the courseware
zip file.
This VI acquires a signal from the vibration sensor and displays its chart on Vibration
Waveform Chart and its corresponding Power Spectrum on the chart Power Spectrum.
51
Furthermore, it performs peak analysis to help extract more accurate readings of the
frequency components of the signal. The questions in this section will help you use the
Power Spectrum VI and Peak Analysis VI to perform signal analysis on your own
vibration device. First, we will give an intuitive explanation of the one-sided power
spectrum and how the power spectrum VI works.
Reading the Signal: Using the Express VI Analog Input, this program acquires voltage
measurement samples from the AI0 channel.
Each iteration of the loop, the Express VI is run once. Each time it is run, it acquires
1000 samples at the rate of 1 KHz. Double click its icon. Note that the Channel reads
A/AI0(DIFF N Samples). This is because the voltage acquired from the electrodes is a
differential one. For the same reason, we have connected the electrodes to channel AI0
and AI4 as opposed to using ground.
Power Spectrum VI: The signal read by the Analog Input Express VI is output into the
Power Spectrum VI in the form of an array of a 1000 voltage-values (See the figure
Below).
Figure 1-32
To the Power Spectrum VI, any value between 0 and 1000 (the number of data points
acquired each time the Analog input express VI is called) is a potential frequency
component. Using FFT analysis, the Power Spectrum VI will assign to each of these
potential frequencies a Power value. Frequencies with relatively higher power values
represent the frequency components of the signal. The potential frequency points with
relatively negligible power values represent noise.
52
Another aspect to take into consideration is that the Power Spectrum generates what is
referred to as “positive” and “negative” frequency components. For example, suppose
1000 points are read at 1 KHz sampling rate from a signal that has frequency
components 5Hz and 10 Hz and a DC offset of 1.
When this array of 1000 data points is passed on to the Power Spectrum VI, it will
assign the power value zero to all the numbers between 0 to 1000, except for the
numbers 0, 5, 10, 990 and 995. 0 represents the DC offset and is assigned 1.
Furthermore, it will assign the same (relatively higher) power value to 10 and 990. It will
do the same for 995 and 5. In such a case, the Power Spectrum VI is said to generate
the double-sided power spectrum. 5 Hz and 10 Hz are said to be the positive frequency
components while 990 Hz and 995 Hz are said to be the negative counterpart frequency
components of respectively 10 Hz and 5 Hz.
For most DAQ systems, only the one-sided spectrum is of interest. The one sided
spectrum contains only the positive frequency components. In the context of the
preceding example, the one-sided spectrum would contain potential frequencies 0 to
500 (Half the amount of data points in the array). It will assign power-values of zero to
all the data points, except for 0, 5 Hz and 10 Hz. The power values assigned to 5Hz and
10Hz are double those values assigned by the double-sided power spectrum. The DC
offset (power-value assigned to 0) is the same.
Thus, to compute the one-sided spectrum, we need to discard the second half of the
power spectrum and double all power values except for the one assigned to 0 (see the
figure below).
Later in this section, we will present a more practical and effective way to computing the
one-sided spectrum.
53
The Peak Detector VI performs the peak analysis on the one-sided spectrum (see the
figure below). For more on this VI, refer to 1.7 Simulate: Peak/Valley Analysis in
LabVIEW.
In the first part of this section, we will provide you with the results of our experiment and
their corresponding signal analysis. The remaining part will require you setting your own
vibrating device and recording the signal analysis.
Open the Front Panel of the VI. The Vibration Waveform Chart and the Power
Spectrum respectively display the signal read from the sensor and its corresponding
Power Spectrum.
Running the VI and acquiring a signal from the vibrating device yielded the following:
As pointed out earlier the one-sided Power Spectrum VI takes into consideration all
potential frequency components (0-499). However, displaying all 500 points is
unnecessary as it makes the frequency components hard to see in the presence of all
the noise frequency points.
54
1-21 Taking into consideration the fact that the device is set up in such a way as not to
emit a signal with frequency components that are higher than the sensor’s resonance
frequency (75 Hz), how would you update the properties of the chart Power Spectrum to
make it more readable?
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
To get a more accurate reading of frequency components, we set the Peak Threshold to
0.10 and Peak Width to 3. We obtained the following reading:
_____________________________________________________________________
_____________________________________________________________________
55
5. Make sure the vibration device you set up is switched on.
6. Ensure that the sensor is installed properly in the way described earlier.
The Vibration Waveform chart displays the signal read from the Analog Input Express
VI. Power Spectrum displays the one-sided power spectrum.
1-25 By looking at the Power Spectrum chart and making any necessary updates to the
x-axis scale, what are the approximate frequency components of the signal?
_____________________________________________________________________
_____________________________________________________________________
1-26 To what values do you need to set the Peak Width and Peak Threshold to get a
more accurate reading of the frequency components?
_____________________________________________________________________
_____________________________________________________________________
56
Conclusion
These questions will help you review and interpret the concepts learned in this lab.
1-27 Summarize any observations from the lab that have not been addressed
elsewhere.
_____________________________________________________________________
_____________________________________________________________________
1-28 In your own words, discuss some common signal processing techniques and
include frequency, level and statistical analyses among your examples.
_____________________________________________________________________
_____________________________________________________________________
1-29 Discuss and compare the applications and use cases of inline real-time processing
and offline processing.
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
57
Answer Key – Check Your Understanding Questions Only
1-1 B
1-2 A
58