|
|
@ -34,22 +34,33 @@ void LS_485Motors_intialize(struct UARTHandler *Handler) |
|
|
|
|
|
|
|
|
void LS_485Motor_loop() |
|
|
void LS_485Motor_loop() |
|
|
{ |
|
|
{ |
|
|
|
|
|
static uint32_t uiLastSendTick = 0; |
|
|
|
|
|
static int IsInit = 1; |
|
|
|
|
|
if (IsInit) |
|
|
|
|
|
{ |
|
|
|
|
|
uiLastSendTick = HAL_GetTick(); |
|
|
|
|
|
IsInit = 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/*雷赛485电机控制*/ |
|
|
/*雷赛485电机控制*/ |
|
|
if(speedModeSet==1) |
|
|
if(speedModeSet==1) |
|
|
{ |
|
|
{ |
|
|
MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf, |
|
|
if ((int32_t)(HAL_GetTick() - uiLastSendTick) >= 5000) |
|
|
&LS_485Motors_handler->TxCount, LS_485Motors_slave_id, 0x6208, 0x02);//PR1为速度模式
|
|
|
{ |
|
|
|
|
|
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->AddSendList(LS_485Motors_handler, |
|
|
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, |
|
|
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, |
|
|
NULL); |
|
|
NULL); |
|
|
|
|
|
|
|
|
speedModeSet=0; |
|
|
speedModeSet=0; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
MB_WriteHoldingReg(&LS_485Motors_handler->Tx_Buf, |
|
|
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->AddSendList(LS_485Motors_handler, |
|
|
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, |
|
|
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->AddSendList(LS_485Motors_handler, |
|
|
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, |
|
|
LS_485Motors_handler->Tx_Buf, LS_485Motors_handler->TxCount, 50, |
|
|
NULL); |
|
|
NULL); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|