I have 2 items that I think need review in the IMU.cpp file.
Item 1:
The existing applyDeadband() macro affects the values that are outside of the deadband region. This affects the calibration/linearity of the system.
This is not a standard deadband function and I can't see how this is the intended function.
Please review and comment.
The existing macro (approx line # 290)
#define applyDeadband(value, deadband) \
if(abs(value) < deadband) { \
value = 0; \
} else if(value > 0){ \
value -= deadband; \
} else if(value < 0){ \
value += deadband; \
}
The replacement macro that does not affect values outside of the deadband region is below:
#define applyDeadband(value, deadband) {value = (abs(value) < deadband ? 0 : value);}
The graph (with example data and deadband = 5) illustrates the effect of the existing MW deadband function vs. the effect of a typical deadband.
Item 2
in getEstimatedAltitude() at approx line # 330
There seems to be a typo in the following line. The '6' should be a '7'. The existing code will never settle to a stable value other than 0 (zero).
alt.EstAlt = (alt.EstAlt * 6 + BaroAlt) >> 3; // additional LPF to reduce baro noise (faster by 30 µs)
The corrected line appears below
alt.EstAlt = (alt.EstAlt * 7 + BaroAlt) >> 3; // additional LPF to reduce baro noise (faster by 30 µs) // corrected
Please review and comment
I have applied both of these fixes to my FC. The altitude hold is better.
Dennis