MODULE 5
1. Fourier Transform:
LabVIEW and its analysis VI library provide a complete set of tools to perform Fourier and
spectral analysis. The Fast Fourier Transform (FFT) and Power Spectrum VIs are optimized,
and their outputs adhere to the standard DSP format.
FFT is a powerful signal analysis tool, applicable to a wide variety of fields including spectral
analysis, digital filtering, applied mechanics, acoustics, medical imaging, modal analysis,
numerical analysis, seismography, instrumentation, and communications. The LabVIEW
analysis VIs, located on the Signal Processing palette, maximize analysis throughput in FFT-
related applications.
The fast Fourier transform maps time-domain functions into frequency-domain
representations. FFT is derived from the Fourier transform equation, which is:
where x(t) is the time domain signal, X(f) is the FFT, and ft is the frequency to analyze.
2. Power Spectrum:
The FFT Power spectrum VI completes the following steps to compute power spectrum:
a) Computes the FFT of time signal
b) Forms the power spectrum of time signal
c) Averages the current power spectrum with the power spectra computed in previous calls
to the VI since the last time the averaging process was restarted.
d) Returns the averaged power spectrum in power spectrum.
• The single channel version of this VI can perform single channel measurements in both
one shot mode and maintains internal state information for a single channel only. The
power spectrum, also called the energy spectral density, that is, the power spectrum
captures the power of a signal per unit frequency.
3. Windowing and Filtering Tools:
• The LabVIEW Digital Filter Design Toolkit contains several filter design tools that are
similar to the filtering tools included with the LabVIEW Full or Professional
Development System.
• For example, the Butterworth Coefficients VI in LabVIEW Full or Professional
Development System is similar to the Butterworth Design functionality from the
Digital Filter Design Toolkit. Also, the Parks-McClellan VI in LabVIEW Full or
Professional Development System is similar to the Remez Design VI from the Digital
Filter Design Toolkit. Although the two sets of VIs have similar functionality, their
results might not be the same because the design algorithms are different.
• The filtering VIs included in the LabVIEW Full or Professional Development System
are coefficients-oriented. The VIs included in the Digital Filter Design Toolkit are
object-oriented.
• The outputs of the classical design methods from LabVIEW Full or Professional
Development System filtering VIs might be different from the outputs computed from
the Digital Filter Design Toolkit because the two sets of VIs use different design
algorithms.
• The following block diagram demonstrates how to apply the coefficients computed for
a finite impulse response (FIR) filter in LabVIEW Full or Professional Development
System to create a digital FIR filter in the Digital Filter Design Toolkit using the DFD
Build Filter from TFVI.
The following block diagram demonstrates how to apply the coefficients computed for an
infinite impulse response (IIR) filter in LabVIEW Full or Professional Development System to
create a digital IIR filter in the Digital Filter Design Toolkit using the DFD Build Filter from
Cascaded Coef VI.
The following block diagram demonstrates how to retrieve filter coefficients from a filter you
designed with the Digital Filter Design Toolkit using the DFD Get TF VI and then use the
coefficients to filter a signal with the IIR Filter VI in LabVIEW Full or Professional
Development System.
4. Simulation of a simple second order system
• Control System Analysis With Graphical LabVIEW
• Create a new VI.
• Save the VI as My Controls Example VI.
• Right-click on the block diagram and navigate to Control Design & Simulation»Control
Design»Model Construction and drag the CD Construct Special TF Model VI onto the
block diagram.
• On the front panel, right-click to display the Controls palette. Navigate
to Modern»Numeric»Horizontal Pointer Slide and drag a Horizontal Pointer
Slide onto the front panel. While the name of the slide is highlighted, change it
to Damping Ratio. Follow the same procedure to create another slide and make its
name Natural Frequency.
• On the front panel, click on the maximum number for the Damping Ratio slide and
change it to 1. Change the maximum number for the Natural Frequency slide to 5.
• On the block diagram, wire the Damping Ratio and the Natural Frequency slides to
the Damping Ratio and Natural Frequencyinputs respectively of the CD Construct
Special TF VI.
• Navigate to Control Design & Simulation»Control Design»Time Response and drag
the CD Step Response VI onto the block diagram. The polymorphic instance of
the CD Step Response VI will show SS for state space but this will change after the
next step.
• Wire the Transfer Function Model output of the CD Construct Special TF VI to
the State-Space Model input of the CD Step Response VI. The polymorphic instance
of the CD Step Response VI will automatically change to TF.
• Right-click on the Step Response Graph output of the CD Step Response VI and
select Create»Indicator.
• Go to Programming»Structures»While Loop and place a While Loop on the
diagram around the existing code.
• Hover over the Loop Condition terminal at the bottom right of the loop, right-click,
and select Create Control to put a Stop button on the front panel for the VI.
• The block diagram of your VI should look like this:
Run the VI after putting in nonzero values for Damping Ratio and Natural
Frequency on the front panel. Adjust the parameters on the front panel and observe
the system response. Your front panel should be similar to this:
5. Control System Analysis With LabVIEW MathScript RT Module
• Save My Controls Example VI as My Controls Example With MathScript VI.
• Delete CD Construct Special TF VI, CD Step Response VI, and Step Response
Graph from the block diagram.
• Go to Programming»Structures and place a MathScript Node on the diagram
inside of the While Loop.
• Right-click on the left-hand side of the MathScript Node and select Add
Input. Name the input zeta.
• Right-click again on the left-hand side of the MathScript Node and select Add
Input. Name the input wn.
• Wire the Damping Ratio slide to the zeta input of the MathScript Node.
• Wire the Natural Frequency slide to the wn input of the MathScript Node.
• Inside the MathScript Node, type in the following:
• num = wn*wn;
• den = [ 1 2*zeta*wn wn*wn];
• sys = tf(num,den);
• t = 0:0.01:5;
• stepresp = step(sys, t);
• Right-click the right-hand side of the MathScript Node and select Add
Output»stepresp.
• Right-click the stepresp output of the MathScript Node and select Choose Data
Type»All Types» 1D-Array»DBL 1D.
• On the front panel of the VI, right-click to display the Controls palette. Navigate
to Modern»Graph and drag a Waveform Graphonto the front panel. While the name
of the graph is highlighted, change it to Step Response.
• Wire the stepresp output of the MathScript Node to the Step Response graph.
• The block diagram of your VI should look like this:
• Run the VI after putting in nonzero values for Damping Ratio and Natural
Frequency on the front panel. Adjust the parameters on the front panel and observe
the system response. Your front panel should look like this (depending upon the values
you have chosen):
6. Build a VI for simple temperature Indicator
Acquiring the temperature from temperature sensor through a DAQ assistant block.
Figure 1: Building a Simple VI to do a temperature indication by taking temperature values
from the temperature sensor using DAQ assistant block
Figure 2: Building a VI to do a Simple Temperature Indication taking the data from a
random number.
• Create a VI fie
• To do the simulation shown in Figure 1, take the temperature values from the
temperature sensor via National Instruments myDAQ block.
• Those temperature values are acquired onto labview using DAQ assistant data. The
temperature values are scaled by 100.
• These temperature values are in Celsius. Using a switch directly it is displayed on
thermometer indicator. If the temperature has to be converted to Fahrenheit. The
Celsius to Fahrenheit subVI block is used.
• In the Figure 2 the random number values generated are taken as temperature values
virtually.
• The temperature values are scaled by 100 so that its magnitude is correctly rceognized.
• The delay of 250mSec is taken.
• Total 100 temperature values are taken and it is displayed on the thermometer indicator.
7. Explain and Design PID Controller.
Proportional-Integral-Derivative (PID) control is the most common control algorithm used in
industry and has been universally accepted in industrial control.
As the name suggests, PID algorithm consists of three basic coefficients; proportional, integral
and derivative which are varied to get optimal response.
The basic idea behind a PID controller is to read a sensor. Then compute the desired actuator
output by calculating proportional, integral, and derivative responses and summing those
three components to compute the output.
Consider the following unity feedback system:
Figure: Unity Feedback System
Plant: A system to be controlled
Controller: Provides the excitation for the plant; Designed to control the overall system
behaviour.
The transfer function of the PID controller looks like the following:
▪ Kp = Proportional gain
▪ Ki = Integral gain
▪ Kd = Derivative gain
First, let's take a look at how the PID controller works in a closed-loop system using the
schematic shown above. The variable (e) represents the tracking error, the difference between
the desired input value (R) and the actual output (Y). This error signal (e) will be sent to the
PID controller, and the controller computes both the derivative and the integral of this error
signal. The signal (u) just past the controller is now equal to the proportional gain (Kp) times
the magnitude of the error plus the integral gain (Ki) times the integral of the error plus the
derivative gain (Kd) times the derivative of the error.
This signal (u) will be sent to the plant, and the new output (Y) will be obtained. This new
output (Y) will be sent back to the sensor again to find the new error signal (e). The controller
takes this new error signal and computes its derivative and its integral again. This process goes
on and on.
The Characteristics of P, I, and D Controllers:
A proportional controller (Kp) will have the effect of reducing the rise time and will reduce but
never eliminate the steady-state error. An integral control (Ki) will have the effect of
eliminating the steady-state error, but it may make the transient response worse. A derivative
control (Kd) will have the effect of increasing the stability of the system, reducing the
overshoot, and improving the transient response. Effects of each of controllers Kp, Kd, and Ki
on a closed-loop system are summarized in the table shown below.
CL RESPONSE RISE TIME OVERSHOOT SETTLING TIME S-S ERROR
Kp Decrease Increase Small Change Decrease
Ki Decrease Increase Increase Eliminate
Kd Small Change Decrease Decrease Small Change
Figure : Effect of PID Controllers on Closed-Loop System
Note that these correlations may not be exactly accurate, because Kp, Ki, and Kd are dependent
on each other. In fact, changing one of these variables can change the effect of the other two.
For this reason, the table should only be used as a reference when you are determining the
values for Ki, Kp and Kd.
• Now, let's take a look at a PID controller. The closed-loop transfer function of the
given system with a PID controller is:
• After several trial and error runs, the gains Kp=350, Ki=300, and Kd= 50
provided the desired response.
• Alternatively, this result can be achieved with a MathScript Node, by using the VI
from Figure 3 with the following code:
• num=1;
• den=[1 10 20];
• plant=tf(num,den);
• Kp=350;
• Ki=300;
• Kd=50;
• contr=tf([Kd Kp Ki],[1 0]);
sys_cl=feedback(contr*plant,1);
Figure 3: Closed Loop System Using Mathscript Node
General Tips for Designing a PID Controller
When you are designing a PID controller for a given system, follow the steps shown below to
obtain a desired response.
1. Obtain an open-loop response and determine what needs to be improved
2. Add a proportional control to improve the rise time
3. Add a derivative control to improve the overshoot
4. Add an integral control to eliminate the steady-state error
5. Adjust each of Kp, Ki, and Kd until you obtain a desired overall response.
8. Generation of HTML page.
The labview supports the generation of HTML file of the VI created.
Considering an example in the figure below:
block
Figure 4:Generation of the Suitable HTML File in Labview
The data from the hardware device is acquired using the DAQ Assistant block in labview. If
we want to measure the power spectrum the spectral measurement block is used, in that option
of power spectrum is selected. The power spectrum graph is displayed using waveform graph
block.
The report block in labview, This block is available in palate function -----express----in that --
-output----then Report block.
Connect this block to the specific block block output in the VI. In the figure 4 the report of the
power spectrum measurement and the DAQ Assistant data is obtained. Configure the report
block as shown in the Figure 5. The HTML report is generated and is saved in the
corresponding folder in the computer. Reports can be configured to automatically generate,
save as a Web page, and be sent directly to a printer.
Figure 5: Report Block in VI to Create the HTML file.
One more open HTML Report in Browser block is given in Figure 6:
Figure 6: Open HTML Report in Browser (String)
9. CRO Simulation Or Signal Generation in Labview
LabVIEW 8 offers a multitude of signal generation options to meet your signal processing
needs.
1. Express VIs
Express VIs encompass the most common functions out of the more than 400 analysis and
signal processing functions that LabVIEW offers. The Simulate Signal Express VI can generate
signals of the following types:
• Sine, Square, Triangle, Sawtooth DC, and Noise*
*In addition to the signal, we have the option to add noise
Examples of the noise types that you can add include the following:
• Uniform white noise, Gaussian white noise, Periodic random noise, Gamma noise,
Poisson noise, Binomial noise, Bernoulli noise , MLS sequence, Inverse f noise
2. Simulate Signal Express VI
When you place a Simulate Signal Express VI on the block diagram, you will be prompted to
configure the signal as shown in the figure below.
You can specify the frequency, phase, amplitude, offset, samples per second, number of
samples, and number of cycles. The Simulate Signal Express VI can also be configured to
simulate a Data Acquisition (DAQ) device by enabling “Simulate acquisition timing.”
Figure 7: Simulate Signal Express VI icon and configuration prompt.
3. Wave, Pattern, and Noise VIs
In LabVIEW 8, the signal processing palette contains twenty-one Wave and Pattern VIs
including Basic Function Generator (sine, triangle, sawtooth, square, and arbitrary wave), Sine,
Impulse, Ramp, Sinc, Pulse and Chirp Patterns, Gaussian, Uniform White Noise, and Period
Random Noise.
Wave VIs
• Arbitrary Wave
• Sawtooth Wave
• Signal Generator by Duration
• Sine Wave
• Square Wave
• Triangle Wave
Pattern VIs
• Chirp Pattern
• Impulse Pattern
• Pulse Pattern
• Ramp Pattern
• Sinc Pattern
• Sine Pattern
Noise VIs
• Bernoulli Noise
• Binary MLS
• Binomial Noise
• Gamma Noise
• Gaussian White Noise
• Periodic Random Noise
• Poisson Noise
• Tones and Noise
• Uniform White Noise
The Pattern and Wave generation VIs may initially appear be identical, but upon closer
examination there is a subtle difference between the two.
Wave VIs can keep track of the phase information of the signal between each call of the VI,
while signal generation VIs cannot.
The Wave VIs have a "phase in" input that specifies the initial phase in degrees of the
generated waveform. Wave VIs also have a "phase out" output that indicates the phase of the
next sample of the generated waveform.
• Arbitrary Wave
• Sawtooth Wave
• Signal Generator by Duration
• Sine Wave
• Square Wave
• Triangle Wave
• Chirp Pattern
4. Waveform Datatype Signal Generation
In addition to array-based signal generation functions such as the pattern and wave generation
VIs, VIs that utilize the waveform datatype are also available.
The waveform datatype, unique to LabVIEW, combines important sampling and timing
information along with the signal data into a single datatype.
This increases ease of access to important information and simplifies the integration with
analysis functions and data acquisition products.
The signal generation functions utilizing the waveform datatype include:
• Basic Function Generator (sine, triangle, sawtooth, and square)
• Tones and Noise Waveform
• Formula Waveform
• Sine Waveform
• Square Waveform
• Triangle Waveform
• Sawtooth Waveform
• Basic Multitone
• Basic Multitone with Amplitudes
• Multitone Generator
• Uniform White Noise Waveform
• Gaussian White Noise Waveform
• Periodic Random Noise Waveform
• Inverse f Noise Waveform
• Gamma Noise Waveform
• Poisson Noise Waveform
• Binomial Noise Waveform
• Bernouilli Noise Waveform
• MLS Sequence Waveform
• Simulate Signal Express VI
• Simulate Arbitrary Signal Express VI
4. Point-by-Point Signal Generation
In addition to array-based and waveform-based signal generation, LabVIEW also provides
point-by-point signal generation. Point-by-point analysis functions are optimized for
continuous, real-time analysis without the hassles of start-up data loss, reinitialization, or
potential interruption problems. The LabVIEW point-by-point signal generation functions fit
seamlessly into this model, providing basic function generator options (sine, triangle, sawtooth,
and square waves) as well as Gaussian white noise, uniform white noise and periodic random
noise.
Figure 8:Point-by-point sine wave generation VI.