2 changed files with 87 additions and 0 deletions
@ -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_ */ |
||||
@ -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…
Reference in new issue