Implement postCrankingFuelCorrection (#485)

This commit is contained in:
andreika-git 2017-11-03 00:10:42 +02:00 committed by rusefi
parent bd2894f198
commit d4974a783d
2 changed files with 16 additions and 1 deletions

View File

@ -193,6 +193,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
efitick_t nowNt = getTimeNowNt(); efitick_t nowNt = getTimeNowNt();
if (ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) { if (ENGINE(rpmCalculator).isCranking(PASS_ENGINE_PARAMETER_SIGNATURE)) {
crankingTime = nowNt; crankingTime = nowNt;
timeSinceCranking = 0.0f;
} else { } else {
timeSinceCranking = nowNt - crankingTime; timeSinceCranking = nowNt - crankingTime;
} }
@ -223,6 +224,18 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
cltFuelCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); cltFuelCorrection = getCltFuelCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
} }
// post-cranking fuel enrichment.
// for compatibility reasons, apply only if the factor is greater than zero (0.01 margin used)
if (engineConfiguration->postCrankingFactor > 0.01f) {
// convert to microsecs and then to seconds
float timeSinceCrankingInSecs = NT2US(timeSinceCranking) / 1000000.0f;
// use interpolation for correction taper
postCrankingFuelCorrection = interpolateClamped(0.0f, engineConfiguration->postCrankingFactor,
engineConfiguration->postCrankingDurationSec, 1.0f, timeSinceCrankingInSecs);
} else {
postCrankingFuelCorrection = 1.0f;
}
cltTimingCorrection = getCltTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); cltTimingCorrection = getCltTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE);
engineNoiseHipLevel = interpolate2d("knock", rpm, engineConfiguration->knockNoiseRpmBins, engineNoiseHipLevel = interpolate2d("knock", rpm, engineConfiguration->knockNoiseRpmBins,

View File

@ -164,10 +164,12 @@ floatms_t getInjectionDuration(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) {
floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) { floatms_t getRunningFuel(floatms_t baseFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
float iatCorrection = ENGINE(engineState.iatFuelCorrection); float iatCorrection = ENGINE(engineState.iatFuelCorrection);
float cltCorrection = ENGINE(engineState.cltFuelCorrection); float cltCorrection = ENGINE(engineState.cltFuelCorrection);
float postCrankingFuelCorrection = ENGINE(engineState.postCrankingFuelCorrection);
efiAssert(!cisnan(iatCorrection), "NaN iatCorrection", 0); efiAssert(!cisnan(iatCorrection), "NaN iatCorrection", 0);
efiAssert(!cisnan(cltCorrection), "NaN cltCorrection", 0); efiAssert(!cisnan(cltCorrection), "NaN cltCorrection", 0);
efiAssert(!cisnan(postCrankingFuelCorrection), "NaN postCrankingFuelCorrection", 0);
floatms_t runningFuel = baseFuel * iatCorrection * cltCorrection + ENGINE(engineState.fuelPidCorrection); floatms_t runningFuel = baseFuel * iatCorrection * cltCorrection * postCrankingFuelCorrection + ENGINE(engineState.fuelPidCorrection);
efiAssert(!cisnan(runningFuel), "NaN runningFuel", 0); efiAssert(!cisnan(runningFuel), "NaN runningFuel", 0);
ENGINE(engineState.runningFuel) = runningFuel; ENGINE(engineState.runningFuel) = runningFuel;