X-Git-Url: http://git.smho.de/?a=blobdiff_plain;f=DS18B20_Thermocouble%2Fconvthermocouple.py;h=2d17bde60590b48a079b18da72993939c0ac15b5;hb=6467d8138460abffd9ddabc7b0a9f00c764af19c;hp=79f65effab4dd25cb120c93f045374a2b405628d;hpb=22f8e0389304cc3f78fec16d8ecc30069afe8584;p=owSlave2.git diff --git a/DS18B20_Thermocouble/convthermocouple.py b/DS18B20_Thermocouble/convthermocouple.py index 79f65ef..2d17bde 100644 --- a/DS18B20_Thermocouble/convthermocouple.py +++ b/DS18B20_Thermocouble/convthermocouple.py @@ -1,31 +1,42 @@ -fi=open("Typ-J.csv","r") -lastv=0 -v=0 -lastt=0 -t=0 -rs="" -wc=0 -for l in fi.readlines(): - #print(l) - ll=l.split(";") - i=0 - for n in ll[1:10]: - s=ll[0]+"."+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 - rs=rs+", %f" %(interp) - wc=wc+1 - if (v==0): - interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) - print int(v),interp - rs="{0" - wc=1 - - i=i+1 -print rs+"};" +fi=open("Typ-K.csv","r") +lastv=0 +v=0 +lastt=0 +t=0 +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][:-1]+""+str(i) + lastv=v + lastt=t + v=float(n) + t=float(s) + if (int(v)!=int(lastv)): + #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<=-6): + interp=lastt+(t-lastt)/(v-lastv)*(int(v)-lastv) + print int(v),interp + 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