1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477 |
- #include "global.h"
- #if JIN_HONG_MACHINE ==1
- void SK_QueDuan_AlarmProtect(void);
- void SK_QueDuan_ManualAction(void);
- void SK_QueDuan_AutoAction(void);
- void SK_QueDuan_StepCheckStart(void);
- void SK_QueDuan_XiaQue(void);
- void SK_QueDuan_BingLian(void);
- void SK_QueDuan_Motor(void);
- void SK_QueDuan_YuanDianAction(void);
- void SK_QueDuan_ExtiActionX31(void);
- void SK_StopCode(void);
- void SK_Motor_SZ(unsigned char En);
- short *SK_length_buffer;
- short *SK_GYlength_buffer;
- void SK_QueDuan_ExtiActionX31(void)
- {
- SK_NcCheckLianFlg = 1;
- }
- void SK_QD_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(SKQD_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void SK_StopCode(void)
- {
- switch(SKQD_StopStep)
- {
- case 1:
- SKQD_StopStep=2;
- if(X_DRV)
- {
- AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS) * 2/3);
- AxisDecStop(X_AXIS);
- }
- break;
- case 2:
- if(!X_DRV || (dwXRealPos < 10))
- {
- SKQD_StopCodeDelay=dwTickCount+350;
- SKQD_StopStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= SKQD_StopCodeDelay)
- {
- // if(!cSTOPONE)
- {
- SKQD_StopStep=0;
- }
- // else
- // {
- // QD_SetAlarmCode(QD_PARAM_ANQUANMEN_ALARM);
- // BKQD_StopStep=0;
- // cSTOPONE=0;
- // }
- SK_Motor_SZ(SKQD_MOTOR_DIS); //电机松轴
- }
- break;
- }
- }
- //电机松轴
- void SK_Motor_SZ(unsigned char En)
- {
- if(En) //使能
- {
- if(SKQD_PARAM_MOTOR_SELECT)
- SKQD_SZ_OUT = 1; //伺服电机
- else
- SKQD_SZ_OUT = 0; //步进电机
- }
- else //松轴
- {
- if(SKQD_PARAM_MOTOR_SELECT)
- SKQD_SZ_OUT = 0; //伺服电机
- else
- SKQD_SZ_OUT = 1; //步进电机
- }
- }
- void SK_QueDuan_InitAction(void)
- {
- float length_buff,pulse_buff;
-
- length_buff = SKQD_PARAM_CYCLE_LENGTH;
- pulse_buff = SKQD_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
-
- SK_Motor_SZ(SKQD_MOTOR_DIS); //电机松轴
- SetAlarmCode(SKQD_ALARM_ADDR,0);
- SetDirReverse(X_AXIS, 0);
- axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,0);
- }
- void SK_QueDuan_Action(void)
- {
- user_datas[123] = 11;
-
- SK_QueDuan_AlarmProtect();
- SK_StopCode();
- SK_QueDuan_Motor();
- SK_QueDuan_XiaQue();
- SK_QueDuan_BingLian();
- SK_QueDuan_ManualAction();
- SK_QueDuan_AutoAction();
- SK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
-
- }
- //手动动作
- void SK_QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
- //下切
- if(SKQD_bXiaQie)
- {
- SKQD_bXiaQie = 0;
- if(SKQD_XiaQieStep == 0)
- {
- SKQD_XiaQieStep = 1;
- }
- }
- if(SKQD_bQianDianDW)
- {
- SKQD_bQianDianDW = 0;
- if(SKQD_MotorStep == 0 && !SKQD_XIAMO_IN &&!SKQD_SHANGMO_IN)
- {
- SKQD_MotorStep = 61;
- SK_cZipCnt = 0;
- SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
- SKQD_MotorDelay = dwTickCount + 150;
- }
- }
-
-
- if(SKQD_bSM)
- {
- SKQD_bSM = 0;
- if(SKQD_YAGOUZHEN_IN && !SKQD_SHANGMO_VAVLE)
- {
- SKQD_SHANGMO_VAVLE = 1;
- }
- else if (SKQD_SHANGMO_VAVLE)
- {
- SKQD_SHANGMO_VAVLE = 0;
- }
-
- }
-
- if(SKQD_bXM)
- {
-
- SKQD_bXM = 0;
- SKQD_XIAMO_VAVLE = ~SKQD_XIAMO_VAVLE;
- }
- if(SKQD_bBinLian)//合链
- {
- SKQD_bBinLian = 0;
- SKQD_BL_VAVLE = ~SKQD_BL_VAVLE;
- }
-
- if(SKQD_bGZ)
- {
- SKQD_bGZ = 0;
- if(SKQD_SHANGMO_ROIGIN_IN && SKQD_GZ_VAVLE)
- SKQD_GZ_VAVLE =0;
- else if (!SKQD_GZ_VAVLE)
- SKQD_GZ_VAVLE=1;
- }
-
- if(SKQD_bDGZ )
- {
- SKQD_bDGZ = 0;
- SKQD_DGZ_VAVLE = ~SKQD_DGZ_VAVLE;
-
- }
- if(SKQD_bChaoSheng)
- {
- SKQD_bChaoSheng = 0;
- SKQD_CSB_VAVLE = 1;
- SKQD_CSDelay = dwTickCount + SKQD_PARAM_CS_TIME + 5;
-
- }
-
- if(SKQD_XiaQieStep == 0)
- {
- if(dwTickCount >= SKQD_CSDelay)
- SKQD_CSB_VAVLE = 0;
- }
-
- if(SKQD_bTABLE)
- {
- SKQD_bTABLE = 0;
- SK_cTableCnt = 0;
- SKQD_TABLE_VAVLE = ~SKQD_TABLE_VAVLE;
- }
-
- if(SKQD_bJIAZI)
- {
- SKQD_bJIAZI = 0;
- SKQD_JIAZI_VAVLE = ~SKQD_JIAZI_VAVLE;
- }
-
- if(SKQD_bYADAI)
- {
- SKQD_bYADAI = 0;
- SKQD_YADAI_VAVLE = ~SKQD_YADAI_VAVLE;
- }
-
- //电机控制
- if(SKQD_bGoMotor && !SKQD_QIAN_LIMIT_IN)
- {
- SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
- SKQD_STOPINDelay = dwTickCount;
- if(!X_DRV)
- {
-
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_N,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,10,12);
- }
- }
-
- if(SKQD_bBackMotor) //后退限位已经取消
- {
- SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
- SKQD_STOPINDelay = dwTickCount;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_P,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,10,12);
- }
-
- if(!SKQD_bGoMotor && !SKQD_bBackMotor && (SKQD_MotorStep == 0) && (dwTickCount >= SKQD_STOPINDelay))
- {
- if(X_DRV) AxisEgmStop(X_AXIS);
- }
-
- if(SKQD_QIAN_LIMIT_IN && (SKQD_MotorStep == 0) && !SKQD_bBackMotor &&(SKQD_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
- }
- }
- void SK_QueDuan_AlarmProtect(void)
- {
- dwXRealPos = GetPos(X_AXIS);
- if(!bRunning)
- {
- ;
-
- }
- else
- {
- if(SKQD_PARAM_RUN_LENGTH < 5000)
- SKQD_PARAM_RUN_LENGTH= 5000;
- if((dwXRealPos > SKQD_PARAM_RUN_LENGTH) && (SK_NcGoLimitEn != 0)) //第一条手动时不保护
- {
- //AxisDecStop(X_AXIS); //AxisEgmStop(X_AXIS);
- SK_NcGoLimitEn = 0;
- bStop = 1;
- SKQD_StopStep = 1;
- SKQD_JIAZI_VAVLE = 0;
- SetAlarmCode(SKQD_ALARM_ADDR,SKQD_BACK_ALARM);
- }
- }
- }
- void SK_QueDuan_AutoAction(void)
- {
- if(bRunning)
- {//台面电机定时关掉
-
- if(dwTickCount >= SKQD_TBDelay)
- SKQD_TABLE_VAVLE = 0;
- switch(SKQD_AutoStep)
- {
- case 1:
- if(dwTickCount >= SKQD_AutoDelay)
- {
-
- if(SKQD_MotorStep == 0)
- {
- SKQD_AutoStep = 2;
- SKQD_MotorDelay = dwTickCount;
- SKQD_MotorStep = 61; //前点定位
- }
- SK_NcGoLimitEn = 0;
- }
- break;
- case 2:
- if(SKQD_MotorStep == 0)
- {
- SKQD_MotorStep = 30; //夹链后拉
- SKQD_AutoStep = 3;
- SK_NcGoLimitEn = 1;
- }
- break;
- case 3: //后面两步为延时反转步
- if((SKQD_MotorStep == 0) )//|| (SKQD_MotorStep == 392) || (SKQD_MotorStep == 393))
- {
- if(SKQD_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
- if(SKQD_XiaQieStep == 0)
- SKQD_XiaQieStep = 1;
- SKQD_AutoStep = 4;
- }
- }
- break;
- case 4:
-
- if((SKQD_XiaQieStep == 0) || (SKQD_XiaQieStep == 13))// && !QD_SHANG_MU_LIMIT_IN)
- {
- if(SKQD_MotorStep == 0)
- {
- SKQD_MotorStep = 40; //切完后退
- }
- SKQD_AutoStep = 5;
- }
-
- break;
- case 5:
- if(SKQD_MotorStep == 0)
- {
- SK_cZipCnt++;
- SKQD_PARAM_NOW_CNT++;
- SK_cTableCnt++;
- AddToTal(SKQD_TOTAL_ADDR);
- AddToTal(CT_WORKTOTAL_ADDR);
- CalProSP(SKQD_PROSPEED_ADDR);
- if(SK_cTableCnt >= SKQD_PARAM_TABLE_NUM)
- {
- SK_cTableCnt = 0;
- SKQD_TABLE_VAVLE = 1;
- SKQD_TBDelay = dwTickCount + SKQD_PARAM_TB_TIME;
- }
- if(SK_SingOneFlg)
- {
- bRunning = 0;
- SKQD_AutoStep = 0;
- SK_SingOneFlg = 0;
- }
- else
- {
- SKQD_AutoStep = 1;
-
- if((SKQD_PARAM_NOW_CNT >= SKQD_PARAM_ZHA_SHU) && (SKQD_PARAM_ZHA_SHU > 0))
- {
-
- SK_cTableCnt = 0;
- SKQD_TABLE_VAVLE = 1;
- SKQD_TBDelay = dwTickCount + SKQD_PARAM_TB_TIME;
-
- SKQD_AutoDelay = dwTickCount + SKQD_PARAM_ZS_STOP_TIME;
- SKQD_PARAM_NOW_CNT = 0;
- if(SKQD_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- SKQD_AutoStep = 0;
- SK_SingOneFlg = 0;
- SK_QD_SetAlarmCode(SKQD_TOTAL_ALARM);
- SKQD_TABLE_VAVLE = 0;
- }
- }
- else
- SKQD_AutoDelay = dwTickCount + SKQD_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- //合链
- void SK_QueDuan_BingLian(void)
- {
- static long bl_pos_buff;
-
- switch(SKQD_BinLianStep)
- {
- case 0:break;
- case 1:
- bl_pos_buff = dwXRealPos;
- SKQD_BinLianStep = 2;
- break;
- case 2:
- if((dwXRealPos - bl_pos_buff) >= SKQD_PARAM_DELAY_HL_LENGTH)
- {
- SKQD_BL_VAVLE = 1;
- SKQD_BinLianStep = 3;
- }
- break;
- case 3://有过链检测
- if((SKQD_GZ_VAVLE && (SKQD_PARAM_HL_DELAY_BACK == 0)) || ((dwXRealPos - bl_pos_buff) >= (SKQD_PARAM_ZIPPER_LENGTH - SKQD_PARAM_HL_DELAY_BACK)))
- {
- SKQD_BL_VAVLE = 0;
- SKQD_BinLianStep = 0;
- }
- break;
- case 10:
- bl_pos_buff = dwXRealPos;
- SKQD_BinLianStep = 11;
- break;
- case 11:
- if((dwXRealPos - bl_pos_buff) >= SKQD_PARAM_DELAY_HL_LENGTH)
- {
- SKQD_BL_VAVLE = 1;
- SKQD_BinLianStep = 12;
- }
- break;
- case 12://有过链检测
- if(SKQD_GUOLIAN_IN_DW)
- {
- SKQD_BinLianStep = 13;
- SKQD_BLDelay = dwTickCount + SKQD_PARAM_BL_DELAY_BACK;
- }
- break;
- case 13:
- if(dwTickCount >= SKQD_BLDelay )
- {
- SKQD_BL_VAVLE = 0;
- SKQD_BinLianStep = 0;
- }
- break;
- default:;
- }
-
- }
- void SK_QueDuan_StepCheckStart(void)
- {
- // 启动
- if((SKQD_START_IN_UP) || bStart || SKQD_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (SKQD_AutoStep == 0))
- {
- if(!SKQD_XIAMO_ROIGIN_IN) SK_QD_SetAlarmCode(SKQD_XM_DAOWEI);
- else if(!SKQD_SHANGMO_ROIGIN_IN) SK_QD_SetAlarmCode(SKQD_SM_ALARM);
- else
- {
- bRunning = 1;
- SKQD_AutoStep = 1;
- SK_SingOneFlg= 0;
- if(SKQD_bSingle)
- SK_SingOneFlg= 1;
- SK_cZipCnt = 0;
- SK_cTuiFangKuaiCnt = 0;
- SetAlarmCode(SKQD_ALARM_ADDR,0);
- SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
- SKQD_AutoDelay = dwTickCount + 150;
- SK_NcGoLimitEn = 0;
- SKQD_BL_VAVLE=0;
- SKQD_GZ_VAVLE =0;
- SKQD_DGZ_VAVLE =0;
- }
- }
- SKQD_bSingle = 0;
- }
- //停止
- if((SKQD_STOP_IN_UP && (dwTickCount >= SKQD_STOPINDelay)) || bStop)
- {
- bStop = 0;
- SKQD_STOPINDelay = dwTickCount + 100;
- if(bRunning)
- {
- SKQD_AutoDelay = dwTickCount;
- SKQD_MotorDelay = dwTickCount;
- SKQD_XiaQieDelay = dwTickCount;
- SK_SingOneFlg = 0;
- SKQD_BinLianStep = 0;
- if((SKQD_StopStep == 0) && X_DRV)
- SKQD_StopStep = 1;
- // AxisDecStop(X_AXIS);
- SetAlarmCode(SKQD_ALARM_ADDR,0);
- SKQD_SHANGMO_VAVLE =0;
- SKQD_XIAMO_VAVLE =0;
- SKQD_CSB_VAVLE =0;
- SKQD_TABLE_VAVLE=0;
- SKQD_BL_VAVLE=0;
- }
- else
- {
- SKQD_AutoDelay = dwTickCount;
- SKQD_MotorDelay = dwTickCount;
- SKQD_XiaQieDelay = dwTickCount;
-
- SK_SingOneFlg = 0;
- SKQD_BinLianStep = 0;
- SKQD_XiaQieStep = 0;
- SKQD_MotorStep = 0;
- SKQD_DGUOLIAN_VAVLE=0;
- SKQD_BL_VAVLE=0;
- SKQD_DGZ_VAVLE =0;
- SKQD_YADAI_VAVLE =0;
- SKQD_SHANGMO_VAVLE =0;
- if(SKQD_SHANGMO_ROIGIN_IN)
- SKQD_GZ_VAVLE =0;
- SKQD_XIAMO_VAVLE =0;
- SKQD_JIAZI_VAVLE =0;
- SKQD_CSB_VAVLE =0;
- SKQD_TABLE_VAVLE = 0;
-
- if((SKQD_StopStep == 0))
- {
- AxisEgmStop(X_AXIS);
- SK_Motor_SZ(SKQD_MOTOR_DIS); //电机松轴
- }
-
- SetAlarmCode(SKQD_ALARM_ADDR,0);
- }
- bRunning = 0;
- SKQD_XiaQieStep = 0;
- SKQD_AutoStep = 0;
- SKQD_MotorStep = 0;
- }
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- SKQD_XiaQieStep = 0;
- SKQD_AutoStep = 0;
- SKQD_MotorStep = 0;
- SKQD_XiaQieStep = 0;
- SKQD_MotorStep = 0;
- SKQD_BinLianStep = 0;
- SKQD_AutoDelay = dwTickCount;
- SKQD_MotorDelay = dwTickCount;
- SKQD_XiaQieDelay = dwTickCount;
- SKQD_KaDaiDelay = dwTickCount;
- SK_SingOneFlg = 0;
- bRunning = 0;
- if(X_DRV) //电机没有停止的话要减速停止
- SKQD_StopStep=1;
- // AxisEgmStop(X_AXIS);
- }
-
- }
- //记忆长度模式误差检测
- void SK_QueDuan_CheckLength(long zip_length)
- {
- static long start_dist;
- switch(SKQD_CheckLengthStep)
- {
- case 0:break;
- case 1:
- start_dist = dwXRealPos;
- SK_NdwSaveLength = 0;
- SKQD_CheckLengthStep = 2;
- break;
- case 2:
- if(SKQD_GUOLIAN_IN_DW){
- SK_NdwSaveLength = dwXRealPos - start_dist;
- }
- break;
- }
- }
- #if 1//!QD_KB_MODE //开口
- //开口切专用
- //30步开始后拉开始,分解4种工作模式
- //40步开始用切断后拉动作
- //60步开始为前方向,开闭口一样
- void SK_QueDuan_Motor(void)
- {
- static long length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff,bhgz_length_buff;
- static unsigned char cChangeSpeed;
- long pulse_buff;
- unsigned short ch,kk;
- user_datas[121] = dwXRealPos ;
- user_datas[122] = SKQD_AutoStep;
- user_datas[123] = SKQD_MotorStep;
- user_datas[124] = SKQD_StopStep ;
- user_datas[125] = SKQD_XiamuStep;//bhgz_length_buff;
- user_datas[126] = go_buff - dwXRealPos;
- switch(SKQD_MotorStep)
- {
- case 30:
- cChangeSpeed = 0;
- switch(SKQD_PARAM_BACK_MODE) //三种模式
- {
- case 0: //单数控模式
- SKQD_MotorStep = 310; //每种模式留20步
-
- break;
- case 1://单感应模式
- SKQD_MotorStep = 330; //每种模式留20步
-
- break;
- case 2: //先感应后数控模式+检测
- SKQD_MotorStep = 350; //每种模式留20步
- break;
-
- }
- back_buff = 0;
- gou_zhen_buff = 0;
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_DELAY_BACK;
- break;
- //310步到315步为数控模式
- case 310:
- SKQD_MotorStep = 311;
- if(SKQD_PARAM_BL_ENABLE)
- SKQD_BinLianStep = 1; //并链起动
- SKQD_DGUOLIAN_VAVLE=1; //顶过链杆
- break;
- case 311:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SK_length_buffer = &SKQD_PARAM_OFFSET_LENGTH;
- SK_DCC_TIME_BL=SKQD_PARAM_DCC + SKQD_PARAM_GO_HIGH_SPEED/500;
-
- AxisMovePosAccDecNotStop(X_AXIS,SKQD_PARAM_BACK_SPEED,SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer), SKQD_PARAM_START_SPEED,SKQD_PARAM_BACK_LOW_SPEED,
- SKQD_PARAM_ACC,SK_DCC_TIME_BL,(SKQD_PARAM_BACK_LOW_SPEED_LENGTH));
- SKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- SKQD_MotorStep = 312;
- }
- break;
- case 312:
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
- }
- //顶过链提前输出
- if (!SKQD_DGUOLIAN_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH + 350) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_DGUOLIAN_VAVLE=0;
- }
- //下模提前输出
- if (!SKQD_DGUOLIAN_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH + 100) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_DGUOLIAN_VAVLE=0;
-
- }
- //勾针提前输出
- if (!SKQD_GZ_VAVLE && ((dwXRealPos + SKQD_PARAM_XIAMO_LENTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_XIAMO_VAVLE=1;
- SKQD_DGUOLIAN_VAVLE=0;
-
- }
- if (!SKQD_GZ_VAVLE && ((dwXRealPos +SKQD_PARAM_GOUZHEN_LENGTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_GZ_VAVLE = 1;
- }
- if((dwXRealPos) >= (SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) - SKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- SKQD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- SKQD_MotorStep = 313;
- }//下面条件为无效代码
- else if((dwXRealPos >= (SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) + SKQD_PARAM_ERROR_LENGTH)) && SKQD_PARAM_ERROR_LENGTH)
- {
- SK_QD_SetAlarmCode(SKQD_GZ_ALARM);
- }
-
- break;
- case 313:
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
-
- }
- //顶过链提前关
- if (!SKQD_DGUOLIAN_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH + 350) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_DGUOLIAN_VAVLE=0; //顶
-
- }
- //下模提前输出
- if (!SKQD_GZ_VAVLE && ((dwXRealPos + SKQD_PARAM_XIAMO_LENTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_XIAMO_VAVLE=1;
- SKQD_DGUOLIAN_VAVLE=0;
-
- }
- //勾针提前输出
- if (!SKQD_GZ_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
- {
- SKQD_GZ_VAVLE = 1;
- SKQD_XIAMO_VAVLE=1;
- SKQD_MotorStep = 501;
-
- }
- if(SKQD_GZ_VAVLE)
- {
- SKQD_MotorStep = 501;
- }
- break;
- case 501:
- if(SKQD_GOUZHEN_IN) //勾针到位信号
- {
- // AxisEgmStop(X_AXIS);
- SKQD_YADAI_VAVLE = 1;
- SKQD_DGZ_VAVLE = 1;
- SKQD_BL_VAVLE = 0;
- if((((dwXRealPos-bhgz_length_buff)< (SKQD_PARAM_KWGZBJ_LENTH + SKQD_PARAM_KWGZBJ_ERROR_LENTH)) && ((dwXRealPos-bhgz_length_buff) > (SKQD_PARAM_KWGZBJ_LENTH - SKQD_PARAM_KWGZBJ_ERROR_LENTH))) | !SKQD_PARAM_KWGZBJ_LENTH)
- {
- if(SKQD_YAGOUZHEN_IN)
- {
- SKQD_MotorStep = 502;
- bhgz_length_buff = dwXRealPos + 30;
- }
- else if(!SKQD_YAGOUZHEN_IN && !X_DRV)
- {
- AxisEgmStop(X_AXIS);
- SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM);
- }
- }
- else
- {
- AxisEgmStop(X_AXIS);
- SK_QD_SetAlarmCode(SKQD_PARAM_KWGZ_ALARM);
- }
- }
- else if((dwXRealPos >= (SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) + SKQD_PARAM_ERROR_LENGTH)) && SKQD_PARAM_ERROR_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= SKQD_MotorDelay)
- SK_QD_SetAlarmCode(SKQD_GZ_ALARM);
- }
- break;
- case 502:
- if(dwXRealPos >= bhgz_length_buff) //??
- {
- AxisEgmStop(X_AXIS);
- SKQD_YADAI_VAVLE=1;
-
- SKQD_MotorStep = 314;
-
- }
- break;
- case 314:
- if(!X_DRV)
- {
- SKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- user_datas[127] = dwXRealPos;
- SKQD_BL_VAVLE=0;
- SKQD_MotorStep = 315;
-
- }
- break;
- case 315:
- if(SK_cZipCnt < 2) //第一条把误差到正负9MM
- {
- ch = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)-200;
- kk = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)+200;
- }
- else
- {
- if(SKQD_PARAM_BACK_MODE == 2)
- {
- ch = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) - 30 - SKQD_PARAM_ERROR_LENGTH;
- kk = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) - 30 + SKQD_PARAM_ERROR_LENGTH;
- }
- else
- {
- ch = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)-SKQD_PARAM_ERROR_LENGTH;
- kk = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)+SKQD_PARAM_ERROR_LENGTH;
- }
- }
- if(((dwXRealPos) < (ch)))
- {
-
- SetAlarmCode(SKQD_ALARM_ADDR,SKQD_LENGTH_SHORT_ALARM);
- if(dwTickCount >= SKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((dwXRealPos > kk))//(QD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(SKQD_ALARM_ADDR,SKQD_LENGTH_LONG_ALARM);
- if(dwTickCount >= SKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- SKQD_MotorStep = 0;//390; //延时反转步
- }
- break;
- //330步到349步单感应模式
- case 330:
- SKQD_MotorStep = 331;
- break;
- case 331:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_MotorStep = 332;
- if(SKQD_PARAM_BL_ENABLE)
- SKQD_BinLianStep = 10; //并链起动
-
- //因为每条都是过链感应,所以直接运行检测模式后拉速度
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_CHECK_BACK_HSPEED,SKQD_DIR_P,2000,2000,SKQD_PARAM_ACC,SKQD_PARAM_DCC);
- }
-
- break;
- case 332:
- if(SKQD_GUOLIAN_IN_UP) //重新到链上
- {
- AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS)/2);
- if(GetCurSpeed(X_AXIS) > (SKQD_PARAM_BACK_LOW_SPEED))
- AxisContinueMoveChangeSpeed(X_AXIS,GetCurSpeed(X_AXIS),SKQD_PARAM_BACK_LOW_SPEED,25,15);
- gou_zhen_buff = dwXRealPos;
- back_buff = dwXRealPos;
- SKQD_MotorStep = 333; //到检测定位
-
- user_datas[127] = dwXRealPos;
- SKQD_MotorDelay = dwTickCount + 3;
- }
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
-
- }
-
- break;
- case 333:
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
- }
- if(dwTickCount > SKQD_MotorDelay)
- {
- if(!SKQD_GUOLIAN_IN)
- {
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_GOUZHEN_DELAY;
- SKQD_XMDelay = dwTickCount + SKQD_PARAM_XIAMO_DELAY;
- AxisContinueMoveChangeSpeed(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED,SKQD_PARAM_BACK_LOW_SPEED/2,25,15);
- back_buff = dwXRealPos;
- SKQD_MotorStep = 334;
- }
- }
- else
- { //滤波时间内信号灭掉就重新检测
- if(!SKQD_GUOLIAN_IN)
- {
- SKQD_MotorStep = 332;
- }
- }
- break;
- case 334:
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
- }
- if(dwTickCount >= SKQD_XMDelay)
- {
- SKQD_XIAMO_VAVLE=1;
- }
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_XIAMO_VAVLE=1;
- SKQD_GZ_VAVLE=1;
- SKQD_MotorDelay = dwTickCount + 350;
- SKQD_MotorStep = 335;
- }
- break;
- case 335:
-
- //在空们都把延时清零
- if(SKQD_GUOLIAN_IN)
- {
- gou_zhen_buff = dwXRealPos;
- }
- if(dwXRealPos > (back_buff + SKQD_PARAM_LLGC_LENTH))
- {
- SK_QD_SetAlarmCode(SKQD_GUOCHANG_ALARM);
- }
-
- if(SKQD_GOUZHEN_IN)
- {
- SKQD_YADAI_VAVLE=1;
- SKQD_DGZ_VAVLE=1;
- SKQD_BL_VAVLE=0;
- if((((dwXRealPos-bhgz_length_buff)< (SKQD_PARAM_KWGZBJ_LENTH + SKQD_PARAM_KWGZBJ_ERROR_LENTH)) && ((dwXRealPos-bhgz_length_buff) > (SKQD_PARAM_KWGZBJ_LENTH - SKQD_PARAM_KWGZBJ_ERROR_LENTH))) | !SKQD_PARAM_KWGZBJ_LENTH)
- {
- if(SKQD_YAGOUZHEN_IN)
- {
- SKQD_MotorStep = 336;
- bhgz_length_buff = dwXRealPos + 30;
- }
- else if(dwTickCount >= SKQD_MotorDelay)
- {
- AxisEgmStop(X_AXIS);
- SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM);
- }
- }
- else
- {
- AxisEgmStop(X_AXIS);
- SK_QD_SetAlarmCode(SKQD_PARAM_KWGZ_ALARM);
- }
- }
- break;
- case 336:
- if(dwXRealPos >= bhgz_length_buff)
- AxisEgmStop(X_AXIS);
- if(!X_DRV)
- {
- SKQD_BL_VAVLE=0;
- SKQD_MotorStep = 337;
-
- }
-
- break;
- case 337:
- if(SK_cZipCnt == 1)
- {
- length_buff = dwXRealPos;
- SetData32bits(SKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff-30); //测量记录长度
- }
- else if(SK_cZipCnt > 1) //长度检测
- {
- if(SKQD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(dwXRealPos >= length_buff) //拉链变长,对比警告
- {
- if((dwXRealPos) > (length_buff+SKQD_PARAM_ERROR_LENGTH))
- SK_QD_SetAlarmCode(SKQD_LENGTH_LONG_ALARM);
- }
- else //拉链变短
- {
- if((dwXRealPos + SKQD_PARAM_ERROR_LENGTH) < (length_buff))
- SK_QD_SetAlarmCode(SKQD_LENGTH_SHORT_ALARM);
- }
- }
- }
- SKQD_MotorStep = 338;
- break;
-
- case 338:
- SKQD_MotorStep = 0;//390; //延时反转步
-
- break;
- //350步到369步先感应后数控模式
- case 350:
- back_buff = dwXRealPos;
- gou_zhen_buff = dwXRealPos;
- SKQD_MotorStep = 351;
- break;
- case 351:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_MotorStep = 352;
- //第一,二条都是过链感应,测量长度
- if(SK_cZipCnt < 2)
- {
- if(SKQD_PARAM_BL_ENABLE)
- SKQD_BinLianStep = 10; //并链起动
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_CHECK_BACK_HSPEED /2,SKQD_DIR_P,SKQD_PARAM_START_SPEED,2000,SKQD_PARAM_ACC,SKQD_PARAM_DCC);
- }
- else
- {
- if(SKQD_PARAM_BL_ENABLE)
- SKQD_BinLianStep = 1; //并链起动
- SKQD_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- SKQD_MotorStep = 310;
- }
- }
- break;
- case 352:
- //前两条都按最低速度工作
- if(SKQD_GUOLIAN_IN_UP) //重新到链上
- {
- AxisContinueMoveChangeSpeed(X_AXIS,SKQD_PARAM_CHECK_BACK_HSPEED/2,SKQD_PARAM_CHECK_BACK_HSPEED/4,25,15);
- gou_zhen_buff = dwXRealPos;
- back_buff = dwXRealPos;
- SKQD_MotorStep = 353; //到检测定位
- SKQD_MotorDelay = dwTickCount + 8;
- }
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
- }
- break;
- case 353:
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
- }
- //此步为前两条运行
- if(dwTickCount > SKQD_MotorDelay)
- {
- if(SKQD_GUOLIAN_IN_DW)
- {
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_GOUZHEN_DELAY;
- AxisContinueMoveChangeSpeed(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED,SKQD_PARAM_BACK_LOW_SPEED/2,25,15);
- back_buff = dwXRealPos;
- SKQD_MotorStep = 354;
- }
- }
- else
- {
- if(!SKQD_GUOLIAN_IN)
- {
- SKQD_MotorStep = 352;
- }
- }
- break;
- case 354:
- if(SKQD_GUOLIAN_IN_DW)
- {
- bhgz_length_buff = dwXRealPos;
-
- }
- if(dwTickCount >= SKQD_XMDelay)
- {
- SKQD_XIAMO_VAVLE=1;
- // SKQD_MotorDelay = dwTickCount + 50;
- }
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_XIAMO_VAVLE=1;
- SKQD_GZ_VAVLE=1;
- SKQD_MotorDelay = dwTickCount + 350;
- SKQD_MotorStep = 355;
- }
- break;
- case 355:
- if(dwXRealPos > back_buff + SKQD_PARAM_LLGC_LENTH )
- {
- SK_QD_SetAlarmCode(SKQD_GUOCHANG_ALARM);
- }
- //在空们都把延时清零
- if(SKQD_GOUZHEN_IN)
- {
- SKQD_BL_VAVLE=0;
- if((((dwXRealPos-bhgz_length_buff)< (SKQD_PARAM_KWGZBJ_LENTH + SKQD_PARAM_KWGZBJ_ERROR_LENTH)) && ((dwXRealPos-bhgz_length_buff) > (SKQD_PARAM_KWGZBJ_LENTH - SKQD_PARAM_KWGZBJ_ERROR_LENTH))) | !SKQD_PARAM_KWGZBJ_LENTH)
- {
- if(SKQD_YAGOUZHEN_IN)
- {
- SKQD_MotorStep = 356;
- bhgz_length_buff = dwXRealPos + 30;
- }
- else if(dwTickCount >= SKQD_MotorDelay)
- {
- AxisEgmStop(X_AXIS);
- SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM);
- }
- }
- else
- {
- AxisEgmStop(X_AXIS);
- SK_QD_SetAlarmCode(SKQD_PARAM_KWGZ_ALARM);
- }
- }
- break;
- case 356:
- if(dwXRealPos >= bhgz_length_buff)
- {
- AxisEgmStop(X_AXIS);
- }
- if(!X_DRV)
- {
- SKQD_YADAI_VAVLE=1;
- SKQD_DGZ_VAVLE=1;
- SKQD_BL_VAVLE=0;
- if(SK_cZipCnt == 1)
- {
- length_buff = dwXRealPos ;
- SetData32bits(SKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- SKQD_MotorStep = 357;
- }
- break;
- case 357:
- SKQD_MotorStep = 0;//390; //延时反转步
- break;
- //此两步为到位后反转步
- case 390:
- if(SKQD_YAGOUZHEN_IN && SKQD_GOUZHEN_IN)
- {
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_YD_FZ_DELAY;
- SKQD_MotorStep = 391;
- }
- break;
- case 391:
- if((dwTickCount >= SKQD_MotorDelay) || SKQD_SHANGMO_IN)
- {
- SKQD_DGZ_VAVLE=1;
- SKQD_MotorStep = 392;
- AxisMovePosAccDec(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED*2,-SKQD_PARAM_FZ_LENGTH,2000,1500,SKQD_PARAM_ACC,SKQD_PARAM_DCC,00);
- }
- break;
- case 392:
- if(!X_DRV)//dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_MotorStep = 0;
- }
- break;
- case 393:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- AxisMovePosAccDec(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED*3/2,-SKQD_PARAM_FZ_LENGTH,1000,1000,SKQD_PARAM_ACC,SKQD_PARAM_DCC,00);
- SKQD_MotorStep = 0;
- }
- break;
- case 40:
- if(SKQD_PARAM_SJZ_LENGTH == 0)
- {
- SKQD_JIAZI_VAVLE = 0;
- }
-
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_CUT_BACK_DELAY;
- SetDir(X_AXIS, SKQD_DIR_N);
- SKQD_MotorStep = 41;
- jz_buff = dwXRealPos;
- break;
- case 41:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- //夹子已经张开
- AxisMovePosAccDec(X_AXIS,SKQD_PARAM_CUT_BACK_SPEED,(SKQD_PARAM_SJZ_LENGTH+SKQD_PARAM_BACK_LENGTH),SKQD_PARAM_START_SPEED,SKQD_PARAM_START_SPEED,10,10,0);
- // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- SKQD_MotorStep = 42;
- }
- break;
- case 42:
- if(((SKQD_PARAM_SJZ_LENGTH) <= (dwXRealPos - jz_buff)))
- {
- SKQD_JIAZI_VAVLE = 0;
- }
- if(!X_DRV)
- {
- SKQD_JIAZI_VAVLE = 0;
- SKQD_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- SKQD_MotorStep = 0;
- SKQD_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- SKQD_BL_VAVLE = 0;
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_MotorStep = 62;
- }
- break;
- case 62:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- if(SKQD_QIAN_LIMIT_IN)
- {
- //前点亮的情况下先后退离开信号后再前进定位 ,10公分
- AxisMovePosAccDec(X_AXIS,3000,1000,2000,2000,10,10,30);
- SKQD_MotorDelay = dwTickCount + 300;
- }
- SKQD_MotorStep = 63;
- SKQD_JIAZI_VAVLE = 0;
- }
- break;
- case 63:
-
- if(!X_DRV && !SKQD_QIAN_LIMIT_IN && (dwTickCount >= SKQD_MotorDelay) &&
- ((dwXRealPos > 4000) || (!SKQD_SHANGMO_IN && !SKQD_XIAMO_IN && !SKQD_YAGOUZHEN_IN)))// && !QD_SHANG_MU_LIMIT_IN)
- {
- go_buff = dwXRealPos;
- SKQD_YADAI_VAVLE = 1;
- SKQD_DGZ_VAVLE = 0;
- if(SK_cZipCnt > 0)
- {
- if(dwXRealPos>(SKQD_PARAM_GO_LOW_SPEED_LENGTH))
- { //
- axis_set_parameter( X_AXIS,AXIS_ACCDEC_MODE,1);
- SK_DCC_TIME_BL = SKQD_PARAM_DCC + SKQD_PARAM_GO_HIGH_SPEED/500;
- AxisMovePosAccDecNotStop(X_AXIS,SKQD_PARAM_GO_HIGH_SPEED,-dwXRealPos,
- SKQD_PARAM_START_SPEED,SKQD_PARAM_GO_LOW_SPEED,SKQD_PARAM_ACC,SK_DCC_TIME_BL,
- SKQD_PARAM_GO_LOW_SPEED_LENGTH);
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_N,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,15,15);
- }
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_N,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,15,15);
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
- SKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- SKQD_MotorStep =64;
- }
- break;
- case 64:
- if(SK_cZipCnt > 0)
- {
- if(SKQD_QIAN_LIMIT_IN) //前点限位
- {
- if(SKQD_PARAM_GO_DW_LENGTH)
- {
- SetPos(X_AXIS, SKQD_PARAM_GO_DW_LENGTH);
- AxisMovePosAccDec(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,-SKQD_PARAM_GO_DW_LENGTH,1200,1000,5,5,00);
- }
- else
- AxisEgmStop(X_AXIS);
- SKQD_MotorStep = 66;
-
-
- }
- }
- else
- {
- if(SKQD_QIAN_LIMIT_IN) //前点限位
- {
- if(SKQD_PARAM_GO_DW_LENGTH)
- {
- SetPos(X_AXIS, SKQD_PARAM_GO_DW_LENGTH);
- AxisMovePosAccDec(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,-SKQD_PARAM_GO_DW_LENGTH,1200,1000,5,5,00);
- }
- else
- AxisEgmStop(X_AXIS);
- SKQD_MotorStep = 66;
- }
- }
- // if(dwTickCount >= SKQD_MotorDelay)
- // SK_QD_SetAlarmCode(SKQD_NO_ZIPPER_ALARM);
- break;
- case 66:
- if(!X_DRV || (dwXRealPos <= 0))
- {
- axis_set_parameter( X_AXIS,AXIS_ACCDEC_MODE,0);
- SetPos(X_AXIS, 0);
- SKQD_MotorDelay = dwTickCount;
- SKQD_MotorStep = 67;
- }
- break;
- case 67:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- if(bRunning)
- {
- SKQD_JIAZI_VAVLE = 1;
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_DELAY_BACK*3/5;
- }
- SKQD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_YADAI_VAVLE = 0;
- SKQD_MotorStep = 69;
- SKQD_MotorDelay = dwTickCount + SKQD_PARAM_DELAY_BACK*2/5;
- }
- break;
- case 69:
- if(dwTickCount >= SKQD_MotorDelay)
- {
- SKQD_MotorStep = 0;
- SKQD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- //超声方式下切,开口专用
- void SK_QueDuan_XiaQue(void)
- {
- switch(SKQD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
-
- if(bRunning)
- {
- SKQD_XiaQieStep = 5;
- SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- if(SKQD_SAFE_IN)
- {
- bStop = 1;
- SKQD_XIAMO_VAVLE = 0;
- }
- }
- else
- SKQD_XiaQieStep = 2;
- break;
- case 2:
- SKQD_XIAMO_VAVLE=1;
- SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- SKQD_XiaQieStep = 3;
- break;
- case 3:
- if(SKQD_XIAMO_IN)
- {
- SKQD_XiaQieDelay = dwTickCount + 0;
- SKQD_XiaQieStep = 4;
- }
- else if(dwTickCount >= SKQD_XiaQieDelay)
- {
- SK_QD_SetAlarmCode(SKQD_XM_DAOWEI);
- }
- break;
- case 4:
- SKQD_XiaQieDelay = dwTickCount + 3000;
- SKQD_GZ_VAVLE = 1;
- SK_cTuiFangKuaiCnt=0;
- SKQD_XiaQieStep = 5;
-
- break;
- case 5:
- if(SKQD_GOUZHEN_IN || bRunning)
- {
- SKQD_DGZ_VAVLE=1;
- SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- SKQD_XiaQieStep = 6;
- }
- else if(dwTickCount >= SKQD_XiaQieDelay)
- {
- SK_QD_SetAlarmCode(SKQD_GZ_ALARM);
- }
-
- break;
- case 6:
- if(SKQD_YAGOUZHEN_IN)
- {
- SKQD_XiaQieStep = 7;
- SKQD_XiaQieDelay = dwTickCount + 1000;
- }
- else if(dwTickCount >= SKQD_XiaQieDelay)
- {
- SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM); //压勾针到位
- }
- break;
- case 7:
- if(SKQD_GOUZHEN_IN || bRunning)
- {
- if(!bRunning)
- SKQD_XiaQieDelay = dwTickCount + 200;
- else
- {
- SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_CUT_DELAY;
- }
- if(!SKQD_QIAN_LIMIT_IN)
- SKQD_XiaQieStep = 8;
- else
- SK_QD_SetAlarmCode(SKQD_QIAN_LIMIT_ALARM);
- }
- break;
- case 8://上下模同时输出
- if(dwTickCount >= SKQD_XiaQieDelay)
- {
- SKQD_YADAI_VAVLE = 1;//压带
- SKQD_DGZ_VAVLE = 1;
- SKQD_SHANGMO_VAVLE = 1;
- SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- SKQD_XiaQieStep = 9;
- if(bRunning)
- SKQD_MotorStep = 390;
- }
- break;
- case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
- if(SKQD_SHANGMO_IN && SKQD_XIAMO_IN )
- {
- SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_DELAY_CS; //
- SKQD_XiaQieStep = 10;
- }
- else if(dwTickCount >= SKQD_XiaQieDelay)
- {
- if(!SKQD_SHANGMO_IN) SK_QD_SetAlarmCode(SKQD_SM_DAOWEI);
- else SK_QD_SetAlarmCode(SKQD_XM_DAOWEI);
- }
- break;
- case 10:
- if(dwTickCount >= SKQD_XiaQieDelay)
- {
-
- SKQD_CSB_VAVLE = 1;
- //
- SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_CS_TIME; //
- SKQD_XiaQieStep = 11;
-
- }
- break;
- case 11:
- if(dwTickCount >= SKQD_XiaQieDelay)
- {
- SKQD_CSB_VAVLE = 0;
- SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_CS_COLD_TIME; //
- SKQD_XiaQieStep = 12;
- SKQD_DGZ_VAVLE = 0;
- }
- break;
- case 12:
- if(dwTickCount >= SKQD_XiaQieDelay)
- {
- SKQD_SHANGMO_VAVLE = 0;
- SKQD_XIAMO_VAVLE = 0;
-
- SKQD_ErrorDelay = dwTickCount + VAVLE_ALARM_TIME;
- SKQD_XiaQieStep = 13;
- }//
- break;
- case 13:
- if((!SKQD_SHANGMO_IN))
- {
- SKQD_GZ_VAVLE = 0;
- SKQD_XiaQieDelay = dwTickCount + 7;//SKQD_PARAM_TDGZ_DELAY ;
- SKQD_XiaQieStep = 14;
- SKQD_ErrorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else if((dwTickCount >= SKQD_ErrorDelay) && !SKQD_SHANGMO_VAVLE)
- {
- SK_QD_SetAlarmCode(SKQD_SM_YUANWEI);
- }
- break;
- case 14:
- if(dwTickCount >= SKQD_XiaQieDelay)
- {
- if(SKQD_SHANGMO_ROIGIN_IN && !SKQD_XIAMO_IN && !SKQD_YAGOUZHEN_IN)
- {
- SKQD_DGZ_VAVLE = 0;
- SKQD_XiaQieStep = 0;
-
- }
- else if(dwTickCount >= SKQD_ErrorDelay)
- {
- SK_QD_SetAlarmCode(SKQD_XYAGOUZHEN_ALARM);
- }
- }
- break;
- }
- }
- #endif
|