mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Configurable PID jitter buffer
This commit is contained in:
parent
9b43dfde19
commit
97504c0ffe
4 changed files with 7 additions and 3 deletions
|
@ -134,7 +134,7 @@ static uint32_t activeFeaturesLatch = 0;
|
|||
static uint8_t currentControlRateProfileIndex = 0;
|
||||
controlRateConfig_t *currentControlRateProfile;
|
||||
|
||||
static const uint8_t EEPROM_CONF_VERSION = 125;
|
||||
static const uint8_t EEPROM_CONF_VERSION = 126;
|
||||
|
||||
static void resetAccelerometerTrims(flightDynamicsTrims_t *accelerometerTrims)
|
||||
{
|
||||
|
@ -402,6 +402,8 @@ static void resetConf(void)
|
|||
masterConfig.gyro_sync_denom = 4;
|
||||
masterConfig.gyro_soft_lpf_hz = 60;
|
||||
|
||||
masterConfig.pid_jitter_buffer = 20;
|
||||
|
||||
resetAccelerometerTrims(&masterConfig.accZero);
|
||||
|
||||
resetSensorAlignment(&masterConfig.sensorAlignmentConfig);
|
||||
|
|
|
@ -63,6 +63,8 @@ typedef struct master_t {
|
|||
uint16_t dcm_kp; // DCM filter proportional gain ( x 10000)
|
||||
uint16_t dcm_ki; // DCM filter integral gain ( x 10000)
|
||||
|
||||
uint8_t pid_jitter_buffer; // Jitter buffer time in us for pid controller for smoother motor output
|
||||
|
||||
gyroConfig_t gyroConfig;
|
||||
|
||||
uint8_t mag_hardware; // Which mag hardware to use on boards with more than one device
|
||||
|
|
|
@ -671,6 +671,7 @@ const clivalue_t valueTable[] = {
|
|||
{ "pid_delta_method", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, &masterConfig.profile[0].pidProfile.deltaMethod, .config.lookup = { TABLE_DELTA_METHOD } },
|
||||
{ "dterm_lpf_hz", VAR_FLOAT | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.dterm_lpf_hz, .config.minmax = {0, 500 } },
|
||||
{ "dterm_average_count", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.dterm_average_count, .config.minmax = {2, 12 } },
|
||||
{ "pid_jitter_buffer", VAR_UINT8 | MASTER_VALUE, &masterConfig.pid_jitter_buffer, .config.minmax = { 0, 100 } },
|
||||
|
||||
{ "pid_controller", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, &masterConfig.profile[0].pidProfile.pidController, .config.lookup = { TABLE_PID_CONTROLLER } },
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ enum {
|
|||
#define IBATINTERVAL (6 * 3500)
|
||||
|
||||
#define GYRO_WATCHDOG_DELAY 80 // delay for gyro sync
|
||||
#define JITTER_BUFFER_TIME 20 // cycleTime jitter buffer time
|
||||
|
||||
uint16_t cycleTime = 0; // this is the number in micro second to achieve a full loop, it can differ a little and is taken into account in the PID loop
|
||||
|
||||
|
@ -720,7 +719,7 @@ void taskMainPidLoopCheck(void) {
|
|||
while (1) {
|
||||
if (gyroSyncCheckUpdate() || ((cycleTime + (micros() - previousTime)) >= (targetLooptime + GYRO_WATCHDOG_DELAY))) {
|
||||
while (1) {
|
||||
if (micros() >= JITTER_BUFFER_TIME + previousTime) break;
|
||||
if (micros() >= masterConfig.pid_jitter_buffer + previousTime) break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue