auto-sync
This commit is contained in:
parent
9283b1f39a
commit
a73141f687
|
@ -58,6 +58,7 @@ public:
|
|||
ThermistorMath();
|
||||
void setConfig(thermistor_conf_s *config);
|
||||
void prepareThermistorCurve(thermistor_conf_s *tc);
|
||||
bool isLinearSensor();
|
||||
float s_h_a;
|
||||
float s_h_b;
|
||||
float s_h_c;
|
||||
|
|
|
@ -49,8 +49,7 @@ float getVoutInVoltageDividor(float Vin, float r1, float r2) {
|
|||
return r2 * Vin / (r1 + r2);
|
||||
}
|
||||
|
||||
float getKelvinTemperature(ThermistorConf *config, float resistance, ThermistorMath *tm) {
|
||||
tm->setConfig(&config->config); // implementation checks if config has changed or not
|
||||
float getKelvinTemperature(float resistance, ThermistorMath *tm) {
|
||||
|
||||
if (resistance <= 0) {
|
||||
//warning("Invalid resistance in getKelvinTemperature=", resistance);
|
||||
|
@ -86,10 +85,12 @@ float getTemperatureC(ThermistorConf *config, ThermistorMath *tm) {
|
|||
firmwareError(CUSTOM_ERR_THERM, "thermstr not initialized");
|
||||
return NAN;
|
||||
}
|
||||
tm->setConfig(&config->config); // implementation checks if configuration has changed or not
|
||||
|
||||
float voltage = getVoltageDivided("term", config->adcChannel);
|
||||
float resistance = getResistance(config, voltage);
|
||||
|
||||
float kelvinTemperature = getKelvinTemperature(config, resistance, tm);
|
||||
float kelvinTemperature = getKelvinTemperature(resistance, tm);
|
||||
return convertKelvinToCelcius(kelvinTemperature);
|
||||
}
|
||||
|
||||
|
@ -214,7 +215,8 @@ void setCommonNTCSensor(ThermistorConf *thermistorConf) {
|
|||
|
||||
#if EFI_PROD_CODE
|
||||
static void testCltByR(float resistance) {
|
||||
float kTemp = getKelvinTemperature(&engineConfiguration->clt, resistance, &engine->engineState.cltCurve);
|
||||
// we expect slowPeriodicCallback to already update configuration in the curve helper class see setConfig
|
||||
float kTemp = getKelvinTemperature(resistance, &engine->engineState.cltCurve);
|
||||
scheduleMsg(logger, "for R=%f we have %f", resistance, (kTemp - KELV));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@ float getTempK(float resistance);
|
|||
float convertCelciustoF(float tempC);
|
||||
float convertFtoCelcius(float tempF);
|
||||
|
||||
float getKelvinTemperature(ThermistorConf *config, float resistance, ThermistorMath *tm);
|
||||
float getKelvinTemperature(float resistance, ThermistorMath *tm);
|
||||
float getResistance(ThermistorConf *config, float voltage);
|
||||
float getTemperatureC(ThermistorConf *config, ThermistorMath *tm);
|
||||
float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_F);
|
||||
|
|
|
@ -91,7 +91,8 @@ void testSensors(void) {
|
|||
ThermistorMath tm;
|
||||
{
|
||||
setThermistorConfiguration(&tc, 32, 9500, 75, 2100, 120, 1000);
|
||||
float t = getKelvinTemperature(&tc, 2100, &tm);
|
||||
tm.setConfig(&tc.config);
|
||||
float t = getKelvinTemperature(2100, &tm);
|
||||
assertEquals(75 + KELV, t);
|
||||
|
||||
assertEquals(-0.003, tm.s_h_a);
|
||||
|
@ -103,8 +104,9 @@ void testSensors(void) {
|
|||
{
|
||||
// 2003 Neon sensor
|
||||
setThermistorConfiguration(&tc, 0, 32500, 30, 7550, 100, 700);
|
||||
tm.setConfig(&tc.config);
|
||||
|
||||
float t = getKelvinTemperature(&tc, 38000, &tm);
|
||||
float t = getKelvinTemperature(38000, &tm);
|
||||
assertEquals(-2.7983, t - KELV);
|
||||
|
||||
assertEqualsM("A", 0.0009, tm.s_h_a);
|
||||
|
|
Loading…
Reference in New Issue