def SteinhartHartTable(ofp, params, names, idx, settings, finalTable): ofp.output((" // %s temp table using Steinhart-Hart algorithm with " "parameters:") % (", ".join(names))) ofp.output((" // Rp = %s, T0 = %s, R0 = %s, T1 = %s, R1 = %s, " "T2 = %s, R2 = %s") % (params[0], params[1], params[2], params[3], params[4], params[5], params[6])) ofp.output(" {") thrm = SHThermistor(int(params[0]), int(params[1]), int(params[2]), int(params[3]), int(params[4]), int(params[5]), int(params[6])) for t in idx: a, r = thrm.setting(t) if a is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT TEMPERATURE %d" % t) continue if t <= 0: c = " " else: c = "," ofp.output(" {%4d, %5d}%s // %4d C, %6.0f ohms, %7.2f adc" % (int(round(a)), t*4, c, t, int(round(r)), a)) if finalTable: ofp.output(" }") else: ofp.output(" },")
def SteinhartHartTable(ofp, params, names, idx, settings, finalTable): ofp.output((" // %s temp table using Steinhart-Hart algorithm with " "parameters:") % (", ".join(names))) ofp.output( (" // Rp = %s, T0 = %s, R0 = %s, T1 = %s, R1 = %s, " "T2 = %s, R2 = %s") % (params[0], params[1], params[2], params[3], params[4], params[5], params[6])) ofp.output(" {") thrm = SHThermistor(int(params[0]), int(params[1]), int(params[2]), int(params[3]), int(params[4]), int(params[5]), int(params[6])) for t in idx: a, r = thrm.setting(t) if a is None: ofp.output( "// ERROR CALCULATING THERMISTOR VALUES AT TEMPERATURE %d" % t) continue if t <= 0: c = " " else: c = "," ofp.output(" {%4d, %5d}%s // %4d C, %6.0f ohms, %7.2f adc" % (int(round(a)), t * 4, c, t, int(round(r)), a)) if finalTable: ofp.output(" }") else: ofp.output(" },")
def SteinhartHartTable(ofp, params, names, settings, finalTable): ofp.output((" // %s temp table using Steinhart-Hart algorithm with " "parameters:") % (", ".join(names))) ofp.output((" // Rp = %s, T0 = %s, R0 = %s, T1 = %s, R1 = %s, " "T2 = %s, R2 = %s") % (params[0], params[1], params[2], params[3], params[4], params[5], params[6])) ofp.output(" {") thrm = SHThermistor(int(params[0]), float(params[1]), int(params[2]), float(params[3]), int(params[4]), float(params[5]), int(params[6])) hiadc = thrm.setting(0)[0] N = int(settings.numTemps) samples = optimizeTempTable(thrm, N, hiadc) prev = samples[0] for i in samples: t = thrm.temp(i) if t is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT ADC %d" % i) continue r = int(thrm.adcInv(i)) if i == max(samples): c = " " else: c = "," delta = (t - thrm.temp(prev)) / (prev - i) if i != prev else 0 ofp.output(" {%4d, %5d, %5d}%s // %4d C, %6d ohms, m = %6.3f" % (i, int(t * 4), int(delta * 4 * 256), c, int(t), int(round(r)), delta)) prev = i if finalTable: ofp.output(" }") else: ofp.output(" },")
def SteinhartHartTable(ofp, params, names, settings, finalTable): ofp.output((" // %s temp table using Steinhart-Hart algorithm with " "parameters:") % (", ".join(names))) ofp.output((" // Rp = %s, T0 = %s, R0 = %s, T1 = %s, R1 = %s, " "T2 = %s, R2 = %s") % (params[0], params[1], params[2], params[3], params[4], params[5], params[6])) ofp.output(" {") thrm = SHThermistor(int(params[0]), float(params[1]), int(params[2]), float(params[3]), int(params[4]), float(params[5]), int(params[6])) hiadc = thrm.setting(0)[0] N = int(settings.numTemps) step = int(hiadc / (N - 1)) idx = range(1, int(hiadc), step) while len(idx) > N: del idx[0] for i in range(1, int(hiadc), step): t = int(thrm.temp(i)) if t is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT ADC %d" % i) continue r = int(thrm.adcInv(i)) if i + step >= int(hiadc): c = " " else: c = "," ofp.output(" {%4d, %5d}%s // %4d C, %6d ohms" % (i, t * 4, c, t, int(round(r)))) if finalTable: ofp.output(" }") else: ofp.output(" },")
def SteinhartHartTable(ofp, params, names, settings, finalTable): ofp.output((" // %s temp table using Steinhart-Hart algorithm with " "parameters:") % (", ".join(names))) ofp.output( (" // Rp = %s, T0 = %s, R0 = %s, T1 = %s, R1 = %s, " "T2 = %s, R2 = %s") % (params[0], params[1], params[2], params[3], params[4], params[5], params[6])) ofp.output(" {") thrm = SHThermistor(int(params[0]), float(params[1]), int(params[2]), float(params[3]), int(params[4]), float(params[5]), int(params[6])) hiadc = thrm.setting(0)[0] N = int(settings.numTemps) step = int(hiadc / (N - 1)) idx = range(1, int(hiadc), step) while len(idx) > N: del idx[0] for i in range(1, int(hiadc), step): t = int(thrm.temp(i)) if t is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT ADC %d" % i) continue r = int(thrm.adcInv(i)) if i + step >= int(hiadc): c = " " else: c = "," ofp.output(" {%4d, %5d}%s // %4d C, %6d ohms" % (i, t * 4, c, t, int(round(r)))) if finalTable: ofp.output(" }") else: ofp.output(" },")
def SteinhartHartTable(ofp, params, names, settings, finalTable): ofp.output((" // %s temp table using Steinhart-Hart algorithm with " "parameters:") % (", ".join(names))) ofp.output( (" // Rp = %s, T0 = %s, R0 = %s, T1 = %s, R1 = %s, " "T2 = %s, R2 = %s") % (params[0], params[1], params[2], params[3], params[4], params[5], params[6])) ofp.output(" {") thrm = SHThermistor(int(params[0]), float(params[1]), int(params[2]), float(params[3]), int(params[4]), float(params[5]), int(params[6])) hiadc = thrm.setting(0)[0] N = int(settings.numTemps) samples = optimizeTempTable(thrm, N, hiadc) prev = samples[0] for i in samples: t = thrm.temp(i) if t is None: ofp.output("// ERROR CALCULATING THERMISTOR VALUES AT ADC %d" % i) continue r = int(thrm.adcInv(i)) if i == max(samples): c = " " else: c = "," delta = (t - thrm.temp(prev)) / (prev - i) if i != prev else 0 ofp.output( " {%4d, %5d, %5d}%s // %4d C, %6d ohms, m = %6.3f" % (i, int(t * 4), int(delta * 4 * 256), c, int(t), int(round(r))), delta) prev = i if finalTable: ofp.output(" }") else: ofp.output(" },")