1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066 |
- #include "global.h"
- #if 0//XIN_YE_MACHINE
- void ChuanTou_AlarmProtect(void);
- void ChuanTou_ManualAction(void);
- void ChuanTou_AutoAction(void);
- void ChuanTou_StepCheckStart(void);
- void ChuanTou_Motor(void);
- void ChuanTou_SongLiaoAction(void);
- void ChuanTou_ZhuangLiaoStep(void);
- void ChuanTou_CLT_Step(void);
- void CT_ZhenDongCTR(unsigned char flag);
- void CT_HeMo(void);
- static unsigned char cOneTimes,cJiaLian,bMotorUPStopCT,cLaTuoNum,CT_bRunning;
- static unsigned long cAutoStopTime;
- static unsigned long GuZhangInputTime,cDinWeiTime,CT_MotorDelay,cTuiPianTime,cWorkPulseNum,cPulseStepADD,cPulseStepDEC;
- //清警告
- void Clr_Warning(unsigned char W_Page)
- {
- user_datas[75] = W_Page;
- user_datas[100] = 0; //检查过链接近开关或没有拉链
- user_datas[101] = 0;
- }
- void ChuanTou_InitAction(void)
- {
- XGearRatio =1;
- CalFreqTab_X_Free(14);
- SetEn(X_AXIS,0);
- Clr_Warning(1);
- MV_Set_Command_Pos_CPU(X_AXIS, 0); //实时位置清零
- if(user_datas[15] < 35)user_datas[15] = 35;
- }
- void ChuanTou_Action(void)
- {
- if(user_datas[100])
- {
- if(user_datas[24] == 1)
- Y06 = 1;
- if(user_datas[35] == 0)
- Y07 = 0;
- if(user_datas[37] == 0)
- Y10 = 0;
- }
- else if(CT_bRunning)
- {
- if(user_datas[24] == 1)
- Y06 = 0;
- if(user_datas[35] == 0)
- Y07 = 1;
- if(user_datas[37] == 0)
- Y10 = 0;
- }
- else
- {
- if(user_datas[24] == 1)
- Y06 = 0;
- if(user_datas[35] == 0)
- Y07 = 0;
- if(user_datas[37] == 0)
- Y10 = 1;
- }
- CT_HeMo();
- CT_ZhenDongCTR(0);
- ChuanTou_ManualAction();
- ChuanTou_Motor();
- ChuanTou_StepCheckStart();
- ChuanTou_AutoAction();
- }
- //手动动作
- void ChuanTou_ManualAction(void)
- {
- if(M14) //产量清零
- {
- M14 = 0;
- ClrcToTal(76);
- }
- if(X15) //空位时的自动停机时间
- {
- if(user_datas[39] == 0)
- cAutoStopTime = dwTickCount + 3500;
- else
- cAutoStopTime = dwTickCount + (unsigned long) 100 * user_datas[39];
- }
-
- if((CT_bRunning == 1) && X20)
- {
- if(user_datas[100] == 0)user_datas[100] = 12;
- M13 = 1;
- }
- //手动
- if ((CT_bRunning == 0) && !X01)
- {
- //起动
- if ((X00_UP || M09 || M11 || (X20_UP && (user_datas[64] != 3)) || (X00 && X06_UP)) && (dwTickCount >= cDelayTime5) && (CT_bRunning == 0))
- {
- //过链感应 送料后 送料前 故障输入
- if (X15 && X10 && !X11 && !X04 && !X20)
- {
- //第一条认为给料已完成
- SetEn(X_AXIS,1); //步进电机松
- CT_bRunning = 1;
- cOneTimes = 0;
- M03 = 0;
- M16 = 0;
- M17 = 0;
- M18 = 0;
- M19 = 0;
- M20 = 0;
- M21 = 0;
- M22 = 0;
- M23 = 0;
- M24 = 0;
- M25 = 0;
- Clr_Warning(1);
- if(M11)
- { //单次动作
- cOneTimes = 1;
- M12 = 1;
- }
- else //自动动作
- {
- M10 = 1;
- }
- cStepMByte1 = 0;
- cStepMByte2 = 10;
- //给料已经完成
- cStepMByte4 = 0;
- cAutoStopTime = dwTickCount + 12000;
- CT_bStop = 0;
- if(user_datas[24] == 0)Y06 = 1; //夹紧(勾针旁)
-
- if((!X13) || (user_datas[23] == 0)) Y04 = 1; //护链
- //延时分带
- cStepMByte = 4;
- cDelayTime5 = dwTickCount + 60;
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[13]*10 + 60;
- CT_ZhenDongCTR(1);
- }
- else
- {
- if(X20)
- {
- M19 = 1;
- user_datas[100] = 12;
- }
- else if (X00_UP || M09 || M11 || (X00 && X06_UP))
- {
- //启动条件不满足报警
- M19 = 1;
- user_datas[100] = 30;
- }
- }
- M09 = 0;
- M11 = 0;
- }
-
- //手动分带(半自动)
- if(X02_UP)
- {
- if (X10 && !X11 && !Y02 && !M30) //给料不能有输出
- {
- cStepMByte4 = 1; //合模变为单独动作
- }
- else
- { //条件不满足警告
- M17 = 1;
- user_datas[100] = 32;
- }
- }
- else if(X02_DW) //半自动放开
- {
- if(user_datas[24] == 0) Y06 = 0; //夹紧
- Y04 = 0; //护链
- Y01 = 0; //下模
- Y00 = 0; //分带
- cStepMByte4 = 0;
- }
- //手动给料
- if(M00)
- {
- M00 = 0;
- if(Y02)
- {
- Y02 = 0;
- M30 = 0;
- if(user_datas[37] == 1)Y10 = 0;
- }
- else if(!Y01 && X07)
- {
- if(user_datas[37] == 0)Y02 = 1;
- else
- {
- Y10 = 1;
- M30 = 1;
- cDelayTime9 = dwTickCount + (unsigned long)user_datas[38] + 20;
- }
- }
- else //条件不满足警告
- {
- M16 = 1;
- user_datas[100] = 31;
- }
- }
- if(M30 && (dwTickCount >= cDelayTime9))
- {
- Y02 = 1;
- M30 = 0;
- }
- //手动拼链
- if(M01)
- {
- M01 = 0;
- if(Y04)
- Y04 = 0;
- else
- Y04 = 1;
- }
- //手动分带和下模动作
- if(M04)
- {
- M04 = 0;
- Y00 = ~Y00; //分带输出
-
- //夹牙
- if(!Y00) cStepMByte4 = 0;
- }
- if(M06)
- {
- M06 = 0;
- if (Y01)
- {
- Y01 = 0;
- cStepMByte4 = 0;
- }
- // 给料后限位 前限位
- else if (X10 && !X11 && !(Y02 && !M30)) //给料不能有输出
- {
- Y01 = 1;
- }
- else
- { //条件不满足警告
- M17 = 1;
- user_datas[100] = 32;
- }
- }
- //
- if(M07)
- {
- M07 = 0;
- if(cStepMByte4 != 0)
- {
- if(user_datas[24] == 0)Y06 = 0; //夹紧
- Y04 = 0; //护链
- Y01 = 0; //下模
- Y00 = 0; //分带
- cStepMByte4 = 0;
- }
- else
- cStepMByte4 = 1;
- }
- if(!X04)GuZhangInputTime = dwTickCount + (unsigned long)120 * 10;
- //顶针 故障开关
- if (X06 || (X04 && (dwTickCount >= GuZhangInputTime)))
- {
- Y03 = 1; //勾针
- }
- //过链
- else if (X15_UP || M02)
- {
- if(M02)
- {
- Y03 = ~Y03;
- M02 = 0;
- }
- else
- {
- Y03 = 0;
- cJiaLian = 1;
- }
- }
- else if(X15_DW)
- {
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[17];
- }
- if(cJiaLian && dwTickCount >= cDelayTime1)
- {
- cJiaLian = 0;
- if(user_datas[24] == 0)Y06 = 1; //夹紧
- }
- //手动拖带
- if (M08 || (X12_UP && (user_datas[22] == 0)))
- { // 勾针选择
- M08 = 0;
- if((!X_DRV) && !Y00 && !Y01)
- {
- Y03 = 1;
- cJiaLian = 0;
- Y04 = 0;
- if(user_datas[24] == 0)Y06 = 0; //夹链电磁阀(勾针旁) //夹紧
- CT_MotorStep = 1;
- if(!X15)
- cAutoStopTime = dwTickCount + 3500;
- }
- }
- if (X15_DW)
- {
- cDelayTime3 = dwTickCount + 2;
- }
- }
- }
- void ChuanTou_AutoAction(void)
- {
- static long save_dist;
- long dist_buff;
-
- if (CT_bRunning)
- { //
- if(user_datas[33] == 1)
- {
- if(X16) //前台机器卡带(贴布机)
- {
- bMotorUPStopCT = 1;
- }
- if(X21) //过链杆下限位
- {
- bMotorUPStopCT = 0;
- }
- }
- else
- bMotorUPStopCT = 0;
-
- switch (cStepMByte)
- {
- case 2: //过链检测
- if((user_datas[33] != 1) && (user_datas[35] == 1))
- {
-
- }
- //判断过链是不是真的松开
- else if(!X15 )//&& ((user_datas[19] <= 300))) //?
- {
- CT_MotorDelay = dwTickCount + 14000;
- CT_MotorStep = 3;
-
- cStepMByte = 3;
- Y04 = 0;
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[17];
- }
- else
- {
- if(user_datas[30] > 80)
- {
- if((save_dist - dwRealPos) > (user_datas[30] * 20))
- {
- M13 = 1;
- CT_bRunning = 0;
- AxisEgmStop(X_AXIS);
- }
- }
- }
- break;
- case 3:
- // 勾针选择
- if(dwTickCount >= cDelayTime1)
- {
- if(user_datas[24] == 0)Y06 = 1; //夹链电磁阀(勾针旁)
- }
-
- if (CT_MotorStep == 0)
- {
- if(user_datas[24] == 0)Y06 = 1; //夹牙
- cStepMByte = 4;
- if (user_datas[21] == 1)Y03 = 0; //勾针
- if ((X02 && (user_datas[20] == BoDong))|| (cOneTimes != 0))
- { //单条停止
- cStepMByte = 3;
- cAutoStopTime = dwTickCount + 250;
- if ((cStepMByte2 == 10))
- {
- cDelayTime8 = dwTickCount + (unsigned long)30 * 10; //延时松电机 //300ms
- cStepMByte = 0;
- CT_bRunning = 0;
- CT_bStop = 0;
- cOneTimes = 0;
- M10 = 0;
- M12 = 0;
- CT_ZhenDongCTR(1);
- }
- }
- else
- {
- if(user_datas[24] == 0)Y06 = 1; //夹牙
- if((!X13) || (user_datas[23] == 0))
- { //护链选择
- cStepMByte3 = 0;
- Y04 = 1; //护链输出
- //延时分带
- if (user_datas[22] == 0) //不用磁感
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[13]*10 + 60;
- else
- cDelayTime1 = dwTickCount;
- }
- else //不用护带
- cDelayTime1 = dwTickCount;
- }
- }
- break;
- case 4: //在过链 不用护链或不用磁感 延时分带 给料
- if (X15 && ((( (user_datas[22] == 0)) && (dwTickCount >= cDelayTime1)) || (X12&& (user_datas[22] == 1))) && !Y02 && !X11 && (cStepMByte2 == 10) && !bMotorUPStopCT)
- {
- cStepMByte = 5;
- Y00 = 1; //分带输出
- cDelayTime1 = dwTickCount + (unsigned long)2000; //给料到位的最长时间 }
- }
- else if(X01 || M13)
- {
- if(cStepMByte2 == 10)
- {
- cDelayTime8 = dwTickCount + (unsigned long)30 * 10; //延时松电机 //300ms
- cStepMByte = 0;
- CT_bRunning = 0;
- CT_bStop = 0;
- cOneTimes = 0;
- M10 = 0;
- M12 = 0;
- CT_ZhenDongCTR(1);
- }
- }
- break;
- //判断分带到位
- case 5: //分带到位 给料已给完成 送料前 送料后
- if(X05)
- {
- if ((cStepMByte2 == 10) && !X11 && X10 && !Y02)
- {
- cStepMByte = 6;
- cStepMByte2 = 0;
- cDelayTime1 = dwTickCount + (unsigned long)5; //25ms
- }
- }
- else if (dwTickCount >= cDelayTime1) //加上分带不到位警告代码
- {
- CT_ZhenDongCTR(1);
- CT_bRunning = 0;
- M21 = 1;
- M10 = 0;
- M12 = 0;
- user_datas[100] = 5;
- }
- break;
- case 6:
- if (dwTickCount >= cDelayTime1)
- {
- cStepMByte = 7;
- Y01 = 1; //下模输出
- cDelayTime1 = dwTickCount + (unsigned long)600; //2.5s
- }
- break;
- //下模气缸上到位
- case 7:
- if (!X07) //下模感应
- {
- if(X06) //送料到
- {
- cStepMByte = 8;
- //延时退勾针
- cDelayTime1 = dwTickCount + (unsigned long)2; //50ms
- if(user_datas[24] == 0)Y06 = 1; //夹紧(护牙)
- }
- else if ((dwTickCount >= cDelayTime1)) // 一定时间不到位就看作没料或卡住
- {
- if(++cLaTuoNum >= user_datas[34])
- {
- cLaTuoNum = 0;
- CT_ZhenDongCTR(1);
- CT_bRunning = 0;
- Y00 = 0; //下模下去
- Y01 = 0; //分带
- M22 = 1;
- M10 = 0;
- M12 = 0;
- M13 = 1;
- user_datas[100] = 6;
- }
- else
- {
- cStepMByte = 4;
- cStepMByte2 = 1;
- Y00 = 0; //分针下去
- Y01 = 0; //下模输出
- }
- }
- }
- break;
- // 延时松勾针
- case 8:
- if(dwTickCount >= cDelayTime1)
- {
- cLaTuoNum = 0;
- cStepMByte = 9;
- Y03 = 1; // 勾针退
- cDelayTime1 = dwTickCount + (unsigned long)user_datas[6] * 10; //70ms
- }
- break;
- // 延时穿入
- case 9:
- if(dwTickCount >= cDelayTime1)
- {
- cStepMByte = 2; //回到空位检测
- cWorkPulseNum = user_datas[61]; //昌盛的不用乘5
- MV_Set_Command_Pos_CPU(X_AXIS, 0); //实时位置可以清零
- dwRealPos = 0;
- save_dist = 0;
- cPulseStepADD = cWorkPulseNum * 2 / 3;
- cPulseStepDEC = cWorkPulseNum / 3;
- if (cPulseStepDEC >= 230) cPulseStepDEC = 230;
-
- MoveAction_Const_AccDec(X_AXIS,1,user_datas[32],user_datas[2],user_datas[1],user_datas[1]/2);
- cStepMByte1 = 1; //延时松分带 和 延时松下模动作
- if(user_datas[24] == 0) //夹牙退
- {
- cStepMByte5 = 1; //延时退护链
- cDelayTime4 = dwTickCount + (unsigned long)user_datas[7] * 3;
- }
- if(user_datas[14] == 0)
- {
- cStepMByte3 = 1; //延时退护链
- cDelayTime6 = dwTickCount + (unsigned long)user_datas[7] * 3;
- }
- cStepMByte2 = 0;
- AddToTal(76);
- CalProSP(78);
- }
- break;
- }
-
- //延时退夹链 退护链的脉冲数
- if(cStepMByte5 && (Y06) && (dwTickCount >= cDelayTime4))
- {
- cStepMByte5 = 0;
- Y06 = 0;
- }
- //延时退护链 退护链的脉冲数
- if(cStepMByte3 && (dwTickCount >= cDelayTime6))
- {
- cStepMByte3 = 0;
- Y04 = 0;
- }
- dist_buff = (dwRealPos);
- //延时松分带 和 延时松下模动作
- switch (cStepMByte1)
- {
- case 1:
- // if (user_datas[10] == 0)
- cStepMByte1 = 2;
- // else
- // cStepMByte1 = 10;
- break;
- //先退分带
- case 2:
-
- //退分带方式
- if((user_datas[31] == 1) && (user_datas[23] == 0))
- {
- if((dist_buff + user_datas[61]) >= (cWorkPulseNum+60))Y00 = 0;
- }
- if(CT_MotorStep == 0)
- {
- if(dwRealPos >= (cWorkPulseNum - cPulseStepDEC))
- {
- AxisChangeSpeed(X_AXIS,user_datas[0]);
- }
- }
- if((dwRealPos >= cWorkPulseNum) || (CT_MotorStep == 5))//穿入长度到或要定位条件下
- {
- //退分带
- Y00 = 0;
- cStepMByte1 = 3;
- if(user_datas[14] != 0)
- {
- cStepMByte3 = 1; //延时退护链
- cDelayTime6 = dwTickCount + (unsigned long)user_datas[18];
- }
- else
- {
- Y04 = 0;
- cStepMByte3 = 0;
- }
- }
- break;
- case 3:
- cDelayTime2 = dwTickCount + (unsigned long)user_datas[8];
- cStepMByte1 = 4;
- break;
- case 4:
- if ((dwTickCount >= cDelayTime2))
- {
- Y01 = 0;
- cStepMByte1 = 5;
-
- }
- break;
- case 5:
- if(!X06 && !Y00 && !Y01)
- {
- cStepMByte1 = 6;
- cDelayTime2 = dwTickCount + (unsigned long)25; //70ms
- if(user_datas[14] != 0)cDelayTime2 = dwTickCount + (unsigned long)user_datas[50]; //合链情况延时加速
- }
- break;
- case 6:
- if(dwTickCount >= cDelayTime2)
- {
- cStepMByte1 = 0;
- cStepMByte2 = 1;
- cDelayTime3 = dwTickCount + (unsigned long)4 * 10;
- //没有长度之前检测到下一条链
- if (CT_MotorStep == 0) //还没到空位前才能加速
- {
- AxisChangeSpeed(X_AXIS,user_datas[3]);
-
- /* if(user_datas[19] > 300)
- {
- cWorkPulseNum = (unsigned long)2000 * user_datas[19]/300;//1200(细分) * user_datas[49](拉链长度)/ (user_datas[31](皮带轮齿数) *50)
- user_datas[129] = cWorkPulseNum;
- if(cWorkPulseNum > cEncodePulse)
- {
- cWorkPulseNum -= cEncodePulse;
- cStepMByte1 = 7;
- cSPAdd_Correction = 0;
- // cSPAdd = 2;
- cStepMode = 4;
- cLowSpeadLimit = cStepSet - 3;//user_datas[4];
- cStepSet += 30; //最高速
- if(cStepSet >= 72)
- cStepSet = 72;
- ch = (unsigned long)(cStepSet - cStepNum)/2 + 2; //平均加速度
- ch = (unsigned long)5 * 30;//(cStepSet - cStepNum); //加减速长度
- if(cWorkPulseNum > (ch*2))
- {
- cPulseStepDEC = (unsigned long)ch + 50;
- }
- else
- {
- cPulseStepDEC = (unsigned long)cWorkPulseNum/2 +30;
- }
- }
- }*/
- }
- }
- break;
- /* case 7:
- if((cWorkPulseNum == 0) || (cStepMode == 2))
- {
- cStepMByte1 = 0;
- cLowSpeadLimit = user_datas[4];
- cSPAdd_Correction = 0;
- }
- break;*/
- //先退下模
- case 10:
- if ((dist_buff >= cWorkPulseNum) || (CT_MotorStep == 5))
- {
- //退下模
- Y01 = 0;
- cStepMByte1 = 11;
- cDelayTime2 = dwTickCount + (unsigned long)user_datas[8]; //70ms
- Y07 = 0; //退夹链
- if(user_datas[14] != 0)
- {
- cStepMByte3 = 1; //延时退护链
- cDelayTime6 = dwTickCount + (unsigned long)user_datas[18];
- }
- else
- {
- Y04 = 0; //退护链
- cStepMByte3 = 0;
- }
- cDelayTime3 = dwTickCount + (unsigned long)3 * 100; //没法开模
- }
- break;
- case 11:
- if((dwTickCount >= cDelayTime2) || !X06)
- {
- Y00 = 0; //退分带
- cStepMByte1 = 12;
- cDelayTime2 = dwTickCount + (unsigned long)250; //70ms
- }
- break;
- case 12:
- if (!X05 && !Y00 && !Y01)
- {
- cDelayTime2 = dwTickCount + (unsigned long)15;
- cStepMByte1 = 13;
- }
- break;
- case 13:
- if (dwTickCount >= cDelayTime2)
- {
- //没有长度之前检测到下一条链
- if (CT_MotorStep == 3)
- {
- AxisChangeSpeed(X_AXIS,user_datas[4]);
- }
- cStepMByte2 = 1; //给料启动
- cStepMByte1 = 0;
- }
- break;
-
- }
- //给料动作
- switch (cStepMByte2)
- {
- case 1:
- //分带感应 有料感应 下模感应 分带 下模
- if (!X05 && !X06 && X07 && !Y00 && !Y01)
- {
- cStepMByte2 = 2;
- cDelayTime3 = dwTickCount + (unsigned long)10 * (4 + user_datas[16]);
- if(user_datas[37] == 1)Y10 = 1;
- }
- break;
- case 2: //延时给料
- if ((dwTickCount >= cDelayTime3) && X07)
- {
- Y02 = 1; //给料输出
- cStepMByte2 = 3;
- //不知道加多少时候才够,只能定成1秒
- cDelayTime3 = dwTickCount + 2000;
- }
- break;
- case 3: //判断给料到位
- if(X11)
- {
- cStepMByte2 = 4;
- cDelayTime3 = dwTickCount + user_datas[9]; //给料到位延时返回
- }
- else if ((dwTickCount >= cDelayTime3) && X07)
- { //下模上升超时
- CT_ZhenDongCTR(1);
- CT_bRunning = 0;
- M20 = 1;
- M10 = 0;
- M12 = 0;
- user_datas[100] = 4;
- }
- break;
- case 4:
- if (dwTickCount >= cDelayTime3)
- {
- Y02 = 0; //给料关
- cStepMByte2 = 5;
- }
- break;
- case 5:
- if (!X11)
- {
- cStepMByte2 = 6;
- cDelayTime3 = dwTickCount + 30; //给料到位延时返回
- if(user_datas[37] == 1)Y10 = 0;
- }
- break;
- case 6:
- if (X10 && (dwTickCount >= cDelayTime3))
- {
- cStepMByte2 = 10;
- }
- break;
- }
- }
- }
- void ChuanTou_StepCheckStart(void)
- {
- //停止 故障输入
- if (X01 || X04 || M13 || (X00_DW && (user_datas[20] == BoDong) && (dwTickCount >= cDelayTime5)) || ((dwTickCount >= cAutoStopTime) && (!X15) && X_DRV))
- {
- M10 = 0;
- M12 = 0;
- if(X04)
- {
- M23 = 1;
- user_datas[100] = 7;
- }
- else if ((dwTickCount >= cAutoStopTime) && X_DRV && !X15)
- {
- M24 = 1;
- user_datas[100] = 8;
- }
- else if(X01)
- {
- M16 = 0;
- M17 = 0;
- M18 = 0;
- M19 = 0;
- M20 = 0;
- M21 = 0;
- M22 = 0;
- M23 = 0;
- M24 = 0;
- M25 = 0;
- Clr_Warning(1);
- if(X01_UP && !CT_bRunning)
- {
- Y03 = 1; //勾针
- }
- }
- if(CT_bRunning)CT_ZhenDongCTR(1);
- if(!M13 || !CT_bRunning)
- {
- AxisEgmStop(X_AXIS);
- cStepMByte = 0;
- cStepMByte1 = 0;
- cStepMByte2 = 0;
- cStepMByte3 = 0;
- cStepMByte4 = 0;
- CT_MotorStep = 0;
- if(user_datas[24] == 0)Y06 = 0; //夹链电磁阀(勾针旁)
-
- Y04 = 0; //护链电磁阀
- Y02 = 0; // 拉头定位电磁阀(给料)
- Y01 = 0; // 下模电磁阀
- Y00 = 0; // 分带电磁阀
- cDelayTime5 = dwTickCount + 60;
- if(user_datas[37] == 1)
- Y10 = 0;
- SetEn(X_AXIS,0);
-
- CT_bRunning = 0;
- }
- else
- {
- cOneTimes = 1;
- }
- M13 = 0;
- }
- }
- //电机动作
- void ChuanTou_Motor(void) //
- {
- static long back_buff,save_buff;
- static long check_buff;
-
- dwRealPos = MV_Get_Command_Pos_CPU(X_AXIS);
- user_datas[121] = dwRealPos;
- user_datas[122] = CT_MotorStep;
- switch(CT_MotorStep)
- {
- case 0:
- break;
- case 1:
- // if(GetEn(X_AXIS) == 0)
- {
- SetEn(X_AXIS,1);
- CT_MotorDelay = dwTickCount + 150;
- }
-
- CT_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= CT_MotorDelay)
- {
- MoveAction_Const_AccDec(X_AXIS,0,user_datas[3],user_datas[2],15,5);
-
- CT_MotorDelay = dwTickCount + 14000;
- CT_MotorStep = 3;
- }
- break;
- case 3:
- if(!X15)
- {
- AxisChangeSpeed(X_AXIS,user_datas[4]);
- CT_MotorDelay = dwTickCount + 3500;
- back_buff = dwRealPos;
- CT_MotorStep = 4;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- CT_MotorStep = 0;
- AxisEgmStop(X_AXIS);
- }
- break;
- case 4:
- if(((dwRealPos - back_buff) >= user_datas[5]) && CT_bRunning) //延时长度下勾针
- {
- if(user_datas[21] == 1)Y03 = 0;
- }
- if(X15_UP)
- {
- save_buff = dwRealPos;
- Y03 = 0;
- if(user_datas[24] == 0)Y06 = 1; //夹链电磁阀(勾针旁) //夹紧
- CT_MotorStep = 5;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- CT_MotorStep = 0;
- AxisEgmStop(X_AXIS);
- }
- break;
- case 5:
- if((dwRealPos-save_buff) >= user_datas[60])
- {
- AxisEgmStop(X_AXIS);
- if(!CT_bRunning)
- {
- CT_MotorStep = 6;
-
- CT_MotorDelay = dwTickCount + 2;
- }
- else
- CT_MotorStep = 0;
- }
- break;
- case 6:
- if(dwTickCount >= CT_MotorDelay) //延时松轴
- {
- // SetEn(X_AXIS,0);
- CT_MotorStep = 0;
- }
- break;
-
- }
- }
- //合模动作
- void CT_HeMo(void)
- {
- switch(cStepMByte4)
- {
- case 0:
- return;
- case 1:
- if(user_datas[24] == 0)Y06 = 1; ////夹紧
- if((!X13) || (user_datas[23] == 0)) Y04 = 1; //护链输出
- cDelayTime7 = dwTickCount + (unsigned long)user_datas[13]*10 + 60; //160ms
- cStepMByte4 = 2;
-
- if(user_datas[37] == 1)
- Y10 = 0;
- break;
- case 2: //护链输出后分带输出
- if (X10 && !X11 && (Y06 || (user_datas[24] == 1)))
- {
- //护链磁感 不用护链磁感时用延时
- if ((((X12 && (user_datas[22] == 1))) || ((user_datas[23] == 1) && (dwTickCount >= cDelayTime7)) ||
- // 护链磁感选择
- ((!X13 || (user_datas[23] == 0)) && (dwTickCount >= cDelayTime7) && (user_datas[22] == 0))) && !Y00 && !X05) //分带电磁阀 分带到位
- {
- Y00 = 1; //分带
- cDelayTime7 = dwTickCount + (unsigned long)10 * 10; //160ms
- }
- if(X05_UP && Y00)
- { //分带到位 分带电磁阀
- Y01 = 1; //下模输出
- }
- //有料感应 下模输出
- if (X06 && Y01)
- {
- Y03 = 1;
- }
- }
- break;
- }
- }
- //振盘控制
- void CT_ZhenDongCTR(unsigned char flag)
- {
- static unsigned long cStopZDTime, cTuiPianTime,cSongLiaoQianTime;
- static unsigned short cStartTimes;
- if(flag == 1)
- {
- if(!X14)
- {
- Y11 = 1;
- cStopZDTime = dwTickCount + (unsigned long)1000 * 120;
- }
- }
- else
- {
- //振动盘 振动检测 手动给料
- if(Y11)
- {
- if((X14_UP || ((user_datas[25] == 0) && !X14)) && !M15) // || (X03_DW))
- {
- cStopZDTime = dwTickCount + (unsigned long)1000 * user_datas[11];
- }
- else if (M15 || ((X14 || (!CT_bRunning && (user_datas[25] == 1))) && (dwTickCount >= cStopZDTime)))
- { // && (!X03))
- M15 = 0;
- Y11 = 0;
- cStartTimes = 0;
- }
- else if(X14_DW)
- {
- cStopZDTime = dwTickCount + (unsigned long)1000 * 40;
- }
- }
- else if ((!Y11) && (((cStartTimes >= user_datas[12]) && (!X14))|| M15))
- {
- M15 = 0;
- Y11 = 1;
- cStopZDTime = dwTickCount + (unsigned long)1000 * 40;
- if(X14)
- cStopZDTime = dwTickCount + (unsigned long)1000 * 4;
- cStartTimes = 0;
- }
- }
- // 送料前
- if (X11_UP && (dwTickCount >= cSongLiaoQianTime))
- {
- cStartTimes++;
- cSongLiaoQianTime = dwTickCount + 100;
- }
- if (X14) //拉头检测
- cStartTimes = 0;
- //推拉片动作(弹簧头)
- if(flag == 0)
- {
- if((user_datas[26] == 0) || M03)
- {
- if(Y11 && !X04 && (M03 || CT_bRunning))
- {
- if (dwTickCount >= cTuiPianTime)
- {
- cTuiPianTime = dwTickCount + (unsigned long)10 * user_datas[15];
- Y05 = ~Y05;
- }
- }
- else Y05 = 0;
- }
- else if(Y11 && !X04)
- Y05 = Y02;
- }
- }
- #endif
|