X-Git-Url: http://git.smho.de/gw/?p=owSlave2.git;a=blobdiff_plain;f=DS18B20_Thermocouble%2Fconvthermocouple.py;fp=DS18B20_Thermocouble%2Fconvthermocouple.py;h=2d17bde60590b48a079b18da72993939c0ac15b5;hp=c11c3ddf200e36537e8efb371d9f4e6a73fcc340;hb=2490e261a78b2a98ee2a9b8fc19cb3f20225926b;hpb=45806622c08cded7d77c9c9735c433de5f7fa027 diff --git a/DS18B20_Thermocouble/convthermocouple.py b/DS18B20_Thermocouble/convthermocouple.py index c11c3dd..2d17bde 100644 --- a/DS18B20_Thermocouble/convthermocouple.py +++ b/DS18B20_Thermocouble/convthermocouple.py @@ -1,4 +1,4 @@ -fi=open("Typ-J.csv","r") +fi=open("Typ-K.csv","r") lastv=0 v=0 lastt=0 @@ -7,25 +7,36 @@ rs="" wc=0 for l in fi.readlines(): #print(l) + l=l.replace(",",".") ll=l.split(";") i=0 for n in ll[1:10]: - s=ll[0]+"."+str(i) + s=ll[0][:-1]+""+str(i) lastv=v lastt=t v=float(n) t=float(s) if (int(v)!=int(lastv)): - interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) - print int(v),interp + #print v,lastv + #print t,lastt + if (lastt<0): + interp=lastt+(t-lastt)/(v-lastv)*(int(v-1)-lastv) + #print (t-lastt)/(v-lastv)*(int(v-1)-lastv) + print int(v-1),interp + else: + interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) + #print (t-lastt)/(v-lastv)*(int(v)-lastv) + print int(v),interp rs=rs+", %f" %(interp) wc=wc+1 - if (v==0): + if (v<=-6): interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) print int(v),interp - rs="{0" - wc=1 - + rs="{" + wc=0 + if (v==0): + rs=rs+", %f" %(0) + wc=wc+1; i=i+1 print rs+"};" print wc \ No newline at end of file