Annotations in C++ code to produce formulas in rusEfi console #807

refactoring wall wetting
This commit is contained in:
rusefi 2019-07-12 22:34:38 -04:00
parent 07f41c8f2a
commit a3de5fc276
5 changed files with 23 additions and 26 deletions

View File

@ -298,7 +298,7 @@ static void printSensors(Logging *log) {
reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.fuelPidCorrection), 2); reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_PID_CORR, "ms", ENGINE(engineState.fuelPidCorrection), 2);
reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel).getWallFuel(0), 2); reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_WALL_AMOUNT, "v", ENGINE(wallFuel).getWallFuel(0), 2);
reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuelCorrection), 2); reportSensorF(log, fileFormat, GAUGE_NAME_FUEL_WALL_CORRECTION, "v", ENGINE(wallFuel).wallFuelCorrection, 2);
reportSensorI(log, fileFormat, GAUGE_NAME_VERSION, "#", getRusEfiVersion()); reportSensorI(log, fileFormat, GAUGE_NAME_VERSION, "#", getRusEfiVersion());
@ -864,7 +864,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
} }
tsOutputChannels->wallFuelAmount = ENGINE(wallFuel).getWallFuel(0); tsOutputChannels->wallFuelAmount = ENGINE(wallFuel).getWallFuel(0);
tsOutputChannels->wallFuelCorrection = ENGINE(wallFuelCorrection); tsOutputChannels->wallFuelCorrection = ENGINE(wallFuel).wallFuelCorrection;
// TPS acceleration // TPS acceleration
tsOutputChannels->deltaTps = engine->tpsAccelEnrichment.getMaxDelta(); tsOutputChannels->deltaTps = engine->tpsAccelEnrichment.getMaxDelta();
tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich; tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;

View File

@ -41,13 +41,14 @@ tps_tps_Map3D_t tpsTpsMap("tpsTps");
static Logging *logger = NULL; static Logging *logger = NULL;
WallFuel::WallFuel() { WallFuel::WallFuel() {
reset(); resetWF();
} }
void WallFuel::reset() { void WallFuel::resetWF() {
memset(wallFuel, 0, sizeof(wallFuel)); wallFuel = 0;
} }
//
floatms_t WallFuel::adjust(int injectorIndex, floatms_t M_des DECLARE_ENGINE_PARAMETER_SUFFIX) { floatms_t WallFuel::adjust(int injectorIndex, floatms_t M_des DECLARE_ENGINE_PARAMETER_SUFFIX) {
if (cisnan(M_des)) { if (cisnan(M_des)) {
return M_des; return M_des;
@ -94,15 +95,13 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t M_des DECLARE_ENGINE_PAR
// if tau is really small, we get div/0. // if tau is really small, we get div/0.
// you probably meant to disable wwae. // you probably meant to disable wwae.
float tau = CONFIG(wwaeTau); float tau = CONFIG(wwaeTau);
if(tau < 0.01f) if (tau < 0.01f) {
{
return M_des; return M_des;
} }
// Ignore really slow RPM // Ignore really slow RPM
int rpm = GET_RPM(); int rpm = GET_RPM();
if(rpm < 100) if (rpm < 100) {
{
return M_des; return M_des;
} }
@ -113,32 +112,30 @@ floatms_t WallFuel::adjust(int injectorIndex, floatms_t M_des DECLARE_ENGINE_PAR
// For reasonable values {tau, beta}, this should only be possible // For reasonable values {tau, beta}, this should only be possible
// at extremely low engine speeds (<300rpm ish) // at extremely low engine speeds (<300rpm ish)
// Clamp beta to less than alpha. // Clamp beta to less than alpha.
if(beta > alpha) if (beta > alpha) {
{
beta = alpha; beta = alpha;
} }
float M_f = wallFuel[injectorIndex]; float M_f = wallFuel/*[injectorIndex]*/;
float M_cmd = (M_des - (1 - alpha) * M_f) / (1 - beta); float M_cmd = (M_des - (1 - alpha) * M_f) / (1 - beta);
// We can't inject a negative amount of fuel // We can't inject a negative amount of fuel
// If this goes below zero we will be over-fueling slightly, // If this goes below zero we will be over-fueling slightly,
// but that's ok. // but that's ok.
if(M_cmd <= 0) if (M_cmd <= 0) {
{
M_cmd = 0; M_cmd = 0;
} }
// remainder on walls from last time + new from this time // remainder on walls from last time + new from this time
float M_f_next = alpha * M_f + beta * M_cmd; float M_f_next = alpha * M_f + beta * M_cmd;
wallFuel[injectorIndex] = M_f_next; wallFuel/*[injectorIndex]*/ = M_f_next;
engine->wallFuelCorrection = M_cmd - M_des; wallFuelCorrection = M_cmd - M_des;
return M_cmd; return M_cmd;
} }
floatms_t WallFuel::getWallFuel(int injectorIndex) const { floatms_t WallFuel::getWallFuel(int injectorIndex) const {
return wallFuel[injectorIndex]; return wallFuel/*[injectorIndex]*/;
} }
int AccelEnrichmemnt::getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_SIGNATURE) { int AccelEnrichmemnt::getMaxDeltaIndex(DECLARE_ENGINE_PARAMETER_SIGNATURE) {

View File

@ -66,12 +66,16 @@ public:
*/ */
floatms_t adjust(int injectorIndex, floatms_t target DECLARE_ENGINE_PARAMETER_SUFFIX); floatms_t adjust(int injectorIndex, floatms_t target DECLARE_ENGINE_PARAMETER_SUFFIX);
floatms_t getWallFuel(int injectorIndex) const; floatms_t getWallFuel(int injectorIndex) const;
void reset(); void resetWF();
/**
* fuel injection time correction to account for wall wetting effect, for current cycle
*/
floatms_t wallFuelCorrection = 0;
private: private:
/** /**
* Amount of fuel on the wall, in ms of injector open time, for specific injector. * Amount of fuel on the wall, in ms of injector open time, for each injector.
*/ */
floatms_t wallFuel[INJECTION_PIN_COUNT]; floatms_t wallFuel/*[INJECTION_PIN_COUNT]*/;
}; };
void initAccelEnrichment(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX); void initAccelEnrichment(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);

View File

@ -189,10 +189,6 @@ public:
* @see getInjectionDuration() * @see getInjectionDuration()
*/ */
floatms_t injectionDuration = 0; floatms_t injectionDuration = 0;
/**
* fuel injection time correction to account for wall wetting effect, for current cycle
*/
floatms_t wallFuelCorrection = 0;
/** /**
* This one with wall wetting accounted for, used for logging. * This one with wall wetting accounted for, used for logging.

View File

@ -214,7 +214,7 @@ 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(event->outputs[0]->injectorIndex, ENGINE(injectionDuration) PASS_ENGINE_PARAMETER_SUFFIX); const floatms_t injectionDuration = ENGINE(wallFuel).adjust(0/*event->outputs[0]->injectorIndex*/, 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 */