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;
|
||||
}
|
||||
|
||||
// Filter parameter less than 0.5 impossible, must always average over at least two events
|
||||
if (filterParameter < 0.5f) {
|
||||
filterParameter = 0.5f;
|
||||
// Filter parameter greater than or equal to 0.5 impossible as it causes filter instability, clamp
|
||||
// far under that value.
|
||||
if (filterParameter > 0.35f) {
|
||||
filterParameter = 0.35f;
|
||||
}
|
||||
|
||||
m_filter.configureLowpass(1, filterParameter);
|
||||
|
|
|
@ -10,8 +10,8 @@ static InputShaftSpeedConverter inputSpeedConverter;
|
|||
void initInputShaftSpeedSensor() {
|
||||
int parameter = engineConfiguration->issFilterReciprocal;
|
||||
|
||||
if (parameter <= 0 || parameter > 200) {
|
||||
parameter = 2;
|
||||
if (parameter < 3 || parameter > 200) {
|
||||
parameter = 3;
|
||||
}
|
||||
|
||||
float filterParameter = 1.0f / parameter;
|
||||
|
|
|
@ -11,8 +11,8 @@ static VehicleSpeedConverter vehicleSpeedConverter;
|
|||
void initVehicleSpeedSensor() {
|
||||
int parameter = engineConfiguration->vssFilterReciprocal;
|
||||
|
||||
if (parameter <= 0 || parameter > 200) {
|
||||
parameter = 2;
|
||||
if (parameter < 3 || parameter > 200) {
|
||||
parameter = 3;
|
||||
}
|
||||
|
||||
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) {
|
||||
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 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) {
|
||||
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 norm = getNorm(K, Q);
|
||||
|
|
|
@ -22,7 +22,7 @@ public:
|
|||
void SetUp() override {
|
||||
// If somehow prodcode will be unwrapped for test it MAYBE! will fire with error.
|
||||
// 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