diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml b/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml index 07f8dd5..15fa460 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/.settings/language.settings.xml @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ - + diff --git a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c index fccc040..b792187 100644 --- a/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c +++ b/diaoerqiege/BHBF_Robot_Lifting_Lug/Core/Src/robot_state.c @@ -234,6 +234,8 @@ uint8_t Pin3 = -1; //下限位,为0表示限位触发 int32_t KinfePosition = 1000; // 初始化为一个不合理的大值,等于1000时显示为未标定 int StrongSingleShotFlag = 0; +#define SAFE_MOTOR_COUNT (67*20000) // 电机脉冲安全保护,防止光电限位失效后导致的意外情况 + void Manual_Up_State_Do(void) { int32_t SliderSpeed_PPS = SliderSpeed_mmps_2_pps(SliderSpeed); @@ -252,6 +254,11 @@ void Manual_Up_State_Do(void) GV.LS_FrontEnd_Motor.Target_Velcity = 0; KinfePosition = GV.LS_FrontEnd_Motor.Real_Position; } + + if (GV.LS_FrontEnd_Motor.Real_Position - KinfePosition >= SAFE_MOTOR_COUNT) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; // 电机脉冲数急停 + } } void Manual_Down_State_Do(void) @@ -271,6 +278,11 @@ void Manual_Down_State_Do(void) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; } + + if (GV.LS_FrontEnd_Motor.Real_Position - KinfePosition >= SAFE_MOTOR_COUNT) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; // 电机脉冲数急停 + } } // 定义前端升降电机速度,单位0.1mm/s @@ -294,6 +306,11 @@ void Manual_Low_Speed_Up_State_Do(void) GV.LS_FrontEnd_Motor.Target_Velcity = 0; KinfePosition = GV.LS_FrontEnd_Motor.Real_Position; } + + if (GV.LS_FrontEnd_Motor.Real_Position - KinfePosition >= SAFE_MOTOR_COUNT) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; // 电机脉冲数急停 + } } void Manual_low_speed_Down_State_Do(void) @@ -313,6 +330,11 @@ void Manual_low_speed_Down_State_Do(void) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; } + + if (GV.LS_FrontEnd_Motor.Real_Position - KinfePosition >= SAFE_MOTOR_COUNT) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; // 电机脉冲数急停 + } } #define STEP_LEN_COUNT 20000 // 位置环每20000个count对应1mm @@ -339,6 +361,11 @@ void Manual_step_Up_State_Do(void) GV.LS_FrontEnd_Motor.Target_Velcity = 0; KinfePosition = GV.LS_FrontEnd_Motor.Real_Position; } + + if (GV.LS_FrontEnd_Motor.Real_Position - KinfePosition >= SAFE_MOTOR_COUNT) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; // 电机脉冲数急停 + } } void Manual_step_Down_State_Do(void) @@ -362,6 +389,11 @@ void Manual_step_Down_State_Do(void) { GV.LS_FrontEnd_Motor.Target_Velcity = 0; } + + if (GV.LS_FrontEnd_Motor.Real_Position - KinfePosition >= SAFE_MOTOR_COUNT) + { + GV.LS_FrontEnd_Motor.Target_Velcity = 0; // 电机脉冲数急停 + } } void FrontEnd_Halt_State_Do(void)