Browse Source

新增485电机驱动源码

master
Lizongdi 4 days ago
parent
commit
ce6fcce60c
  1. 16
      diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Inc/MSP/msp_LeiSai_485.h
  2. 71
      diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_LeiSai_485.c

16
diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Inc/MSP/msp_LeiSai_485.h

@ -0,0 +1,16 @@
/*
* msp_LeiSai_485.h
*
* Created on: 2025年12月19日
* Author: xsq
*/
#ifndef BASE_INC_MSP_MSP_LEISAI_485_H_
#define BASE_INC_MSP_MSP_LEISAI_485_H_
#include "BHBF_ROBOT.h"
extern uint8_t LS_485Motors_Speed;
#endif /* BASE_INC_MSP_MSP_LEISAI_485_H_ */

71
diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_LeiSai_485.c

@ -0,0 +1,71 @@
/*
* msp_LeiSai_485.c
*
* Created on: 2025年12月19日
* Author: xsq
*/
#include "msp_LeiSai_485.h"
#include "BHBF_ROBOT.h"
//雷赛485电机
struct UARTHandler *LS_485Motors_handler;
DispacherController *LS_485Motors_dispacherController;
uint8_t LS_485Motors_slave_id = 0x00; //默认为0 广播形式
uint8_t LS_485Motors_Speed=0;
uint8_t speedModeSet=1;
void LS_485Motor_loop();
void LS_485Motors_intialize(struct UARTHandler *Handler)
{
LS_485Motors_handler = Handler;
LS_485Motors_handler->Wait_time = 20; //等待10ms 最低不要低于4;
LS_485Motors_dispacherController = Handler->dispacherController;
LS_485Motors_dispacherController->Dispacher_Enable = 1;
//不周期性发送
LS_485Motors_dispacherController->Add_Dispatcher_List(
LS_485Motors_dispacherController, LS_485Motor_loop);
LOG("LS_485Motors_intialize");
}
void LS_485Motor_loop()
{
/*雷赛485电机控制*/
if(speedModeSet==1)
{
MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf,
&LS_485Motors_handler->TxCount, LS_485Motors_slave_id, 0x6208, 0x02);//PR1为速度模式
LS_485Motors_handler->AddSendList(LS_485Motors_handler,
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, OneLineWaitTime,
NULL);
speedModeSet=0;
}
MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf,
&LS_485Motors_handler->TxCount, LS_485Motors_slave_id, 0x620B, LS_485Motors_Speed);//PR1速度
LS_485Motors_handler->AddSendList(LS_485Motors_handler,
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, OneLineWaitTime,
NULL);
MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf,
&LS_485Motors_handler->TxCount, LS_485Motors_slave_id, 0x6002, 0x11);//PR1运行
LS_485Motors_handler->AddSendList(LS_485Motors_handler,
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, OneLineWaitTime,
NULL);
}
Loading…
Cancel
Save