From 4de51c948452f714883f4582a5d491613cde3f60 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Mon, 2 Feb 2015 11:05:12 -0600 Subject: [PATCH] auto-sync --- firmware/config/engines/acura_rsx.cpp | 2 +- .../config/engines/citroenBerlingoTU3JP.cpp | 4 +- firmware/config/engines/dodge_neon.cpp | 4 +- firmware/config/engines/ford_aspire.cpp | 4 +- firmware/config/engines/honda_accord.cpp | 4 +- firmware/config/engines/mazda_323.cpp | 2 +- firmware/config/engines/mazda_miata.cpp | 6 +- firmware/config/engines/mitsubishi.cpp | 2 +- firmware/config/engines/rover_v8.cpp | 2 +- firmware/config/engines/sachs.cpp | 2 +- .../tunerstudio/tunerstudio_configuration.h | 2 +- .../controllers/algo/engine_configuration.cpp | 6 +- ...ngine_configuration_generated_structures.h | 280 +++++++++--------- firmware/controllers/algo/fuel_math.cpp | 4 +- firmware/controllers/math/speed_density.cpp | 4 +- firmware/controllers/settings.cpp | 2 +- firmware/rusefi_config.ini | 31 +- unit_tests/test_fuel_map.cpp | 4 +- unit_tests/test_speed_density.cpp | 4 +- unit_tests/test_trigger_decoder.cpp | 2 +- 20 files changed, 199 insertions(+), 172 deletions(-) diff --git a/firmware/config/engines/acura_rsx.cpp b/firmware/config/engines/acura_rsx.cpp index e7d6eebc56..c1daff47c7 100644 --- a/firmware/config/engines/acura_rsx.cpp +++ b/firmware/config/engines/acura_rsx.cpp @@ -13,7 +13,7 @@ void setAcuraRSX(engine_configuration_s *engineConfiguration) { // http://injectordynamics.com/injectors/id1300-2/ - engineConfiguration->injectorFlow = 1300; + engineConfiguration->injector.flow = 1300; engineConfiguration->cylindersCount = 4; } diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index 90387074ef..9336aa93a6 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -64,7 +64,7 @@ void setCitroenBerlingoTU3JPConfiguration(engine_configuration_s *engineConfigur engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_60_2; engineConfiguration->globalTriggerAngleOffset = 114; engineConfiguration->cylindersCount = 4; - engineConfiguration->displacement = 1.360; + engineConfiguration->specs.displacement = 1.360; engineConfiguration->firingOrder = FO_1_THEN_3_THEN_4_THEN2; engineConfiguration->ignitionMode = IM_WASTED_SPARK; engineConfiguration->injectionMode = IM_BATCH; @@ -104,7 +104,7 @@ void setCitroenBerlingoTU3JPConfiguration(engine_configuration_s *engineConfigur // Frankenstein lo-side output #11: PB8 // Frankenstein lo-side output #12: PB9 Fuel pump - engineConfiguration->injectorFlow = 137; //SIEMENS DEKA VAZ20734 + engineConfiguration->injector.flow = 137; //SIEMENS DEKA VAZ20734 boardConfiguration->injectionPins[0] = GPIOE_6; boardConfiguration->injectionPins[1] = GPIOC_13; boardConfiguration->injectionPins[2] = GPIO_UNASSIGNED; diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index af2dcadb4b..d6aa519c33 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -194,7 +194,7 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat engineConfiguration->crankingInjectionMode = IM_SIMULTANEOUS; engineConfiguration->injectionMode = IM_SEQUENTIAL; engineConfiguration->ignitionMode = IM_WASTED_SPARK; - engineConfiguration->displacement = 1.996; + engineConfiguration->specs.displacement = 1.996; engineConfiguration->cylindersCount = 4; /** @@ -229,7 +229,7 @@ void setDodgeNeonNGCEngineConfiguration(engine_configuration_s *engineConfigurat * bosch 4G1139 * http://forum.2gn.org/viewtopic.php?t=21657 */ - engineConfiguration->injectorFlow = 199; + engineConfiguration->injector.flow = 199; // I want to start with a simple Alpha-N engineConfiguration->algorithm = LM_ALPHA_N; diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index 9e516a979c..e4b7e5972e 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -94,9 +94,9 @@ void setFordAspireEngineConfiguration(engine_configuration_s *engineConfiguratio // engineConfiguration->ignitionPinMode = OM_INVERTED; engineConfiguration->cylindersCount = 4; - engineConfiguration->displacement = 1.3; + engineConfiguration->specs.displacement = 1.3; // Denso 195500-2110 - engineConfiguration->injectorFlow = 119.8; + engineConfiguration->injector.flow = 119.8; engineConfiguration->firingOrder = FO_1_THEN_3_THEN_4_THEN2; engineConfiguration->globalTriggerAngleOffset = 175; diff --git a/firmware/config/engines/honda_accord.cpp b/firmware/config/engines/honda_accord.cpp index d28e7c4936..54069f813c 100644 --- a/firmware/config/engines/honda_accord.cpp +++ b/firmware/config/engines/honda_accord.cpp @@ -40,10 +40,10 @@ static void setHondaAccordConfigurationCommon(engine_configuration_s *engineConf engineConfiguration->HD44780height = 4; engineConfiguration->cylindersCount = 4; - engineConfiguration->displacement = 2.156; + engineConfiguration->specs.displacement = 2.156; // Keihin 06164-P0A-A00 - engineConfiguration->injectorFlow = 248; + engineConfiguration->injector.flow = 248; // engineConfiguration->algorithm = LM_SPEED_DENSITY; // I want to start with a simple Alpha-N diff --git a/firmware/config/engines/mazda_323.cpp b/firmware/config/engines/mazda_323.cpp index 0d76aacfa5..36a757f4f4 100644 --- a/firmware/config/engines/mazda_323.cpp +++ b/firmware/config/engines/mazda_323.cpp @@ -9,7 +9,7 @@ void setMazda323EngineConfiguration(engine_configuration_s *engineConfiguration) { engineConfiguration->cylindersCount = 4; - engineConfiguration->displacement = 1.6; + engineConfiguration->specs.displacement = 1.6; engineConfiguration->ignitionMode = IM_ONE_COIL; diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index 9e6ab5d7b5..bc8d538aec 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -236,7 +236,7 @@ void setFordEscortGt(engine_configuration_s *engineConfiguration) { setFrankenso_01_LCD(boardConfiguration); setFrankenso0_1_joystick(engineConfiguration); - engineConfiguration->displacement = 1.839; + engineConfiguration->specs.displacement = 1.839; engineConfiguration->algorithm = LM_MAF; boardConfiguration->tunerStudioSerialSpeed = 9600; @@ -332,7 +332,7 @@ void setFordEscortGt(engine_configuration_s *engineConfiguration) { static void setMiata1994_common(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { commonMiataNa(engineConfiguration, boardConfiguration); - engineConfiguration->displacement = 1.839; + engineConfiguration->specs.displacement = 1.839; // set_cranking_timing_angle 0 engineConfiguration->crankingTimingAngle = 0; @@ -463,7 +463,7 @@ void setMiata1994_s(engine_configuration_s *engineConfiguration, board_configura */ void setMiata1996(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { commonMiataNa(engineConfiguration, boardConfiguration); - engineConfiguration->displacement = 1.839; + engineConfiguration->specs.displacement = 1.839; copyFuelTable(miata_maf_fuel_table, engineConfiguration->fuelTable); copyTimingTable(miata_maf_advance_table, engineConfiguration->ignitionTable); diff --git a/firmware/config/engines/mitsubishi.cpp b/firmware/config/engines/mitsubishi.cpp index 7ca683d64d..b97108142e 100644 --- a/firmware/config/engines/mitsubishi.cpp +++ b/firmware/config/engines/mitsubishi.cpp @@ -19,7 +19,7 @@ void setMitsubishiConfiguration(engine_configuration_s *engineConfiguration, boa engineConfiguration->trigger.type = TT_MITSU; engineConfiguration->cylindersCount = 4; - engineConfiguration->displacement = 1.800; + engineConfiguration->specs.displacement = 1.800; // set_ignition_mode 2 engineConfiguration->ignitionMode = IM_WASTED_SPARK; diff --git a/firmware/config/engines/rover_v8.cpp b/firmware/config/engines/rover_v8.cpp index d3dee5afdc..279c5e5402 100644 --- a/firmware/config/engines/rover_v8.cpp +++ b/firmware/config/engines/rover_v8.cpp @@ -28,7 +28,7 @@ void setRoverv8(engine_configuration_s *engineConfiguration, board_configuration setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->trigger.type = TT_TOOTHED_WHEEL_36_1; - engineConfiguration->displacement = 3.528; + engineConfiguration->specs.displacement = 3.528; engineConfiguration->cylindersCount = 8; engineConfiguration->firingOrder = FO_1_8_4_3_6_5_7_2; diff --git a/firmware/config/engines/sachs.cpp b/firmware/config/engines/sachs.cpp index 62e4f9acb2..92c276484f 100644 --- a/firmware/config/engines/sachs.cpp +++ b/firmware/config/engines/sachs.cpp @@ -12,7 +12,7 @@ #include "allsensors.h" void setSachs(engine_configuration_s *engineConfiguration) { - engineConfiguration->displacement = 0.1; // 100cc + engineConfiguration->specs.displacement = 0.1; // 100cc engineConfiguration->cylindersCount = 1; engineConfiguration->engineCycle = 360; diff --git a/firmware/console/tunerstudio/tunerstudio_configuration.h b/firmware/console/tunerstudio/tunerstudio_configuration.h index ea11b46aae..09d4eae6b6 100644 --- a/firmware/console/tunerstudio/tunerstudio_configuration.h +++ b/firmware/console/tunerstudio/tunerstudio_configuration.h @@ -14,7 +14,7 @@ /** * this is used to confirm that firmware and TunerStudio are using the same rusefi.ini version */ -#define TS_FILE_VERSION 20150127 +#define TS_FILE_VERSION 20150202 #define PAGE_0_SIZE 11832 #define TS_OUTPUT_SIZE 116 diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 9081380bb6..dc310605e0 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -138,7 +138,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ setDetaultVETable(engineConfiguration); - engineConfiguration->injectorLag = 1.0; + engineConfiguration->injector.lag = 1.0; engineConfiguration->acCutoffLowRpm = 700; engineConfiguration->acCutoffHighRpm = 5000; @@ -279,11 +279,11 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR); engineConfiguration->cylindersCount = 4; - engineConfiguration->displacement = 2; + engineConfiguration->specs.displacement = 2; /** * By the way http://users.erols.com/srweiss/tableifc.htm has a LOT of data */ - engineConfiguration->injectorFlow = 200; + engineConfiguration->injector.flow = 200; engineConfiguration->displayMode = DM_HD44780; diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 310b474659..d471aa8bff 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 Mon Feb 02 10:48:00 EST 2015 +// this section was generated by config_definition.jar on Mon Feb 02 11:45:00 EST 2015 // begin #include "rusefi_types.h" typedef struct { @@ -121,6 +121,32 @@ typedef struct { /** total size 40*/ } ThermistorConf; +typedef struct { + /** + * cc/min, cubic centimeter per minute + * By the way, g/s = 0.125997881 * (lb/hr) + * g/s = 0.125997881 * (cc/min)/10.5 + * g/s = 0.0119997981 * cc/min + * offset 0 + */ + float flow; + /** + * offset 4 + */ + float lag; + /** total size 8*/ +} injector_s; + +typedef struct { + /** + * Engine displacement, in liters + * see also cylindersCount + * offset 0 + */ + float displacement; + /** total size 4*/ +} specs_s; + /** * @brief Trigger wheel(s) configuration @@ -561,450 +587,440 @@ typedef struct { /** * offset 8 */ + injector_s injector; + /** + * offset 16 + */ float battInjectorLagCorrBins[VBAT_INJECTOR_CURVE_SIZE]; /** - * offset 40 + * offset 48 */ float battInjectorLagCorr[VBAT_INJECTOR_CURVE_SIZE]; /** - * offset 72 + * offset 80 */ float cltFuelCorrBins[CLT_CURVE_SIZE]; /** - * offset 136 + * offset 144 */ float cltFuelCorr[CLT_CURVE_SIZE]; /** - * offset 200 + * offset 208 */ float iatFuelCorrBins[IAT_CURVE_SIZE]; /** - * offset 264 + * offset 272 */ float iatFuelCorr[IAT_CURVE_SIZE]; /** * Should the trigger emulator push data right into trigger input, eliminating the need for physical jumper wires? * PS: Funny name, right? :) * todo: make this a bit on some bit field - * offset 328 + * offset 336 */ int16_t directSelfStimulation; /** * todo: extract these two fields into a structure * todo: we need two sets of TPS parameters - modern ETBs have to sensors - * offset 330 + * offset 338 */ int16_t tpsMin; /** * tpsMax value as 10 bit ADC value. Not Voltage! - * offset 332 + * offset 340 */ int16_t tpsMax; /** - * offset 334 + * offset 342 */ uint16_t unused334; /** * todo: finish implementation. These values are used for TPS disconnect detection - * offset 336 + * offset 344 */ int16_t tpsErrorLowValue; /** - * offset 338 + * offset 346 */ int16_t tpsErrorHighValue; /** - * offset 340 + * offset 348 */ float primingSquirtDurationMs; /** * 360 for two-stroke * 720 for four-stroke - * offset 344 + * offset 352 */ int engineCycle; /** - * offset 348 + * offset 356 */ cranking_parameters_s cranking; /** * @see hasMapSensor * @see isMapAveragingEnabled - * offset 356 + * offset 364 */ MAP_sensor_config_s map; /** * todo: merge with channel settings, use full-scale Thermistor here! - * offset 500 + * offset 508 */ ThermistorConf clt; /** - * offset 540 + * offset 548 */ ThermistorConf iat; /** - * offset 580 + * offset 588 */ float sparkDwellBins[DWELL_COUNT]; /** - * offset 612 + * offset 620 */ float sparkDwell[DWELL_COUNT]; /** - * offset 644 + * offset 652 */ float ignitionLoadBins[IGN_LOAD_COUNT]; /** - * offset 708 + * offset 716 */ float ignitionRpmBins[IGN_RPM_COUNT]; /** * this value could be used to offset the whole ignition timing table by a constant - * offset 772 + * offset 780 */ float ignitionBaseAngle; /** * While cranking (which causes battery voltage to drop) we can calculate dwell time in shaft * degrees, not in absolute time as in running mode. - * offset 776 + * offset 784 */ float crankingChargeAngle; /** - * offset 780 + * offset 788 */ timing_mode_e timingMode; /** * This value is used in 'fixed timing' mode, i.e. constant timing * This mode is useful for instance while adjusting distributor location - * offset 784 + * offset 792 */ float fixedModeTiming; /** - * offset 788 - */ - float injectorLag; - /** - * offset 792 + * offset 796 */ float fuelLoadBins[FUEL_LOAD_COUNT]; /** * RPM is float and not integer in order to use unified methods for interpolation - * offset 856 + * offset 860 */ float fuelRpmBins[FUEL_RPM_COUNT]; - /** - * Engine displacement, in liters - * see also cylindersCount - * offset 920 - */ - float displacement; /** * offset 924 */ - int rpmHardLimit; + specs_s specs; /** * offset 928 */ - injection_mode_e crankingInjectionMode; + cylinders_count_t cylindersCount; /** * offset 932 */ + firing_order_e firingOrder; + /** + * offset 936 + */ + int rpmHardLimit; + /** + * offset 940 + */ + injection_mode_e crankingInjectionMode; + /** + * offset 944 + */ injection_mode_e injectionMode; /** * This field is the angle between Top Dead Center (TDC) and the first trigger event. * Knowing this angle allows us to control timing and other angles in reference to TDC. - * offset 936 + * offset 948 */ float globalTriggerAngleOffset; /** * This parameter holds the coefficient of input voltage dividers - * offset 940 + * offset 952 */ float analogInputDividerCoefficient; /** * This setting controls which algorithm is used for ENGINE LOAD - * offset 944 + * offset 956 */ engine_load_mode_e algorithm; /** - * offset 948 + * offset 960 */ float vbattDividerCoeff; /** * Cooling fan turn-on temperature threshold, in Celsuis - * offset 952 + * offset 964 */ float fanOnTemperature; /** * Cooling fan turn-off temperature threshold, in Celsuis - * offset 956 + * offset 968 */ float fanOffTemperature; /** - * offset 960 + * offset 972 */ brain_pin_e vehicleSpeedSensorInputPin; /** * This coefficient translates vehicle speed input frequency (in Hz) into vehicle speed, km/h - * offset 964 + * offset 976 */ float vehicleSpeedCoef; /** - * offset 968 + * offset 980 */ can_nbc_e canNbcType; /** - * offset 972 + * offset 984 */ int canSleepPeriod; /** - * offset 976 - */ - cylinders_count_t cylindersCount; - /** - * offset 980 + * offset 988 */ ignition_mode_e ignitionMode; - /** - * offset 984 - */ - firing_order_e firingOrder; /** * todo: refactor this, see operation_mode_e - * offset 988 + * offset 992 */ float rpmMultiplier; /** - * offset 992 + * offset 996 */ display_mode_e displayMode; /** - * offset 996 + * offset 1000 */ log_format_e logFormat; /** - * offset 1000 + * offset 1004 */ int firmwareVersion; /** - * offset 1004 + * offset 1008 */ int HD44780width; /** - * offset 1008 + * offset 1012 */ int HD44780height; /** - * offset 1012 + * offset 1016 */ adc_channel_e tpsAdcChannel; /** - * offset 1016 + * offset 1020 */ int overrideCrankingIgnition; /** - * offset 1020 + * offset 1024 */ int analogChartFrequency; /** - * offset 1024 + * offset 1028 */ trigger_config_s trigger; /** - * offset 1052 + * offset 1056 */ spi_device_e hip9011SpiDevice; /** - * offset 1056 + * offset 1060 */ adc_channel_e vbattAdcChannel; /** - * offset 1060 + * offset 1064 */ float globalFuelCorrection; /** * todo: merge with channel settings, use full-scale Thermistor! - * offset 1064 + * offset 1068 */ adc_channel_e cltAdcChannel; /** - * offset 1068 + * offset 1072 */ adc_channel_e iatAdcChannel; /** - * offset 1072 + * offset 1076 */ adc_channel_e mafAdcChannel; /** * @see hasAfrSensor - * offset 1076 + * offset 1080 */ afr_sensor_s afr; /** * this is about deciding when the injector starts it's squirt - * offset 1096 + * offset 1100 */ float injectionAngle; /** - * offset 1100 + * offset 1104 */ float crankingTimingAngle; /** - * offset 1104 + * offset 1108 */ float diffLoadEnrichmentCoef; /** * @see hasBaroSensor - * offset 1108 + * offset 1112 */ air_pressure_sensor_config_s baroSensor; /** - * offset 1124 + * offset 1128 */ float veLoadBins[FUEL_LOAD_COUNT]; /** - * offset 1188 + * offset 1192 */ float veRpmBins[FUEL_RPM_COUNT]; /** - * offset 1252 + * offset 1256 */ float afrLoadBins[FUEL_LOAD_COUNT]; /** - * offset 1316 + * offset 1320 */ float afrRpmBins[FUEL_RPM_COUNT]; /** - * offset 1380 + * offset 1384 */ fuel_table_t fuelTable; /** - * offset 2404 + * offset 2408 */ ignition_table_t ignitionTable; /** - * offset 3428 + * offset 3432 */ ve_table_t veTable; /** - * offset 4452 + * offset 4456 */ afr_table_t afrTable; /** - * offset 5476 + * offset 5480 */ board_configuration_s bc; /** * @see isMapAveragingEnabled - offset 9480 bit 0 */ + offset 9484 bit 0 */ bool_t hasMapSensor : 1; /** - offset 9480 bit 1 */ + offset 9484 bit 1 */ bool_t hasIatSensor : 1; /** - offset 9480 bit 2 */ + offset 9484 bit 2 */ bool_t hasBaroSensor : 1; /** - offset 9480 bit 3 */ + offset 9484 bit 3 */ bool_t hasAfrSensor : 1; /** - offset 9480 bit 4 */ + offset 9484 bit 4 */ bool_t useConstantDwellDuringCranking : 1; /** - offset 9480 bit 5 */ + offset 9484 bit 5 */ bool_t isDigitalChartEnabled : 1; /** - offset 9480 bit 6 */ + offset 9484 bit 6 */ bool_t isCanEnabled : 1; /** - offset 9480 bit 7 */ + offset 9484 bit 7 */ bool_t hasCltSensor : 1; /** - offset 9480 bit 8 */ + offset 9484 bit 8 */ bool_t canReadEnabled : 1; /** - offset 9480 bit 9 */ + offset 9484 bit 9 */ bool_t canWriteEnabled : 1; /** - offset 9480 bit 10 */ + offset 9484 bit 10 */ bool_t hasVehicleSpeedSensor : 1; /** - offset 9480 bit 11 */ + offset 9484 bit 11 */ bool_t isJoystickEnabled : 1; /** - offset 9480 bit 12 */ + offset 9484 bit 12 */ bool_t isGpsEnabled : 1; /** - offset 9480 bit 13 */ + offset 9484 bit 13 */ bool_t hasMafSensor : 1; /** - offset 9480 bit 14 */ + offset 9484 bit 14 */ bool_t hasTpsSensor : 1; - /** - * offset 9484 - */ - adc_channel_e hipOutputChannel; /** * offset 9488 */ + adc_channel_e hipOutputChannel; + /** + * offset 9492 + */ idle_mode_e idleMode; /** - offset 9492 bit 0 */ + offset 9496 bit 0 */ bool_t isInjectionEnabled : 1; /** - offset 9492 bit 1 */ + offset 9496 bit 1 */ bool_t isIgnitionEnabled : 1; /** - offset 9492 bit 2 */ + offset 9496 bit 2 */ bool_t isCylinderCleanupEnabled : 1; /** - offset 9492 bit 3 */ + offset 9496 bit 3 */ bool_t secondTriggerChannelEnabled : 1; /** - offset 9492 bit 4 */ + offset 9496 bit 4 */ bool_t needSecondTriggerInput : 1; /** - offset 9492 bit 5 */ + offset 9496 bit 5 */ bool_t isMapAveragingEnabled : 1; /** - offset 9492 bit 6 */ + offset 9496 bit 6 */ bool_t isMilEnabled : 1; /** - offset 9492 bit 7 */ + offset 9496 bit 7 */ bool_t isFuelPumpEnabled : 1; /** - offset 9492 bit 8 */ + offset 9496 bit 8 */ bool_t isTunerStudioEnabled : 1; /** - offset 9492 bit 9 */ + offset 9496 bit 9 */ bool_t isWaveAnalyzerEnabled : 1; /** - offset 9492 bit 10 */ + offset 9496 bit 10 */ bool_t isIdleThreadEnabled : 1; /** - offset 9492 bit 11 */ + offset 9496 bit 11 */ bool_t isPrintTriggerSynchDetails : 1; /** * Usually if we have no trigger events that means engine is stopped * Unless we are troubleshooting and spinning the engine by hand - this case a longer * delay is needed - offset 9492 bit 12 */ + offset 9496 bit 12 */ bool_t isManualSpinningMode : 1; /** - offset 9492 bit 13 */ + offset 9496 bit 13 */ bool_t twoWireBatch : 1; /** - * offset 9496 - */ - uint32_t digitalChartSize; - /** - * cc/min, cubic centimeter per minute - * By the way, g/s = 0.125997881 * (lb/hr) - * g/s = 0.125997881 * (cc/min)/10.5 - * g/s = 0.0119997981 * cc/min * offset 9500 */ - float injectorFlow; + uint32_t digitalChartSize; /** * offset 9504 */ @@ -1112,4 +1128,4 @@ typedef struct { } engine_configuration_s; // end -// this section was generated by config_definition.jar on Mon Feb 02 10:48:00 EST 2015 +// this section was generated by config_definition.jar on Mon Feb 02 11:45:00 EST 2015 diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 35f286615c..c377cf320b 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -108,11 +108,11 @@ float getRunningFuel(float baseFuelMs, int rpm DECLARE_ENGINE_PARAMETER_S) { float getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_S) { if (cisnan(vBatt)) { warning(OBD_System_Voltage_Malfunction, "vBatt=%f", vBatt); - return engineConfiguration->injectorLag; + return engineConfiguration->injector.lag; } float vBattCorrection = interpolate2d(vBatt, engineConfiguration->battInjectorLagCorrBins, engineConfiguration->battInjectorLagCorr, VBAT_INJECTOR_CURVE_SIZE); - return engineConfiguration->injectorLag + vBattCorrection; + return engineConfiguration->injector.lag + vBattCorrection; } /** diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index 9c4ac97b8c..a39f129bb0 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -53,8 +53,8 @@ float sdMath(engine_configuration_s *engineConfiguration, float VE, float MAP, f return 0; } - float injectorFlowRate = cc_minute_to_gramm_second(engineConfiguration->injectorFlow); - float Vol = engineConfiguration->displacement / engineConfiguration->cylindersCount; + float injectorFlowRate = cc_minute_to_gramm_second(engineConfiguration->injector.flow); + float Vol = engineConfiguration->specs.displacement / engineConfiguration->cylindersCount; return (Vol * VE * MAP) / (AFR * injectorFlowRate * GAS_R * tempK); } diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 303bddd9ab..c12d1c1a17 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -858,7 +858,7 @@ static void printAllInfo(void) { } static void setInjectorLag(float value) { - engineConfiguration->injectorLag = value; + engineConfiguration->injector.lag = value; } void initSettings(engine_configuration_s *engineConfiguration) { diff --git a/firmware/rusefi_config.ini b/firmware/rusefi_config.ini index 4689d8d43d..b1cffbf8d4 100644 --- a/firmware/rusefi_config.ini +++ b/firmware/rusefi_config.ini @@ -94,6 +94,14 @@ engine_type_e engineType;http://rusefi.com/wiki/index.php?title=Manual:Engine_Ty int headerMagicValue;this magic number is used to make sure that what we read from Flash is in fact some configuration +struct injector_s + float flow;cc/min, cubic centimeter per minute\nBy the way, g/s = 0.125997881 * (lb/hr)\ng/s = 0.125997881 * (cc/min)/10.5\ng/s = 0.0119997981 * cc/min;"cm3/min", 1, 0, 0, 1000, 2 + float lag;;"msec", 1, 0, -10, 25.50, 2 +end_struct + +injector_s injector + + float[VBAT_INJECTOR_CURVE_SIZE] battInjectorLagCorrBins;;"V", 1, 0, 0.0, 20.0, 2 float[VBAT_INJECTOR_CURVE_SIZE] battInjectorLagCorr;;"ms/V", 1, 0, 0.0, 50.0, 2 @@ -140,14 +148,25 @@ custom timing_mode_e 4 bits, U32, @OFFSET@ [0:0], "dynamic", "fixed" timing_mode_e timingMode; float fixedModeTiming;This value is used in 'fixed timing' mode, i.e. constant timing\nThis mode is useful for instance while adjusting distributor location;"RPM", 1, 0, 0, 3000.0, 0 -float injectorLag;;"msec", 1, 0, -10, 25.50, 2 - float[FUEL_LOAD_COUNT] fuelLoadBins;;"V", 1, 0, 0.0, 300.0, 2 float[FUEL_RPM_COUNT] fuelRpmBins;RPM is float and not integer in order to use unified methods for interpolation;"RPM", 1, 0, 0.0, 25500.0, 2 + +struct_no_prefix specs_s float displacement;Engine displacement, in liters\nsee also cylindersCount;"L", 1, 0, 0, 1000.0, 2 +end_struct + + specs_s specs + +custom cylinders_count_t 4 bits, U32, @OFFSET@, [0:3], "INVALID", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, "INVALID", "INVALID", "INVALID" +cylinders_count_t cylindersCount; + +custom firing_order_e 4 bits, U32, @OFFSET@, [0:2], "One Cylinder", "1-3-4-2", "1-2-4-3", "1-3-2-4", "1-5-3-6-2-4", "1-8-4-3-6-5-7-2", "INVALID", "INVALID" +firing_order_e firingOrder; + + int rpmHardLimit;;"rpm", 1, 0, 0, 10000.0, 2 injection_mode_e crankingInjectionMode; @@ -170,15 +189,9 @@ can_nbc_e canNbcType; int canSleepPeriod;;"ms", 1, 0, 0, 1000.0, 2 -custom cylinders_count_t 4 bits, U32, @OFFSET@, [0:3], "INVALID", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, "INVALID", "INVALID", "INVALID" -cylinders_count_t cylindersCount; - custom ignition_mode_e 4 bits, U32, @OFFSET@, [0:1], "One coil", "Individual Coils", "Wasted", "INVALID" ignition_mode_e ignitionMode; -custom firing_order_e 4 bits, U32, @OFFSET@, [0:2], "One Cylinder", "1-3-4-2", "1-2-4-3", "1-3-2-4", "1-5-3-6-2-4", "1-8-4-3-6-5-7-2", "INVALID", "INVALID" -firing_order_e firingOrder; - float rpmMultiplier;todo: refactor this, see operation_mode_e custom display_mode_e 4 bits, U32, @OFFSET@, [0:1], "none", "hd44780", "hd44780 over pcf8574", "INVALID" @@ -429,12 +442,10 @@ bit hasMapSensor;@see isMapAveragingEnabled bit isPrintTriggerSynchDetails bit isManualSpinningMode;Usually if we have no trigger events that means engine is stopped\nUnless we are troubleshooting and spinning the engine by hand - this case a longer\ndelay is needed bit twoWireBatch - uint32_t digitalChartSize;;"count", 1, 0, 0, 300, 0 - float injectorFlow;cc/min, cubic centimeter per minute\nBy the way, g/s = 0.125997881 * (lb/hr)\ng/s = 0.125997881 * (cc/min)/10.5\ng/s = 0.0119997981 * cc/min;"cm3/min", 1, 0, 0, 1000, 2 float[CRANKING_CURVE_SIZE] crankingFuelCoef;;"%", 100, 0, 0.0, 700.0, 2 float[CRANKING_CURVE_SIZE] crankingFuelBins;;"C", 1, 0, -80.0, 170.0, 2 diff --git a/unit_tests/test_fuel_map.cpp b/unit_tests/test_fuel_map.cpp index 23110d9d72..84ba91b25d 100644 --- a/unit_tests/test_fuel_map.cpp +++ b/unit_tests/test_fuel_map.cpp @@ -46,7 +46,7 @@ void testFuelMap(void) { printf("*** getInjectorLag\r\n"); assertEquals(1.0, getInjectorLag(12 PASS_ENGINE_PARAMETER)); - eth.engine.engineConfiguration->injectorLag = 0.5; + eth.engine.engineConfiguration->injector.lag = 0.5; for (int i = 0; i < VBAT_INJECTOR_CURVE_SIZE; i++) { eth.engine.engineConfiguration->battInjectorLagCorrBins[i] = i; @@ -71,7 +71,7 @@ void testFuelMap(void) { eth.engine.engineConfiguration->cltFuelCorrBins[i] = i; eth.engine.engineConfiguration->cltFuelCorr[i] = 1; } - eth.engine.engineConfiguration->injectorLag = 0; + eth.engine.engineConfiguration->injector.lag = 0; assertEquals(NAN, getIntakeAirTemperature(ð.engine)); float iatCorrection = getIatCorrection(-KELV PASS_ENGINE_PARAMETER); diff --git a/unit_tests/test_speed_density.cpp b/unit_tests/test_speed_density.cpp index d5fb1f9332..8e5a71ade4 100644 --- a/unit_tests/test_speed_density.cpp +++ b/unit_tests/test_speed_density.cpp @@ -23,10 +23,10 @@ void testSpeedDensity(void) { assertEqualsM("RPM", 1500, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F)); // 427 cubic inches, that's a LOT of engine - eth.ec->displacement = 6.99728; + eth.ec->specs.displacement = 6.99728; eth.ec->cylindersCount = 8; - eth.ec->injectorFlow = gramm_second_to_cc_minute(5.303); + eth.ec->injector.flow = gramm_second_to_cc_minute(5.303); // 0.01414 sec or 14.14 ms assertEquals(0.01414, sdMath(eth.ec, 0.92, 98, 12.5, 293.16)); diff --git a/unit_tests/test_trigger_decoder.cpp b/unit_tests/test_trigger_decoder.cpp index 0cb8fecece..f9d064eca2 100644 --- a/unit_tests/test_trigger_decoder.cpp +++ b/unit_tests/test_trigger_decoder.cpp @@ -406,7 +406,7 @@ static void testRpmCalculator(void) { // this is a very dirty and sad hack. todo: eliminate // engine.engineConfiguration = eth.engine.engineConfiguration; - eth.engine.engineConfiguration->injectorLag = 0.0; + eth.engine.engineConfiguration->injector.lag = 0.0; timeNow = 0; assertEquals(0, eth.engine.rpmCalculator.rpm(PASS_ENGINE_PARAMETER_F));