1 Part 1: Track B: Linear Fitting Scheme to Find Best-Fit Values
Introduction
In a linear regression problem, a mathematical model is used to examine the relationship between two variables i.e. the independent variables and dependent variable (the independent variable is used to predict the dependent variable).
This is achieved by using the least square method using excel plotting data values and drawing a straight line to derive the best fit values. A nonlinear graph was obtained on plotting the data points provided but the least square method applied obtained a linear graph with a straight line which estimated and minimized the squared difference between the total sum of the data values and model values.
Aim
The aim of this coursework Part1, Track B is to carryout data analysis assessment with respect to linear model fitting by manual calculation working obtaining the best-fit values with the decay transient data provided in table 1 below which is implemented using excel.
Time (sec) Response (v)
0.01 0.812392
0.02 0.618284
0.03 0.425669
0.04 0.328861
0.05 0.260562
0.06 0.18126
0.07 0.1510454
0.08 0.11254
0.09 0.060903
0.1 0.070437
Table 1.1: data for decay transient
Methodology
The data in the table 1.1 above represents decay transient which can be modelled as an exponential function of time as shown below:
V(t)=V_0 exp'(-t/??) ”””””””””””””’ (1.1)
The equation above is nonlinear; to make it linear the natural logarithm method is applied
Logex = Inx ”””””””””””””””. (1.2)
From the mathematical equation of a straight line
Y = mx + c”””””””””””””””. (1.3)
Y = a0 + a1x + e””””””””””””””. (1.4)
Y = Inx”””””””””””””””’… (1.5)
In this case
Y = InV”””””””””””””””’… (1.6)
So,
InV = InV0 + Ine(-t/??) ””””””””””””’. (1.6)
But Inex = x; eInx = x
InV = InV0 ‘ t/”””””””””””””’??. (1.7)
Applying natural logarithm method to the equation obtained two coefficients InV0 and t/?? which represent a0 and a1 respectively from equation (1.4)
The normal equation for a straight line can be written in matrix form as:
[‘(n&’xi@’xi&”xi’^2 )] {‘(a0@ai)} = {‘(‘yi@’xiyi)} ”””””””””.””. (1.8)
This is separated to give
[‘(‘(1&1)&’&1@'(xi&x2)&’&xn)] [‘(‘(1@1)&'(x1@x2)@’&’@1&xn)]{‘(a0@a1)} = [‘(‘(1&1)&’&1@'(x1&x2)&’&xn)] [‘(‘(y1@y2)@’@yn)] ””’.””. (1.9)
From (1.9) the general linear least squares fit equation is given as
[[Z^T ] [Z]]{A}= {[Z^T ] {Y}}
The main purpose is to calculate for {A} (InV0 and t/??) which are the coefficients of the linear equation in (1.7). Matrix method using excel is used to achieve this by finding values for [Z],[Z^T ],[Z^T ][Z],[Z^T ][Y],’and[[Z^T ] [Z]]’^(-1).
The table below shows the calculated values for InV when natural logarithm was applied to the response V using excel.
Table 1.2: Excel table showing calculated values for InV
[Z]= [‘(1&0.01@1&0.02@1&0.03@1&0.04@1&0.05@1&0.06@1&0.07@1&0.08@1&0.09@1&0.1) ]
The transpose of [Z] is given as
[Z]= [‘(1&1&1&1&1&1&1&1&1&1@0.01&0.02&0.03&0.04&0.05&0.06&0.07&0.08&0.09&0.1)]
The product of [Z^T ][Z] is given as
[Z^T ][Z] = [‘(10.0000&0.5500@0.5500&0.0385)]
The inverse [[Z^T ] [Z]]^(-1) of the matrix [Z^T ][Z] is given as
[[Z^T ] [Z]]^(-1) = [‘(0.4667&-6.6667@-6.6667&121.2121)]
The product of the transpose of [Z], [Z^T ] and [Y] (InV) is given as
[Z^T ][Y] = [‘(-152376@-1.07060)]
To obtain {A} the product of [[Z^T ] [Z]]^(-1) and [Z^T ][Y] was calculated to give
{A} = [‘(a0@a1)]; {A}= [‘(InV0@-1/??)]
Where;
InV0 = a0; and – 1/?? = a1
{A} = [‘(0.0626@-28.8434)]
So,
InV0 = 0.0626; and 1/?? = -28.8434
V0 = exp(0.0626) = 1.0646; and ?? = 1/-28.8434 = 0.03467
Then,
V(t)=1.0646exp'(-t/0.03467)
Since Y = InV(t)
Y = 1.0646exp'(-t/0.03467)
Table 1.3: Excel table showing calculated values for InV [Y] and InV(t) [Y]
Table 1.4: Diagram of Excel calculation for curve fitting
Figure 1.1: Diagram of transient decay for response V and response V(t)
Figure 1.2: Diagram of transient decay for response V and response V(t)
Conclusion
The solutions to this linear regression exercise was achieved by manually calculating the generalized normal equation for the least square fit using the matrix method and Microsoft excel program obtaining the unknown values of the coefficients V0 and ??. The method provides accurate results and the best fit values obtained show the relationship between the straight line response and the transient line response shown in figure above and is seen to have given
2 Part 2: Track B: Type K thermocouple
INTRODUCTION:
The thermocouple is a sensor that is used to measure temperature and is commonly used in many industries. For this lab work, a Type K thermocouple is used to acquire a first order transient data (non-linear) response to a temperature change, a signal conditioning element called the AD595 thermocouple amplifier is used to improve thermocouple signal since it produced a low voltage output proportional to the input temperature, a data acquisition device the NI-USB 6008 is used to acquire signals from the signal conditioning circuit, a resistor-capacitor (RC) low-pass filter is built for reduce the frequency and noise of the signal generated and further investigations and analysis are carried out. In this part, the non-linear regression was used to obtain the transient response of thermocouple signal using Labview program
Aim
The aim of the assignment is to produce a Labview program which can obtain transient real data values from a Type K thermocouple which is a sensor that produces voltage by the differential temperature its conductors sense (i.e. a first order response) followed by a non- linear model fitting procedure which allows the user capture the thermocouple initial first order response to a rising input temperature and an appropriate response function model to the transient response. The program displays the transient data, fitted model response and calculated model parameters.
Reason of the choice of model response
The model output transient response obtained from the input (temperature) of the Type K thermocouple was a first order can be defined as having only s to the power of one in the first order transfer function which is characterised with no overshoot because the order of any system is determined by the power of s in the transfer function denominator and has a transfer function as 1/(??s+1) for a unit step signal of 1/s in the Laplace transform domain or s domain and is given as
Y(s) = 1/(s(??s+1)) ””””””””””””””’… (2.1)
Partial fraction method is used to find the output signal Y(t) to give
Y(s) = A/s+B/(??s+1) ””””””””””””””’ (2.2)
A = [s * Y(s)] for s = 0 = 1
B = [(??s+1) * Y(s)] for s = (-1)/?? = -1
Y(s) = 1/s-1/(??s+1) ””””””””””””””’ (2.3)
Therefore the output signal in the time domain is given as:
Y(t) = L-1 [1/s-1/(??s+1)] ”””””””””””””’ (2.4)
Y(t) = U(t) – e^((-t)/??) ”””””””””””””’ (2.5)
Y(t) = 1- e^((-t)/??) where t’0 ””””””””””” (2.6)
Substituting the output response V(t) for Y(t) , the equation (2.6) can also be re-written as:
V(t) = 1- e^((-t)/??) ”””””””””””””’ (2.7)
Assuming for a given input temperature T0 an output response V0 was derived and for a given increase in temperature T1 an output response voltage V1 was derived, so therefore the output voltage for the change in voltage relative to the change in temperature is given as:
V(t) =(V1 ‘ V0)( 1- e^((-t)/??) ) ”””””””””””. (2.7)
V(t) =V0 + (V1 ‘ V0)( 1- e^((-t)/??) ) (thermocouple voltage response) ”””’. (2.8)
V(t) = (V1 ‘ V0)( 1- e^((-t)/??) ) + V0 ””””””””””. (2.9)
Where (V1 ‘ V0) = ??V
V(t) = ??V ( 1- e^((-t)/??) ) + V0 ”””””””””””. (3.0)
T(t) = ??T ( 1- e^((-t)/??) ) + T0”””””””””””. (3.1)
T(t) = a ( 1- e^((-t)/b) ) + c
Equation (3.1) is similar to the general nonlinear model given as:
F(x) = a ( 1- e^((-t)/b) ) + c ”…””””””””””’. (3.2)
Where,
F(x) = V(t) ; a = ??V; b = 1/??; and c = V0
The thermocouples voltage output is nonlinear given a first order response curve (Digilent Inc., 2010)
V(t)
0 (-t)/??
Table 2:1: showing thermocouple output voltage first order response curve
Explanation on the principles of non-linear regression analysis
The principle of non-linear regression is a method that can be used to show how the response and the unknown values (predictors) relate to each other by following a functional form i.e. relating Y as being a function of x or more variables. This is to say that the non-linear equation we are trying to predict rely non-linearly mainly upon one or more variables or parameters. The Gauss Newton Method is a method used to solve non-linear regression by applying Taylor series expansion to express a non-linear expression in a linear for form.
A non-linear regression compared to a linear regression cannot be manipulated or solved directly to get the equation; it can be exhausting calculating for this as an iterative approach is used. A non-linear regression model is given as:
Yi = f(xi, a0, a1) + ei
Where,
Yi = responses
F = function of (xi, a0, a1)
ei = errors
For this assignment the non-linear regression model is given as
f(x) = a0(1 ‘ e-a1x) + e
Where,
F(x) = V(t) ; a0 = ??V; b = (-t)/??; and e = V0
T(t) = (T1 ‘ T0)( 1- e^((-t)/??) ) + T0 ””””””””””. (3.3)
V(t) = (V1 ‘ V0)( 1- e^((-t)/??) ) + V0 ””””””””””. (3.4)
Where (V1 ‘ V0) = ??V
V(t) = ??V ( 1- e^((-t)/??) ) + V0 ”””””””””””. (3.5)
Description of measurement task
The intent of the measurement experiment was to seek, identify, analyse the components of that make measurement task and to examine the transient response from the Type k thermocouple. It analyses the method, instruments and series of actions in obtaining results from measurements. Equipment such as the Type K thermocouple, NI-PXI-6070E 12 bit I/O card, AD595 thermocouple amplifier, and a Labview software program which was used for calculation of model parameters were used to carry out this task.
The measurement task is to introduce the Type K thermocouple sensing junction in hot water to analyse the temperature change and the corresponding voltage response is generated and observed on a Labview program. This activity is executed frequently to acquire the best fitted model response and parameters.
Choice of signal conditioning elements
The choice of a signal conditioning element used in measurement is important because the signal conditioning element used can either enhance the quality and efficiency of a measurement system or reduce its performance.
The AD595 thermocouple amplifier is the choice signal conditioning element used with the Type K thermocouple for this experiment because it is has a built in ice-point compensation (cold junction compensator) and amplifier which is used as a reference junction to compare and amplify the output voltage of the Type K thermocouple which generates a small output voltage corresponding to the input temperature. AD595AQ chip used is pre-calibrated by laser trimming to correspond to the Type K thermocouple characteristic feature with an accuracy of ??3oC, operating between (-55 oC – 125 oC) and are available with 14 pins/low cost cerdip. The AD595 device resolves this issue by providing amplification of low output voltage (gain), linearization of the nonlinear output response of the thermocouple so as to change to the equivalent input temperature, and provide cold junction compensation to improve the performance and accuracy of thermocouple measurements.
Equipment provided for measurement
There were three equipment provided for the measurement exercise and they include:
Type K thermocouple
The Type K thermocouple (chromel/alumel) is the most commonly used transducer to measure temperature with an electromotive force (e.m.f) of 41 microvolts per degree(??V/ oC) which is nonlinear and the voltage produced between its two dissimilar alloys changes with temperature i.e. the input temperature corresponds to the output voltage it generates. It is cheap to buy with the ability to perform in rugged environmental conditions and is calibrated to operate at wide temperature range of about -250 oC to 1370 oC. It is made of a constituent called nickel which is magnetic and its magnetic component may change direction or deviate when subjected to a high enough temperature and can affect its accuracy.
Signal connector signal conditioner
Thermocouple
Cold junction ‘(+@-)
Figure 2.2: Circuit diagram of a thermocouple, signal connector and signal conditioner
NI-USB 6008
The NI-USB 6008 is a National Instrument device that provides DAQ functionality for some applications like portable measurements, data logging and lab experiments. It is cheap for academic purposes and is used for more complicated measurement tasks. It has a ready to run data logger software which allows the user to perform quick measurements and can be configured by using Labview National Instruments software. It provides connection to 8 analog single-ended input channels (AI), 2 analog output channels (AO), 12 data input and output (I/O) channels, 32 bit counter bus with a very quick USB interface and are compatible with Labview 7.x, LabWindowsTM/CVI, and Measurement Studio DAQ modules for visual Studio.
Figure 2.3: NI-USB 6008 pin out
AD595 thermocouple amplifier
The AD595 thermocouple amplifier is a thermocouple amplifier and a cold junction compensator on a small chip of semiconductor material (microchip or IC) which produces a high output of 10 mV/oC from the input signal of a thermocouple as a result of combining a cold junction reference with a pre-calibrated amplifier. It has an accuracy of ??10C and ??30C for the A and C performance grade version respectively and can be powered by a supply including +5V and a negative supply if temperatures below 00C are to be measured. It laser trimmer is pre-calibrated so as to conform to the Type k thermocouple specification and is available in 14-pin side brazed ceramic dips (Devices, 1999).
Figure 2.4: Block diagram showing AD595 in a functional circuit
Configuration of the I/O channel(s)
The I/O channel(s) provide a way (path) for communication between the input device (thermocouple sensor) and the output device (DAQ). The thermocouple senses temperature as input and sends the data to the DAQ which receives the data and displays the information through a computer on the Labview front panel graph.
The following explain the configuration of the DAQ for the thermocouple measurement:
Channel Settings: this is used to select an I/O channel in the DAQ device either AI0 or AI1 can be chosen and rename to suit user
Signal Input Range: this is used to select the minimum and maximum voltage of the AD595 thermocouple amplifier which also helps to achieve better resolution of the NI-USB 6008 Data Acquisition Device
Scale Units: this is used to select the scale unit of the analog signal generated and since the thermocouples output signal measured corresponding to temperature is Voltage, then the Scaled unit chosen will be ‘Volts’
Terminal Configuration: this is used to choose terminal on the DAQ for which the signal conditioning circuit is connected
Custom Scaling: No scale was chosen since no custom scale was adopted
Acquisition Mode: this is used to select how the sample are played, the continuous samples was chosen because it allows the DAQ to collect data signals continuously from the circuit until the user decides to stop
Samples to Read: this allows the user to choose how many samples to read depending on the frequency of the input signal generated. It is important to choose at least twice the frequency signal to acquire all the desire signals. One thousand (2K) samples was chosen
Rate (Hz): this allows the user to choose the rate of the sample signals generated. Rate (Hz) 1k was chosen.
Connection of Circuit to DAQ and Configuration of I/O channel(s)
The connection of the circuit to the NI-USB 6008 data acquisition device was carried out by connecting two wires from the output voltage and ground of the signal conditioning unit i.e. the AD595 device.
The red wire from the signal conditioning unit was connected to the positive port of the analog input channel 0 (+AI0) of the DAQ device and the black wire from the ground was connected to the negative port of the analog input channel 0 (-AI0) of the DAQ. The diagrams below show the connections between the signal conditioning circuit and the connector block (DAQ).
Figure 2.5: Picture showing the connection of the signal conditioning circuit with the DAQ
Description of the Labview VI
Labview is a National instrument programming system design software that is optimal for control measurements and provides an engineer with tools to test, solve practical problems in a short amount of time, and the design of control systems. It is less complex and very easy to use compared to other programming simulation applications. The Labview Virtual Instrument (VI) program includes the Front Panel and the Block diagram and for this lab experiment, it is used to examine and determine the thermocouple frequency response and to carry out an analysis of the noise present in the filtered and unfiltered signal of the thermocouple voltage generated, displaying the result on its Graph indicators. The description of the Labview VI Front Panel and Block diagram are as follows:
Figure 2.6: Block diagram of the Labview design
Block diagram:
It is where a user can create the basic code for the Labview program. The program can be created when the block diagram is active by using the functions palette which contains objects like structure, numeric, Boolean, string, array, cluster, time and dialog, file I/O, and advanced functions which can be added to the block diagram.
Front Panel:
It is a graphic user interface that allows the user to interact with the Labview program. It can appear in silver, classic, modern or system style. The controls and indicators are located on the controls palette and used to build and add objects like numeric displays, graphs and charts, Boolean controls and indicators etc. to the front panel.
DAQ Assistant:
It allows a user to configure, generate and acquire analog input signals from any one of the data acquisitions (DAQ) input channel. For this experiment the signal conditioning circuit was connected to the analog input 0 channel of the NI-USB 6008 data acquisition device and the DAQ assistant is used to configure to DAQ so as to be able to acquire signals from the AD595 thermocouple amplifier.
For Loop:
The For loop like the while loop allows codes to be executed repeatedly by executing a subdiagram a required number of times (N). The For loop is found on the structure palette and can be placed on the block diagram. It is made up of the count and iteration terminal.
Trigger and Gate VI:
It is used to take out a part (segment) of a signal and its mode of operation is either based on a start or stop condition or can be static.
Curve Fitting VI:
It is used to calculate and determine the best fit parameter values that best depict an input signal. It can be used for linear, non-linear, spline, quadratic and polynomial models type. It minimizing the weighted mean squared error between the initial and best fit response signal generated. For this experiment initial guesses were made for the coefficients of non-linear model used.
Graphs:
It is a type of special indicator accepts different data types and used to display an array of input data or signals. In this case a waveform graph was used.
Numeric Function:
It is used to carry out mathematical and arithmetic actions on numbers and converts numbers from one data type to another. The multiply numeric function was used to return the products of inputs.
Figure 2.7: Configuration of Trigger and Gate
Figure 2.8: Curve fitting configuration
The diagram in figure 2.8 above is a window showing the configuration for curve fitting and the configuration steps are as follows:
Model Type: Non-linear model was chosen because the signal observed is a first order response (non-linear) curve.
Independent variable: t was the independent variable chosen
Maximum iterations: The default maximum iterations 500 is chosen.
Non-linear model: The equation for the non-linear model a*( 1- exp'(-t/b)) ) + c
Initial guesses: Values for a, b, and c were chosen to get the best fitting values for the curve. The values for a, b, and c are 15.000000, 0.040000, and 29.000000 respectively.
Figure 2.9: Transient response of the thermocouple for best fit 1st measurement
Figure 3.0: Transient response of the thermocouple for best fit 2nd measurement
Figure 3.1: Transient response of the thermocouple for best fit 3rd measurement
The diagrams in figures 2.9, 3.0 and 3.1 above show the transient response of the thermocouple after being inserted in warm water to get the best fit curve i.e. to replicate the actual thermocouple response curve. It is observed that with the use of the Trigger and Gate Express VI, the delay experienced in the in the three graphs were removed making the thermocouples signal response more appropriate providing a more decent best fit curve result. Carrying out multiple measurements to get the best fit curve reduces the time constants and produces a better response curve compared to taking one measurement. The table below shows the results from the three measurement activities with their residual and mean squared error values.
Model Parameters First Measurement(1st) Second Measurement(2nd) Third Measurement(3rd)
a (0C) 21.4671 10.2373 8.60708
b (sec) 0.0232065 0.039578 0.0432934
c (0C) 32.1068 29.661 29.4745
Residual 0.666461 0.0357227 0.124069
Mean Squared Error 0.431833 0.0181012 0.0227711
Table 2.1: Showing results from the three measurements with best fit parameters mean squared error and Residual for curve fitting.
From Table the second measurement was observed to have the best fitting curve with the minimum residual and Mean Squared error that are closest to zero compared to the 1st and 3rd measurements. The best fit parameter results of the second measurement will be inserted in the non-linear model equation which is given as:
y = a*( 1- exp'(-t/b)) ) + c””””””””””””(3.6)
T(t) = ??T ( 1- e^((-t)/??) ) + T0””””””””””””…(3.7)
Where,
a is the change in temperature of thermocouple (??T)
b is the time constant (??)
c is the initial temperature of the thermocouple (T0)
t is the time
Substituting values for a, b, and c of third measurement in the equation
T(t) = 10.2373( 1- exp'(-t/0.039578)) ) + 29.661”’..”””””..(3.8)
Equation 3.7 above is the non-linear model equation with best fit parameters for the thermocouple response signal at every value of time (t).
To achieve the output voltage response, the change in temperature and the initial temperature values from equation 3.7 need to be converted to volts this can be obtained by dividing the temperature value by 100 since 100oC is equal to 1V. So the resulting output voltage of the thermocouple is as follows:
V(t) = ??V ( 1- e^((-t)/??) ) + V0”’..””””””””””'(3.9)
Where,
a = ??V; b =1/??; and c = V0
V(t) = 0.102373( 1- exp'(-t/0.039578)) ) + 0.29661””””””’.(4.0)
Conclusion
The curve fitting experiment using the Type K thermocouple, the AD595 signal conditioning device, and the NI-USB 6008 to acquire and display signals using Labview software was carried out successfully. Curve fitting of the transient response signal of the thermocouple was achieved by analysing and obtaining the transient response of the thermocouple and using a non-linear model implementing best fit values to replicate the response curve by subjecting the thermocouple to temperature. This can be used to obtain the behaviour of an input response signal and improve efficiency for control systems.
References
Cimbala, J. M., 2013. Dynamic System Response. [Online]
Available at: https://www.mne.psu.edu/me345/Lectures/Dynamic_systems.pdf
[Accessed 10 March 2014].
Devices, A., 1999. Analog Devices. [Online]
Available at: http://www.analog.com/media/en/technical-documentation/data-sheets/AD594_595.pdf
[Accessed 2 March 2015].
Digilent Inc., 2010. Introduction to First Order Responses. [Online]
Available at: http://www.digilentinc.com/Classroom/RealAnalog/text/Chapter_2p4p1.pdf
[Accessed 6 March 2014].
here…
Essay: Data Acquisition and Analysis – Curve fitting and Data Modelling
Essay details and download:
- Subject area(s): Computer science essays
- Reading time: 13 minutes
- Price: Free download
- Published: 11 November 2015*
- Last Modified: 29 September 2024
- File format: Text
- Words: 3,737 (approx)
- Number of pages: 15 (approx)
Text preview of this essay:
This page of the essay has 3,737 words.
About this essay:
If you use part of this page in your own work, you need to provide a citation, as follows:
Essay Sauce, Data Acquisition and Analysis – Curve fitting and Data Modelling. Available from:<https://www.essaysauce.com/computer-science-essays/essay-data-acquisition-and-analysis-curve-fitting-and-data-modelling/> [Accessed 18-01-25].
These Computer science essays have been submitted to us by students in order to help you with your studies.
* This essay may have been previously published on EssaySauce.com and/or Essay.uk.com at an earlier date than indicated.