Compare commits
	
		
			2 Commits
		
	
	
		
			5b856e6b87
			...
			94f899f27b
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 94f899f27b | |||
| adbf87522c | 
| @ -103,7 +103,7 @@ void MX_USART6_UART_Init(void) | ||||
| 
 | ||||
|   /* USER CODE END USART6_Init 1 */ | ||||
|   huart6.Instance = USART6; | ||||
|   huart6.Init.BaudRate = 115200; | ||||
|   huart6.Init.BaudRate = 4000000; | ||||
|   huart6.Init.WordLength = UART_WORDLENGTH_8B; | ||||
|   huart6.Init.StopBits = UART_STOPBITS_1; | ||||
|   huart6.Init.Parity = UART_PARITY_NONE; | ||||
|  | ||||
| @ -13,6 +13,7 @@ int8_t up_init(UP_t *u,const UP_Param_t *param,float target_freq) | ||||
| { | ||||
| 	 u->param = param; 	/*初始化参数 */ | ||||
|     | ||||
| 	GO_M8010_init(); | ||||
| 	PID_init (&u->pid.VESC_5065_M1 ,PID_POSITION ,&(u->param ->VESC_5065_M1_param  )); | ||||
| 	PID_init (&u->pid.VESC_5065_M2 ,PID_POSITION ,&(u->param ->VESC_5065_M2_param )); | ||||
| 
 | ||||
|  | ||||
| @ -48,3 +48,15 @@ bool CRC16_Verify(const uint8_t *buf, size_t len) { | ||||
|          ((const uint16_t *)((const uint8_t *)buf + | ||||
|                              (len % 2)))[len / sizeof(uint16_t) - 1]; | ||||
| } | ||||
| 
 | ||||
| uint16_t do_crc_table(uint8_t *ptr, int len) | ||||
| { | ||||
|     uint16_t crc = 0x0000; | ||||
|      | ||||
|     while(len--)  | ||||
|     { | ||||
|         crc = (crc >> 8) ^ crc16_tab[(crc ^ *ptr++) & 0xff]; | ||||
|     } | ||||
|      | ||||
|     return crc; | ||||
| } | ||||
|  | ||||
| @ -12,6 +12,7 @@ extern "C" { | ||||
| 
 | ||||
| uint16_t CRC16_Calc(const uint8_t *buf, size_t len, uint16_t crc); | ||||
| bool CRC16_Verify(const uint8_t *buf, size_t len); | ||||
| uint16_t do_crc_table(uint8_t *ptr, int len); | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| } | ||||
|  | ||||
| @ -7,7 +7,7 @@ | ||||
| #include <cmsis_os2.h> | ||||
| 
 | ||||
| GO_Motorfield GO_motor_info[GO_NUM];//存放电机数据
 | ||||
| const float gravit_const =9.81;//计算前馈力矩有关
 | ||||
| static const float gravit_const =9.81;//计算前馈力矩有关
 | ||||
| 
 | ||||
| //数据处理函数
 | ||||
| static void GO_M8010_recv_data(uint8_t* Temp_buffer); | ||||
| @ -38,7 +38,7 @@ void GO_M8010_init (){ | ||||
| 
 | ||||
| 
 | ||||
| //暂存接收数据
 | ||||
| static uint8_t Temp_buffer[16]; | ||||
| uint8_t Temp_buffer[16]; | ||||
| 
 | ||||
| void USART6_RxCompleteCallback(void )  | ||||
| { | ||||
| @ -79,12 +79,12 @@ void uartTxCB(UART_HandleTypeDef *huart) | ||||
| 	*@input[in]		K_W 速度环kp | ||||
| 	*@note				控制公式 : t = T + (设定位置 - 实际位置)*K_P + (设定速度 - 实际速度)*K_W | ||||
| 	*/ | ||||
|     GO_Motorfield* motor; | ||||
| 
 | ||||
| void GO_M8010_send_data(UART_HandleTypeDef *huart, int id,int rev,float T,float Pos, | ||||
|                          float W,float K_P,float K_W) | ||||
| { | ||||
|     // a pointer to target motor
 | ||||
|     GO_Motorfield* motor; | ||||
|     motor = GO_motor_info+id; | ||||
| 		 | ||||
| 	  //这个rev是干啥的
 | ||||
| @ -130,7 +130,7 @@ void GO_M8010_send_data(UART_HandleTypeDef *huart, int id,int rev,float T,float | ||||
| 
 | ||||
|     // interrupt buffer sending
 | ||||
|     HAL_UART_Transmit_IT(huart,motor->buffer,sizeof(motor->buffer)); | ||||
|     osDelay(100); | ||||
|     osDelay(1000); | ||||
|     HAL_UART_Receive_DMA(huart, Temp_buffer, 16);//有无都可以
 | ||||
| 
 | ||||
|      | ||||
|  | ||||
| @ -35,23 +35,22 @@ typedef struct | ||||
|     uint16_t  k_pos;        // <20><><EFBFBD><EFBFBD><EFBFBD>ؽڸն<DAB8>ϵ<EFBFBD><CFB5> unit: 0.0-1.0 (q15)
 | ||||
|     uint16_t  k_spd;        // <20><><EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><D8BD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5> unit: 0.0-1.0 (q15)
 | ||||
|      | ||||
| } RIS_Comd_t;   // <20><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD> 12Byte
 | ||||
| 
 | ||||
| } RIS_Comd_t;    | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /**
 | ||||
|  * @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݰ<EFBFBD><EFBFBD><EFBFBD>ʽ | ||||
|  * | ||||
|  *  | ||||
|  */ | ||||
| typedef struct | ||||
| { | ||||
|     uint8_t head[2];    // <20><>ͷ         2Byte
 | ||||
|     RIS_Mode_t mode;    // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ  1Byte
 | ||||
|     RIS_Comd_t comd;    // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 12Byte
 | ||||
|     uint16_t   CRC16;   // CRC          2Byte
 | ||||
|     uint8_t head[2];     | ||||
|     RIS_Mode_t mode;     | ||||
|     RIS_Comd_t comd;    | ||||
|     uint16_t   CRC16;   | ||||
| 
 | ||||
| } ControlData_t;    // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>     17Byte
 | ||||
| } ControlData_t;     | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -102,7 +102,6 @@ typedef struct { | ||||
|   BSP_CAN_t chassis5065; | ||||
| 	BSP_CAN_t motor3508; | ||||
| 	BSP_CAN_t pitch6020; | ||||
| 	 | ||||
| 	BSP_CAN_t sick; | ||||
| } CAN_Params_t; | ||||
| 
 | ||||
|  | ||||
| @ -55,8 +55,11 @@ void Task_up(void *argument) | ||||
| //    GM6020_control(&UP, 100) ;
 | ||||
| //			UP_M2006_angle(&UP, 180);
 | ||||
| //			UP_M3508_speed(&UP, 500);
 | ||||
| //			VESC_M5065_Control(&UP, 1000);
 | ||||
| 			VESC_M5065_Control(&UP, 00); | ||||
| 		ALL_Motor_Control(&UP,&UP_CAN_out); | ||||
| //    GO_M8010_send_data(&huart6, 0,0,0,5,10,0.12,0.08);
 | ||||
| 		osDelay(1); | ||||
| 			 | ||||
| 
 | ||||
| 	/*imu数据获取*/					 | ||||
| 	osMessageQueueGet(task_runtime.msgq.imu.eulr, &UP.pos088.imu_eulr, NULL, 0); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user