1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Fix default PID DENOM (#12509)

* Set default PID DENOM

* Fixes after Karate review

* Fixes after Karate review v2

* Use gyro.sampleRateHz

* Fixes after discussion
This commit is contained in:
Mark Haslinghuis 2023-12-04 03:02:08 +01:00 committed by GitHub
parent e126f1c4a4
commit 7dffe25ed1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 10 deletions

View file

@ -673,15 +673,19 @@ void validateAndFixGyroConfig(void)
// check for looptime restrictions based on motor protocol. Motor times have safety margin
float motorUpdateRestriction;
#if defined(STM32F4) || defined(STM32G4)
#if defined(USE_DSHOT) && defined(USE_PID_DENOM_CHECK)
/* If bidirectional DSHOT is being used on an F4 or G4 then force DSHOT300. The motor update restrictions then applied
* will automatically consider the loop time and adjust pid_process_denom appropriately
*/
if (motorConfig()->dev.useDshotTelemetry && (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_DSHOT600)) {
if (motorConfig()->dev.useDshotTelemetry) {
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_DSHOT600) {
motorConfigMutable()->dev.motorPwmProtocol = PWM_TYPE_DSHOT300;
}
#endif
if (gyro.sampleRateHz > 4000) {
pidConfigMutable()->pid_process_denom = 2;
}
}
#endif // USE_DSHOT && USE_PID_DENOM_CHECK
switch (motorConfig()->dev.motorPwmProtocol) {
case PWM_TYPE_STANDARD:
motorUpdateRestriction = 1.0f / BRUSHLESS_MOTORS_PWM_RATE;

View file

@ -90,13 +90,9 @@ pt1Filter_t throttleLpf;
PG_REGISTER_WITH_RESET_TEMPLATE(pidConfig_t, pidConfig, PG_PID_CONFIG, 3);
#if !defined(DEFAULT_PID_PROCESS_DENOM)
#if defined(STM32F411xE)
#define DEFAULT_PID_PROCESS_DENOM 2
#else
#ifndef DEFAULT_PID_PROCESS_DENOM
#define DEFAULT_PID_PROCESS_DENOM 1
#endif
#endif
#ifdef USE_RUNAWAY_TAKEOFF
PG_RESET_TEMPLATE(pidConfig_t, pidConfig,

View file

@ -79,4 +79,6 @@
#define USE_EXTI
#define USE_PID_DENOM_CHECK
#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors

View file

@ -78,4 +78,6 @@
#define USE_EXTI
#define USE_PID_DENOM_CHECK
#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors

View file

@ -72,5 +72,9 @@
#define USE_ESCSERIAL
#define USE_ADC
#define USE_EXTI
#define USE_PID_DENOM_CHECK
#define USE_TIMER_UP_CONFIG