#include "global.h" #if HONG_YE_MACHINE /* 机械手式切断机 切断穿头机动作函数 ** 输入输出说明: X00 起动(全自动) X01 停止 X02 没链感应 X03 X04 卡带 X05 拉带前进限位感应开关 X06 拉带前进减速感应开关 X07 拉带后退限位感应开关 X10 拉头触针感应 X11 给料前(推拉头前) X12 给料后(推拉头后) X13 送料前 X14 送料后 X15 上切原位 X16 X17 下切到位 X20 下切原位 X21 下模到位 X22 下模原位 X23 振动盘 X24 夹子左 X25 夹子右 //输出 Y17 Y16 Y15 Y14 Y13 振动盘 Y12 开链 Y11 Y10 Y07 Y06 机械手夹 Y05 给料 Y04 送料 Y03 夹拉头 Y02 上模 Y01 下切 Y00 上切 D76 累计产量 D77 累计产量 D78 一分钟产量 D80 音波自动 D84 切断计数 D85 打包数量设定(不是触摸屏时设为0) */ #define _YZQ_W_NO_WARNING 0 //没警告 #define __YZQ_W_NO_ZIP 1 //没拉链,自动停机 #define __YZQ_GUOZH_DAOWEI 2 //钩针到位开关异常 #define __YZQ_JIADAI 5 //夹带感应开关异常 #define __YZQ_MOTOR_FORWARDRETARD 6 //拉带前进减速感应开关异常 #define __YZQ_XIAQUE_DAOWEI 4 //下切到位感应开关异常 #define __YZQ_XIAQUE_ORIGIN 3 //下切退到位感应开关异常 #define __YZQ_FORWARD_LIMIT 7 //拉带前进限位感应开关异常 #define __YZQ_BACK_LIMIT 8 //拉带后退限位感应开关异常 #define __YZQ_SONGDAI_DAOWEI 9 //送带到位感应开关异常 #define __YZQ_RETARD_SIGNAL 10 //减速感应开关异常 #define __YZQ_SafeDoor_SIGNAL 11 //安全门 #define __YZQ_LaLianLend_Change 12 //拉链长度变化 #define __YZQ_ZIPPER_LONG 14 //拉链变长 #define __YZQ_ZIPPER_SHORT 15 //拉链变短 #define __YZQ_XIAMO_DAOWEI 16 //下模到位感应开关异常 #define __YZQ_TOTAL 17 void QueDuan_NewStr_StepCheckStart(void); void QianDianDWStep(void); void QueDuan_NewStr_Motor(void); void QueDuan_NewStr_XiaQue(void); void Stop_Dec(void); void SongDai(void); void GeiLiao_CT_QD_GL(void); void HeMo_CT_QD_GL(void); void ZhuangLiao_CT_QD_GL(void); void ManualActionYJ(void); void AutoStep(void); //void TaiMianMotorStep(void); void KaiLianStep(void); void ChuanLTStep(void); void ZhenDongStep(void); void JiaLianStep(void); SystemParam_str *SystemParam; TestData_str *TestData; unsigned short cTaiMiamMotor; unsigned long cSlowPusle; unsigned short cXiaQieStep; unsigned short cXiaQieDelay; unsigned short cZhuangLiaoStep; unsigned short cZhuangLiaoDelay; unsigned short cGeiLiaoStep; unsigned short cGeiLiaoDelay; unsigned short cMotorStep; unsigned short cMotorDelay; unsigned short cHeMoStep; unsigned short cHeMoDelay; unsigned short cAutoStep; unsigned short cAutoDelay; unsigned short cKaiLianStep; unsigned short cKaiLianDelay; unsigned short cTaiMianMotorStep; unsigned short cTaiMianMotorDelay; unsigned long cTaiMianCnt; unsigned short cQianDianDWStep; unsigned short cQianDianDWDelay; unsigned short cChuanLTStep; unsigned short cChuanLTDelay; unsigned short cZhenDongStep; unsigned short cZhenDongDelay; unsigned short cJiaLianStep; unsigned short cJiaLianDelay; unsigned char bDecEn; unsigned char bStartOnceTime; unsigned short cWorkCnt; unsigned char TryCnt = 0; unsigned char FirstGeiLiaoFlg = 0; unsigned char ZhuangLiaoOkFlg = 0; void DelayYJ(void) { if(cXiaQieDelay)cXiaQieDelay--; if(cZhuangLiaoDelay)cZhuangLiaoDelay--; if(cMotorDelay)cMotorDelay--; if(cGeiLiaoDelay)cGeiLiaoDelay--; if(cHeMoDelay)cHeMoDelay--; if(cAutoDelay)cAutoDelay--; if(cKaiLianDelay)cKaiLianDelay--; if(cTaiMianMotorDelay)cTaiMianMotorDelay--; if(cQianDianDWDelay)cQianDianDWDelay--; if(cChuanLTDelay)cChuanLTDelay--; if(cZhenDongDelay)cZhenDongDelay--; if(cJiaLianDelay)cJiaLianDelay--; } //故障报警 void SetAlarmYJ(unsigned short alarm_num) { if(bWorkMode) { bAlarmStop = 1; if(alarm_num != 0)SystemParam->AlarmCode = alarm_num; } } //初始化动作 void InitActionYJ(void) { float buff_pulse,buff_dist; SystemParam = (SystemParam_str *)&cDataArea[0]; TestData = (TestData_str *)&cDataArea[121]; buff_pulse = SystemParam->XCyclePulse; buff_dist = SystemParam->XCycleDist; XGearRatio = buff_pulse/buff_dist; X_SON = 0; } //X05减速感应外部中断动作(上升沿) void ExIneruptActionYJ(void) { if(bDecEn) { bDecEn = 0; if(SystemParam->MachineMode) MoveDecPulse(X_AXIS,SystemParam->DecLength); //反穿中间要停 else MoveDecPulse(X_AXIS,(SystemParam->DecLength + SystemParam->SecondMoveLength)); //正穿中间不停所以要加上二次前进长度 } } //告警动作 void AlarmProtectYJ(void) { if(X_DRV) { if(bXDirction) { /* if(TUODAI_QIANJIN_LIMIT_IN) { SetAlarmYJ(7); MV_Limit_Stop(X_AXIS); }*/ } else { if(TUODAI_HOUTUI_LIMIT_IN) { SetAlarmYJ(8); MV_Limit_Stop(X_AXIS); } } } if(bRunning) { if(!NO_ZIPPER_CHECK_IN)SetAlarmYJ(1); } } void StopAction(void) { cXiaQieStep = 0; cZhuangLiaoStep = 0; cGeiLiaoStep = 0; cMotorStep = 0; cAutoStep = 0; cKaiLianStep = 0; cQianDianDWStep = 0; cChuanLTStep = 0; cZhenDongStep = 0; cJiaLianStep = 0; FirstGeiLiaoFlg = 0; SystemParam->Speed = 0; bSaveWorkState = 1; } void QueDuan_ChuanTou_ActionYJ(void) { TestData->DispLay[0] = cAutoStep; TestData->DispLay[1] = cQianDianDWStep; TestData->DispLay[2] = cGeiLiaoStep; TestData->DispLay[3] = cZhuangLiaoStep; TestData->DispLay[4] = cMotorStep; TestData->DispLay[5] = cXiaQieStep; TestData->DispLay[6] = cChuanLTStep; TestData->DispLay[7] = cXiaQieStep; TestData->DispLay[8] = cKaiLianStep; AlarmProtectYJ(); QueDuan_NewStr_StepCheckStart(); // 调用脚踏开关检测程序 QueDuan_NewStr_Motor(); QianDianDWStep(); QueDuan_NewStr_XiaQue(); GeiLiao_CT_QD_GL(); ChuanLTStep(); ZhuangLiao_CT_QD_GL(); ZhenDongStep(); JiaLianStep(); // TaiMianMotorStep(); ManualActionYJ(); AutoStep(); } void JiaLianStep(void) { if(cJiaLianStep == 1) { cJiaLianDelay = SystemParam->DelayJD * 10; cJiaLianStep = 2; } else if((cJiaLianStep == 2) && (cJiaLianDelay == 0)) { JZ_OUT = 1; cJiaLianDelay = JIA_DAI_ERROR_TIME; cJiaLianStep = 3; } else if(cJiaLianStep == 3) { if(JZ_LEFT_IN && JZ_RIGHT_IN) { cJiaLianStep = 4; } else if(cJiaLianDelay == 0) { if(!JZ_LEFT_IN)SetAlarmYJ(24); else if(!JZ_RIGHT_IN)SetAlarmYJ(25); } } else if(cJiaLianStep == 4) { if(SystemParam->KaiLianTime) { cJiaLianDelay = SystemParam->DelayKL * 10; cJiaLianStep = 5; } else { cJiaLianStep = 7; } } else if((cJiaLianStep == 5) && (cJiaLianDelay == 0)) { KL_OUT = 1; cJiaLianStep = 6; cJiaLianDelay = SystemParam->KaiLianTime * 10; } else if((cJiaLianStep == 6) && (cJiaLianDelay == 0)) { KL_OUT = 0; cJiaLianStep = 7; // cJiaLianDelay = SystemParam->KaiLianTime * 10; } else if((cJiaLianStep == 7)) { cJiaLianStep = 0; } } //自动动作 void AutoStep(void) { if(bRunning) { if(cAutoStep == 1) { cAutoStep = 2; cZhenDongStep = 1; } else if((cAutoStep == 2) && (cAutoDelay == 0)) { if(cGeiLiaoStep == 0) { cGeiLiaoStep = 1; cAutoStep = 3; } } else if(cAutoStep == 3) { if(cQianDianDWStep == 0) { cQianDianDWStep = 1; ZhuangLiaoOkFlg = 0; cAutoStep = 4; } } else if(cAutoStep == 4) { if(cGeiLiaoStep == 0) { cAutoStep = 5; } } else if(cAutoStep == 5) { if(cZhuangLiaoStep == 0) { cZhuangLiaoStep = 1; cAutoStep = 6; } } else if(cAutoStep == 6) { if(cZhuangLiaoStep == 0) { cAutoStep = 7; } } else if(cAutoStep == 7) { cAutoStep = 8; } else if(cAutoStep == 8) { cAutoStep = 9; } else if(cAutoStep == 9) { if(cQianDianDWStep == 0) { cAutoStep = 10; } } else if(cAutoStep == 10) { cAutoStep = 11; } else if(cAutoStep == 11) { if(cChuanLTStep == 0) { cChuanLTStep = 1; cAutoStep = 12; } } else if(cAutoStep == 12) { if(cChuanLTStep == 0) { cAutoStep = 13; } } else if(cAutoStep == 13) { cAutoStep = 14; } else if(cAutoStep == 14) { if(cXiaQieStep == 0) { cXiaQieStep = 1; cAutoStep = 15; } } else if(cAutoStep == 15) { if(cXiaQieStep == 0) { cAutoStep = 16; } } else if(cAutoStep == 16) { CalProSP(); //计算生产速度 AddToTal(8); //生产总量加1并保存 AddToTal(10); //生产总量加1并保存 cWorkCnt++; if(SystemParam->NowTotal >= SystemParam->SetTotal) { SystemParam->NowTotal = 0; Save32BitDate(0,10); bStartOnceTime = 0; SetAlarmYJ(16); } else { if(bStartOnceTime) { bStartOnceTime = 0; cAutoStep = 0; bRunning = 0; } else cAutoStep = 17; } } else if(cAutoStep == 17) { if(!LATOU_CHUZHEN_IN) { cAutoStep = 2; // cAutoDelay = SystemParam->CycleDelay * 10; } else { SetAlarmYJ(2); } } } } //振动盘控制 void ZhenDongStep(void) { if(cZhenDongStep == 1) { cZhenDongStep = 2; } else if(cZhenDongStep == 2) { if(LATOU_IN) { } else { ZDP_OUT = 1; cZhenDongStep = 3; } } else if(cZhenDongStep == 3) { if(!SystemParam->ZhenDongMode) { cZhenDongStep = 0; } else { cZhenDongStep = 4; cZhenDongDelay = SystemParam->ZDWorkDelay * 10; } } else if((cZhenDongStep == 4) && (cZhenDongDelay == 0)) { ZDP_OUT = 0; cZhenDongStep = 2; } else if(cZhenDongStep == 6) { cZhenDongStep = 0; } } //台面电机动作 /* void TaiMianMotorStep(void) { if(cTaiMianMotorStep == 1) { // TABLE_MOTOR_OUT = 1; cTaiMianMotorDelay = SystemParam->TableMotorWorkTime * 10; cTaiMianMotorStep = 2; } else if((cTaiMianMotorStep == 2) && (cTaiMianMotorDelay == 0)) { // TABLE_MOTOR_OUT = 0; cTaiMianMotorStep = 0; } }*/ void QueDuan_NewStr_StepCheckStart(void) { //启动 自动启动 单一自动 if(START_IN_UP || bStart || bOnceStart) { if(bOnceStart) { bOnceStart = 0; bStartOnceTime = 1; } bStart = 0; if(!NO_ZIPPER_CHECK_IN)SetAlarmYJ(30); else if(JLT_IN)SetAlarmYJ(31); else if(LATOU_CHUZHEN_IN)SetAlarmYJ(32); else if(!GL_ORIGIN_IN)SetAlarmYJ(33); else if(SL_ARRIVE_IN)SetAlarmYJ(34); else if(!SQ_ORIGIN_IN)SetAlarmYJ(35); else if(!XQ_ORIGIN_IN)SetAlarmYJ(36); else if(!SM_ORIGIN_IN)SetAlarmYJ(37); else { if(!bRunning && (cAutoStep == 0) && (SystemParam->AlarmCode == 0)) { bRunning = 1; cAutoStep = 1; cWorkCnt = 0; TryCnt = 0; } } } //停止 if(STOP_IN_UP|| bStop) { StopAction(); MV_Dec_Stop(X_AXIS); bRunning = 0; bOnceStart = 0; bStop = 0; X_SON = 0; bStartOnceTime = 0; SQ_OUT = 0; XQ_OUT = 0; SM_OUT = 0; JZ_OUT = 0; SL_OUT = 0; JLT_OUT= 0; GL_OUT = 0; KL_OUT = 0; ZDP_OUT= 0; SLT_OUT= 0; if(SystemParam->AlarmCode)SystemParam->AlarmCode = 0; } if(bAlarmStop) { StopAction(); bOnceStart = 0; bAlarmStop = 0; bStartOnceTime = 0; ZDP_OUT = 0; MV_Dec_Stop(X_AXIS); M48 = 0; M49 = 0; } } //电机控制动作 void QueDuan_NewStr_Motor(void) // { static long save_jz_dist; if(cMotorStep == 1) //第一条不知道夹子位置直接走慢速 { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 2; } else if((cMotorStep == 2) && (cMotorDelay == 0)) { bDecEn = 1; MV_Const_Move(X_AXIS,SystemParam->LowSpeed,0); cMotorStep = 3; } else if((cMotorStep == 3) && !X_DRV) { cMotorStep = 0; } else if(cMotorStep == 10) //第二条开始走高速,到慢速长度后降到慢速保证过减速感应的时候都是同一个速度 { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 11; } else if((cMotorStep == 11) && (cMotorDelay == 0)) { bDecEn = 1; save_jz_dist = SystemParam->XRealPos; MV_Const_Move(X_AXIS,SystemParam->JJGoSpeed,0); cMotorStep = 12; } else if((cMotorStep == 12)) { if(SystemParam->XRealPos <= (save_jz_dist - SystemParam->CutBackLength - SystemParam->ZipperLength + SystemParam->LowSpeedLength + SystemParam->FZLength)) { MV_Const_Move_Change_Speed(X_AXIS,SystemParam->LowSpeed); cMotorStep = 13; } } else if((cMotorStep == 13) && !X_DRV) { cMotorStep = 0; } else if(cMotorStep == 20) //穿拉带先高速再低速然后再高速 { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 21; } else if((cMotorStep == 21) && (cMotorDelay == 0)) { MoveControl(X_AXIS,SystemParam->ZipperLength,SystemParam->HighSpeedLength,SystemParam->BackLowSpeedLength,SystemParam->LDBackSpeed,SystemParam->LDBackLowSpeed,1); cMotorStep = 22; } else if((cMotorStep == 22) && !X_DRV) { cMotorStep = 0; } else if(cMotorStep == 30) { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 31; } else if((cMotorStep == 31) && (cMotorDelay == 0)) //反转 { MoveAction_Dist(X_AXIS,SystemParam->FZLength,SystemParam->FZSpeed,0); cMotorStep = 32; } else if((cMotorStep == 32) && !X_DRV) { cMotorStep = 0; } else if(cMotorStep == 40) { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 41; } else if((cMotorStep == 41) && (cMotorDelay == 0)) //切断之后后退长度 { MoveAction_Dist(X_AXIS,SystemParam->CutBackLength,SystemParam->CutBackSpeed,1); cMotorStep = 42; } else if((cMotorStep == 42) && !X_DRV) { cMotorStep = 0; } else if(cMotorStep == 60) { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 61; } else if((cMotorStep == 61) && (cMotorDelay == 0)) //手动拖带后退 { MV_Const_Move(X_AXIS,20,1); cMotorStep = 62; } else if((cMotorStep == 62) && !X_DRV) { X_SON = 0; cMotorStep = 0; } else if(cMotorStep == 80) { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 81; } else if((cMotorStep == 81) && (cMotorDelay == 0)) //手动拖带前进 { MV_Const_Move(X_AXIS,20,0); cMotorStep = 82; } else if((cMotorStep == 82) && !X_DRV) { X_SON = 0; cMotorStep = 0; } else if(cMotorStep == 100) { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 101; } else if((cMotorStep == 101) && (cMotorDelay == 0)) //二次前进长度 { MoveAction_Dist(X_AXIS,SystemParam->SecondMoveLength,SystemParam->JJGoSpeed,0); cMotorStep = 102; } else if((cMotorStep == 102) && !X_DRV) { cMotorStep = 0; } else if(cMotorStep == 120) { if(!X_SON) { X_SON = 1; cMotorDelay = 150; } cMotorStep = 121; } else if((cMotorStep == 121) && (cMotorDelay == 0)) { MoveAction_Dist(X_AXIS,SystemParam->FirstBackLength,SystemParam->CutBackSpeed,1); //一开始如果压着感应直接先后退 cMotorStep = 122; } else if((cMotorStep == 122) && !X_DRV) { cMotorStep = 0; } } //前点定位 void QianDianDWStep(void) { if(cQianDianDWStep == 1) { JZ_OUT = 0; cQianDianDWDelay = JIA_DAI_ERROR_TIME; cQianDianDWStep = 2; } else if(cQianDianDWStep == 2) { if((cWorkCnt == 0) && (TUODAI_QIANJIN_LIMIT_IN || TUODAI_QIANJIN_DEC_IN)) //第一条启动的时候压着感应就要先后退 { cMotorStep = 120; cQianDianDWStep = 3; } else cQianDianDWStep = 4; } else if(cQianDianDWStep == 3) { if(cMotorStep == 0) { cQianDianDWStep = 4; } } else if(cQianDianDWStep == 4) { if(!JZ_LEFT_IN && !JZ_RIGHT_IN) { if(cWorkCnt >= 1) //第一条走慢速 cMotorStep = 10; else cMotorStep = 1; cQianDianDWStep = 5; cQianDianDWDelay = 0; } else if(cQianDianDWDelay == 0) { if(JZ_LEFT_IN)SetAlarmYJ(24); else if(JZ_RIGHT_IN)SetAlarmYJ(25); } } else if(cQianDianDWStep == 5) { if(cMotorStep == 0) { if(!SystemParam->MachineMode) cJiaLianStep = 1;//正穿的话直接电机停了就要夹链和开链 cQianDianDWStep = 6; } } else if((cQianDianDWStep == 6) && (bWorkMode || bNext)) { if((cZhuangLiaoStep == 0) && (ZhuangLiaoOkFlg == 1)) { cQianDianDWStep = 7; ZhuangLiaoOkFlg = 0; } } else if((cQianDianDWStep == 7) && (bWorkMode || bNext)) { if(SystemParam->MachineMode) //反穿才需要在夹链前停止进行二次前进,正穿不需要直接到位后夹拉链 cMotorStep = 100; else cMotorStep = 0; cQianDianDWStep = 8; } else if(cQianDianDWStep == 8) { if(cMotorStep == 0) { cQianDianDWStep = 9; } } else if((cQianDianDWStep == 9) && (bWorkMode || bNext)) { if(SystemParam->MachineMode)cJiaLianStep = 1; //反穿夹带要等装完料才夹正穿之前就要夹直接跳过 cQianDianDWStep = 10; } else if(cQianDianDWStep == 10) { if(cJiaLianStep == 0) { cQianDianDWStep = 11; } } else if((cQianDianDWStep == 11)) { cQianDianDWStep = 12; } else if((cQianDianDWStep == 12)) { cQianDianDWStep = 13; } else if((cQianDianDWStep == 13)) { cQianDianDWStep = 0; } } //穿拉头动作 void ChuanLTStep(void) { static long save_xm_dist; if(cChuanLTStep == 1) { cChuanLTStep = 2; save_xm_dist = SystemParam->XRealPos; } else if(cChuanLTStep == 2) { cMotorStep = 20; cChuanLTStep = 3; } else if(cChuanLTStep == 3) { if(SystemParam->XRealPos >= (save_xm_dist + SystemParam->PutInLength + SystemParam->HighSpeedLength)) { cChuanLTStep = 4; SM_OUT = 0; JLT_OUT = 0; } else if(SLT_OUT) { if(SystemParam->XRealPos >= (save_xm_dist + SystemParam->PutInLength + SystemParam->HighSpeedLength - SystemParam->UnLockDist)) SLT_OUT = 0; } } else if(cChuanLTStep == 4) { if(cMotorStep == 0)cChuanLTStep = 5; } else if(cChuanLTStep == 5) { cChuanLTDelay = SystemParam->FZDelay * 10; cChuanLTStep = 6; } else if((cChuanLTStep == 6) && (cChuanLTDelay == 0)) { cMotorStep = 30; cChuanLTStep = 7; } else if(cChuanLTStep == 7) { if(cMotorStep == 0)cChuanLTStep = 8; } else if(cChuanLTStep == 8) { cChuanLTDelay = XIA_MO_DW_ERROR_TIME; cChuanLTStep = 9; } else if(cChuanLTStep == 9) { if(SM_ORIGIN_IN) { cChuanLTStep = 10; } else if(cChuanLTDelay == 0) { SetAlarmYJ(17); } } else if(cChuanLTStep == 10) { cChuanLTStep = 0; } } //切断动作 void QueDuan_NewStr_XiaQue(void) { static long save_jiazi_dist; if((cXiaQieStep == 1) && (bWorkMode || bNext)) { cXiaQieStep = 2; cXiaQieDelay = XIA_QIE_ERROR_TIME; XQ_OUT = 1; } else if(cXiaQieStep == 2) { if(XQ_ARRIVE_IN) { cXiaQieStep = 3; } else if(cXiaQieDelay == 0) { SetAlarmYJ(14); } } else if((cXiaQieStep == 3) && (bWorkMode || bNext)) { SQ_OUT = 1; cXiaQieDelay = SystemParam->CutBackDelay * 10; cXiaQieStep = 4; } else if((cXiaQieStep == 4) && (cXiaQieDelay == 0) && (bWorkMode || bNext)) { SQ_OUT = 0; XQ_OUT = 0; cXiaQieDelay = XIA_QIE_ERROR_TIME; cXiaQieStep = 5; } else if(cXiaQieStep == 5) { if(SQ_ORIGIN_IN && XQ_ORIGIN_IN) { if(bRunning) cXiaQieStep = 6; else cXiaQieStep = 0; } else if(cXiaQieDelay == 0) { if(!SQ_ORIGIN_IN) SetAlarmYJ(19); else if(!XQ_ORIGIN_IN)SetAlarmYJ(18); } } else if(cXiaQieStep == 6) { cMotorStep = 40; save_jiazi_dist = SystemParam->XRealPos; cXiaQieStep = 7; } else if(cXiaQieStep == 7) { if(SystemParam->XRealPos >= (save_jiazi_dist + SystemParam->SJZdist)) { JZ_OUT = 0; } if(cMotorStep == 0) { cXiaQieStep = 8; } } else if(cXiaQieStep == 8) { cXiaQieStep = 0; } } //装拉头动作 void ZhuangLiao_CT_QD_GL(void) { if(cZhuangLiaoStep == 1) { cZhuangLiaoStep = 2; } else if((cZhuangLiaoStep == 2) && (bWorkMode || bNext)) { JLT_OUT = 1; cZhuangLiaoDelay = ZLT_ERROR_TIME; cZhuangLiaoStep = 3; } else if(cZhuangLiaoStep == 3) { if(JLT_IN) { cZhuangLiaoStep = 4; } else if(cZhuangLiaoDelay == 0) { SetAlarmYJ(26); } } else if((cZhuangLiaoStep == 4) && (bWorkMode || bNext)) { GL_OUT = 0; cZhuangLiaoStep = 5; } else if((cZhuangLiaoStep == 5)) { cZhuangLiaoDelay = ZLT_ERROR_TIME; cZhuangLiaoStep = 6; } else if(cZhuangLiaoStep == 6) { if(GL_ORIGIN_IN) { cZhuangLiaoStep = 7; } else if(cZhuangLiaoDelay == 0) { SetAlarmYJ(21); } } else if((cZhuangLiaoStep == 7) && (bWorkMode || bNext)) { SM_OUT = 1; cZhuangLiaoDelay = ZLT_ERROR_TIME; cZhuangLiaoStep = 8; } else if((cZhuangLiaoStep == 8) && (bWorkMode || bNext)) { if(SM_ARRIVE_IN) { cZhuangLiaoStep = 9; cZhuangLiaoDelay = SystemParam->CZDelayCheck * 10; } else if(cZhuangLiaoDelay == 0) { SetAlarmYJ(13); } } else if((cZhuangLiaoStep == 9) && (cZhuangLiaoDelay == 0) && (bWorkMode || bNext)) { if(LATOU_CHUZHEN_IN) { if(SystemParam->LockZipperTime) { cZhuangLiaoDelay = SystemParam->LockZipperTime*10; SLT_OUT = 1; cZhuangLiaoStep = 20; } else { cZhuangLiaoStep = 0; ZhuangLiaoOkFlg = 1; } TryCnt = 0; } else { TryCnt++; if(TryCnt > 4) { SetAlarmYJ(27); } else { cZhuangLiaoStep = 10; } } } else if((cZhuangLiaoStep == 10) && (bWorkMode || bNext)) //装拉头失败重复装几次拉头 { SM_OUT = 0; JLT_OUT = 0; cZhuangLiaoDelay = XIA_MO_DW_ERROR_TIME; cZhuangLiaoStep = 11; } else if(cZhuangLiaoStep == 11) { if(SM_ORIGIN_IN) { cZhuangLiaoStep = 12; } else if(cZhuangLiaoDelay == 0) { SetAlarmYJ(17); } } else if(cZhuangLiaoStep == 12) { cGeiLiaoStep = 1; cZhuangLiaoStep = 13; } else if(cZhuangLiaoStep == 13) { if(cGeiLiaoStep == 0) { cZhuangLiaoStep = 14; } } else if(cZhuangLiaoStep == 14) { cZhuangLiaoStep = 1; } else if((cZhuangLiaoStep == 20) && (cZhuangLiaoDelay == 0)) { cZhuangLiaoStep = 0; ZhuangLiaoOkFlg = 1; } } //给料动作 void GeiLiao_CT_QD_GL(void) { if(cGeiLiaoStep == 1) { if(FirstGeiLiaoFlg == 0) { cGeiLiaoStep = 6; FirstGeiLiaoFlg = 1; } else { cGeiLiaoStep = 2; } } else if(cGeiLiaoStep == 2) { SL_OUT = 1; cGeiLiaoStep = 3; cGeiLiaoDelay = SONG_LIAO_ERROR_TIME; } else if(cGeiLiaoStep == 3) { if(SL_ARRIVE_IN) { cGeiLiaoStep = 4; } else if(cGeiLiaoDelay == 0) { SetAlarmYJ(20); } } else if((cGeiLiaoStep == 4) && (bWorkMode || bNext)) { cGeiLiaoDelay = SONG_LIAO_ERROR_TIME; SL_OUT = 0; cGeiLiaoStep = 6; } else if(cGeiLiaoStep == 5) { /* if(SL_ORIGIN_IN) { cGeiLiaoStep = 6; } else if(cGeiLiaoDelay == 0) { SetAlarmYJ(21); } */ } else if((cGeiLiaoStep == 6) && (bWorkMode || bNext)) { cGeiLiaoDelay = SONG_LIAO_ERROR_TIME; GL_OUT = 1; cGeiLiaoStep = 7; } else if(cGeiLiaoStep == 7) { if(GL_ARRIVE_IN) { cGeiLiaoStep = 10; } else if(cGeiLiaoDelay == 0) { SetAlarmYJ(22); } } else if((cGeiLiaoStep == 8) && (bWorkMode || bNext)) { cGeiLiaoDelay = SONG_LIAO_ERROR_TIME; GL_OUT = 0; cGeiLiaoStep = 9; } else if(cGeiLiaoStep == 9) { if(GL_ORIGIN_IN) { cGeiLiaoStep = 10; } else if(cGeiLiaoDelay == 0) { SetAlarmYJ(23); } } else if(cGeiLiaoStep == 10) { cGeiLiaoStep = 0; } } //手动动作 void ManualActionYJ(void) { static unsigned char manual_flag = 0; // TestData->DispLay[0] = tXAxisStepper.cCurSpeed; // TestData->DispLay[1] = tXAxisStepper.cAutoControlState; if(!bRunning) { if(bQianDianDW) { bQianDianDW = 0; if(cQianDianDWStep == 0)cQianDianDWStep = 1; } if(bGeiLT) { bGeiLT = 0; if(cGeiLiaoStep == 0)cGeiLiaoStep = 1; } if(bZhuangLiao) { bZhuangLiao = 0; if(cZhuangLiaoStep == 0)cZhuangLiaoStep = 1; } if(bChuanLT) { bChuanLT = 0; if(cChuanLTStep == 0)cChuanLTStep = 1; } if(bQieDuan) { bQieDuan = 0; if(cXiaQieStep == 0)cXiaQieStep = 1; } if(bClearTotal) //切断计数清零 { bClearTotal = 0; SystemParam->Total = 0; Save32BitDate(0,8); } if(bClerNowTotal) { bClerNowTotal = 0; SystemParam->NowTotal = 0; Save32BitDate(0,10); } if(M48) { if(cMotorStep == 0)cMotorStep = 60; } else { if((cMotorStep == 62) && !M49) { MV_Dec_Stop(X_AXIS); } } if(M49) { if(cMotorStep == 0)cMotorStep = 80; } else { if((cMotorStep == 82) && !M48) { MV_Dec_Stop(X_AXIS); } } if (M50) { M50 = 0; Y00 = ~Y00; } if (M51) { M51 = 0; Y01 = ~Y01; } if (M52) { M52 = 0; if(Y02) { Y02 = 0; } else if(GL_ORIGIN_IN) { Y02 = 1; } else { SetAlarmYJ(23); } } if (M53) { Y03 = ~Y03; M53 = 0; } if (M54) { Y04 = ~Y04; M54 = 0; } if (M55) { M55 = 0; Y05 = ~Y05; } if (M56) { M56 = 0; if(Y06) { Y06 = 0; } else if(SM_ORIGIN_IN) { Y06 = 1; } else { SetAlarmYJ(17); } } if (M57) { M57 = 0; Y07 = ~Y07; } if (M58) { M58 = 0; Y10 = ~Y10; } if (M59) { M59 = 0; Y11 = ~Y11; } if (M60) { Y12 = ~Y12; M60 = 0; } if (M61) { Y13 = ~Y13; M61 = 0; } if (M62) { M62 = 0; Y14 = ~Y14; } if (M63) { M63 = 0; Y15 = ~Y15; } if (M64) { M64 = 0; Y16 = ~Y16; } if (M65) { M65 = 0; Y17 = ~Y17; } } } #endif