CSE-471 Lab 06

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Kingdom of Saudi Arabia

‫اﻟﻤــﻤـــــــــﻠﻜــــﺔ اﻟﻌـﺮﺑﯿﺔ اﻟﺴــــــﻌﻮدﯾﺔ‬


Royal Commission at Yanbu
Colleges & Institutes Division ‫اﻟـــــــﮭـــــــــــﯿـــــﺌﺔ اﻟﻤﻠــــــﻜـــــــﯿﺔ ﺑــﯿﻨﺒﻊ‬
‫ﻗــــﻄـــﺎع اﻟـﻜــــــــــــﻠــﯿﺎت واﻟـﻤــﻌــﺎھـﺪ‬
Yanbu University College ‫ﻛـــــﻠﯿﺔ ﯾﻨﺒﻊ اﻟﺠــــــــــــــــﺎﻣـــــــــــﻌﯿﺔ‬
Computer Science & Engineering Dept. ‫ﻗﺴﻢ ﻋﻠﻮم وھﻨﺪﺳﺔ اﻟﺤﺎﺳﺐ اﻷﻟﻲ‬
Information & Computer Technology Dept. ‫ﻗﺴﻢ ﺗﻘﻨﯿﺔ اﻟﻤﻌﻠﻮﻣﺎت واﻟﺤﺎﺳﺐ اﻵﻟﻲ‬
LAB 6

ACADEMIC YEAR 1439/1440 H (2018/2019 G), SEMESTER II (182)

MICROCOMPUTER INTERFACING &


DATA ACQUISITION
CSE471
START TIME: 8:15 AM
DATE: Tuesday, 05 March, 2019
FINISH TIME: 10:05 AM

STUDENT NAME: _________________________________________________________

STUDENT ID: SECTION: 1

FOR INSTRUCTOR USE ONLY GENERAL INSTRUCTIONS

MAX MARKS
Q. No. CLOs
MARK OBTAINED

1
2
3
4
5
6
7

TOTAL MARKS

MARKED BY: Signature:

CHECKED BY: Signature:


LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

DATA ANALYSIS USING LABVIEW

PERFORMANCE OBJECTIVES:
Upon completion of this laboratory exercise, the student technicians/engineers will be able to:
1. Write VIs to perform the statistical calculations.
2. Perform data analysis using LABVIEW.
EQUIPMENT:

1 LABVIEW equipped PC

DISCUSSION:
MEAN defines the arithmetic average value.
MEDIAN is the central value when values are arranged in a sorted list.
STANDARD DEVIATION describes the extent of variability in the values.
VARIANCE is the square of the standard deviation.
INTERPOLATION is a method of constructing new data points within the range of a discrete
set of known data points. Various methods that are available in LABVIEW are as follows:
• Nearest (no interpolation, just the closest value in the data set)
• Linear (default)
• Cubic spline
• Cubic hermite
• Lagrange
CURVE FITTING
The general term curve fitting means getting some sort of a curve through a set of data points.
There are two general approaches to curve fitting, with different goals:
Method 1: Get a curve on a graph that goes through each data point; no model (mathematical
equation) is needed.

Method 2: Find the coefficients of a mathematical model (regression equation) that best fits the
model to the data. It is not required that the plotted regression equation go through each data
point.
Method 1 is intrinsically related to interpolation, because the same methods are used for
interpolation and for Method 1 curve fitting. To use LABVIEW Interpolation 1D function for
curve fitting, there are two options:

1. Supply an array of xi values that spans the range of the X values in the data set.
2. Do not supply the xi array at all, but set the ntimes value to tell LABVIEW how many
times to interpolate between the values.

The meaning of ntimes may not be immediately obvious; it indicates how many times
LABVIEW will go through the data set interpolating between each current value of X. This is
illustrated in figure 6.1.The original data points are represented by stars, and with each pass
new stars are added between the original points.

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


1
LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

Figure 6.1 Visualization of Interpolation in LABVIEW.


• ntimes_1: LABVIEW makes one interpolation pass through the data and adds one
interpolated point between each original data point.
• ntimes_2: LABVIEW makes two interpolation passes through the data. In the first pass one
interpolated point is added between each original data point (same as when ntimes = 1). In
the second pass, another interpolated point is added between each point after the first pass
(original and interpolated). The result is three interpolated points between each original data
point.
• ntimes_3: LABVIEW makes three interpolation passes through the data and ultimately
leaves seven interpolated points between each original data point.
REGRESSION
Regression involves finding the coefficients that cause a mathematical model (regression
model) to best fit the values in a data set. “Best” means the coefficients that minimize the sum
of the squared error (SSE) between the y values predicted by the regression model and the y
values in the data set.LABVIEW allows selecting between three different definitions of “best”
for many of the regression functions:
• Least Square
• Least Absolute Residual
• Bisquare
The most common type of regression is linear regression. With linear regression the
coefficients can be determined directly (perhaps with some significant matrix math). Nonlinear
regression is also possible, but requires an iterative solution of trying various coefficient values
until the sum of the squared error is minimized. LABVIEW provides functions for both linear
and non-linear regression. All of the regression functions are found in the Fitting Group (not
available in BaseLABVIEW Package) which is as follows:

LINEAR REGRESSION FUNCTIONS


• Linear Fit
• Exponential Fit
• Power Fit
• Gaussian Peak Fit
• Logarithm Fit
• General Polynomial Fit
• General LS (Least Squares) Linear Fit—fits any linear model
NON-LINEAR REGRESSION FUNCTIONS
• Non-Linear Curve Fit
• Constrained Non-Linear Curve Fit

YANBU UNIVERSITY COLLEGE


2
LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

TASK-1
STATISTICAL CALCULATION
In this task the following statistical operations will be performed on the given data to determine
• Minimum and maximum value from the ensemble
• The median
• Mean and standard deviation
PROCEDURE:
1. On the front panel, create an array and name it as sensor data.
2. On the block diagram insert the following VI functions.
a. Funtions>> Mathematics >> Probability an Statistics >>Std Deviation and Variance
b. Funtions>> Mathematics >> Probability an Statistics >> Median
c. Funtions>> Programming >> Array >> Array max and min
3. Connect each block with the sensor data array.
4. Place numerical indicators and connect them to respective output of the each block as shown
in following block diagram as shown in figure 6.2.
5. Execute the VI to insert sensor data manually on the front panel with senor data and observe
its statistical result is shown in figure 6.3.

Figure 6.2 Front Panel (top) and Block Diagram (bottom) for Task 1

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


3
LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

TASK-2
INTERPOLATION
In this task the sine value of an angle will be calculated using interpolation operation on the
given data set..
PROCEDURE:
1. On the front panel create the following 1D arrays:
a. Sine
b. Angle
c. Unknown
d. Result (Indicator)
2. Select ring constant in the numeric sub palette and edit its element according to the following
table:
Serial Nr. Type Value
1 Nearest 0
2 Linear (default) 1
3 Cubic Spline 2
4 Cubic Hermite 3
5 Lagrange 4

3. On the block diagram insert the following VI.


Funtions>> Mathematics >> Interpolation and Extrapolation >> Interpolate 1D
4. Connect the components as shown in block diagram figure 6.3 (left) and then run the VI to
see the result on front panel figure 6.3(right).

Figure 6.3 Front Panel (left) and Block


Diagram (right) of Task 2

YANBU UNIVERSITY COLLEGE


4
LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

TASK-3
REGRESSION FOR A LINEAR FIT
The coefficient of determination (R2): If the best fit regression curve goes through every data
point perfectly, R2 = 1. The more distance, there is between the data points and the regression
curve, the smaller the value of R2.
For the following set of data points estimate the slope, intercept, R2.
X Y
1 2.0
2 7.5
3 8.2
4 12.8
5 15.9
6 19.1
7 22.3
8 22.5

PROCEDURE:
1. Construct the block diagram as shown in the figure 6.4. Use search command to find the
functions, the name of which is written in rectangle. The value indicating the intercept and
slope is directly calculate from the curve fitting, whereas for R2 goodness of fit function is
used which requires best fit and value of Y.
2. On the front panel enter the given data to see the actual data and fitted points. (see figure 6.5)

Figure 6.4 Block Diagram of Task 3

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


5
LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

Figure 6.5 Front Panel of Task 3


REVIEW QUESTIONS
A company has advertised an updated instrument that now comes with a digital readout
and an enhanced price. The old analog display could be read to two decimal places, but
the digital display shows four. To see if the new instrument is truly more precise, an old
sample was re-run on the new instrument. The old and new data sets are shown below.
1. Calculate mean and standard deviation to find out.

a) If the two instruments give essentially the same mean value.


b) If the new instrument produces results with a smaller standard deviation than the old
instrument.
Old New
11.55 11.5308
11.43 11.5310
11.54 11.5268
11.49 11.5348
11.56 11.5203
11.51 11.5276
11.67 11.5361
11.52 11.5447
11.66 11.5360
11.44 11.5234

YANBU UNIVERSITY COLLEGE


6
LAB MANUAL
LAB EXPERIMENT - 06: DATA ANALYSIS IN LABVIEW

Analytical instruments typically need to be calibrated for one or both of the following
reasons:
• To ensure that the instrument is still reporting correct values.
• To correlate the measurement units to the units output by the instrument.
2. As an example of the latter, consider a meter that measures pH but outputs a voltage
signal suitable for automated data acquisition. A calibration curve is used to correlate
pH and voltage. To calibrate the pH meter, solutions of known pH are prepared and
used with the meter. The output voltages (in triplicate) corresponding to the known pH
values are recorded. The calibration data are listed below.
pH Voltage
1.5 1.21 1.14 1.16
2.3 1.76 1.70 1.76
3.3 2.32 2.39 2.40
4.1 2.89 2.91 2.90
5.6 3.91 3.87 3.89
6.9 4.68 4.72 4.68
7.4 4.98 5.05 5.05
8.2 5.57 5.47 5.57
10.4 7.01 6.98 6.95
11.8 7.96 7.88 7.91

Read the data into LABVIEW, plot it to see if a linear fit is reasonable, and then
regress the data to determine the calibration equation. The calibration equation should
allow you to calculate a pH given a voltage value.

FINAL CHECKLIST
All the students must make sure, before they leave the Lab:
1. Clean your equipment, materials, and work benches before you leave.
2. Return all equipment and materials to their proper storage area.
3. Submit your lab report and answers to the questions, together with your data,
calculations (if any) and results before the next laboratory sessions.

CSE 471 – MICROCOMPUTER INTERFACING & DATA ACQUISITION


7

You might also like