#include "global.h" #if JU_XING_MACHINE ==1 void KK_QueDuan_AlarmProtect(void); void KK_QueDuan_ManualAction(void); void KK_QueDuan_AutoAction(void); void KK_QueDuan_StepCheckStart(void); void KK_QueDuan_XiaQue(void); void KK_QueDuan_Motor(void); void KK_QueDuan_YuanDianAction(void); void KK_QueDuan_TuiLianAction(void); void KK_QueDuan_ExtiActionX31(void); void KK_QueDuan_BingLian(void); void KK_StopCode(void); void KKQD_TuiDaiAction(void); short *KK_length_buffer; void KKQD_SetAlarmCode(unsigned alarm_code) { SetAlarmCode(KKQD_ALARM_ADDR,alarm_code); bAlarmStop = 1; } void KK_QueDuan_ExtiActionX31(void) { KK_cCheckLianFlg = 1; } void KK_StopCode(void) { switch(KKQD_StopStep) { case 1: KKQD_StopStep=2; if(X_DRV) { AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS) * 2/3); AxisDecStop(X_AXIS); } break; case 2: if(!X_DRV || (KK_cRealPos < 10)) { KKQD_StopCodeDelay=dwTickCount+350; KKQD_StopStep = 3; } break; case 3: if(dwTickCount >= KKQD_StopCodeDelay) { if(!cSTOPONE) { KKQD_StopStep=0; } else { KKQD_SetAlarmCode(KKQD_PARAM_ANQUANMEN_ALARM); KKQD_StopStep=0; cSTOPONE=0; } KKQD_SZ_OUT = 1; //电机松轴 } break; } } void KK_QueDuan_InitAction(void) { float length_buff,pulse_buff; length_buff = KKQD_PARAM_CYCLE_LENGTH; pulse_buff = KKQD_PARAM_CYCLE_PULSE; XGearRatio = pulse_buff/length_buff; // KKQD_SZ_OUT = 1; KKQD_SetAlarmCode(0); SetDirReverse(X_AXIS, 1); } void KK_QueDuan_Action(void) { KK_QueDuan_AlarmProtect(); KK_QueDuan_Motor(); KK_QueDuan_XiaQue(); KK_QueDuan_ManualAction(); KK_QueDuan_TuiLianAction(); KK_QueDuan_BingLian(); KK_StopCode(); KK_QueDuan_AutoAction(); KK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序 } //手动动作 void KK_QueDuan_ManualAction(void) { //条数或扎数达到后,台面电机转两秒之后再停机 if(KK_cTABLETIME) { if(KK_cTABLETOTAL) { KK_cTABLETOTAL=0; KKQD_TABLE_VAVLE = 1; KKQD_TableDelay=dwTickCount + 2000; } if(dwTickCount >= KKQD_TableDelay) { KKQD_TABLE_VAVLE = 0; KK_cTABLETIME=0; } } if(bRunning == 0) { KK_cGoLimitEn = 0; if(KKQD_bClearTotal) //切断计数清零 { KKQD_bClearTotal = 0; ClrcToTal(KKQD_TOTAL_ADDR); } if(KKQD_bClearNowTotal) { KKQD_bClearNowTotal = 0; KKQD_PARAM_NOW_CNT = 0; } if(KKQD_bXiaQie) { KKQD_bXiaQie = 0; if((KKQD_XiaQieStep == 0) && !KKQD_TL_VAVLE) { KKQD_XiaQieStep = 1; } } if(KKQD_bQianDianDW) { KKQD_bQianDianDW = 0; if(KKQD_MotorStep == 0) { KKQD_MotorStep = 61; cZipCnt = 0; } } if(KKQD_bTL) { KKQD_bTL = 0; if(KKQD_TL_VAVLE) { KKQD_TL_VAVLE = 0; } else if(!KKQD_GZ_VAVLE && !KKQD_SM_VAVLE) { KKQD_TL_VAVLE = ~KKQD_TL_VAVLE; } } if(KKQD_bECQ) { KKQD_bECQ=0; KK_cShuangDao=1; KK_cDiErLaChu=1; KK_cECQ_STOP=1; bRunning = 1; KKQD_AutoStep = 1; } // if(!Y_DRV)KKQD_bTL = 0; if(KKQD_bYD) { KKQD_bYD = 0; KKQD_YD_VAVLE = ~KKQD_YD_VAVLE; } if(KKQD_bGZ) { KKQD_bGZ = 0; KKQD_GZ_VAVLE = ~KKQD_GZ_VAVLE; } if(KKQD_bJD) { KKQD_bJD = 0; KKQD_JD_VAVLE = ~KKQD_JD_VAVLE; } if(KKQD_bXM) { KKQD_bXM = 0; KKQD_XM_VAVLE = ~KKQD_XM_VAVLE; if(!KKQD_XM_VAVLE)KKQD_GZ_VAVLE = 0; } if(KKQD_GOUZHEN_IN_UP) { KKQD_YD_VAVLE=1; } if(KKQD_bSM) { KKQD_bSM = 0; if(KKQD_SM_VAVLE) KKQD_SM_VAVLE = 0; else if(!KKQD_TL_VAVLE || !KKQD_PARAM_XM_ENABLE) KKQD_SM_VAVLE = 1; } //推方块 if(KKQD_bTFK) { KKQD_bTFK = 0; KKQD_TFK_VAVLE = ~KKQD_TFK_VAVLE; } //台面电机 if(KKQD_bTB) { KKQD_bTB = 0; KKQD_TABLE_VAVLE = ~KKQD_TABLE_VAVLE; } // if(KKQD_bYBD) // / { // KKQD_bYBD = 0; // KKQD_YBD_VAVLE = ~KKQD_YBD_VAVLE; // } if(KKQD_bTestCS) { KKQD_bTestCS = 0; KKQD_CS_OUT = 1; KKQD_CSDelay = dwTickCount + KKQD_PARAM_CS_TIME; } if(KKQD_bBL)//吹气 { KKQD_bBL = 0; KKQD_CQ_VAVLE = ~KKQD_CQ_VAVLE; } if(KKQD_bHL) //护链,双开用 { KKQD_bHL = 0; KKQD_HL_VAVLE = ~KKQD_HL_VAVLE; } if(KKQD_bYX) { KKQD_bYX = 0; KKQD_YX_VAVLE = ~KKQD_YX_VAVLE; } if(KKQD_XiaQieStep == 0) { if(dwTickCount >= KKQD_CSDelay)KKQD_CS_OUT = 0; } //电机控制 if(KKQD_bGoMotor && !KKQD_QIAN_LIMIT_IN) { KKQD_SZ_OUT = 0; // KKQD_JZ_DIR = KKQD_YDIR_N; if(!X_DRV) // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED,KKQD_PARAM_GO_LOW_SPEED,10,12); } if(KKQD_bBackMotor) //后退限位已经取消 { KKQD_SZ_OUT = 0; // KKQD_JZ_DIR = KKQD_YDIR_P; if(!X_DRV) // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_P,KKQD_PARAM_GO_LOW_SPEED,KKQD_PARAM_GO_LOW_SPEED,10,12); } if(!KKQD_bGoMotor && !KKQD_bBackMotor && (KKQD_MotorStep == 0)) { if(X_DRV)AxisDecStop(X_AXIS); } if(KKQD_QIAN_LIMIT_IN && (KKQD_MotorStep == 0) && !KKQD_bBackMotor &&(KKQD_AutoStep == 0)) { if(X_DRV)AxisEgmStop(X_AXIS); } } } void KK_QueDuan_AlarmProtect(void) { KK_cRealPos = GetPos(X_AXIS); if(!bRunning) { ; } else { if((KK_cRealPos > KKQD_PARAM_RUN_LENGTH) && (KKQD_PARAM_RUN_LENGTH > 3000) && (KK_cGoLimitEn != 0)) { AxisEgmStop(X_AXIS); KKQD_JD_VAVLE = 0; KKQD_SetAlarmCode(KKQD_BACK_ALARM); } } } void KK_QueDuan_AutoAction(void) { //台面电机定时关掉 if(KKQD_QIAN_STOP_Auto) { KK_cDLJ_ATUO=1; AxisEgmStop(X_AXIS); } if(KKQD_QIAN_START_Auto) { if(KK_cDLJ_ATUO) { KK_cDLJ_ATUO=0; KKQD_AutoDelay = dwTickCount + 1000; KKQD_MotorDelay = dwTickCount + 2000; if((KKQD_MotorStep==63 || KKQD_MotorStep==64 || KKQD_MotorStep==65) && !KKQD_QIAN_LIMIT_IN) AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED/3,KKQD_PARAM_GO_LOW_SPEED/3,15,15); else if((KK_cRealPos < KKQD_PARAM_ZIPPER_LENGTH) && (KKQD_MotorStep > 311)) AxisMoveTwoPos(X_AXIS,1000,(KKQD_PARAM_ZIPPER_LENGTH - KK_cRealPos) + (*KK_length_buffer), KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED_LENGTH,KKQD_DIR_P,5000,3000,20,30); } } if(!KK_cDLJ_ATUO) { if(bRunning) { if(!KK_cTABLETIME) { if(dwTickCount >= KKQD_TBDelay) KKQD_TABLE_VAVLE = 0; } switch(KKQD_AutoStep) { case 1: if(dwTickCount >= KKQD_AutoDelay) { KKQD_AutoStep = 2; if(KKQD_MotorStep == 0) { KKQD_MotorStep = 61; //前点定位 } KK_cGoLimitEn = 0; } break; case 2: if(KKQD_MotorStep == 0) { if(!KK_cShuangDao) KKQD_MotorStep = 30; else KKQD_MotorStep = 801; KKQD_AutoStep = 3; KK_cGoLimitEn = 1; } break; case 3: if(KKQD_MotorStep == 0) { if(KKQD_SAFE_IN) { bStop = 1; } else { if(!KK_cShuangDao) { if(KKQD_XiaQieStep == 0) KKQD_XiaQieStep = 1; } else { if(KKQD_XiaQieStep == 0) KKQD_XiaQieStep = 201; } KKQD_AutoStep = 4; } } break; case 4: // 闭口 if((KKQD_XiaQieStep == 0) || ((KKQD_XiaQieStep == 6) && KKQD_KB_MODE)|| ((KKQD_XiaQieStep == 14) && (KKQD_KB_MODE == 0)))// && !KKQD_SHANG_MU_LIMIT_IN) { if(KKQD_MotorStep == 0) { KK_cGoLimitEn=0; KKQD_MotorStep = 40; //切完后退 } KKQD_AutoStep = 5; } break; case 5: if(KKQD_MotorStep == 0) { if(!KK_cDiErLaChu) cZipCnt++; KKQD_PARAM_NOW_CNT++; cTableCnt++; AddToTal(KKQD_TOTAL_ADDR); AddToTal(CT_WORKTOTAL_ADDR); CalProSP(KKQD_PROSPEED_ADDR); if(cTableCnt >= KKQD_PARAM_TABLE_NUM) { cTableCnt = 0; KKQD_TABLE_VAVLE = 1; KKQD_TBDelay = dwTickCount + KKQD_PARAM_TB_TIME; } if( SingOneFlg || cZhouWanone) { { cZhouWanone=0; cStopMode=0; bRunning = 0; KKQD_AutoStep = 0; SingOneFlg = 0; KKQD_TABLE_VAVLE = 0; } // if(GetTotal(KKQD_TOTAL_ADDR) >= KKQD_PARAM_SET_TOTAL) KKQD_SetAlarmCode(KKQD_TOTAL_ALARM); } else { KKQD_AutoStep = 1; if((KKQD_PARAM_NOW_CNT >= KKQD_PARAM_ZHA_SHU) && (KKQD_PARAM_ZHA_SHU > 0)) { KKQD_AutoDelay = dwTickCount + KKQD_PARAM_ZS_STOP_TIME; KKQD_PARAM_NOW_CNT = 0; KK_cTABLETIME = 1; KK_cTABLETOTAL= 1; if(KKQD_PARAM_ZS_STOP_TIME == 0) { bRunning = 0; KKQD_AutoStep = 0; SingOneFlg = 0; KK_cTABLETIME = 1; KK_cTABLETOTAL= 1; KKQD_SetAlarmCode(KKQD_TOTAL_ALARM); } } else KKQD_AutoDelay = dwTickCount + KKQD_PARAM_CYCLE_DELAY; } } break; } } } } void KK_QueDuan_StepCheckStart(void) { // 启动 if((START_IN_UP) || bStart || KKQD_bSingle) { bStart = 0; if(!bRunning && (KKQD_AutoStep == 0)) { if(KKQD_XIA_MU_LIMIT_IN && !KKQD_PARAM_XM_ENABLE)KKQD_SetAlarmCode(KKQD_XM_DAOWEI); // else if(GetAlarmCode(KKQD_ALARM_ADDR) != 0); //else if(GetTotal(KKQD_TOTAL_ADDR) >= KKQD_PARAM_SET_TOTAL) KKQD_SetAlarmCode(KKQD_TOTAL_ALARM); // else if(KKQD_BL_VAVLE)KKQD_SetAlarmCode(KKQD_BL_ALARM); else if(KKQD_SM_VAVLE)KKQD_SetAlarmCode(KKQD_SM_ALARM); else { bRunning = 1; KKQD_AutoStep = 1; if(KKQD_PARAM_BL_ENABLE) KKQD_PARAM_BL_ENABLE=1 ; //并链起动 if(KKQD_bSingle) { SingOneFlg= 1; KKQD_bSingle=0; } else { SingOneFlg=0; } cZipCnt = 0; KK_cTABLETIME = 0; KK_cTABLETOTAL= 0; cSTOPONE=0; cTuiFangKuaiCnt = 0; KKQD_BL_VAVLE = 0; //并链关 KK_cDLJ_ATUO=0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 SetAlarmCode(KKQD_ALARM_ADDR,0); } } KKQD_bSingle = 0; } if(KKQD_STOP_ANNIU_IN_UP) { bRunning = 0; KKQD_XiaQieStep = 0; KKQD_AutoStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_AutoDelay = dwTickCount; KKQD_MotorDelay = dwTickCount; KKQD_XiaQieDelay = dwTickCount; KKQD_KaDaiDelay = dwTickCount; KKQD_CSDelay = dwTickCount; KKQD_TBDelay = dwTickCount; KKQD_TFKDelay = dwTickCount; KKQD_TLDelay = dwTickCount; dwTickCount = KKQD_TBDelay; KKQD_CHUIQIStep=0; SingOneFlg = 0; KKQD_JD_VAVLE = 0; KKQD_SM_VAVLE = 0; KKQD_XM_VAVLE = 0; KKQD_YD_VAVLE = 0; KKQD_TFK_VAVLE= 0; KKQD_YX_VAVLE = 0; KKQD_HL_VAVLE = 0; KKQD_TL_VAVLE = 0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 KKQD_CS_OUT = 0; KKQD_XiaQieStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_SZ_OUT = 1; KKQD_GZ_VAVLE = 0; KKQD_TABLE_VAVLE = 0; KKQD_StopStep=1; KK_cTABLETIME = 0; KK_cTABLETOTAL= 0; KKQD_BinLianStep = 0; KKQD_BL_VAVLE = 0; SetAlarmCode(KKQD_ALARM_ADDR,0); } if((KKQD_ANQUANMEN_LIMIT_IN_UP || KKQD_ANQUANMEN_LIMIT_IN) && bRunning) { KKQD_StopStep=1; cSTOPONE=1; } if(STOP_IN_UP) { if(bRunning) { KK_cShuangDao=0; KK_cDiErLaChu=0; KKQD_AutoDelay = dwTickCount; KKQD_MotorDelay = dwTickCount; KKQD_XiaQieDelay = dwTickCount; KKQD_KaDaiDelay = dwTickCount; KKQD_CSDelay = dwTickCount; KKQD_TBDelay = dwTickCount; KKQD_TFKDelay = dwTickCount; KKQD_TLDelay = dwTickCount; dwTickCount = KKQD_TBDelay; KKQD_CHUIQIStep=0; SingOneFlg = 0; KKQD_JD_VAVLE = 0; KKQD_SM_VAVLE = 0; KKQD_XM_VAVLE = 0; KKQD_YD_VAVLE = 0; KKQD_TFK_VAVLE= 0; KKQD_YX_VAVLE = 0; KKQD_HL_VAVLE = 0; cStopMode=0; cZhouWanone=0; KKQD_TL_VAVLE = 0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 KKQD_CS_OUT = 0; KKQD_XiaQieStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; // KKQD_SZ_OUT = 1; KKQD_GZ_VAVLE = 0; KKQD_TABLE_VAVLE = 0; if((KKQD_StopStep == 0) && X_DRV) KKQD_StopStep = 1; KK_cTABLETIME = 0; KK_cTABLETOTAL= 0; KKQD_BinLianStep = 0; KKQD_BL_VAVLE = 0; SetAlarmCode(KKQD_ALARM_ADDR,0); bRunning = 0; KKQD_XiaQieStep = 0; KKQD_AutoStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; } else { KK_cShuangDao=0; KK_cDiErLaChu=0; KKQD_AutoDelay = dwTickCount; KKQD_MotorDelay = dwTickCount; KKQD_XiaQieDelay = dwTickCount; KKQD_KaDaiDelay = dwTickCount; KKQD_CSDelay = dwTickCount; KKQD_TBDelay = dwTickCount; KKQD_TFKDelay = dwTickCount; KKQD_TLDelay = dwTickCount; dwTickCount = KKQD_TBDelay; KKQD_CHUIQIStep=0; SingOneFlg = 0; KKQD_JD_VAVLE = 0; KKQD_SM_VAVLE = 0; KKQD_XM_VAVLE = 0; KKQD_YD_VAVLE = 0; KKQD_TFK_VAVLE= 0; KKQD_YX_VAVLE = 0; KKQD_HL_VAVLE = 0; cStopMode=0; cZhouWanone=0; KKQD_TL_VAVLE = 0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 KKQD_CS_OUT = 0; KKQD_XiaQieStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_SZ_OUT = 1; KKQD_GZ_VAVLE = 0; KKQD_TABLE_VAVLE = 0; if((KKQD_StopStep == 0)) { KK_cSTOPONE = 0; AxisEgmStop(X_AXIS); KKQD_SZ_OUT = 1; } KK_cTABLETIME = 0; KK_cTABLETOTAL= 0; KKQD_BinLianStep = 0; KKQD_BL_VAVLE = 0; SetAlarmCode(KKQD_ALARM_ADDR,0); bRunning = 0; KKQD_XiaQieStep = 0; KKQD_AutoStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; } } //停止 if( bStop) { bStop = 0; if(cStopMode < 2) cStopMode++; if(cStopMode==1 && bRunning) cZhouWanone=1; if(bRunning && cStopMode==2) { KK_cShuangDao=0; KK_cDiErLaChu=0; KKQD_AutoDelay = dwTickCount; KKQD_MotorDelay = dwTickCount; KKQD_XiaQieDelay = dwTickCount; KKQD_KaDaiDelay = dwTickCount; KKQD_CSDelay = dwTickCount; KKQD_TBDelay = dwTickCount; KKQD_TFKDelay = dwTickCount; KKQD_TLDelay = dwTickCount; dwTickCount = KKQD_TBDelay; SingOneFlg = 0; bRunning = 0; KKQD_XiaQieStep = 0; KKQD_AutoStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_JD_VAVLE = 0; KKQD_SM_VAVLE = 0; KKQD_XM_VAVLE = 0; KKQD_YD_VAVLE = 0; KKQD_TFK_VAVLE= 0; KKQD_TL_VAVLE = 0; KKQD_HL_VAVLE = 0; KKQD_CS_OUT = 0; KKQD_XiaQieStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; //KKQD_SZ_OUT = 1; KKQD_GZ_VAVLE = 0; KKQD_TABLE_VAVLE = 0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 if((KKQD_StopStep == 0) && X_DRV) KKQD_StopStep = 1; KKQD_BinLianStep = 0; KKQD_BL_VAVLE = 0; KK_cTABLETIME = 0; KK_cTABLETOTAL= 0; user_datas[121] = 0; user_datas[122] = 0; SetAlarmCode(KKQD_ALARM_ADDR,0); } else if(!bRunning) { KK_cShuangDao=0; KK_cDiErLaChu=0; KKQD_AutoDelay = dwTickCount; KKQD_MotorDelay = dwTickCount; KKQD_XiaQieDelay = dwTickCount; KKQD_KaDaiDelay = dwTickCount; KKQD_CSDelay = dwTickCount; KKQD_TBDelay = dwTickCount; KKQD_TFKDelay = dwTickCount; KKQD_TLDelay = dwTickCount; dwTickCount = KKQD_TBDelay; KKQD_CHUIQIStep=0; SingOneFlg = 0; KKQD_JD_VAVLE = 0; KKQD_SM_VAVLE = 0; KKQD_XM_VAVLE = 0; KKQD_YD_VAVLE = 0; KKQD_TFK_VAVLE= 0; KKQD_YX_VAVLE = 0; KKQD_HL_VAVLE = 0; cStopMode=0; cZhouWanone=0; KKQD_TL_VAVLE = 0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 KKQD_CS_OUT = 0; KKQD_XiaQieStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_SZ_OUT = 1; KKQD_GZ_VAVLE = 0; KKQD_TABLE_VAVLE = 0; if((KKQD_StopStep == 0)) { KK_cSTOPONE = 0; AxisEgmStop(X_AXIS); KKQD_SZ_OUT = 1; } KK_cTABLETIME = 0; KK_cTABLETOTAL= 0; KKQD_BinLianStep = 0; KKQD_BL_VAVLE = 0; SetAlarmCode(KKQD_ALARM_ADDR,0); bRunning = 0; KKQD_XiaQieStep = 0; KKQD_AutoStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; } } if(bAlarmStop) { bAlarmStop = 0; KKQD_XiaQieStep = 0; KKQD_AutoStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_XiaQieStep = 0; KKQD_MotorStep = 0; KKQD_TuiLianStep = 0; KKQD_AutoDelay = dwTickCount; KKQD_MotorDelay = dwTickCount; KKQD_XiaQieDelay = dwTickCount; KKQD_KaDaiDelay = dwTickCount; KKQD_CSDelay = dwTickCount; KKQD_TBDelay = dwTickCount; KKQD_TFKDelay = dwTickCount; KKQD_TLDelay = dwTickCount; SingOneFlg = 0; bRunning = 0; // KKQD_StopStep=1; cStopMode=0; cZhouWanone=0; dwTickCount = KKQD_TBDelay; KKQD_TABLE_VAVLE = 0; KKQD_TFK_VAVLE =0; KKQD_JD_VAVLE=0; KKQD_GZ_VAVLE=0; } } //记忆长度模式误差检测 void KK_QueDuan_CheckLength(long zip_length) { static long start_dist; switch(KKQD_CheckLengthStep) { case 0:break; case 1: start_dist = KK_cRealPos; dwSaveLength = 0; KKQD_CheckLengthStep = 2; break; case 2: if(KKQD_GUO_LIAN_IN_DW) { dwSaveLength = KK_cRealPos - start_dist; // user_datas[127] = KK_cRealPos; } break; } } void KK_QueDuan_Motor(void) { static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff; unsigned short ch; user_datas[121]= KKQD_MotorStep; user_datas[122]= length_buff; user_datas[123] = KK_cRealPos; user_datas[124] = dwSaveLength;//QD_BinLianStep; user_datas[125] = KKQD_CheckLengthStep;//QD_AutoStep; user_datas[126] = KKQD_XiaQieStep; // user_datas[127] = KKQD_XiaQieStep; KK_QueDuan_CheckLength(length_buff); if(!KK_cDLJ_ATUO) { switch(KKQD_MotorStep) { case 30: switch(KKQD_PARAM_BACK_MODE) //开口分四种模式 { case 0: //单数控模式 KKQD_MotorStep = 310; //每种模式留20步 break; case 1://单感应模式 KKQD_MotorStep = 330; //每种模式留20步 break; case 2: //先感应后数控模式+检测 KKQD_MotorStep = 350; //每种模式留20步 break; default: //数控模式+过链检测长度 KKQD_MotorStep = 370; //每种模式留20步 break; } KKQD_MotorDelay = dwTickCount + KKQD_PARAM_DELAY_BACK; break; //310步到315步为数控模式 case 310: SetDir(X_AXIS, KKQD_DIR_P); if(KKQD_PARAM_BL_ENABLE) KKQD_BinLianStep = 1; //并链起动 KKQD_MotorStep = 311; break; case 311: if(dwTickCount >= KKQD_MotorDelay) { KK_length_buffer = &KKQD_PARAM_OFFSET_LENGTH; SetPos(X_AXIS, 0); //李永庆代码 //两段速度移动距离 拉链长度+慢速长度停止 // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向 KK_DCC_TIME_BL=KKQD_PARAM_BACK_SPEED/400; AxisMovePosAccDecNotStop(X_AXIS,KKQD_PARAM_BACK_SPEED,KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer), KKQD_PARAM_START_SPEED,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_ACC,KK_DCC_TIME_BL,KKQD_PARAM_BACK_LOW_SPEED_LENGTH); gou_zhen_buff = KK_cRealPos; save_buff = KK_cRealPos; KKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; KKQD_MotorStep = 312; } break; case 312: //勾针提前输出 ,争取时间推方块 if(KK_cRealPos>300) KKQD_DGLG_VAVLE = 1; //顶过链杆关 if (!KKQD_GZ_VAVLE && (KK_cRealPos >= (KKQD_PARAM_ZIPPER_LENGTH- 230))) KKQD_GZ_VAVLE = 1; if((KK_cRealPos) > (KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer)-KKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*KK_length_buffer) - (KKQD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(KKQD_PARAM_BACK_SPEED,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_DCC))))) { KKQD_MotorStep = 313; } else if(KK_cRealPos >= (KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer) + KKQD_PARAM_ERROR_LENGTH)) { KKQD_SetAlarmCode(KKQD_GZ_ALARM); } break; case 313: if (!KKQD_GZ_VAVLE && (KK_cRealPos >= (KKQD_PARAM_ZIPPER_LENGTH- 230))) KKQD_GZ_VAVLE = 1; if(!X_DRV || KK_cRealPos>=(KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer))) { AxisEgmStop(X_AXIS); KKQD_MotorDelay = dwTickCount + KKQD_PARAM_TFK_DELAY; KKQD_MotorStep = 314; KKQD_BL_VAVLE = 0; //停止时并链一定要打开 if(KKQD_PARAM_BACK_MODE == 2) //模式2,先检测长度后数控 {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经 if(cZipCnt > 1) //长度检测 { if(KKQD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0 { if(((dwSaveLength + KKQD_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + KKQD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0)) { KKQD_SetAlarmCode(KKQD_LENGTH_LONG_ALARM);//拉链变长,对比警告 } else if((dwSaveLength + KKQD_PARAM_MOTOR_DELAY_LENGTH+ KKQD_PARAM_ERROR_LENGTH) < length_buff) { KKQD_SetAlarmCode(KKQD_LENGTH_SHORT_ALARM); ////拉链变短 } KKQD_CheckLengthStep = 0; } } } } break; case 314: if(!X_DRV && (dwTickCount >= KKQD_MotorDelay)) //数控到停止 { KKQD_MotorStep = 0; KKQD_TFK_VAVLE = 1; //推方块输出 } break; //330步到349步单感应模式 case 330: back_buff = KK_cRealPos; gou_zhen_buff = KK_cRealPos; SetDir(X_AXIS, KKQD_DIR_P); KKQD_MotorStep = 331; user_datas[127] = 0; break; case 331: if(dwTickCount >= KKQD_MotorDelay) { if(cZipCnt < 2) { if(KKQD_PARAM_BL_ENABLE) KKQD_BinLianStep = 10; //并链起动 //第一条都是过链感应,后拉速度减半//原来KKQD_PARAM_CHECK_BACK_HSPEED/2 // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,9000,KKQD_DIR_P,KKQD_PARAM_START_SPEED,2000,8,13); // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向 // AxisMoveTwoPos(X_AXIS,KKQD_PARAM_BACK_SPEED,KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer)-KKQD_PARAM_BACK_LOW_SPEED_LENGTH,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED_LENGTH,KKQD_DIR_P); } else { if(KKQD_PARAM_BL_ENABLE) KKQD_BinLianStep = 1; //并链起动 //因为每条都是过链感应,所以直接运行检测模式后拉速度 // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_CHECK_BACK_HSPEED,KKQD_DIR_P,KKQD_PARAM_START_SPEED,2000,KKQD_PARAM_ACC,KKQD_PARAM_DCC); } KKQD_MotorStep = 332; } break; case 332: if(KK_cRealPos>300) { if(cZipCnt > 1) //第二条开始数控降速 { if((KK_cRealPos + KKQD_PARAM_BACK_LOW_SPEED_LENGTH + 600)>= length_buff) { AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15); user_datas[127] = KK_cRealPos; KKQD_MotorStep = 334; //到检测定位 } if(KKQD_GUO_LIAN_IN_DW) //重新到链上 { AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15); gou_zhen_buff = KK_cRealPos; KKQD_MotorStep = 335; //到检测定位 } // // if((KK_cRealPos >= (KKQD_PARAM_BACK_LOW_SPEED_LENGTH + 60)) && KKQD_GUO_LIAN_IN) // { // } } else //第一条工作 { if(KKQD_GUO_LIAN_IN_UP) { checkdelay_buff = KK_cRealPos; AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15); KKQD_MotorDelay = dwTickCount + 0;//KKQD_PARAM_DELAY_XM; KKQD_MotorStep = 333; } else if((KK_cRealPos >= KKQD_PARAM_RUN_LENGTH) && (KKQD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制 { // KKQD_SetAlarmCode(KKQD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度 } } } break; case 333: if(dwTickCount >= KKQD_MotorDelay) { KKQD_MotorStep = 334; } break; case 334: if(KKQD_GUO_LIAN_IN_DW) //下降沿,定位长度 { //滤波有待调试 // if((((KK_cRealPos - checkdelay_buff) >= KKQD_PARAM_DELAY_CHECK) && (KKQD_PARAM_LT_ENABLE)) || (((KK_cRealPos - checkdelay_buff) >= KKQD_PARAM_NO_LT_DELAY_CHECK) && (KKQD_PARAM_LT_ENABLE == 0))) // { if(KKQD_GUO_LIAN_IN_DW) { gou_zhen_buff = KK_cRealPos; KKQD_MotorStep = 335; } // } } break; case 335: if(KKQD_GUO_LIAN_IN_DW) { gou_zhen_buff = KK_cRealPos; } //在空们都把延时清零 if(KKQD_GUO_LIAN_IN) { gou_zhen_buff = KK_cRealPos; } //定位停止 if(((KK_cRealPos - gou_zhen_buff) >= KKQD_PARAM_MOTOR_DELAY_LENGTH) && !KKQD_GUO_LIAN_IN) { AxisEgmStop(X_AXIS); KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; KKQD_MotorStep = 336; KKQD_GZ_VAVLE = 1; } break; case 336: if(!X_DRV) { KKQD_GZ_VAVLE = 1; KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; // KKQD_XM_VAVLE = 1; KKQD_MotorStep = 337; } break; case 337: if(1) { KKQD_MotorStep = 338; KKQD_MotorDelay = dwTickCount + KKQD_PARAM_TFK_DELAY; } // else if(dwTickCount >= KKQD_MotorDelay) KKQD_SetAlarmCode(KKQD_XM_DAOWEI); break; case 338: if((dwTickCount >= KKQD_MotorDelay)) { KKQD_TFK_VAVLE = 1; //推方块输出 KKQD_MotorStep = 339; KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; } break; case 339: if(cZipCnt == 1) { length_buff = KK_cRealPos - save_buff; SetData32bits(KKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); } else if(cZipCnt > 1) //长度检测 { if(KKQD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0 { if(KK_cRealPos >= length_buff) //拉链变长,对比警告 { if((KK_cRealPos - save_buff) > (length_buff+KKQD_PARAM_ERROR_LENGTH)) KKQD_SetAlarmCode(KKQD_LENGTH_LONG_ALARM); } else //拉链变短 { if((KK_cRealPos - save_buff + KKQD_PARAM_ERROR_LENGTH) < (length_buff)) KKQD_SetAlarmCode(KKQD_LENGTH_SHORT_ALARM); } } } KKQD_MotorStep = 0; break; //350步到369步单感应模式 case 350: back_buff = KK_cRealPos; gou_zhen_buff = KK_cRealPos; SetDir(X_AXIS, KKQD_DIR_P); KKQD_MotorStep = 351; break; case 351: if(dwTickCount >= KKQD_MotorDelay) { //第一,二条都是过链感应,测量长度 if(cZipCnt < 2) { if(KKQD_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链 KKQD_BinLianStep = 10; //并链起动 KKQD_DGLG_VAVLE = 0; //顶过链杆关 // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,9000,KKQD_DIR_P,KKQD_PARAM_START_SPEED,2000,8,12); KKQD_MotorStep = 352; } else { if(KKQD_PARAM_BL_ENABLE) KKQD_BinLianStep = 1; //并链起动 KKQD_DGLG_VAVLE = 1; //顶过链杆关 KKQD_CheckLengthStep = 1; //长度检测,第3条才有对比 //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走 KKQD_MotorStep = 311; } } break; case 352: if(KK_cRealPos>300) { //前两条都按最低速度工作 if(KKQD_GUO_LIAN_IN_UP) { checkdelay_buff = KK_cRealPos; AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15); KKQD_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波 KKQD_MotorStep = 353; } else if((KK_cRealPos >= KKQD_PARAM_RUN_LENGTH) && (KKQD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制 { // KKQD_SetAlarmCode(KKQD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度 } } break; case 353: if(dwTickCount >= KKQD_MotorDelay) { KKQD_MotorStep = 354; } break; case 354: if(KKQD_GUO_LIAN_IN_DW) //下降沿,定位长度 { if(KKQD_GUO_LIAN_IN_DW) { gou_zhen_buff = KK_cRealPos; KKQD_MotorStep = 355; } } break; case 355: if(KKQD_GUO_LIAN_IN_DW) { gou_zhen_buff = KK_cRealPos; } //在空们都把延时清零 if(KKQD_GUO_LIAN_IN) { gou_zhen_buff = KK_cRealPos; } //定位停止 if(((KK_cRealPos - gou_zhen_buff) >= KKQD_PARAM_MOTOR_DELAY_LENGTH) && !KKQD_GUO_LIAN_IN) { AxisEgmStop(X_AXIS); KKQD_MotorStep = 356; KKQD_GZ_VAVLE = 1; } break; case 356: if(!X_DRV) { KKQD_GZ_VAVLE = 1; KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; // KKQD_XM_VAVLE = 1; KKQD_MotorStep = 357; } break; case 357: if(1) { KKQD_MotorStep = 358; KKQD_MotorDelay = dwTickCount + KKQD_PARAM_TFK_DELAY; } break; case 358: if((dwTickCount >= KKQD_MotorDelay)) { KKQD_TFK_VAVLE = 1; //推方块输出 KKQD_MotorStep = 359; KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; } break; case 359: if(cZipCnt == 1) { length_buff = KK_cRealPos - save_buff; //测量出来长度 SetData32bits(KKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); } KKQD_MotorStep = 0; break; case 40: //切完延时后拉带松夹子 if(KKQD_PARAM_SJZ_LENGTH == 0 ) { KKQD_JD_VAVLE = 0; SetDir(X_AXIS, KKQD_DIR_P); jz_buff = KK_cRealPos; AxisMovePosAccDec(X_AXIS,KKQD_PARAM_CUT_BACK_SPEED,KKQD_PARAM_BACK_LENGTH,1000,1000,100,50,0); // AxisMovePosAccDec(X_AXIS,KKQD_PARAM_CUT_BACK_SPEED,KKQD_PARAM_SJZ_LENGTH + KKQD_PARAM_BACK_LENGTH,2000,2000,25,25,40); KKQD_MotorStep = 44; } else { jz_buff = KK_cRealPos; SetDir(X_AXIS, KKQD_DIR_P); KKQD_MotorStep = 41; } break; case 41: AxisMovePosAccDec(X_AXIS,KKQD_PARAM_CUT_BACK_SPEED,(KKQD_PARAM_SJZ_LENGTH+KKQD_PARAM_BACK_LENGTH),1000,1000,100,50,0); KKQD_MotorStep = 42; break; case 42: if((KKQD_PARAM_SJZ_LENGTH <= (KK_cRealPos - jz_buff))) { KKQD_JD_VAVLE = 0; KKQD_GZ_VAVLE=0; KKQD_MotorStep = 44; } break; case 44: // 切断完成后拉电机动作 if((KKQD_PARAM_SJZ_LENGTH+KKQD_PARAM_BACK_LENGTH) <= (KK_cRealPos - jz_buff) || !X_DRV) { AxisEgmStop(X_AXIS); KKQD_MotorStep = 0; KKQD_GZ_VAVLE=0; KKQD_MotorDelay = dwTickCount; } break; case 61: // 前点定位数控模式 if(KKQD_SZ_OUT) { KKQD_SZ_OUT = 0; KKQD_MotorDelay = dwTickCount + 150; SetDir(X_AXIS, KKQD_DIR_N); SetPos(X_AXIS, 0); } else KKQD_MotorDelay = dwTickCount; KKQD_BL_VAVLE = 0;//并链也要打开 // KKQD_JZ_DIR = KKQD_YDIR_N; if(KKQD_TuiLianStep==0) { if(!KKQD_TL_VAVLE && cZipCnt) //没送链情况下主动送链 { if(!KKQD_SHANG_MU_LIMIT_IN && (KKQD_TuiLianStep == 0)) { KKQD_TuiLianStep = 1; KKQD_MotorStep = 62; } } else KKQD_MotorStep = 62; } else KKQD_MotorStep = 62; break; case 62: if(dwTickCount >= KKQD_MotorDelay) { if(KKQD_QIAN_LIMIT_IN) { SetPos(X_AXIS, 0);//在前点,直接置零点 // KKQD_JZ_DIR = KKQD_YDIR_P; //前点亮的情况下先退出 AxisMovePos(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,1000); KKQD_MotorDelay = dwTickCount + 300; } KKQD_MotorStep = 63; KKQD_JD_VAVLE = 0; } break; case 63: if(!X_DRV && !KKQD_QIAN_LIMIT_IN && (dwTickCount >= KKQD_MotorDelay))// && !KKQD_SHANG_MU_LIMIT_IN) { // KKQD_JZ_DIR = KKQD_YDIR_N; SetDir(X_AXIS, KKQD_DIR_N); go_buff = KK_cRealPos; KKQD_YD_VAVLE = 1; KKQD_HL_VAVLE = 1; KKQD_YX_VAVLE = 1; //李永庆代码,当位置在慢速之外,走数控到慢速点 if(cZipCnt > 0) { if(KK_cRealPos>(KKQD_PARAM_GO_LOW_SPEED_LENGTH)) { KK_DCC_TIME_BL=KKQD_PARAM_GO_HIGH_SPEED/400; AxisMovePosAccDecNotStop(X_AXIS,KKQD_PARAM_GO_HIGH_SPEED,-KK_cRealPos, KKQD_PARAM_START_SPEED,KKQD_PARAM_GO_LOW_SPEED,KKQD_PARAM_ACC,KK_DCC_TIME_BL, KKQD_PARAM_GO_LOW_SPEED_LENGTH); } else { // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED/3,1000,15,15); } } else { // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED/3,1000,15,15); } KKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; KKQD_MotorStep =64; } break; case 64: if(cZipCnt > 1) { //李永庆代码 if(((KK_cRealPos) < (KKQD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (KKQD_QIAN_DEC_IN)) { user_datas[126]= GetCurSpeed(X_AXIS); // MoveChangSpeedDec(X_AXIS,KKQD_PARAM_GO_HIGH_SPEED*2/3,6,8); // AxisChangeSpeed(X_AXIS,40); KKQD_MotorStep =65; } if(KKQD_QIAN_LIMIT_IN) //前点限位 { AxisEgmStop(X_AXIS); KKQD_MotorStep = 66; } } else { if(KKQD_QIAN_LIMIT_IN) //前点限位 { AxisEgmStop(X_AXIS); KKQD_MotorStep = 66; } } break; case 65: if(KKQD_QIAN_LIMIT_IN) { KKQD_TFK_VAVLE = 0; AxisEgmStop(X_AXIS); KKQD_MotorStep = 66; } else if(dwTickCount >= KKQD_MotorDelay) KKQD_SetAlarmCode(KKQD_NO_ZIPPER_ALARM); break; case 66: if(!X_DRV) { KKQD_TFK_VAVLE=0; SetPos(X_AXIS, 0); KKQD_MotorDelay = dwTickCount; KKQD_MotorStep = 67; } break; case 67: //等推链完成后, if((dwTickCount >= KKQD_MotorDelay) && (KKQD_TuiLianStep == 0) && ((KKQD_PARAM_TIAOSHI_MODE && KKQD_bTS) || (KKQD_PARAM_TIAOSHI_MODE == 0)) ) { if(bRunning) { KKQD_JD_VAVLE = 1; KKQD_MotorDelay = dwTickCount + KKQD_PARAM_DELAY_BACK; } KKQD_MotorStep = 68; } break; case 68: if(dwTickCount >= KKQD_MotorDelay) { KKQD_YD_VAVLE = 0; KKQD_HL_VAVLE = 0; KKQD_YX_VAVLE = 0; KKQD_TL_VAVLE = 0; KKQD_MotorStep = 0; KKQD_MotorDelay = dwTickCount; } break; } } } void KK_QueDuan_BingLian(void) { static long bl_pos_buff,HL_delay; switch(KKQD_BinLianStep) { case 1: bl_pos_buff = KK_cRealPos; KKQD_BinLianStep = 2; break; case 2: if((KK_cRealPos - bl_pos_buff) >= KKQD_PARAM_DELAY_HL_LENGTH) { KKQD_BL_VAVLE = 1; KKQD_BinLianStep = 3; } break; case 3://有过链检测 if((KK_cRealPos - bl_pos_buff) >= (KKQD_PARAM_ZIPPER_LENGTH - KKQD_PARAM_HL_DELAY_BACK)) { KKQD_BL_VAVLE = 0; KKQD_BinLianStep = 0; } if(KKQD_GUO_LIAN_IN_DW && KKQD_PARAM_BACK_MODE ==1) //|| (KKQD_PARAM_BACK_MODE==2 && cZipCnt < 2))) { KKQD_BL_VAVLE = 0; KKQD_BinLianStep = 0; } break; case 10: bl_pos_buff = KK_cRealPos; KKQD_BinLianStep = 11; break; case 11: if((KK_cRealPos - bl_pos_buff) >= KKQD_PARAM_DELAY_HL_LENGTH) { KKQD_BL_VAVLE = 1; KKQD_BinLianStep = 12; } break; case 12://有过链检测 if(KKQD_GUO_LIAN_IN_DW) { KKQD_BL_VAVLE = 0; KKQD_BinLianStep = 0; } break; default:; } } //超声方式下切,开口专用 void KK_QueDuan_XiaQue_KK(void) { switch(KKQD_XiaQieStep) { case 0: break; case 1: KKQD_XiaQieStep = 2; break; case 2: KKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; KKQD_XiaQieStep = 3; break; case 3: if(1) { KKQD_XiaQieDelay = dwTickCount + 0;//KKQD_PARAM_GZ_DELAY; KKQD_XiaQieStep = 4; } else if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_SetAlarmCode(KKQD_XM_DAOWEI); } break; case 4: if(KKQD_GZ_VAVLE) //勾针已经有输出就不需要延时 { KKQD_XiaQieDelay = dwTickCount + 0; } else KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_TFK_DELAY; KKQD_GZ_VAVLE = 1; cTuiFangKuaiCnt=0; KKQD_XiaQieStep = 5; break; case 5: if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_TFK_VAVLE = 1; KKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; KKQD_XiaQieStep = 6; } break; case 6: if(1) { KKQD_XiaQieStep = 7; KKQD_XiaQieDelay = dwTickCount + 1000; } else if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_SetAlarmCode(KKQD_XM_DAOWEI); } break; case 7: if(KKQD_GOUZHEN_IN) { cTuiFangKuaiCnt = 0; KKQD_YD_VAVLE = 1; if(!bRunning) KKQD_XiaQieDelay = dwTickCount + 200; else KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_CUT_DELAY; if(!KKQD_QIAN_LIMIT_IN) KKQD_XiaQieStep = 8; else KKQD_SetAlarmCode(KKQD_QIAN_LIMIT_ALARM); } else if((dwTickCount >= KKQD_XiaQieDelay)) { if(cTuiFangKuaiCnt < KKQD_PARAM_TFK_NUMBER) { KKQD_TFK_VAVLE = 0; cTuiFangKuaiCnt++; KKQD_XiaQieDelay = dwTickCount + 500; KKQD_XiaQieStep = 100; } else KKQD_SetAlarmCode(KKQD_GZ_ALARM); } break; case 100: if((dwTickCount >= KKQD_XiaQieDelay)) { KKQD_XiaQieStep = 5; } break; case 8://上下模同时输出 if(KKQD_GOUZHEN_IN) { if(KKQD_SHANG_MU_ORIGIN_IN) { if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_SM_VAVLE = 1; if(KKQD_PARAM_XM_ENABLE == 0) //配置下模动 KKQD_XM_VAVLE = 1; KKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; KKQD_XiaQieStep = 9; } } else if(dwTickCount >= (KKQD_XiaQieDelay+3000)) { KKQD_SetAlarmCode(KKQD_SM_YUANWEI); } } else { KKQD_SetAlarmCode(KKQD_GZ_ALARM); } break; case 9://上下模到位,调试模下的话,等按下一步按键 下模不动 if(KKQD_SHANG_MU_LIMIT_IN && (KKQD_XIA_MU_LIMIT_IN || KKQD_PARAM_XM_ENABLE) && ((KKQD_PARAM_TIAOSHI_MODE && KKQD_bTS) || (KKQD_PARAM_TIAOSHI_MODE == 0)) ) { if(!KKQD_PARAM_CS_MODE) //无超声配置 { KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_DELAYBACK_SM; // KKQD_XiaQieStep = 12; } else { KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_DELAY_CS; // KKQD_XiaQieStep = 10; } } else if(dwTickCount >= KKQD_XiaQieDelay) { if(!KKQD_SHANG_MU_LIMIT_IN)KKQD_SetAlarmCode(KKQD_SM_DAOWEI); else KKQD_SetAlarmCode(KKQD_XM_DAOWEI); } break; case 10: if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_CS_OUT = 1; KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_CS_TIME; // KKQD_XiaQieStep = 11; } break; case 11: if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_CS_OUT = 0; KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_CS_COLD_TIME; // KKQD_XiaQieStep = 12; } break; case 12: if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_SM_VAVLE = 0; if(KKQD_PARAM_XM_ENABLE == 0) //配置下模动 KKQD_XM_VAVLE = 0; KKQD_DGLG_VAVLE = 0; //顶过链杆关 KKQD_TFK_VAVLE = 0; // KKQD_GZ_VAVLE = 0 KKQD_XiaQieStep = 13; }// break; case 13: KKQD_GZ_VAVLE = 0; KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_TTFK_TIME; KKQD_XiaQieStep = 14; break; case 14: if(dwTickCount >= KKQD_XiaQieDelay) { KKQD_TFK_VAVLE = 1; } if(!KKQD_SHANG_MU_LIMIT_IN) { //启动推链(送链) if((KKQD_TuiLianStep == 0) && !KKQD_TL_VAVLE) KKQD_TuiLianStep = 1; } if(!KKQD_SHANG_MU_LIMIT_IN && (!KKQD_XIA_MU_LIMIT_IN || KKQD_PARAM_XM_ENABLE) && KKQD_TFK_VAVLE) { KKQD_XiaQieStep = 0; } else if(dwTickCount >= (KKQD_XiaQieDelay+3000)) { KKQD_SetAlarmCode(KKQD_SM_YUANWEI); } break; } } void KK_QueDuan_TuiLianAction(void) { if(KKQD_PARAM_XM_ENABLE == 0) { KKQD_TuiLianStep = 0; } else { switch(KKQD_TuiLianStep) { case 1: KKQD_TuiLianStep = 2; break; case 2: KKQD_TLDelay = dwTickCount + KKQD_PARAM_YD_DELAY; KKQD_TuiLianStep = 3; break; case 3: if(!KKQD_SM_VAVLE && !KKQD_SHANG_MU_LIMIT_IN)//dwTickCount >= KKQD_TLDelay) { KKQD_TL_VAVLE = 1; // KKQD_TFK_VAVLE = 0; // if(!bRunning)KKQD_TFK_VAVLE = 1; KKQD_TLDelay = dwTickCount + KKQD_PARAM_TL_DELAY; KKQD_TuiLianStep = 4; } break; case 4: if(dwTickCount >= KKQD_TLDelay) { KKQD_TuiLianStep = 0; } break; case 10: KKQD_TuiLianStep = 11; break; case 11: if(!Y_DRV) { { KKQD_TuiLianStep = 0; } } break; } } } //切断动作 void KK_QueDuan_XiaQue(void) { KK_QueDuan_XiaQue_KK(); } #endif