加入Bsp_can
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : CAN_Task.c
|
||||
* @brief : CAN task
|
||||
* @author : GrassFam Wang
|
||||
* @date : 2025/1/22
|
||||
* @version : v1.1
|
||||
******************************************************************************
|
||||
* @attention : None
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "cmsis_os.h"
|
||||
#include "CAN_Task.h"
|
||||
#include "Control_Task.h"
|
||||
#include "INS_Task.h"
|
||||
#include "Motor.h"
|
||||
#include "bsp_can.h"
|
||||
#include "Remote_Control.h"
|
||||
#include "Control_Task.h"
|
||||
|
||||
/* USER CODE BEGIN Header_CAN_Task */
|
||||
/**
|
||||
* @brief Function implementing the StartCANTask thread.
|
||||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
/* USER CODE END Header_CAN_Task */
|
||||
|
||||
void CAN_Task(void const * argument)
|
||||
{
|
||||
|
||||
TickType_t CAN_Task_SysTick = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
||||
CAN_Task_SysTick = osKernelSysTick();
|
||||
|
||||
if(CAN_Task_SysTick % 2 == 0){
|
||||
|
||||
//500Hz<48><7A><EFBFBD><EFBFBD> <20>뱣֤<EBB1A3><D6A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>osDelay(1)
|
||||
|
||||
}
|
||||
osDelay(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : Control_Task.c
|
||||
* @brief : Control task
|
||||
* @author : GrassFan Wang
|
||||
* @date : 2025/01/22
|
||||
* @version : v1.1
|
||||
******************************************************************************
|
||||
* @attention : None
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "Control_Task.h"
|
||||
#include "cmsis_os.h"
|
||||
#include "Control_Task.h"
|
||||
#include "bsp_uart.h"
|
||||
#include "Remote_Control.h"
|
||||
#include "PID.h"
|
||||
#include "Motor.h"
|
||||
|
||||
static void Control_Init(Control_Info_Typedef *Control_Info);
|
||||
static void Control_Measure_Update(Control_Info_Typedef *Control_Info);
|
||||
static void Control_Target_Update(Control_Info_Typedef *Control_Info);
|
||||
static void Control_Info_Update(Control_Info_Typedef *Control_Info);
|
||||
|
||||
Control_Info_Typedef Control_Info;
|
||||
// KP KI KD Alpha Deadband I_MAX Output_MAX
|
||||
static float Chassis_PID_Param[7] = {13.f,0.1f,0.f,0.f, 0.f, 5000.f, 12000.f};
|
||||
|
||||
PID_Info_TypeDef Chassis_PID;
|
||||
|
||||
void Control_Task(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN Control_Task */
|
||||
TickType_t Control_Task_SysTick = 0;
|
||||
|
||||
Control_Init(&Control_Info);
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
Control_Task_SysTick = osKernelSysTick();
|
||||
|
||||
|
||||
Control_Measure_Update(&Control_Info);
|
||||
Control_Target_Update(&Control_Info);
|
||||
Control_Info_Update(&Control_Info);
|
||||
USART_Vofa_Justfloat_Transmit(Control_Info.Measure.Chassis_Velocity,0.f,0.f);
|
||||
|
||||
osDelay(1);
|
||||
}
|
||||
}
|
||||
/* USER CODE END Control_Task */
|
||||
|
||||
static void Control_Init(Control_Info_Typedef *Control_Info){
|
||||
|
||||
PID_Init(&Chassis_PID,PID_POSITION,Chassis_PID_Param);
|
||||
|
||||
}
|
||||
|
||||
static void Control_Measure_Update(Control_Info_Typedef *Control_Info){
|
||||
|
||||
Control_Info->Measure.Chassis_Velocity = Chassis_Motor[0].Data.Velocity;
|
||||
|
||||
}
|
||||
|
||||
static void Control_Target_Update(Control_Info_Typedef *Control_Info){
|
||||
|
||||
Control_Info->Target.Chassis_Velocity = remote_ctrl.rc.ch[3] * 5.f;
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void Control_Info_Update(Control_Info_Typedef *Control_Info){
|
||||
|
||||
PID_Calculate(&Chassis_PID, Control_Info->Target.Chassis_Velocity, Control_Info->Measure.Chassis_Velocity);
|
||||
|
||||
Control_Info->SendValue[0] = (int16_t)(Chassis_PID.Output);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user