diff --git a/Gambal/APP/usart1.c b/Gambal/APP/usart1.c index fbc85ab..eac2a23 100644 --- a/Gambal/APP/usart1.c +++ b/Gambal/APP/usart1.c @@ -2,7 +2,7 @@ //#include "math.h" #include #include -u8 USART_RX_BUF[20]; +u8 USART_RX_BUF[30]; //接收到的数据长度 unsigned short USART_RX_STA=0; //接收状态标志 @@ -41,8 +41,8 @@ unsigned short USART_RX_STA=0; // u32 RX_CNT = 0; u8 f; -u8 x[10]; -u8 y[10]; +u8 x[12]; +u8 y[12]; void USART1_IRQHandler(void) { unsigned char res; @@ -61,8 +61,8 @@ void USART1_IRQHandler(void) else { memcpy(x,USART_RX_BUF,f+1); - memcpy(y,USART_RX_BUF+f+1,20-f-1); - memset(USART_RX_BUF,0,20); + memcpy(y,USART_RX_BUF+f+1,30-f-1); + memset(USART_RX_BUF,0,30); RX_CNT = 0; } } diff --git a/Gambal/APP/usart1.h b/Gambal/APP/usart1.h index a374da5..a07ab19 100644 --- a/Gambal/APP/usart1.h +++ b/Gambal/APP/usart1.h @@ -9,11 +9,11 @@ extern float error; -extern u8 USART_RX_BUF[20]; +extern u8 USART_RX_BUF[30]; //接收到的数据长度 extern unsigned short USART_RX_STA; //接收状态标志 -extern u8 x[10]; -extern u8 y[10]; +extern u8 x[12]; +extern u8 y[12]; void usart1_Init(u32 bound); diff --git a/Gambal/User/main.c b/Gambal/User/main.c index a31a2ce..e48a661 100644 --- a/Gambal/User/main.c +++ b/Gambal/User/main.c @@ -163,7 +163,7 @@ void PID_init(void) // pid_ang_timestamp=SysTick->VAL; // ////////yyyyyyyyyyyy - pid_vel_P=1.5; //0.1 + pid_vel_P=0.8; //0.1 pid_vel_I=0.1; //2 output_vel_ramp=100; integral_vel_prev=0; @@ -172,30 +172,10 @@ void PID_init(void) pid_vel_timestamp=SysTick->VAL; pid_ang_P = 10; - pid_ang_D =0.5; + pid_ang_D =5; error_ang_prev= 0; pid_ang_timestamp=SysTick->VAL; - } -//void commander_run(void) -//{ -// if((USART_RX_STA&0x8000)!=0) -// { -// switch(USART_RX_BUF[0]) -// { - -// case 'y': //D -// target = 0 - atof((const char *)(USART_RX_BUF+1)); -// break; -// case 'x': -// target =atof((const char *)(USART_RX_BUF+1)); -// break; -// -// } - -// USART_RX_STA=0; -// } -//} /******************************************************************************/ float shaftAngle(void) @@ -231,22 +211,6 @@ float LPF_velocity(float x) return y; } /******************************************************************************/ -//void PID_init(void) -//{ -// pid_vel_P=0.2; //0.1 -// pid_vel_I=2.0; //2 -// output_vel_ramp=100; -// integral_vel_prev=0; -// error_vel_prev=0; -// output_vel_prev=0; -// pid_vel_timestamp=SysTick->VAL; -// -// pid_ang_P=20; -// pid_ang_D=0.5; -// error_ang_prev=0; -// pid_ang_timestamp=SysTick->VAL; -//} -/******************************************************************************/ float PID_velocity(float error) { unsigned long now_us; diff --git a/MPU6050/User/main.c b/MPU6050/User/main.c index 1d9ff84..6abdee0 100644 --- a/MPU6050/User/main.c +++ b/MPU6050/User/main.c @@ -39,7 +39,7 @@ int main(void) GetAngle(&MPU6050,&Angle,0.003f); float x = Angle.pitch / 180.f * _PI; float y = Angle.roll / 180.f * _PI; - printf("%.3fy%.3f\r\n",x,y); + printf("%fy%f\r\n",x,y); //// printf("y%.3f\r\n",Angle.roll / 180.f * _PI); // printf("A%dA",i); }