chenged to 2 motor velocity-closed-loop; before testing

This commit is contained in:
2025-11-20 09:50:13 +08:00
parent dd8f7c006f
commit ed09f10c03
13 changed files with 276 additions and 261 deletions

24
empty.c
View File

@@ -50,8 +50,14 @@ const float num_f = 0.123456f;
volatile uint16_t count = 0;
volatile float Target = 20; // 串口目标值
const int pp = 7; // 电机极对数
const int Dir = -1; // 电机编码器方向
int M0_PP = 7, M0_DIR = 1;
int M1_PP = 7, M1_DIR = 1;
int Motor0 = 0;
int Motor1 = 1;
float M0_Target = 20.0; // 串口目标值
float M1_Target = 20.0; // 串口目标值
#define UART_PACKET_SIZE (6)
@@ -108,22 +114,12 @@ int main(void) {
NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
DL_TimerG_startCounter(TIMER_0_INST);
FOC_Init(12.6);
FOC_Init();
DL_SYSTICK_resetValue();
while (1) {
// DL_GPIO_togglePins(LED_PORT, LED_PA0_PIN);
// delay_ms(10);
M0_Set_Velocity(M0_Target); // 速度模式
// 开环
velocityopenloop(Target);
// //test MT6701
// MT6701_get_angle_degree();
// printf("angle degree is %f \n", angle_f);
// // 闭环
// Set_Angle(Target);
if (gCheckUART) {
gCheckUART = false;
parse_uart_cmd();