|
|
|
@ -67,13 +67,14 @@ void Fsm_Init() |
|
|
|
void GF_Dispatch() |
|
|
|
{ |
|
|
|
IV_Control(); |
|
|
|
|
|
|
|
|
|
|
|
IO_Control(); |
|
|
|
|
|
|
|
Mode_Control(); |
|
|
|
|
|
|
|
// 限位安全检测
|
|
|
|
Limit_Detection(); |
|
|
|
// 急停
|
|
|
|
EmergencyStopControl(); |
|
|
|
|
|
|
|
action_perfrom(MoveTransitions,sizeof(MoveTransitions) / sizeof(transition_t), CurrentMoveState); |
|
|
|
action_perfrom(FrontendMoveTransitions, |
|
|
|
@ -82,6 +83,19 @@ void GF_Dispatch() |
|
|
|
sizeof(StrongGrindingMachineTransitions) / sizeof(transition_t), StrongGrindingMachineCurrentState); |
|
|
|
} |
|
|
|
|
|
|
|
void EmergencyStopControl() |
|
|
|
{ |
|
|
|
if((GV.MK32_Key.CH8_SE == -1000) && GV.MK32_Key.CH9_SF == -1000) |
|
|
|
{ |
|
|
|
CurrentMoveState = Move_HALT; |
|
|
|
CurrentFrontEndState = HALT_STATE; |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
} |
|
|
|
else{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t upper_limit_position = 0; |
|
|
|
uint8_t lower_limit_position = 0; |
|
|
|
|
|
|
|
@ -128,6 +142,19 @@ void Mode_Control() |
|
|
|
void IO_Control() |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(4, 1); |
|
|
|
|
|
|
|
if(StrongGrindingMachineCurrentState == STRONG_GRINDING_MACHINE_MOTION_STATE) |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(5, 0); |
|
|
|
} |
|
|
|
else if(StrongGrindingMachineCurrentState == STRONG_GRINDING_MACHINE_HALT_STATE) |
|
|
|
{ |
|
|
|
GF_BSP_GPIO_SetIO(5, 1); |
|
|
|
} |
|
|
|
else{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
uint8_t IsAllowRotation_AutoMode = 0; |
|
|
|
@ -150,33 +177,35 @@ void Automatic_Operation() |
|
|
|
case 5: |
|
|
|
knife_current_altitude = GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance; |
|
|
|
auto_work_mode_states = 10; |
|
|
|
auto_work_halt_states = 10; |
|
|
|
break; |
|
|
|
case 10: |
|
|
|
CurrentFrontEndState = Manual_DOWN_STATE; |
|
|
|
IsAllowRotation_AutoMode = Knife_Detection(); |
|
|
|
if(IsAllowRotation_AutoMode == 1) |
|
|
|
{ |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_MOTION_STATE; |
|
|
|
} |
|
|
|
else{ |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
} |
|
|
|
|
|
|
|
if(knife_current_altitude - GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance |
|
|
|
>= knife_descent_height) |
|
|
|
{ |
|
|
|
CurrentFrontEndState = HALT_STATE; |
|
|
|
auto_work_halt_states = 10; |
|
|
|
auto_work_mode_states = 20; |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
case 20: |
|
|
|
IsAllowRotation_AutoMode = Knife_Detection(); |
|
|
|
if(IsAllowRotation_AutoMode == 1) |
|
|
|
{ |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_MOTION_STATE; |
|
|
|
|
|
|
|
delay_counts = delay_counts + 1; |
|
|
|
if(delay_counts >= 500) |
|
|
|
{ |
|
|
|
delay_counts = 0; |
|
|
|
CurrentMoveState = AUTO_FORWARD; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case 30: |
|
|
|
@ -192,15 +221,13 @@ void Automatic_Operation() |
|
|
|
else{ |
|
|
|
delay_counts = 0; |
|
|
|
CurrentMoveState = Move_HALT; |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
|
|
|
|
if(auto_work_mode_states == 10) |
|
|
|
if(auto_work_mode_states == 5) |
|
|
|
{ |
|
|
|
CurrentFrontEndState = HALT_STATE; |
|
|
|
auto_work_mode_states = 5; |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
} |
|
|
|
else if(auto_work_mode_states == 20) |
|
|
|
{ |
|
|
|
else{ |
|
|
|
switch(auto_work_halt_states) |
|
|
|
{ |
|
|
|
case 10: |
|
|
|
@ -209,19 +236,16 @@ void Automatic_Operation() |
|
|
|
break; |
|
|
|
case 20: |
|
|
|
CurrentFrontEndState = Manual_UP_STATE; |
|
|
|
|
|
|
|
if(GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance - knife_current_altitude |
|
|
|
>= knife_rising_height) |
|
|
|
{ |
|
|
|
auto_work_mode_states = 5; |
|
|
|
CurrentFrontEndState = HALT_STATE; |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
auto_work_mode_states = 5; |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
auto_work_mode_states = 5; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -238,15 +262,11 @@ void Strong_Grinding_Machine_Control() |
|
|
|
} |
|
|
|
else{ |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
// 只有在刀到位且不转的时候和刀未到位的时候可以控制
|
|
|
|
IO_Control(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else{ |
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
// 只有在刀到位且不转的时候和刀未到位的时候可以控制
|
|
|
|
IO_Control(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
@ -372,6 +392,7 @@ void IV_Control() |
|
|
|
IV.laser_sensor_1_measure_distance = GV.ZHR29_200_measure_results.laser_sensor_1_measure_distance; |
|
|
|
IV.laser_sensor_2_measure_distance = GV.ZHR29_200_measure_results.laser_sensor_2_measure_distance; |
|
|
|
IV.laser_sensor_3_measure_distance = GV.ZHR29_200_measure_results.laser_sensor_3_measure_distance; |
|
|
|
IV.kinfe_complete_signal = IsAllowRotation; |
|
|
|
} |
|
|
|
|
|
|
|
void Robot_Control() |
|
|
|
|