fix wwae (#980)
This commit is contained in:
parent
88c8363f82
commit
10a6d6eb8b
|
@ -265,7 +265,7 @@ static const void * getStructAddr(int structId) {
|
||||||
case LDS_ENGINE_STATE_INDEX:
|
case LDS_ENGINE_STATE_INDEX:
|
||||||
return static_cast<engine_state2_s*>(&engine->engineState);
|
return static_cast<engine_state2_s*>(&engine->engineState);
|
||||||
case LDS_FUEL_TRIM_STATE_INDEX:
|
case LDS_FUEL_TRIM_STATE_INDEX:
|
||||||
return static_cast<wall_fuel_state*>(&engine->wallFuel);
|
return static_cast<wall_fuel_state*>(&engine->wallFuel[0]);
|
||||||
case LDS_TRIGGER_CENTRAL_STATE_INDEX:
|
case LDS_TRIGGER_CENTRAL_STATE_INDEX:
|
||||||
return static_cast<trigger_central_s*>(&engine->triggerCentral);
|
return static_cast<trigger_central_s*>(&engine->triggerCentral);
|
||||||
case LDS_TRIGGER_STATE_STATE_INDEX:
|
case LDS_TRIGGER_STATE_STATE_INDEX:
|
||||||
|
|
|
@ -324,8 +324,8 @@ static void printSensors(Logging *log) {
|
||||||
// 268
|
// 268
|
||||||
reportSensorF(log, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.running.pidCorrection), 2);
|
reportSensorF(log, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.running.pidCorrection), 2);
|
||||||
|
|
||||||
reportSensorF(log, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel).getWallFuel(0), 2);
|
reportSensorF(log, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel[0]).getWallFuel(), 2);
|
||||||
reportSensorF(log, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuel).wallFuelCorrection, 2);
|
reportSensorF(log, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuel[0]).wallFuelCorrection, 2);
|
||||||
|
|
||||||
reportSensorI(log, GAUGE_NAME_VERSION, "#", getRusEfiVersion());
|
reportSensorI(log, GAUGE_NAME_VERSION, "#", getRusEfiVersion());
|
||||||
|
|
||||||
|
@ -754,11 +754,11 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
||||||
// 148
|
// 148
|
||||||
tsOutputChannels->fuelTankLevel = engine->sensors.fuelTankLevel;
|
tsOutputChannels->fuelTankLevel = engine->sensors.fuelTankLevel;
|
||||||
// 160
|
// 160
|
||||||
tsOutputChannels->wallFuelAmount = ENGINE(wallFuel).getWallFuel(0);
|
tsOutputChannels->wallFuelAmount = ENGINE(wallFuel[0]).getWallFuel();
|
||||||
// 164
|
// 164
|
||||||
tsOutputChannels->iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient);
|
tsOutputChannels->iatCorrection = ENGINE(engineState.running.intakeTemperatureCoefficient);
|
||||||
// 168
|
// 168
|
||||||
tsOutputChannels->wallFuelCorrection = ENGINE(wallFuel).wallFuelCorrection;
|
tsOutputChannels->wallFuelCorrection = ENGINE(wallFuel[0]).wallFuelCorrection;
|
||||||
// 184
|
// 184
|
||||||
tsOutputChannels->cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient);
|
tsOutputChannels->cltCorrection = ENGINE(engineState.running.coolantTemperatureCoefficient);
|
||||||
// 188
|
// 188
|
||||||
|
|
|
@ -38,16 +38,12 @@ tps_tps_Map3D_t tpsTpsMap("tpsTps");
|
||||||
|
|
||||||
static Logging *logger = nullptr;
|
static Logging *logger = nullptr;
|
||||||
|
|
||||||
WallFuel::WallFuel() {
|
|
||||||
resetWF();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WallFuel::resetWF() {
|
void WallFuel::resetWF() {
|
||||||
wallFuel = 0;
|
wallFuel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
floatms_t WallFuel::adjust(floatms_t desiredFuel DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
invocationCounter++;
|
invocationCounter++;
|
||||||
if (cisnan(desiredFuel)) {
|
if (cisnan(desiredFuel)) {
|
||||||
return desiredFuel;
|
return desiredFuel;
|
||||||
|
@ -116,7 +112,7 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGI
|
||||||
beta = alpha;
|
beta = alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
float fuelFilmMass = wallFuel/*[injectorIndex]*/;
|
float fuelFilmMass = wallFuel;
|
||||||
float M_cmd = (desiredFuel - (1 - alpha) * fuelFilmMass) / (1 - beta);
|
float M_cmd = (desiredFuel - (1 - alpha) * fuelFilmMass) / (1 - beta);
|
||||||
|
|
||||||
// We can't inject a negative amount of fuel
|
// We can't inject a negative amount of fuel
|
||||||
|
@ -130,15 +126,15 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t desiredFuel DECLARE_ENGI
|
||||||
float fuelFilmMassNext = alpha * fuelFilmMass + beta * M_cmd;
|
float fuelFilmMassNext = alpha * fuelFilmMass + beta * M_cmd;
|
||||||
|
|
||||||
DISPLAY_TEXT(Current_Wall_Fuel_Film);
|
DISPLAY_TEXT(Current_Wall_Fuel_Film);
|
||||||
DISPLAY_FIELD(wallFuel)/*[injectorIndex]*/ = fuelFilmMassNext;
|
DISPLAY_FIELD(wallFuel) = fuelFilmMassNext;
|
||||||
DISPLAY_TEXT(Fuel correction);
|
DISPLAY_TEXT(Fuel correction);
|
||||||
DISPLAY_FIELD(wallFuelCorrection) = M_cmd - desiredFuel;
|
DISPLAY_FIELD(wallFuelCorrection) = M_cmd - desiredFuel;
|
||||||
DISPLAY_TEXT(ms);
|
DISPLAY_TEXT(ms);
|
||||||
return M_cmd;
|
return M_cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
floatms_t WallFuel::getWallFuel(int injectorIndex) const {
|
floatms_t WallFuel::getWallFuel() const {
|
||||||
return wallFuel/*[injectorIndex]*/;
|
return wallFuel;
|
||||||
}
|
}
|
||||||
|
|
||||||
int AccelEnrichment::getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
int AccelEnrichment::getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
|
@ -68,16 +68,14 @@ private:
|
||||||
*/
|
*/
|
||||||
class WallFuel : public wall_fuel_state {
|
class WallFuel : public wall_fuel_state {
|
||||||
public:
|
public:
|
||||||
WallFuel();
|
|
||||||
/**
|
/**
|
||||||
* @param target desired squirt duration
|
* @param target desired squirt duration
|
||||||
* @return total adjusted fuel squirt duration once wall wetting is taken into effect
|
* @return total adjusted fuel squirt duration once wall wetting is taken into effect
|
||||||
*/
|
*/
|
||||||
floatms_t adjust(int injectorIndex, floatms_t target DECLARE_ENGINE_PARAMETER_SUFFIX);
|
floatms_t adjust(floatms_t target DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
floatms_t getWallFuel(int injectorIndex) const;
|
floatms_t getWallFuel() const;
|
||||||
void resetWF();
|
void resetWF();
|
||||||
int invocationCounter = 0;
|
int invocationCounter = 0;
|
||||||
private:
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void initAccelEnrichment(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
void initAccelEnrichment(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
|
@ -94,7 +94,7 @@ public:
|
||||||
IgnitionEventList ignitionEvents;
|
IgnitionEventList ignitionEvents;
|
||||||
#endif /* EFI_ENGINE_CONTROL */
|
#endif /* EFI_ENGINE_CONTROL */
|
||||||
|
|
||||||
WallFuel wallFuel;
|
WallFuel wallFuel[INJECTION_PIN_COUNT];
|
||||||
bool needToStopEngine(efitick_t nowNt) const;
|
bool needToStopEngine(efitick_t nowNt) const;
|
||||||
bool etbAutoTune = false;
|
bool etbAutoTune = false;
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -287,7 +287,11 @@ efitimesec_t getTimeNowSeconds(void) {
|
||||||
static void resetAccel(void) {
|
static void resetAccel(void) {
|
||||||
engine->engineLoadAccelEnrichment.resetAE();
|
engine->engineLoadAccelEnrichment.resetAE();
|
||||||
engine->tpsAccelEnrichment.resetAE();
|
engine->tpsAccelEnrichment.resetAE();
|
||||||
engine->wallFuel.resetWF();
|
|
||||||
|
for (int i = 0; i < sizeof(engine->wallFuel) / sizeof(engine->wallFuel[0]); i++)
|
||||||
|
{
|
||||||
|
engine->wallFuel[i].resetWF();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int previousSecond;
|
static int previousSecond;
|
||||||
|
|
|
@ -209,7 +209,9 @@ static ALWAYS_INLINE void handleFuelInjectionEvent(int injEventIndex, InjectionE
|
||||||
* wetting coefficient works the same way for any injection mode, or is something
|
* wetting coefficient works the same way for any injection mode, or is something
|
||||||
* x2 or /2?
|
* x2 or /2?
|
||||||
*/
|
*/
|
||||||
const floatms_t injectionDuration = ENGINE(wallFuel).adjust(0/*event->outputs[0]->injectorIndex*/, ENGINE(injectionDuration) PASS_ENGINE_PARAMETER_SUFFIX);
|
|
||||||
|
size_t injectorIndex = event->outputs[0]->injectorIndex;
|
||||||
|
const floatms_t injectionDuration = ENGINE(wallFuel[injectorIndex]).adjust(ENGINE(injectionDuration) PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
#if EFI_PRINTF_FUEL_DETAILS
|
#if EFI_PRINTF_FUEL_DETAILS
|
||||||
printf("fuel injectionDuration=%.2f adjusted=%.2f\t\n", ENGINE(injectionDuration), injectionDuration);
|
printf("fuel injectionDuration=%.2f adjusted=%.2f\t\n", ENGINE(injectionDuration), injectionDuration);
|
||||||
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
#endif /*EFI_PRINTF_FUEL_DETAILS */
|
||||||
|
|
|
@ -20,8 +20,8 @@ TEST(fuel, testWallWettingEnrichmentMath) {
|
||||||
engine->rpmCalculator.setRpmValue(3000 PASS_ENGINE_PARAMETER_SUFFIX);
|
engine->rpmCalculator.setRpmValue(3000 PASS_ENGINE_PARAMETER_SUFFIX);
|
||||||
|
|
||||||
// each invocation of 'adjust' changes WallWetting internal state
|
// each invocation of 'adjust' changes WallWetting internal state
|
||||||
ASSERT_NEAR(16.6666, ENGINE(wallFuel).adjust(0, 10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
ASSERT_NEAR(16.6666, ENGINE(wallFuel[0]).adjust(10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
||||||
ASSERT_NEAR(16.198, ENGINE(wallFuel).adjust(0, 10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
ASSERT_NEAR(16.198, ENGINE(wallFuel[0]).adjust(10.0 PASS_ENGINE_PARAMETER_SUFFIX), EPS4D);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(fuel, testWallWettingEnrichmentScheduling) {
|
TEST(fuel, testWallWettingEnrichmentScheduling) {
|
||||||
|
@ -37,13 +37,24 @@ TEST(fuel, testWallWettingEnrichmentScheduling) {
|
||||||
eth.fireTriggerEvents2(/* count */ 5, 25 /* ms */);
|
eth.fireTriggerEvents2(/* count */ 5, 25 /* ms */);
|
||||||
ASSERT_EQ( 1200, GET_RPM()) << "RPM";
|
ASSERT_EQ( 1200, GET_RPM()) << "RPM";
|
||||||
|
|
||||||
int expectedInvocationCounter = 4;
|
int expectedInvocationCounter = 1;
|
||||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel).invocationCounter);
|
|
||||||
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel[i]).invocationCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cylinder 5 doesn't exist - shouldn't have been called!
|
||||||
|
ASSERT_EQ(0, ENGINE(wallFuel[5]).invocationCounter);
|
||||||
|
|
||||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
eth.engine.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
// still same 4 - wall wetting is NOT invoked from 'periodicFastCallback'
|
// still same 1 per cylinder - wall wetting is NOT invoked from 'periodicFastCallback'
|
||||||
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel).invocationCounter);
|
for (int i = 0; i < 4; i++) {
|
||||||
|
ASSERT_EQ(expectedInvocationCounter, ENGINE(wallFuel[i]).invocationCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cylinder 5 doesn't exist - shouldn't have been called!
|
||||||
|
ASSERT_EQ(0, ENGINE(wallFuel[5]).invocationCounter);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue