From 8e59e3655769437abf730488d8230e9388ca7861 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Tue, 27 Oct 2026 14:20:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=E6=88=90=E4=B9=8B=E5=89=8D?= =?UTF-8?q?=E7=9A=84=E7=94=B5=E6=9C=BA=E5=8F=98=E9=A2=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Src/MSP/msp_Strong_grinding_machine.c | 60 +++++++++++-------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_Strong_grinding_machine.c b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_Strong_grinding_machine.c index 7d7c077..b02a256 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_Strong_grinding_machine.c +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/BASE/Src/MSP/msp_Strong_grinding_machine.c @@ -31,40 +31,50 @@ void strong_grinding_machine_intialize(struct UARTHandler *Handler) // 测试,转速20rpm const uint8_t strong_grinding_machine_set_speed_cmd[8] = {0x01, 0x06, 0x00, 0x02, 0x00, 0x14, 0x28, 0x05}; -const uint8_t strong_grinding_machine_start_cmd[8] = {0x01, 0x06, 0x20, 0x00, 0x00, 0x01, 0x43, 0xCA}; -const uint8_t strong_grinding_machine_stop_cmd[8] = {0x01, 0x06, 0x20, 0x00, 0x00, 0x00, 0x82, 0x0A}; +const uint8_t strong_grinding_machine_start_cmd[8] = {0x01, 0x06, 0x00, 0x01, 0x08, 0x82, 0x5F, 0xAB}; +const uint8_t strong_grinding_machine_stop_cmd[8] = {0x01, 0x06, 0x00, 0x01, 0x08, 0x81, 0x1F, 0xAA}; +static uint8_t strong_grinding_machine_cmd_flag = 0; uint8_t strong_grinding_machine_cmd = 0; // 测试,转速20rpm int32_t strong_grinding_machine_speed = 10; void Strong_grinding_machine_cmd(void) { - strong_grinding_machine_speed = GV.PV.main_axis_speed / 15;//公式是转速除以60/p,是极对数,极对数是极数的一半。当前电机极数是8,所以是除以15 + strong_grinding_machine_speed = GV.PV.main_axis_speed; - //发速度 - MB_WriteHoldingReg(&Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, - 0x01, 0x4000, strong_grinding_machine_speed); - Strong_grinding_machine_handler->AddSendList(Strong_grinding_machine_handler, Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, - inquiry_interval, NULL); - - //发是否旋转 - if(strong_grinding_machine_cmd == 0) - { - Strong_grinding_machine_handler->TxCount = 8; - memcpy(&Strong_grinding_machine_handler->Tx_Buf, &strong_grinding_machine_stop_cmd, Strong_grinding_machine_handler->TxCount); - Strong_grinding_machine_handler->AddSendList(Strong_grinding_machine_handler, Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, - inquiry_interval, NULL); - } - else if(strong_grinding_machine_cmd == 1) + switch(strong_grinding_machine_cmd_flag) { - Strong_grinding_machine_handler->TxCount = 8; - memcpy(&Strong_grinding_machine_handler->Tx_Buf, &strong_grinding_machine_start_cmd, Strong_grinding_machine_handler->TxCount); - Strong_grinding_machine_handler->AddSendList(Strong_grinding_machine_handler, Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, - inquiry_interval, NULL); - } - else{ - + case 0: + + MB_WriteHoldingReg(&Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, + 0x01, 0x0002, strong_grinding_machine_speed); +// Strong_grinding_machine_handler->TxCount = 8; +// memcpy(&Strong_grinding_machine_handler->Tx_Buf, &strong_grinding_machine_set_speed_cmd, Strong_grinding_machine_handler->TxCount); + Strong_grinding_machine_handler->AddSendList(Strong_grinding_machine_handler, Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, + inquiry_interval, NULL); + strong_grinding_machine_cmd_flag = 1; + break; + case 1: + if(strong_grinding_machine_cmd == 0) + { + Strong_grinding_machine_handler->TxCount = 8; + memcpy(&Strong_grinding_machine_handler->Tx_Buf, &strong_grinding_machine_stop_cmd, Strong_grinding_machine_handler->TxCount); + Strong_grinding_machine_handler->AddSendList(Strong_grinding_machine_handler, Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, + inquiry_interval, NULL); + } + else if(strong_grinding_machine_cmd == 1) + { + Strong_grinding_machine_handler->TxCount = 8; + memcpy(&Strong_grinding_machine_handler->Tx_Buf, &strong_grinding_machine_start_cmd, Strong_grinding_machine_handler->TxCount); + Strong_grinding_machine_handler->AddSendList(Strong_grinding_machine_handler, Strong_grinding_machine_handler->Tx_Buf, Strong_grinding_machine_handler->TxCount, + inquiry_interval, NULL); + } + else{ + + } + strong_grinding_machine_cmd_flag = 0; + break; } }