removing narrow ego avg
This commit is contained in:
parent
bb143f6cc3
commit
2048492c59
|
@ -31,6 +31,9 @@ Release template (copy/paste this for new release):
|
|||
### Breaking Changes
|
||||
- Trigger Edge settings renamed from "true"/"false" to "Falling"/"Rising"
|
||||
|
||||
### Removed
|
||||
- Narrow to Wideband approximation
|
||||
|
||||
## December 2023 "Day 677"
|
||||
|
||||
### Breaking Changes
|
||||
|
|
|
@ -85,6 +85,3 @@
|
|||
|
||||
#define RPM_LOW_THRESHOLD 8 // RPM=8 is an empirical lower sensitivity threshold of MAX9926 for 60-2
|
||||
#define NO_RPM_EVENTS_TIMEOUT_SECS 5 // (RPM < 12)
|
||||
|
||||
#define EFI_NARROW_EGO_AVERAGING TRUE
|
||||
|
||||
|
|
|
@ -100,8 +100,6 @@
|
|||
#define RPM_LOW_THRESHOLD 8 // RPM=8 is an empirical lower sensitivity threshold of MAX9926 for 60-2
|
||||
#define NO_RPM_EVENTS_TIMEOUT_SECS 5 // (RPM < 12)
|
||||
|
||||
#define EFI_NARROW_EGO_AVERAGING TRUE
|
||||
|
||||
#ifndef EFI_BOOTLOADER // bootloader needs INT_FLASH and doesn't have MFS
|
||||
/* this board has external QSPI NOR flash */
|
||||
#undef EFI_STORAGE_MFS
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "advance_map.h"
|
||||
|
||||
void setGy6139qmbDefaultEngineConfiguration() {
|
||||
// engineConfiguration->map.sensor.type = MT_3V_SENSOR;
|
||||
engineConfiguration->rpmHardLimit = 9000;
|
||||
engineConfiguration->cranking.rpm = 1100;
|
||||
setTargetRpmCurve(2000);
|
||||
|
|
|
@ -247,8 +247,6 @@
|
|||
|
||||
#define EFI_USE_FAST_ADC TRUE
|
||||
|
||||
#define EFI_NARROW_EGO_AVERAGING TRUE
|
||||
|
||||
#ifndef EFI_CAN_SUPPORT
|
||||
#define EFI_CAN_SUPPORT TRUE
|
||||
#endif
|
||||
|
|
|
@ -371,8 +371,6 @@ typedef enum __attribute__ ((__packed__)) {
|
|||
*/
|
||||
ES_14Point7_Free = 2,
|
||||
|
||||
ES_NarrowBand = 3,
|
||||
|
||||
ES_PLX = 4,
|
||||
|
||||
ES_Custom = 5,
|
||||
|
|
|
@ -716,7 +716,6 @@ void initRealHardwareEngineController() {
|
|||
initPwmTester();
|
||||
#endif /* EFI_PWM_TESTER */
|
||||
|
||||
initEgoAveraging();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,78 +13,6 @@
|
|||
|
||||
#include "cyclic_buffer.h"
|
||||
|
||||
#ifdef EFI_NARROW_EGO_AVERAGING
|
||||
// Needed by narrow EGOs (see updateEgoAverage()).
|
||||
// getAfr() is called at ~50Hz, so we store at most (1<<3)*32 EGO values for ~5 secs.
|
||||
#define EGO_AVG_SHIFT 3
|
||||
#define EGO_AVG_BUF_SIZE 32 // 32*sizeof(float)
|
||||
|
||||
static bool useAveraging = false;
|
||||
// Circular running-average buffer, used by CIC-like averaging filter
|
||||
static cyclic_buffer<float, EGO_AVG_BUF_SIZE> egoAfrBuf;
|
||||
// Total ego iterations (>240 days max. for 10ms update period)
|
||||
static int totalEgoCnt = 0;
|
||||
// We need this to calculate the real number of values stored in the buffer.
|
||||
static int prevEgoCnt = 0;
|
||||
|
||||
// todo: move it to engineConfiguration
|
||||
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
|
||||
|
||||
#ifdef EFI_NARROW_EGO_AVERAGING
|
||||
// we store the last measured AFR value to predict the current averaging window size
|
||||
static float lastAfr = stoichAfr;
|
||||
#endif
|
||||
|
||||
void initEgoAveraging() {
|
||||
// Our averaging is intended for use only with Narrow EGOs.
|
||||
if (engineConfiguration->afr_type == ES_NarrowBand) {
|
||||
totalEgoCnt = prevEgoCnt = 0;
|
||||
egoAfrBuf.clear();
|
||||
useAveraging = true;
|
||||
}
|
||||
}
|
||||
|
||||
static float updateEgoAverage(float afr) {
|
||||
// use a variation of cascaded integrator-comb (CIC) filtering
|
||||
totalEgoCnt++;
|
||||
int localBufPos = (totalEgoCnt >> EGO_AVG_SHIFT) % EGO_AVG_BUF_SIZE;
|
||||
int localPrevBufPos = ((totalEgoCnt - 1) >> EGO_AVG_SHIFT) % EGO_AVG_BUF_SIZE;
|
||||
|
||||
// reset old buffer cell
|
||||
if (localPrevBufPos != localBufPos) {
|
||||
egoAfrBuf.elements[localBufPos] = 0;
|
||||
// Remove (1 << EGO_AVG_SHIFT) elements from our circular buffer (except for the 1st cycle).
|
||||
if (totalEgoCnt >= (EGO_AVG_BUF_SIZE << EGO_AVG_SHIFT))
|
||||
prevEgoCnt += (1 << EGO_AVG_SHIFT);
|
||||
}
|
||||
// integrator stage
|
||||
egoAfrBuf.elements[localBufPos] += afr;
|
||||
|
||||
// Change window size depending on |AFR-stoich| deviation.
|
||||
// The narrow EGO is very noisy when AFR is close to shoich.
|
||||
// And we need the fastest EGO response when AFR has the extreme deviation (way too lean/rich).
|
||||
float avgSize = maxAvgSize;//interpolateClamped(minAvgSize, maxAfrDeviation, maxAvgSize, 0.0f, absF(lastAfr - stoichAfr));
|
||||
// choose the number of recently filled buffer cells for averaging
|
||||
int avgCnt = (int)efiRound(avgSize, 1.0f) << EGO_AVG_SHIFT;
|
||||
// limit averaging count to the real stored count
|
||||
int startAvgCnt = maxI(totalEgoCnt - avgCnt, prevEgoCnt);
|
||||
|
||||
// return moving average of N last sums
|
||||
float egoAfrSum = 0;
|
||||
for (int i = (totalEgoCnt >> EGO_AVG_SHIFT); i >= (startAvgCnt >> EGO_AVG_SHIFT); i--) {
|
||||
egoAfrSum += egoAfrBuf.elements[i % EGO_AVG_BUF_SIZE];
|
||||
}
|
||||
// we divide by a real number of stored values to get an exact average
|
||||
return egoAfrSum / float(totalEgoCnt - startAvgCnt);
|
||||
}
|
||||
#else
|
||||
void initEgoAveraging() {
|
||||
}
|
||||
#endif
|
||||
|
||||
bool hasAfrSensor() {
|
||||
if (engineConfiguration->enableAemXSeries || engineConfiguration->enableInnovateLC2) {
|
||||
return true;
|
||||
|
@ -109,17 +37,6 @@ float getAfr(SensorType type) {
|
|||
|
||||
float volts = getVoltageDivided("ego", type == SensorType::Lambda1 ? sensor->hwChannel : sensor->hwChannel2);
|
||||
|
||||
if (engineConfiguration->afr_type == ES_NarrowBand) {
|
||||
float afr = interpolate2d(volts, config->narrowToWideOxygenBins, config->narrowToWideOxygen);
|
||||
#ifdef EFI_NARROW_EGO_AVERAGING
|
||||
if (useAveraging)
|
||||
afr = updateEgoAverage(afr);
|
||||
return (lastAfr = afr);
|
||||
#else
|
||||
return afr;
|
||||
#endif
|
||||
}
|
||||
|
||||
return interpolateMsg("AFR", sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts)
|
||||
+ engineConfiguration->egoValueShift;
|
||||
}
|
||||
|
@ -157,12 +74,6 @@ static void initEgoSensor(afr_sensor_s *sensor, ego_sensor_e type) {
|
|||
sensor->v2 = 5;
|
||||
sensor->value2 = 20;
|
||||
break;
|
||||
case ES_NarrowBand:
|
||||
sensor->v1 = 0.1;
|
||||
sensor->value1 = 15;
|
||||
sensor->v2 = 0.9;
|
||||
sensor->value2 = 14;
|
||||
break;
|
||||
case ES_AEM:
|
||||
sensor->v1 = 0.5;
|
||||
sensor->value1 = 8.5;
|
||||
|
|
|
@ -15,4 +15,3 @@
|
|||
float getAfr(SensorType type);
|
||||
bool hasAfrSensor();
|
||||
void setEgoSensor(ego_sensor_e type);
|
||||
void initEgoAveraging();
|
||||
|
|
|
@ -146,8 +146,6 @@ struct_no_prefix engine_configuration_s
|
|||
|
||||
#define IAC_PID_MULT_SIZE 8
|
||||
|
||||
#define NARROW_BAND_WIDE_BAND_CONVERSION_SIZE 8
|
||||
|
||||
#define TORQUE_CURVE_SIZE 6
|
||||
#define CLT_CURVE_SIZE 16
|
||||
#define CLT_LIMITER_CURVE_SIZE 4
|
||||
|
@ -269,7 +267,7 @@ struct pid_s
|
|||
int16_t maxValue;Output Max Duty Cycle;"", 1, 0, -30000, 30000, 0
|
||||
end_struct
|
||||
|
||||
#define ego_sensor_e_enum "BPSX", "Innovate", "14Point7", "Narrow", "PLX", "Custom", "AEM"
|
||||
#define ego_sensor_e_enum "BPSX", "Innovate", "14Point7", "INVALID", "PLX", "Custom", "AEM"
|
||||
custom ego_sensor_e 1 bits, S08, @OFFSET@, [0:2], @@ego_sensor_e_enum@@
|
||||
|
||||
#define SentEtbType_enum "None", "GM type 1", "Ford type 1", "Custom"
|
||||
|
@ -900,7 +898,7 @@ custom maf_sensor_type_e 1 bits, S08, @OFFSET@, [0:1], @@maf_sensor_type_e_enum@
|
|||
bit enableCanVss;Read VSS from OEM CAN bus according to selected CAN vehicle configuration.
|
||||
bit enableInnovateLC2
|
||||
bit showHumanReadableWarning
|
||||
bit stftIgnoreErrorMagnitude;If enabled, adjust at a constant rate instead of a rate proportional to the current lambda error. This mode may be easier to tune, and more tolerant of sensor noise. Use of this mode is required if you have a narrowband O2 sensor.
|
||||
bit stftIgnoreErrorMagnitude;If enabled, adjust at a constant rate instead of a rate proportional to the current lambda error. This mode may be easier to tune, and more tolerant of sensor noise.
|
||||
bit vvtBooleanForVerySpecialCases
|
||||
bit enableSoftwareKnock
|
||||
bit verboseVVTDecoding;Verbose info in console below engineSnifferRpmThreshold\nenable vvt_details
|
||||
|
@ -1653,8 +1651,7 @@ engine_configuration_s engineConfiguration;
|
|||
|
||||
float[CRANKING_CURVE_SIZE] crankingTpsCoef;Cranking fuel correction coefficient based on TPS;"Ratio", 1, 0, 0, 700, 2
|
||||
float[CRANKING_CURVE_SIZE] crankingTpsBins;;"%", 1, 0, 0, 100, 2
|
||||
float[NARROW_BAND_WIDE_BAND_CONVERSION_SIZE] narrowToWideOxygenBins;Narrow Band WBO Approximation;"V", 1, 0, -10, 10, 3
|
||||
float[NARROW_BAND_WIDE_BAND_CONVERSION_SIZE] narrowToWideOxygen;;"ratio", 1, 0, -40, 40, 2
|
||||
float[16] unusedSpaceHere
|
||||
|
||||
uint16_t[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvanceBins;Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"RPM", 1, 0, 0, 25000, 0
|
||||
int16_t[CRANKING_ADVANCE_CURVE_SIZE] autoscale crankingAdvance;Optional timing advance table for Cranking (see useSeparateAdvanceForCranking);"deg", 0.01, 0, -20, 90, 2
|
||||
|
|
|
@ -346,18 +346,6 @@ enable2ndByteCanID = false
|
|||
yBins = knockBaseNoise
|
||||
gauge = RPMGauge
|
||||
|
||||
curve = narrowToWideOxygenCurve, "Narrow to Wideband approximation"
|
||||
columnLabel = "Voltage", "AFR"
|
||||
xAxis = 0, 6, 10
|
||||
yAxis = 0, 28, 10
|
||||
xBins = narrowToWideOxygenBins
|
||||
yBins = narrowToWideOxygen
|
||||
#if LAMBDA
|
||||
gauge = lambda1Gauge
|
||||
#else
|
||||
gauge = afr1Gauge
|
||||
#endif
|
||||
|
||||
curve = scriptCurve1, "Script Curve #1"
|
||||
columnLabel = "X", "Y"
|
||||
xAxis = 0, 128, 10
|
||||
|
@ -1979,7 +1967,6 @@ menuDialog = main
|
|||
# O2 sensor(s)
|
||||
subMenu = egoSettings, "EGO sensor"
|
||||
subMenu = widebandConfig, "rusEFI Wideband Controller", 0, { canReadEnabled && canWriteEnabled }
|
||||
subMenu = narrowToWideOxygenCurve, "Narrow to Wideband approximation"
|
||||
subMenu = std_separator
|
||||
|
||||
# Misc sensors
|
||||
|
|
Loading…
Reference in New Issue