Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default PID DENOM #12509

Merged
merged 5 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/main/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
motorConfigMutable()->dev.motorPwmProtocol = PWM_TYPE_DSHOT300;
if (motorConfig()->dev.useDshotTelemetry) {
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_DSHOT600) {
motorConfigMutable()->dev.motorPwmProtocol = PWM_TYPE_DSHOT300;
}
if (gyro.sampleRateHz > 4000) {
pidConfigMutable()->pid_process_denom = 2;
}
}
#endif

#endif // USE_DSHOT && USE_PID_DENOM_CHECK
switch (motorConfig()->dev.motorPwmProtocol) {
case PWM_TYPE_STANDARD:
motorUpdateRestriction = 1.0f / BRUSHLESS_MOTORS_PWM_RATE;
Expand Down
6 changes: 1 addition & 5 deletions src/main/flight/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/main/target/STM32F405/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@

#define USE_EXTI

#define USE_PID_DENOM_CHECK

#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors
2 changes: 2 additions & 0 deletions src/main/target/STM32F411/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,6 @@

#define USE_EXTI

#define USE_PID_DENOM_CHECK

#define FLASH_PAGE_SIZE ((uint32_t)0x4000) // 16K sectors
4 changes: 4 additions & 0 deletions src/main/target/STM32G47X/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@
#define USE_ESCSERIAL

#define USE_ADC

#define USE_EXTI

#define USE_PID_DENOM_CHECK

#define USE_TIMER_UP_CONFIG