diff --git a/CMakeLists.txt b/CMakeLists.txt index 79d1267..62aec4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,13 +36,15 @@ include_directories( #add_definitions(-DMOTOR_TEST) add_definitions(-DFEATURE_IGNORE_OTHER_MOTOR) +add_definitions(-DGSCHISSENES_HALL) +#add_definitions(-DGSCHISSENE_PWM_FREQ) #add_definitions(-DFEATURE_BUTTON) add_definitions(-DPETERS_PLATINE) -add_definitions(-DHUARN2) +#add_definitions(-DHUARN2) #add_definitions(-DHUARN3) #add_definitions(-DFEATURE_SERIAL_CONTROL) #add_definitions(-DFEATURE_SERIAL_FEEDBACK) -add_definitions(-DLOG_TO_SERIAL) +#add_definitions(-DLOG_TO_SERIAL) add_definitions(-DFEATURE_CAN) #add_definitions(-DCAN_LOG_UNKNOWN_ADDR) add_definitions(-DIS_BACK) diff --git a/config.h b/config.h index 6afe11f..0e1d0d7 100644 --- a/config.h +++ b/config.h @@ -1,6 +1,6 @@ #pragma once -#ifdef PETERS_PLATINE +#ifdef GSCHISSENE_PWM_FREQ #define PWM_FREQ 12000 // PWM frequency in Hz #else #define PWM_FREQ 16000 // PWM frequency in Hz diff --git a/defines.h b/defines.h index 67e30e4..604d407 100644 --- a/defines.h +++ b/defines.h @@ -23,33 +23,57 @@ #include "stm32f1xx_hal.h" #ifdef PETERS_PLATINE +#ifdef GSCHISSENES_HALL + #define LEFT_HALL_U_PIN GPIO_PIN_10 + #define LEFT_HALL_V_PIN GPIO_PIN_11 + #define LEFT_HALL_W_PIN GPIO_PIN_12 +#else #define LEFT_HALL_U_PIN GPIO_PIN_12 #define LEFT_HALL_V_PIN GPIO_PIN_11 #define LEFT_HALL_W_PIN GPIO_PIN_10 +#endif #define LEFT_HALL_U_PORT GPIOC #define LEFT_HALL_V_PORT GPIOC #define LEFT_HALL_W_PORT GPIOC +#ifdef GSCHISSENES_HALL + #define RIGHT_HALL_U_PIN GPIO_PIN_7 + #define RIGHT_HALL_V_PIN GPIO_PIN_6 + #define RIGHT_HALL_W_PIN GPIO_PIN_5 +#else #define RIGHT_HALL_U_PIN GPIO_PIN_5 #define RIGHT_HALL_V_PIN GPIO_PIN_6 #define RIGHT_HALL_W_PIN GPIO_PIN_7 +#endif #define RIGHT_HALL_U_PORT GPIOB #define RIGHT_HALL_V_PORT GPIOB #define RIGHT_HALL_W_PORT GPIOB +#else +#ifdef GSCHISSENES_HALL + #define LEFT_HALL_U_PIN GPIO_PIN_7 + #define LEFT_HALL_V_PIN GPIO_PIN_6 + #define LEFT_HALL_W_PIN GPIO_PIN_5 #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 +#endif #define LEFT_HALL_U_PORT GPIOB #define LEFT_HALL_V_PORT GPIOB #define LEFT_HALL_W_PORT GPIOB +#ifdef GSCHISSENES_HALL + #define RIGHT_HALL_U_PIN GPIO_PIN_12 + #define RIGHT_HALL_V_PIN GPIO_PIN_11 + #define RIGHT_HALL_W_PIN GPIO_PIN_10 +#else #define RIGHT_HALL_U_PIN GPIO_PIN_10 #define RIGHT_HALL_V_PIN GPIO_PIN_11 #define RIGHT_HALL_W_PIN GPIO_PIN_12 +#endif #define RIGHT_HALL_U_PORT GPIOC #define RIGHT_HALL_V_PORT GPIOC diff --git a/main.cpp b/main.cpp index 5e00566..df4565f 100644 --- a/main.cpp +++ b/main.cpp @@ -373,7 +373,9 @@ int main() while ((HAL_GetTick() - tickstart) < wait) { +#ifdef FEATURE_CAN applyIncomingCanMessage(); +#endif } }; @@ -1421,7 +1423,7 @@ void doMotorTest() right.rtP.id_fieldWeakMax = (0 * A2BIT_CONV) << 4; right.rtP.a_phaAdvMax = 40 << 4; - constexpr auto pwmMax = 250; + constexpr auto pwmMax = 400; pwm += dir; if (pwm > pwmMax) {