#include "global.h" #if FJ_YING_XING_MACHINE ==1 void BK_QueDuan_AlarmProtect(void); void BK_QueDuan_ManualAction(void); void BK_QueDuan_AutoAction(void); void BK_QueDuan_StepCheckStart(void); void BK_QueDuan_XiaQue(void); void BK_QueDuan_Motor_NoGL(void); void BK_QueDuan_YuanDianAction(void); void BK_QueDuan_TuiLianAction(void); void BK_QueDuan_ExtiActionX31(void); void BK_QueDuan_BingLian(void); void BKQD_TuiDaiAction(void); short *length_buffer; void BK_QueDuan_ExtiActionX31(void) { cCheckLianFlg = 1; } void BKQD_SetAlarmCode(unsigned alarm_code) { SetAlarmCode(BKQD_ALARM_ADDR,alarm_code); bAlarmStop = 1; } void BK_QueDuan_InitAction(void) { float length_buff,pulse_buff; length_buff = BKQD_PARAM_CYCLE_LENGTH; pulse_buff = BKQD_PARAM_CYCLE_PULSE; XGearRatio = pulse_buff/length_buff; SetDirReverse(X_AXIS, 1); // BKQD_SZ_OUT = 1; } void BK_QueDuan_Action(void) { BK_QueDuan_AlarmProtect(); BK_QueDuan_Motor_NoGL(); BK_QueDuan_XiaQue(); BK_QueDuan_ManualAction(); BK_QueDuan_TuiLianAction(); BK_QueDuan_BingLian(); BK_QueDuan_AutoAction(); BK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序 } //手动动作 void BK_QueDuan_ManualAction(void) { //条数或扎数达到后,台面电机转两秒之后再停机 if(cTABLETIME) { if(cTABLETOTAL) { cTABLETOTAL=0; BKQD_TABLE_VAVLE = 1; BKQD_TableDelay=dwTickCount + 2000; } if(dwTickCount >= BKQD_TableDelay) { BKQD_TABLE_VAVLE = 0; cTABLETIME=0; } } if(bRunning == 0) { cGoLimitEn = 0; if(BKQD_bClearTotal) //切断计数清零 { BKQD_bClearTotal = 0; ClrcToTal(BKQD_TOTAL_ADDR); } if(BKQD_bClearNowTotal) { BKQD_bClearNowTotal = 0; BKQD_PARAM_NOW_CNT = 0; } if(BKQD_bXiaQie) { BKQD_bXiaQie = 0; if((BKQD_XiaQieStep == 0) && !BKQD_TL_VAVLE) { BKQD_XiaQieStep = 1; } } if(BKQD_bQianDianDW) { BKQD_bQianDianDW = 0; if(BKQD_MotorStep == 0) { BKQD_MotorStep = 61; cZipCnt = 0; } } if(BKQD_bTL) { BKQD_bTL = 0; if(BKQD_TL_VAVLE) { BKQD_TL_VAVLE = 0; } else if(!BKQD_GZ_VAVLE && !BKQD_SM_VAVLE) { BKQD_TL_VAVLE = ~BKQD_TL_VAVLE; } } // if(!Y_DRV)BKQD_bTL = 0; if(BKQD_bYD) { BKQD_bYD = 0; BKQD_YD_VAVLE = ~BKQD_YD_VAVLE; } if(BKQD_bGZ) { BKQD_bGZ = 0; BKQD_GZ_VAVLE = ~BKQD_GZ_VAVLE; } if(BKQD_bJD) { BKQD_bJD = 0; BKQD_JD_VAVLE = ~BKQD_JD_VAVLE; } if(BKQD_bXM) { BKQD_bXM = 0; BKQD_XM_VAVLE = ~BKQD_XM_VAVLE; if(!BKQD_XM_VAVLE)BKQD_GZ_VAVLE = 0; } if(BKQD_bSM) { BKQD_bSM = 0; if(BKQD_SM_VAVLE) BKQD_SM_VAVLE = 0; else if(!BKQD_TL_VAVLE) BKQD_SM_VAVLE = 1; } //推方块 if(BKQD_bTFK) { BKQD_bTFK = 0; BKQD_TFK_VAVLE = ~BKQD_TFK_VAVLE; } //台面电机 if(BKQD_bTB) { BKQD_bTB = 0; BKQD_TABLE_VAVLE = ~BKQD_TABLE_VAVLE; } if(BKQD_bTestCS) { BKQD_bTestCS = 0; BKQD_CS_OUT = 1; BKQD_CSDelay = dwTickCount + BKQD_PARAM_CS_TIME; } if(BKQD_bBL)//合链 { BKQD_bBL = 0; BKQD_BL_VAVLE = ~BKQD_BL_VAVLE; } if(BKQD_bHL) //护链,双开用 { BKQD_bHL = 0; BKQD_HL_VAVLE = ~BKQD_HL_VAVLE; } if(BKQD_bYX) { BKQD_bYX = 0; BKQD_YX_VAVLE = ~BKQD_YX_VAVLE; } if(BKQD_XiaQieStep == 0) { if(dwTickCount >= BKQD_CSDelay)BKQD_CS_OUT = 0; } //电机控制 if(BKQD_bGoMotor && !BKQD_QIAN_LIMIT_IN) { BKQD_SZ_OUT = 0; // BKQD_JZ_DIR = BKQD_YDIR_N; if(!X_DRV) // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_GO_LOW_SPEED,10,12); } if(BKQD_bBackMotor) //后退限位已经取消 { BKQD_SZ_OUT = 0; // BKQD_JZ_DIR = BKQD_YDIR_P; if(!X_DRV) // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_P,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_GO_LOW_SPEED,10,12); } if(!BKQD_bGoMotor && !BKQD_bBackMotor && (BKQD_MotorStep == 0)) { if(X_DRV)AxisDecStop(X_AXIS); } if(BKQD_QIAN_LIMIT_IN && (BKQD_MotorStep == 0) && !BKQD_bBackMotor &&(BKQD_AutoStep == 0)) { if(X_DRV)AxisEgmStop(X_AXIS); } } } void BK_QueDuan_AlarmProtect(void) { BKQD_cRealPos = GetPos(X_AXIS); if(!bRunning) { ; } else { if((BKQD_cRealPos > BKQD_PARAM_RUN_LENGTH) && (BKQD_PARAM_RUN_LENGTH > 3000) && (cGoLimitEn != 0)) { AxisEgmStop(X_AXIS); BKQD_JD_VAVLE = 0; BKQD_SetAlarmCode(BKQD_BACK_ALARM); } } } void BK_QueDuan_AutoAction(void) { //台面电机定时关掉 if(BKQD_QIAN_STOP_Auto) { cDLJ_ATUO=1; AxisEgmStop(X_AXIS); } if(BKQD_QIAN_START_Auto) { if(cDLJ_ATUO) { cDLJ_ATUO=0; BKQD_AutoDelay = dwTickCount + 1000; BKQD_MotorDelay = dwTickCount + 2000; if((BKQD_MotorStep==63 || BKQD_MotorStep==64 || BKQD_MotorStep==65) && !BKQD_QIAN_LIMIT_IN) AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,BKQD_PARAM_GO_LOW_SPEED/3,15,15); else if((BKQD_cRealPos < BKQD_PARAM_ZIPPER_LENGTH) && (BKQD_MotorStep > 311)) AxisMoveTwoPos(X_AXIS,1000,(BKQD_PARAM_ZIPPER_LENGTH - BKQD_cRealPos) + (*length_buffer), BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED_LENGTH,BKQD_DIR_P,5000,3000,20,30); } } if(!cDLJ_ATUO) { if(bRunning) { if(!cTABLETIME) { if(dwTickCount >= BKQD_TBDelay) BKQD_TABLE_VAVLE = 0; } switch(BKQD_AutoStep) { case 1: if(dwTickCount >= BKQD_AutoDelay) { BKQD_AutoStep = 2; if(BKQD_MotorStep == 0 && !X_DRV) { BKQD_MotorStep = 61; //前点定位 } cGoLimitEn = 0; } break; case 2: if(BKQD_MotorStep == 0) { BKQD_MotorStep = 30; BKQD_AutoStep = 3; cGoLimitEn = 1; } break; case 3: if(BKQD_MotorStep == 0) { if(BKQD_SAFE_IN) { bStop = 1; } else { if(BKQD_XiaQieStep == 0) BKQD_XiaQieStep = 1; BKQD_AutoStep = 4; } } break; case 4: // 闭口 if((BKQD_XiaQieStep == 0) || ((BKQD_XiaQieStep == 6) && BKQD_KB_MODE)|| ((BKQD_XiaQieStep == 13) && (BKQD_KB_MODE == 0)))// && !BKQD_SHANG_MU_LIMIT_IN) { if(BKQD_MotorStep == 0) { cGoLimitEn=0; BKQD_MotorStep = 40; //切完后退 } BKQD_AutoStep = 5; } break; case 5: if(BKQD_MotorStep == 0) { cZipCnt++; BKQD_PARAM_NOW_CNT++; cTableCnt++; AddToTal(BKQD_TOTAL_ADDR); AddToTal(CT_WORKTOTAL_ADDR); CalProSP(BKQD_PROSPEED_ADDR); if(cTableCnt >= BKQD_PARAM_TABLE_NUM) { cTableCnt = 0; BKQD_TABLE_VAVLE = 1; BKQD_TBDelay = dwTickCount + BKQD_PARAM_TB_TIME; } if( SingOneFlg) { { bRunning = 0; BKQD_AutoStep = 0; SingOneFlg = 0; } } else { BKQD_AutoStep = 1; if((BKQD_PARAM_NOW_CNT >= BKQD_PARAM_ZHA_SHU) && (BKQD_PARAM_ZHA_SHU > 0)) { BKQD_AutoDelay = dwTickCount + BKQD_PARAM_ZS_STOP_TIME; BKQD_PARAM_NOW_CNT = 0; cTABLETIME = 1; cTABLETOTAL= 1; if(BKQD_PARAM_ZS_STOP_TIME == 0) { bRunning = 0; BKQD_AutoStep = 0; SingOneFlg = 0; cTABLETIME = 1; cTABLETOTAL= 1; BKQD_SetAlarmCode(BKQD_TOTAL_ALARM); } } else BKQD_AutoDelay = dwTickCount + BKQD_PARAM_CYCLE_DELAY; } } break; } } } } void BK_QueDuan_StepCheckStart(void) { // 启动 if((BKQD_START_IN_UP) || bStart || BKQD_bSingle) { bStart = 0; if(!bRunning && (BKQD_AutoStep == 0)) { if(BKQD_XIA_MU_LIMIT_IN && !BKQD_PARAM_XM_ENABLE)BKQD_SetAlarmCode(BKQD_XM_DAOWEI); // else if(GetAlarmCode(BKQD_ALARM_ADDR) != 0); //else if(GetTotal(BKQD_TOTAL_ADDR) >= BKQD_PARAM_SET_TOTAL) BKQD_SetAlarmCode(BKQD_TOTAL_ALARM); // else if(BKQD_BL_VAVLE)BKQD_SetAlarmCode(BKQD_BL_ALARM); else if(BKQD_SM_VAVLE)BKQD_SetAlarmCode(BKQD_SM_ALARM); else { bRunning = 1; BKQD_AutoStep = 1; if(BKQD_PARAM_BL_ENABLE) BKQD_PARAM_BL_ENABLE=1 ; //并链起动 if(BKQD_bSingle) SingOneFlg= 1; cZipCnt = 0; cTABLETIME = 0; cTABLETOTAL= 0; cTuiFangKuaiCnt = 0; BKQD_BL_VAVLE = 0; //并链关 cDLJ_ATUO=0; BKQD_DGLG_VAVLE = 0; //顶过链杆关 SetAlarmCode(BKQD_ALARM_ADDR,0); } } BKQD_bSingle = 0; } //停止 if(BKQD_STOP_IN_UP || bStop) { bStop = 0; if(bRunning) { BKQD_AutoDelay = dwTickCount; BKQD_MotorDelay = dwTickCount; BKQD_XiaQieDelay = dwTickCount; BKQD_KaDaiDelay = dwTickCount; BKQD_CSDelay = dwTickCount; BKQD_TBDelay = dwTickCount; BKQD_TFKDelay = dwTickCount; BKQD_TLDelay = dwTickCount; dwTickCount = BKQD_TBDelay; SingOneFlg = 0; BKQD_JD_VAVLE = 0; BKQD_SM_VAVLE = 0; BKQD_XM_VAVLE = 0; BKQD_YD_VAVLE = 0; BKQD_TFK_VAVLE= 0; BKQD_TL_VAVLE = 0; BKQD_HL_VAVLE = 0; BKQD_CS_OUT = 0; BKQD_XiaQieStep = 0; BKQD_MotorStep = 0; BKQD_TuiLianStep = 0; //BKQD_SZ_OUT = 1; BKQD_GZ_VAVLE = 0; BKQD_TABLE_VAVLE = 0; BKQD_DGLG_VAVLE = 0; //顶过链杆关 AxisDecStop(X_AXIS); BKQD_BinLianStep = 0; BKQD_BL_VAVLE = 0; cTABLETIME = 0; cTABLETOTAL= 0; user_datas[121] = 0; user_datas[122] = 0; SetAlarmCode(BKQD_ALARM_ADDR,0); } else { BKQD_AutoDelay = dwTickCount; BKQD_MotorDelay = dwTickCount; BKQD_XiaQieDelay = dwTickCount; BKQD_KaDaiDelay = dwTickCount; BKQD_CSDelay = dwTickCount; BKQD_TBDelay = dwTickCount; BKQD_TFKDelay = dwTickCount; BKQD_TLDelay = dwTickCount; dwTickCount = BKQD_TBDelay; SingOneFlg = 0; BKQD_JD_VAVLE = 0; BKQD_SM_VAVLE = 0; BKQD_XM_VAVLE = 0; BKQD_YD_VAVLE = 0; BKQD_TFK_VAVLE= 0; BKQD_YX_VAVLE = 0; BKQD_HL_VAVLE = 0; BKQD_TL_VAVLE = 0; BKQD_DGLG_VAVLE = 0; //顶过链杆关 BKQD_CS_OUT = 0; BKQD_XiaQieStep = 0; BKQD_MotorStep = 0; BKQD_TuiLianStep = 0; BKQD_SZ_OUT = 1; BKQD_GZ_VAVLE = 0; BKQD_TABLE_VAVLE = 0; AxisDecStop(X_AXIS); cTABLETIME = 0; cTABLETOTAL= 0; BKQD_BinLianStep = 0; BKQD_BL_VAVLE = 0; SetAlarmCode(BKQD_ALARM_ADDR,0); } bRunning = 0; BKQD_XiaQieStep = 0; BKQD_AutoStep = 0; BKQD_MotorStep = 0; BKQD_TuiLianStep = 0; } if(bAlarmStop) { bAlarmStop = 0; BKQD_XiaQieStep = 0; BKQD_AutoStep = 0; BKQD_MotorStep = 0; BKQD_TuiLianStep = 0; BKQD_XiaQieStep = 0; BKQD_MotorStep = 0; BKQD_TuiLianStep = 0; BKQD_AutoDelay = dwTickCount; BKQD_MotorDelay = dwTickCount; BKQD_XiaQieDelay = dwTickCount; BKQD_KaDaiDelay = dwTickCount; BKQD_CSDelay = dwTickCount; BKQD_TBDelay = dwTickCount; BKQD_TFKDelay = dwTickCount; BKQD_TLDelay = dwTickCount; SingOneFlg = 0; bRunning = 0; AxisDecStop(X_AXIS); dwTickCount = BKQD_TBDelay; BKQD_TABLE_VAVLE = 0; BKQD_TFK_VAVLE =0; BKQD_JD_VAVLE=0; BKQD_GZ_VAVLE=0; } } //记忆长度模式误差检测 void BK_QueDuan_CheckLength(long zip_length) { static long start_dist; switch(BKQD_CheckLengthStep) { case 0:break; case 1: start_dist = BKQD_cRealPos; dwSaveLength = 0; BKQD_CheckLengthStep = 2; break; case 2: if(BKQD_GUO_LIAN_IN_DW){ dwSaveLength = BKQD_cRealPos - start_dist; // user_datas[127] = BKQD_cRealPos; } break; } } void BK_QueDuan_BingLian(void) { static long bl_pos_buff,HL_delay; switch(BKQD_BinLianStep) { case 1: bl_pos_buff = BKQD_cRealPos; BKQD_BinLianStep = 2; break; case 2: if((BKQD_cRealPos - bl_pos_buff) >= BKQD_PARAM_DELAY_HL_LENGTH) { BKQD_BL_VAVLE = 1; BKQD_BinLianStep = 3; } break; case 3://有过链检测 if((BKQD_cRealPos - bl_pos_buff) >= (BKQD_PARAM_ZIPPER_LENGTH - BKQD_PARAM_HL_DELAY_BACK)) { BKQD_BL_VAVLE = 0; BKQD_BinLianStep = 0; } if(BKQD_GUO_LIAN_IN_DW && BKQD_PARAM_BACK_MODE ==1) //|| (BKQD_PARAM_BACK_MODE==2 && cZipCnt < 2))) { BKQD_BL_VAVLE = 0; BKQD_BinLianStep = 0; } break; case 10: bl_pos_buff = BKQD_cRealPos; BKQD_BinLianStep = 11; break; case 11: if((BKQD_cRealPos - bl_pos_buff) >= BKQD_PARAM_DELAY_HL_LENGTH) { BKQD_BL_VAVLE = 1; BKQD_BinLianStep = 12; } break; case 12://有过链检测 if(BKQD_GUO_LIAN_IN_DW) { BKQD_BL_VAVLE = 0; BKQD_BinLianStep = 0; } break; default:; } } //不带过链感应长度输入电机长度 闭口有勾针到位 void BK_QueDuan_Motor_NoGL(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; long pulse_buff; unsigned short ch,kk; user_datas[121] = BKQD_MotorStep; user_datas[122] = BKQD_AutoStep; user_datas[124]= BKQD_cRealPos; user_datas[125]= bRunning; // user_datas[123] = length_buff - (*length_buffer); // user_datas[127] = BKQD_cRealPos; // user_datas[126] = go_buff - BKQD_cRealPos; if((BKQD_MotorStep >= 101) && (BKQD_MotorStep <= 103)) { if(BKQD_QIAN_LIMIT_IN_DW)BKQD_HL_VAVLE = 0; } if(!cDLJ_ATUO) { switch(BKQD_MotorStep) { case 30: BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK; SetPos(X_AXIS, 0); length_buffer = &BKQD_PARAM_OFFSET_LENGTH; if(BKQD_PARAM_BL_ENABLE) // BKQD_BinLianStep = 1; BKQD_MotorStep = 31; break; case 31: if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH )) BKQD_GZ_VAVLE = 1; if(dwTickCount >= BKQD_MotorDelay) { back_buff = BKQD_cRealPos; gou_zhen_buff = BKQD_cRealPos; save_buff = BKQD_cRealPos; length_buffer = &BKQD_PARAM_OFFSET_LENGTH; DCC_TIME_BL=BKQD_PARAM_GO_HIGH_SPEED/500; AxisMovePosAccDecNotStop(X_AXIS,BKQD_PARAM_BACK_SPEED,BKQD_PARAM_ZIPPER_LENGTH + (*length_buffer), BKQD_PARAM_START_SPEED,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_ACC,DCC_TIME_BL,BKQD_PARAM_BACK_LOW_SPEED_LENGTH); BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; BKQD_MotorStep = 32; } break; case 32: //勾针提前输出 if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH )) BKQD_GZ_VAVLE = 1; if((BKQD_cRealPos) > (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (BKQD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(BKQD_PARAM_BACK_SPEED,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_DCC))))) { BKQD_MotorDelay = dwTickCount + 3000; //钩针未到位延时警告 BKQD_MotorStep = 33; } else if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//BKQD_PARAM_ERROR_LENGTH)) { BKQD_SetAlarmCode(BKQD_GZ_ALARM); } break; case 33: if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH )) { BKQD_GZ_VAVLE = 1; } if(BKQD_GOUZHEN_IN) { AxisEgmStop(X_AXIS); BKQD_MotorDelay = dwTickCount + 15; BKQD_YD_VAVLE = 1; BKQD_MotorStep = 34; BKQD_BL_VAVLE = 0; //停止时并链一定要打开 } else if((BKQD_cRealPos >= BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))// && dwTickCount >= BKQD_MotorDelay) { AxisEgmStop(X_AXIS); if(dwTickCount >= BKQD_MotorDelay) BKQD_SetAlarmCode(BKQD_GZ_ALARM); } break; case 34: if(!X_DRV && (dwTickCount >= BKQD_MotorDelay)) { BKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME; BKQD_YD_VAVLE = 1; BKQD_MotorStep = 35; } break; case 35: if(cZipCnt == 0) { ch = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-120; kk = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+120; } else { ch = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-100; kk = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+100; } user_datas[128] = ch; user_datas[127] = kk; if(((BKQD_cRealPos) < (ch))) { SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM); if(dwTickCount >= BKQD_MotorDelay) bAlarmStop = 1; } else if((BKQD_cRealPos > kk))//(BKQD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50))) { SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM); if(dwTickCount >= BKQD_MotorDelay) bAlarmStop = 1; } else { AxisMovePosAccDec(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,-BKQD_PARAM_FZ_LENGTH,3000,1000,BKQD_PARAM_ACC,BKQD_PARAM_DCC,00); BKQD_MotorStep = 0; } break; case 40: //切完延时后拉带松夹子 if(BKQD_PARAM_SJZ_LENGTH == 0) { BKQD_MotorDelay = dwTickCount + BKQD_PARAM_TDYS_DELAY; jz_buff = BKQD_cRealPos; BKQD_MotorStep = 43; BKQD_JD_VAVLE = 0; } else { jz_buff = BKQD_cRealPos; SetDir(X_AXIS, BKQD_DIR_P); BKQD_MotorStep = 41; } break; case 41: AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_SJZ_LENGTH+BKQD_PARAM_BACK_LENGTH,1000,1000,25,50,0); BKQD_MotorStep = 42; break; case 42: if(!X_DRV || (BKQD_PARAM_SJZ_LENGTH <= (BKQD_cRealPos - jz_buff))) { BKQD_JD_VAVLE = 0; BKQD_GZ_VAVLE=0; BKQD_MotorStep = 44; } break; case 43: if(dwTickCount >= BKQD_MotorDelay) { SetDir(X_AXIS, BKQD_DIR_P); AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_BACK_LENGTH,1000,1000,25,50,0); BKQD_MotorStep = 44; } break; case 44: // 切断完成后拉电机动作 if(!X_DRV || (BKQD_cRealPos - jz_buff) >= (BKQD_PARAM_SJZ_LENGTH+BKQD_PARAM_BACK_LENGTH)) { AxisEgmStop(X_AXIS); BKQD_MotorStep = 0; BKQD_GZ_VAVLE=0; BKQD_MotorDelay = dwTickCount; } break; case 61: // 前点定位数控模式 if(BKQD_SZ_OUT) { BKQD_SZ_OUT = 0; BKQD_MotorDelay = dwTickCount + 150; SetPos(X_AXIS, 0); } else BKQD_MotorDelay = dwTickCount; BKQD_BL_VAVLE = 0;//并链也要打开 if(!BKQD_TL_VAVLE && cZipCnt) //没送链情况下主动送链 { if(!BKQD_SHANG_MU_LIMIT_IN && (BKQD_TuiLianStep == 0)) { BKQD_TuiLianStep = 1; BKQD_MotorStep = 62; } } else BKQD_MotorStep = 62; break; case 62: if(dwTickCount >= BKQD_MotorDelay) { if(BKQD_QIAN_LIMIT_IN) { SetPos(X_AXIS, 0);//在前点,直接置零点 //前点亮的情况下先退出 AxisMovePos(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,1000); BKQD_MotorDelay = dwTickCount + 300; } BKQD_MotorStep = 63; BKQD_JD_VAVLE = 0; } break; case 63: if(!X_DRV && !BKQD_QIAN_LIMIT_IN && (dwTickCount >= BKQD_MotorDelay))// && !BKQD_SHANG_MU_LIMIT_IN) { go_buff = BKQD_cRealPos; BKQD_YD_VAVLE = 1; BKQD_HL_VAVLE = 1; BKQD_YX_VAVLE = 1; if(cZipCnt > 0) { if(BKQD_cRealPos>(BKQD_PARAM_GO_LOW_SPEED_LENGTH)) { DCC_TIME_BL=BKQD_PARAM_GO_HIGH_SPEED/500; AxisMovePosAccDecNotStop(X_AXIS,BKQD_PARAM_GO_HIGH_SPEED,-BKQD_cRealPos, BKQD_PARAM_START_SPEED,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_ACC,DCC_TIME_BL, BKQD_PARAM_GO_LOW_SPEED_LENGTH); } else { // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,1000,15,15); } } else { // X轴 运行速度 启动速度 加速度 减速度 AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,1000,15,15); } BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME; BKQD_MotorStep =64; } break; case 64: if(cZipCnt > 1) { //李永庆代码 if(((BKQD_cRealPos) < (BKQD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (BKQD_QIAN_DEC_IN)) { user_datas[126]= GetCurSpeed(X_AXIS); BKQD_MotorStep =65; } if(BKQD_QIAN_LIMIT_IN) //前点限位 { SetPos(X_AXIS, BKQD_PARAM_QDW_LENGTH); AxisMovePosAccDec(X_AXIS,1000,-BKQD_PARAM_QDW_LENGTH,1000,1000,5,5,00); BKQD_MotorStep = 66; } } else { if(BKQD_QIAN_LIMIT_IN) //前点限位 { SetPos(X_AXIS, BKQD_PARAM_QDW_LENGTH); AxisMovePosAccDec(X_AXIS,1000,-BKQD_PARAM_QDW_LENGTH,1000,1000,5,5,00); BKQD_MotorStep = 66; } } break; case 65: if(BKQD_QIAN_LIMIT_IN) { SetPos(X_AXIS, BKQD_PARAM_QDW_LENGTH); AxisMovePosAccDec(X_AXIS,1000,-BKQD_PARAM_QDW_LENGTH,1000,1000,5,5,00); BKQD_MotorStep = 66; } else if(dwTickCount >= BKQD_MotorDelay) BKQD_SetAlarmCode(BKQD_NO_ZIPPER_ALARM); break; case 66: if(!X_DRV || BKQD_cRealPos<0) { SetPos(X_AXIS, 0); BKQD_MotorDelay = dwTickCount; BKQD_MotorStep = 67; } break; case 67: //等推链完成后, if((dwTickCount >= BKQD_MotorDelay) && (BKQD_TuiLianStep == 0) && ((BKQD_PARAM_TIAOSHI_MODE && BKQD_bTS) || (BKQD_PARAM_TIAOSHI_MODE == 0)) ) { if(bRunning) { BKQD_JD_VAVLE = 1; BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK; } BKQD_MotorStep = 68; } break; case 68: if(dwTickCount >= BKQD_MotorDelay) { BKQD_YD_VAVLE = 0; BKQD_HL_VAVLE = 0; BKQD_YX_VAVLE = 0; BKQD_TL_VAVLE = 0; BKQD_MotorStep = 0; BKQD_MotorDelay = dwTickCount; } break; } } } void BK_QueDuan_TuiLianAction(void) { if(BKQD_PARAM_XM_ENABLE == 0) { BKQD_TuiLianStep = 0; } else { switch(BKQD_TuiLianStep) { case 1: BKQD_TuiLianStep = 2; break; case 2: if(BKQD_PARAM_TL_DELAY) BKQD_TLDelay = dwTickCount + BKQD_PARAM_TL_DELAY; else BKQD_TLDelay = dwTickCount + 100; BKQD_TuiLianStep = 3; break; case 3: if(!BKQD_SM_VAVLE && !BKQD_SHANG_MU_LIMIT_IN && dwTickCount >= BKQD_TLDelay) { BKQD_TL_VAVLE = 1; BKQD_TFK_VAVLE = 0; if(!bRunning)BKQD_TFK_VAVLE = 0; BKQD_TLDelay = dwTickCount + BKQD_PARAM_TL_DELAY; BKQD_TuiLianStep = 4; } break; case 4: if(dwTickCount >= BKQD_TLDelay) { BKQD_TuiLianStep = 0; } break; case 10: BKQD_TuiLianStep = 11; break; case 11: if(!Y_DRV) { { BKQD_TuiLianStep = 0; } } break; } } } //闭口专用 void BK_QueDuan_XiaQue_NO_GL(void) { switch(BKQD_XiaQieStep) { case 0: break; case 1: if(!bRunning) { BKQD_YD_VAVLE = 1; BKQD_XiaQieStep = 2; BKQD_XiaQieDelay = dwTickCount + 30; } else { BKQD_YD_VAVLE = 1; BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CUT_DELAY; BKQD_XiaQieStep = 2; } break; case 2: if(dwTickCount >= BKQD_XiaQieDelay) { BKQD_XiaQieStep = 3; BKQD_XiaQieDelay = dwTickCount; } break; case 3: if(dwTickCount >= BKQD_XiaQieDelay) { if((BKQD_PARAM_TIAOSHI_MODE && BKQD_bTS) || (BKQD_PARAM_TIAOSHI_MODE == 0)) { BKQD_SM_VAVLE = 1; BKQD_XM_VAVLE = 1; BKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // BKQD_XiaQieStep = 4; } } break; case 4://永兴为下模固定 if(BKQD_SHANG_MU_LIMIT_IN && (BKQD_XIA_MU_LIMIT_IN || BKQD_PARAM_XM_ENABLE)) { BKQD_GZ_VAVLE = 0; if(!BKQD_PARAM_CS_MODE) //气切 { BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_DELAYBACK_SM; // BKQD_XiaQieStep = 5; } else { BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_DELAY_CS; // BKQD_XiaQieStep = 10; } // } else if(dwTickCount >= BKQD_XiaQieDelay)BKQD_SetAlarmCode(BKQD_SM_DAOWEI); break; case 5: if(dwTickCount >= BKQD_XiaQieDelay) { BKQD_SM_VAVLE = 0; BKQD_XM_VAVLE = 0; BKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; // BKQD_XiaQieStep = 6; } break; case 6: if(!BKQD_SHANG_MU_LIMIT_IN && (!BKQD_XIA_MU_LIMIT_IN || BKQD_PARAM_XM_ENABLE)) //下模不动就不用判断 { if(BKQD_TuiLianStep == 0) BKQD_TuiLianStep = 1; if(!bRunning) BKQD_JD_VAVLE = 0; BKQD_XiaQieStep = 0; } else if(dwTickCount >= BKQD_XiaQieDelay) { BKQD_SetAlarmCode(BKQD_SM_YUANWEI); } break; //10~11步为超声 case 10: if(dwTickCount >= BKQD_XiaQieDelay) { if(BKQD_PARAM_CS_ENABLE)BKQD_CS_OUT = 1; BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CS_TIME; // BKQD_XiaQieStep = 11; } break; case 11: if(dwTickCount >= BKQD_XiaQieDelay) { BKQD_CS_OUT = 0; BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CS_COLD_TIME; // BKQD_XiaQieStep = 5; } break; case 100: if(dwTickCount >= BKQD_XiaQieDelay) { //这是双开程序,暂时不考虑 #if 1 if(BKQD_GOUZHEN_IN) { BKQD_YD_VAVLE = 1; BKQD_XiaQieStep = 3; } #endif } break; } } //切断动作 void BK_QueDuan_XiaQue(void) { BK_QueDuan_XiaQue_NO_GL(); } #endif