Browse Source

【待优化】解决PID控制不及时问题,电机查询命令降频,陀螺仪改为全局变量(这里有待商议)

paint_robot_new-v1.5
Lizongdi 2 weeks ago
parent
commit
3f43369c55
  1. 3
      RBcore/TL720D.c
  2. 16
      project/paint_robot_new/paint_robot_new_motors.c

3
RBcore/TL720D.c

@ -41,6 +41,7 @@
* 模块级变量 * * 模块级变量 *
*----------------------------------------------*/ *----------------------------------------------*/
static MSP_TL720DParameters g_stTL720D = {0}; static MSP_TL720DParameters g_stTL720D = {0};
volatile int32_t g_RF_Angle_Roll = 0;
/*----------------------------------------------* /*----------------------------------------------*
* 常量定义 * * 常量定义 *
@ -120,12 +121,12 @@ static void decode_TL720D(const char *buf, uint32_t _iSize)
g_stTL720D.RF_Gro_Y = getDeci((uint8_t *)&buf[25]); g_stTL720D.RF_Gro_Y = getDeci((uint8_t *)&buf[25]);
g_stTL720D.RF_Gro_Z = getDeci((uint8_t *)&buf[28]); g_stTL720D.RF_Gro_Z = getDeci((uint8_t *)&buf[28]);
g_RF_Angle_Roll = g_stTL720D.RF_Angle_Roll;
uint32_t uiNowTick = Rd_GetTime(); uint32_t uiNowTick = Rd_GetTime();
if ((int32_t)(uiNowTick - uiLastSendTick) >= 50) if ((int32_t)(uiNowTick - uiLastSendTick) >= 50)
{ {
uiLastSendTick = uiNowTick; uiLastSendTick = uiNowTick;
MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_TL720D_ROLL, (void *)&g_stTL720D.RF_Angle_Roll, sizeof(int32_t)); MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_GET_TL720D_ROLL, (void *)&g_stTL720D.RF_Angle_Roll, sizeof(int32_t));
MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_GET_TL720D_ROLL, (void *)&g_stTL720D.RF_Angle_Roll, sizeof(int32_t));
MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_TL720D, NULL, 0); MsgCenter_SendTo(MODULE_NAME_DAEMON, DAEMON_SET_TL720D, NULL, 0);
} }
} }

16
project/paint_robot_new/paint_robot_new_motors.c

@ -189,6 +189,8 @@ void MotorTask(void *argument)
else if (g_isMotorInit > 0) else if (g_isMotorInit > 0)
{ {
static int LS_Motor_Config_Count = 0; static int LS_Motor_Config_Count = 0;
static int iStatusQueryCycle = 0;
if (LS_Motor_Config_Count <= 200) if (LS_Motor_Config_Count <= 200)
{ {
LS_Motor_Config_Count++; LS_Motor_Config_Count++;
@ -197,6 +199,15 @@ void MotorTask(void *argument)
MotorMgr_SetWatchdog(g_apstMotors[1], 1000); MotorMgr_SetWatchdog(g_apstMotors[1], 1000);
Rd_Delay(4); Rd_Delay(4);
} }
MotorMgr_SetTargetSpeed(g_apstMotors[0], g_aiMotorSpeed[0]);
Rd_Delay(4);
MotorMgr_SetTargetSpeed(g_apstMotors[1], g_aiMotorSpeed[1]);
Rd_Delay(4);
if (++iStatusQueryCycle >= 10)
{
iStatusQueryCycle = 0;
MotorMgr_RequestPosition(g_apstMotors[0]); MotorMgr_RequestPosition(g_apstMotors[0]);
Rd_Delay(4); Rd_Delay(4);
MotorMgr_RequestPosition(g_apstMotors[1]); MotorMgr_RequestPosition(g_apstMotors[1]);
@ -209,10 +220,7 @@ void MotorTask(void *argument)
Rd_Delay(4); Rd_Delay(4);
MotorMgr_RequestVelocity(g_apstMotors[1]); MotorMgr_RequestVelocity(g_apstMotors[1]);
Rd_Delay(4); Rd_Delay(4);
MotorMgr_SetTargetSpeed(g_apstMotors[0], g_aiMotorSpeed[0]); }
Rd_Delay(4);
MotorMgr_SetTargetSpeed(g_apstMotors[1], g_aiMotorSpeed[1]);
Rd_Delay(4);
} }
} }
} }

Loading…
Cancel
Save