1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 23:35:34 +03:00

Improve dterm filter accuracy // magic number

This commit is contained in:
borisbstyle 2016-08-21 00:13:14 +02:00
parent 4543778ad1
commit 138ade7939
3 changed files with 7 additions and 5 deletions

View file

@ -72,9 +72,9 @@ pidControllerFuncPtr pid_controller = pidLegacy; // which pid controller are we
pidControllerFuncPtr pid_controller = pidBetaflight; // which pid controller are we using pidControllerFuncPtr pid_controller = pidBetaflight; // which pid controller are we using
#endif #endif
void setTargetPidLooptime(uint8_t pidProcessDenom) void setTargetPidLooptime(uint32_t pidLooptime)
{ {
targetPidLooptime = gyro.targetLooptime * pidProcessDenom; targetPidLooptime = pidLooptime;
} }
void pidResetErrorGyroState(void) void pidResetErrorGyroState(void)

View file

@ -133,5 +133,5 @@ extern uint8_t PIDweight[3];
void pidSetController(pidControllerType_e type); void pidSetController(pidControllerType_e type);
void pidResetErrorGyroState(void); void pidResetErrorGyroState(void);
void pidStabilisationState(pidStabilisationState_e pidControllerState); void pidStabilisationState(pidStabilisationState_e pidControllerState);
void setTargetPidLooptime(uint8_t pidProcessDenom); void setTargetPidLooptime(uint32_t pidLooptime);

View file

@ -109,6 +109,8 @@
#include "config/config_profile.h" #include "config/config_profile.h"
#include "config/config_master.h" #include "config/config_master.h"
#define LOOPTIME_SUSPEND_TIME 5 // Prevent too long busy wait times
#ifdef USE_HARDWARE_REVISION_DETECTION #ifdef USE_HARDWARE_REVISION_DETECTION
#include "hardware_revision.h" #include "hardware_revision.h"
#endif #endif
@ -600,7 +602,7 @@ void init(void)
masterConfig.gyro_sync_denom = 1; masterConfig.gyro_sync_denom = 1;
} }
setTargetPidLooptime(masterConfig.pid_process_denom); // Initialize pid looptime setTargetPidLooptime((gyro.targetLooptime + LOOPTIME_SUSPEND_TIME) * masterConfig.pid_process_denom); // Initialize pid looptime
#ifdef BLACKBOX #ifdef BLACKBOX
@ -678,7 +680,7 @@ void main_init(void)
/* Setup scheduler */ /* Setup scheduler */
schedulerInit(); schedulerInit();
rescheduleTask(TASK_GYROPID, gyro.targetLooptime + 5); // Add a littlebit of extra time to reduce busy wait rescheduleTask(TASK_GYROPID, gyro.targetLooptime + LOOPTIME_SUSPEND_TIME); // Add a littlebit of extra time to reduce busy wait
setTaskEnabled(TASK_GYROPID, true); setTaskEnabled(TASK_GYROPID, true);
if (sensors(SENSOR_ACC)) { if (sensors(SENSOR_ACC)) {