fix peters platine

This commit is contained in:
Peter Poetzi
2020-10-25 02:27:18 +02:00
committed by Peter
parent 75f7451224
commit f232660cc0
3 changed files with 39 additions and 26 deletions

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#ifdef PETERS_PLATINE #ifdef PETERS_PLATINE
#define PWM_FREQ 10000 // PWM frequency in Hz #define PWM_FREQ 12000 // PWM frequency in Hz
#else #else
#define PWM_FREQ 16000 // PWM frequency in Hz #define PWM_FREQ 16000 // PWM frequency in Hz
#endif #endif

View File

@ -22,21 +22,41 @@
#pragma once #pragma once
#include "stm32f1xx_hal.h" #include "stm32f1xx_hal.h"
#define LEFT_HALL_U_PIN GPIO_PIN_5 #ifdef PETERS_PLATINE
#define LEFT_HALL_V_PIN GPIO_PIN_6 #define LEFT_HALL_U_PIN GPIO_PIN_12
#define LEFT_HALL_W_PIN GPIO_PIN_7 #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_U_PORT GPIOC
#define LEFT_HALL_V_PORT GPIOB #define LEFT_HALL_V_PORT GPIOC
#define LEFT_HALL_W_PORT GPIOB #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 TIM8
#define LEFT_TIM_U CCR1 #define LEFT_TIM_U CCR1
@ -44,24 +64,17 @@
#define LEFT_TIM_UH_PORT GPIOC #define LEFT_TIM_UH_PORT GPIOC
#define LEFT_TIM_UL_PIN GPIO_PIN_7 #define LEFT_TIM_UL_PIN GPIO_PIN_7
#define LEFT_TIM_UL_PORT GPIOA #define LEFT_TIM_UL_PORT GPIOA
#define LEFT_TIM_V CCR2 #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_VH_PIN GPIO_PIN_7
#define LEFT_TIM_VL_PIN GPIO_PIN_0 #define LEFT_TIM_VL_PIN GPIO_PIN_0
#endif
#define LEFT_TIM_VH_PORT GPIOC #define LEFT_TIM_VH_PORT GPIOC
#define LEFT_TIM_VL_PORT GPIOB #define LEFT_TIM_VL_PORT GPIOB
#define LEFT_TIM_W CCR3 #define LEFT_TIM_W CCR3
#define LEFT_TIM_WH_PIN GPIO_PIN_8 #define LEFT_TIM_WH_PIN GPIO_PIN_8
#define LEFT_TIM_WH_PORT GPIOC #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 #define LEFT_TIM_WL_PIN GPIO_PIN_1
#endif
#define LEFT_TIM_WL_PORT GPIOB #define LEFT_TIM_WL_PORT GPIOB
#define RIGHT_TIM TIM1 #define RIGHT_TIM TIM1

View File

@ -236,16 +236,16 @@ int main()
#ifdef MOTOR_TEST #ifdef MOTOR_TEST
left.state.enable = true; left.state.enable = true;
left.state.ctrlMod = ControlMode::Torque; left.state.ctrlMod = ControlMode::Voltage;
left.state.ctrlTyp = ControlType::FieldOrientedControl; left.state.ctrlTyp = ControlType::FieldOrientedControl;
left.state.pwm = pwm; left.state.pwm = pwm;
left.state.iMotMax = 10; left.state.iMotMax = 2;
right.state.enable = true; right.state.enable = true;
right.state.ctrlMod = ControlMode::Torque; right.state.ctrlMod = ControlMode::Voltage;
right.state.ctrlTyp = ControlType::FieldOrientedControl; right.state.ctrlTyp = ControlType::FieldOrientedControl;
right.state.pwm = pwm; right.state.pwm = pwm;
right.state.iMotMax = 10; right.state.iMotMax = 2;
constexpr auto pwmMax = 500; constexpr auto pwmMax = 500;