|
|
@ -12,6 +12,7 @@ |
|
|
#include "msp_TL720D.h" |
|
|
#include "msp_TL720D.h" |
|
|
#include "robot_state.h" |
|
|
#include "robot_state.h" |
|
|
#include "bsp_TIMER.h" |
|
|
#include "bsp_TIMER.h" |
|
|
|
|
|
#include "msp_Strong_grinding_machine.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void action_perfrom(transition_t transitions[], int length, int state); |
|
|
void action_perfrom(transition_t transitions[], int length, int state); |
|
|
@ -24,6 +25,8 @@ static void Frontend_Control(); |
|
|
|
|
|
|
|
|
MoveSTATE_t CurrentMoveState; |
|
|
MoveSTATE_t CurrentMoveState; |
|
|
Front_MoveSTATE_t CurrentFrontEndState; |
|
|
Front_MoveSTATE_t CurrentFrontEndState; |
|
|
|
|
|
Strong_Grinding_Machine_MoveSTATE_t StrongGrindingMachineCurrentState; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int index_counter = 0; |
|
|
static int index_counter = 0; |
|
|
|
|
|
|
|
|
@ -34,7 +37,6 @@ transition_t MoveTransitions[] = |
|
|
{ Move_HALT, HALT_State_Do }, |
|
|
{ Move_HALT, HALT_State_Do }, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transition_t FrontendMoveTransitions[] = |
|
|
transition_t FrontendMoveTransitions[] = |
|
|
{ |
|
|
{ |
|
|
{ HALT_STATE, FrontEnd_Halt_State_Do}, |
|
|
{ HALT_STATE, FrontEnd_Halt_State_Do}, |
|
|
@ -43,6 +45,16 @@ transition_t FrontendMoveTransitions[] = |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
transition_t StrongGrindingMachineTransitions[] = |
|
|
|
|
|
{ |
|
|
|
|
|
{ STRONG_GRINDING_MACHINE_HALT_STATE, Strong_Grinding_Machine_Halt_State_Do}, |
|
|
|
|
|
{ STRONG_GRINDING_MACHINE_MOTION_STATE, Strong_Grinding_Machine_Motion_State_Do}, |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Fsm_Init() |
|
|
void Fsm_Init() |
|
|
{ |
|
|
{ |
|
|
GF_BSP_Interrupt_Add_CallBack( |
|
|
GF_BSP_Interrupt_Add_CallBack( |
|
|
@ -60,9 +72,67 @@ void GF_Dispatch() |
|
|
// 前端控制
|
|
|
// 前端控制
|
|
|
Frontend_Control(); |
|
|
Frontend_Control(); |
|
|
|
|
|
|
|
|
|
|
|
//强磨机控制
|
|
|
|
|
|
Strong_Grinding_Machine_Control(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
action_perfrom(MoveTransitions,sizeof(MoveTransitions) / sizeof(transition_t), CurrentMoveState); |
|
|
action_perfrom(MoveTransitions,sizeof(MoveTransitions) / sizeof(transition_t), CurrentMoveState); |
|
|
action_perfrom(FrontendMoveTransitions, |
|
|
action_perfrom(FrontendMoveTransitions, |
|
|
sizeof(FrontendMoveTransitions) / sizeof(transition_t), CurrentFrontEndState); |
|
|
sizeof(FrontendMoveTransitions) / sizeof(transition_t), CurrentFrontEndState); |
|
|
|
|
|
action_perfrom(StrongGrindingMachineTransitions, |
|
|
|
|
|
sizeof(StrongGrindingMachineTransitions) / sizeof(transition_t), StrongGrindingMachineCurrentState); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t IsAllowRotation = 0; |
|
|
|
|
|
void Strong_Grinding_Machine_Control() |
|
|
|
|
|
{ |
|
|
|
|
|
GF_BSP_GPIO_SetIO(4, 1); |
|
|
|
|
|
IsAllowRotation = Knife_Detection(); |
|
|
|
|
|
if(IsAllowRotation == 1) |
|
|
|
|
|
{ |
|
|
|
|
|
if(GV.MK32_Key.CH7_SD == -1000) |
|
|
|
|
|
{ |
|
|
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_MOTION_STATE; |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
StrongGrindingMachineCurrentState = STRONG_GRINDING_MACHINE_HALT_STATE; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t loosening_knife_signal = 0; |
|
|
|
|
|
uint8_t clamping_knife_signal = 0; |
|
|
|
|
|
|
|
|
|
|
|
int Knife_Detection(void) |
|
|
|
|
|
{ |
|
|
|
|
|
// uint8_t loosening_knife_signal = 1;
|
|
|
|
|
|
// uint8_t clamping_knife_signal = 1;
|
|
|
|
|
|
|
|
|
|
|
|
// 夹刀信号检测
|
|
|
|
|
|
clamping_knife_signal = GF_BSP_GPIO_ReadIO(0); |
|
|
|
|
|
// 松刀信号检测
|
|
|
|
|
|
loosening_knife_signal = GF_BSP_GPIO_ReadIO(1); |
|
|
|
|
|
|
|
|
|
|
|
if(loosening_knife_signal == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
else if(clamping_knife_signal == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
else{ |
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Frontend_Control() |
|
|
void Frontend_Control() |
|
|
|