From f232660cc0b790206d06ef9d4e80e3a52f39f4b5 Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Sun, 25 Oct 2020 02:27:18 +0200 Subject: [PATCH] fix peters platine --- config.h | 2 +- defines.h | 55 ++++++++++++++++++++++++++++++++++--------------------- main.cpp | 8 ++++---- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/config.h b/config.h index ab0efdc..a0cc685 100644 --- a/config.h +++ b/config.h @@ -1,7 +1,7 @@ #pragma once #ifdef PETERS_PLATINE -#define PWM_FREQ 10000 // PWM frequency in Hz +#define PWM_FREQ 12000 // PWM frequency in Hz #else #define PWM_FREQ 16000 // PWM frequency in Hz #endif diff --git a/defines.h b/defines.h index a621dc7..67e30e4 100644 --- a/defines.h +++ b/defines.h @@ -22,21 +22,41 @@ #pragma once #include "stm32f1xx_hal.h" -#define LEFT_HALL_U_PIN GPIO_PIN_5 -#define LEFT_HALL_V_PIN GPIO_PIN_6 -#define LEFT_HALL_W_PIN GPIO_PIN_7 +#ifdef PETERS_PLATINE + #define LEFT_HALL_U_PIN GPIO_PIN_12 + #define LEFT_HALL_V_PIN GPIO_PIN_11 + #define LEFT_HALL_W_PIN GPIO_PIN_10 -#define LEFT_HALL_U_PORT GPIOB -#define LEFT_HALL_V_PORT GPIOB -#define LEFT_HALL_W_PORT GPIOB + #define LEFT_HALL_U_PORT GPIOC + #define LEFT_HALL_V_PORT GPIOC + #define LEFT_HALL_W_PORT GPIOC + + #define RIGHT_HALL_U_PIN GPIO_PIN_5 + #define RIGHT_HALL_V_PIN GPIO_PIN_6 + #define RIGHT_HALL_W_PIN GPIO_PIN_7 + + #define RIGHT_HALL_U_PORT GPIOB + #define RIGHT_HALL_V_PORT GPIOB + #define RIGHT_HALL_W_PORT GPIOB +#else + #define LEFT_HALL_U_PIN GPIO_PIN_5 + #define LEFT_HALL_V_PIN GPIO_PIN_6 + #define LEFT_HALL_W_PIN GPIO_PIN_7 + + #define LEFT_HALL_U_PORT GPIOB + #define LEFT_HALL_V_PORT GPIOB + #define LEFT_HALL_W_PORT GPIOB + + #define RIGHT_HALL_U_PIN GPIO_PIN_10 + #define RIGHT_HALL_V_PIN GPIO_PIN_11 + #define RIGHT_HALL_W_PIN GPIO_PIN_12 + + #define RIGHT_HALL_U_PORT GPIOC + #define RIGHT_HALL_V_PORT GPIOC + #define RIGHT_HALL_W_PORT GPIOC +#endif -#define RIGHT_HALL_U_PIN GPIO_PIN_10 -#define RIGHT_HALL_V_PIN GPIO_PIN_11 -#define RIGHT_HALL_W_PIN GPIO_PIN_12 -#define RIGHT_HALL_U_PORT GPIOC -#define RIGHT_HALL_V_PORT GPIOC -#define RIGHT_HALL_W_PORT GPIOC #define LEFT_TIM TIM8 #define LEFT_TIM_U CCR1 @@ -44,24 +64,17 @@ #define LEFT_TIM_UH_PORT GPIOC #define LEFT_TIM_UL_PIN GPIO_PIN_7 #define LEFT_TIM_UL_PORT GPIOA + #define LEFT_TIM_V CCR2 -#ifdef PETERS_PLATINE -#define LEFT_TIM_VH_PIN GPIO_PIN_8 -#define LEFT_TIM_VL_PIN GPIO_PIN_1 -#else #define LEFT_TIM_VH_PIN GPIO_PIN_7 #define LEFT_TIM_VL_PIN GPIO_PIN_0 -#endif #define LEFT_TIM_VH_PORT GPIOC #define LEFT_TIM_VL_PORT GPIOB + #define LEFT_TIM_W CCR3 #define LEFT_TIM_WH_PIN GPIO_PIN_8 #define LEFT_TIM_WH_PORT GPIOC -#ifdef PETERS_PLATINE -#define LEFT_TIM_WL_PIN GPIO_PIN_0 -#else #define LEFT_TIM_WL_PIN GPIO_PIN_1 -#endif #define LEFT_TIM_WL_PORT GPIOB #define RIGHT_TIM TIM1 diff --git a/main.cpp b/main.cpp index 2c2b757..6673bc8 100644 --- a/main.cpp +++ b/main.cpp @@ -236,16 +236,16 @@ int main() #ifdef MOTOR_TEST left.state.enable = true; - left.state.ctrlMod = ControlMode::Torque; + left.state.ctrlMod = ControlMode::Voltage; left.state.ctrlTyp = ControlType::FieldOrientedControl; left.state.pwm = pwm; - left.state.iMotMax = 10; + left.state.iMotMax = 2; right.state.enable = true; - right.state.ctrlMod = ControlMode::Torque; + right.state.ctrlMod = ControlMode::Voltage; right.state.ctrlTyp = ControlType::FieldOrientedControl; right.state.pwm = pwm; - right.state.iMotMax = 10; + right.state.iMotMax = 2; constexpr auto pwmMax = 500;