Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
Restrict thermistor table range to 0C-500C
Browse files Browse the repository at this point in the history
We don't care about the accuracy of very cold temperatures
or unreasonably hot ones.
  • Loading branch information
phord committed Apr 13, 2016
1 parent b8dab21 commit 0fc8212
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions configtool/thermistortablefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,16 @@ def BetaTable(ofp, params, names, settings, finalTable):
# Calculate actual temps for all ADC values.
actual = dict([(x, thrm.temp(1.0 * x)) for x in range(1, int(hiadc + 1))])

# Limit ADC range to 0C to 500C
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])

# Build a lookup table starting with the extremes.
lookup = dict([(x, actual[x]) for x in [1, int(hiadc)]])

A = 1
B = int(hiadc)
A = min(actual)
B = max(actual)
lookup = dict([(x, actual[x]) for x in [A,B]])
error = dict({})
while len(lookup) < N:
error.update(dict([(x, abs(actual[x] - LinearTableEstimate(lookup, x)))
Expand Down

0 comments on commit 0fc8212

Please sign in to comment.