#include "global.h" #if FU_JIAN_MACHINE void QueDuan_AlarmProtect(void); void QueDuan_ManualAction(void); void QueDuan_AutoAction(void); void QueDuan_StepCheckStart(void); void QueDuan_XiaQue(void); void QueDuan_Motor(void); void QueDuan_YuanDianAction(void); void QueDuan_TuiLianAction(void); void QueDuan_TuiFangKuai(void); void QueDuan_ExtiActionX31(void); void QueDuan_BingLian(void); static unsigned long cZipCnt = 0,cTableCnt = 0; static long save_limit_pos,cRealPos; unsigned char cCheckLianFlg = 0; unsigned char cCheckLianFlgEN = 0; unsigned char cGoLimitEn = 0; void QueDuan_ExtiActionX31(void) { cCheckLianFlg = 1; // user_datas[123]++; } void QD_SetAlarmCode(unsigned alarm_code) { SetAlarmCode(QD_ALARM_ADDR,alarm_code); bAlarmStop = 1; } void QueDuan_InitAction(void) { float length_buff,pulse_buff; save_limit_pos = QD_SAVE_POS; axis_x->speed_unit = 500; SetAccTime(X_AXIS,10); SetDecTime(X_AXIS,10); length_buff = QD_PARAM_CYCLE_LENGTH; pulse_buff = QD_PARAM_CYCLE_PULSE; XGearRatio = pulse_buff/length_buff; axis_y->speed_unit = 300; SetAccTime(Y_AXIS,3); SetDecTime(Y_AXIS,3); length_buff = QD_PARAM_TL_CYCLE_LENGTH; pulse_buff = QD_PARAM_TL_CYCLE_PULSE; YGearRatio = pulse_buff/length_buff; QD_SZ_OUT = 1; } void QueDuan_Action(void) { QueDuan_AlarmProtect(); QueDuan_TuiFangKuai(); QueDuan_Motor(); QueDuan_XiaQue(); QueDuan_ManualAction(); QueDuan_YuanDianAction(); QueDuan_TuiLianAction(); QueDuan_BingLian(); QueDuan_AutoAction(); QueDuan_StepCheckStart(); // 调用脚踏开关检测程序 } //手动动作 void QueDuan_ManualAction(void) { if(bRunning == 0) { if(QD_bClearTotal) //切断计数清零 { QD_bClearTotal = 0; ClrcToTal(QD_TOTAL_ADDR); } if(QD_bClearNowTotal) { QD_bClearNowTotal = 0; QD_PARAM_NOW_CNT = 0; } if(QD_bXiaQie) { QD_bXiaQie = 0; if(QD_XiaQieStep == 0)QD_XiaQieStep = 1; } if(QD_bQianDianDW) { QD_bQianDianDW = 0; if(QD_MotorStep == 0) { QD_MotorStep = 61; cZipCnt = 0; } } if(QD_bTL) { if(QD_PARAM_TL_MODE) { if(!Y_DRV)AxisMovePos(Y_AXIS,QD_PARAM_TL_SPEED,QD_PARAM_TL_LENGTH); } else { QD_bTL = 0; QD_TL_VAVLE = ~QD_TL_VAVLE; } } if(!Y_DRV)QD_bTL = 0; if(QD_bYD) { QD_bYD = 0; QD_YD_VAVLE = ~QD_YD_VAVLE; } if(QD_bGZ) { QD_bGZ = 0; QD_GZ_VAVLE = ~QD_GZ_VAVLE; } if(QD_bJD) { QD_bJD = 0; QD_JD_VAVEL = ~QD_JD_VAVEL; } if(QD_bXM) { QD_bXM = 0; QD_XM_VAVLE = ~QD_XM_VAVLE; } if(QD_bSM) { QD_bSM = 0; QD_SM_VAVLE = ~QD_SM_VAVLE; } if(QD_bTFK) { QD_bTFK = 0; QD_TFK_VAVEL = ~QD_TFK_VAVEL; } if(QD_bTB) { QD_bTB = 0; QD_TABLE_VAVLE = ~QD_TABLE_VAVLE; } if(QD_bYBD) { QD_bYBD = 0; QD_YBD_VAVLE = ~QD_YBD_VAVLE; } if(QD_bTestCS) { QD_bTestCS = 0; QD_CS_OUT = 1; QD_CSDelay = dwTickCount + QD_PARAM_CS_TIME; } if(QD_bBL) { QD_bBL = 0; QD_BL_VAVLE = ~QD_BL_VAVLE; } if(QD_XiaQieStep == 0) { if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0; } if(QD_bYuanDianDW) { QD_bYuanDianDW = 0; if(QD_YuanDianStep == 0)QD_YuanDianStep = 1; } //电机控制 if(QD_bGoMotor && !QD_QIAN_LIMIT_IN) { QD_SZ_OUT = 0; if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_N; if(!X_DRV)AxisContinueMove(X_AXIS,20,QD_DIR_N); } if(QD_bBackMotor && !QD_BACK_LIMIT_IN) { QD_SZ_OUT = 0; if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P; if(!X_DRV)AxisContinueMove(X_AXIS,20,QD_DIR_P); } if(!QD_bGoMotor && !QD_bBackMotor && (QD_MotorStep == 0)) { if(X_DRV)AxisDecStop(X_AXIS); } if(QD_QIAN_LIMIT_IN && (QD_MotorStep == 0) && !QD_bBackMotor &&(QD_AutoStep == 0)) { if(X_DRV)AxisEgmStop(X_AXIS); } } } void QueDuan_YuanDianAction(void) { switch(QD_YuanDianStep) { case 0:break; case 1: if(QD_MotorStep == 0)QD_MotorStep = 1; QD_YuanDianStep = 2; break; case 2: if(QD_MotorStep == 0) { QD_MotorStep = 30; QD_YuanDianStep = 3; QD_JD_VAVEL = 1; } break; case 3: if(QD_MotorStep == 0) { QD_MotorStep = 0; QD_YuanDianStep = 0; } break; } } void QueDuan_AlarmProtect(void) { cRealPos = GetPos(X_AXIS); if(QD_PARAM_BACK_ALARM_MODE) { //感应后限模式 if(!bRunning) { if(QD_BACK_LIMIT_IN_UP) { if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进 { QD_bBackMotor = 0; AxisDecStop(X_AXIS); QD_JD_VAVEL = 0; QD_SetAlarmCode(QD_BACK_ALARM); } } } else { if(QD_BACK_LIMIT_IN_UP) { AxisDecStop(X_AXIS); QD_JD_VAVEL = 0; QD_SetAlarmCode(QD_BACK_ALARM); } } } else { if(QD_QIAN_LIMIT_IN_UP) //数控后限模式 { save_limit_pos = cRealPos; SetData32bits(200,save_limit_pos); } if(QD_PARAM_MAX_BACK_LENGTH < (cRealPos - save_limit_pos)) { if(!bRunning) { if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进 { QD_bBackMotor = 0; AxisDecStop(X_AXIS); QD_JD_VAVEL = 0; QD_SetAlarmCode(QD_BACK_ALARM); } } else { AxisDecStop(X_AXIS); QD_JD_VAVEL = 0; QD_SetAlarmCode(QD_BACK_ALARM); } } } // if(!QD_KADAI_IN)QD_KaDaiDelay = dwTickCount + 3000; /* if(bRunning) { if(dwTickCount >= QD_KaDaiDelay)QD_SetAlarmCode(QD_KA_DAI_ALARM); }*/ } void QueDuan_AutoAction(void) { if(bRunning) { if(dwTickCount >= QD_TBDelay)QD_TABLE_VAVLE = 0; switch(QD_AutoStep) { case 1: if(dwTickCount >= QD_AutoDelay) { QD_AutoStep = 2; if(QD_MotorStep == 0) { QD_MotorStep = 61; //前点定位 // else QD_MotorStep = 1; } } break; case 2: if(QD_MotorStep == 0) { if(QD_PARAM_DC_MODE == 0) QD_MotorStep = 20; //后退到位 else QD_MotorStep = 30; QD_AutoStep = 3; } break; case 3: if(QD_MotorStep == 0) { if(QD_XiaQieStep == 0)QD_XiaQieStep = 1; QD_AutoStep = 4; } break; case 4: if(QD_MACHINE_TYPE == QD_QQ_TUIFANGKUAI) { if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 4)) && !QD_SHANG_MU_LIMIT_IN) { if(QD_MotorStep == 0) { QD_MotorStep = 40; //切完后退 QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY; } QD_AutoStep = 5; } } else { if((QD_XiaQieStep == 0) && !QD_SHANG_MU_LIMIT_IN) { if(QD_MotorStep == 0) { QD_MotorStep = 40; //切完后退 QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY; } QD_AutoStep = 5; } } break; case 5: if(QD_MotorStep == 0) { cZipCnt++; QD_PARAM_NOW_CNT++; cTableCnt++; AddToTal(QD_TOTAL_ADDR); CalProSP(QD_PROSPEED_ADDR); if(cTableCnt >= QD_PARAM_TABLE_NUM) { cTableCnt = 0; QD_TABLE_VAVLE = 1; QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME; } if((GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) || SingOneFlg) { bRunning = 0; QD_AutoStep = 0; SingOneFlg = 0; if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM); } else { QD_AutoStep = 1; if(QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU) { QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME + 50; QD_PARAM_NOW_CNT = 0; } else QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY; } } break; } } } void QueDuan_StepCheckStart(void) { // 启动 if((START_IN_UP) || bStart || QD_bSingle) { bStart = 0; if(!bRunning && (QD_AutoStep == 0)) { if(!QD_SHANG_MU_ORIGIN_IN)QD_SetAlarmCode(QD_SM_YUANWEI); else if(GetAlarmCode(QD_ALARM_ADDR) != 0); else if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM); else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM); else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM); else { bRunning = 1; QD_AutoStep = 1; if(QD_bSingle) SingOneFlg= 1; cZipCnt = 0; if(QD_PARAM_TL_MODE) { if(QD_TuiLianStep == 0)QD_TuiLianStep = 1; } } } QD_bSingle = 0; } //停止 if(STOP_IN_UP || bStop) { bStop = 0; /* if(bRunning) { if(SingOneFlg) { bRunning = 0; QD_XiaQieStep = 0; QD_AutoStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_YuanDianStep = 0; QD_BinLianStep = 0; SingOneFlg = 0; QD_JD_VAVEL = 0; QD_SM_VAVLE = 0; QD_XM_VAVLE = 0; QD_YD_VAVLE = 0; QD_XHG_VAVLE = 0; // QD_CS_OUT = 0; QD_TL_VAVLE = 0; QD_SZ_OUT = 1; QD_GZ_VAVLE = 0; QD_YBD_VAVLE = 0; QD_TFK_VAVEL = 0; QD_TABLE_VAVLE = 0; QD_BL_VAVLE = 0; QD_AutoDelay = dwTickCount; QD_MotorDelay = dwTickCount; QD_XiaQieDelay = dwTickCount; QD_KaDaiDelay = dwTickCount; QD_CSDelay = dwTickCount; QD_TBDelay = dwTickCount; QD_TFKDelay = dwTickCount; QD_TLDelay = dwTickCount; QD_CheckDelay = dwTickCount; AxisDecStop(X_AXIS); if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0); } else { SingOneFlg = 1; } } else { bRunning = 0; QD_XiaQieStep = 0; QD_AutoStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_YuanDianStep = 0; QD_AutoDelay = dwTickCount; QD_MotorDelay = dwTickCount; QD_XiaQieDelay = dwTickCount; QD_KaDaiDelay = dwTickCount; QD_CSDelay = dwTickCount; QD_TBDelay = dwTickCount; QD_TFKDelay = dwTickCount; QD_TLDelay = dwTickCount; QD_CheckDelay = dwTickCount; SingOneFlg = 0; QD_JD_VAVEL = 0; QD_SM_VAVLE = 0; QD_XM_VAVLE = 0; QD_YD_VAVLE = 0; QD_TFK_VAVEL= 0; QD_TL_VAVLE = 0; QD_YBD_VAVLE = 0; //QD_CS_OUT = 0; QD_XiaQieStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_SZ_OUT = 1; QD_GZ_VAVLE = 0; QD_TABLE_VAVLE = 0; QD_XHG_VAVLE = 0; AxisDecStop(X_AXIS); QD_YuanDianStep = 0; QD_BinLianStep = 0; QD_BL_VAVLE = 0; if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0); }*/ if(bRunning) { bRunning = 0; QD_XiaQieStep = 0; QD_AutoStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_YuanDianStep = 0; QD_AutoDelay = dwTickCount; QD_MotorDelay = dwTickCount; QD_XiaQieDelay = dwTickCount; QD_KaDaiDelay = dwTickCount; QD_CSDelay = dwTickCount; QD_TBDelay = dwTickCount; QD_TFKDelay = dwTickCount; QD_TLDelay = dwTickCount; QD_CheckDelay = dwTickCount; dwTickCount = QD_TBDelay; SingOneFlg = 0; QD_JD_VAVEL = 0; QD_SM_VAVLE = 0; QD_XM_VAVLE = 0; QD_YD_VAVLE = 0; QD_TFK_VAVEL= 0; QD_TL_VAVLE = 0; QD_YBD_VAVLE = 0; QD_CS_OUT = 0; QD_XiaQieStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; //QD_SZ_OUT = 1; QD_GZ_VAVLE = 0; QD_TABLE_VAVLE = 0; QD_XHG_VAVLE = 0; AxisDecStop(X_AXIS); QD_YuanDianStep = 0; QD_BinLianStep = 0; QD_BL_VAVLE = 0; if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0); } else { bRunning = 0; QD_XiaQieStep = 0; QD_AutoStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_YuanDianStep = 0; QD_AutoDelay = dwTickCount; QD_MotorDelay = dwTickCount; QD_XiaQieDelay = dwTickCount; QD_KaDaiDelay = dwTickCount; QD_CSDelay = dwTickCount; QD_TBDelay = dwTickCount; QD_TFKDelay = dwTickCount; QD_TLDelay = dwTickCount; QD_CheckDelay = dwTickCount; dwTickCount = QD_TBDelay; SingOneFlg = 0; QD_JD_VAVEL = 0; QD_SM_VAVLE = 0; QD_XM_VAVLE = 0; QD_YD_VAVLE = 0; QD_TFK_VAVEL= 0; QD_TL_VAVLE = 0; QD_YBD_VAVLE = 0; QD_CS_OUT = 0; QD_XiaQieStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_SZ_OUT = 1; QD_GZ_VAVLE = 0; QD_TABLE_VAVLE = 0; QD_XHG_VAVLE = 0; AxisDecStop(X_AXIS); QD_YuanDianStep = 0; QD_BinLianStep = 0; QD_BL_VAVLE = 0; if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0); } } if(bAlarmStop) { bAlarmStop = 0; QD_XiaQieStep = 0; QD_AutoStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_YuanDianStep = 0; QD_XiaQieStep = 0; QD_MotorStep = 0; QD_TuiLianStep = 0; QD_TuiFangKuaiStep = 0; QD_AutoDelay = dwTickCount; QD_MotorDelay = dwTickCount; QD_XiaQieDelay = dwTickCount; QD_KaDaiDelay = dwTickCount; QD_CSDelay = dwTickCount; QD_TBDelay = dwTickCount; QD_TFKDelay = dwTickCount; QD_TLDelay = dwTickCount; QD_CheckDelay = dwTickCount; SingOneFlg = 0; bRunning = 0; AxisDecStop(X_AXIS); dwTickCount = QD_TBDelay; QD_TABLE_VAVLE = 0; } } void QueDuan_Motor_CS(void) { static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff; user_datas[124]= QD_MotorStep; user_datas[125]= go_length_buff; user_datas[123] = length_buff; user_datas[127] = cRealPos; user_datas[126] = go_buff - cRealPos; user_datas[121] = QD_BinLianStep; switch(QD_MotorStep) { case 0: break; case 1: // 前点定位数控模式 if(QD_SZ_OUT) { QD_SZ_OUT = 0; QD_MotorDelay = dwTickCount + 50; } if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; if((QD_TuiLianStep == 0) && !QD_TL_VAVLE && !QD_PARAM_TL_MODE)QD_TuiLianStep = 1; QD_MotorStep = 2; break; case 2: if(dwTickCount >= QD_MotorDelay) { if(QD_QIAN_LIMIT_IN) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P; AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_ON_BACK_LENGTH); QD_MotorDelay = dwTickCount + 1000; } QD_MotorStep = 3; QD_JD_VAVEL = 0; } break; case 3: if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay)) { if(cZipCnt == 0) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); //第一条走低速 } else { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,(length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH +QD_PARAM_SJZ_LENGTH),QD_PARAM_GO_LOW_SPEED,0xFFFFFF,QD_DIR_P);//第二条开始走两段速 } QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 4; } break; case 4: if(QD_QIAN_LIMIT_IN_UP) { AxisEgmStop(X_AXIS); QD_MotorStep = 5; } else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM); break; case 5: if(!X_DRV) { QD_MotorDelay = dwTickCount; QD_MotorStep = 6; } break; case 6: if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0)) { if(bRunning) { QD_JD_VAVEL = 1; } QD_MotorStep = 7; QD_MotorDelay = dwTickCount + 100; } break; case 7: if(dwTickCount >= QD_MotorDelay) { QD_YBD_VAVLE = 0; QD_TL_VAVLE = 0; QD_MotorStep = 0; } break; case 20:// 后退使用电机定长 QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK; QD_MotorStep = 21; break; case 21: if(dwTickCount >= QD_MotorDelay) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-QD_PARAM_ZIPPER_LENGTH); QD_MotorStep = 22; } break; case 22: if(!X_DRV) { QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_FZ; QD_MotorStep = 23; } break; case 23: if(dwTickCount >= QD_MotorDelay) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P; AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH); QD_MotorStep = 24; } break; case 24: if(!X_DRV) { QD_MotorStep = 0; QD_MotorDelay = dwTickCount; } break; case 30: QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK; QD_MotorStep = 31; if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1; break; case 31: // 后退使用钩针定长 if(dwTickCount >= QD_MotorDelay) { save_buff = cRealPos; back_buff = cRealPos; if(QD_PARAM_DEC_MODE == 0) { AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P); QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 32; } else { if(cZipCnt < 2) { AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 32; } else { gouzhen_buff = cRealPos; AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff); MoveChangSpeedPos(X_AXIS, QD_PARAM_GO_LOW_SPEED,PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH)); QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 33; } } } break; case 32: if(QD_PARAM_BACK_MODE) { if(cZipCnt < 2) { if(QD_GUO_LIAN_IN_UP) { cCheckLianFlg = 0; checkdelay_buff = cRealPos; if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep = 33; dwTickCount = QD_MotorDelay; } else if(dwTickCount >= QD_MotorDelay) { QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); } } else { QD_MotorStep = 36; } } else { if(QD_GUO_LIAN_IN_UP) { cCheckLianFlg = 0; checkdelay_buff = cRealPos; if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep = 33; } else if(dwTickCount >= QD_MotorDelay) { QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); } } break; case 33: if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0)) { if(dwTickCount >= QD_MotorDelay) { QD_MotorStep = 34; } } else { if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH)) { if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep = 34; } } break; case 34: if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0)) { if((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) { cCheckLianFlgEN = 1; if(cCheckLianFlg) { cCheckLianFlg = 0; gou_zhen_buff = cRealPos; QD_MotorStep = 35; } } } else { if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH)) { QD_MotorStep = 36; } } break; case 35: if(cCheckLianFlg) { cCheckLianFlg = 0; gou_zhen_buff = cRealPos; } if(QD_GUO_LIAN_IN_DW) { gou_zhen_buff = cRealPos; } if(QD_GUO_LIAN_IN_UP) { gou_zhen_buff = cRealPos; } if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) { AxisEgmStop(X_AXIS); QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; QD_MotorStep = 36; } break; case 36: if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))) { cCheckLianFlgEN = 0; if(QD_PARAM_DEC_MODE == 0)QD_GZ_VAVLE = 1; QD_YD_VAVLE = 1; QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY; QD_MotorStep = 37; } break; case 37: if(dwTickCount >= QD_MotorDelay) { QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; QD_MotorStep = 38; } break; case 38: if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))) { if(cZipCnt == 1) { length_buff = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH; } if(cZipCnt == 0) { go_length_buff = cRealPos - save_buff; } QD_MotorStep = 0; } else if(dwTickCount >= QD_MotorDelay) { QD_SetAlarmCode(QD_GZ_ALARM); } break; case 40: if(dwTickCount >= QD_MotorDelay) { // 切断完成后拉电机动作 if(QD_PARAM_SJZ_LENGTH == 0) { QD_MotorDelay = dwTickCount + 50; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 100) { QD_MotorDelay = dwTickCount + 40; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 200) { QD_MotorDelay = dwTickCount + 30; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 300) { QD_MotorDelay = dwTickCount + 20; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 400) { QD_MotorDelay = dwTickCount + 10; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 500) { QD_MotorDelay = dwTickCount + 5; QD_JD_VAVEL = 0; } else { QD_MotorDelay = dwTickCount; } QD_MotorStep = 41; } break; case 41: if(dwTickCount >= QD_MotorDelay) { save_buff = cRealPos; if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P; AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)); QD_MotorStep = 42; } break; case 42: // 切断完成后拉电机动作 if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - save_buff))) { QD_JD_VAVEL = 0; QD_MotorStep = 43; } else if(!X_DRV) { QD_JD_VAVEL = 0; QD_MotorStep = 43; } break; case 43: // 切断完成后拉电机动作 if(!X_DRV) { QD_MotorStep = 0; QD_MotorDelay = dwTickCount; } break; case 61: // 前点定位数控模式 if(QD_SZ_OUT) { QD_SZ_OUT = 0; QD_MotorDelay = dwTickCount + 50; } if(QD_PARAM_TL_MODE) { } else { if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1; } QD_MotorStep = 62; break; case 62: if(dwTickCount >= QD_MotorDelay) { if(QD_QIAN_LIMIT_IN) { AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH); QD_MotorDelay = dwTickCount + 1000; } QD_MotorStep = 63; QD_JD_VAVEL = 0; } break; case 63: if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay)) { go_buff = cRealPos; if(cZipCnt > 0) { MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);// } else { MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED); } QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 64; } break; case 64: if(QD_PARAM_GO_MODE) { if(cZipCnt > 0) { if((go_buff - cRealPos) > (go_length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) { MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep =65; } } else { QD_MotorStep =65; } } else { QD_MotorStep =65; } break; case 65: if(QD_QIAN_LIMIT_IN_UP) { if(QD_PARAM_DAO_MODE) { dandao_buff = cRealPos; QD_MotorStep = 70; } else { AxisEgmStop(X_AXIS); QD_MotorStep = 66; } } else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM); break; case 70: if((dandao_buff - cRealPos) >= QD_PARAM_DANDAO_MODE_LENGTH) { AxisEgmStop(X_AXIS); QD_MotorStep = 66; } break; case 66: if(!X_DRV) { QD_MotorDelay = dwTickCount; QD_MotorStep = 67; } break; case 67: if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) ) { if(bRunning) { QD_JD_VAVEL = 1; } QD_MotorStep = 68; QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK; } break; case 68: if(dwTickCount >= QD_MotorDelay) { QD_YD_VAVLE = 0; QD_MotorStep = 0; } break; } } //推方块动作 void QueDuan_TuiFangKuai(void) { } void QueDuan_BingLian(void) { static long bl_pos_buff; switch(QD_BinLianStep) { case 0:break; case 1: bl_pos_buff = cRealPos; QD_BinLianStep = 2; break; case 2: if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH) { QD_BL_VAVLE = 1; QD_BinLianStep = 3; } break; case 3: if(QD_SM_VAVLE)QD_BL_VAVLE = 0; break; default:; } } void QueDuan_Motor_QD(void) { static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff; user_datas[124]= QD_MotorStep; user_datas[125]= go_length_buff; user_datas[123] = length_buff; user_datas[127] = cRealPos; user_datas[126] = go_buff - cRealPos; user_datas[121] = QD_BinLianStep; switch(QD_MotorStep) { case 0: break; case 1: // 前点定位数控模式 if(QD_SZ_OUT) { QD_SZ_OUT = 0; QD_MotorDelay = dwTickCount + 50; } if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; if((QD_TuiLianStep == 0) && !QD_TL_VAVLE && !QD_PARAM_TL_MODE)QD_TuiLianStep = 1; QD_MotorStep = 2; break; case 2: if(dwTickCount >= QD_MotorDelay) { if(QD_QIAN_LIMIT_IN) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P; AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_ON_BACK_LENGTH); QD_MotorDelay = dwTickCount + 1000; } QD_MotorStep = 3; QD_JD_VAVEL = 0; } break; case 3: if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay)) { if(cZipCnt == 0) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); //第一条走低速 } else { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,(length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH +QD_PARAM_SJZ_LENGTH),QD_PARAM_GO_LOW_SPEED,0xFFFFFF,QD_DIR_P);//第二条开始走两段速 } QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 4; } break; case 4: if(QD_QIAN_LIMIT_IN_UP) { AxisEgmStop(X_AXIS); QD_MotorStep = 5; } else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM); break; case 5: if(!X_DRV) { QD_MotorDelay = dwTickCount; QD_MotorStep = 6; } break; case 6: if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0)) { if(bRunning) { QD_JD_VAVEL = 1; } QD_MotorStep = 7; QD_MotorDelay = dwTickCount + 100; } break; case 7: if(dwTickCount >= QD_MotorDelay) { QD_YBD_VAVLE = 0; QD_TL_VAVLE = 0; QD_MotorStep = 0; } break; case 20:// 后退使用电机定长 QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK; QD_MotorStep = 21; break; case 21: if(dwTickCount >= QD_MotorDelay) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N; AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-QD_PARAM_ZIPPER_LENGTH); QD_MotorStep = 22; } break; case 22: if(!X_DRV) { QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_FZ; QD_MotorStep = 23; } break; case 23: if(dwTickCount >= QD_MotorDelay) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P; AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH); QD_MotorStep = 24; } break; case 24: if(!X_DRV) { QD_MotorStep = 0; QD_MotorDelay = dwTickCount; } break; case 30: QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK; QD_MotorStep = 31; if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1; break; case 31: // 后退使用钩针定长 if(dwTickCount >= QD_MotorDelay) { save_buff = cRealPos; back_buff = cRealPos; SetAccTime(X_AXIS,5); SetDecTime(X_AXIS,5); if(QD_PARAM_DEC_MODE == 0) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P; AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P); QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 32; } else { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P; if(cZipCnt < 2) { QD_XHG_VAVLE = 0; AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 32; } else { gouzhen_buff = cRealPos; QD_XHG_VAVLE = 1; //AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,(length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH),QD_PARAM_GO_LOW_SPEED,QD_PARAM_Back_LOW_SPEED_LENGTH,QD_DIR_N); AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff); MoveChangSpeedPos(X_AXIS, QD_PARAM_GO_LOW_SPEED,PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH)); QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep = 33; } // AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_N); } } break; case 32: if(QD_PARAM_BACK_MODE) { if(cZipCnt < 2) { if(QD_GUO_LIAN_IN_UP) { cCheckLianFlg = 0; checkdelay_buff = cRealPos; if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY; // QD_CheckDelay = dwTickCount + QD_PARAM_DELAY_CHECK; QD_MotorStep = 33; } else if(dwTickCount >= QD_MotorDelay) { QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); } } else { /* if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH)) { // if(X_DRV)MoveChangSpeedPos(X_AXIS, QD_PARAM_GO_LOW_SPEED,PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH)); }*/ QD_MotorStep = 36; } } else { if(QD_GUO_LIAN_IN_UP) { cCheckLianFlg = 0; checkdelay_buff = cRealPos; if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY; // QD_CheckDelay = dwTickCount + QD_PARAM_DELAY_CHECK; QD_MotorStep = 33; } else if(dwTickCount >= QD_MotorDelay) { QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); } } break; case 33: if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0)) { if(dwTickCount >= QD_MotorDelay) { QD_GZ_VAVLE = 1; QD_MotorStep = 34; } } else { if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH)) { if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep = 34; } } break; case 34: if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0)) { if((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) { //user_datas[125]= cRealPos - checkdelay_buff; cCheckLianFlgEN = 1; if(cCheckLianFlg)//(!QD_GUO_LIAN_IN) { // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); cCheckLianFlg = 0; gou_zhen_buff = cRealPos; QD_MotorStep = 35; } } } else { if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH)) { QD_GZ_VAVLE = 1; QD_MotorStep = 36; } } break; case 35: if(cCheckLianFlg) { cCheckLianFlg = 0; gou_zhen_buff = cRealPos; } if(QD_GUO_LIAN_IN_DW) { gou_zhen_buff = cRealPos; } if(QD_GUO_LIAN_IN_UP) { gou_zhen_buff = cRealPos; } if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) { AxisEgmStop(X_AXIS); QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; QD_MotorStep = 36; } break; case 36: if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))) { cCheckLianFlgEN = 0; if(QD_PARAM_DEC_MODE == 0)QD_GZ_VAVLE = 1; if(!QD_PARAM_TL_MODE)QD_YBD_VAVLE = 1; QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY; QD_MotorStep = 37; } break; case 37: if(dwTickCount >= QD_MotorDelay) { QD_TFK_VAVEL = 1; QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; QD_MotorStep = 38; } break; case 38: if(QD_GOUZHEN_IN && !X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))) { if(QD_PARAM_TL_MODE)QD_YBD_VAVLE = 1; if(cZipCnt == 1) { length_buff = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH; } if(cZipCnt == 0) { go_length_buff = cRealPos - save_buff; } QD_MotorStep = 0; } else if(dwTickCount >= QD_MotorDelay) { QD_SetAlarmCode(QD_GZ_ALARM); } break; case 40: if(dwTickCount >= QD_MotorDelay) { // 切断完成后拉电机动作 if(QD_PARAM_SJZ_LENGTH == 0) { QD_MotorDelay = dwTickCount + 50; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 100) { QD_MotorDelay = dwTickCount + 40; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 200) { QD_MotorDelay = dwTickCount + 30; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 300) { QD_MotorDelay = dwTickCount + 20; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 400) { QD_MotorDelay = dwTickCount + 10; QD_JD_VAVEL = 0; } else if(QD_PARAM_SJZ_LENGTH <= 500) { QD_MotorDelay = dwTickCount + 5; QD_JD_VAVEL = 0; } else { QD_MotorDelay = dwTickCount; } QD_MotorStep = 41; } break; case 41: if(dwTickCount >= QD_MotorDelay) { save_buff = cRealPos; if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P; AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)); QD_MotorStep = 42; } break; case 42: // 切断完成后拉电机动作 if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - save_buff))) { QD_JD_VAVEL = 0; QD_MotorStep = 43; } else if(!X_DRV) { QD_JD_VAVEL = 0; QD_MotorStep = 43; } break; case 43: // 切断完成后拉电机动作 if(!X_DRV) { QD_MotorStep = 0; QD_MotorDelay = dwTickCount; } break; case 61: // 前点定位数控模式 if(QD_SZ_OUT) { QD_SZ_OUT = 0; QD_MotorDelay = dwTickCount + 50; } if(QD_PARAM_TL_MODE) { // if(QD_TuiLianStep == 0)QD_TuiLianStep = 1; } else { if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1; } // cGoLimitEn = 1; SetAccTime(X_AXIS,10); SetDecTime(X_AXIS,10); QD_MotorStep = 62; break; case 62: if(dwTickCount >= QD_MotorDelay) { if(QD_QIAN_LIMIT_IN) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P; AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH); QD_MotorDelay = dwTickCount + 1000; } QD_MotorStep = 63; QD_JD_VAVEL = 0; } break; case 63: if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay)) { if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_N; go_buff = cRealPos; if(cZipCnt > 0) { MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);// } else { MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED); } // MoveAction_Const_Stop(X_AXIS, QD_DIR_P,QD_PARAM_GO_HIGH_SPEED);// // AxisContinueMove(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_DIR_P); //第一条走低速 QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; QD_MotorStep =64; } break; case 64: if(QD_PARAM_GO_MODE) { if(cZipCnt > 0) { if((go_buff - cRealPos) > (go_length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) { MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep =65; } } else { // if(QD_QIAN_DEC_IN) { // if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep =65; } } } else { // if(QD_QIAN_DEC_IN) { // if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED); QD_MotorStep =65; } } break; case 65: if(QD_QIAN_LIMIT_IN_UP) { if(QD_PARAM_DAO_MODE) { dandao_buff = cRealPos; QD_MotorStep = 70; } else { AxisEgmStop(X_AXIS); QD_MotorStep = 66; } } else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM); else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM); break; case 70: if((dandao_buff - cRealPos) >= QD_PARAM_DANDAO_MODE_LENGTH) { AxisEgmStop(X_AXIS); QD_MotorStep = 66; } break; case 66: if(!X_DRV) { QD_MotorDelay = dwTickCount; QD_MotorStep = 67; } break; case 67: if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) ) { if(bRunning) { QD_JD_VAVEL = 1; } QD_MotorStep = 68; QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK; } break; case 68: if(dwTickCount >= QD_MotorDelay) { QD_YBD_VAVLE = 0; QD_TL_VAVLE = 0; QD_MotorStep = 0; } break; } } //电机动作 void QueDuan_Motor(void) // { switch(QD_MACHINE_TYPE) { case QD_CS_TUIFANGKUAI: QueDuan_Motor_CS();break; case QD_QQ_TUIFANGKUAI: QueDuan_Motor_QD();break; default:; } } //超声方式下切 void QueDuan_XiaQue_CS(void) { switch(QD_XiaQieStep) { case 0: break; case 1: QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY; QD_XiaQieStep = 2; break; case 2: if(dwTickCount >= QD_XiaQieDelay) { QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // QD_XM_VAVLE = 1; QD_XiaQieStep = 3; } break; case 3: if(QD_XIA_MU_LIMIT_IN) { QD_XiaQieDelay = dwTickCount + QD_PARAM_GZ_DELAY; QD_XiaQieStep = 4; } else if(dwTickCount >= QD_XiaQieDelay) { QD_SetAlarmCode(QD_XM_DAOWEI); } break; case 4: if(dwTickCount >= QD_XiaQieDelay) { QD_GZ_VAVLE = 1; QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY; // QD_XiaQieStep = 5; } break; case 5: if(dwTickCount >= QD_XiaQieDelay) { QD_TFK_VAVEL = 1; QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // QD_XiaQieStep = 6; } break; case 6: if(QD_GOUZHEN_IN) { QD_SM_VAVLE = 1; QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // QD_XiaQieStep = 7; } else if(dwTickCount >= QD_XiaQieDelay) { QD_SetAlarmCode(QD_GZ_ALARM); } break; case 7: if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) ) { QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; // QD_XiaQieStep = 8; } else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI); break; case 8: if(dwTickCount >= QD_XiaQieDelay) { if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1; QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; // QD_XiaQieStep = 9; } break; case 9: if(dwTickCount >= QD_XiaQieDelay) { QD_CS_OUT = 0; QD_SM_VAVLE = 0; QD_XM_VAVLE = 0; QD_TFK_VAVEL = 0; QD_GZ_VAVLE = 0; QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // QD_XiaQieStep = 10; } break; case 10: if(QD_SHANG_MU_ORIGIN_IN && !QD_XIA_MU_LIMIT_IN) { QD_XiaQieStep = 0; } else if(dwTickCount >= QD_XiaQieDelay) { QD_SetAlarmCode(QD_SM_YUANWEI); } break; } } void QueDuan_TuiLianAction(void) { switch(QD_TuiLianStep) { case 0: break; case 1: QD_TuiLianStep = 2; break; case 2: QD_YBD_VAVLE = 1; QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY; QD_TuiLianStep = 3; break; case 3: if(dwTickCount >= QD_TLDelay) { if(QD_PARAM_TL_MODE) { QD_TuiLianStep = 10; } else { QD_TL_VAVLE = 1; QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY; QD_TuiLianStep = 4; } } break; case 4: if(dwTickCount >= QD_TLDelay) { // QD_TL_VAVLE = 0; QD_TuiLianStep = 0; } break; case 10: if(bRunning && QD_PARAM_TL_MODE)AxisMovePos(Y_AXIS,QD_PARAM_TL_SPEED,QD_PARAM_TL_LENGTH); QD_TuiLianStep = 11; break; case 11: if(!Y_DRV) { { QD_TuiLianStep = 0; } } break; } } //气动推方块方式下切 void QueDuan_XiaQue_QD(void) { switch(QD_XiaQieStep) { case 0: break; case 1: if(!bRunning) { QD_XiaQieDelay = dwTickCount + 50; QD_GZ_VAVLE = 1; QD_XiaQieStep = 20; } else { QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY; QD_XiaQieStep = 2; } break; case 20: if(dwTickCount >= QD_XiaQieDelay) { QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY; QD_TFK_VAVEL = 1; QD_XiaQieStep = 2; } break; case 2: if(dwTickCount >= QD_XiaQieDelay) { QD_SM_VAVLE = 1; QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // QD_XiaQieStep = 3; } break; case 3: if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) ) { QD_XiaQieStep = 4; QD_XiaQieDelay = dwTickCount + 100; } else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI); break; case 4: if(dwTickCount >= QD_XiaQieDelay) { QD_SM_VAVLE = 0; QD_TFK_VAVEL = 0; QD_GZ_VAVLE = 0; if(!QD_PARAM_TL_MODE) { if(QD_TuiLianStep == 0)QD_TuiLianStep = 1; } QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // QD_XiaQieStep = 5; } break; case 5: if(QD_SHANG_MU_ORIGIN_IN && (QD_TuiLianStep == 0)) { if(QD_PARAM_TL_MODE) { if(QD_TuiLianStep == 0)QD_TuiLianStep = 1; } QD_XiaQieStep = 0; QD_XiaQieDelay = dwTickCount + QD_PARAM_TL_DELAY; } else if(dwTickCount >= QD_XiaQieDelay) { QD_SetAlarmCode(QD_SM_YUANWEI); } break; } } //切断动作 void QueDuan_XiaQue(void) { switch(QD_MACHINE_TYPE) { case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break; case QD_QQ_TUIFANGKUAI:QueDuan_XiaQue_QD();break; default:; } } #endif