mirror of
https://github.com/mck1117/wideband.git
synced 2026-09-30 09:57:06 -04:00
clamp temperature estimation
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user