From e8f0b1fad8f786c3b2682951d12097a9e0c2c09f Mon Sep 17 00:00:00 2001 From: Tobias Antonson Date: Fri, 15 Sep 2023 11:42:40 +0200 Subject: [PATCH] Added brushed support for Bolt 1.1 (HW mod required) --- Kconfig | 9 +++++ src/drivers/interface/motors.h | 1 + src/drivers/src/motors_def.c | 34 +++++++++++++++++++ .../src/controller/position_controller_pid.c | 2 +- src/platform/src/platform_bolt.c | 4 +++ 5 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Kconfig b/Kconfig index 233c6acda9..ada05e298a 100644 --- a/Kconfig +++ b/Kconfig @@ -85,6 +85,15 @@ config PLATFORM_FLAPPER endchoice +config BOLT11_BRUSHED + bool "Bolt 1.1: Use brushed motor driver (HW mod required)" + depends on PLATFORM_BOLT + default n + help + 0R resistors 0402 (or simple wire to short) should be mounted at + R19, R22, R33, R34 and motor override signals will be disabled (high impedance). + Brushed motor should be connected + and - at motor connector (not S). + endmenu menu "IMU configuration" diff --git a/src/drivers/interface/motors.h b/src/drivers/interface/motors.h index 43fd9e1b6b..0a97cfbd7d 100644 --- a/src/drivers/interface/motors.h +++ b/src/drivers/interface/motors.h @@ -259,6 +259,7 @@ extern const MotorPerifDef* motorMapDefaltConBrushless[NBR_OF_MOTORS]; extern const MotorPerifDef* motorMapBigQuadDeck[NBR_OF_MOTORS]; extern const MotorPerifDef* motorMapBoltBrushless[NBR_OF_MOTORS]; extern const MotorPerifDef* motorMapBolt11Brushless[NBR_OF_MOTORS]; +extern const MotorPerifDef* motorMapBolt11Brushed[NBR_OF_MOTORS]; extern const MotorPerifDef* motorMapCF21Brushless[NBR_OF_MOTORS]; /** diff --git a/src/drivers/src/motors_def.c b/src/drivers/src/motors_def.c index 143a44b39f..0e334efdcd 100644 --- a/src/drivers/src/motors_def.c +++ b/src/drivers/src/motors_def.c @@ -112,6 +112,27 @@ static const MotorPerifDef MOTORS_PB9_TIM4_CH4_BRUSHED = .ocInit = TIM_OC4Init, .preloadConfig = TIM_OC4PreloadConfig, }; +// Bolt 1.1 M4, PB10, TIM2_CH3, Brushed config +static const MotorPerifDef MOTORS_PB10_TIM2_CH3_BRUSHED = +{ + .drvType = BRUSHED, + .gpioPerif = RCC_AHB1Periph_GPIOB, + .gpioPort = GPIOB, + .gpioPin = GPIO_Pin_10, + .gpioPinSource = GPIO_PinSource10, + .gpioOType = GPIO_OType_PP, + .gpioAF = GPIO_AF_TIM2, + .timPerif = RCC_APB1Periph_TIM2, + .tim = TIM2, + .timPolarity = TIM_OCPolarity_High, + .timDbgStop = DBGMCU_TIM2_STOP, + .timPeriod = MOTORS_PWM_PERIOD, + .timPrescaler = MOTORS_PWM_PRESCALE, + .setCompare = TIM_SetCompare3, + .getCompare = TIM_GetCapture3, + .ocInit = TIM_OC3Init, + .preloadConfig = TIM_OC3PreloadConfig, +}; // CF2.X connector M1, PA1, TIM2_CH2, Brushless config, inversed static const MotorPerifDef MOTORS_PA1_TIM2_CH2_BRUSHLESS_INV_PP = @@ -760,6 +781,19 @@ const MotorPerifDef* motorMapBolt11Brushless[NBR_OF_MOTORS] = &MOTORS_PB10_TIM2_CH3_BRUSHLESS_PP }; +/** + * Brushed motors mapped to the Bolt 1.1 PWM outputs. + * 0R resistors 0402 should be mounted at R19, R22, R33, R34 and + * motor override signals will be disabled (high impedance). + */ +const MotorPerifDef* motorMapBolt11Brushed[NBR_OF_MOTORS] = +{ + &MOTORS_PA1_TIM2_CH2_BRUSHED, + &MOTORS_PB11_TIM2_CH4_BRUSHED, + &MOTORS_PA15_TIM2_CH1_BRUSHED, + &MOTORS_PB10_TIM2_CH3_BRUSHED +}; + /** * Brushless motors mapped to the Bolt Rev.F PWM outputs. */ diff --git a/src/modules/src/controller/position_controller_pid.c b/src/modules/src/controller/position_controller_pid.c index a706e059fd..9dfb66148d 100644 --- a/src/modules/src/controller/position_controller_pid.c +++ b/src/modules/src/controller/position_controller_pid.c @@ -524,7 +524,7 @@ PARAM_GROUP_START(posCtlPid) */ PARAM_ADD(PARAM_FLOAT | PARAM_PERSISTENT, xKp, &this.pidX.pid.kp) /** - * @brief Proportional gain for the position PID in the body-yaw-aligned X direction + * @brief Integral gain for the position PID in the body-yaw-aligned X direction */ PARAM_ADD(PARAM_FLOAT | PARAM_PERSISTENT, xKi, &this.pidX.pid.ki) /** diff --git a/src/platform/src/platform_bolt.c b/src/platform/src/platform_bolt.c index 6a08cd5459..9421dfd266 100644 --- a/src/platform/src/platform_bolt.c +++ b/src/platform/src/platform_bolt.c @@ -56,7 +56,11 @@ static platformConfig_t configs[] = { .deviceTypeName = "Crazyflie Bolt 1.1", .sensorImplementation = SensorImplementation_bmi088_spi_bmp388, .physicalLayoutAntennasAreClose = false, + #ifdef CONFIG_BOLT11_BRUSHED + .motorMap = motorMapBolt11Brushed, + #else .motorMap = motorMapBolt11Brushless, + #endif } #endif };