Files
origincar_controller/HARDWARE/motor.h
cyy_mac 93ca37e36c 完善阿克曼控制与高速串口遥测
- 校正舵机中位、转向符号和阿克曼后轮差速模型\n- 增加航向角速度辅助及遥控通道调试开关\n- 将速度环提升至 200Hz,并按实际 dt 计算 PI 积分\n- 将 IMU 启动校准缩短为 2 秒\n- 为 USART3 增加 DMA 发送和 MCU 采样时间戳
2026-08-12 18:51:48 +08:00

64 lines
1.6 KiB
C
Raw Blame History

#ifndef __MOTOR_H
#define __MOTOR_H
#include "system.h"
/*--------Motor_A control pins--------*/
#define PWM_PORTA1 GPIOB //PWMA
#define PWM_PIN_A1 GPIO_Pin_8 //PWMA
#define PWMA1 TIM10->CCR1 //PWMA
#define PWM_PORTA2 GPIOB //PWMA
#define PWM_PIN_A2 GPIO_Pin_9 //PWMA
#define PWMA2 TIM11->CCR1 //PWMA
/*------------------------------------*/
/*--------Motor_B control pins--------*/
#define PWM_PORTB1 GPIOE //PWMB
#define PWM_PIN_B1 GPIO_Pin_5 //PWMB
#define PWMB1 TIM9->CCR1 //PWMB
#define PWM_PORTB2 GPIOE //PWMB
#define PWM_PIN_B2 GPIO_Pin_6 //PWMB
#define PWMB2 TIM9->CCR2 //PWMB
/*------------------------------------*/
/*--------Motor_C control pins--------*/
#define PWM_PORTC1 GPIOE //PWMC
#define PWM_PIN_C1 GPIO_Pin_11 //PWMC
#define PWMC1 TIM1->CCR2 //PWMC
#define PWM_PORTC2 GPIOE //PWMC
#define PWM_PIN_C2 GPIO_Pin_9 //PWMC
#define PWMC2 TIM1->CCR1 //PWMC
/*------------------------------------*/
/*--------Motor_D control pins--------*/
#define PWM_PORTD1 GPIOE //PWMD
#define PWM_PIN_D1 GPIO_Pin_14 //PWMD
#define PWMD1 TIM1->CCR4 //PWMD
#define PWM_PORTD2 GPIOE //PWMD
#define PWM_PIN_D2 GPIO_Pin_13 //PWMD
#define PWMD2 TIM1->CCR3 //PWMD
/*------------------------------------*/
#define EN PDin(3)
#define Servo_PWM TIM12->CCR2
#define SERVO_INIT 1670 //Servo straight-ahead point (calibrated 1/R~=0) //<2F><>ֱ<EFBFBD><D6B1>ǰ<EFBFBD><C7B0>
void Enable_Pin(void);
void Servo_PWM_Init(u16 arr,u16 psc);
void TIM1_PWM_Init(u16 arr,u16 psc);
void TIM9_PWM_Init(u16 arr,u16 psc);
void TIM10_PWM_Init(u16 arr,u16 psc);
void TIM11_PWM_Init(u16 arr,u16 psc);
#endif