betaflight / betaflight

Open Source Flight Controller Firmware
GNU General Public License v3.0
8k stars 2.86k forks source link

battery - fix BATTERY_NOT_PRESENT detection, detection logic change #13599

Closed ledvinap closed 2 weeks ago

ledvinap commented 2 weeks ago

Detection logic is refactored:

slowly changing voltage will update threshold, but voltage will be considered stable, 1 update/s (100mV/s) is tolerated

github-actions[bot] commented 2 weeks ago

Do you want to test this code? You can flash it directly from Betaflight Configurator:

WARNING: It may be unstable. Use only for testing!

ledvinap commented 2 weeks ago

voltage

ledvinap commented 2 weeks ago

battery - improve stable voltage detection

ledvinap commented 2 weeks ago

Tested, works fine on H7NANO.

I've extended detection window to 1s - now filtered voltage is close to final value. Default time constant is ~.5s (Its really bad idea to specify inverse of filter cutoff - time constant would make much more time) It seems that resulting value is roughly within VOLTAGE_STABLE_MAX_DELTA of final value under these conditions (anyone wants to do the math?).

ledvinap commented 2 weeks ago

@pfeerick it takes some time for the voltage filter to stabilize plus 1s detection window. Are the initial beeps a big problem?

pfeerick commented 2 weeks ago

Not as far as I'm concerned... If I were being pedantic, sure, it should do just the initial fast startup beeps and zip it... but my preference is more that it doesn't beep incessantly all the frigging time if you have beeper active on middle position, and don't have the handset on. :partying_face:

nerdCopter commented 2 weeks ago

backport to 4.5-maintenance?