diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index eee6859940..bafdd3443a 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -182,13 +182,13 @@ void setCitroenBerlingoTU3JPConfiguration(DECLARE_ENGINE_PARAMETER_F) { /** * IAT */ - engineConfiguration->iatAdcChannel = EFI_ADC_13; + engineConfiguration->iat.adcChannel = EFI_ADC_13; setThermistorConfiguration(&engineConfiguration->iat, -20.0, 15600.0, 23.0, 2250.0, 92.0, 240.0); engineConfiguration->iat.config.bias_resistor = 2660; /** * CLT */ - engineConfiguration->cltAdcChannel = EFI_ADC_11; + engineConfiguration->clt.adcChannel = EFI_ADC_11; setThermistorConfiguration(&engineConfiguration->clt, -20.0, 28680.0, 25.0, 2796.0, 100.0, 177.0); engineConfiguration->iat.config.bias_resistor = 2660; /** diff --git a/firmware/config/engines/custom_engine.cpp b/firmware/config/engines/custom_engine.cpp index b481b39f36..29d322fe19 100644 --- a/firmware/config/engines/custom_engine.cpp +++ b/firmware/config/engines/custom_engine.cpp @@ -37,8 +37,8 @@ void setCustomEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->map.sensor.hwChannel = EFI_ADC_0; - engineConfiguration->cltAdcChannel = EFI_ADC_12; - engineConfiguration->iatAdcChannel = EFI_ADC_11; + engineConfiguration->clt.adcChannel = EFI_ADC_12; + engineConfiguration->iat.adcChannel = EFI_ADC_11; engineConfiguration->afr.hwChannel = EFI_ADC_13; setCommonNTCSensor(&engineConfiguration->clt); diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index 8469e9b694..4ed47d452d 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -326,12 +326,12 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { /** * IAT D15/W7 */ - engineConfiguration->iatAdcChannel = EFI_ADC_11; + engineConfiguration->iat.adcChannel = EFI_ADC_11; /** * CLT D13/W9 */ - engineConfiguration->cltAdcChannel = EFI_ADC_12; + engineConfiguration->clt.adcChannel = EFI_ADC_12; boardConfiguration->sensorChartMode = SC_MAP; diff --git a/firmware/config/engines/ford_1995_inline_6.cpp b/firmware/config/engines/ford_1995_inline_6.cpp index be1e909102..374b510d06 100644 --- a/firmware/config/engines/ford_1995_inline_6.cpp +++ b/firmware/config/engines/ford_1995_inline_6.cpp @@ -70,8 +70,8 @@ void setFordInline6(DECLARE_ENGINE_PARAMETER_F) { // input channel 12 is PC1, that's ADC11 engineConfiguration->tpsAdcChannel = EFI_ADC_4; - engineConfiguration->iatAdcChannel = EFI_ADC_2; - engineConfiguration->cltAdcChannel = EFI_ADC_1; + engineConfiguration->iat.adcChannel = EFI_ADC_2; + engineConfiguration->clt.adcChannel = EFI_ADC_1; engineConfiguration->afr.hwChannel = EFI_ADC_11; engineConfiguration->map.sensor.type = MT_MPX4250; diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index aec16aba72..fc1b94f6fa 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -144,8 +144,8 @@ void setFordAspireEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->vbattAdcChannel = EFI_ADC_0; engineConfiguration->map.sensor.hwChannel = EFI_ADC_4; engineConfiguration->mafAdcChannel = EFI_ADC_1; - engineConfiguration->cltAdcChannel = EFI_ADC_11; -// engineConfiguration->iatAdcChannel = + engineConfiguration->clt.adcChannel = EFI_ADC_11; +// engineConfiguration->iat.adcChannel = engineConfiguration->map.sensor.type = MT_DENSO183; } diff --git a/firmware/config/engines/honda_accord.cpp b/firmware/config/engines/honda_accord.cpp index 2d5385f62c..9a43e12ce6 100644 --- a/firmware/config/engines/honda_accord.cpp +++ b/firmware/config/engines/honda_accord.cpp @@ -122,12 +122,12 @@ static void setHondaAccordConfigurationCommon(DECLARE_ENGINE_PARAMETER_F) { /** * IAT D15/W7 */ - engineConfiguration->iatAdcChannel = EFI_ADC_11; + engineConfiguration->iat.adcChannel = EFI_ADC_11; /** * CLT D13/W9 */ - engineConfiguration->cltAdcChannel = EFI_ADC_12; + engineConfiguration->clt.adcChannel = EFI_ADC_12; /** diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index c7b2d7075a..2e6ca7037a 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -196,7 +196,7 @@ static void common079721_2351(engine_configuration_s *engineConfiguration, board // Frankenstein analog input #12: adc engineConfiguration->mafAdcChannel = EFI_ADC_1; engineConfiguration->tpsAdcChannel = EFI_ADC_3; - engineConfiguration->cltAdcChannel = EFI_ADC_11; + engineConfiguration->clt.adcChannel = EFI_ADC_11; } @@ -349,8 +349,8 @@ void setFordEscortGt(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->tpsAdcChannel = EFI_ADC_NONE; // engineConfiguration->map.sensor.hwChannel = EFI_ADC_4; engineConfiguration->mafAdcChannel = EFI_ADC_0; - engineConfiguration->cltAdcChannel = EFI_ADC_12; - engineConfiguration->iatAdcChannel = EFI_ADC_11; + engineConfiguration->clt.adcChannel = EFI_ADC_12; + engineConfiguration->iat.adcChannel = EFI_ADC_11; // todo: 8.2 or 10k? engineConfiguration->vbattDividerCoeff = ((float) (10 + 33)) / 10 * 2; @@ -423,8 +423,8 @@ static void setMiata1994_common(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->tpsAdcChannel = EFI_ADC_2; engineConfiguration->map.sensor.hwChannel = EFI_ADC_4; engineConfiguration->mafAdcChannel = EFI_ADC_0; - engineConfiguration->cltAdcChannel = EFI_ADC_12; - engineConfiguration->iatAdcChannel = EFI_ADC_11; + engineConfiguration->clt.adcChannel = EFI_ADC_12; + engineConfiguration->iat.adcChannel = EFI_ADC_11; // end of 1994 commond } @@ -508,7 +508,7 @@ void setMiata1996(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->idle.solenoidPin = GPIOE_5; engineConfiguration->mafAdcChannel = EFI_ADC_1; - engineConfiguration->cltAdcChannel = EFI_ADC_11; + engineConfiguration->clt.adcChannel = EFI_ADC_11; engineConfiguration->tpsAdcChannel = EFI_ADC_13; boardConfiguration->ignitionPins[0] = GPIOE_12; // Frankenstein: high side #3 diff --git a/firmware/config/engines/mazda_miata_nb.cpp b/firmware/config/engines/mazda_miata_nb.cpp index 8c452d13ce..2b1063433f 100644 --- a/firmware/config/engines/mazda_miata_nb.cpp +++ b/firmware/config/engines/mazda_miata_nb.cpp @@ -39,8 +39,8 @@ void setMazdaMiataNbEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->vbattAdcChannel = EFI_ADC_0; // 1 is the old value // engineConfiguration->map.channel = 1; engineConfiguration->mafAdcChannel = EFI_ADC_1; - engineConfiguration->cltAdcChannel = EFI_ADC_11; - engineConfiguration->iatAdcChannel = EFI_ADC_13; + engineConfiguration->clt.adcChannel = EFI_ADC_11; + engineConfiguration->iat.adcChannel = EFI_ADC_13; engineConfiguration->afr.hwChannel = EFI_ADC_2; boardConfiguration->idle.solenoidPin = GPIOE_0; diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 4340cc583a..88fce0bf02 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -76,12 +76,6 @@ Engine::Engine(persistent_config_s *config) { knockNow = false; knockEver = false; - iat.config = NULL; - iat.channel = EFI_ADC_NONE; - - clt.config = NULL; - clt.channel = EFI_ADC_NONE; - injectorLagMs = fuelMs = 0; clutchDownState = clutchUpState = false; memset(&m, 0, sizeof(m)); diff --git a/firmware/controllers/algo/engine.h b/firmware/controllers/algo/engine.h index 04d078b106..3a01155705 100644 --- a/firmware/controllers/algo/engine.h +++ b/firmware/controllers/algo/engine.h @@ -124,11 +124,6 @@ public: class RpmCalculator; -typedef struct { - ThermistorConf *config; - adc_channel_e channel; -} Thermistor; - #define MAF_DECODING_CACHE_SIZE 256 #define MAF_DECODING_CACHE_MULT (MAF_DECODING_CACHE_SIZE / 5.0) @@ -183,9 +178,6 @@ public: */ uint64_t stopEngineRequestTimeNt; - Thermistor iat; - Thermistor clt; - AccelEnrichmemnt mapAccelEnrichment; AccelEnrichmemnt tpsAccelEnrichment; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index b9aa9ea4a2..415ee9860f 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -396,8 +396,8 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_F) { boardConfiguration->alternatorDT = 100; engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; - engineConfiguration->cltAdcChannel = EFI_ADC_6; - engineConfiguration->iatAdcChannel = EFI_ADC_7; + engineConfiguration->clt.adcChannel = EFI_ADC_6; + engineConfiguration->iat.adcChannel = EFI_ADC_7; engineConfiguration->mafAdcChannel = EFI_ADC_NONE; engineConfiguration->afr.hwChannel = EFI_ADC_14; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 45f92614da..ad0f6cb193 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated by config_definition.jar on Fri May 22 14:07:18 EDT 2015 +// this section was generated by config_definition.jar on Fri May 22 22:10:47 EDT 2015 // begin #include "rusefi_types.h" typedef struct { @@ -141,8 +141,8 @@ typedef struct { /** * offset 28 */ - float unused[3]; - /** total size 40*/ + adc_channel_e adcChannel; + /** total size 32*/ } ThermistorConf; typedef struct { @@ -732,9 +732,13 @@ typedef struct { */ ThermistorConf clt; /** - * offset 296 + * offset 288 */ ThermistorConf iat; + /** + * offset 320 + */ + float unused[4]; /** * offset 336 */ @@ -900,14 +904,13 @@ typedef struct { */ float globalFuelCorrection; /** - * todo: merge with channel settings, use full-scale Thermistor! * offset 572 */ - adc_channel_e cltAdcChannel; + int unused11; /** * offset 576 */ - adc_channel_e iatAdcChannel; + int unused12; /** * offset 580 */ @@ -1326,4 +1329,4 @@ typedef struct { } persistent_config_s; // end -// this section was generated by config_definition.jar on Fri May 22 14:07:18 EDT 2015 +// this section was generated by config_definition.jar on Fri May 22 22:10:47 EDT 2015 diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index e59c927398..f28377d775 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -1,5 +1,5 @@ #define LE_COMMAND_LENGTH 200 -#define TS_FILE_VERSION 20150506 +#define TS_FILE_VERSION 20150522 #define MAP_ANGLE_SIZE 8 #define MAP_WINDOW_SIZE 8 #define CLT_CURVE_SIZE 16 @@ -87,25 +87,27 @@ #define clt_resistance_3_offset_hex 114 #define clt_bias_resistor_offset 280 #define clt_bias_resistor_offset_hex 118 -#define clt_unused_offset 284 -#define iat_offset 296 -#define iat_offset_hex 128 -#define iat_config_offset 296 -#define iat_config_offset_hex 128 -#define iat_tempC_1_offset 296 -#define iat_tempC_1_offset_hex 128 -#define iat_tempC_2_offset 300 -#define iat_tempC_3_offset 304 -#define iat_tempC_3_offset_hex 130 -#define iat_resistance_1_offset 308 -#define iat_resistance_1_offset_hex 134 -#define iat_resistance_2_offset 312 -#define iat_resistance_2_offset_hex 138 -#define iat_resistance_3_offset 316 -#define iat_bias_resistor_offset 320 -#define iat_bias_resistor_offset_hex 140 -#define iat_unused_offset 324 -#define iat_unused_offset_hex 144 +#define clt_adcChannel_offset 284 +#define iat_offset 288 +#define iat_offset_hex 120 +#define iat_config_offset 288 +#define iat_config_offset_hex 120 +#define iat_tempC_1_offset 288 +#define iat_tempC_1_offset_hex 120 +#define iat_tempC_2_offset 292 +#define iat_tempC_2_offset_hex 124 +#define iat_tempC_3_offset 296 +#define iat_tempC_3_offset_hex 128 +#define iat_resistance_1_offset 300 +#define iat_resistance_2_offset 304 +#define iat_resistance_2_offset_hex 130 +#define iat_resistance_3_offset 308 +#define iat_resistance_3_offset_hex 134 +#define iat_bias_resistor_offset 312 +#define iat_bias_resistor_offset_hex 138 +#define iat_adcChannel_offset 316 +#define unused_offset 320 +#define unused_offset_hex 140 #define sparkDwellBins_offset 336 #define sparkDwellBins_offset_hex 150 #define sparkDwell_offset 368 @@ -173,9 +175,9 @@ #define hip9011SpiDevice_offset_hex 234 #define globalFuelCorrection_offset 568 #define globalFuelCorrection_offset_hex 238 -#define cltAdcChannel_offset 572 -#define iatAdcChannel_offset 576 -#define iatAdcChannel_offset_hex 240 +#define unused11_offset 572 +#define unused12_offset 576 +#define unused12_offset_hex 240 #define mafAdcChannel_offset 580 #define mafAdcChannel_offset_hex 244 #define afr_offset 584 diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index c422487e46..96eac2c61e 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -323,9 +323,9 @@ static void printAnalogChannelInfo(const char *name, adc_channel_e hwChannel) { static void printAnalogInfo(void) { printAnalogChannelInfo("hip9011", EFI_ADC_10); printAnalogChannelInfo("TPS", engineConfiguration->tpsAdcChannel); - printAnalogChannelInfo("CLT", engineConfiguration->cltAdcChannel); + printAnalogChannelInfo("CLT", engineConfiguration->clt.adcChannel); if (engineConfiguration->hasIatSensor) { - printAnalogChannelInfo("IAT", engineConfiguration->iatAdcChannel); + printAnalogChannelInfo("IAT", engineConfiguration->iat.adcChannel); } if (hasMafSensor()) { printAnalogChannelInfo("MAF", engineConfiguration->mafAdcChannel); diff --git a/firmware/controllers/flash_main.h b/firmware/controllers/flash_main.h index 6336e98be6..5352f8c71e 100644 --- a/firmware/controllers/flash_main.h +++ b/firmware/controllers/flash_main.h @@ -12,7 +12,7 @@ #include "engine_configuration.h" #include "engine.h" -#define FLASH_DATA_VERSION 8080 +#define FLASH_DATA_VERSION 8100 void readFromFlash(void); void initFlash(Logging *sharedLogger, Engine *engine); diff --git a/firmware/controllers/sensors/thermistors.cpp b/firmware/controllers/sensors/thermistors.cpp index 1a1cc39ccb..cf57453382 100644 --- a/firmware/controllers/sensors/thermistors.cpp +++ b/firmware/controllers/sensors/thermistors.cpp @@ -45,11 +45,11 @@ float getVoutInVoltageDividor(float Vin, float r1, float r2) { return r2 * Vin / (r1 + r2); } -float convertResistanceToKelvinTemperature(float resistance, thermistor_curve_s * curve) { +float getKelvinTemperature(float resistance, thermistor_curve_s * curve) { efiAssert(curve != NULL, "thermistor pointer is NULL", NAN); if (resistance <= 0) { - //warning("Invalid resistance in convertResistanceToKelvinTemperature=", resistance); + //warning("Invalid resistance in getKelvinTemperature=", resistance); return 0.0f; } float logR = logf(resistance); @@ -69,26 +69,21 @@ float convertKelvinToFahrenheit(float kelvin) { return convertCelsiustoF(tempC); } -float getKelvinTemperature(float resistance, thermistor_curve_s * curve) { - // todo: inline thid method - return convertResistanceToKelvinTemperature(resistance, curve); -} - -float getResistance(Thermistor *thermistor) { - float voltage = getVoltageDivided("term", thermistor->channel); - efiAssert(thermistor->config != NULL, "thermistor config is null", NAN); - thermistor_conf_s *tc = &thermistor->config->config; +float getResistance(ThermistorConf *config) { + float voltage = getVoltageDivided("term", config->adcChannel); + efiAssert(config != NULL, "thermistor config is null", NAN); + thermistor_conf_s *tc = &config->config; float resistance = getR2InVoltageDividor(voltage, _5_VOLTS, tc->bias_resistor); return resistance; } -float getTemperatureC(Thermistor *thermistor, thermistor_curve_s * curve) { +float getTemperatureC(ThermistorConf *config, thermistor_curve_s * curve) { if (!initialized) { firmwareError("thermstr not initialized"); return NAN; } - float resistance = getResistance(thermistor); + float resistance = getResistance(config); float kelvinTemperature = getKelvinTemperature(resistance, curve); return convertKelvinToCelcius(kelvinTemperature); @@ -108,7 +103,7 @@ bool isValidIntakeAirTemperature(float temperature) { * @return coolant temperature, in Celsius */ float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_F) { - float temperature = getTemperatureC(&engine->clt, &engine->engineState.cltCurve.curve); + float temperature = getTemperatureC(&engineConfiguration->clt, &engine->engineState.cltCurve.curve); if (!isValidCoolantTemperature(temperature)) { efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN); if (engineConfiguration->hasCltSensor) { @@ -173,7 +168,7 @@ void prepareThermistorCurve(ThermistorConf * config, thermistor_curve_s * curve) * @return Celsius value */ float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_F) { - float temperature = getTemperatureC(&engine->iat, &engine->engineState.iatCurve.curve); + float temperature = getTemperatureC(&engineConfiguration->iat, &engine->engineState.iatCurve.curve); if (!isValidIntakeAirTemperature(temperature)) { efiAssert(engineConfiguration!=NULL, "NULL engineConfiguration", NAN); if (engineConfiguration->hasIatSensor) { @@ -184,13 +179,6 @@ float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_F) { return temperature; } -static void initThermistorCurve(Thermistor * t, ThermistorConf *config, adc_channel_e channel, - thermistor_curve_s * curve) { - prepareThermistorCurve(config, curve); - t->config = config; - t->channel = channel; -} - void setDodgeSensor(ThermistorConf *thermistorConf) { setThermistorConfiguration(thermistorConf, -40, 336660, 30, 7550, 120, 390); } @@ -208,12 +196,10 @@ void setCommonNTCSensor(ThermistorConf *thermistorConf) { #if EFI_PROD_CODE static void testCltByR(float resistance) { - Thermistor *thermistor = &engine->clt; float kTemp = getKelvinTemperature(resistance, &engine->engineState.cltCurve.curve); scheduleMsg(logger, "for R=%f we have %f", resistance, (kTemp - KELV)); - initThermistorCurve(&engine->clt, &engineConfiguration->clt, engineConfiguration->cltAdcChannel, - &engine->engineState.cltCurve.curve); + prepareThermistorCurve(&engineConfiguration->clt, &engine->engineState.cltCurve.curve); } #endif @@ -222,9 +208,9 @@ 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, &engineConfiguration->clt, engineConfiguration->cltAdcChannel, + prepareThermistorCurve(&engineConfiguration->clt, &engine->engineState.cltCurve.curve); - initThermistorCurve(&engine->iat, &engineConfiguration->iat, engineConfiguration->iatAdcChannel, + prepareThermistorCurve(&engineConfiguration->iat, &engine->engineState.iatCurve.curve); #if EFI_PROD_CODE diff --git a/firmware/controllers/sensors/thermistors.h b/firmware/controllers/sensors/thermistors.h index 1c38c12c54..aab7ac590a 100644 --- a/firmware/controllers/sensors/thermistors.h +++ b/firmware/controllers/sensors/thermistors.h @@ -32,15 +32,13 @@ float convertCelciustoF(float tempC); float convertFtoCelcius(float tempF); float getKelvinTemperature(float resistance, thermistor_curve_s * curve); -float getResistance(Thermistor *thermistor); -float getTemperatureC(Thermistor *thermistor, thermistor_curve_s * curve); +float getResistance(ThermistorConf *config); +float getTemperatureC(ThermistorConf *config, thermistor_curve_s * curve); float getCoolantTemperature(DECLARE_ENGINE_PARAMETER_F); bool isValidCoolantTemperature(float temperature); float getIntakeAirTemperature(DECLARE_ENGINE_PARAMETER_F); bool isValidIntakeAirTemperature(float temperature); -float convertResistanceToKelvinTemperature(float resistance, - thermistor_curve_s * curve); void setThermistorConfiguration(ThermistorConf * tc, float temp1, float r1, float temp2, float r2, float temp3, float r3); void prepareThermistorCurve(ThermistorConf * config, thermistor_curve_s * curve); diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 3625e60e29..eccef58a27 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -367,14 +367,14 @@ static void setOM(int value) { static char pinNameBuffer[16]; -static void printThermistor(const char *msg, Thermistor *thermistor, thermistor_curve_s * curve) { - adc_channel_e adcChannel = thermistor->channel; +static void printThermistor(const char *msg, ThermistorConf *config, thermistor_curve_s * curve) { + adc_channel_e adcChannel = config->adcChannel; float voltage = getVoltageDivided("term", adcChannel); - float r = getResistance(thermistor); + float r = getResistance(config); - float t = getTemperatureC(thermistor, curve); + float t = getTemperatureC(config, curve); - thermistor_conf_s *tc = &thermistor->config->config; + thermistor_conf_s *tc = &config->config; scheduleMsg(&logger, "%s volts=%f Celsius=%f sensorR=%f on channel %d", msg, voltage, t, r, adcChannel); scheduleMsg(&logger, "@%s", getPinNameByAdcChannel(adcChannel, pinNameBuffer)); @@ -428,11 +428,11 @@ static void printTPSInfo(void) { static void printTemperatureInfo(void) { #if EFI_ANALOG_SENSORS || defined(__DOXYGEN__) - printThermistor("CLT", &engine->clt, &engine->engineState.cltCurve.curve); + printThermistor("CLT", &engineConfiguration->clt, &engine->engineState.cltCurve.curve); if (!isValidCoolantTemperature(getCoolantTemperature(PASS_ENGINE_PARAMETER_F))) { scheduleMsg(&logger, "CLT sensing error"); } - printThermistor("IAT", &engine->iat, &engine->engineState.iatCurve.curve); + printThermistor("IAT", &engineConfiguration->iat, &engine->engineState.iatCurve.curve); if (!isValidIntakeAirTemperature(getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F))) { scheduleMsg(&logger, "IAT sensing error"); } @@ -731,10 +731,10 @@ static void setAnalogInputPin(const char *sensorStr, const char *pinName) { engineConfiguration->map.sensor.hwChannel = channel; scheduleMsg(&logger, "setting MAP to %s/%d", pinName, channel); } else if (strEqual("clt", sensorStr)) { - engineConfiguration->cltAdcChannel = channel; + engineConfiguration->clt.adcChannel = channel; scheduleMsg(&logger, "setting CLT to %s/%d", pinName, channel); } else if (strEqual("iat", sensorStr)) { - engineConfiguration->iatAdcChannel = channel; + engineConfiguration->iat.adcChannel = channel; scheduleMsg(&logger, "setting IAT to %s/%d", pinName, channel); } else if (strEqual("tps", sensorStr)) { engineConfiguration->tpsAdcChannel = channel; diff --git a/firmware/hw_layer/adc_inputs.cpp b/firmware/hw_layer/adc_inputs.cpp index 4258340354..e17ac2d452 100644 --- a/firmware/hw_layer/adc_inputs.cpp +++ b/firmware/hw_layer/adc_inputs.cpp @@ -492,8 +492,8 @@ static void configureInputs(void) { addChannel("hip", engineConfiguration->hipOutputChannel, ADC_FAST); addChannel("VBatt", engineConfiguration->vbattAdcChannel, ADC_SLOW); - addChannel("CLT", engineConfiguration->cltAdcChannel, ADC_SLOW); - addChannel("IAT", engineConfiguration->iatAdcChannel, ADC_SLOW); + addChannel("CLT", engineConfiguration->clt.adcChannel, ADC_SLOW); + addChannel("IAT", engineConfiguration->iat.adcChannel, ADC_SLOW); addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW); addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW); } diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 0bc78b2426..4b559e570d 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -20,7 +20,7 @@ struct_no_prefix engine_configuration_s ! ! this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version ! -#define TS_FILE_VERSION 20150506 +#define TS_FILE_VERSION 20150522 #define MAP_ANGLE_SIZE 8 @@ -119,7 +119,7 @@ end_struct struct ThermistorConf @brief Thermistor curve parameters thermistor_conf_s config; - float[3] unused; + adc_channel_e adcChannel; end_struct custom engine_type_e 4 bits, S32, @OFFSET@, [0:2], "AUDI_AAN", "DODGE_NEON_1995", "FORD_ASPIRE_1996", "FORD_FIESTA", "NISSAN_PRIMERA", "HONDA_ACCORD", "FORD_INLINE_6_1995", "GY6_139QMB" @@ -158,6 +158,9 @@ MAP_sensor_config_s map;@see hasMapSensor\n@see isMapAveragingEnabled ThermistorConf clt;todo: merge with channel settings, use full-scale Thermistor here! ThermistorConf iat; + + float[4] unused; + float[DWELL_CURVE_SIZE] sparkDwellBins;;"RPM", 1, 0.0, 0.0, 18000, 2 float[DWELL_CURVE_SIZE] sparkDwell;;"ms", 1, 0.0, 0.0, 30.0, 2 @@ -269,8 +272,8 @@ custom spi_device_e 4 bits,U32, @OFFSET@, [0:1], "Off", "SPI1", "SPI2", "SPI3" float globalFuelCorrection;;"coef", 1, 0.0, 0, 1000.0, 2 - adc_channel_e cltAdcChannel;todo: merge with channel settings, use full-scale Thermistor! - adc_channel_e iatAdcChannel; + int unused11; + int unused12; adc_channel_e mafAdcChannel; struct afr_sensor_s diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 73f731542d..8c19275dbc 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -40,7 +40,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated by ConfigDefinition.jar on Fri May 22 14:07:20 EDT 2015 +; this section was generated by ConfigDefinition.jar on Fri May 22 22:10:51 EDT 2015 pageSize = 15288 page = 1 @@ -76,15 +76,16 @@ page = 1 clt_resistance_2 = scalar, F32, 272, "Ohm", 1, 0, 0, 200000, 1 clt_resistance_3 = scalar, F32, 276, "Ohm", 1, 0, 0, 200000, 1 clt_bias_resistor = scalar, F32, 280, "Ohm", 1, 0, 0, 200000, 1 -;skipping clt_unused offset 284 - iat_tempC_1 = scalar, F32, 296, "*C", 1, 0, -40, 200, 1 - iat_tempC_2 = scalar, F32, 300, "*C", 1, 0, -40, 200, 1 - iat_tempC_3 = scalar, F32, 304, "*C", 1, 0, -40, 200, 1 - iat_resistance_1 = scalar, F32, 308, "Ohm", 1, 0, 0, 200000, 1 - iat_resistance_2 = scalar, F32, 312, "Ohm", 1, 0, 0, 200000, 1 - iat_resistance_3 = scalar, F32, 316, "Ohm", 1, 0, 0, 200000, 1 - iat_bias_resistor = scalar, F32, 320, "Ohm", 1, 0, 0, 200000, 1 -;skipping iat_unused offset 324 + clt_adcChannel = bits, U32, 284, [0:3] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5" + iat_tempC_1 = scalar, F32, 288, "*C", 1, 0, -40, 200, 1 + iat_tempC_2 = scalar, F32, 292, "*C", 1, 0, -40, 200, 1 + iat_tempC_3 = scalar, F32, 296, "*C", 1, 0, -40, 200, 1 + iat_resistance_1 = scalar, F32, 300, "Ohm", 1, 0, 0, 200000, 1 + iat_resistance_2 = scalar, F32, 304, "Ohm", 1, 0, 0, 200000, 1 + iat_resistance_3 = scalar, F32, 308, "Ohm", 1, 0, 0, 200000, 1 + iat_bias_resistor = scalar, F32, 312, "Ohm", 1, 0, 0, 200000, 1 + iat_adcChannel = bits, U32, 316, [0:3] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5" +;skipping unused offset 320 sparkDwellBins = array, F32, 336, [8], "RPM", 1, 0.0, 0.0, 18000, 2 sparkDwell = array, F32, 368, [8], "ms", 1, 0.0, 0.0, 30.0, 2 displacement = scalar, F32, 400, "L", 1, 0, 0, 1000.0, 2 @@ -131,8 +132,8 @@ page = 1 trigger_customUseRiseEdge = bits, U32, 560, [0:0], "false", "true" hip9011SpiDevice = bits,U32, 564, [0:1], "Off", "SPI1", "SPI2", "SPI3" globalFuelCorrection = scalar, F32, 568, "coef", 1, 0.0, 0, 1000.0, 2 - cltAdcChannel = bits, U32, 572, [0:3] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5" - iatAdcChannel = bits, U32, 576, [0:3] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5" +;skipping unused11 offset 572 +;skipping unused12 offset 576 mafAdcChannel = bits, U32, 580, [0:3] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5" afr_hwChannel = bits, U32, 584, [0:3] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5" afr_v1 = scalar, F32, 588, "volts", 1, 0.0, 0, 10.0, 2 @@ -543,7 +544,7 @@ page = 1 [OutputChannels] ; see TS_FILE_VERSION in firmware code -fileVersion = { 20150506 } +fileVersion = { 20150522 } ochGetCommand = "O" @@ -1050,7 +1051,7 @@ fileVersion = { 20150506 } field = "Highest temperature", clt_tempC_3 field = "Resistance @ HT", clt_resistance_3 dialog = cltSensor_IO, "CLT Sensor I/O" - field = "CLT ADC input", cltAdcChannel + field = "CLT ADC input", clt_adcChannel field = "Bias Resistor Value", clt_bias_resistor dialog = cltSensor, "", yAxis panel = clt_thermistor, North @@ -1070,7 +1071,7 @@ fileVersion = { 20150506 } field = "Highest temperature", iat_tempC_3 field = "Resistance @ HT", iat_resistance_3 dialog = iatSensor_IO, "IAT Sensor I/O" - field = "IAT ADC input", iatAdcChannel + field = "IAT ADC input", iat_adcChannel field = "Bias Resistor Value", iat_bias_resistor dialog = iatSensor, "", yAxis panel = iat_thermistor, North diff --git a/unit_tests/test_sensors.cpp b/unit_tests/test_sensors.cpp index 227b2c6f59..14c1fbc902 100644 --- a/unit_tests/test_sensors.cpp +++ b/unit_tests/test_sensors.cpp @@ -1,5 +1,5 @@ /** - * @file test_sensors.c + * @file test_sensors.cpp * * @date Dec 7, 2013 * @author Andrey Belomutskiy, (c) 2012-2015 @@ -97,7 +97,7 @@ void testSensors(void) { assertEquals(0.001, curve->s_h_b); assertEquals(0.0, curve->s_h_c); - float t = convertResistanceToKelvinTemperature(2100, curve); + float t = getKelvinTemperature(2100, curve); assertEquals(75 + KELV, t); } @@ -110,7 +110,7 @@ void testSensors(void) { assertEqualsM("A", 0.0009, curve->s_h_a); assertEqualsM("B", 0.0003, curve->s_h_b); assertEquals(0.0, curve->s_h_c); - float t = convertResistanceToKelvinTemperature(38000, curve); + float t = getKelvinTemperature(38000, curve); assertEquals(-2.7983, t - KELV); } } diff --git a/win32_functional_tests/simulator/boards.cpp b/win32_functional_tests/simulator/boards.cpp index 15c2898206..04aaf597a8 100644 --- a/win32_functional_tests/simulator/boards.cpp +++ b/win32_functional_tests/simulator/boards.cpp @@ -25,11 +25,11 @@ static void setVoltage(int hwChannel, float voltage) { } static void setCltVoltage(float voltage) { - setVoltage(engineConfiguration->cltAdcChannel, voltage); + setVoltage(engineConfiguration->clt.adcChannel, voltage); } static void setIatVoltage(float voltage) { - setVoltage(engineConfiguration->iatAdcChannel, voltage); + setVoltage(engineConfiguration->iat.adcChannel, voltage); } static void setMafVoltage(float voltage) {