fix vss/iss filter parameter validation (#4114)
* fix filter parameter validation * use values that don't get clipped
This commit is contained in:
parent
f773e4a10b
commit
c3fb211d6b
|
@ -18,9 +18,10 @@ void FrequencySensor::initIfValid(brain_pin_e pin, SensorConverter &converter, f
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter parameter less than 0.5 impossible, must always average over at least two events
|
// Filter parameter greater than or equal to 0.5 impossible as it causes filter instability, clamp
|
||||||
if (filterParameter < 0.5f) {
|
// far under that value.
|
||||||
filterParameter = 0.5f;
|
if (filterParameter > 0.35f) {
|
||||||
|
filterParameter = 0.35f;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_filter.configureLowpass(1, filterParameter);
|
m_filter.configureLowpass(1, filterParameter);
|
||||||
|
|
|
@ -10,8 +10,8 @@ static InputShaftSpeedConverter inputSpeedConverter;
|
||||||
void initInputShaftSpeedSensor() {
|
void initInputShaftSpeedSensor() {
|
||||||
int parameter = engineConfiguration->issFilterReciprocal;
|
int parameter = engineConfiguration->issFilterReciprocal;
|
||||||
|
|
||||||
if (parameter <= 0 || parameter > 200) {
|
if (parameter < 3 || parameter > 200) {
|
||||||
parameter = 2;
|
parameter = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
float filterParameter = 1.0f / parameter;
|
float filterParameter = 1.0f / parameter;
|
||||||
|
|
|
@ -11,8 +11,8 @@ static VehicleSpeedConverter vehicleSpeedConverter;
|
||||||
void initVehicleSpeedSensor() {
|
void initVehicleSpeedSensor() {
|
||||||
int parameter = engineConfiguration->vssFilterReciprocal;
|
int parameter = engineConfiguration->vssFilterReciprocal;
|
||||||
|
|
||||||
if (parameter <= 0 || parameter > 200) {
|
if (parameter < 3 || parameter > 200) {
|
||||||
parameter = 2;
|
parameter = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
float filterParameter = 1.0f / parameter;
|
float filterParameter = 1.0f / parameter;
|
||||||
|
|
|
@ -30,7 +30,7 @@ static float getNorm(float K, float Q) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Biquad::configureBandpass(float samplingFrequency, float centerFrequency, float Q) {
|
void Biquad::configureBandpass(float samplingFrequency, float centerFrequency, float Q) {
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, samplingFrequency >= 2 * centerFrequency, "Invalid biquad parameters");
|
efiAssertVoid(OBD_PCM_Processor_Fault, samplingFrequency >= 2.5f * centerFrequency, "Invalid biquad parameters");
|
||||||
|
|
||||||
float K = getK(samplingFrequency, centerFrequency);
|
float K = getK(samplingFrequency, centerFrequency);
|
||||||
float norm = getNorm(K, Q);
|
float norm = getNorm(K, Q);
|
||||||
|
@ -43,7 +43,7 @@ void Biquad::configureBandpass(float samplingFrequency, float centerFrequency, f
|
||||||
}
|
}
|
||||||
|
|
||||||
void Biquad::configureLowpass(float samplingFrequency, float cutoffFrequency, float Q) {
|
void Biquad::configureLowpass(float samplingFrequency, float cutoffFrequency, float Q) {
|
||||||
efiAssertVoid(OBD_PCM_Processor_Fault, samplingFrequency >= 2 * cutoffFrequency, "Invalid biquad parameters");
|
efiAssertVoid(OBD_PCM_Processor_Fault, samplingFrequency >= 2.5f * cutoffFrequency, "Invalid biquad parameters");
|
||||||
|
|
||||||
float K = getK(samplingFrequency, cutoffFrequency);
|
float K = getK(samplingFrequency, cutoffFrequency);
|
||||||
float norm = getNorm(K, Q);
|
float norm = getNorm(K, Q);
|
||||||
|
|
|
@ -22,7 +22,7 @@ public:
|
||||||
void SetUp() override {
|
void SetUp() override {
|
||||||
// If somehow prodcode will be unwrapped for test it MAYBE! will fire with error.
|
// If somehow prodcode will be unwrapped for test it MAYBE! will fire with error.
|
||||||
// At least we must init FlexSensor somehow
|
// At least we must init FlexSensor somehow
|
||||||
dut.initIfValid(GPIOA_0, identityFunc, 0.5f);
|
dut.initIfValid(GPIOA_0, identityFunc, 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue