diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index 6d548b359c..67c888de2b 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -356,7 +356,7 @@ static void getFloat(int offset) { /** * this response is part of dev console API */ - scheduleMsg(&logger, "float @%d is %f", offset, value); + scheduleMsg(&logger, "float @%d is %..100000f", offset, value); } static void setFloat(const char *offsetStr, const char *valueStr) { diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index b1b7d186b8..78d486ee31 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -23,6 +23,8 @@ EXTERN_ENGINE ; +static Logging *logger; + static bool initialized = false; /** @@ -131,24 +133,36 @@ void setThermistorConfiguration(ThermistorConf * tc, float tempC1, float r1, flo } void prepareThermistorCurve(ThermistorConf * config) { + efiAssertVoid(config!=NULL, "therm config"); float T1 = config->tempC_1 + KELV; float T2 = config->tempC_2 + KELV; float T3 = config->tempC_3 + KELV; + scheduleMsg(logger, "T1=%..100000f/T2=%..100000f/T3=%..100000f", T1, T2, T3); float L1 = logf(config->resistance_1); float L2 = logf(config->resistance_2); float L3 = logf(config->resistance_3); + scheduleMsg(logger, "R1=%..100000f/R2=%..100000f/R3=%..100000f", config->resistance_1, config->resistance_2, config->resistance_3); + scheduleMsg(logger, "L1=%..100000f/L2=%..100000f/L3=%..100000f", L1, L2, L3); float Y1 = 1 / T1; float Y2 = 1 / T2; float Y3 = 1 / T3; + scheduleMsg(logger, "Y1=%..100000f/Y2=%..100000f/Y3=%..100000f", Y1, Y2, Y3); + float U2 = (Y2 - Y1) / (L2 - L1); float U3 = (Y3 - Y1) / (L3 - L1); + scheduleMsg(logger, "U2=%..100000f/U3=%..100000f", U2, U3); + + config->s_h_c = (U3 - U2) / (L3 - L2) * pow(L1 + L2 + L3, -1); config->s_h_b = U2 - config->s_h_c * (L1 * L1 + L1 * L2 + L2 * L2); config->s_h_a = Y1 - (config->s_h_b + L1 * L1 * config->s_h_c) * L1; + + scheduleMsg(logger, "s_h_c=%..100000f/s_h_b=%..100000f/s_h_a=%..100000f", config->s_h_c, config->s_h_b, config->s_h_a); + } /** @@ -183,17 +197,19 @@ void setCommonNTCSensor(ThermistorConf *thermistorConf) { setThermistorConfiguration(thermistorConf, -20, 18000, 23.8889, 2100, 120.0, 100.0); } -static Logging *logger; - #if EFI_PROD_CODE static void testCltByR(float resistance) { Thermistor *thermistor = &engine->clt; float kTemp = getKelvinTemperature(resistance, thermistor->config); scheduleMsg(logger, "for R=%f we have %f", resistance, (kTemp - KELV)); + + initThermistorCurve(&engine->clt, &engine->engineConfiguration->clt, engine->engineConfiguration->cltAdcChannel); + } #endif void initThermistors(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_S) { + logger = sharedLogger; efiAssertVoid(engine!=NULL, "e NULL initThermistors"); efiAssertVoid(engine->engineConfiguration2!=NULL, "e2 NULL initThermistors"); initThermistorCurve(&engine->clt, &engine->engineConfiguration->clt, engine->engineConfiguration->cltAdcChannel); diff --git a/firmware/controllers/sensors/thermistors.h b/firmware/controllers/sensors/thermistors.h index bd05d35e5d..2d68962ea2 100644 --- a/firmware/controllers/sensors/thermistors.h +++ b/firmware/controllers/sensors/thermistors.h @@ -11,7 +11,7 @@ #include "main.h" #define _5_VOLTS 5.0 -#define KELV 273.15 +#define KELV 273.15f #include "sensor_types.h" #include "engine.h" diff --git a/firmware/svnversion.h b/firmware/svnversion.h index 697d73baa6..800fa8c657 100644 --- a/firmware/svnversion.h +++ b/firmware/svnversion.h @@ -1,5 +1,5 @@ // This file was generated by Version2Header -// Mon Feb 16 16:09:44 EST 2015 +// Wed Feb 18 21:12:04 EST 2015 #ifndef VCS_VERSION -#define VCS_VERSION "6883" +#define VCS_VERSION "6940" #endif diff --git a/firmware/util/datalogging.cpp b/firmware/util/datalogging.cpp index f06ca05050..a8472b249c 100644 --- a/firmware/util/datalogging.cpp +++ b/firmware/util/datalogging.cpp @@ -298,6 +298,7 @@ void printMsg(Logging *logger, const char *fmt, ...) { * in order to reduce memory usage */ void scheduleMsg(Logging *logging, const char *fmt, ...) { + efiAssertVoid(logging != NULL, "logging NULL"); int wasLocked = lockAnyContext(); resetLogging(logging); // todo: is 'reset' really needed here? appendMsgPrefix(logging);