123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994 |
- #include "global.h"
- #if TONG_YONG_MACHINE
- void TBJ_InitAction(void);
- void TBJ_Action(void);
- void CSTB_SongJiao_CS(void);
- void CSTB_Auto_Con_CS(void);
- void CSTB_HeMo_CS_CS(void);
- void Auto_Run(void);
- void Hand_Action(void);
- unsigned short cCountTime;
- unsigned char TBJ_cOneTimes,cTest1;
- unsigned long cErrorTime1,cErrorTime2,cErrorTime3;
- static long cSetEncode;
- static long cEncodePulse;
- unsigned char tbj_bRunning = 0,tbj_bStop;
- void TBJ_InitAction(void)
- {
- XGearRatio = 1;
- if(CJSelect == XinYe)//鑫业的Y06为夹胶
- {
- if(X17)Y06 = 1;
- }
- SetEn(X_AXIS,1); //步进电机松
- }
- void TBJ_Action(void)
- {
- static unsigned long c10msDelay = 0;
- //cStepMByte;
- user_datas[122] = cStepMByte1;
- user_datas[123] = cStepMByte2;
- user_datas[124] = cStepMByte3;
- user_datas[125] = cStepMByte4;
- // user_datas[126] = cStepMByte5;
- CSTB_HeMo_CS_CS(); //合模超声动作
- CSTB_SongJiao_CS(); //送胶动作
- CSTB_Auto_Con_CS(); //电机拖带动作
- if(dwTickCount >= c10msDelay)
- {
- c10msDelay = dwTickCount+10;
- if(cCountTime > 0)
- {
- cCountTime--;
- if(cCountTime == 0)Y07 = 0;
- }
- }
-
- if(M0015) //M15 故障确定
- {
- M0015 = 1;
- user_datas[100] = 0;
- user_datas[75] = 1;
- cDelayTime7 = dwTickCount + (unsigned long)1010;
- }
- if(M0001) //清产量
- {
- if(dwTickCount >= cDelayTime8)
- {
- M0001 = 0;
- ClrcToTal(76);
- }
- }
- else
- {
- cDelayTime8 = dwTickCount + (unsigned long)120*10;
- }
- //设定音波参数使能
- if(M0005)
- {
- if(dwTickCount >= cDelayTime9)
- {
- M0005 = 0;
- M0006 = 1;
- cDelayTime10 = dwTickCount + (unsigned long)5000;
- }
- }
- else
- cDelayTime9 = dwTickCount + (unsigned long)1300;
- if(M0006 && (dwTickCount >= cDelayTime10))
- {
- M0006 = 0;
- }
- if(CJSelect == ChangSheng)
- {
- if(Y06 && (dwTickCount >= cDelayTime6))
- {
- Y06 = 0;
- }
- }
- else if(CJSelect == XinYe)
- {
- if(Y11 && (dwTickCount >= cDelayTime6))
- {
- Y11 = 0;
- }
- }
- //停止
- if(X01 || tbj_bStop || M0014)
- {
- M0019 = 0;
- M0014 = 0;
- M0015 = 0;
- M0002 = 0;
- Y00 = 0;
- Y01 = 0;
- Y02 = 0;
- Y03 = 0;
- Y04 = 0;
- Y05 = 0;
- Y15 = 0;
- Y11 = 0;
- Y12 = 0;
- Y13 = 0;
- Y14 = 0;
- Y15 = 0;
- cStepMByte = 0;
- cStepMByte1 = 0;
- cStepMByte2 = 0;
- cStepMByte3 = 0;
- cStepMByte4 = 0;
- tbj_bRunning = 0;
- AxisEgmStop(X_AXIS);
- tbj_bStop = 0;
- SETDR(); //步进电机松
- cCountTime = user_datas[30] * 100 + 2;
- TBJ_cOneTimes = 0;
- }
-
- if(((X00 && !OLDX00) || M0000 || M0016) && !X01)
- {
- M0000 = 0;
- //分胶 送胶 分胶前 分胶后 送胶到位 退胶到位 双勾针方式时勾针要退到位 单勾针方式
- //if((!Y02) && (!Y04) && (!X12) && (X13 || FengJiaoSelect) && (((!X16) && X17) || (SongJiaoMode == 1)) && (((SGZSelect == 0) && X15 && !X20) || (SGZSelect == 1)) && !bRunning)
- {
- tbj_bRunning = 1;
- cStepMByte = 1;
- M0002 = 1;//cMidleCoil[0] |= (1<<2);
- user_datas[100] = 0;
- TBJ_cOneTimes = 0;
- cCountTime = 0;
- if(M0016)
- {
- TBJ_cOneTimes = 1;
- M0017 = 1;
- M0002 = 0;
- }
-
- Y07 = 1; //计数器输出
- }
- M0016 = 0;
- }
- //手动模式
- if(!tbj_bRunning && !X01)
- {
- Hand_Action();
- }
- else if(tbj_bRunning)
- {
- Auto_Run();
- }
- else if(X01)
- {
- Y00 = 0;
- Y01 = 0;
- Y02 = 0;
- Y03 = 0;
- Y04 = 0;
- Y05 = 0;
- if(CJSelect == XinYe)//鑫业的Y06为夹胶
- {
- if(X17)Y06 = 1;
- }
- else
- Y06 = 0;
- Y15 = 0;
- tbj_bRunning = 0;
- }
- if(CJSelect != XinYe)
- {
- if(Y15)
- Y11 = 1;
- else
- Y11 = 0;
- }
- }
- void TBStartCuiQi(void)
- {
- if(CJSelect == ChangSheng)//鑫业的Y06为夹胶不能输出
- Y06 = 1; //吹气
- else if(CJSelect == XinYe)
- Y11 = 1;
- cDelayTime6 = dwTickCount + (unsigned long)10 * user_datas[8];
- }
- //电机控制
- void CSTB_Auto_Con_CS(void)
- {
- unsigned short speed_buf;
- long cWorkPulseNum;
- cEncodePulse = GetPos(X_AXIS);
- switch(cStepMByte2)
- {
- case 0:
- Y00 = 0;
- if(X_DRV)AxisEgmStop(X_AXIS);
- break;
- case 1: //离合器起动
- cStepMByte2 = 2;
- Y00 = 1; //离合器输出
- if(user_datas[90] == 55)
- cDelayTime3 = dwTickCount + (unsigned long)300;
-
-
- cErrorTime2 = dwTickCount + (unsigned long)100*user_datas[24];
-
- if(!X11)
- {
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,user_datas[13],user_datas[10],user_datas[11],2);
- }
- else
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,user_datas[12],user_datas[10],user_datas[11],2);
- break;
- case 2: //过链接近下降沿
- if((!X11) || ((user_datas[90] == 55) && (dwTickCount >= cDelayTime3)))
- {
- cStepMByte2 = 3;
- if(user_datas[90] == 55)
- cDelayTime3 = dwTickCount + (unsigned long)200;
- else
- cDelayTime3 = dwTickCount + (unsigned long)5;
- cErrorTime2 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
- AxisChangeSpeed(X_AXIS,user_datas[13]);
- }
- else if((dwTickCount>=cErrorTime2) && (user_datas[24] != 0))
- {
- user_datas[75] = ActionPage;
- user_datas[100] = NoZip_W; //检查过链接近开关或没有拉链
- M15 = 0;
- tbj_bStop = 1;
- }
- else if((user_datas[29] > 5) && ((0 - cEncodePulse) >= (cSetEncode + user_datas[29] * 10)) && (cTest1 > 1))
- {
- user_datas[75] = ActionPage;
- user_datas[100] = ZipperLengPRO_W; //检查过链接近开关或没有拉链
- M15 = 0;
- tbj_bStop = 1;
- }
- break;
- case 3:
- //过链接近上升沿 //拖带到
- if(((X11_UP) || !Y00 || (user_datas[90] == 55)) && (dwTickCount >= cDelayTime3))
- {
- if(TWOTDSelect == 0) //普通拖带
- {
- AxisChangeSpeed(X_AXIS,user_datas[13]); //电机减速
- cStepMByte2 = 4;
- cErrorTime2 = dwTickCount + (unsigned long)500;
- cDelayTime3 = dwTickCount + (unsigned long)user_datas[5];
- cDelayTime4 = dwTickCount + (unsigned long)user_datas[1]; // 延时上勾针
- }
- else
- {
- cDelayTime3 = dwTickCount + (unsigned long)user_datas[26];
- cStepMByte2 = 40;
- }
- }
- else if(dwTickCount >= cErrorTime2) //拖带警告
- {
- //cMidleCoil[5] |= (1<<0); //记录
- user_datas[75] = ActionPage;
- user_datas[100] = NoZip_W; //检查过链接近开关或没有拉链
- M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
- tbj_bStop = 1;
- }
- break;
- case 40:
- if(dwTickCount >= cDelayTime3)
- {
- CLRQ00; //离合停
- AxisEgmStop(X_AXIS); //步进电机停
- if(cStepMByte1 == 0) //送胶完成
- {
- SETQ01; //上勾针
- cDelayTime3 = dwTickCount + (unsigned long)10 * user_datas[25];
- cStepMByte2 = 41;
- }
- }
- break;
- case 41:
- if((dwTickCount >= cDelayTime3) && !X_DRV)
- {
- cStepMByte2 = 4;
- cErrorTime2 = dwTickCount + (unsigned long)500;
- cDelayTime3 = dwTickCount + (unsigned long)user_datas[5];
- MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,user_datas[13],user_datas[10],user_datas[11],2);
- SETQ00; //离合开
- }
- break;
- case 4:
- //要加延时上勾针
- if(dwTickCount >= cDelayTime4)
- SETQ01; //上勾针
- if(((dwTickCount >= cDelayTime3) && (SGZSelect != 0)) || (X20 ||(user_datas[90] == 55))) //到位或延时停时间到
- {
- SETQ01; //上勾针
- CLRQ00; //离合停
- AxisEgmStop(X_AXIS); //步进电机停
- if(SGZSelect == 0) //双勾针
- {
- cStepMByte2 = 5;
- cDelayTime3 = dwTickCount + (unsigned long)1; //延时压带
- }
- else //单勾针
- {
- cStepMByte2 = 0;
- cDelayTime5 = dwTickCount + 50;
- //SETDR(); //步进电机松
- }
- }
- else if((dwTickCount >= cErrorTime2) && (SGZSelect == 0)) //拖带警告
- {
-
- user_datas[75] = ActionPage;
- user_datas[100] = GZDaoWei_W; //检查过链接近开关或没有拉链
- M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
- tbj_bStop = 1;
- }
- break;
- case 5:
- if((dwTickCount >= cDelayTime3) && !X_DRV)
- {
- cStepMByte2 = 6;
- SETQ05;
- cDelayTime3 = dwTickCount + (unsigned long)10 * user_datas[3]; //压带输出延时退勾针
- }
- break;
- case 6:
- if(dwTickCount >= cDelayTime3) //压带输出延时退勾针
- {
- CLRQ01; //勾针退
- cStepMByte2 = 7; //拖带完成
- SETDR(); //步进电机松
- cErrorTime2 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
- }
- break;
- case 7:
- if(X15) //勾针退到位
- {
- cStepMByte2 = 0;
- }
- else if(dwTickCount >= cErrorTime2)
- {
- user_datas[75] = ActionPage;
- user_datas[100] = TuiGZ_W; //勾针退不到位警告
- M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
- }
- break;
- case 20: //到位后反转一点
- CLRDR();
- cEncodePulse = 0;
- MV_Set_Command_Pos_CPU(X_AXIS,0);
- user_datas[121] = 0;
- cStepMByte2 = 21;
- cDelayTime3 = dwTickCount + 50;
- if(DianJiFanZ == 0)
- cStepMByte2 = 0;
- break;
- case 21:
- if((dwTickCount >= cDelayTime3) && !X_DRV)
- {
- cStepMByte2 = 22;
- cWorkPulseNum = user_datas[27];
- user_datas[99] = 2;
- //if(cWorkPulseNum != 0)
- {
- user_datas[99] = 1;
- AxisMovePosAccDec(X_AXIS, user_datas[22],cWorkPulseNum,1,5,1);
- }
- }
- break;
- case 22:
- if(!X_DRV)
- {
- cStepMByte2 = 0;
- // AxisEgmStop(X_AXIS); //步进电机停
- // SETDR(); //步进电机松
- }
- break;
- }
- }
- //送胶动作
- void CSTB_SongJiao_CS(void)
- {
- if(tbj_bStop)
- return;
- switch(cStepMByte1)
- {
- case 0:
- break;
- case 1: //动作开始,延时分胶
- cStepMByte1 = 2;
- cDelayTime2 = dwTickCount + (unsigned long)10 * user_datas[4]; //分胶延时输出
- break;
- case 2:
- if((dwTickCount >= cDelayTime2) || !X11)
- {
- cStepMByte1 = 3;
- SETQ02; //分胶阀
- if(CJSelect == XinYe)//鑫业的Y06为夹胶
- SETQ06;
- cDelayTime2 = dwTickCount + (unsigned long)10 * 6; //分胶延时输出
- }
- break;
- case 3:
- if(X11_UP || (user_datas[90] == 55) || ((!tbj_bRunning || (Y01 && TBJ_cOneTimes)/* || ((CJSelect == XinYe) && (SongJiaoMode == 0))*/)
- && (dwTickCount >= cDelayTime2))) //过链上到链上的时候送胶开始
- {
- cStepMByte1 = 4;
- }
- break;
- case 4:
- //单勾针方式上升开始送胶 双勾针方式电机完成后才能送 分胶到位
- if(((SGZSelect == 1) || (cStepMByte2 == 0)) && (dwTickCount >= cDelayTime2))
- {
- if(X12 && Y02) //分胶到位
- {
- cStepMByte1 = 5;
- SETQ04;
- cErrorTime1 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
- cDelayTime2 = dwTickCount + (unsigned long)10 * user_datas[9];
- }
- }
- break;
- case 5:
- if(X16_UP || ((SongJiaoMode == 1) && (SongJiaoDaoWei == 1) && (dwTickCount >= cDelayTime2)))
- {
- if(tbj_bRunning || M19) //在工作状态
- {
- cStepMByte1 = 6;
- cDelayTime2 = dwTickCount + (unsigned long)15;
- }
- else
- cStepMByte1 = 0;
-
- }
- else if(dwTickCount >= cErrorTime1)
- {
- user_datas[75] = ActionPage;
- user_datas[100] = SongJiao_W; //送胶不到位警告
- M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
- }
- if(X10 && tbj_bRunning)
- {
- user_datas[75] = ActionPage;
- user_datas[100] = NoJiao_W; //没胶警告
- M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
- // tbj_bStop = 1;
- TBJ_cOneTimes = 1;
- }
- break;
- case 6:
- if(dwTickCount >= cDelayTime2) //普通拖带
- {
- cStepMByte1 = 7;
- CLRQ02;//关分胶
-
- if(CJSelect == XinYe)//鑫业的Y06为夹胶
- {
- CLRQ06;
- }
- cErrorTime1 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
- }
- break;
- case 7:
- if(/*(X13 || FengJiaoSelect) && */!X12 && (dwTickCount >= cDelayTime2))
- {
- cStepMByte1 = 8;
- if((SongJiaoMode == 0) || (!tbj_bRunning)) //气缸送胶先退,滚轮送胶先不退或是触摸屏手动退送胶
- CLRQ04;
- cErrorTime1 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
- }
- else if(dwTickCount >= cErrorTime1)
- {
- user_datas[75] = ActionPage;
- user_datas[100] = TuiFenJiao_W; //退分胶不到位警告
- }
- break;
- case 8:
- //送胶模式 0 气缸 1 滚轮(没后接近)/感应前点离开
- if(((SongJiaoMode == 1) || (!X16 && X17)))
- {
- cStepMByte1 = 0;
- M19 = 0;
- }
- else if(dwTickCount >= cErrorTime1)
- {
- user_datas[75] = ActionPage;
- user_datas[100] = TuiJiao_W; //退送胶不到位警告
- }
- break;
- }
- }
- //合模超声动作
- void CSTB_HeMo_CS_CS(void)
- {
- switch(cStepMByte3)
- {
- case 0:
- break;
- case 1:
- //分胶 送胶 滚轮模式不退 分胶前 分胶后 送胶到位 退胶胶到位 滚轮方式 //单勾针方式
- if(((!Y02) && ((!Y04) || (SongJiaoMode == 1)) && (!X12) && (X13 || FengJiaoSelect) && (((!X16) && X17) || (SongJiaoMode == 1)) && (X15 || (SGZSelect != 0))) && (dwTickCount >= cDelayTime5))
- {
- SETQ03; // 下冲
- //下模方式 0 下模活动,1 下模不动
- if((XiaMoMode == 0) && (SGZSelect != 0))//单勾针方式
- {
- SETQ05;
- }
- cStepMByte3 = 2;
- cErrorTime3 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
- }
- else if(!tbj_bRunning)
- cStepMByte3 = 0;
- break;
- case 2:
- //上模下到位 单勾针方式X15才接到下模上到位 或下模不动
- if(X14 && ((X15 && (SGZSelect != 0)) || (XiaMoMode != 0)))
- {
- cDelayTime5 = dwTickCount + (unsigned long)10 * user_datas[0]; //延时超声
- cStepMByte3 = 3;
- if(TuiGZMode == 1) //0 先超声后下勾针,1 先下勾针后超声
- Y01 = 0;
- }
- break;
- case 3:
- if(dwTickCount >= cDelayTime5)
- {
- if((user_datas[90] != 55))
- {
- M09 = 0;
- Y15 = 1; //超声开
- Y11 = 1;
- if(user_datas[6] > 150)
- cDelayTime5 = dwTickCount + (unsigned long)10 * 150; //超声时间
- else
- {
- if(X07 && (user_datas[28] < user_datas[6]))
- cDelayTime5 = dwTickCount + (unsigned long)10 * (user_datas[6] - user_datas[28]); //超声时间
- else
- cDelayTime5 = dwTickCount + (unsigned long)10 * user_datas[6]; //超声时间
- }
- Y04 = 0; //滚轮方式退送胶
- }
- else
- {
- cDelayTime5 = dwTickCount + (unsigned long)30;
- }
- cStepMByte3 = 4;
- }
- break;
- case 4:
- if(dwTickCount >= cDelayTime5)
- {
- cStepMByte3 = 5;
- Y15 = 0;
- Y11 = 0;
- TBStartCuiQi(); //启动吹气
- cDelayTime5 = dwTickCount + (unsigned long)5 * user_datas[7]; //固化时间一半
- }
- break;
- case 5:
- if(dwTickCount >= cDelayTime5)
- {
- cStepMByte3 = 6;
- Y01 = 0;
- cDelayTime5 = dwTickCount + (unsigned long)5 * user_datas[7]; //固化时间一半
- }
- break;
- case 6:
- if(dwTickCount >= cDelayTime5)
- {
- Y03 = 0; //上模关
- Y05 = 0; //下模或压带关
- cStepMByte3 = 7;
- }
- break;
- case 7:
- if(!X14)
- {
- cStepMByte3 = 8;
- cDelayTime5 = dwTickCount + (unsigned long)25;
- }
- break;
- case 8:
- if(dwTickCount >= cDelayTime5)
- {
- Y01 = 0; //勾针下
- cStepMByte3 = 0;
- cDelayTime5 = dwTickCount + (unsigned long)10 * 35;
- }
- break;
- }
- }
- void Hand_Action(void)
- {
- unsigned char ch;
- //手动勾针,屏单独控制
- if(M0004)
- {
- M04 = 0;//cMidleCoil[0] &= ~(1<<4); //M4
- if(Y01)
- {
- if(!Y03)CLRQ01;
- }
- else
- SETQ01;
- /*if(!X_DRV && (cStepMByte2 == 0))MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,10,1,1,2);
- else
- AxisEgmStop(X_AXIS); */
- user_datas[121]++;
- }
- //手动勾针
- if(X02)
- {// 送胶前 单勾针方式 滚轮送胶方式
- if(X02_UP && (!X16 || (SGZSelect == 1) || (SongJiaoMode == 1)))
- {
- Y01 = 1;
- }
- // 双勾针选择0 双勾针(新款) 1 单勾针
- if((SGZSelect == 0)) //没触摸屏时自动压带
- {
- //勾针到位
- if(Y01 && X20 && !Y05)
- {
- Y05 = 1;
- cDelayTime2 = dwTickCount + (unsigned long)10 * user_datas[3]; //压带输出时间
- }
- if(Y05 && (dwTickCount >= cDelayTime2))
- {
- Y01 = 0;
- }
- }
- }
- else if(!X02 && OLDX02)
- {
- Y01 = 0;
- if((SGZSelect == 0) && (!X02 && OLDX02))//没触摸屏时自动退压带
- Y05 = 0;
- }
- //压带,在双勾针方式时有效
- if(M0003)
- {
- M0003 = 0;//cMidleCoil[0] &= ~(1<<3); //M3
- //双勾针方式 下模不动
- if((SGZSelect == 0) && (XiaMoMode == 1))
- {
- if(Y05)
- Y05 = 0;
- else
- Y05 = 1;
- }
- }
- //手动前导板(分胶)
- //改动06.12.27 合模或双勾针 合模到位 上模 下模下到位 手动超声
- if(((X03 && !OLDX03) || M0013) && ((!Y05 && (!X15) && (SGZSelect == 1)) || ((SGZSelect == 0) && X15 && !X20)) &&
- (!Y03) && (!X14) && (!X06))
- {
- M0013 = 0;
- if(Y02 && !X03)Y02 = 0;
- else Y02 = 1;
-
- }
- else if(!X03 && OLDX03)Y02 = 0;
- //手动送胶 当单勾针时下模信号不能有 当为双勾针时要勾针退到位(X15是复用)
- if(Y04 && (X16 && !OLDX16))
- {
- //CLRQ06;
- }
- // 合模或双勾针 合模到位
- if((X05 || M0007) && ((!Y05 &&(!X15) && (SGZSelect == 1)) || ((SGZSelect == 0) && X15 && !X20))
- //上模 下模下到位 手动超声
- && (!Y03) && (!X14) && (!X06) && (!Y04 || (X05 && !OLDX05)))
- {
- if(CJSelect == XinYe)//鑫业的Y06为夹胶
- {
- if((X05 && !OLDX05) || (!Y06 && M0007))
- {
- Y06 = 1;
- cDelayTime1 = dwTickCount + (unsigned long)70;
- }
- else if(Y06 && (dwTickCount >= cDelayTime1))
- {
- Y04 = 1;
- M0007 = 0;//cMidleCoil[0] &= ~(1<<7); //M7
- }
- }
- else if(CJSelect == ChangSheng)//鑫业的Y06为夹胶
- {//手动送胶 普通拖带 二次拖带时勾针不能有输出
- if((X05_UP || M0007) && ((TWOTDSelect == 0) || ((TWOTDSelect == 1) && !Y01)))
- {
- Y04 = 1;
- M0007 = 0;
- }
- }
- }
- else if(!X05)
- {
- if(CJSelect == XinYe)//鑫业的Y06为夹胶
- {
- if((!X05 && OLDX05) || M0007)
- {
- M0007 = 0;
- Y06 = 0;
- cDelayTime1 = dwTickCount + (unsigned long)120;
- }
- else if(!Y06 && (dwTickCount >= cDelayTime1))
- {
- Y04 = 0;
- }
- if(!Y04 && (X17 && !OLDX17))
- {
- Y06 = 1;
- }
- }
- else if(CJSelect == ChangSheng)//鑫业的Y06为夹胶
- {
- if((!X05 && OLDX05) || M0007)
- {
- Y04 = 0;
- M0007 = 0;
- }
- }
- }
- //手动合模
- //手动下冲 分胶后 分胶前 送胶到位 退胶到位 或滚轮送胶
- if((X04 || M0008) && (X13 || FengJiaoSelect) && (!X12) && (((!X16) && X17) || (SongJiaoMode == 1))
- //超声输出
- && (!Y15))
- {
- if(M0008 && Y03 && !X04)
- {
- Y03 = 0;
- if(((SGZSelect == 0) && (XiaMoMode == 1)) || (XiaMoMode == 0))
- {
- Y05 = 0;
- }
- }
- //合模输出
- else if(((X04 && !OLDX04) || M0008) && !Y03 &&((SGZSelect == 0) && X15 && !X20) || ((SGZSelect == 1) && Y01))
- {
- Y03 = 1;
- if(XiaMoMode == 0) //下模活动方式
- Y05 = 1;
- }
- M0008 = 0;//cMidleCoil[0] &= ~(1<<8); //M8
- }
- else if((!X04 && OLDX04))
- {
- Y03 = 0;
- if(((SGZSelect == 0) && (XiaMoMode == 1)) || (XiaMoMode == 0))
- {
- Y05 = 0;
- }
- }
- if((X14 && !OLDX14)) //合模到位
- {
- // if(CJSelect != XinYe)
- // TBStartCuiQi(); //启动吹气
- }
- //手动超声
- // 分胶 送胶 分胶前 分胶后 送胶到位 退胶到位 送胶为滚轮方式
- if((X06 || ((M09 || M10) && !X06_DW)) && (!Y02) && (!Y04) && (!X12) && (X13 || FengJiaoSelect) && (((!X16) && X17) || (SongJiaoMode == 1)) && (dwTickCount >= cDelayTime5))
- {// 上超
- if((((SGZSelect == 0) && X15 && !X20) || (SGZSelect == 1)&& Y01) && !M12 )
- {
- if(XiaMoMode == 1) //下模不动
- {
- if(X14)//已经合模
- {
- if((X06_UP || M09) && (cStepMByte3 == 0))
- {
- cStepMByte3 = 3; //直接发超声(按设定时间)
- M10 = 1;
- }
- }
- else
- {
- if((X06_UP || M09) && !M10)
- {
- M10 = 1;//cMidleCoil[0] |= (1<<10); //M10
- user_datas[126]++;
- SETQ15; //发超声
- cDelayTime5 = dwTickCount + (unsigned long)10 * user_datas[6]; //限长时间2秒
- }
- else if(((!M09 && !X06) || (dwTickCount >= cDelayTime5)) && Y15)
- {
- M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
- M10 = 0;
- CLRQ15;
- TBStartCuiQi();
- }
- }
- }
- else if(SGZSelect == 1)//下模活动,勾针为单勾针
- {
- if((X06_UP || M09) && !M10)
- {
- M09 = 1;M10 = 1;//cMidleCoil[0] |= ((1<<10) | (1<<9)) ; //M10
- SETQ05; //先下模升上去
- if(X15) //先合模的情况下直接发超声
- {
- SETQ15; //发超声
- cDelayTime5 = dwTickCount + (unsigned long)10 * 200; //限长时间2秒
- }
- }
- if(Y05 && X15_UP)
- {
- SETQ15; //发超声
- cDelayTime5 = dwTickCount + (unsigned long)10 * 200; //限长时间2秒
- }
- if((!M09 || (dwTickCount >= cDelayTime5)) && Y15)
- {
- M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
- CLRQ15;
- cStepMByte3 = 4;
- }
- }
- //手动超声完成
- if(!M09 && !Y15 && !X06)
- {
- M10 = 0;//cMidleCoil[0] &= ~(1<<10); //M10
- cStepMByte3 = 0;
- user_datas[128] = 0;
- if(XiaMoMode == 0) //下模活动
- {
- CLRQ05;
- }
- }
- }
- else
- M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
- }
- else if(X06_DW)
- {
- M10 = 0;//cMidleCoil[0] &= ~(1<<10); //M10
- M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
- CLRQ15;
- cStepMByte3 = 0;
- cDelayTime5 = dwTickCount + (unsigned long)10 * 30;
- if(XiaMoMode == 0) //下模活动
- {
- CLRQ05;
- }
- }
-
- //手动 上超
- // 分胶 分胶前 分胶后 送胶 送胶到位 退胶到位 手动超声
- if(M11 && !M12 && (!Y02) && (!X12) && (X13 || FengJiaoSelect) && (((!Y04) && (!X16) && X17) || (SongJiaoMode == 1))&& (!X06) && (dwTickCount >= cDelayTime5))
- {
-
- if(((SGZSelect == 0) && X15 && !X20) || ((SGZSelect == 1)&& Y01))
- {
- M12 = 1;//cMidleCoil[0] |= (1<<12); //M12
- cStepMByte3 = 1; //整个合模超声过程
- }
- M11 = 0;//cMidleCoil[0] &= ~(1<<11); //M11
- }
- else if((M12 && ((cStepMByte3 == 0) || M11)))
- {
- M11 = 0;//cMidleCoil[0] &= ~(1<<11); //M11
- M12 = 0;//cMidleCoil[0] &= ~(1<<12); //M12
- CLRQ03; //上模关
- CLRQ15; //超声关
- if((SGZSelect == 1) && (XiaMoMode == 0)) //下模活动
- CLRQ05; //下模或压带关
- cStepMByte3 = 0;
- cDelayTime5 = dwTickCount + (unsigned long)10 * 30;
- }
- //自动送胶动作
- if(M0018)
- {
- M18 = 0;
- if(!Y03 && !X14 && (XiaMoMode == 1) && !Y04)
- {
- M19 = 1;
- cStepMByte1 = 1; //分胶送开始
- }
- }
- }
- void Auto_Run(void)
- {
- switch(cStepMByte)
- {
- case 0:
- break;
- case 1:
- cStepMByte = 2;
- CLRDR();
-
- cDelayTime1 = dwTickCount + (unsigned long)200; //先锁轴
- cTest1 = 0;
- cSetEncode = 0;
- break;
- case 2: //第一条时
- if(dwTickCount >= cDelayTime1)
- {
- cStepMByte = 3;
- cStepMByte1 = 1; //分胶送开始
- MV_Set_Command_Pos_CPU(X_AXIS,0);
- if(!Y01)
- cStepMByte2 = 1; //拖带电机开始
- }
- break;
- case 3:
- // 送胶完成
- if((cStepMByte1 == 0) && (cStepMByte2 == 0))
- {
- cStepMByte = 4;
- if(cTest1 == 1)
- cSetEncode = cEncodePulse;
- if(DianJiFanZ == 1)
- cStepMByte2 = 20; //拖带电机反转一点
- else
- SETDR();
- cDelayTime1 = dwTickCount + (unsigned long)1000; // 退分胶到位要警告
- }
- break;
- case 4:
- //分胶 分胶前 分胶后 送胶 送胶到位 退胶到位 滚轮方式 双勾针方式时勾针要退到位 单勾针方式
- if((!Y02) && (!X12) && (X13 || FengJiaoSelect) && (((!Y04) &&(!X16) && X17) || (SongJiaoMode == 1))&& (((SGZSelect == 0) && X15 && !X20) || (SGZSelect == 1)))
- {
- if(cStepMByte2 == 0)
- {
- cStepMByte = 5;
- cStepMByte3 = 1;
- }
- }
- break;
- case 5:
- if(cStepMByte3 == 0)
- {
- cStepMByte = 6;
-
- CLRQ01;
- if(TBJ_cOneTimes == 1)
- {
- SETDR();
- tbj_bStop = 1;
- }
- else
- {
- CLRDR();
- CalProSP(78); //计算生产速度
- }
- AddToTal(76); //产量加1保存
- }
- break;
- case 6:
- if(!X14 && (((SGZSelect == 0) && X15 && !X20) || ((XiaMoMode == 0) && !X15) || ((XiaMoMode == 1) && (SGZSelect == 1)))) //上模离开
- {
- cStepMByte = 7;
- cDelayTime1 = dwTickCount + (unsigned long)30; //先锁轴
- }
- break;
- case 7:
- if(dwTickCount >= cDelayTime1)
- {
- cStepMByte = 2;
- cTest1++;
- if(cTest1 > 2)
- cTest1 = 3;
- }
- break;
- }
- }
- #endif
|