RC smoothing retraining update - adds full support for CRSF
commit1982c94780009ec50679864af69d53dae23ecc20
authorBruce Luckcuck <github@etracer.net>
Thu, 14 Jun 2018 20:46:33 +0000 (14 16:46 -0400)
committerBruce Luckcuck <github@etracer.net>
Sat, 23 Jun 2018 00:10:06 +0000 (22 20:10 -0400)
tree221122d4cfe03fefa57aa56b52022ddc26eca34a
parent6acbed6d6edaf160b209233732bcf841fcbe6d32
RC smoothing retraining update - adds full support for CRSF
Adds in flight monitoring of the rx frame rate and adapts the filters if the frame rate changes. Primarily to add support for Crossfire with its ability to switch from 150hz to 50hz (and back) under some circumstances. Will work with any protocol - not CRSF specific.   So if future receivers add the ability to switch frame rates dynamically the logic should support them.

If the current rx frame rate is more than +-20% from the previously detected rate, then the process will retrain for the next 50 samples as long as the rate continues to be outside the 20% tolerance. Once 50 samples are collected the new frame rate is updated and the filter cutoffs are adjusted. Only filters set with their cutoffs = 0 (auto) will be adjusted. There is a 2 second guard time after a successful update before retraining can start again to prevent rapid switching back and forth.

The logic is optimized to not perform any training if the filters are set to manual cutoffs. So there is an opportunity for advanced users to choose specific cutoffs and reduce the PID loop load slightly. However this is not recommended for Crossfire or other protocols that might change their rx frame rate.

Updated the output of the `rc_smoothing_info` cli command to match the revised logic.
src/main/blackbox/blackbox.c
src/main/build/debug.c
src/main/build/debug.h
src/main/common/filter.c
src/main/common/filter.h
src/main/fc/fc_rc.c
src/main/fc/fc_rc.h
src/main/fc/rc_controls.h
src/main/flight/pid.c
src/main/flight/pid.h
src/main/interface/cli.c