Files
foc_Gimbal/APP/mymain.c

59 lines
1.3 KiB
C
Raw Normal View History

2024-01-24 15:56:10 +08:00
//
2024-03-14 16:50:56 +08:00
// Created by lijie on 2024/1/16.
2024-01-24 15:56:10 +08:00
//
#include "mymain.h"
void mymain()
{
2024-02-22 10:16:24 +08:00
HAL_UART_Receive_IT(&huart1, (uint8_t *)g_rx_buffer, RXBUFFERSIZE); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
2024-03-14 16:50:56 +08:00
setvbuf(stdout, NULL, _IONBF, 0); //<2F><><EFBFBD><EFBFBD>printfû<66><C3BB>\n<><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-01-24 15:56:10 +08:00
HAL_Delay(2000);
led_init();
2024-03-08 15:19:23 +08:00
adc_init();
2024-01-24 15:56:10 +08:00
tle5012b_init();
2024-03-08 16:50:42 +08:00
Init_ICM42688();
imu_rest();
2024-01-24 15:56:10 +08:00
moto_Init();
PID_Iint();
float x = 0,y=0;
2024-03-14 16:50:56 +08:00
unsigned int a =0;
2024-01-24 15:56:10 +08:00
HAL_TIM_Base_Start(&htim5); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
2024-03-14 16:50:56 +08:00
while(a<2200*6)
{
MpuGetData();
GetAngle(&ICM42688,&Angle);
// Angel_closed_loop(motorx,&FOCStruct_X,x);
// Angel_closed_loop(motory,&FOCStruct_Y,y);
a++;
}
2024-03-08 15:19:23 +08:00
// LED_ON;
2024-01-24 15:56:10 +08:00
while(1)
{
2024-03-14 16:50:56 +08:00
MpuGetData();
GetAngle(&ICM42688,&Angle);
x = Angle.pitch;
y = Angle.roll + 90.f;
Zitai_closed_loop(motorx,&FOCStruct_X,x);
Zitai_closed_loop(motory,&FOCStruct_Y,-y);
2024-03-08 15:19:23 +08:00
// commander_run();
2024-01-26 15:31:40 +08:00
// x = getAngle(motorx);
// y = getAngle(motory);
2024-01-24 15:56:10 +08:00
// printf("%fY%f\n",x,y);
2024-03-14 16:50:56 +08:00
// HAL_Delay(10);
2024-01-24 15:56:10 +08:00
// speed_closed_loop(motorx,&FOCStruct_X,_2PI*5);
// speed_closed_loop(motory,&FOCStruct_Y,_2PI*2);
// printf("b%d\n",b);
// if(i%3000 ==0)
// {
// printf("%d\n",i);
// }
// i++;
2024-02-22 10:16:24 +08:00
// Data_send(x,y);
2024-01-24 15:56:10 +08:00
// HAL_Delay(3);
}
2024-02-22 10:16:24 +08:00
}