clamp temperature estimation

This commit is contained in:
Matthew Kennedy
2022-05-18 23:45:42 -07:00
parent d3e460a9a6
commit 62f5b9e7ae

View File

@@ -17,21 +17,22 @@ static float internalBatteryVoltage = 0;
static const struct inter_point lsu49_r_to_temp[] =
{
{ 80, 1030},
{ 150, 890},
{ 200, 840},
{ 250, 805},
{ 300, 780},
{ 350, 760},
{ 400, 745},
{ 450, 730},
{ 550, 705},
{ 650, 685},
{ 800, 665},
{ 1000, 640},
{ 1200, 630},
{ 2500, 565},
{ 6000, 25} /* measured while cold */
{ 80, 1030 },
{ 150, 890 },
{ 200, 840 },
{ 250, 805 },
{ 300, 780 },
{ 350, 760 },
{ 400, 745 },
{ 450, 730 },
{ 550, 705 },
{ 650, 685 },
{ 800, 665 },
{ 1000, 640 },
{ 1200, 630 },
{ 2500, 565 },
// approximated by the greatest measurable sensor resistance
{ 5000, 500 }
};
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
@@ -110,7 +111,14 @@ float GetSensorInternalResistance()
float GetSensorTemperature()
{
return interpolate_1d_float(lsu49_r_to_temp, ARRAY_SIZE(lsu49_r_to_temp), GetSensorInternalResistance());
float esr = GetSensorInternalResistance();
if (esr > 5000)
{
return 0;
}
return interpolate_1d_float(lsu49_r_to_temp, ARRAY_SIZE(lsu49_r_to_temp), esr);
}
float GetNernstDc()