From cfc74a361d9952cbb736e0177e67e0f9fad594fb Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Tue, 27 Oct 2026 15:40:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8A=E8=80=B3=E5=88=87=E5=89=B2=20?= =?UTF-8?q?=E3=80=90=E8=B0=83=E9=80=9A=E6=89=93=E6=A0=87=E3=80=91=E5=BB=B6?= =?UTF-8?q?=E6=97=B65s=E5=86=8D=E5=8F=91=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/BASE/Src/MSP/msp_LeiSai_485.c | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_LeiSai_485.c b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_LeiSai_485.c index 53c25ac..4909672 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_LeiSai_485.c +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_LeiSai_485.c @@ -34,22 +34,33 @@ void LS_485Motors_intialize(struct UARTHandler *Handler) void LS_485Motor_loop() { + static uint32_t uiLastSendTick = 0; + static int IsInit = 1; + if (IsInit) + { + uiLastSendTick = HAL_GetTick(); + IsInit = 0; + } /*雷赛485电机控制*/ if(speedModeSet==1) { - MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf, - &LS_485Motors_handler->TxCount, LS_485Motors_slave_id, 0x6208, 0x02);//PR1为速度模式 + if ((int32_t)(HAL_GetTick() - uiLastSendTick) >= 5000) + { + 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, 50, - NULL); + LS_485Motors_handler->AddSendList(LS_485Motors_handler, + LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, + NULL); - speedModeSet=0; + speedModeSet=0; + } } - + else + { MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf, - &LS_485Motors_handler->TxCount, LS_485Motors_slave_id, 0x620B, LS_485Motors_Speed);//PR1速度 + &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, 50, @@ -61,10 +72,7 @@ void LS_485Motor_loop() LS_485Motors_handler->AddSendList(LS_485Motors_handler, LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, NULL); - - - - + } }