RC Smoothing: reduce retraining sample count
Reduce the retraining sample count from 50 to 20. The initial training remains unchanged at 50 samples. Speeds up the transition to a new detected frame rate and adjusts the filters to new optimal cutoffs quicker. As an example for CRSF: switching from 150hz to 50hz would take approximately 1 second (50 samples @ 20ms). After this change it will take approximately 0.4 seconds.
This commit is contained in:
parent
39582667c2
commit
76e537cff7
|
@ -71,7 +71,8 @@ enum {
|
|||
#ifdef USE_RC_SMOOTHING_FILTER
|
||||
#define RC_SMOOTHING_IDENTITY_FREQUENCY 80 // Used in the formula to convert a BIQUAD cutoff frequency to PT1
|
||||
#define RC_SMOOTHING_FILTER_STARTUP_DELAY_MS 5000 // Time to wait after power to let the PID loop stabilize before starting average frame rate calculation
|
||||
#define RC_SMOOTHING_FILTER_TRAINING_SAMPLES 50 // Number of rx frame rate samples to average
|
||||
#define RC_SMOOTHING_FILTER_TRAINING_SAMPLES 50 // Number of rx frame rate samples to average during initial training
|
||||
#define RC_SMOOTHING_FILTER_RETRAINING_SAMPLES 20 // Number of rx frame rate samples to average during frame rate changes
|
||||
#define RC_SMOOTHING_FILTER_TRAINING_DELAY_MS 1000 // Additional time to wait after receiving first valid rx frame before initial training starts
|
||||
#define RC_SMOOTHING_FILTER_RETRAINING_DELAY_MS 2000 // Guard time to wait after retraining to prevent retraining again too quickly
|
||||
#define RC_SMOOTHING_RX_RATE_CHANGE_PERCENT 20 // Look for samples varying this much from the current detected frame rate to initiate retraining
|
||||
|
@ -377,7 +378,8 @@ FAST_CODE bool rcSmoothingAccumulateSample(rcSmoothingFilter_t *smoothingData, i
|
|||
smoothingData->training.min = MIN(smoothingData->training.min, rxFrameTimeUs);
|
||||
|
||||
// if we've collected enough samples then calculate the average and reset the accumulation
|
||||
if (smoothingData->training.count >= RC_SMOOTHING_FILTER_TRAINING_SAMPLES) {
|
||||
const int sampleLimit = (rcSmoothingData.filterInitialized) ? RC_SMOOTHING_FILTER_RETRAINING_SAMPLES : RC_SMOOTHING_FILTER_TRAINING_SAMPLES;
|
||||
if (smoothingData->training.count >= sampleLimit) {
|
||||
smoothingData->training.sum = smoothingData->training.sum - smoothingData->training.min - smoothingData->training.max; // Throw out high and low samples
|
||||
smoothingData->averageFrameTimeUs = lrintf(smoothingData->training.sum / (smoothingData->training.count - 2));
|
||||
rcSmoothingResetAccumulation(smoothingData);
|
||||
|
|
Loading…
Reference in New Issue