You are on page 1of 3

In [278…

# By Alberto Caro S.
# Sistemas Inteligentes INFO1157
# Unidad Sensores

import matplotlib.pyplot as plt


import matplotlib.patches as mpatches
import numpy as np
import random as RA
import scipy

In [49]:
def LM34(nV): # Sensor grados Farheihein
nAux = (nV/0.01)
if nAux >= 125: return (125)
else: return nAux

def LM35(nV): # Sensor grados Celcius


nAux = (nV/0.01)
if nAux >= 125: return (125)
else: return nAux

def TPM36(nL): # Sensor grados Celcius


return ((5.0/1024)*nL*100-50)

def AD592(nRC):
CALIB = 43680.0
return ((CALIB/nRC)-273)

In [55]:
aVolt = [0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.10,0.11,0.12,0.125]

In [246…
nSAMP = 250
aTime = np.arange(nSAMP)
aTemF = [LM34(RA.choice(aVolt)) for i in range(nSAMP)]
aTemC = [LM35(RA.choice(aVolt)) for i in range(nSAMP)]
aTem3 = [TPM36(RA.randint(50,200)) for i in range(nSAMP)]
aTemA = [AD592(RA.randint(130,170)) for i in range(nSAMP)]

In [247…
fig,axes = plt.subplots(figsize=(20,3))
axes.plot(aTime,aTemF,'r')
axes.set_xlabel("Tiempo/s")
axes.set_ylabel("Tempe LM34 (F°)")
plt.grid(True)
In [248…
fig,axes = plt.subplots(figsize=(20,3))
axes.plot(aTime,aTemC,'g')
axes.set_xlabel('Tiempo/s')
axes.set_ylabel('Tempe LM35 (C°)')
plt.grid(True)

In [284…
nW = 10 # Ventama movil de 10 datos pasados historicos
xf = np.zeros(len(aTem3)-nW + 1)
for i in range(len(aTem3)-nW + 1):
xf[i] = np.mean(aTem3[i:i+nW])
fig,axes = plt.subplots(figsize=(20,3))
axes.plot(aTime,aTem3,'b')
axes.plot(aTime[nW-1:],xf,'r',lw=3) # OffSet x(t) = 10 en adelante segun la ventana..
axes.set_xlabel('Tiempo/s')
axes.set_ylabel('Tempe TPM36 (C°)')
plt.title('Tracking Temperatura Promedio Movil - Ventana = 10')
plt.legend(['Tempe','Promedio Movil'])
plt.grid(True)
In [270…
fig,axes = plt.subplots(figsize=(20,3))
axes.plot(aTime,aTemA,'y')
axes.set_ylabel('Tempe AD592 (C°)')
plt.grid(True)

In [252…
np.mean(aTem3)

10.83203125
Out[252…

In [ ]:

In [ ]:

You might also like