From 7fda52e89d3606c8840181c8ff6c28bf571865cd Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 15 Nov 2022 13:53:04 +0100 Subject: [PATCH 1/2] Made propTestPWMRatio parameter a persistent parameter. --- src/modules/src/health.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/src/health.c b/src/modules/src/health.c index 4e97497166..d153889c88 100644 --- a/src/modules/src/health.c +++ b/src/modules/src/health.c @@ -334,7 +334,7 @@ PARAM_ADD_CORE(PARAM_UINT8, startBatTest, &startBatTest) /** * @brief PWM ratio to use when testing propellers. Required for brushless motors. [0 - UINT16_MAX] */ -PARAM_ADD_CORE(PARAM_UINT16, propTestPWMRatio, &propTestPWMRatio) +PARAM_ADD_CORE(PARAM_UINT16 | PARAM_PERSISTENT, propTestPWMRatio, &propTestPWMRatio) PARAM_GROUP_STOP(health) From e82edd4533a1b862eab038cdc6d7476cdea9153a Mon Sep 17 00:00:00 2001 From: victor Date: Tue, 15 Nov 2022 14:05:06 +0100 Subject: [PATCH 2/2] Moved ENABLE_THRUST_BAT_COMPENSATED define to Kbuild --- src/drivers/interface/motors.h | 4 ---- src/drivers/src/motors.c | 2 +- src/modules/src/Kconfig | 9 +++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/drivers/interface/motors.h b/src/drivers/interface/motors.h index 98050b7490..614601aa81 100644 --- a/src/drivers/interface/motors.h +++ b/src/drivers/interface/motors.h @@ -58,10 +58,6 @@ #define MOTORS_TIM_DBG_CFG DBGMCU_APB2PeriphConfig #define MOTORS_GPIO_AF_CFG(a,b,c) GPIO_PinAFConfig(a,b,c) -// Compensate thrust depending on battery voltage so it will produce about the same -// amount of thrust independent of the battery voltage. Based on thrust measurement. -// Not applied for brushless motor setup. -#define ENABLE_THRUST_BAT_COMPENSATED #ifdef CONFIG_MOTORS_ESC_PROTOCOL_ONESHOT125 /** diff --git a/src/drivers/src/motors.c b/src/drivers/src/motors.c index 66decfbc9a..3fb8c62e7a 100644 --- a/src/drivers/src/motors.c +++ b/src/drivers/src/motors.c @@ -170,7 +170,7 @@ GPIO_InitTypeDef GPIO_PassthroughOutput = // Voltage needed with the Supply voltage. float motorsCompensateBatteryVoltage(uint32_t id, float iThrust, float supplyVoltage) { - #ifdef ENABLE_THRUST_BAT_COMPENSATED + #ifdef CONFIG_ENABLE_THRUST_BAT_COMPENSATED ASSERT(id < NBR_OF_MOTORS); if (motorMap[id]->drvType == BRUSHED) diff --git a/src/modules/src/Kconfig b/src/modules/src/Kconfig index 4826483ce7..9075797cd7 100644 --- a/src/modules/src/Kconfig +++ b/src/modules/src/Kconfig @@ -162,6 +162,15 @@ config POWER_DISTRIBUTION_FLAPPER_REVB help Power distribution function for Flapper Nimble+ with revB PCB +config ENABLE_THRUST_BAT_COMPENSATED + bool "Enable battery thrust compensation" + default y + help + Compensate thrust depending on battery voltage so it will produce about the same + amount of thrust independent of the battery voltage. + The compensation is based on thrust measurements, which are only valid for CF2.X stock configuration. + Not applied for brushless motor setup. + endmenu menu "Parameter subsystem"