0% found this document useful (0 votes)
120 views

Solución: R T β T R (T) = 1000 Ω Ω

This document summarizes the linear approximation of a nonlinear temperature sensor transfer function. It evaluates the sensor's beta value using two known data points. It then plots the nonlinear transfer function and approximates it with: 1) A straight line between the end points, finding a maximum error of 66.5% of full scale. 2) A linear least squares fit, finding a maximum error of 64.2% of full scale.

Uploaded by

Duvan Bayona
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views

Solución: R T β T R (T) = 1000 Ω Ω

This document summarizes the linear approximation of a nonlinear temperature sensor transfer function. It evaluates the sensor's beta value using two known data points. It then plots the nonlinear transfer function and approximates it with: 1) A straight line between the end points, finding a maximum error of 66.5% of full scale. 2) A linear least squares fit, finding a maximum error of 64.2% of full scale.

Uploaded by

Duvan Bayona
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

29/8/2017 Ejercicio 2.

16

Linear approximation of nonlinear transfer function. The response of a temperature sensor is given as

where R0 is the resistance of the sensor at temperature T0 and β is a constant that depends on the material of
the sensor. T0 = 20°C. Temperatures T and T_{0} are in K. Given: R(T ) = 1000 Ω at 25°C and 3000 Ω W at
0°C. The sensor is intended for use between -45°C and 120°C.

1 1
β( − )
R(T ) = R 0 e T T
0

a.Evaluate β for this sensor and plot the sensor transfer function for the intended span.
b. Approximate the transfer function as a straight line connecting the end points and calculate the maximum error
expected as a percentage of full scale.
c. Approximate the transfer function as a linear least squares approximation and calculate the maximum error
expected as a percentage of full scale.

Solución

a. Evaluate β for this sensor and plot the sensor transfer function for the intended span. From the two known
points
R 1 = 3000 Ω , T1 = 273.15 K .

R 2 = 1000 Ω , T2 = 298.15 K .

From the general equation and the points,


R1
R0 = ,
1 1
β( − )
e T
1
T
0

we obtain
R2
ln( )
R1
β = .
1 1
( − )
T2 T1

file:///C:/Users/Manuel%20Ranchoddas/Downloads/Ejercicio+2.16.html 1/6
29/8/2017 Ejercicio 2.16

In [6]: import matplotlib.pyplot as plt


import numpy as np
from math import log, exp
%matplotlib inline

# Evaluate beta for this sensor


T_0=273.15+20;
N=(1/273.15-1/293.15)-(1/298.15-1/293.15);
beta= log(3000/1000)/N;
R_0=1000/exp(beta*((1/298.15)-(1/293.15)));

## Results
print ('Beta for this sensor = %2.2f and the resistance of the sensor at tempe
rature T0 is R_0 = = %2.2f' % (beta, R_0))

# Plot the sensor transfer function for the intended span.


# T= np.arange(start = -45, stop = 121, step = 1)+273.15
T = np.linspace(-45,120)+273.15
R_T= R_0*np.exp(beta*(1/T-1/T_0));

# Plot
# plt.plot(T,R_T,T[45],R_T[45],'ro',T[45+25],R_T[45+25],'ro')
plt.plot(T,R_T)
plt.ylabel('Resistance of the sensor[ohm]')
plt.xlabel('Temperature [K]')
plt.show()

Beta for this sensor = 3578.82 and the resistance of the sensor at temperatur
e T0 is R_0 = = 1227.20

The plot shows the nonlinear behaviour of the sensor and the two points used for estimating the curve. b.
Approximate the transfer function as a straight line connecting the end points and calculate the maximum error
expected as a percentage of full scale.
We approximate the transfer function as a straight line as R(T ) linear = aT + b and compute the error.

file:///C:/Users/Manuel%20Ranchoddas/Downloads/Ejercicio+2.16.html 2/6
29/8/2017 Ejercicio 2.16

In [8]: # Linear fit with just end points


a, b = np.polyfit(np.array([T[0],T[-1]]),np.array([R_T[0],R_T[-1]]),1)

print ('The coefficients are a = %2.4f and b = %2.4f' % (a, b))

# Linear approximation
R_T_linear = a*T+b

# Plot
plt.plot(T,R_T_linear,'b:',label='Linear approximation')
plt.plot(T,R_T,label='Transfer function')
plt.ylabel('Resistance of the sensor[ohm]')
plt.xlabel('Temperature [K]')
plt.legend(loc='upper right')
plt.show()

The coefficients are a = -240.6320 and b = 94659.4583

file:///C:/Users/Manuel%20Ranchoddas/Downloads/Ejercicio+2.16.html 3/6
29/8/2017 Ejercicio 2.16

In [9]: # Output Full scale


FS = np.abs(np.max(R_T)-np.min(R_T))

error=np.abs(R_T-R_T_linear)/FS*100;

# error_X=np.abs(error_Y/a2);
plt.ylabel('error [%]')
plt.plot(T,error)
plt.xlabel('Temperature [K]')
plt.show()
print ('The maximum error expected as a percentage of full scale is = %2.2f
%%' % (np.max(error)))

The maximum error expected as a percentage of full scale is = 66.49 %

Note how the error starts from zero reaches a maximum of 66.5 % and comes back down to zero at the other
end point as expected.

c. Approximate the transfer function as a linear least squares approximation and calculate the maximum error
expected as a percentage of full scale.

Mediante la funcion polyfit se realizo la aproximacion lineal de la funcion de transferencia del sensor. El maximo
error con respecto a la temperatura es calculado a partir de la diferencia entre R(T) y la aproximacion obtenida,
en el intervalo definido por los puntos de corte de la funciones. Esta diferencia dividida por la pendiente de la
aproximacion me dará el error en el eje correspondiente a la temperatura en K:

file:///C:/Users/Manuel%20Ranchoddas/Downloads/Ejercicio+2.16.html 4/6
29/8/2017 Ejercicio 2.16

In [10]: # polyfit computes the coefficients a and b of degree=1


a,b = np.polyfit(T,R_T,1)

# Linear approximation
R_T_lsq = a*T+b

# Plot
plt.plot(T,R_T_lsq,'b:',label='Least Squares fit')
plt.plot(T,R_T,label='Transfer function')
plt.ylabel('Resistance of sensor [ohm]')
plt.xlabel('Temperature [K]')
plt.legend(loc='upper right')
plt.show()

file:///C:/Users/Manuel%20Ranchoddas/Downloads/Ejercicio+2.16.html 5/6
29/8/2017 Ejercicio 2.16

In [11]: error=np.abs(R_T-R_T_lsq)/FS*100;

# error_X=np.abs(error_Y/a2);
plt.ylabel('error [%]')
plt.plot(T,error)
plt.xlabel('Temperature [K]')
plt.show()
print ('The maximum error expected as a percentage of full scale is = %2.1f
%%' % (np.max(error)))

The maximum error expected as a percentage of full scale is = 64.2 %

In [ ]:

file:///C:/Users/Manuel%20Ranchoddas/Downloads/Ejercicio+2.16.html 6/6

You might also like