This commit is contained in:
rusefi 2019-02-01 21:24:07 -05:00
parent 3e953d5131
commit a9d39f760d
3 changed files with 15 additions and 14 deletions

View File

@ -772,5 +772,5 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0) if (initBootloader() != 0)
return 123; return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */ #endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20190130; return 20190131;
} }

View File

@ -35,5 +35,7 @@
#endif /* EFI_UNIT_TEST */ #endif /* EFI_UNIT_TEST */
#define get_operationMode CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(operationMode) #define get_operationMode CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(operationMode)
#define get_specs_displacement CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(specs.displacement)
#define get_injector_flow CONFIG_ACCESS_FOR_CONFIG_HEADER_ONLY(injector.flow)
#endif /* CONTROLLERS_MATH_CONFIG_ENGINE_SPECS_H_ */ #endif /* CONTROLLERS_MATH_CONFIG_ENGINE_SPECS_H_ */

View File

@ -14,6 +14,7 @@
#include "engine.h" #include "engine.h"
#include "engine_math.h" #include "engine_math.h"
#include "maf2map.h" #include "maf2map.h"
#include "config_engine_specs.h"
#define rpmMin 500 #define rpmMin 500
#define rpmMax 8000 #define rpmMax 8000
@ -82,27 +83,25 @@ float getTCharge(int rpm, float tps, float coolantTemp, float airTemp DECLARE_EN
/** /**
* @return air mass in grams * @return air mass in grams
*/ */
static float getCycleAirMass(float volumetricEfficiency, float MAP, float tempK DECLARE_ENGINE_PARAMETER_SUFFIX) { static float getCycleAirMass(float volumetricEfficiency, float MAP, float tempK DECLARE_GLOBAL_SUFFIX) {
// todo: pre-calculate cylinder displacement to save one division return (get_specs_displacement * volumetricEfficiency * MAP) / (GAS_R * tempK);
float cylinderDisplacement = CONFIG(specs.displacement);
return (cylinderDisplacement * volumetricEfficiency * MAP) / (GAS_R * tempK);
} }
float getCylinderAirMass(float volumetricEfficiency, float MAP, float tempK DECLARE_ENGINE_PARAMETER_SUFFIX) { float getCylinderAirMass(float volumetricEfficiency, float MAP, float tempK DECLARE_GLOBAL_SUFFIX) {
return getCycleAirMass(volumetricEfficiency, MAP, tempK PASS_ENGINE_PARAMETER_SUFFIX) return getCycleAirMass(volumetricEfficiency, MAP, tempK PASS_GLOBAL_SUFFIX)
/ CONFIG(specs.cylindersCount); / get_specs_displacement;
} }
/** /**
* @return per cylinder injection time, in seconds * @return per cylinder injection time, in seconds
*/ */
float sdMath(float airMass, float AFR DECLARE_ENGINE_PARAMETER_SUFFIX) { float sdMath(float airMass, float AFR DECLARE_GLOBAL_SUFFIX) {
/** /**
* todo: pre-calculate gramm/second injector flow to save one multiplication * todo: pre-calculate gramm/second injector flow to save one multiplication
* open question if that's needed since that's just a multiplication * open question if that's needed since that's just a multiplication
*/ */
float injectorFlowRate = cc_minute_to_gramm_second(CONFIG(injector.flow)); float injectorFlowRate = cc_minute_to_gramm_second(get_injector_flow);
/** /**
* injection_pulse_duration = fuel_mass / injector_flow * injection_pulse_duration = fuel_mass / injector_flow
* fuel_mass = air_mass / target_afr * fuel_mass = air_mass / target_afr
@ -117,7 +116,7 @@ EXTERN_ENGINE;
/** /**
* @return per cylinder injection time, in Milliseconds * @return per cylinder injection time, in Milliseconds
*/ */
floatms_t getSpeedDensityFuel(float map DECLARE_ENGINE_PARAMETER_SUFFIX) { floatms_t getSpeedDensityFuel(float map DECLARE_GLOBAL_SUFFIX) {
/** /**
* most of the values are pre-calculated for performance reasons * most of the values are pre-calculated for performance reasons
*/ */
@ -128,10 +127,10 @@ floatms_t getSpeedDensityFuel(float map DECLARE_ENGINE_PARAMETER_SUFFIX) {
} }
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(map), "NaN map", 0); efiAssert(CUSTOM_ERR_ASSERT, !cisnan(map), "NaN map", 0);
float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE); float adjustedMap = map + engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_GLOBAL_SIGNATURE);
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", 0); efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", 0);
float airMass = getCylinderAirMass(ENGINE(engineState.currentVE), adjustedMap, tChargeK PASS_ENGINE_PARAMETER_SUFFIX); float airMass = getCylinderAirMass(ENGINE(engineState.currentVE), adjustedMap, tChargeK PASS_GLOBAL_SUFFIX);
if (cisnan(airMass)) { if (cisnan(airMass)) {
warning(CUSTOM_ERR_6685, "NaN airMass"); warning(CUSTOM_ERR_6685, "NaN airMass");
return 0; return 0;
@ -142,7 +141,7 @@ floatms_t getSpeedDensityFuel(float map DECLARE_ENGINE_PARAMETER_SUFFIX) {
#endif /*EFI_PRINTF_FUEL_DETAILS */ #endif /*EFI_PRINTF_FUEL_DETAILS */
engine->engineState.airMass = airMass; engine->engineState.airMass = airMass;
return sdMath(airMass, ENGINE(engineState.targetAFR) PASS_ENGINE_PARAMETER_SUFFIX) * 1000; return sdMath(airMass, ENGINE(engineState.targetAFR) PASS_GLOBAL_SUFFIX) * 1000;
} }
static const baro_corr_table_t default_baro_corr = { static const baro_corr_table_t default_baro_corr = {