Restrict thermistor table range to 0C-500C
We don't care about the accuracy of very cold temperatures or unreasonably hot ones.
This commit is contained in:
parent
6542c284fb
commit
b7a2d58b31
|
|
@ -106,6 +106,7 @@ def BetaTable(ofp, params, names, settings, finalTable):
|
||||||
# It works like this:
|
# It works like this:
|
||||||
#
|
#
|
||||||
# - Calculate all (1024) ideal values.
|
# - Calculate all (1024) ideal values.
|
||||||
|
# - Keep only the ones in the interesting range (0..500C).
|
||||||
# - Insert the two extremes into our sample list.
|
# - Insert the two extremes into our sample list.
|
||||||
# - Calculate the linear approximation of the remaining values.
|
# - Calculate the linear approximation of the remaining values.
|
||||||
# - Insert the correct value for the "most-wrong" estimation into our
|
# - Insert the correct value for the "most-wrong" estimation into our
|
||||||
|
|
@ -115,11 +116,16 @@ def BetaTable(ofp, params, names, settings, finalTable):
|
||||||
# Calculate actual temps for all ADC values.
|
# Calculate actual temps for all ADC values.
|
||||||
actual = dict([(x, thrm.temp(1.0 * x)) for x in range(1, int(hiadc + 1))])
|
actual = dict([(x, thrm.temp(1.0 * x)) for x in range(1, int(hiadc + 1))])
|
||||||
|
|
||||||
# Build a lookup table starting with the extremes.
|
# Limit ADC range to 0C to 500C.
|
||||||
lookup = dict([(x, actual[x]) for x in [1, int(hiadc)]])
|
MIN_TEMP = 0
|
||||||
|
MAX_TEMP = 500
|
||||||
|
actual = dict([(adc, actual[adc]) for adc in actual
|
||||||
|
if actual[adc] <= MAX_TEMP and actual[adc] >= MIN_TEMP])
|
||||||
|
|
||||||
A = 1
|
# Build a lookup table starting with the extremes.
|
||||||
B = int(hiadc)
|
A = min(actual)
|
||||||
|
B = max(actual)
|
||||||
|
lookup = dict([(x, actual[x]) for x in [A,B]])
|
||||||
error = dict({})
|
error = dict({})
|
||||||
while len(lookup) < N:
|
while len(lookup) < N:
|
||||||
error.update(dict([(x, abs(actual[x] - LinearTableEstimate(lookup, x)))
|
error.update(dict([(x, abs(actual[x] - LinearTableEstimate(lookup, x)))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue