refactoring magic constant STOICH_RATIO

This commit is contained in:
Andrey 2021-05-20 02:39:20 -04:00
parent ba758dd5cb
commit a762853d3b
5 changed files with 5 additions and 5 deletions

View File

@ -805,7 +805,7 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
setLinearCurve(engineConfiguration->map.samplingWindow, 50, 50, 1);
setLambdaMap(config->lambdaTable, 1.0f);
engineConfiguration->stoichRatioPrimary = 14.7f * PACK_MULT_AFR_CFG;
engineConfiguration->stoichRatioPrimary = STOICH_RATIO * PACK_MULT_AFR_CFG;
engineConfiguration->stoichRatioSecondary = 9.0f * PACK_MULT_AFR_CFG;
setDefaultVETable(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -27,7 +27,7 @@ float FuelComputer::getStoichiometricRatio() const {
// Config compatibility: this field may be zero on ECUs with old defaults
if (primary < 5) {
// 14.7 = E0 gasoline AFR
primary = 14.7f;
primary = STOICH_RATIO;
}
// Without an ethanol/flex sensor, return primary configured stoich ratio

View File

@ -117,7 +117,7 @@ struct Sensors2 {
};
static void populateFrame(Sensors2& msg) {
msg.afr = Sensor::get(SensorType::Lambda1).value_or(0) * 14.7f;
msg.afr = Sensor::get(SensorType::Lambda1).value_or(0) * STOICH_RATIO;
msg.oilPressure = Sensor::get(SensorType::OilPressure).value_or(-1);
msg.vvtPos = engine->triggerCentral.getVVTPosition(0, 0);
msg.vbatt = Sensor::get(SensorType::BatteryVoltage).value_or(0);

View File

@ -83,7 +83,7 @@ bool shouldUpdateCorrection(SensorType sensor DECLARE_ENGINE_PARAMETER_SUFFIX) {
// Pause (but don't reset) correction if the AFR is off scale.
// It's probably a transient and poorly tuned transient correction
auto afr = Sensor::get(sensor).value_or(0) * 14.7f;
auto afr = Sensor::get(sensor).value_or(0) * STOICH_RATIO;
if (!afr || afr < (cfg.minAfr * 0.1f) || afr > (cfg.maxAfr * 0.1f)) {
return false;
}

View File

@ -38,7 +38,7 @@ static int totalEgoCnt = 0;
static int prevEgoCnt = 0;
// todo: move it to engineConfiguration
static const float stoichAfr = 14.7f;
static const float stoichAfr = STOICH_RATIO;
static const float maxAfrDeviation = 5.0f; // 9.7..19.7
static const int minAvgSize = (EGO_AVG_BUF_SIZE / 2); // ~0.6 sec for 20ms period of 'fast' callback, and it matches a lag time of most narrow EGOs
static const int maxAvgSize = (EGO_AVG_BUF_SIZE - 1); // the whole buffer