mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Correct the NTC lookup
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include "Setup.h"
|
||||
#include "TipThermoModel.h"
|
||||
#include "USBPD.h"
|
||||
#include "Utils.h"
|
||||
#include "configuration.h"
|
||||
#include "crc32.h"
|
||||
#include "history.hpp"
|
||||
@@ -29,107 +30,51 @@ void resetWatchdog() {
|
||||
static const int32_t NTCHandleLookup[] = {
|
||||
// ADC Reading , Temp in C x10
|
||||
|
||||
// 64179, -400, //
|
||||
// 64001, -390, //
|
||||
// 63813, -380, //
|
||||
// 63618, -370, //
|
||||
// 63415, -360, //
|
||||
// 63204, -350, //
|
||||
// 62983, -340, //
|
||||
// 62757, -330, //
|
||||
// 62518, -320, //
|
||||
// 62271, -310, //
|
||||
// 62012, -300, //
|
||||
// 61748, -290, //
|
||||
// 61473, -280, //
|
||||
// 61186, -270, //
|
||||
// 60891, -260, //
|
||||
// 60585, -250, //
|
||||
// 60268, -240, //
|
||||
// 59941, -230, //
|
||||
// 59604, -220, //
|
||||
// 59255, -210, //
|
||||
58896, -200, //
|
||||
58526, -190, //
|
||||
58145, -180, //
|
||||
57752, -170, //
|
||||
57349, -160, //
|
||||
56934, -150, //
|
||||
56510, -140, //
|
||||
56073, -130, //
|
||||
55626, -120, //
|
||||
55167, -110, //
|
||||
54699, -100, //
|
||||
54220, -90, //
|
||||
53729, -80, //
|
||||
53229, -70, //
|
||||
52717, -60, //
|
||||
52200, -50, //
|
||||
51667, -40, //
|
||||
51128, -30, //
|
||||
50582, -20, //
|
||||
50025, -10, //
|
||||
49455, 0, //
|
||||
48883, 10, //
|
||||
48302, 20, //
|
||||
47712, 30, //
|
||||
47116, 40, //
|
||||
46510, 50, //
|
||||
45902, 60, //
|
||||
45286, 70, //
|
||||
44666, 80, //
|
||||
44044, 90, //
|
||||
43412, 100, //
|
||||
42783, 110, //
|
||||
42148, 120, //
|
||||
41500, 130, //
|
||||
40860, 140, //
|
||||
40222, 150, //
|
||||
39576, 160, //
|
||||
38935, 170, //
|
||||
38289, 180, //
|
||||
37640, 190, //
|
||||
36989, 200, //
|
||||
36353, 210, //
|
||||
35705, 220, //
|
||||
35060, 230, //
|
||||
34422, 240, //
|
||||
33792, 250, //
|
||||
33160, 260, //
|
||||
32534, 270, //
|
||||
31910, 280, //
|
||||
31291, 290, //
|
||||
30677, 300, //
|
||||
30069, 310, //
|
||||
29466, 320, //
|
||||
28867, 330, //
|
||||
28277, 340, //
|
||||
27693, 350, //
|
||||
27115, 360, //
|
||||
26544, 370, //
|
||||
25981, 380, //
|
||||
25426, 390, //
|
||||
24880, 400, //
|
||||
24339, 410, //
|
||||
23806, 420, //
|
||||
23281, 430, //
|
||||
22767, 440, //
|
||||
22259, 450, //
|
||||
// 21761, 460, //
|
||||
// 21268, 470, //
|
||||
// 20787, 480, //
|
||||
// 20313, 490, //
|
||||
// 19848, 500, //
|
||||
// 19392, 510, //
|
||||
// 18945, 520, //
|
||||
// 18507, 530, //
|
||||
// 18076, 540, //
|
||||
// 17655, 550, //
|
||||
// 17242, 560, //
|
||||
// 16838, 570, //
|
||||
// 16442, 580, //
|
||||
// 16052, 590, //
|
||||
// 15672, 600, //
|
||||
3221, -400, //
|
||||
4144, -350, //
|
||||
5271, -300, //
|
||||
6622, -250, //
|
||||
8219, -200, //
|
||||
10075, -150, //
|
||||
12190, -100, //
|
||||
14554, -50, //
|
||||
17151, 0, //
|
||||
19937, 50, //
|
||||
22867, 100, //
|
||||
25886, 150, //
|
||||
28944, 200, //
|
||||
29546, 210, //
|
||||
30159, 220, //
|
||||
30769, 230, //
|
||||
31373, 240, //
|
||||
31969, 250, //
|
||||
32566, 260, //
|
||||
33159, 270, //
|
||||
33749, 280, //
|
||||
34334, 290, //
|
||||
34916, 300, //
|
||||
35491, 310, //
|
||||
36062, 320, //
|
||||
36628, 330, //
|
||||
37186, 340, //
|
||||
37739, 350, //
|
||||
38286, 360, //
|
||||
38825, 370, //
|
||||
39358, 380, //
|
||||
39884, 390, //
|
||||
40400, 400, //
|
||||
42879, 450, //
|
||||
45160, 500, //
|
||||
47235, 550, //
|
||||
49111, 600, //
|
||||
50792, 650, //
|
||||
52292, 700, //
|
||||
53621, 750, //
|
||||
54797, 800, //
|
||||
55836, 850, //
|
||||
56748, 900, //
|
||||
57550, 950, //
|
||||
58257, 1000, //
|
||||
|
||||
};
|
||||
#endif
|
||||
@@ -138,28 +83,7 @@ uint16_t getHandleTemperature(uint8_t sample) {
|
||||
// Tip is wired up with an NTC thermistor
|
||||
// 10K NTC balanced with a 10K pulldown
|
||||
// NTCG163JF103FTDS
|
||||
#ifdef TEMP_NTC
|
||||
// vout =
|
||||
// For now not doing interpolation
|
||||
for (uint32_t i = 0; i < (sizeof(NTCHandleLookup) / (2 * sizeof(uint16_t))); i++) {
|
||||
if (result > NTCHandleLookup[(i * 2) + 0]) {
|
||||
return NTCHandleLookup[(i * 2) + 1];
|
||||
}
|
||||
}
|
||||
return 45 * 10;
|
||||
#endif
|
||||
#ifdef TEMP_TMP36
|
||||
#warn This is not shipped in production
|
||||
result -= 10240; // remove 0.5V offset
|
||||
// 10mV per C
|
||||
// 204.7 counts per Deg C above 0C
|
||||
result *= 10;
|
||||
result /= 205;
|
||||
if (result < 0) {
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
return Utils::InterpolateLookupTable(NTCHandleLookup, sizeof(NTCHandleLookup) / (2 * sizeof(int32_t)), result);
|
||||
}
|
||||
|
||||
uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
|
||||
|
||||
Reference in New Issue
Block a user