chassis修改(有个舵反馈有问题)
This commit is contained in:
parent
a21e807ba6
commit
d678da76b0
@ -68,10 +68,6 @@ void Error_Handler(void);
|
|||||||
#define LED_Green_GPIO_Port GPIOH
|
#define LED_Green_GPIO_Port GPIOH
|
||||||
#define LED_Blue_Pin GPIO_PIN_10
|
#define LED_Blue_Pin GPIO_PIN_10
|
||||||
#define LED_Blue_GPIO_Port GPIOH
|
#define LED_Blue_GPIO_Port GPIOH
|
||||||
#define PUL_N_Pin GPIO_PIN_2
|
|
||||||
#define PUL_N_GPIO_Port GPIOC
|
|
||||||
#define DIR_N_Pin GPIO_PIN_2
|
|
||||||
#define DIR_N_GPIO_Port GPIOB
|
|
||||||
#define USER_KEY_Pin GPIO_PIN_0
|
#define USER_KEY_Pin GPIO_PIN_0
|
||||||
#define USER_KEY_GPIO_Port GPIOA
|
#define USER_KEY_GPIO_Port GPIOA
|
||||||
#define USER_KEY_EXTI_IRQn EXTI0_IRQn
|
#define USER_KEY_EXTI_IRQn EXTI0_IRQn
|
||||||
@ -83,8 +79,8 @@ void Error_Handler(void);
|
|||||||
#define GYRO_INT_Pin GPIO_PIN_5
|
#define GYRO_INT_Pin GPIO_PIN_5
|
||||||
#define GYRO_INT_GPIO_Port GPIOC
|
#define GYRO_INT_GPIO_Port GPIOC
|
||||||
#define GYRO_INT_EXTI_IRQn EXTI9_5_IRQn
|
#define GYRO_INT_EXTI_IRQn EXTI9_5_IRQn
|
||||||
#define DIR_P_Pin GPIO_PIN_1
|
#define DIR_P_Pin GPIO_PIN_11
|
||||||
#define DIR_P_GPIO_Port GPIOB
|
#define DIR_P_GPIO_Port GPIOE
|
||||||
#define GYRO_CS_Pin GPIO_PIN_0
|
#define GYRO_CS_Pin GPIO_PIN_0
|
||||||
#define GYRO_CS_GPIO_Port GPIOB
|
#define GYRO_CS_GPIO_Port GPIOB
|
||||||
|
|
||||||
|
|||||||
@ -61,7 +61,7 @@ void CAN1_TX_IRQHandler(void);
|
|||||||
void CAN1_RX0_IRQHandler(void);
|
void CAN1_RX0_IRQHandler(void);
|
||||||
void CAN1_RX1_IRQHandler(void);
|
void CAN1_RX1_IRQHandler(void);
|
||||||
void EXTI9_5_IRQHandler(void);
|
void EXTI9_5_IRQHandler(void);
|
||||||
void TIM1_UP_TIM10_IRQHandler(void);
|
void TIM1_BRK_TIM9_IRQHandler(void);
|
||||||
void USART1_IRQHandler(void);
|
void USART1_IRQHandler(void);
|
||||||
void USART3_IRQHandler(void);
|
void USART3_IRQHandler(void);
|
||||||
void DMA2_Stream1_IRQHandler(void);
|
void DMA2_Stream1_IRQHandler(void);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ extern "C" {
|
|||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim8;
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim10;
|
extern TIM_HandleTypeDef htim10;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ extern TIM_HandleTypeDef htim10;
|
|||||||
|
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
void MX_TIM8_Init(void);
|
void MX_TIM1_Init(void);
|
||||||
void MX_TIM10_Init(void);
|
void MX_TIM10_Init(void);
|
||||||
|
|
||||||
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
||||||
|
|||||||
@ -49,7 +49,7 @@ void MX_CAN1_Init(void)
|
|||||||
hcan1.Init.AutoWakeUp = DISABLE;
|
hcan1.Init.AutoWakeUp = DISABLE;
|
||||||
hcan1.Init.AutoRetransmission = ENABLE;
|
hcan1.Init.AutoRetransmission = ENABLE;
|
||||||
hcan1.Init.ReceiveFifoLocked = DISABLE;
|
hcan1.Init.ReceiveFifoLocked = DISABLE;
|
||||||
hcan1.Init.TransmitFifoPriority = DISABLE;
|
hcan1.Init.TransmitFifoPriority = ENABLE;
|
||||||
if (HAL_CAN_Init(&hcan1) != HAL_OK)
|
if (HAL_CAN_Init(&hcan1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
@ -81,7 +81,7 @@ void MX_CAN2_Init(void)
|
|||||||
hcan2.Init.AutoWakeUp = DISABLE;
|
hcan2.Init.AutoWakeUp = DISABLE;
|
||||||
hcan2.Init.AutoRetransmission = ENABLE;
|
hcan2.Init.AutoRetransmission = ENABLE;
|
||||||
hcan2.Init.ReceiveFifoLocked = DISABLE;
|
hcan2.Init.ReceiveFifoLocked = DISABLE;
|
||||||
hcan2.Init.TransmitFifoPriority = DISABLE;
|
hcan2.Init.TransmitFifoPriority = ENABLE;
|
||||||
if (HAL_CAN_Init(&hcan2) != HAL_OK)
|
if (HAL_CAN_Init(&hcan2) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
@ -146,10 +146,10 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle)
|
|||||||
|
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
/**CAN2 GPIO Configuration
|
/**CAN2 GPIO Configuration
|
||||||
|
PB5 ------> CAN2_RX
|
||||||
PB6 ------> CAN2_TX
|
PB6 ------> CAN2_TX
|
||||||
PB12 ------> CAN2_RX
|
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_12;
|
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_6;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||||
@ -210,10 +210,10 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**CAN2 GPIO Configuration
|
/**CAN2 GPIO Configuration
|
||||||
|
PB5 ------> CAN2_RX
|
||||||
PB6 ------> CAN2_TX
|
PB6 ------> CAN2_TX
|
||||||
PB12 ------> CAN2_RX
|
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_12);
|
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_5|GPIO_PIN_6);
|
||||||
|
|
||||||
/* CAN2 interrupt Deinit */
|
/* CAN2 interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(CAN2_TX_IRQn);
|
HAL_NVIC_DisableIRQ(CAN2_TX_IRQn);
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
* Output
|
* Output
|
||||||
* EVENT_OUT
|
* EVENT_OUT
|
||||||
* EXTI
|
* EXTI
|
||||||
|
PC7 ------> S_TIM8_CH2
|
||||||
*/
|
*/
|
||||||
void MX_GPIO_Init(void)
|
void MX_GPIO_Init(void)
|
||||||
{
|
{
|
||||||
@ -52,6 +53,7 @@ void MX_GPIO_Init(void)
|
|||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOF_CLK_ENABLE();
|
__HAL_RCC_GPIOF_CLK_ENABLE();
|
||||||
__HAL_RCC_GPIOH_CLK_ENABLE();
|
__HAL_RCC_GPIOH_CLK_ENABLE();
|
||||||
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(CMPS_RST_GPIO_Port, CMPS_RST_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(CMPS_RST_GPIO_Port, CMPS_RST_Pin, GPIO_PIN_RESET);
|
||||||
@ -59,18 +61,23 @@ void MX_GPIO_Init(void)
|
|||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GPIOH, LED_Red_Pin|LED_Green_Pin|LED_Blue_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(GPIOH, LED_Red_Pin|LED_Green_Pin|LED_Blue_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
|
||||||
HAL_GPIO_WritePin(PUL_N_GPIO_Port, PUL_N_Pin, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
|
||||||
HAL_GPIO_WritePin(GPIOB, DIR_N_Pin|DIR_P_Pin, GPIO_PIN_RESET);
|
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(ACCL_CS_GPIO_Port, ACCL_CS_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(ACCL_CS_GPIO_Port, ACCL_CS_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin Output Level */
|
||||||
|
HAL_GPIO_WritePin(DIR_P_GPIO_Port, DIR_P_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
HAL_GPIO_WritePin(GYRO_CS_GPIO_Port, GYRO_CS_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(GYRO_CS_GPIO_Port, GYRO_CS_Pin, GPIO_PIN_SET);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : PC7 */
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_7;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
|
||||||
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pin : CMPS_RST_Pin */
|
/*Configure GPIO pin : CMPS_RST_Pin */
|
||||||
GPIO_InitStruct.Pin = CMPS_RST_Pin;
|
GPIO_InitStruct.Pin = CMPS_RST_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
@ -91,20 +98,6 @@ void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
HAL_GPIO_Init(CMPS_INT_GPIO_Port, &GPIO_InitStruct);
|
HAL_GPIO_Init(CMPS_INT_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pin : PUL_N_Pin */
|
|
||||||
GPIO_InitStruct.Pin = PUL_N_Pin;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(PUL_N_GPIO_Port, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/*Configure GPIO pins : DIR_N_Pin DIR_P_Pin */
|
|
||||||
GPIO_InitStruct.Pin = DIR_N_Pin|DIR_P_Pin;
|
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
|
||||||
|
|
||||||
/*Configure GPIO pin : USER_KEY_Pin */
|
/*Configure GPIO pin : USER_KEY_Pin */
|
||||||
GPIO_InitStruct.Pin = USER_KEY_Pin;
|
GPIO_InitStruct.Pin = USER_KEY_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
|
||||||
@ -124,6 +117,13 @@ void MX_GPIO_Init(void)
|
|||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/*Configure GPIO pin : DIR_P_Pin */
|
||||||
|
GPIO_InitStruct.Pin = DIR_P_Pin;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(DIR_P_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
/*Configure GPIO pin : GYRO_CS_Pin */
|
/*Configure GPIO pin : GYRO_CS_Pin */
|
||||||
GPIO_InitStruct.Pin = GYRO_CS_Pin;
|
GPIO_InitStruct.Pin = GYRO_CS_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
|||||||
@ -105,7 +105,7 @@ int main(void)
|
|||||||
MX_USART3_UART_Init();
|
MX_USART3_UART_Init();
|
||||||
MX_TIM10_Init();
|
MX_TIM10_Init();
|
||||||
MX_USART6_UART_Init();
|
MX_USART6_UART_Init();
|
||||||
MX_TIM8_Init();
|
MX_TIM1_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|||||||
@ -62,7 +62,7 @@ extern CAN_HandleTypeDef hcan1;
|
|||||||
extern CAN_HandleTypeDef hcan2;
|
extern CAN_HandleTypeDef hcan2;
|
||||||
extern DMA_HandleTypeDef hdma_spi1_rx;
|
extern DMA_HandleTypeDef hdma_spi1_rx;
|
||||||
extern DMA_HandleTypeDef hdma_spi1_tx;
|
extern DMA_HandleTypeDef hdma_spi1_tx;
|
||||||
extern TIM_HandleTypeDef htim10;
|
extern TIM_HandleTypeDef htim1;
|
||||||
extern DMA_HandleTypeDef hdma_usart3_rx;
|
extern DMA_HandleTypeDef hdma_usart3_rx;
|
||||||
extern DMA_HandleTypeDef hdma_usart6_rx;
|
extern DMA_HandleTypeDef hdma_usart6_rx;
|
||||||
extern DMA_HandleTypeDef hdma_usart6_tx;
|
extern DMA_HandleTypeDef hdma_usart6_tx;
|
||||||
@ -306,17 +306,17 @@ void EXTI9_5_IRQHandler(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
* @brief This function handles TIM1 break interrupt and TIM9 global interrupt.
|
||||||
*/
|
*/
|
||||||
void TIM1_UP_TIM10_IRQHandler(void)
|
void TIM1_BRK_TIM9_IRQHandler(void)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
|
/* USER CODE BEGIN TIM1_BRK_TIM9_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM1_UP_TIM10_IRQn 0 */
|
/* USER CODE END TIM1_BRK_TIM9_IRQn 0 */
|
||||||
HAL_TIM_IRQHandler(&htim10);
|
HAL_TIM_IRQHandler(&htim1);
|
||||||
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
|
/* USER CODE BEGIN TIM1_BRK_TIM9_IRQn 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
|
/* USER CODE END TIM1_BRK_TIM9_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
132
Core/Src/tim.c
132
Core/Src/tim.c
@ -24,48 +24,48 @@
|
|||||||
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
TIM_HandleTypeDef htim8;
|
TIM_HandleTypeDef htim1;
|
||||||
TIM_HandleTypeDef htim10;
|
TIM_HandleTypeDef htim10;
|
||||||
|
|
||||||
/* TIM8 init function */
|
/* TIM1 init function */
|
||||||
void MX_TIM8_Init(void)
|
void MX_TIM1_Init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM8_Init 0 */
|
/* USER CODE BEGIN TIM1_Init 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_Init 0 */
|
/* USER CODE END TIM1_Init 0 */
|
||||||
|
|
||||||
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
TIM_OC_InitTypeDef sConfigOC = {0};
|
TIM_OC_InitTypeDef sConfigOC = {0};
|
||||||
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
|
TIM_BreakDeadTimeConfigTypeDef sBreakDeadTimeConfig = {0};
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM8_Init 1 */
|
/* USER CODE BEGIN TIM1_Init 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_Init 1 */
|
/* USER CODE END TIM1_Init 1 */
|
||||||
htim8.Instance = TIM8;
|
htim1.Instance = TIM1;
|
||||||
htim8.Init.Prescaler = 167;
|
htim1.Init.Prescaler = 167;
|
||||||
htim8.Init.CounterMode = TIM_COUNTERMODE_UP;
|
htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
htim8.Init.Period = 19999;
|
htim1.Init.Period = 19999;
|
||||||
htim8.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
htim8.Init.RepetitionCounter = 0;
|
htim1.Init.RepetitionCounter = 0;
|
||||||
htim8.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
if (HAL_TIM_Base_Init(&htim8) != HAL_OK)
|
if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
if (HAL_TIM_ConfigClockSource(&htim8, &sClockSourceConfig) != HAL_OK)
|
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
if (HAL_TIM_PWM_Init(&htim8) != HAL_OK)
|
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
if (HAL_TIMEx_MasterConfigSynchronization(&htim8, &sMasterConfig) != HAL_OK)
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
@ -76,7 +76,7 @@ void MX_TIM8_Init(void)
|
|||||||
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
|
||||||
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
|
||||||
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
|
||||||
if (HAL_TIM_PWM_ConfigChannel(&htim8, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
|
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
@ -87,14 +87,14 @@ void MX_TIM8_Init(void)
|
|||||||
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
|
||||||
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
sBreakDeadTimeConfig.BreakPolarity = TIM_BREAKPOLARITY_HIGH;
|
||||||
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
|
||||||
if (HAL_TIMEx_ConfigBreakDeadTime(&htim8, &sBreakDeadTimeConfig) != HAL_OK)
|
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK)
|
||||||
{
|
{
|
||||||
Error_Handler();
|
Error_Handler();
|
||||||
}
|
}
|
||||||
/* USER CODE BEGIN TIM8_Init 2 */
|
/* USER CODE BEGIN TIM1_Init 2 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_Init 2 */
|
/* USER CODE END TIM1_Init 2 */
|
||||||
HAL_TIM_MspPostInit(&htim8);
|
HAL_TIM_MspPostInit(&htim1);
|
||||||
|
|
||||||
}
|
}
|
||||||
/* TIM10 init function */
|
/* TIM10 init function */
|
||||||
@ -142,16 +142,33 @@ void MX_TIM10_Init(void)
|
|||||||
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(tim_baseHandle->Instance==TIM8)
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
if(tim_baseHandle->Instance==TIM1)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM8_MspInit 0 */
|
/* USER CODE BEGIN TIM1_MspInit 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_MspInit 0 */
|
/* USER CODE END TIM1_MspInit 0 */
|
||||||
/* TIM8 clock enable */
|
/* TIM1 clock enable */
|
||||||
__HAL_RCC_TIM8_CLK_ENABLE();
|
__HAL_RCC_TIM1_CLK_ENABLE();
|
||||||
/* USER CODE BEGIN TIM8_MspInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END TIM8_MspInit 1 */
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
|
/**TIM1 GPIO Configuration
|
||||||
|
PE13 ------> TIM1_CH3
|
||||||
|
PE14 ------> TIM1_CH4
|
||||||
|
*/
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
|
||||||
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* TIM1 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(TIM1_BRK_TIM9_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(TIM1_BRK_TIM9_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM1_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspInit 1 */
|
||||||
}
|
}
|
||||||
else if(tim_baseHandle->Instance==TIM10)
|
else if(tim_baseHandle->Instance==TIM10)
|
||||||
{
|
{
|
||||||
@ -160,10 +177,6 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||||||
/* USER CODE END TIM10_MspInit 0 */
|
/* USER CODE END TIM10_MspInit 0 */
|
||||||
/* TIM10 clock enable */
|
/* TIM10 clock enable */
|
||||||
__HAL_RCC_TIM10_CLK_ENABLE();
|
__HAL_RCC_TIM10_CLK_ENABLE();
|
||||||
|
|
||||||
/* TIM10 interrupt Init */
|
|
||||||
HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 5, 0);
|
|
||||||
HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
|
|
||||||
/* USER CODE BEGIN TIM10_MspInit 1 */
|
/* USER CODE BEGIN TIM10_MspInit 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM10_MspInit 1 */
|
/* USER CODE END TIM10_MspInit 1 */
|
||||||
@ -173,25 +186,25 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
|||||||
{
|
{
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
if(timHandle->Instance==TIM8)
|
if(timHandle->Instance==TIM1)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM8_MspPostInit 0 */
|
/* USER CODE BEGIN TIM1_MspPostInit 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_MspPostInit 0 */
|
/* USER CODE END TIM1_MspPostInit 0 */
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
/**TIM8 GPIO Configuration
|
/**TIM1 GPIO Configuration
|
||||||
PC7 ------> TIM8_CH2
|
PE9 ------> TIM1_CH1
|
||||||
*/
|
*/
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_7;
|
GPIO_InitStruct.Pin = GPIO_PIN_9;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
|
GPIO_InitStruct.Alternate = GPIO_AF1_TIM1;
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* USER CODE BEGIN TIM8_MspPostInit 1 */
|
/* USER CODE BEGIN TIM1_MspPostInit 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_MspPostInit 1 */
|
/* USER CODE END TIM1_MspPostInit 1 */
|
||||||
}
|
}
|
||||||
else if(timHandle->Instance==TIM10)
|
else if(timHandle->Instance==TIM10)
|
||||||
{
|
{
|
||||||
@ -220,16 +233,26 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
|
|||||||
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(tim_baseHandle->Instance==TIM8)
|
if(tim_baseHandle->Instance==TIM1)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM8_MspDeInit 0 */
|
/* USER CODE BEGIN TIM1_MspDeInit 0 */
|
||||||
|
|
||||||
/* USER CODE END TIM8_MspDeInit 0 */
|
/* USER CODE END TIM1_MspDeInit 0 */
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_TIM8_CLK_DISABLE();
|
__HAL_RCC_TIM1_CLK_DISABLE();
|
||||||
/* USER CODE BEGIN TIM8_MspDeInit 1 */
|
|
||||||
|
|
||||||
/* USER CODE END TIM8_MspDeInit 1 */
|
/**TIM1 GPIO Configuration
|
||||||
|
PE13 ------> TIM1_CH3
|
||||||
|
PE9 ------> TIM1_CH1
|
||||||
|
PE14 ------> TIM1_CH4
|
||||||
|
*/
|
||||||
|
HAL_GPIO_DeInit(GPIOE, GPIO_PIN_13|GPIO_PIN_9|GPIO_PIN_14);
|
||||||
|
|
||||||
|
/* TIM1 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(TIM1_BRK_TIM9_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM1_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM1_MspDeInit 1 */
|
||||||
}
|
}
|
||||||
else if(tim_baseHandle->Instance==TIM10)
|
else if(tim_baseHandle->Instance==TIM10)
|
||||||
{
|
{
|
||||||
@ -238,9 +261,6 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
|||||||
/* USER CODE END TIM10_MspDeInit 0 */
|
/* USER CODE END TIM10_MspDeInit 0 */
|
||||||
/* Peripheral clock disable */
|
/* Peripheral clock disable */
|
||||||
__HAL_RCC_TIM10_CLK_DISABLE();
|
__HAL_RCC_TIM10_CLK_DISABLE();
|
||||||
|
|
||||||
/* TIM10 interrupt Deinit */
|
|
||||||
HAL_NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn);
|
|
||||||
/* USER CODE BEGIN TIM10_MspDeInit 1 */
|
/* USER CODE BEGIN TIM10_MspDeInit 1 */
|
||||||
|
|
||||||
/* USER CODE END TIM10_MspDeInit 1 */
|
/* USER CODE END TIM10_MspDeInit 1 */
|
||||||
|
|||||||
4
MDK-ARM/.vscode/keil-assistant.log
vendored
4
MDK-ARM/.vscode/keil-assistant.log
vendored
@ -44,3 +44,7 @@
|
|||||||
|
|
||||||
[info] Log at : 2026/1/21|22:02:02|GMT+0800
|
[info] Log at : 2026/1/21|22:02:02|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2026/2/4|15:19:28|GMT+0800
|
||||||
|
|
||||||
|
[info] Log at : 2026/2/4|15:19:33|GMT+0800
|
||||||
|
|
||||||
|
|||||||
17
MDK-ARM/.vscode/uv4.log
vendored
17
MDK-ARM/.vscode/uv4.log
vendored
@ -1,16 +1 @@
|
|||||||
*** Using Compiler 'V6.16', folder: 'D:\Keil_v5\ARM\ARMCLANG\Bin'
|
Load "Steering Wheel_Infatry\\Steering Wheel_Infatry.axf"
|
||||||
Build target 'Steering Wheel_Infatry'
|
|
||||||
Note: source file '..\User\bsp\can.c' - object file renamed from 'Steering Wheel_Infatry\can.o' to 'Steering Wheel_Infatry\can_1.o'.Note: source file '..\User\bsp\gpio.c' - object file renamed from 'Steering Wheel_Infatry\gpio.o' to 'Steering Wheel_Infatry\gpio_1.o'.Note: source file '..\User\bsp\i2c.c' - object file renamed from 'Steering Wheel_Infatry\i2c.o' to 'Steering Wheel_Infatry\i2c_1.o'.Note: source file '..\User\bsp\spi.c' - object file renamed from 'Steering Wheel_Infatry\spi.o' to 'Steering Wheel_Infatry\spi_1.o'.Note: source file '..\User\task\ai.c' - object file renamed from 'Steering Wheel_Infatry\ai.o' to 'Steering Wheel_Infatry\ai_1.o'.Note: source file '..\User\task\ET16s.c' - object file renamed from 'Steering Wheel_Infatry\ET16s.o' to 'Steering Wheel_Infatry\et16s_1.o'.Note: source file '..\User\task\dr16.c' - object file renamed from 'Steering Wheel_Infatry\dr16.o' to 'Steering Wheel_Infatry\dr16_1.o'.Note: source file '..\User\task\step_motor.c' - object file renamed from 'Steering Wheel_Infatry\step_motor.o' to 'Steering Wheel_Infatry\step_motor_1.o'.Note: source file '..\User\module\cmd\cmd.c' - object file renamed from 'Steering Wheel_Infatry\cmd.o' to 'Steering Wheel_Infatry\cmd_1.o'.../User/module/cmd/cmd_adapter.c(12): warning: 'CMD_RC_DEVICE_TYPE' macro redefined [-Wmacro-redefined]
|
|
||||||
#define CMD_RC_DEVICE_TYPE 2
|
|
||||||
^
|
|
||||||
../User/module/cmd/cmd_adapter.h(73): note: previous definition is here
|
|
||||||
#define CMD_RC_DEVICE_TYPE 3 /* 0:DR16, 1:AT9S, 2:VT13 */
|
|
||||||
^
|
|
||||||
../User/module/cmd/cmd_adapter.c(157): error: use of undeclared identifier 'g_adapter_ET916s'
|
|
||||||
CMD_Adapter_Register(&g_adapter_ET916s);
|
|
||||||
^
|
|
||||||
1 warning and 1 error generated.
|
|
||||||
compiling cmd_adapter.c...
|
|
||||||
"Steering Wheel_Infatry\Steering Wheel_Infatry.axf" - 1 Error(s), 1 Warning(s).
|
|
||||||
Target not created.
|
|
||||||
Build Time Elapsed: 00:00:03
|
|
||||||
|
|||||||
2
MDK-ARM/.vscode/uv4.log.lock
vendored
2
MDK-ARM/.vscode/uv4.log.lock
vendored
@ -1 +1 @@
|
|||||||
2026/1/21 23:45:46
|
2026/2/4 15:19:52
|
||||||
35471
MDK-ARM/JLinkLog.txt
35471
MDK-ARM/JLinkLog.txt
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -120,11 +120,12 @@
|
|||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>DLGUARM</Key>
|
<Key>DLGUARM</Key>
|
||||||
|
<Name>榶?p</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
<Key>JL2CM3</Key>
|
<Key>JL2CM3</Key>
|
||||||
<Name>-U20760100 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
<Name>-U20760100 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||||
</SetRegEntry>
|
</SetRegEntry>
|
||||||
<SetRegEntry>
|
<SetRegEntry>
|
||||||
<Number>0</Number>
|
<Number>0</Number>
|
||||||
@ -239,6 +240,11 @@
|
|||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>shoot</ItemText>
|
<ItemText>shoot</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>16</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>cmd_et16s1</ItemText>
|
||||||
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<Tracepoint>
|
<Tracepoint>
|
||||||
<THDelay>0</THDelay>
|
<THDelay>0</THDelay>
|
||||||
@ -1142,7 +1148,7 @@
|
|||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>device</GroupName>
|
<GroupName>device</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
|||||||
Binary file not shown.
@ -22,7 +22,7 @@ Dialog DLL: TCM.DLL V1.48.0.0
|
|||||||
|
|
||||||
<h2>Project:</h2>
|
<h2>Project:</h2>
|
||||||
D:\yunha\git_gimbal\RM\Steering Wheel_Infatry\MDK-ARM\Steering Wheel_Infatry.uvprojx
|
D:\yunha\git_gimbal\RM\Steering Wheel_Infatry\MDK-ARM\Steering Wheel_Infatry.uvprojx
|
||||||
Project File Date: 01/28/2026
|
Project File Date: 02/07/2026
|
||||||
|
|
||||||
<h2>Output:</h2>
|
<h2>Output:</h2>
|
||||||
*** Using Compiler 'V6.16', folder: 'D:\Keil_v5\ARM\ARMCLANG\Bin'
|
*** Using Compiler 'V6.16', folder: 'D:\Keil_v5\ARM\ARMCLANG\Bin'
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -61,4 +61,5 @@ steering\ wheel_infatry/init.o: ..\User\task\init.c \
|
|||||||
..\User\device\bmi088.h ..\User\component\user_math.h \
|
..\User\device\bmi088.h ..\User\component\user_math.h \
|
||||||
..\User\module\shoot.h ..\Core\Inc\main.h ..\User\device\dr16.h \
|
..\User\module\shoot.h ..\Core\Inc\main.h ..\User\device\dr16.h \
|
||||||
..\User\device\device.h ..\User\device\et16s.h \
|
..\User\device\device.h ..\User\device\et16s.h \
|
||||||
..\User\device\motor_step.h
|
..\User\device\motor_step.h ..\User\bsp\pwm.h ..\Core\Inc\tim.h \
|
||||||
|
..\User\bsp\bsp.h
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -13,6 +13,39 @@ steering\ wheel_infatry/step_motor_1.o: ..\User\task\step_motor.c \
|
|||||||
..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h \
|
..\Middlewares\Third_Party\FreeRTOS\Source\include\task.h \
|
||||||
..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h \
|
..\Middlewares\Third_Party\FreeRTOS\Source\include\list.h \
|
||||||
..\User\device\motor_step.h \
|
..\User\device\motor_step.h \
|
||||||
D:\Keil_v5\ARM\ARMCLANG\Bin\..\include\stdbool.h \
|
D:\Keil_v5\ARM\ARMCLANG\Bin\..\include\stdbool.h ..\User\bsp\pwm.h \
|
||||||
..\User\device\ET16s.h ..\User\device\device.h ..\User\bsp\gpio.h \
|
..\Core\Inc\tim.h ..\Core\Inc\main.h \
|
||||||
..\User\bsp\bsp.h
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h \
|
||||||
|
..\Core\Inc\stm32f4xx_hal_conf.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_def.h \
|
||||||
|
..\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h \
|
||||||
|
..\Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f407xx.h \
|
||||||
|
..\Drivers\CMSIS\Include\core_cm4.h \
|
||||||
|
..\Drivers\CMSIS\Include\cmsis_version.h \
|
||||||
|
..\Drivers\CMSIS\Include\cmsis_compiler.h \
|
||||||
|
..\Drivers\CMSIS\Include\cmsis_armclang.h \
|
||||||
|
..\Drivers\CMSIS\Include\mpu_armv7.h \
|
||||||
|
..\Drivers\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_exti.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_cortex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_can.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ramfunc.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_i2c.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_i2c_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_spi.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim_ex.h \
|
||||||
|
..\Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h \
|
||||||
|
..\User\bsp\bsp.h ..\User\device\ET16s.h ..\User\device\device.h \
|
||||||
|
..\User\bsp\gpio.h ..\User\bsp\bsp.h
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,18 +7,20 @@ CAN1.BS2=CAN_BS2_3TQ
|
|||||||
CAN1.CalculateBaudRate=1000000
|
CAN1.CalculateBaudRate=1000000
|
||||||
CAN1.CalculateTimeBit=1000
|
CAN1.CalculateTimeBit=1000
|
||||||
CAN1.CalculateTimeQuantum=71.42857142857143
|
CAN1.CalculateTimeQuantum=71.42857142857143
|
||||||
CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,Prescaler,BS2,NART,SJW
|
CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,Prescaler,BS2,NART,SJW,TXFP
|
||||||
CAN1.NART=ENABLE
|
CAN1.NART=ENABLE
|
||||||
CAN1.Prescaler=3
|
CAN1.Prescaler=3
|
||||||
CAN1.SJW=CAN_SJW_1TQ
|
CAN1.SJW=CAN_SJW_1TQ
|
||||||
|
CAN1.TXFP=ENABLE
|
||||||
CAN2.BS1=CAN_BS1_10TQ
|
CAN2.BS1=CAN_BS1_10TQ
|
||||||
CAN2.BS2=CAN_BS2_3TQ
|
CAN2.BS2=CAN_BS2_3TQ
|
||||||
CAN2.CalculateBaudRate=1000000
|
CAN2.CalculateBaudRate=1000000
|
||||||
CAN2.CalculateTimeBit=1000
|
CAN2.CalculateTimeBit=1000
|
||||||
CAN2.CalculateTimeQuantum=71.42857142857143
|
CAN2.CalculateTimeQuantum=71.42857142857143
|
||||||
CAN2.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,BS2,Prescaler,NART
|
CAN2.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,BS1,BS2,Prescaler,NART,TXFP
|
||||||
CAN2.NART=ENABLE
|
CAN2.NART=ENABLE
|
||||||
CAN2.Prescaler=3
|
CAN2.Prescaler=3
|
||||||
|
CAN2.TXFP=ENABLE
|
||||||
Dma.Request0=USART3_RX
|
Dma.Request0=USART3_RX
|
||||||
Dma.Request1=SPI1_RX
|
Dma.Request1=SPI1_RX
|
||||||
Dma.Request2=SPI1_TX
|
Dma.Request2=SPI1_TX
|
||||||
@ -91,7 +93,7 @@ Mcu.CPN=STM32F407IGH6
|
|||||||
Mcu.Family=STM32F4
|
Mcu.Family=STM32F4
|
||||||
Mcu.IP0=CAN1
|
Mcu.IP0=CAN1
|
||||||
Mcu.IP1=CAN2
|
Mcu.IP1=CAN2
|
||||||
Mcu.IP10=TIM8
|
Mcu.IP10=TIM1
|
||||||
Mcu.IP11=TIM10
|
Mcu.IP11=TIM10
|
||||||
Mcu.IP12=USART1
|
Mcu.IP12=USART1
|
||||||
Mcu.IP13=USART2
|
Mcu.IP13=USART2
|
||||||
@ -109,50 +111,51 @@ Mcu.IPNb=16
|
|||||||
Mcu.Name=STM32F407I(E-G)Hx
|
Mcu.Name=STM32F407I(E-G)Hx
|
||||||
Mcu.Package=UFBGA176
|
Mcu.Package=UFBGA176
|
||||||
Mcu.Pin0=PB8
|
Mcu.Pin0=PB8
|
||||||
Mcu.Pin1=PG14
|
Mcu.Pin1=PB5
|
||||||
Mcu.Pin10=PD0
|
Mcu.Pin10=PD6
|
||||||
Mcu.Pin11=PC11
|
Mcu.Pin11=PD0
|
||||||
Mcu.Pin12=PC10
|
Mcu.Pin12=PC11
|
||||||
Mcu.Pin13=PG9
|
Mcu.Pin13=PC10
|
||||||
Mcu.Pin14=PD5
|
Mcu.Pin14=PG9
|
||||||
Mcu.Pin15=PD1
|
Mcu.Pin15=PD5
|
||||||
Mcu.Pin16=PC14-OSC32_IN
|
Mcu.Pin16=PD1
|
||||||
Mcu.Pin17=PF0
|
Mcu.Pin17=PC14-OSC32_IN
|
||||||
Mcu.Pin18=PA9
|
Mcu.Pin18=PF0
|
||||||
Mcu.Pin19=PC15-OSC32_OUT
|
Mcu.Pin19=PA9
|
||||||
Mcu.Pin2=PB4
|
Mcu.Pin2=PG14
|
||||||
Mcu.Pin20=PH0-OSC_IN
|
Mcu.Pin20=PC15-OSC32_OUT
|
||||||
Mcu.Pin21=PC7
|
Mcu.Pin21=PH0-OSC_IN
|
||||||
Mcu.Pin22=PH1-OSC_OUT
|
Mcu.Pin22=PC7
|
||||||
Mcu.Pin23=PF1
|
Mcu.Pin23=PH1-OSC_OUT
|
||||||
Mcu.Pin24=PG6
|
Mcu.Pin24=PF1
|
||||||
Mcu.Pin25=PF6
|
Mcu.Pin25=PG6
|
||||||
Mcu.Pin26=PH12
|
Mcu.Pin26=PF6
|
||||||
Mcu.Pin27=PG3
|
Mcu.Pin27=PH12
|
||||||
Mcu.Pin28=PH11
|
Mcu.Pin28=PG3
|
||||||
Mcu.Pin29=PH10
|
Mcu.Pin29=PH11
|
||||||
Mcu.Pin3=PB3
|
Mcu.Pin3=PB4
|
||||||
Mcu.Pin30=PC2
|
Mcu.Pin30=PH10
|
||||||
Mcu.Pin31=PB2
|
Mcu.Pin31=PA0-WKUP
|
||||||
Mcu.Pin32=PA0-WKUP
|
Mcu.Pin32=PA4
|
||||||
Mcu.Pin33=PA4
|
Mcu.Pin33=PC4
|
||||||
Mcu.Pin34=PC4
|
Mcu.Pin34=PE13
|
||||||
Mcu.Pin35=PC5
|
Mcu.Pin35=PC5
|
||||||
Mcu.Pin36=PB12
|
Mcu.Pin36=PE9
|
||||||
Mcu.Pin37=PA7
|
Mcu.Pin37=PE11
|
||||||
Mcu.Pin38=PB1
|
Mcu.Pin38=PE14
|
||||||
Mcu.Pin39=PB0
|
Mcu.Pin39=PA7
|
||||||
Mcu.Pin4=PA14
|
Mcu.Pin4=PB3
|
||||||
Mcu.Pin40=VP_FREERTOS_VS_CMSIS_V2
|
Mcu.Pin40=PB0
|
||||||
Mcu.Pin41=VP_SYS_VS_Systick
|
Mcu.Pin41=VP_FREERTOS_VS_CMSIS_V2
|
||||||
Mcu.Pin42=VP_TIM8_VS_ClockSourceINT
|
Mcu.Pin42=VP_SYS_VS_Systick
|
||||||
Mcu.Pin43=VP_TIM10_VS_ClockSourceINT
|
Mcu.Pin43=VP_TIM1_VS_ClockSourceINT
|
||||||
Mcu.Pin5=PA13
|
Mcu.Pin44=VP_TIM10_VS_ClockSourceINT
|
||||||
Mcu.Pin6=PB9
|
Mcu.Pin5=PA14
|
||||||
Mcu.Pin7=PB7
|
Mcu.Pin6=PA13
|
||||||
Mcu.Pin8=PB6
|
Mcu.Pin7=PB9
|
||||||
Mcu.Pin9=PD6
|
Mcu.Pin8=PB7
|
||||||
Mcu.PinsNb=44
|
Mcu.Pin9=PB6
|
||||||
|
Mcu.PinsNb=45
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=
|
Mcu.UserConstants=
|
||||||
Mcu.UserName=STM32F407IGHx
|
Mcu.UserName=STM32F407IGHx
|
||||||
@ -186,7 +189,7 @@ NVIC.SavedPendsvIrqHandlerGenerated=true
|
|||||||
NVIC.SavedSvcallIrqHandlerGenerated=true
|
NVIC.SavedSvcallIrqHandlerGenerated=true
|
||||||
NVIC.SavedSystickIrqHandlerGenerated=true
|
NVIC.SavedSystickIrqHandlerGenerated=true
|
||||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true\:false
|
||||||
NVIC.TIM1_UP_TIM10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.TIM1_BRK_TIM9_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.USART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.USART1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.USART3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.USART6_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.USART6_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
@ -220,23 +223,13 @@ PB0.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
|
|||||||
PB0.Locked=true
|
PB0.Locked=true
|
||||||
PB0.PinState=GPIO_PIN_SET
|
PB0.PinState=GPIO_PIN_SET
|
||||||
PB0.Signal=GPIO_Output
|
PB0.Signal=GPIO_Output
|
||||||
PB1.GPIOParameters=GPIO_PuPd,GPIO_Label
|
|
||||||
PB1.GPIO_Label=DIR_P
|
|
||||||
PB1.GPIO_PuPd=GPIO_PULLUP
|
|
||||||
PB1.Locked=true
|
|
||||||
PB1.Signal=GPIO_Output
|
|
||||||
PB12.Locked=true
|
|
||||||
PB12.Mode=CAN_Activate
|
|
||||||
PB12.Signal=CAN2_RX
|
|
||||||
PB2.GPIOParameters=GPIO_PuPd,GPIO_Label
|
|
||||||
PB2.GPIO_Label=DIR_N
|
|
||||||
PB2.GPIO_PuPd=GPIO_PULLUP
|
|
||||||
PB2.Locked=true
|
|
||||||
PB2.Signal=GPIO_Output
|
|
||||||
PB3.Mode=Full_Duplex_Master
|
PB3.Mode=Full_Duplex_Master
|
||||||
PB3.Signal=SPI1_SCK
|
PB3.Signal=SPI1_SCK
|
||||||
PB4.Mode=Full_Duplex_Master
|
PB4.Mode=Full_Duplex_Master
|
||||||
PB4.Signal=SPI1_MISO
|
PB4.Signal=SPI1_MISO
|
||||||
|
PB5.Locked=true
|
||||||
|
PB5.Mode=CAN_Activate
|
||||||
|
PB5.Signal=CAN2_RX
|
||||||
PB6.Mode=CAN_Activate
|
PB6.Mode=CAN_Activate
|
||||||
PB6.Signal=CAN2_TX
|
PB6.Signal=CAN2_TX
|
||||||
PB7.Mode=Asynchronous
|
PB7.Mode=Asynchronous
|
||||||
@ -253,11 +246,6 @@ PC14-OSC32_IN.Mode=LSE-External-Oscillator
|
|||||||
PC14-OSC32_IN.Signal=RCC_OSC32_IN
|
PC14-OSC32_IN.Signal=RCC_OSC32_IN
|
||||||
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
|
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
|
||||||
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
|
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
|
||||||
PC2.GPIOParameters=GPIO_PuPd,GPIO_Label
|
|
||||||
PC2.GPIO_Label=PUL_N
|
|
||||||
PC2.GPIO_PuPd=GPIO_PULLUP
|
|
||||||
PC2.Locked=true
|
|
||||||
PC2.Signal=GPIO_Output
|
|
||||||
PC4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
PC4.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
|
||||||
PC4.GPIO_Label=ACCL_INT
|
PC4.GPIO_Label=ACCL_INT
|
||||||
PC4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
PC4.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
||||||
@ -270,6 +258,9 @@ PC5.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
|
|||||||
PC5.GPIO_PuPd=GPIO_PULLUP
|
PC5.GPIO_PuPd=GPIO_PULLUP
|
||||||
PC5.Locked=true
|
PC5.Locked=true
|
||||||
PC5.Signal=GPXTI5
|
PC5.Signal=GPXTI5
|
||||||
|
PC7.GPIOParameters=GPIO_Speed,GPIO_PuPd
|
||||||
|
PC7.GPIO_PuPd=GPIO_PULLUP
|
||||||
|
PC7.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
PC7.Locked=true
|
PC7.Locked=true
|
||||||
PC7.Signal=S_TIM8_CH2
|
PC7.Signal=S_TIM8_CH2
|
||||||
PCC.Checker=false
|
PCC.Checker=false
|
||||||
@ -289,6 +280,29 @@ PD5.Mode=Asynchronous
|
|||||||
PD5.Signal=USART2_TX
|
PD5.Signal=USART2_TX
|
||||||
PD6.Mode=Asynchronous
|
PD6.Mode=Asynchronous
|
||||||
PD6.Signal=USART2_RX
|
PD6.Signal=USART2_RX
|
||||||
|
PE11.GPIOParameters=GPIO_Speed,PinState,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP
|
||||||
|
PE11.GPIO_Label=DIR_P
|
||||||
|
PE11.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP
|
||||||
|
PE11.GPIO_PuPd=GPIO_PULLUP
|
||||||
|
PE11.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
|
PE11.Locked=true
|
||||||
|
PE11.PinState=GPIO_PIN_SET
|
||||||
|
PE11.Signal=GPIO_Output
|
||||||
|
PE13.GPIOParameters=GPIO_Speed,GPIO_PuPd
|
||||||
|
PE13.GPIO_PuPd=GPIO_PULLUP
|
||||||
|
PE13.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
|
PE13.Locked=true
|
||||||
|
PE13.Signal=S_TIM1_CH3
|
||||||
|
PE14.GPIOParameters=GPIO_Speed,GPIO_PuPd
|
||||||
|
PE14.GPIO_PuPd=GPIO_PULLUP
|
||||||
|
PE14.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
|
PE14.Locked=true
|
||||||
|
PE14.Signal=S_TIM1_CH4
|
||||||
|
PE9.GPIOParameters=GPIO_Speed,GPIO_PuPd
|
||||||
|
PE9.GPIO_PuPd=GPIO_PULLUP
|
||||||
|
PE9.GPIO_Speed=GPIO_SPEED_FREQ_HIGH
|
||||||
|
PE9.Locked=true
|
||||||
|
PE9.Signal=S_TIM1_CH1
|
||||||
PF0.Mode=I2C
|
PF0.Mode=I2C
|
||||||
PF0.Signal=I2C2_SDA
|
PF0.Signal=I2C2_SDA
|
||||||
PF1.Mode=I2C
|
PF1.Mode=I2C
|
||||||
@ -363,7 +377,7 @@ ProjectManager.ToolChainLocation=
|
|||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=false
|
ProjectManager.UnderRoot=false
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_CAN2_Init-CAN2-false-HAL-true,6-MX_I2C1_Init-I2C1-false-HAL-true,7-MX_I2C2_Init-I2C2-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_TIM10_Init-TIM10-false-HAL-true,13-MX_USART6_UART_Init-USART6-false-HAL-true,14-MX_TIM8_Init-TIM8-false-HAL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_CAN1_Init-CAN1-false-HAL-true,5-MX_CAN2_Init-CAN2-false-HAL-true,6-MX_I2C1_Init-I2C1-false-HAL-true,7-MX_I2C2_Init-I2C2-false-HAL-true,8-MX_SPI1_Init-SPI1-false-HAL-true,9-MX_USART1_UART_Init-USART1-false-HAL-true,10-MX_USART2_UART_Init-USART2-false-HAL-true,11-MX_USART3_UART_Init-USART3-false-HAL-true,12-MX_TIM10_Init-TIM10-false-HAL-true,13-MX_USART6_UART_Init-USART6-false-HAL-true,14-MX_TIM1_Init-TIM1-false-HAL-true
|
||||||
RCC.48MHZClocksFreq_Value=84000000
|
RCC.48MHZClocksFreq_Value=84000000
|
||||||
RCC.AHBFreq_Value=168000000
|
RCC.AHBFreq_Value=168000000
|
||||||
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
RCC.APB1CLKDivider=RCC_HCLK_DIV4
|
||||||
@ -406,7 +420,13 @@ SH.GPXTI5.0=GPIO_EXTI5
|
|||||||
SH.GPXTI5.ConfNb=1
|
SH.GPXTI5.ConfNb=1
|
||||||
SH.S_TIM10_CH1.0=TIM10_CH1,PWM Generation1 CH1
|
SH.S_TIM10_CH1.0=TIM10_CH1,PWM Generation1 CH1
|
||||||
SH.S_TIM10_CH1.ConfNb=1
|
SH.S_TIM10_CH1.ConfNb=1
|
||||||
SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2
|
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
|
||||||
|
SH.S_TIM1_CH1.ConfNb=1
|
||||||
|
SH.S_TIM1_CH3.0=TIM1_CH3
|
||||||
|
SH.S_TIM1_CH3.ConfNb=1
|
||||||
|
SH.S_TIM1_CH4.0=TIM1_CH4
|
||||||
|
SH.S_TIM1_CH4.ConfNb=1
|
||||||
|
SH.S_TIM8_CH2.0=TIM8_CH2
|
||||||
SH.S_TIM8_CH2.ConfNb=1
|
SH.S_TIM8_CH2.ConfNb=1
|
||||||
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
|
SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_16
|
||||||
SPI1.CLKPhase=SPI_PHASE_2EDGE
|
SPI1.CLKPhase=SPI_PHASE_2EDGE
|
||||||
@ -416,13 +436,13 @@ SPI1.Direction=SPI_DIRECTION_2LINES
|
|||||||
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,CLKPhase,CLKPolarity
|
SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,CLKPhase,CLKPolarity
|
||||||
SPI1.Mode=SPI_MODE_MASTER
|
SPI1.Mode=SPI_MODE_MASTER
|
||||||
SPI1.VirtualType=VM_MASTER
|
SPI1.VirtualType=VM_MASTER
|
||||||
|
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
|
||||||
|
TIM1.IPParameters=Channel-PWM Generation1 CH1,Prescaler,Period
|
||||||
|
TIM1.Period=19999
|
||||||
|
TIM1.Prescaler=167
|
||||||
TIM10.Channel=TIM_CHANNEL_1
|
TIM10.Channel=TIM_CHANNEL_1
|
||||||
TIM10.IPParameters=Channel,Period
|
TIM10.IPParameters=Channel,Period
|
||||||
TIM10.Period=5000
|
TIM10.Period=5000
|
||||||
TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
|
|
||||||
TIM8.IPParameters=Channel-PWM Generation2 CH2,Prescaler,Period
|
|
||||||
TIM8.Period=19999
|
|
||||||
TIM8.Prescaler=167
|
|
||||||
USART1.IPParameters=VirtualMode
|
USART1.IPParameters=VirtualMode
|
||||||
USART1.VirtualMode=VM_ASYNC
|
USART1.VirtualMode=VM_ASYNC
|
||||||
USART2.IPParameters=VirtualMode
|
USART2.IPParameters=VirtualMode
|
||||||
@ -441,7 +461,7 @@ VP_SYS_VS_Systick.Mode=SysTick
|
|||||||
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
|
||||||
VP_TIM10_VS_ClockSourceINT.Mode=Enable_Timer
|
VP_TIM10_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
VP_TIM10_VS_ClockSourceINT.Signal=TIM10_VS_ClockSourceINT
|
VP_TIM10_VS_ClockSourceINT.Signal=TIM10_VS_ClockSourceINT
|
||||||
VP_TIM8_VS_ClockSourceINT.Mode=Internal
|
VP_TIM1_VS_ClockSourceINT.Mode=Internal
|
||||||
VP_TIM8_VS_ClockSourceINT.Signal=TIM8_VS_ClockSourceINT
|
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
|
||||||
board=custom
|
board=custom
|
||||||
rtos.0.ip=FREERTOS
|
rtos.0.ip=FREERTOS
|
||||||
|
|||||||
@ -24,21 +24,6 @@ gpio:
|
|||||||
ioc_label: GYRO_CS
|
ioc_label: GYRO_CS
|
||||||
pin: PB0
|
pin: PB0
|
||||||
type: OUTPUT
|
type: OUTPUT
|
||||||
- custom_name: DIR_P
|
|
||||||
has_exti: false
|
|
||||||
ioc_label: DIR_P
|
|
||||||
pin: PB1
|
|
||||||
type: OUTPUT
|
|
||||||
- custom_name: DIR_N
|
|
||||||
has_exti: false
|
|
||||||
ioc_label: DIR_N
|
|
||||||
pin: PB2
|
|
||||||
type: OUTPUT
|
|
||||||
- custom_name: PUL_N
|
|
||||||
has_exti: false
|
|
||||||
ioc_label: PUL_N
|
|
||||||
pin: PC2
|
|
||||||
type: OUTPUT
|
|
||||||
- custom_name: ACCL_INT
|
- custom_name: ACCL_INT
|
||||||
has_exti: true
|
has_exti: true
|
||||||
ioc_label: ACCL_INT
|
ioc_label: ACCL_INT
|
||||||
@ -49,6 +34,11 @@ gpio:
|
|||||||
ioc_label: GYRO_INT
|
ioc_label: GYRO_INT
|
||||||
pin: PC5
|
pin: PC5
|
||||||
type: EXTI
|
type: EXTI
|
||||||
|
- custom_name: DIR_P
|
||||||
|
has_exti: false
|
||||||
|
ioc_label: DIR_P
|
||||||
|
pin: PE11
|
||||||
|
type: OUTPUT
|
||||||
- custom_name: CMPS_INT
|
- custom_name: CMPS_INT
|
||||||
has_exti: true
|
has_exti: true
|
||||||
ioc_label: CMPS_INT
|
ioc_label: CMPS_INT
|
||||||
@ -86,10 +76,10 @@ mm:
|
|||||||
enabled: true
|
enabled: true
|
||||||
pwm:
|
pwm:
|
||||||
configs:
|
configs:
|
||||||
- channel: TIM_CHANNEL_2
|
- channel: TIM_CHANNEL_1
|
||||||
custom_name: MOTOR_STEP
|
custom_name: TIM1_CH1
|
||||||
label: TIM8_CH2
|
label: TIM1_CH1
|
||||||
timer: TIM8
|
timer: TIM1
|
||||||
- channel: TIM_CHANNEL_1
|
- channel: TIM_CHANNEL_1
|
||||||
custom_name: IMU_HEAT
|
custom_name: IMU_HEAT
|
||||||
label: TIM10_CH1
|
label: TIM10_CH1
|
||||||
|
|||||||
@ -29,11 +29,9 @@ static const BSP_GPIO_MAP_t GPIO_Map[BSP_GPIO_NUM] = {
|
|||||||
{USER_KEY_Pin, USER_KEY_GPIO_Port},
|
{USER_KEY_Pin, USER_KEY_GPIO_Port},
|
||||||
{ACCL_CS_Pin, ACCL_CS_GPIO_Port},
|
{ACCL_CS_Pin, ACCL_CS_GPIO_Port},
|
||||||
{GYRO_CS_Pin, GYRO_CS_GPIO_Port},
|
{GYRO_CS_Pin, GYRO_CS_GPIO_Port},
|
||||||
{DIR_P_Pin, DIR_P_GPIO_Port},
|
|
||||||
{DIR_N_Pin, DIR_N_GPIO_Port},
|
|
||||||
{PUL_N_Pin, PUL_N_GPIO_Port},
|
|
||||||
{ACCL_INT_Pin, ACCL_INT_GPIO_Port},
|
{ACCL_INT_Pin, ACCL_INT_GPIO_Port},
|
||||||
{GYRO_INT_Pin, GYRO_INT_GPIO_Port},
|
{GYRO_INT_Pin, GYRO_INT_GPIO_Port},
|
||||||
|
{DIR_P_Pin, DIR_P_GPIO_Port},
|
||||||
{CMPS_INT_Pin, CMPS_INT_GPIO_Port},
|
{CMPS_INT_Pin, CMPS_INT_GPIO_Port},
|
||||||
{CMPS_RST_Pin, CMPS_RST_GPIO_Port},
|
{CMPS_RST_Pin, CMPS_RST_GPIO_Port},
|
||||||
{LED_Blue_Pin, LED_Blue_GPIO_Port},
|
{LED_Blue_Pin, LED_Blue_GPIO_Port},
|
||||||
|
|||||||
@ -25,11 +25,9 @@ typedef enum {
|
|||||||
BSP_GPIO_USER_KEY,
|
BSP_GPIO_USER_KEY,
|
||||||
BSP_GPIO_ACCL_CS,
|
BSP_GPIO_ACCL_CS,
|
||||||
BSP_GPIO_GYRO_CS,
|
BSP_GPIO_GYRO_CS,
|
||||||
BSP_GPIO_DIR_P,
|
|
||||||
BSP_GPIO_DIR_N,
|
|
||||||
BSP_GPIO_PUL_N,
|
|
||||||
BSP_GPIO_ACCL_INT,
|
BSP_GPIO_ACCL_INT,
|
||||||
BSP_GPIO_GYRO_INT,
|
BSP_GPIO_GYRO_INT,
|
||||||
|
BSP_GPIO_DIR_P,
|
||||||
BSP_GPIO_CMPS_INT,
|
BSP_GPIO_CMPS_INT,
|
||||||
BSP_GPIO_CMPS_RST,
|
BSP_GPIO_CMPS_RST,
|
||||||
BSP_GPIO_LED_BLUE,
|
BSP_GPIO_LED_BLUE,
|
||||||
|
|||||||
@ -25,7 +25,7 @@ typedef struct {
|
|||||||
|
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
static const BSP_PWM_Config_t PWM_Map[BSP_PWM_NUM] = {
|
static const BSP_PWM_Config_t PWM_Map[BSP_PWM_NUM] = {
|
||||||
{&htim8, TIM_CHANNEL_2},
|
{&htim1, TIM_CHANNEL_1},
|
||||||
{&htim10, TIM_CHANNEL_1},
|
{&htim10, TIM_CHANNEL_1},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ extern "C" {
|
|||||||
/* Exported types ----------------------------------------------------------- */
|
/* Exported types ----------------------------------------------------------- */
|
||||||
/* PWM通道 */
|
/* PWM通道 */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
BSP_PWM_MOTOR_STEP,
|
BSP_PWM_TIM1_CH1,
|
||||||
BSP_PWM_IMU_HEAT,
|
BSP_PWM_IMU_HEAT,
|
||||||
BSP_PWM_NUM,
|
BSP_PWM_NUM,
|
||||||
BSP_PWM_ERR,
|
BSP_PWM_ERR,
|
||||||
|
|||||||
@ -5,26 +5,33 @@
|
|||||||
#include "bsp/gpio.h"
|
#include "bsp/gpio.h"
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
|
|
||||||
int8_t Motor_Step_Init(STEP_MOTOR *param){
|
int8_t Motor_Step_Init(MOTOR_STEP_t *motor_step){
|
||||||
|
|
||||||
BSP_PWM_Start(BSP_PWM_MOTOR_STEP);
|
|
||||||
|
|
||||||
|
BSP_PWM_Start(motor_step->param.channel);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t Motor_Step_Ctrl(STEP_MOTOR *param){
|
int8_t Motor_Step_Ctrl(MOTOR_STEP_t *motor_step){
|
||||||
|
|
||||||
// if(param->state==1){
|
|
||||||
/* 控制方向 */
|
/* 控制方向 */
|
||||||
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, param->direction);
|
if(motor_step->param.reverse==true){
|
||||||
osDelay(10); // 方向稳定时间
|
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, true);
|
||||||
// for(int i;i<10000;i++){
|
BSP_PWM_SetComp(motor_step->param.channel,0.5);
|
||||||
BSP_PWM_SetComp(BSP_PWM_MOTOR_STEP,19999);
|
}
|
||||||
// osDelay(200);
|
|
||||||
// BSP_PWM_SetComp(BSP_PWM_STEP_MOTOR,0);
|
if(motor_step->param.reverse==false){
|
||||||
// osDelay(200);
|
BSP_GPIO_WritePin(BSP_GPIO_DIR_P, true);
|
||||||
// }
|
|
||||||
|
BSP_PWM_SetComp(motor_step->param.channel,0.9);
|
||||||
|
// osDelay(100);
|
||||||
|
// BSP_PWM_SetComp(motor_step->param.channel,0);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int8_t Motor_Step_Stop(MOTOR_STEP_t *motor_step){
|
||||||
|
|
||||||
|
BSP_PWM_Stop(motor_step->param.channel) ;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,27 +11,32 @@ extern "C" {
|
|||||||
/* Includes ----------------------------------------------------------------- */
|
/* Includes ----------------------------------------------------------------- */
|
||||||
#include "cmsis_os2.h"
|
#include "cmsis_os2.h"
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "bsp/pwm.h"
|
||||||
/* Exported constants ------------------------------------------------------- */
|
/* Exported constants ------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
/* Exported macro ----------------------------------------------------------- */
|
/* Exported macro ----------------------------------------------------------- */
|
||||||
/* Exported types ----------------------------------------------------------- */
|
/* Exported types ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
/*每个电机需要的参数*/
|
||||||
|
typedef struct {
|
||||||
|
BSP_PWM_Channel_t channel;
|
||||||
|
bool reverse;
|
||||||
|
bool gear;
|
||||||
|
} MOTOR_STEP_Param_t;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
|
|
||||||
|
MOTOR_STEP_Param_t param;
|
||||||
/* 脉冲个数 */
|
/* 脉冲个数 */
|
||||||
int pulse;
|
int pulse;
|
||||||
/* 脉冲间隔 */
|
|
||||||
float time;
|
|
||||||
|
|
||||||
/* 方向 */
|
}MOTOR_STEP_t;
|
||||||
bool direction;
|
|
||||||
/* 状态 */
|
|
||||||
int state;
|
|
||||||
|
|
||||||
}STEP_MOTOR;
|
int8_t Motor_Step_Init(MOTOR_STEP_t *param);
|
||||||
|
int8_t Motor_Step_Ctrl(MOTOR_STEP_t *param);
|
||||||
int8_t Motor_Step_Init(STEP_MOTOR *param);
|
int8_t Motor_Step_Stop(MOTOR_STEP_t *motor_step);
|
||||||
int8_t Motor_Step_Ctrl(STEP_MOTOR *param);
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -40,7 +40,6 @@ chassis_init(&chassis,&Config_GetRobotParam()->chassis,CHASSIS_FREQ);
|
|||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include "component/pid.h"
|
#include "component/pid.h"
|
||||||
#include "component/filter.h"
|
#include "component/filter.h"
|
||||||
|
|
||||||
#include "stdlib.h"
|
#include "stdlib.h"
|
||||||
|
|
||||||
/*舵轮舵向校准方法:注释掉关于6020反馈角度的处理以及6020数据的发送这两处(define.h里有快捷方法),
|
/*舵轮舵向校准方法:注释掉关于6020反馈角度的处理以及6020数据的发送这两处(define.h里有快捷方法),
|
||||||
@ -64,6 +63,7 @@ fp32 vofa_send[8]; //vofa输出数据
|
|||||||
#define CHASSIS_ROTOR_OMEGA 0.001
|
#define CHASSIS_ROTOR_OMEGA 0.001
|
||||||
#define CHASSIS_ROTOR_WZ_MIN 0.6f /* 小陀螺旋转位移下界 */
|
#define CHASSIS_ROTOR_WZ_MIN 0.6f /* 小陀螺旋转位移下界 */
|
||||||
#define CHASSIS_ROTOR_WZ_MAX 0.8f /* 小陀螺旋转位移上界 */
|
#define CHASSIS_ROTOR_WZ_MAX 0.8f /* 小陀螺旋转位移上界 */
|
||||||
|
#define ONE_MINUTE 60.0f /* 一分钟时间 */
|
||||||
|
|
||||||
float motor_add_anagle(float current_angle){
|
float motor_add_anagle(float current_angle){
|
||||||
static int cirle;
|
static int cirle;
|
||||||
@ -80,7 +80,40 @@ float motor_add_anagle(float current_angle){
|
|||||||
return current_angle;
|
return current_angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int8_t Chassis_SetMode(Chassis_t *c, Chassis_mode_t mode ,uint32_t now)
|
|
||||||
|
static int8_t Set_Chassis_Attitude(Chassis_t *c,CHASSIS_ATTITUDE_MODE_t mode){
|
||||||
|
float Telescope_omega_set_point;
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case STOP_MODE:
|
||||||
|
c->out.Telescope = 0.0f;
|
||||||
|
break;
|
||||||
|
case EXPAND_MODE:
|
||||||
|
|
||||||
|
Telescope_omega_set_point = PID_Calc(&(c->pid.Telescope_angle), c->param->Set_TelescopeAngle,
|
||||||
|
c->feedback.motor.Telescope_SuperiorAngle, 0.0f, c->dt);
|
||||||
|
c->out.Telescope = PID_Calc(&(c->pid.Telescope_omega), Telescope_omega_set_point,
|
||||||
|
c->feedback.motor.Telescope_Omega, 0.f, c->dt);
|
||||||
|
break;
|
||||||
|
case REDUCE_MODE:
|
||||||
|
|
||||||
|
Telescope_omega_set_point = PID_Calc(&(c->pid.Telescope_angle), 0,
|
||||||
|
c->feedback.motor.Telescope_SuperiorAngle, 0.0f, c->dt);
|
||||||
|
c->out.Telescope = PID_Calc(&(c->pid.Telescope_omega), Telescope_omega_set_point,
|
||||||
|
c->feedback.motor.Telescope_Omega, 0.f, c->dt);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
c->out.Telescope = 0.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return CHASSIS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int8_t Chassis_SetMode(Chassis_t *c, Chassis_Mode_t mode ,uint32_t now)
|
||||||
{
|
{
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return CHASSIS_ERR_NULL; /* 主结构体不能为空 */
|
return CHASSIS_ERR_NULL; /* 主结构体不能为空 */
|
||||||
@ -88,15 +121,19 @@ static int8_t Chassis_SetMode(Chassis_t *c, Chassis_mode_t mode ,uint32_t now)
|
|||||||
|
|
||||||
if (mode == CHASSIS_MODE_ROTOR && c->mode != CHASSIS_MODE_ROTOR) {
|
if (mode == CHASSIS_MODE_ROTOR && c->mode != CHASSIS_MODE_ROTOR) {
|
||||||
srand(now);
|
srand(now);
|
||||||
c->wz_multi = (rand() % 2) ? -1 : 1;
|
c->wz_multi =1;
|
||||||
|
// c->wz_multi = (rand() % 2) ? -1 : 1;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
PID_Reset(&c->pid.chassis_3508VPID[i]);
|
PID_Reset(&c->pid.Radder_DIR_omega[i]);
|
||||||
PID_Reset(&c->pid.chassis_6020OmegaPid[i]);
|
PID_Reset(&c->pid.Radder_DIR_angle[i]);
|
||||||
PID_Reset(&c->pid.chassis_6020anglePid[i]);
|
PID_Reset(&c->pid.Wheel_DIR_omega[i]);
|
||||||
|
PID_Reset(&c->pid.Radder_DIR_omega[i]);
|
||||||
}
|
}
|
||||||
|
/* 丝杆伸缩 */
|
||||||
|
PID_Reset(&c->pid.Telescope_omega);
|
||||||
|
PID_Reset(&c->pid.Telescope_angle);
|
||||||
c->mode = mode;
|
c->mode = mode;
|
||||||
return CHASSIS_OK;
|
return CHASSIS_OK;
|
||||||
}
|
}
|
||||||
@ -127,46 +164,40 @@ int8_t chassis_init(Chassis_t *c, Chassis_Param_t *param, float target_freq)
|
|||||||
c->mode = CHASSIS_MODE_RELAX; // 默认模式为停止锁死底盘
|
c->mode = CHASSIS_MODE_RELAX; // 默认模式为停止锁死底盘
|
||||||
c->mech_zero = c->param->mech_zero;/*云台6020的机械中点*/
|
c->mech_zero = c->param->mech_zero;/*云台6020的机械中点*/
|
||||||
c->travel = c->param->travel ;/*云台6020的机械行程*/
|
c->travel = c->param->travel ;/*云台6020的机械行程*/
|
||||||
// c->chassis2006_setangle = c->param->chassis2006_setangle; // 变形舵轮2006目标角度 大概是48圈
|
// c->mech_zero_4310 = c->param->mech_zero_4310;/*云台4310的机械中点*/
|
||||||
// c->chassis3508_setangle = c->param->chassis3508_setangle; // 变形舵轮3508目标角度 大概是60度左右
|
|
||||||
/*初始化can*/
|
/*初始化can*/
|
||||||
BSP_CAN_Init();
|
BSP_CAN_Init();
|
||||||
/*注册3508电机*/
|
/*注册轮向电机*/
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
MOTOR_RM_Register(&(c->param->motor_3508_param[i]));
|
MOTOR_RM_Register(&(c->param->motor.Wheel_DIR[i]));
|
||||||
}
|
}
|
||||||
/*注册6020电机*/
|
/*注册舵向电机*/
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
MOTOR_RM_Register(&(c->param->motor_6020_param[i]));
|
MOTOR_RM_Register(&(c->param->motor.Radder_DIR[i]));
|
||||||
}
|
}
|
||||||
MOTOR_RM_Register(&(c->param->motor_2006_param)); // 注册2006电机
|
/*注册伸缩电机*/
|
||||||
|
MOTOR_RM_Register(&(c->param->motor.Telescope_motor));
|
||||||
// 舵轮安装时的6020机械误差,机械校准时1号轮在左前方,所有轮的编码器朝向右面
|
// 舵轮安装时的6020机械误差,机械校准时1号轮在左前方,所有轮的编码器朝向右面
|
||||||
MotorOffset_t motor_offset = {{2.09311676 / M_PI * 180.0f, 0.50467968 / M_PI * 180.0f, 3.63706851 / M_PI * 180.0f, 5.26232147 / M_PI * 180.0f}}; // 右右右右
|
MotorOffset_t motor_offset = {{2.12916541 / M_PI * 180.0f, 5.23470974/ M_PI * 180.0f,
|
||||||
|
1.60531092 / M_PI * 180.0f, 4.16322374/ M_PI * 180.0f}}; // 右右右右
|
||||||
|
|
||||||
c->motoroffset = motor_offset;
|
c->motoroffset = motor_offset;
|
||||||
/*对3508的速度环和6020的角速度以及位置环pid进行初始化*/
|
/*对3508的速度环和6020的角速度以及位置环pid进行初始化*/
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
PID_Init(&c->pid.chassis_3508VPID[i], KPID_MODE_NO_D, target_freq, &c->param->M3508v_param);
|
PID_Init(&c->pid.Wheel_DIR_omega[i], KPID_MODE_NO_D, target_freq, &c->param->pid.Wheel_DIR_Omega);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
PID_Init(&c->pid.chassis_6020OmegaPid[i], KPID_MODE_CALC_D, target_freq, &c->param->C6020Omega_param);
|
PID_Init(&c->pid.Radder_DIR_omega[i], KPID_MODE_CALC_D, target_freq, &c->param->pid.Radder_DIR_Omega);
|
||||||
PID_Init(&c->pid.chassis_6020anglePid[i], KPID_MODE_CALC_D, target_freq, &c->param->C6020Angle_param);
|
PID_Init(&c->pid.Radder_DIR_angle[i], KPID_MODE_CALC_D, target_freq, &c->param->pid.Radder_DIR_Angle);
|
||||||
}
|
|
||||||
PID_Init(&c->pid.chassis_follow_gimbal_pid, KPID_MODE_CALC_D, target_freq, &c->param->chassis_follow_gimbalPID);
|
|
||||||
/*2006位置环pid*/
|
|
||||||
PID_Init(&c->pid.chassis_2006_anglepid,KPID_MODE_NO_D,target_freq , &c->param->chassis_2006_angle_param);
|
|
||||||
PID_Init(&c->pid.chassis_2006_OmegaPid,KPID_MODE_CALC_D,target_freq , &c->param->chassis_2006_Omega_param);
|
|
||||||
/*底盘轮向3508在控制展开时的位置双环pid*/
|
|
||||||
for(int i=0;i<4;i++)
|
|
||||||
{
|
|
||||||
PID_Init(&c->pid.chassis_3508_anglepid[i],KPID_MODE_NO_D,target_freq , &c->param->chassis_3508_angle_param);
|
|
||||||
PID_Init(&c->pid.chassis_3508_OmegaPid[i],KPID_MODE_CALC_D,target_freq , &c->param->chassis_3508_Omega_param);
|
|
||||||
}
|
}
|
||||||
|
PID_Init(&c->pid.chassis_follow_gimbal_pid,
|
||||||
|
KPID_MODE_CALC_D,
|
||||||
|
target_freq,
|
||||||
|
&c->param->pid.chassis_follow_gimbal);
|
||||||
|
|
||||||
LowPassFilter2p_Init(&c->filled[0], target_freq, 20.0f); // vx
|
LowPassFilter2p_Init(&c->filled[0], target_freq, 20.0f); // vx
|
||||||
LowPassFilter2p_Init(&c->filled[1], target_freq, 20.0f); // vy
|
LowPassFilter2p_Init(&c->filled[1], target_freq, 20.0f); // vy
|
||||||
@ -180,9 +211,7 @@ int8_t chassis_init(Chassis_t *c, Chassis_Param_t *param, float target_freq)
|
|||||||
LowPassFilter2p_Init(&c->filled[7], target_freq, 20.0f); // 6020-1
|
LowPassFilter2p_Init(&c->filled[7], target_freq, 20.0f); // 6020-1
|
||||||
LowPassFilter2p_Init(&c->filled[8], target_freq, 20.0f); // 6020-2
|
LowPassFilter2p_Init(&c->filled[8], target_freq, 20.0f); // 6020-2
|
||||||
LowPassFilter2p_Init(&c->filled[9], target_freq, 20.0f); // 6020-3
|
LowPassFilter2p_Init(&c->filled[9], target_freq, 20.0f); // 6020-3
|
||||||
LowPassFilter2p_Init(&c->filled[10],target_freq, 20.0f); // 6020-4
|
LowPassFilter2p_Init(&c->filled[10], target_freq, 20.0f); // 6020-4
|
||||||
|
|
||||||
LowPassFilter2p_Init(&c->filled[11], target_freq, 10.0f); // 2006角度
|
|
||||||
|
|
||||||
|
|
||||||
return CHASSIS_OK;
|
return CHASSIS_OK;
|
||||||
@ -205,13 +234,13 @@ void Chassis_speed_calculate(Chassis_t *c, Chassis_CMD_t *c_cmd)
|
|||||||
// 使用保持的角度,而不是实时反馈值,速度为0
|
// 使用保持的角度,而不是实时反馈值,速度为0
|
||||||
for (uint8_t i = 0; i < 4; i++)
|
for (uint8_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[i] = c->keep_angle[i];
|
c->hopemotorout.Radder_DIR_Solving_1[i] = c->keep_angle[i];
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[i] = 0;
|
c->hopemotorout.Wheel_DIR_Solving_1[i] = 0;
|
||||||
}
|
}
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[0] = 315;
|
// c->hopemotorout.Radder_DIR_Solving_1[0] = 315;
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[1] = 45;
|
// c->hopemotorout.Radder_DIR_Solving_1[1] = 45;
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[2] = 315;
|
// c->hopemotorout.Radder_DIR_Solving_1[2] = 315;
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[3] = 45;
|
// c->hopemotorout.Radder_DIR_Solving_1[3] = 45;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -220,42 +249,44 @@ void Chassis_speed_calculate(Chassis_t *c, Chassis_CMD_t *c_cmd)
|
|||||||
// 让保持角度实时等于进入保持阈值前的最后一次角度值
|
// 让保持角度实时等于进入保持阈值前的最后一次角度值
|
||||||
for (uint8_t i = 0; i < 4; i++)
|
for (uint8_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
c->keep_angle[i] = c->hopemotorout.rotor6020_jiesuan_1[i];
|
c->keep_angle[i] = c->hopemotorout.Radder_DIR_Solving_1[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (c->mode)
|
switch (c->mode)
|
||||||
{
|
{
|
||||||
case RC:
|
case RC:
|
||||||
|
|
||||||
|
|
||||||
case CHASSIS_MODE_ROTOR:
|
case CHASSIS_MODE_ROTOR:
|
||||||
case CHASSIS_MODE_FOLLOW_GIMBAL:
|
case CHASSIS_MODE_FOLLOW_GIMBAL:
|
||||||
|
|
||||||
|
|
||||||
// const double radians = atan(1.0f * 330 / 330);
|
// const double radians = atan(1.0f * 330 / 330);
|
||||||
|
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[0] = sqrt(
|
c->hopemotorout.Wheel_DIR_Solving_1[0] = sqrt(
|
||||||
(c->move_vec.Vx + c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx + c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy + c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy + c->move_vec.Vw * cos(radians)));
|
(c->move_vec.Vx + c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx + c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy + c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy + c->move_vec.Vw * cos(radians)));
|
||||||
|
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[1] = sqrt(
|
c->hopemotorout.Wheel_DIR_Solving_1[1] = sqrt(
|
||||||
(c->move_vec.Vx + c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx + c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy - c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy - c->move_vec.Vw * cos(radians)));
|
(c->move_vec.Vx + c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx + c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy - c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy - c->move_vec.Vw * cos(radians)));
|
||||||
|
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[2] = sqrt(
|
c->hopemotorout.Wheel_DIR_Solving_1[2] = sqrt(
|
||||||
(c->move_vec.Vx - c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx - c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy - c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy - c->move_vec.Vw * cos(radians)));
|
(c->move_vec.Vx - c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx - c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy - c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy - c->move_vec.Vw * cos(radians)));
|
||||||
|
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[3] = sqrt(
|
c->hopemotorout.Wheel_DIR_Solving_1[3] = sqrt(
|
||||||
(c->move_vec.Vx - c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx - c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy + c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy + c->move_vec.Vw * cos(radians)));
|
(c->move_vec.Vx - c->move_vec.Vw * sin(radians)) * (c->move_vec.Vx - c->move_vec.Vw * sin(radians)) + (c->move_vec.Vy + c->move_vec.Vw * cos(radians)) * (c->move_vec.Vy + c->move_vec.Vw * cos(radians)));
|
||||||
|
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[0] = atan2((c->move_vec.Vy + c->move_vec.Vw * cos(radians)),
|
c->hopemotorout.Radder_DIR_Solving_1[0] = atan2((c->move_vec.Vy + c->move_vec.Vw * cos(radians)),
|
||||||
(c->move_vec.Vx + c->move_vec.Vw * sin(radians))) *
|
(c->move_vec.Vx + c->move_vec.Vw * sin(radians))) *
|
||||||
(180.0f / M_PI);
|
(180.0f / M_PI);
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[1] = atan2((c->move_vec.Vy - c->move_vec.Vw * cos(radians)),
|
c->hopemotorout.Radder_DIR_Solving_1[1] = atan2((c->move_vec.Vy - c->move_vec.Vw * cos(radians)),
|
||||||
(c->move_vec.Vx + c->move_vec.Vw * sin(radians))) *
|
(c->move_vec.Vx + c->move_vec.Vw * sin(radians))) *
|
||||||
(180.0f / M_PI);
|
(180.0f / M_PI);
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[2] = atan2((c->move_vec.Vy - c->move_vec.Vw * cos(radians)),
|
c->hopemotorout.Radder_DIR_Solving_1[2] = atan2((c->move_vec.Vy - c->move_vec.Vw * cos(radians)),
|
||||||
(c->move_vec.Vx - c->move_vec.Vw * sin(radians))) *
|
(c->move_vec.Vx - c->move_vec.Vw * sin(radians))) *
|
||||||
(180.0f / M_PI);
|
(180.0f / M_PI);
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[3] = atan2((c->move_vec.Vy + c->move_vec.Vw * cos(radians)),
|
c->hopemotorout.Radder_DIR_Solving_1[3] = atan2((c->move_vec.Vy + c->move_vec.Vw * cos(radians)),
|
||||||
(c->move_vec.Vx - c->move_vec.Vw * sin(radians))) *
|
(c->move_vec.Vx - c->move_vec.Vw * sin(radians))) *
|
||||||
(180.0f / M_PI);
|
(180.0f / M_PI);
|
||||||
c->chassis2006_setangle=c->param->chassis2006_setangle;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHASSIS_MODE_BREAK:
|
case CHASSIS_MODE_BREAK:
|
||||||
@ -264,82 +295,61 @@ void Chassis_speed_calculate(Chassis_t *c, Chassis_CMD_t *c_cmd)
|
|||||||
|
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[i] = 0.0f;
|
c->hopemotorout.Wheel_DIR_Solving_1[i] = 0.0f;
|
||||||
}
|
}
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[0] = 6.26554489/M_PI*180.0f;
|
// c->hopemotorout.Radder_DIR_Solving_1[0] = 6.26554489/M_PI*180.0f;
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[1] = 2.1099906/M_PI*180.0f;
|
// c->hopemotorout.Radder_DIR_Solving_1[1] = 2.1099906/M_PI*180.0f;
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[2] = 2.08391285/M_PI*180.0f;
|
// c->hopemotorout.Radder_DIR_Solving_1[2] = 2.08391285/M_PI*180.0f;
|
||||||
// c->hopemotorout.rotor6020_jiesuan_1[3] = 5.26845694/M_PI*180.0f;
|
// c->hopemotorout.Radder_DIR_Solving_1[3] = 5.26845694/M_PI*180.0f;
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[0] = 315;
|
// c->hopemotorout.Radder_DIR_Solving_1[0] = 315;
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[1] = 45;
|
// c->hopemotorout.Radder_DIR_Solving_1[1] = 45;
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[2] = 315;
|
// c->hopemotorout.Radder_DIR_Solving_1[2] = 315;
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[3] = 45;
|
// c->hopemotorout.Radder_DIR_Solving_1[3] = 45;
|
||||||
|
|
||||||
|
c->hopemotorout.Radder_DIR_Solving_1[0] = 0;
|
||||||
c->chassis2006_setangle=0;
|
c->hopemotorout.Radder_DIR_Solving_1[1] = 0;
|
||||||
|
c->hopemotorout.Radder_DIR_Solving_1[2] = 0;
|
||||||
|
c->hopemotorout.Radder_DIR_Solving_1[3] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HUIHANG_BIANXING_DUOLUN:
|
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[0] = 90;
|
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[1] = 90;
|
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[2] = 270;
|
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[3] = 270;
|
|
||||||
c->chassis2006_setangle = c->param->chassis2006_setangle;
|
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
c->hopemotorout.rotor3508_jiesuan_1[i] = 0.0f;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// c->hopemotorout.rotor3508_jiesuan_1[0] = PID_Calc(&c->pid.chassis_3508_anglepid[0],c->chassis3508_setangle,c->motorfeedback.rotor_angle3508[0],0.0f,c->dt);
|
|
||||||
// c->hopemotorout.rotor3508_jiesuan_1[1] = PID_Calc(&c->pid.chassis_3508_anglepid[1],c->chassis3508_setangle,c->motorfeedback.rotor_angle3508[1],0.0f,c->dt);
|
|
||||||
// c->hopemotorout.rotor3508_jiesuan_1[2] = PID_Calc(&c->pid.chassis_3508_anglepid[2],-c->chassis3508_setangle,c->motorfeedback.rotor_angle3508[2],0.0f,c->dt);
|
|
||||||
// c->hopemotorout.rotor3508_jiesuan_1[3] = PID_Calc(&c->pid.chassis_3508_anglepid[3],-c->chassis3508_setangle,c->motorfeedback.rotor_angle3508[3],0.0f,c->dt);
|
|
||||||
|
|
||||||
// c->out.rotor3508_out[0]=PID_Calc(&c->pid.chassis_3508_OmegaPid[0],c->hopemotorout.rotor3508_jiesuan_1[0],c->motorfeedback.rotor_rpm3508[0],0.0f,c->dt);
|
|
||||||
// c->out.rotor3508_out[1]=PID_Calc(&c->pid.chassis_3508_OmegaPid[1],c->hopemotorout.rotor3508_jiesuan_1[1],c->motorfeedback.rotor_rpm3508[1],0.0f,c->dt);
|
|
||||||
// c->out.rotor3508_out[2]=PID_Calc(&c->pid.chassis_3508_OmegaPid[2],c->hopemotorout.rotor3508_jiesuan_1[2],c->motorfeedback.rotor_rpm3508[2],0.0f,c->dt);
|
|
||||||
// c->out.rotor3508_out[3]=PID_Calc(&c->pid.chassis_3508_OmegaPid[3],c->hopemotorout.rotor3508_jiesuan_1[3],c->motorfeedback.rotor_rpm3508[3],0.0f,c->dt);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
float motor_2006omega = PID_Calc(&c->pid.chassis_2006_anglepid,c->chassis2006_setangle,c->motorfeedback.motor2006_add_angle,0.0f,c->dt);
|
}
|
||||||
c->final_out.final_2006out=PID_Calc(&c->pid.chassis_2006_OmegaPid,motor_2006omega,c->motorfeedback.motor2006_omega,0.0f,c->dt);
|
|
||||||
|
|
||||||
}
|
|
||||||
// 角度归化到0°——360°
|
// 角度归化到0°——360°
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 4; i++)
|
for (uint8_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
if (c->hopemotorout.rotor6020_jiesuan_1[i] < 0)
|
if (c->hopemotorout.Radder_DIR_Solving_1[i] < 0)
|
||||||
{
|
{
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[i] += 360;
|
c->hopemotorout.Radder_DIR_Solving_1[i] += 360;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 4; i++)
|
for (uint8_t i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
float angle_error[4]; // 角度误差
|
float angle_error[4]; // 角度误差
|
||||||
angle_error[i] = c->hopemotorout.rotor6020_jiesuan_1[i] - c->motorfeedback.rotor_angle6020[i];
|
angle_error[i] = c->hopemotorout.Radder_DIR_Solving_1[i] - c->feedback.motor.Radder_DIR_Angle[i];
|
||||||
// 误差角度归化到-180°——+180°
|
// 误差角度归化到-180°——+180°
|
||||||
while (angle_error[i] > 180)
|
while (angle_error[i] > 180)
|
||||||
angle_error[i] -= 360;
|
angle_error[i] -= 360;
|
||||||
while (angle_error[i] < -180)
|
while (angle_error[i] < -180)
|
||||||
angle_error[i] += 360;
|
angle_error[i] += 360;
|
||||||
/*这里发现如果下面的c->motorfeedback.rotor_angle6020[i]+angle_error[i]变为
|
/*这里发现如果下面的c->motorfeedback.rotor_angle6020[i]+angle_error[i]变为
|
||||||
c->hopemotorout.rotor6020_jiesuan_1[i]会导致6020出现故障*/
|
c->hopemotorout.Radder_DIR_Solving_1[i]会导致6020出现故障*/
|
||||||
if (angle_error[i] > 90 && angle_error[i] <= 180)
|
if (angle_error[i] > 90 && angle_error[i] <= 180)
|
||||||
{
|
{
|
||||||
c->hopemotorout.rotor3508_jiesuan_2[i] = c->hopemotorout.rotor3508_jiesuan_1[i];
|
c->hopemotorout.Wheel_DIR_Solving_2[i] = c->hopemotorout.Wheel_DIR_Solving_1[i];
|
||||||
c->hopemotorout.rotor6020_jiesuan_2[i] = c->motorfeedback.rotor_angle6020[i] + angle_error[i] - 180;
|
c->hopemotorout.Radder_DIR_Solving_2[i] = c->feedback.motor.Radder_DIR_Angle[i] + angle_error[i] - 180;
|
||||||
}
|
}
|
||||||
else if (angle_error[i] < -90 && angle_error[i] >= -180)
|
else if (angle_error[i] < -90 && angle_error[i] >= -180)
|
||||||
{
|
{
|
||||||
c->hopemotorout.rotor3508_jiesuan_2[i] = c->hopemotorout.rotor3508_jiesuan_1[i];
|
c->hopemotorout.Wheel_DIR_Solving_2[i] = c->hopemotorout.Wheel_DIR_Solving_1[i];
|
||||||
c->hopemotorout.rotor6020_jiesuan_2[i] = c->motorfeedback.rotor_angle6020[i] + angle_error[i] + 180;
|
c->hopemotorout.Radder_DIR_Solving_2[i] = c->feedback.motor.Radder_DIR_Angle[i] + angle_error[i] + 180;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
c->hopemotorout.rotor3508_jiesuan_2[i] = -c->hopemotorout.rotor3508_jiesuan_1[i];
|
c->hopemotorout.Wheel_DIR_Solving_2[i] = -c->hopemotorout.Wheel_DIR_Solving_1[i];
|
||||||
c->hopemotorout.rotor6020_jiesuan_2[i] = c->motorfeedback.rotor_angle6020[i] + angle_error[i];
|
c->hopemotorout.Radder_DIR_Solving_2[i] = c->feedback.motor.Radder_DIR_Angle[i] + angle_error[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,31 +365,39 @@ int8_t Chassis_update(Chassis_t *c)
|
|||||||
{
|
{
|
||||||
return CHASSIS_ERR_NULL; // 参数错误
|
return CHASSIS_ERR_NULL; // 参数错误
|
||||||
}
|
}
|
||||||
/*更新所有电机数据*/
|
|
||||||
MOTOR_RM_UpdateAll();
|
MOTOR_RM_t *Wheel_DIR_MOTOR[4];
|
||||||
|
MOTOR_RM_t *Radder_DIR_MOTOR[4];
|
||||||
|
|
||||||
/*更新电机反馈*/
|
/*更新电机反馈*/
|
||||||
// for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
// {
|
{
|
||||||
// // c->motorfeedback.rotor_angle6020[i] = (MOTOR_GetRotorAbsAngle(&(MOTOR_RM_GetMotor(&c->param->motor_6020_param[i])->motor)) );
|
/* 轮向电机更新 */
|
||||||
// c->motorfeedback.rotor_angle6020[i] = (MOTOR_GetRotorAbsAngle(&(MOTOR_RM_GetMotor(&c->param->motor_6020_param[i])->motor)) / M_PI * 180.0f) ;
|
MOTOR_RM_Update(&(c->param->motor.Wheel_DIR[i]));
|
||||||
// c->motorfeedback.rotor_rpm6020[i] = (MOTOR_GetRotorSpeed(&(MOTOR_RM_GetMotor(&c->param->motor_6020_param[i])->motor)) / 320);
|
Wheel_DIR_MOTOR[i]= MOTOR_RM_GetMotor(&(c->param->motor.Wheel_DIR[i]));
|
||||||
// c->motorfeedback.rotor_rpm3508[i] = MOTOR_GetRotorSpeed(&(MOTOR_RM_GetMotor(&c->param->motor_3508_param[i])->motor)) /10000;
|
c->feedback.motor.Wheel_DIR[i] = Wheel_DIR_MOTOR[i]->feedback;
|
||||||
// c->motorfeedback.rotor_angle3508[i] = MOTOR_GetRotorAbsAngle(&(MOTOR_RM_GetMotor(&c->param->motor_3508_param[i])->motor)) ;
|
|
||||||
// // c->motorfeedback.rotor_angle6020[i] = MOTOR_GetRotorAbsAngle(&(MOTOR_RM_GetMotor(&c->param->motor_6020_param[i])->motor));
|
|
||||||
|
|
||||||
// // 角度归化到0°——360°并且进行偏移校准
|
/* 舵向电机 */
|
||||||
// c->motorfeedback.rotor_angle6020[i] = fmod(c->motorfeedback.rotor_angle6020[i] - c->motoroffset.MOTOR_OFFSET[i], 360.0);
|
MOTOR_RM_Update(&(c->param->motor.Radder_DIR[i]));
|
||||||
// if (c->motorfeedback.rotor_angle6020[i] < 0)
|
Radder_DIR_MOTOR[i]= MOTOR_RM_GetMotor(&(c->param->motor.Radder_DIR[i]));
|
||||||
// {
|
c->feedback.motor.Radder_DIR[i] = Radder_DIR_MOTOR[i]->feedback;
|
||||||
// c->motorfeedback.rotor_angle6020[i] += 360;
|
/* 单位转换 */
|
||||||
// }
|
c->feedback.motor.Radder_DIR_Angle[i]=c->feedback.motor.Radder_DIR[i].rotor_abs_angle/ M_PI * 180.0f;
|
||||||
// }
|
c->feedback.motor.Radder_DIR_Rpm[i]= c->feedback.motor.Radder_DIR[i].rotor_speed/320;
|
||||||
c->motorfeedback.motor2006_angle = MOTOR_GetRotorAbsAngle(&(MOTOR_RM_GetMotor(&c->param->motor_2006_param)->motor)) ;
|
c->feedback.motor.Wheel_DIR_Angle[i]= c->feedback.motor.Wheel_DIR[i].rotor_speed/10000;
|
||||||
c->motorfeedback.motor2006_rpm = MOTOR_GetRotorSpeed(&(MOTOR_RM_GetMotor(&c->param->motor_2006_param)->motor)) ;
|
|
||||||
|
|
||||||
c->motorfeedback.motor2006_add_angle= motor_add_anagle(c->motorfeedback.motor2006_angle);
|
c->feedback.motor.Radder_DIR_Angle[i] = fmod(c->feedback.motor.Radder_DIR_Angle[i] - c->motoroffset.MOTOR_OFFSET[i], 360.0);
|
||||||
c->motorfeedback.motor2006_omega=c->motorfeedback.motor2006_rpm*M_2PI/60;
|
if (c->feedback.motor.Radder_DIR_Angle[i] < 0)
|
||||||
|
{
|
||||||
|
c->feedback.motor.Radder_DIR_Angle[i] += 360;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MOTOR_RM_Update(&(c->param->motor.Telescope_motor));
|
||||||
|
MOTOR_RM_t *Telescope_RM = MOTOR_RM_GetMotor(&(c->param->motor.Telescope_motor));
|
||||||
|
if (Telescope_RM != NULL)
|
||||||
|
c->feedback.motor.Telescope = Telescope_RM->feedback;
|
||||||
|
c->feedback.motor.Telescope_Omega=c->feedback.motor.Telescope.rotor_speed*M_2PI/ONE_MINUTE;
|
||||||
|
c->feedback.motor.Telescope_SuperiorAngle=motor_add_anagle(c->feedback.motor.Telescope.rotor_abs_angle);
|
||||||
return CHASSIS_OK;
|
return CHASSIS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,7 +425,7 @@ int8_t Chassis_Control(Chassis_t *c, Chassis_CMD_t *c_cmd,uint32_t now)
|
|||||||
{
|
{
|
||||||
return CHASSIS_ERR_MODE; /* 设置模式失败 */
|
return CHASSIS_ERR_MODE; /* 设置模式失败 */
|
||||||
}
|
}
|
||||||
|
float beta;
|
||||||
|
|
||||||
/*根据底盘模式进行不同的控制*/
|
/*根据底盘模式进行不同的控制*/
|
||||||
switch (c->mode)
|
switch (c->mode)
|
||||||
@ -419,7 +437,6 @@ int8_t Chassis_Control(Chassis_t *c, Chassis_CMD_t *c_cmd,uint32_t now)
|
|||||||
c->move_vec.Vx = 0.0f;
|
c->move_vec.Vx = 0.0f;
|
||||||
c->move_vec.Vy = 0.0f;
|
c->move_vec.Vy = 0.0f;
|
||||||
c->move_vec.Vw = 0.0f;
|
c->move_vec.Vw = 0.0f;
|
||||||
c->final_out.final_2006out=0.0f;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RC:
|
case RC:
|
||||||
@ -434,24 +451,25 @@ int8_t Chassis_Control(Chassis_t *c, Chassis_CMD_t *c_cmd,uint32_t now)
|
|||||||
|
|
||||||
case CHASSIS_MODE_ROTOR:
|
case CHASSIS_MODE_ROTOR:
|
||||||
// 小陀螺模式
|
// 小陀螺模式
|
||||||
c->move_vec.Vx =c_cmd->y_l;
|
|
||||||
c->move_vec.Vy =c_cmd->x_l;
|
beta = (c->feedback.motor.gimbal_yaw.rotor_abs_angle / 180.0f * M_PI) - c->mech_zero; // 云台当前角度转弧度
|
||||||
|
float cos_beta = cosf(beta);
|
||||||
|
float sin_beta = sinf(beta);
|
||||||
|
|
||||||
|
c->move_vec.Vx =cos_beta * c_cmd->x_l - sin_beta * c_cmd->y_l;
|
||||||
|
c->move_vec.Vy =sin_beta* c_cmd->x_l + cos_beta * c_cmd->y_l;
|
||||||
c->move_vec.Vw =c->wz_multi* Chassis_CalcWz(CHASSIS_ROTOR_WZ_MIN,CHASSIS_ROTOR_WZ_MAX, now);
|
c->move_vec.Vw =c->wz_multi* Chassis_CalcWz(CHASSIS_ROTOR_WZ_MIN,CHASSIS_ROTOR_WZ_MAX, now);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CHASSIS_MODE_FOLLOW_GIMBAL:
|
case CHASSIS_MODE_FOLLOW_GIMBAL:
|
||||||
// 跟随云台模式
|
// 跟随云台模式
|
||||||
c->move_vec.Vx =c_cmd->y_l;
|
c->move_vec.Vx =-c_cmd->y_l;
|
||||||
c->move_vec.Vy =c_cmd->x_l;
|
c->move_vec.Vy =-c_cmd->x_l;
|
||||||
c->move_vec.Vw = -PID_Calc(&c->pid.chassis_follow_gimbal_pid, 2.0f ,c->motorfeedback.gimbal_yaw_encoder, 0.0f, c->dt);
|
c->move_vec.Vw = PID_Calc(&c->pid.chassis_follow_gimbal_pid, 2.06f ,c->feedback.motor.gimbal_yaw.rotor_abs_angle, 0.0f, c->dt);
|
||||||
|
|
||||||
|
// c->move_vec.Vw = -PID_Calc(&c->pid.chassis_follow_gimbal_pid, c->motorfeedback.gimbal_yaw_encoder-2.07694483f ,c->motorfeedback.gimbal_yaw_encoder, 0.0f, c->dt);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HUIHANG_BIANXING_DUOLUN:
|
|
||||||
// 会航变形舵轮模式
|
|
||||||
c->move_vec.Vx = 0.0f;
|
|
||||||
c->move_vec.Vy = 0.0f;
|
|
||||||
c->move_vec.Vw = 0.0f;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -468,21 +486,20 @@ int8_t Chassis_Control(Chassis_t *c, Chassis_CMD_t *c_cmd,uint32_t now)
|
|||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
float chassis6020_detangle[4]; // 6020解算出的角度
|
float chassis6020_detangle[4]; // 6020解算出的角度
|
||||||
c->hopemotorout.motor6020_target[i] = c->hopemotorout.rotor6020_jiesuan_2[i];
|
c->hopemotorout.Radder_DIR_target[i] = c->hopemotorout.Radder_DIR_Solving_2[i];
|
||||||
chassis6020_detangle[i] = PID_Calc(&(c->pid.chassis_6020anglePid[i]), c->hopemotorout.motor6020_target[i],
|
chassis6020_detangle[i] = PID_Calc(&(c->pid.Radder_DIR_angle[i]), c->hopemotorout.Radder_DIR_target[i],
|
||||||
c->motorfeedback.rotor_angle6020[i], 0.0f, c->dt);
|
c->feedback.motor.Radder_DIR_Angle[i], 0.0f, c->dt);
|
||||||
// c->final_out.final_6020out[i] = chassis6020_detangle[i] ; //单环控制就用这个
|
// c->final_out.final_6020out[i] = chassis6020_detangle[i] ; //单环控制就用这个
|
||||||
c->final_out.final_6020out[i] = PID_Calc(&(c->pid.chassis_6020OmegaPid[i]), chassis6020_detangle[i],
|
c->chassis6020_detangle[i]=chassis6020_detangle[i];
|
||||||
c->motorfeedback.rotor_rpm6020[i], 0.0f, c->dt);
|
c->final_out.final_Radder_DIR[i] = PID_Calc(&(c->pid.Radder_DIR_omega[i]), chassis6020_detangle[i],
|
||||||
|
c->feedback.motor.Radder_DIR_Rpm[i], 0.0f, c->dt);
|
||||||
|
|
||||||
c->out.rotor6020_out[i] = LowPassFilter2p_Apply(&c->filled[7+i], c->final_out.final_6020out[i]);
|
c->out.Radder_DIR[i] = LowPassFilter2p_Apply(&c->filled[7+i], c->final_out.final_Radder_DIR[i]);
|
||||||
|
// c->out.Radder_DIR[i]= c->final_out.final_Radder_DIR[i];
|
||||||
c->hopemotorout.motor3508_target[i] = c->hopemotorout.rotor3508_jiesuan_2[i];
|
c->hopemotorout.Wheel_DIR_target[i] = c->hopemotorout.Wheel_DIR_Solving_2[i];
|
||||||
c->final_out.final_3508out[i] = PID_Calc(&(c->pid.chassis_3508VPID[i]), c->hopemotorout.motor3508_target[i],
|
c->final_out.final_Wheel_DIR[i] = PID_Calc(&(c->pid.Wheel_DIR_omega[i]), c->hopemotorout.Wheel_DIR_target[i],
|
||||||
c->motorfeedback.rotor_rpm3508[i], 0.0f, c->dt);
|
c->feedback.motor.Wheel_DIR_Rpm[i], 0.0f, c->dt);
|
||||||
c->out.rotor3508_out[i] = LowPassFilter2p_Apply(&c->filled[3+i], c->final_out.final_3508out[i]);
|
c->out.Wheel_DIR[i] = LowPassFilter2p_Apply(&c->filled[3+i], c->final_out.final_Wheel_DIR[i]);
|
||||||
|
|
||||||
c->out.motor2006_out=c->final_out.final_2006out;
|
|
||||||
}
|
}
|
||||||
return CHASSIS_OK;
|
return CHASSIS_OK;
|
||||||
}
|
}
|
||||||
@ -490,15 +507,19 @@ int8_t Chassis_Control(Chassis_t *c, Chassis_CMD_t *c_cmd,uint32_t now)
|
|||||||
/*电机输出设定和发送*/
|
/*电机输出设定和发送*/
|
||||||
void Chassis_Setoutput(Chassis_t *c)
|
void Chassis_Setoutput(Chassis_t *c)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; i++)
|
|
||||||
{
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
MOTOR_RM_SetOutput(&(c->param->motor_3508_param[i]), c->out.rotor3508_out[i]);
|
MOTOR_RM_SetOutput(&(c->param->motor.Wheel_DIR[i]), c->out.Wheel_DIR[i]);
|
||||||
MOTOR_RM_SetOutput(&(c->param->motor_6020_param[i]), c->out.rotor6020_out[i]);
|
MOTOR_RM_SetOutput(&(c->param->motor.Radder_DIR[i]), c->out.Radder_DIR[i]);
|
||||||
}
|
}
|
||||||
MOTOR_RM_SetOutput(&(c->param->motor_2006_param), c->out.motor2006_out);
|
MOTOR_RM_Ctrl(&(c->param->motor.Wheel_DIR[0]));
|
||||||
MOTOR_RM_SetOutput(&(c->param->motor_3508_param[0]), 1.0f);
|
MOTOR_RM_Ctrl(&(c->param->motor.Wheel_DIR[1]));
|
||||||
MOTOR_RM_Ctrl(&(c->param->motor_3508_param[0]));
|
MOTOR_RM_Ctrl(&(c->param->motor.Wheel_DIR[2]));
|
||||||
MOTOR_RM_Ctrl(&(c->param->motor_6020_param[0]));
|
MOTOR_RM_Ctrl(&(c->param->motor.Wheel_DIR[3]));
|
||||||
MOTOR_RM_Ctrl(&(c->param->motor_2006_param));
|
// MOTOR_RM_Ctrl(&(c->param->motor.Radder_DIR[0]));
|
||||||
|
// MOTOR_RM_Ctrl(&(c->param->motor.Radder_DIR[1]));
|
||||||
|
// MOTOR_RM_Ctrl(&(c->param->motor.Radder_DIR[2]));
|
||||||
|
MOTOR_RM_Ctrl(&(c->param->motor.Radder_DIR[3]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,26 @@ extern "C"
|
|||||||
#define CHASSIS_ERR_TYPE (-4) /*Chassis_Type_t */
|
#define CHASSIS_ERR_TYPE (-4) /*Chassis_Type_t */
|
||||||
|
|
||||||
|
|
||||||
|
// 纵向/横向
|
||||||
|
#define radians atan(1.0f * 390 /390) // 角度制
|
||||||
|
|
||||||
|
|
||||||
|
/*底盘姿态模式*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
STOP_MODE,/* 急停模式 */
|
||||||
|
EXPAND_MODE,/* 展开模式 */
|
||||||
|
REDUCE_MODE,/* 收缩模式 */
|
||||||
|
} CHASSIS_ATTITUDE_MODE_t;
|
||||||
|
|
||||||
|
/*底盘状态*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
STOP_STATE,/* 急停状态 */
|
||||||
|
EXPAND_STATE,/* 展开状态 */
|
||||||
|
REDUCE_STATE,/* 收缩状态 */
|
||||||
|
} CHASSIS_STATE_t;
|
||||||
|
|
||||||
/*底盘模式*/
|
/*底盘模式*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@ -32,15 +52,13 @@ typedef enum
|
|||||||
CHASSIS_MODE_FOLLOW_GIMBAL, /* 通过闭环控制使车头方向跟随云台 */
|
CHASSIS_MODE_FOLLOW_GIMBAL, /* 通过闭环控制使车头方向跟随云台 */
|
||||||
CHASSIS_MODE_ROTOR, /* 小陀螺模式,通过闭环控制使底盘不停旋转 */
|
CHASSIS_MODE_ROTOR, /* 小陀螺模式,通过闭环控制使底盘不停旋转 */
|
||||||
|
|
||||||
HUIHANG_BIANXING_DUOLUN, /*会航将军变形舵轮底盘*/
|
} Chassis_Mode_t;
|
||||||
} Chassis_mode_t;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int cmd_power_on_safe; // 上电安全标志
|
int cmd_power_on_safe; // 上电安全标志
|
||||||
|
Chassis_Mode_t mode;
|
||||||
Chassis_mode_t mode;
|
CHASSIS_ATTITUDE_MODE_t attitude_mode;
|
||||||
|
|
||||||
// 遥控器输出值
|
// 遥控器输出值
|
||||||
fp32 Vx;
|
fp32 Vx;
|
||||||
fp32 Vy;
|
fp32 Vy;
|
||||||
@ -51,9 +69,6 @@ typedef struct
|
|||||||
fp32 y_l;
|
fp32 y_l;
|
||||||
} Chassis_CMD_t;
|
} Chassis_CMD_t;
|
||||||
|
|
||||||
// 纵向/横向
|
|
||||||
#define radians atan(1.0f * 390 /390) // 角度制
|
|
||||||
|
|
||||||
// 四个舵轮的安装误差
|
// 四个舵轮的安装误差
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -63,7 +78,7 @@ typedef struct
|
|||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
||||||
BMI088_t bmi088;
|
|
||||||
|
|
||||||
/*可通过该枚举类型来决定Imu的数据量纲*/
|
/*可通过该枚举类型来决定Imu的数据量纲*/
|
||||||
enum
|
enum
|
||||||
@ -72,36 +87,34 @@ typedef struct
|
|||||||
IMU_RADIAN // 弧度制(0-2pi)
|
IMU_RADIAN // 弧度制(0-2pi)
|
||||||
} angle_mode;
|
} angle_mode;
|
||||||
|
|
||||||
AHRS_Eulr_t imu_eulr; // 解算后存放欧拉角(弧度制)
|
// AHRS_Eulr_t imu_eulr; // 解算后存放欧拉角(弧度制)
|
||||||
} ChassisImu_t;
|
} ChassisImu_t;
|
||||||
|
|
||||||
/*底盘参数结构体*/
|
/*底盘参数结构体*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
/* 改变角度 */
|
||||||
|
float Set_TelescopeAngle;
|
||||||
|
struct{
|
||||||
/*该部分决定PID的参数整定在config中修改*/
|
/*该部分决定PID的参数整定在config中修改*/
|
||||||
KPID_Params_t C6020Omega_param;
|
KPID_Params_t Telescope_Omega;
|
||||||
KPID_Params_t C6020Angle_param;
|
KPID_Params_t Telescope_Angle;
|
||||||
KPID_Params_t M3508v_param;
|
KPID_Params_t Radder_DIR_Omega;
|
||||||
KPID_Params_t chassis_follow_gimbalPID;
|
KPID_Params_t Radder_DIR_Angle;
|
||||||
|
KPID_Params_t Wheel_DIR_Omega;
|
||||||
|
KPID_Params_t chassis_follow_gimbal;
|
||||||
|
}pid;
|
||||||
|
|
||||||
KPID_Params_t chassis_2006_angle_param;
|
struct{
|
||||||
KPID_Params_t chassis_2006_Omega_param;
|
MOTOR_RM_Param_t Wheel_DIR[4]; // 四个轮向电机
|
||||||
KPID_Params_t chassis_3508_angle_param;
|
MOTOR_RM_Param_t Radder_DIR[4]; // 四个舵向电机
|
||||||
KPID_Params_t chassis_3508_Omega_param;
|
MOTOR_RM_Param_t chassis_follow_gimbal; // 底盘跟随云台
|
||||||
|
MOTOR_RM_Param_t Telescope_motor; //2006电机
|
||||||
|
|
||||||
MOTOR_RM_Param_t motor_3508_param[4]; // 四个3508电机
|
}motor;
|
||||||
MOTOR_RM_Param_t motor_6020_param[4]; // 四个6020电机
|
|
||||||
MOTOR_RM_Param_t motor_2006_param; // 一个2006电机
|
|
||||||
|
|
||||||
// MOTOR_RM_Param_t chassis_follow_gimbal_param; // 底盘跟随云台
|
|
||||||
float mech_zero;/*云台6020的机械中点*/
|
float mech_zero;/*云台6020的机械中点*/
|
||||||
float travel ;/*云台6020的机械行程*/
|
float travel ;/*云台6020的机械行程*/
|
||||||
|
float mech_zero_4310;/*云台4310的机械中点*/
|
||||||
float chassis2006_setangle; // 变形舵轮2006目标角度 大概是48圈
|
|
||||||
float chassis3508_setangle; // 变形舵轮3508目标角度 大概是60度左右
|
|
||||||
|
|
||||||
|
|
||||||
} Chassis_Param_t;
|
} Chassis_Param_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -114,71 +127,64 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
float rotor3508_out[4];
|
float Telescope;
|
||||||
float rotor6020_out[4];
|
float Wheel_DIR[4];
|
||||||
float motor2006_out;
|
float Radder_DIR[4];
|
||||||
} Chassis_out_t;
|
} Chassis_out_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t last_wakeup;
|
uint32_t last_wakeup;
|
||||||
float dt;
|
float dt;
|
||||||
|
float chassis6020_detangle[4];
|
||||||
Chassis_mode_t mode;
|
Chassis_Mode_t mode;
|
||||||
ChassisMove_Vec move_vec; // 最终输入速度
|
ChassisMove_Vec move_vec; // 最终输入速度
|
||||||
|
|
||||||
/*期望的底盘输出值(此处为舵轮解算出的各个电机的期望输出值)ֵ*/
|
/*期望的底盘输出值(此处为舵轮解算出的各个电机的期望输出值)ֵ*/
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
fp32 rotor3508_jiesuan_1[4];
|
fp32 Wheel_DIR_Solving_1[4];
|
||||||
fp32 rotor3508_jiesuan_2[4];
|
fp32 Wheel_DIR_Solving_2[4];
|
||||||
fp32 rotor6020_jiesuan_1[4];
|
fp32 Radder_DIR_Solving_1[4];
|
||||||
fp32 rotor6020_jiesuan_2[4];
|
fp32 Radder_DIR_Solving_2[4];
|
||||||
// fp32 rotor6020_elur_yaw;
|
// fp32 rotor6020_elur_yaw;
|
||||||
|
|
||||||
fp32 motor6020_target[4];
|
fp32 Radder_DIR_target[4];
|
||||||
fp32 motor3508_target[4];
|
fp32 Wheel_DIR_target[4];
|
||||||
|
|
||||||
} hopemotorout;
|
} hopemotorout;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
fp32 final_6020out[4];
|
fp32 final_Telescope;
|
||||||
fp32 final_3508out[4];
|
fp32 final_Radder_DIR[4];
|
||||||
fp32 final_2006out;
|
fp32 final_Wheel_DIR[4];
|
||||||
// fp32 final_pitchout;
|
|
||||||
} final_out;
|
} final_out;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
fp32 rotor_rpm3508[4];
|
struct{
|
||||||
fp32 rotor_current3508[4];
|
float Telescope_SuperiorAngle;
|
||||||
fp32 rotor_angle3508[4];
|
float Telescope_Omega;
|
||||||
fp32 rotor_rpm6020[4];
|
float Radder_DIR_Angle[4];
|
||||||
fp32 rotor_angle6020[4];
|
float Radder_DIR_Rpm[4];
|
||||||
fp32 rotor_current6020[4];
|
float Wheel_DIR_Angle[4];
|
||||||
fp32 rotor_temp6020[4];
|
float Wheel_DIR_Rpm[4];
|
||||||
fp32 motor2006_rpm;
|
MOTOR_Feedback_t Telescope; // 四个轮向电机
|
||||||
fp32 motor2006_omega;
|
MOTOR_Feedback_t Wheel_DIR[4]; // 四个轮向电机
|
||||||
fp32 motor2006_current;
|
MOTOR_Feedback_t Radder_DIR[4];
|
||||||
fp32 motor2006_temp;
|
MOTOR_Feedback_t gimbal_yaw;
|
||||||
fp32 motor2006_angle;
|
}motor;
|
||||||
fp32 motor2006_add_angle;
|
} feedback;
|
||||||
fp32 gimbal_yaw_encoder;
|
|
||||||
} motorfeedback;
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
KPID_t chassis_6020anglePid[4];
|
KPID_t Telescope_angle;
|
||||||
KPID_t chassis_6020OmegaPid[4];
|
KPID_t Telescope_omega;
|
||||||
KPID_t chassis_3508VPID[4];
|
KPID_t Radder_DIR_angle[4];
|
||||||
|
KPID_t Radder_DIR_omega[4];
|
||||||
|
KPID_t Wheel_DIR_omega[4];
|
||||||
KPID_t chassis_follow_gimbal_pid;
|
KPID_t chassis_follow_gimbal_pid;
|
||||||
|
|
||||||
KPID_t chassis_2006_anglepid;
|
|
||||||
KPID_t chassis_2006_OmegaPid;
|
|
||||||
KPID_t chassis_3508_anglepid[4];
|
|
||||||
KPID_t chassis_3508_OmegaPid[4];
|
|
||||||
|
|
||||||
} pid;
|
} pid;
|
||||||
|
|
||||||
uint8_t keeping_angle_flag; // 是否处于保持角度模式
|
uint8_t keeping_angle_flag; // 是否处于保持角度模式
|
||||||
@ -191,18 +197,15 @@ typedef struct
|
|||||||
ChassisImu_t pos088; // 088的实时姿态
|
ChassisImu_t pos088; // 088的实时姿态
|
||||||
MotorOffset_t motoroffset; // 5065校准数据
|
MotorOffset_t motoroffset; // 5065校准数据
|
||||||
Chassis_Param_t *param; // 一些固定的参数
|
Chassis_Param_t *param; // 一些固定的参数
|
||||||
fp32 vofa_send[8]; // vofa输出数据
|
|
||||||
LowPassFilter2p_t filled[11]; // 低通滤波器
|
LowPassFilter2p_t filled[11]; // 低通滤波器
|
||||||
float keep_angle[4]; // 保持的 6020 角度
|
float keep_angle[4]; // 保持的 舵向 角度
|
||||||
|
|
||||||
Chassis_out_t out;
|
Chassis_out_t out;
|
||||||
|
|
||||||
float wz_multi; /* 小陀螺模式旋转方向 */
|
float wz_multi; /* 小陀螺模式旋转方向 */
|
||||||
float mech_zero;/*云台6020的机械中点*/
|
float mech_zero;/*云台6020的机械中点*/
|
||||||
float travel ;/*云台6020的机械行程*/
|
float travel ;/*云台6020的机械行程*/
|
||||||
|
// float mech_zero_4310;/*云台4310的机械中点*/
|
||||||
float chassis2006_setangle; // 变形舵轮2006目标角度 大概是48圈
|
|
||||||
float chassis3508_setangle; // 变形舵轮3508目标角度 大概是60度左右
|
|
||||||
} Chassis_t;
|
} Chassis_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,6 +21,7 @@ static void CMD_RC_BuildChassisCmd(CMD_t *ctx) {
|
|||||||
break;
|
break;
|
||||||
case CMD_SW_MID:
|
case CMD_SW_MID:
|
||||||
ctx->output.chassis.cmd.mode = map->sw_left_mid;
|
ctx->output.chassis.cmd.mode = map->sw_left_mid;
|
||||||
|
ctx->output.chassis.cmd.throttle = ctx->config->sensitivity.move_slow_mult;
|
||||||
break;
|
break;
|
||||||
case CMD_SW_DOWN:
|
case CMD_SW_DOWN:
|
||||||
ctx->output.chassis.cmd.mode = map->sw_left_down;
|
ctx->output.chassis.cmd.mode = map->sw_left_down;
|
||||||
@ -77,10 +78,9 @@ static void CMD_RC_BuildShootCmd(CMD_t *ctx) {
|
|||||||
break;
|
break;
|
||||||
case CMD_SW_UP:
|
case CMD_SW_UP:
|
||||||
ctx->output.shoot.cmd.ready = SHOOT_MODE_SAFE;
|
ctx->output.shoot.cmd.ready = SHOOT_MODE_SAFE;
|
||||||
|
default:
|
||||||
// default:
|
ctx->output.shoot.cmd.ready = false;
|
||||||
// ctx->output.shoot.cmd.ready = false;
|
ctx->output.shoot.cmd.firecmd = false;
|
||||||
// ctx->output.shoot.cmd.firecmd = false;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* 根据D拨杆控制射击 */
|
/* 根据D拨杆控制射击 */
|
||||||
@ -96,9 +96,9 @@ static void CMD_RC_BuildShootCmd(CMD_t *ctx) {
|
|||||||
case CMD_SW_UP:
|
case CMD_SW_UP:
|
||||||
ctx->output.shoot.cmd.ready = false;
|
ctx->output.shoot.cmd.ready = false;
|
||||||
ctx->output.shoot.cmd.firecmd = false;
|
ctx->output.shoot.cmd.firecmd = false;
|
||||||
// default:
|
default:
|
||||||
// ctx->output.shoot.cmd.ready = false;
|
ctx->output.shoot.cmd.ready = false;
|
||||||
// ctx->output.shoot.cmd.firecmd = false;
|
ctx->output.shoot.cmd.firecmd = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,9 +53,9 @@ typedef struct {
|
|||||||
/* RC模式映射配置 - 定义开关位置到模式的映射 */
|
/* RC模式映射配置 - 定义开关位置到模式的映射 */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* 左拨杆映射 - 底盘模式 */
|
/* 左拨杆映射 - 底盘模式 */
|
||||||
Chassis_mode_t sw_left_up;
|
Chassis_Mode_t sw_left_up;
|
||||||
Chassis_mode_t sw_left_mid;
|
Chassis_Mode_t sw_left_mid;
|
||||||
Chassis_mode_t sw_left_down;
|
Chassis_Mode_t sw_left_down;
|
||||||
|
|
||||||
/* 右拨杆映射 - 云台/射击模式 */
|
/* 右拨杆映射 - 云台/射击模式 */
|
||||||
Gimbal_Mode_t gimbal_sw_up;
|
Gimbal_Mode_t gimbal_sw_up;
|
||||||
|
|||||||
@ -18,18 +18,19 @@
|
|||||||
// 机器人参数配置
|
// 机器人参数配置
|
||||||
Config_RobotParam_t robot_config = {
|
Config_RobotParam_t robot_config = {
|
||||||
.chassis={
|
.chassis={
|
||||||
|
.Set_TelescopeAngle=195,
|
||||||
.motor_3508_param[0]={BSP_CAN_1,0x201,MOTOR_M3508,false,false},
|
.pid={
|
||||||
.motor_3508_param[1]={BSP_CAN_1,0x202,MOTOR_M3508,false,false},
|
.Telescope_Omega={
|
||||||
.motor_3508_param[2]={BSP_CAN_1,0x203,MOTOR_M3508,false,false},
|
.k=1.0f,
|
||||||
.motor_3508_param[3]={BSP_CAN_1,0x204,MOTOR_M3508,false,false},
|
.p=0.3f,
|
||||||
.motor_2006_param ={BSP_CAN_1,0x205,MOTOR_M2006,false,true},
|
.i=0.0f,
|
||||||
.motor_6020_param[0]={BSP_CAN_1,0x206,MOTOR_GM6020,false,false},
|
.d=0.001f,
|
||||||
.motor_6020_param[1]={BSP_CAN_1,0x207,MOTOR_GM6020,false,false},
|
.i_limit=1.0f,
|
||||||
.motor_6020_param[2]={BSP_CAN_1,0x208,MOTOR_GM6020,false,false},
|
.out_limit=1.0f,
|
||||||
.motor_6020_param[3]={BSP_CAN_1,0x209,MOTOR_GM6020,false,false},
|
.d_cutoff_freq= -1.0f,
|
||||||
.chassis2006_setangle=195,
|
.range=-1.0f
|
||||||
.chassis_2006_angle_param={
|
},
|
||||||
|
.Telescope_Angle={
|
||||||
.k=1.0f,
|
.k=1.0f,
|
||||||
.p=1.0f,
|
.p=1.0f,
|
||||||
.i=0.2f,
|
.i=0.2f,
|
||||||
@ -39,52 +40,48 @@ Config_RobotParam_t robot_config = {
|
|||||||
.d_cutoff_freq= -1.0f,
|
.d_cutoff_freq= -1.0f,
|
||||||
.range=-M_2PI,
|
.range=-M_2PI,
|
||||||
},
|
},
|
||||||
.chassis_2006_Omega_param={
|
.Radder_DIR_Omega={
|
||||||
.k=1.0f,
|
.k=1.0f,
|
||||||
.p=0.3f,
|
.p=0.4f,
|
||||||
.i=0.0f,
|
.i=0.15f,
|
||||||
|
.d=0.0f,
|
||||||
|
.i_limit=1.0f,
|
||||||
|
.out_limit=1.0f,
|
||||||
|
.d_cutoff_freq= -1.0f,
|
||||||
|
.range=-1.0f
|
||||||
|
},
|
||||||
|
.Radder_DIR_Angle={
|
||||||
|
.k=0.15f,
|
||||||
|
.p=0.20f,
|
||||||
|
.i=0.1f,
|
||||||
.d=0.001f,
|
.d=0.001f,
|
||||||
.i_limit=1.0f,
|
.i_limit=1.0f,
|
||||||
.out_limit=1.0f,
|
|
||||||
.d_cutoff_freq= -1.0f,
|
|
||||||
.range=-1.0f
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
.C6020Omega_param={
|
|
||||||
.k=1.0f,
|
|
||||||
.p=0.5f,
|
|
||||||
.i=0.1f,
|
|
||||||
.d=0.0f,
|
|
||||||
.i_limit=1.0f,
|
|
||||||
.out_limit=1.0f,
|
|
||||||
.d_cutoff_freq= -1.0f,
|
|
||||||
.range=-1.0f
|
|
||||||
},
|
|
||||||
|
|
||||||
.C6020Angle_param={
|
|
||||||
.k=0.2f,
|
|
||||||
.p=0.21f,
|
|
||||||
.i=0.1f,
|
|
||||||
.d=0.0f,
|
|
||||||
.i_limit=1.0f,
|
|
||||||
.out_limit=30.0f,
|
.out_limit=30.0f,
|
||||||
.d_cutoff_freq= -1.0f,
|
.d_cutoff_freq= -1.0f,
|
||||||
.range=360
|
.range=360
|
||||||
},
|
},
|
||||||
|
.Wheel_DIR_Omega={
|
||||||
.M3508v_param={
|
|
||||||
.k=0.2f,
|
.k=0.2f,
|
||||||
.p=0.25f,
|
.p=0.25f,
|
||||||
.i=0.1f,
|
.i=0.1f,
|
||||||
.d=0.0f,
|
.d=0.001f,
|
||||||
.i_limit=1.0f,
|
.i_limit=1.0f,
|
||||||
.out_limit=1.0f,
|
.out_limit=1.0f,
|
||||||
.d_cutoff_freq= -1.0f,
|
.d_cutoff_freq= -1.0f,
|
||||||
.range=-1.0f
|
.range=-1.0f
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
.motor={
|
||||||
|
.Wheel_DIR[0]={BSP_CAN_2,0x201,MOTOR_M3508,true,false},
|
||||||
|
.Wheel_DIR[1]={BSP_CAN_2,0x202,MOTOR_M3508,true,false},
|
||||||
|
.Wheel_DIR[2]={BSP_CAN_2,0x203,MOTOR_M3508,false,false},
|
||||||
|
.Wheel_DIR[3]={BSP_CAN_2,0x204,MOTOR_M3508,false,false},
|
||||||
|
.Telescope_motor={BSP_CAN_1,0x205,MOTOR_M2006,false,true},
|
||||||
|
.Radder_DIR[0]={BSP_CAN_2,0x206,MOTOR_GM6020,false,false},
|
||||||
|
.Radder_DIR[1]={BSP_CAN_2,0x207,MOTOR_GM6020,false,false},
|
||||||
|
.Radder_DIR[2]={BSP_CAN_2,0x208,MOTOR_GM6020,false,false},
|
||||||
|
.Radder_DIR[3]={BSP_CAN_1,0x209,MOTOR_GM6020,false,false},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
@ -152,7 +149,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
.reverse=false
|
.reverse=false
|
||||||
},
|
},
|
||||||
.pit_dm_motor={
|
.pit_dm_motor={
|
||||||
.can=BSP_CAN_2,
|
.can=BSP_CAN_1,
|
||||||
.can_id = 0x02,
|
.can_id = 0x02,
|
||||||
.master_id=0x12,
|
.master_id=0x12,
|
||||||
.module = MOTOR_DM_J4310,
|
.module = MOTOR_DM_J4310,
|
||||||
@ -178,7 +175,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
|
|
||||||
/*欧拉角控制参数*/
|
/*欧拉角控制参数*/
|
||||||
.yaw_omega = {
|
.yaw_omega = {
|
||||||
.k = 0.30f,
|
.k = 0.0f,
|
||||||
.p = 0.4f,
|
.p = 0.4f,
|
||||||
.i = 0.01f,
|
.i = 0.01f,
|
||||||
.d = 0.0f,
|
.d = 0.0f,
|
||||||
@ -198,7 +195,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
.range = M_2PI
|
.range = M_2PI
|
||||||
},
|
},
|
||||||
.pit_omega = {
|
.pit_omega = {
|
||||||
.k = 0.3f,
|
.k = 0.0f,
|
||||||
.p = 0.3f,
|
.p = 0.3f,
|
||||||
.i = 0.0f,
|
.i = 0.0f,
|
||||||
.d = 0.0,
|
.d = 0.0,
|
||||||
@ -241,7 +238,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
.fric = {
|
.fric = {
|
||||||
{
|
{
|
||||||
.param = {
|
.param = {
|
||||||
.can = BSP_CAN_2,
|
.can = BSP_CAN_1,
|
||||||
.id = 0x201,
|
.id = 0x201,
|
||||||
.module = MOTOR_M3508,
|
.module = MOTOR_M3508,
|
||||||
.reverse = false,
|
.reverse = false,
|
||||||
@ -251,7 +248,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.param = {
|
.param = {
|
||||||
.can = BSP_CAN_2,
|
.can = BSP_CAN_1,
|
||||||
.id = 0x202,
|
.id = 0x202,
|
||||||
.module = MOTOR_M3508,
|
.module = MOTOR_M3508,
|
||||||
.reverse = true,
|
.reverse = true,
|
||||||
@ -263,7 +260,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
},
|
},
|
||||||
.trig = {
|
.trig = {
|
||||||
.can = BSP_CAN_1,
|
.can = BSP_CAN_1,
|
||||||
.id = 0x205,
|
.id = 0x203,
|
||||||
.module = MOTOR_M2006,
|
.module = MOTOR_M2006,
|
||||||
.reverse = false,
|
.reverse = false,
|
||||||
.gear=true,
|
.gear=true,
|
||||||
@ -338,7 +335,7 @@ Config_RobotParam_t robot_config = {
|
|||||||
},
|
},
|
||||||
.rc_mode_map = {
|
.rc_mode_map = {
|
||||||
.sw_left_up = CHASSIS_MODE_RELAX,
|
.sw_left_up = CHASSIS_MODE_RELAX,
|
||||||
.sw_left_mid = HUIHANG_BIANXING_DUOLUN,
|
.sw_left_mid = RC,
|
||||||
.sw_left_down = CHASSIS_MODE_FOLLOW_GIMBAL,
|
.sw_left_down = CHASSIS_MODE_FOLLOW_GIMBAL,
|
||||||
|
|
||||||
.gimbal_sw_up = GIMBAL_MODE_RELAX,
|
.gimbal_sw_up = GIMBAL_MODE_RELAX,
|
||||||
|
|||||||
@ -41,16 +41,10 @@ void Task_chassis_ctrl(void *argument) {
|
|||||||
/*接受cmd任务数据*/
|
/*接受cmd任务数据*/
|
||||||
if(osMessageQueueGet(task_runtime.msgq.chassis.cmd, &cmd_chassis, NULL, 0)==osOK);
|
if(osMessageQueueGet(task_runtime.msgq.chassis.cmd, &cmd_chassis, NULL, 0)==osOK);
|
||||||
|
|
||||||
// Chassis_update(&chassis);
|
Chassis_update(&chassis);
|
||||||
// Chassis_Control(&chassis, &cmd_chassis,tick);
|
Chassis_Control(&chassis, &cmd_chassis,tick);
|
||||||
// Chassis_Setoutput(&chassis);
|
Chassis_Setoutput(&chassis);
|
||||||
////{
|
|
||||||
// // 如果没有收到命令,可以执行一个安全停止的逻辑
|
|
||||||
// // 或者什么都不做,让底盘保持上一帧的状态(取决于你的设计)
|
|
||||||
// // 一个安全的选择是让底盘停止
|
|
||||||
// Chassis_CMD_t safe_cmd = {.mode = STOP, .Vx = 0, .Vy = 0, .Vw = 0};
|
|
||||||
// Chassis_Control(&chassis, &safe_cmd,tick);
|
|
||||||
////}
|
|
||||||
|
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
|
|||||||
@ -55,6 +55,7 @@ void Task_Init(void *argument) {
|
|||||||
task_runtime.msgq.shoot.cmd= osMessageQueueNew(2u, sizeof(Shoot_CMD_t), NULL);
|
task_runtime.msgq.shoot.cmd= osMessageQueueNew(2u, sizeof(Shoot_CMD_t), NULL);
|
||||||
task_runtime.msgq.rc.dr16= osMessageQueueNew(2u, sizeof(DR16_t), NULL);
|
task_runtime.msgq.rc.dr16= osMessageQueueNew(2u, sizeof(DR16_t), NULL);
|
||||||
task_runtime.msgq.rc.et16s= osMessageQueueNew(2u, sizeof(ET16s_t), NULL);
|
task_runtime.msgq.rc.et16s= osMessageQueueNew(2u, sizeof(ET16s_t), NULL);
|
||||||
|
task_runtime.msgq.rc.et16s= osMessageQueueNew(2u, sizeof(ET16s_t), NULL);
|
||||||
/* USER MESSAGE END */
|
/* USER MESSAGE END */
|
||||||
|
|
||||||
osKernelUnlock(); // 解锁内核
|
osKernelUnlock(); // 解锁内核
|
||||||
|
|||||||
@ -45,7 +45,7 @@ void Task_shoot_ctrl(void *argument) {
|
|||||||
// shoot.target_variable.target_rpm=4000;
|
// shoot.target_variable.target_rpm=4000;
|
||||||
// shoot.mode=shoot_ctrl_cmd_rc.mode;
|
// shoot.mode=shoot_ctrl_cmd_rc.mode;
|
||||||
Shoot_UpdateFeedback(&shoot);
|
Shoot_UpdateFeedback(&shoot);
|
||||||
Shoot_Control(&shoot,&shoot_cmd);
|
// Shoot_Control(&shoot,&shoot_cmd);
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,14 +16,17 @@
|
|||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private variables -------------------------------------------------------- */
|
/* Private variables -------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
/* USER STRUCT BEGIN */
|
||||||
STEP_MOTOR StepMotor_param={
|
MOTOR_STEP_t StepMotor_param={
|
||||||
.direction=true,
|
|
||||||
|
.param={
|
||||||
|
.channel=BSP_PWM_TIM1_CH1,
|
||||||
|
.reverse=false,
|
||||||
|
.gear=false,
|
||||||
|
},
|
||||||
.pulse=900,
|
.pulse=900,
|
||||||
.time=500,
|
|
||||||
|
|
||||||
};
|
};
|
||||||
int key1=1;
|
int key1=1;
|
||||||
ET16S_SwitchPos_t Key_A;
|
|
||||||
int prev_state ; // 初始为无状态
|
int prev_state ; // 初始为无状态
|
||||||
/* USER STRUCT END */
|
/* USER STRUCT END */
|
||||||
|
|
||||||
@ -48,8 +51,12 @@ void Task_step_motor(void *argument) {
|
|||||||
while (1) {
|
while (1) {
|
||||||
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
tick += delay_tick; /* 计算下一个唤醒时刻 */
|
||||||
/* USER CODE BEGIN */
|
/* USER CODE BEGIN */
|
||||||
if(osMessageQueueGet(task_runtime.msgq.chassis.SetpMotor, &Key_A, NULL, 0)==osOK);
|
|
||||||
Motor_Step_Ctrl(&StepMotor_param);
|
|
||||||
|
// Motor_Step_Ctrl(&StepMotor_param);
|
||||||
|
//
|
||||||
|
|
||||||
|
// Motor_Step_Ctrl(&StepMotor_param);
|
||||||
/* USER CODE END */
|
/* USER CODE END */
|
||||||
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
osDelayUntil(tick); /* 运行结束,等待下一次唤醒 */
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ extern "C" {
|
|||||||
#define ATTI_ESTI_FREQ (500.0)
|
#define ATTI_ESTI_FREQ (500.0)
|
||||||
#define DR16_FREQ (500.0)
|
#define DR16_FREQ (500.0)
|
||||||
#define CMD_FREQ (500.0)
|
#define CMD_FREQ (500.0)
|
||||||
#define STEP_MOTOR_FREQ (500.0)
|
#define STEP_MOTOR_FREQ (600.0)
|
||||||
#define ET16S_FREQ (500.0)
|
#define ET16S_FREQ (500.0)
|
||||||
#define VOFA_FREQ (500.0)
|
#define VOFA_FREQ (500.0)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user