TYTieBuJi.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994
  1. #include "global.h"
  2. #if TONG_YONG_MACHINE
  3. void TBJ_InitAction(void);
  4. void TBJ_Action(void);
  5. void CSTB_SongJiao_CS(void);
  6. void CSTB_Auto_Con_CS(void);
  7. void CSTB_HeMo_CS_CS(void);
  8. void Auto_Run(void);
  9. void Hand_Action(void);
  10. unsigned short cCountTime;
  11. unsigned char TBJ_cOneTimes,cTest1;
  12. unsigned long cErrorTime1,cErrorTime2,cErrorTime3;
  13. static long cSetEncode;
  14. static long cEncodePulse;
  15. unsigned char tbj_bRunning = 0,tbj_bStop;
  16. void TBJ_InitAction(void)
  17. {
  18. XGearRatio = 1;
  19. if(CJSelect == XinYe)//鑫业的Y06为夹胶
  20. {
  21. if(X17)Y06 = 1;
  22. }
  23. SetEn(X_AXIS,1); //步进电机松
  24. }
  25. void TBJ_Action(void)
  26. {
  27. static unsigned long c10msDelay = 0;
  28. //cStepMByte;
  29. user_datas[122] = cStepMByte1;
  30. user_datas[123] = cStepMByte2;
  31. user_datas[124] = cStepMByte3;
  32. user_datas[125] = cStepMByte4;
  33. // user_datas[126] = cStepMByte5;
  34. CSTB_HeMo_CS_CS(); //合模超声动作
  35. CSTB_SongJiao_CS(); //送胶动作
  36. CSTB_Auto_Con_CS(); //电机拖带动作
  37. if(dwTickCount >= c10msDelay)
  38. {
  39. c10msDelay = dwTickCount+10;
  40. if(cCountTime > 0)
  41. {
  42. cCountTime--;
  43. if(cCountTime == 0)Y07 = 0;
  44. }
  45. }
  46. if(M0015) //M15 故障确定
  47. {
  48. M0015 = 1;
  49. user_datas[100] = 0;
  50. user_datas[75] = 1;
  51. cDelayTime7 = dwTickCount + (unsigned long)1010;
  52. }
  53. if(M0001) //清产量
  54. {
  55. if(dwTickCount >= cDelayTime8)
  56. {
  57. M0001 = 0;
  58. ClrcToTal(76);
  59. }
  60. }
  61. else
  62. {
  63. cDelayTime8 = dwTickCount + (unsigned long)120*10;
  64. }
  65. //设定音波参数使能
  66. if(M0005)
  67. {
  68. if(dwTickCount >= cDelayTime9)
  69. {
  70. M0005 = 0;
  71. M0006 = 1;
  72. cDelayTime10 = dwTickCount + (unsigned long)5000;
  73. }
  74. }
  75. else
  76. cDelayTime9 = dwTickCount + (unsigned long)1300;
  77. if(M0006 && (dwTickCount >= cDelayTime10))
  78. {
  79. M0006 = 0;
  80. }
  81. if(CJSelect == ChangSheng)
  82. {
  83. if(Y06 && (dwTickCount >= cDelayTime6))
  84. {
  85. Y06 = 0;
  86. }
  87. }
  88. else if(CJSelect == XinYe)
  89. {
  90. if(Y11 && (dwTickCount >= cDelayTime6))
  91. {
  92. Y11 = 0;
  93. }
  94. }
  95. //停止
  96. if(X01 || tbj_bStop || M0014)
  97. {
  98. M0019 = 0;
  99. M0014 = 0;
  100. M0015 = 0;
  101. M0002 = 0;
  102. Y00 = 0;
  103. Y01 = 0;
  104. Y02 = 0;
  105. Y03 = 0;
  106. Y04 = 0;
  107. Y05 = 0;
  108. Y15 = 0;
  109. Y11 = 0;
  110. Y12 = 0;
  111. Y13 = 0;
  112. Y14 = 0;
  113. Y15 = 0;
  114. cStepMByte = 0;
  115. cStepMByte1 = 0;
  116. cStepMByte2 = 0;
  117. cStepMByte3 = 0;
  118. cStepMByte4 = 0;
  119. tbj_bRunning = 0;
  120. AxisEgmStop(X_AXIS);
  121. tbj_bStop = 0;
  122. SETDR(); //步进电机松
  123. cCountTime = user_datas[30] * 100 + 2;
  124. TBJ_cOneTimes = 0;
  125. }
  126. if(((X00 && !OLDX00) || M0000 || M0016) && !X01)
  127. {
  128. M0000 = 0;
  129. //分胶 送胶 分胶前 分胶后 送胶到位 退胶到位 双勾针方式时勾针要退到位       单勾针方式
  130. //if((!Y02) && (!Y04) && (!X12) && (X13 || FengJiaoSelect) && (((!X16) && X17) || (SongJiaoMode == 1)) && (((SGZSelect == 0) && X15 && !X20) || (SGZSelect == 1)) && !bRunning)
  131. {
  132. tbj_bRunning = 1;
  133. cStepMByte = 1;
  134. M0002 = 1;//cMidleCoil[0] |= (1<<2);
  135. user_datas[100] = 0;
  136. TBJ_cOneTimes = 0;
  137. cCountTime = 0;
  138. if(M0016)
  139. {
  140. TBJ_cOneTimes = 1;
  141. M0017 = 1;
  142. M0002 = 0;
  143. }
  144. Y07 = 1; //计数器输出
  145. }
  146. M0016 = 0;
  147. }
  148. //手动模式
  149. if(!tbj_bRunning && !X01)
  150. {
  151. Hand_Action();
  152. }
  153. else if(tbj_bRunning)
  154. {
  155. Auto_Run();
  156. }
  157. else if(X01)
  158. {
  159. Y00 = 0;
  160. Y01 = 0;
  161. Y02 = 0;
  162. Y03 = 0;
  163. Y04 = 0;
  164. Y05 = 0;
  165. if(CJSelect == XinYe)//鑫业的Y06为夹胶
  166. {
  167. if(X17)Y06 = 1;
  168. }
  169. else
  170. Y06 = 0;
  171. Y15 = 0;
  172. tbj_bRunning = 0;
  173. }
  174. if(CJSelect != XinYe)
  175. {
  176. if(Y15)
  177. Y11 = 1;
  178. else
  179. Y11 = 0;
  180. }
  181. }
  182. void TBStartCuiQi(void)
  183. {
  184. if(CJSelect == ChangSheng)//鑫业的Y06为夹胶不能输出
  185. Y06 = 1; //吹气
  186. else if(CJSelect == XinYe)
  187. Y11 = 1;
  188. cDelayTime6 = dwTickCount + (unsigned long)10 * user_datas[8];
  189. }
  190. //电机控制
  191. void CSTB_Auto_Con_CS(void)
  192. {
  193. unsigned short speed_buf;
  194. long cWorkPulseNum;
  195. cEncodePulse = GetPos(X_AXIS);
  196. switch(cStepMByte2)
  197. {
  198. case 0:
  199. Y00 = 0;
  200. if(X_DRV)AxisEgmStop(X_AXIS);
  201. break;
  202. case 1: //离合器起动
  203. cStepMByte2 = 2;
  204. Y00 = 1; //离合器输出
  205. if(user_datas[90] == 55)
  206. cDelayTime3 = dwTickCount + (unsigned long)300;
  207. cErrorTime2 = dwTickCount + (unsigned long)100*user_datas[24];
  208. if(!X11)
  209. {
  210. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,user_datas[13],user_datas[10],user_datas[11],2);
  211. }
  212. else
  213. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,user_datas[12],user_datas[10],user_datas[11],2);
  214. break;
  215. case 2: //过链接近下降沿
  216. if((!X11) || ((user_datas[90] == 55) && (dwTickCount >= cDelayTime3)))
  217. {
  218. cStepMByte2 = 3;
  219. if(user_datas[90] == 55)
  220. cDelayTime3 = dwTickCount + (unsigned long)200;
  221. else
  222. cDelayTime3 = dwTickCount + (unsigned long)5;
  223. cErrorTime2 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
  224. AxisChangeSpeed(X_AXIS,user_datas[13]);
  225. }
  226. else if((dwTickCount>=cErrorTime2) && (user_datas[24] != 0))
  227. {
  228. user_datas[75] = ActionPage;
  229. user_datas[100] = NoZip_W; //检查过链接近开关或没有拉链
  230. M15 = 0;
  231. tbj_bStop = 1;
  232. }
  233. else if((user_datas[29] > 5) && ((0 - cEncodePulse) >= (cSetEncode + user_datas[29] * 10)) && (cTest1 > 1))
  234. {
  235. user_datas[75] = ActionPage;
  236. user_datas[100] = ZipperLengPRO_W; //检查过链接近开关或没有拉链
  237. M15 = 0;
  238. tbj_bStop = 1;
  239. }
  240. break;
  241. case 3:
  242. //过链接近上升沿 //拖带到
  243. if(((X11_UP) || !Y00 || (user_datas[90] == 55)) && (dwTickCount >= cDelayTime3))
  244. {
  245. if(TWOTDSelect == 0) //普通拖带
  246. {
  247. AxisChangeSpeed(X_AXIS,user_datas[13]); //电机减速
  248. cStepMByte2 = 4;
  249. cErrorTime2 = dwTickCount + (unsigned long)500;
  250. cDelayTime3 = dwTickCount + (unsigned long)user_datas[5];
  251. cDelayTime4 = dwTickCount + (unsigned long)user_datas[1]; // 延时上勾针
  252. }
  253. else
  254. {
  255. cDelayTime3 = dwTickCount + (unsigned long)user_datas[26];
  256. cStepMByte2 = 40;
  257. }
  258. }
  259. else if(dwTickCount >= cErrorTime2) //拖带警告
  260. {
  261. //cMidleCoil[5] |= (1<<0); //记录
  262. user_datas[75] = ActionPage;
  263. user_datas[100] = NoZip_W; //检查过链接近开关或没有拉链
  264. M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
  265. tbj_bStop = 1;
  266. }
  267. break;
  268. case 40:
  269. if(dwTickCount >= cDelayTime3)
  270. {
  271. CLRQ00; //离合停
  272. AxisEgmStop(X_AXIS); //步进电机停
  273. if(cStepMByte1 == 0) //送胶完成
  274. {
  275. SETQ01; //上勾针
  276. cDelayTime3 = dwTickCount + (unsigned long)10 * user_datas[25];
  277. cStepMByte2 = 41;
  278. }
  279. }
  280. break;
  281. case 41:
  282. if((dwTickCount >= cDelayTime3) && !X_DRV)
  283. {
  284. cStepMByte2 = 4;
  285. cErrorTime2 = dwTickCount + (unsigned long)500;
  286. cDelayTime3 = dwTickCount + (unsigned long)user_datas[5];
  287. MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,user_datas[13],user_datas[10],user_datas[11],2);
  288. SETQ00; //离合开
  289. }
  290. break;
  291. case 4:
  292. //要加延时上勾针
  293. if(dwTickCount >= cDelayTime4)
  294. SETQ01; //上勾针
  295. if(((dwTickCount >= cDelayTime3) && (SGZSelect != 0)) || (X20 ||(user_datas[90] == 55))) //到位或延时停时间到
  296. {
  297. SETQ01; //上勾针
  298. CLRQ00; //离合停
  299. AxisEgmStop(X_AXIS); //步进电机停
  300. if(SGZSelect == 0) //双勾针
  301. {
  302. cStepMByte2 = 5;
  303. cDelayTime3 = dwTickCount + (unsigned long)1; //延时压带
  304. }
  305. else //单勾针
  306. {
  307. cStepMByte2 = 0;
  308. cDelayTime5 = dwTickCount + 50;
  309. //SETDR(); //步进电机松
  310. }
  311. }
  312. else if((dwTickCount >= cErrorTime2) && (SGZSelect == 0)) //拖带警告
  313. {
  314. user_datas[75] = ActionPage;
  315. user_datas[100] = GZDaoWei_W; //检查过链接近开关或没有拉链
  316. M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
  317. tbj_bStop = 1;
  318. }
  319. break;
  320. case 5:
  321. if((dwTickCount >= cDelayTime3) && !X_DRV)
  322. {
  323. cStepMByte2 = 6;
  324. SETQ05;
  325. cDelayTime3 = dwTickCount + (unsigned long)10 * user_datas[3]; //压带输出延时退勾针
  326. }
  327. break;
  328. case 6:
  329. if(dwTickCount >= cDelayTime3) //压带输出延时退勾针
  330. {
  331. CLRQ01; //勾针退
  332. cStepMByte2 = 7; //拖带完成
  333. SETDR(); //步进电机松
  334. cErrorTime2 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
  335. }
  336. break;
  337. case 7:
  338. if(X15) //勾针退到位
  339. {
  340. cStepMByte2 = 0;
  341. }
  342. else if(dwTickCount >= cErrorTime2)
  343. {
  344. user_datas[75] = ActionPage;
  345. user_datas[100] = TuiGZ_W; //勾针退不到位警告
  346. M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
  347. }
  348. break;
  349. case 20: //到位后反转一点
  350. CLRDR();
  351. cEncodePulse = 0;
  352. MV_Set_Command_Pos_CPU(X_AXIS,0);
  353. user_datas[121] = 0;
  354. cStepMByte2 = 21;
  355. cDelayTime3 = dwTickCount + 50;
  356. if(DianJiFanZ == 0)
  357. cStepMByte2 = 0;
  358. break;
  359. case 21:
  360. if((dwTickCount >= cDelayTime3) && !X_DRV)
  361. {
  362. cStepMByte2 = 22;
  363. cWorkPulseNum = user_datas[27];
  364. user_datas[99] = 2;
  365. //if(cWorkPulseNum != 0)
  366. {
  367. user_datas[99] = 1;
  368. AxisMovePosAccDec(X_AXIS, user_datas[22],cWorkPulseNum,1,5,1);
  369. }
  370. }
  371. break;
  372. case 22:
  373. if(!X_DRV)
  374. {
  375. cStepMByte2 = 0;
  376. // AxisEgmStop(X_AXIS); //步进电机停
  377. // SETDR(); //步进电机松
  378. }
  379. break;
  380. }
  381. }
  382. //送胶动作
  383. void CSTB_SongJiao_CS(void)
  384. {
  385. if(tbj_bStop)
  386. return;
  387. switch(cStepMByte1)
  388. {
  389. case 0:
  390. break;
  391. case 1: //动作开始,延时分胶
  392. cStepMByte1 = 2;
  393. cDelayTime2 = dwTickCount + (unsigned long)10 * user_datas[4]; //分胶延时输出
  394. break;
  395. case 2:
  396. if((dwTickCount >= cDelayTime2) || !X11)
  397. {
  398. cStepMByte1 = 3;
  399. SETQ02; //分胶阀
  400. if(CJSelect == XinYe)//鑫业的Y06为夹胶
  401. SETQ06;
  402. cDelayTime2 = dwTickCount + (unsigned long)10 * 6; //分胶延时输出
  403. }
  404. break;
  405. case 3:
  406. if(X11_UP || (user_datas[90] == 55) || ((!tbj_bRunning || (Y01 && TBJ_cOneTimes)/* || ((CJSelect == XinYe) && (SongJiaoMode == 0))*/)
  407. && (dwTickCount >= cDelayTime2))) //过链上到链上的时候送胶开始
  408. {
  409. cStepMByte1 = 4;
  410. }
  411. break;
  412. case 4:
  413. //单勾针方式上升开始送胶 双勾针方式电机完成后才能送 分胶到位
  414. if(((SGZSelect == 1) || (cStepMByte2 == 0)) && (dwTickCount >= cDelayTime2))
  415. {
  416. if(X12 && Y02) //分胶到位
  417. {
  418. cStepMByte1 = 5;
  419. SETQ04;
  420. cErrorTime1 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
  421. cDelayTime2 = dwTickCount + (unsigned long)10 * user_datas[9];
  422. }
  423. }
  424. break;
  425. case 5:
  426. if(X16_UP || ((SongJiaoMode == 1) && (SongJiaoDaoWei == 1) && (dwTickCount >= cDelayTime2)))
  427. {
  428. if(tbj_bRunning || M19) //在工作状态
  429. {
  430. cStepMByte1 = 6;
  431. cDelayTime2 = dwTickCount + (unsigned long)15;
  432. }
  433. else
  434. cStepMByte1 = 0;
  435. }
  436. else if(dwTickCount >= cErrorTime1)
  437. {
  438. user_datas[75] = ActionPage;
  439. user_datas[100] = SongJiao_W; //送胶不到位警告
  440. M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
  441. }
  442. if(X10 && tbj_bRunning)
  443. {
  444. user_datas[75] = ActionPage;
  445. user_datas[100] = NoJiao_W; //没胶警告
  446. M15 = 0;//cMidleCoil[0] &= ~(1<<15); //M15
  447. // tbj_bStop = 1;
  448. TBJ_cOneTimes = 1;
  449. }
  450. break;
  451. case 6:
  452. if(dwTickCount >= cDelayTime2) //普通拖带
  453. {
  454. cStepMByte1 = 7;
  455. CLRQ02;//关分胶
  456. if(CJSelect == XinYe)//鑫业的Y06为夹胶
  457. {
  458. CLRQ06;
  459. }
  460. cErrorTime1 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
  461. }
  462. break;
  463. case 7:
  464. if(/*(X13 || FengJiaoSelect) && */!X12 && (dwTickCount >= cDelayTime2))
  465. {
  466. cStepMByte1 = 8;
  467. if((SongJiaoMode == 0) || (!tbj_bRunning)) //气缸送胶先退,滚轮送胶先不退或是触摸屏手动退送胶
  468. CLRQ04;
  469. cErrorTime1 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
  470. }
  471. else if(dwTickCount >= cErrorTime1)
  472. {
  473. user_datas[75] = ActionPage;
  474. user_datas[100] = TuiFenJiao_W; //退分胶不到位警告
  475. }
  476. break;
  477. case 8:
  478. //送胶模式 0 气缸 1 滚轮(没后接近)/感应前点离开
  479. if(((SongJiaoMode == 1) || (!X16 && X17)))
  480. {
  481. cStepMByte1 = 0;
  482. M19 = 0;
  483. }
  484. else if(dwTickCount >= cErrorTime1)
  485. {
  486. user_datas[75] = ActionPage;
  487. user_datas[100] = TuiJiao_W; //退送胶不到位警告
  488. }
  489. break;
  490. }
  491. }
  492. //合模超声动作
  493. void CSTB_HeMo_CS_CS(void)
  494. {
  495. switch(cStepMByte3)
  496. {
  497. case 0:
  498. break;
  499. case 1:
  500. //分胶 送胶 滚轮模式不退 分胶前 分胶后 送胶到位 退胶胶到位 滚轮方式 //单勾针方式
  501. if(((!Y02) && ((!Y04) || (SongJiaoMode == 1)) && (!X12) && (X13 || FengJiaoSelect) && (((!X16) && X17) || (SongJiaoMode == 1)) && (X15 || (SGZSelect != 0))) && (dwTickCount >= cDelayTime5))
  502. {
  503. SETQ03; // 下冲
  504. //下模方式 0 下模活动,1 下模不动
  505. if((XiaMoMode == 0) && (SGZSelect != 0))//单勾针方式
  506. {
  507. SETQ05;
  508. }
  509. cStepMByte3 = 2;
  510. cErrorTime3 = dwTickCount + (unsigned long)TBJ_ERRORTIME;
  511. }
  512. else if(!tbj_bRunning)
  513. cStepMByte3 = 0;
  514. break;
  515. case 2:
  516. //上模下到位 单勾针方式X15才接到下模上到位 或下模不动
  517. if(X14 && ((X15 && (SGZSelect != 0)) || (XiaMoMode != 0)))
  518. {
  519. cDelayTime5 = dwTickCount + (unsigned long)10 * user_datas[0]; //延时超声
  520. cStepMByte3 = 3;
  521. if(TuiGZMode == 1) //0 先超声后下勾针,1 先下勾针后超声
  522. Y01 = 0;
  523. }
  524. break;
  525. case 3:
  526. if(dwTickCount >= cDelayTime5)
  527. {
  528. if((user_datas[90] != 55))
  529. {
  530. M09 = 0;
  531. Y15 = 1; //超声开
  532. Y11 = 1;
  533. if(user_datas[6] > 150)
  534. cDelayTime5 = dwTickCount + (unsigned long)10 * 150; //超声时间
  535. else
  536. {
  537. if(X07 && (user_datas[28] < user_datas[6]))
  538. cDelayTime5 = dwTickCount + (unsigned long)10 * (user_datas[6] - user_datas[28]); //超声时间
  539. else
  540. cDelayTime5 = dwTickCount + (unsigned long)10 * user_datas[6]; //超声时间
  541. }
  542. Y04 = 0; //滚轮方式退送胶
  543. }
  544. else
  545. {
  546. cDelayTime5 = dwTickCount + (unsigned long)30;
  547. }
  548. cStepMByte3 = 4;
  549. }
  550. break;
  551. case 4:
  552. if(dwTickCount >= cDelayTime5)
  553. {
  554. cStepMByte3 = 5;
  555. Y15 = 0;
  556. Y11 = 0;
  557. TBStartCuiQi(); //启动吹气
  558. cDelayTime5 = dwTickCount + (unsigned long)5 * user_datas[7]; //固化时间一半
  559. }
  560. break;
  561. case 5:
  562. if(dwTickCount >= cDelayTime5)
  563. {
  564. cStepMByte3 = 6;
  565. Y01 = 0;
  566. cDelayTime5 = dwTickCount + (unsigned long)5 * user_datas[7]; //固化时间一半
  567. }
  568. break;
  569. case 6:
  570. if(dwTickCount >= cDelayTime5)
  571. {
  572. Y03 = 0; //上模关
  573. Y05 = 0; //下模或压带关
  574. cStepMByte3 = 7;
  575. }
  576. break;
  577. case 7:
  578. if(!X14)
  579. {
  580. cStepMByte3 = 8;
  581. cDelayTime5 = dwTickCount + (unsigned long)25;
  582. }
  583. break;
  584. case 8:
  585. if(dwTickCount >= cDelayTime5)
  586. {
  587. Y01 = 0; //勾针下
  588. cStepMByte3 = 0;
  589. cDelayTime5 = dwTickCount + (unsigned long)10 * 35;
  590. }
  591. break;
  592. }
  593. }
  594. void Hand_Action(void)
  595. {
  596. unsigned char ch;
  597. //手动勾针,屏单独控制
  598. if(M0004)
  599. {
  600. M04 = 0;//cMidleCoil[0] &= ~(1<<4); //M4
  601. if(Y01)
  602. {
  603. if(!Y03)CLRQ01;
  604. }
  605. else
  606. SETQ01;
  607. /*if(!X_DRV && (cStepMByte2 == 0))MoveAction_Const_AccDec(X_AXIS,MXC_DIR_P,10,1,1,2);
  608. else
  609. AxisEgmStop(X_AXIS); */
  610. user_datas[121]++;
  611. }
  612. //手动勾针
  613. if(X02)
  614. {// 送胶前  单勾针方式     滚轮送胶方式
  615. if(X02_UP && (!X16 || (SGZSelect == 1) || (SongJiaoMode == 1)))
  616. {
  617. Y01 = 1;
  618. }
  619. // 双勾针选择0 双勾针(新款) 1 单勾针
  620. if((SGZSelect == 0)) //没触摸屏时自动压带
  621. {
  622. //勾针到位
  623. if(Y01 && X20 && !Y05)
  624. {
  625. Y05 = 1;
  626. cDelayTime2 = dwTickCount + (unsigned long)10 * user_datas[3]; //压带输出时间
  627. }
  628. if(Y05 && (dwTickCount >= cDelayTime2))
  629. {
  630. Y01 = 0;
  631. }
  632. }
  633. }
  634. else if(!X02 && OLDX02)
  635. {
  636. Y01 = 0;
  637. if((SGZSelect == 0) && (!X02 && OLDX02))//没触摸屏时自动退压带
  638. Y05 = 0;
  639. }
  640. //压带,在双勾针方式时有效
  641. if(M0003)
  642. {
  643. M0003 = 0;//cMidleCoil[0] &= ~(1<<3); //M3
  644. //双勾针方式      下模不动
  645. if((SGZSelect == 0) && (XiaMoMode == 1))
  646. {
  647. if(Y05)
  648. Y05 = 0;
  649. else
  650. Y05 = 1;
  651. }
  652. }
  653. //手动前导板(分胶)
  654. //改动06.12.27 合模或双勾针 合模到位 上模 下模下到位 手动超声
  655. if(((X03 && !OLDX03) || M0013) && ((!Y05 && (!X15) && (SGZSelect == 1)) || ((SGZSelect == 0) && X15 && !X20)) &&
  656. (!Y03) && (!X14) && (!X06))
  657. {
  658. M0013 = 0;
  659. if(Y02 && !X03)Y02 = 0;
  660. else Y02 = 1;
  661. }
  662. else if(!X03 && OLDX03)Y02 = 0;
  663. //手动送胶 当单勾针时下模信号不能有 当为双勾针时要勾针退到位(X15是复用)
  664. if(Y04 && (X16 && !OLDX16))
  665. {
  666. //CLRQ06;
  667. }
  668. // 合模或双勾针 合模到位
  669. if((X05 || M0007) && ((!Y05 &&(!X15) && (SGZSelect == 1)) || ((SGZSelect == 0) && X15 && !X20))
  670. //上模 下模下到位 手动超声
  671. && (!Y03) && (!X14) && (!X06) && (!Y04 || (X05 && !OLDX05)))
  672. {
  673. if(CJSelect == XinYe)//鑫业的Y06为夹胶
  674. {
  675. if((X05 && !OLDX05) || (!Y06 && M0007))
  676. {
  677. Y06 = 1;
  678. cDelayTime1 = dwTickCount + (unsigned long)70;
  679. }
  680. else if(Y06 && (dwTickCount >= cDelayTime1))
  681. {
  682. Y04 = 1;
  683. M0007 = 0;//cMidleCoil[0] &= ~(1<<7); //M7
  684. }
  685. }
  686. else if(CJSelect == ChangSheng)//鑫业的Y06为夹胶
  687. {//手动送胶 普通拖带   二次拖带时勾针不能有输出
  688. if((X05_UP || M0007) && ((TWOTDSelect == 0) || ((TWOTDSelect == 1) && !Y01)))
  689. {
  690. Y04 = 1;
  691. M0007 = 0;
  692. }
  693. }
  694. }
  695. else if(!X05)
  696. {
  697. if(CJSelect == XinYe)//鑫业的Y06为夹胶
  698. {
  699. if((!X05 && OLDX05) || M0007)
  700. {
  701. M0007 = 0;
  702. Y06 = 0;
  703. cDelayTime1 = dwTickCount + (unsigned long)120;
  704. }
  705. else if(!Y06 && (dwTickCount >= cDelayTime1))
  706. {
  707. Y04 = 0;
  708. }
  709. if(!Y04 && (X17 && !OLDX17))
  710. {
  711. Y06 = 1;
  712. }
  713. }
  714. else if(CJSelect == ChangSheng)//鑫业的Y06为夹胶
  715. {
  716. if((!X05 && OLDX05) || M0007)
  717. {
  718. Y04 = 0;
  719. M0007 = 0;
  720. }
  721. }
  722. }
  723. //手动合模
  724. //手动下冲 分胶后 分胶前 送胶到位 退胶到位 或滚轮送胶
  725. if((X04 || M0008) && (X13 || FengJiaoSelect) && (!X12) && (((!X16) && X17) || (SongJiaoMode == 1))
  726. //超声输出
  727. && (!Y15))
  728. {
  729. if(M0008 && Y03 && !X04)
  730. {
  731. Y03 = 0;
  732. if(((SGZSelect == 0) && (XiaMoMode == 1)) || (XiaMoMode == 0))
  733. {
  734. Y05 = 0;
  735. }
  736. }
  737. //合模输出
  738. else if(((X04 && !OLDX04) || M0008) && !Y03 &&((SGZSelect == 0) && X15 && !X20) || ((SGZSelect == 1) && Y01))
  739. {
  740. Y03 = 1;
  741. if(XiaMoMode == 0) //下模活动方式
  742. Y05 = 1;
  743. }
  744. M0008 = 0;//cMidleCoil[0] &= ~(1<<8); //M8
  745. }
  746. else if((!X04 && OLDX04))
  747. {
  748. Y03 = 0;
  749. if(((SGZSelect == 0) && (XiaMoMode == 1)) || (XiaMoMode == 0))
  750. {
  751. Y05 = 0;
  752. }
  753. }
  754. if((X14 && !OLDX14)) //合模到位
  755. {
  756. // if(CJSelect != XinYe)
  757. // TBStartCuiQi(); //启动吹气
  758. }
  759. //手动超声
  760. // 分胶 送胶 分胶前 分胶后 送胶到位 退胶到位 送胶为滚轮方式
  761. if((X06 || ((M09 || M10) && !X06_DW)) && (!Y02) && (!Y04) && (!X12) && (X13 || FengJiaoSelect) && (((!X16) && X17) || (SongJiaoMode == 1)) && (dwTickCount >= cDelayTime5))
  762. {// 上超
  763. if((((SGZSelect == 0) && X15 && !X20) || (SGZSelect == 1)&& Y01) && !M12 )
  764. {
  765. if(XiaMoMode == 1) //下模不动
  766. {
  767. if(X14)//已经合模
  768. {
  769. if((X06_UP || M09) && (cStepMByte3 == 0))
  770. {
  771. cStepMByte3 = 3; //直接发超声(按设定时间)
  772. M10 = 1;
  773. }
  774. }
  775. else
  776. {
  777. if((X06_UP || M09) && !M10)
  778. {
  779. M10 = 1;//cMidleCoil[0] |= (1<<10); //M10
  780. user_datas[126]++;
  781. SETQ15; //发超声
  782. cDelayTime5 = dwTickCount + (unsigned long)10 * user_datas[6]; //限长时间2秒
  783. }
  784. else if(((!M09 && !X06) || (dwTickCount >= cDelayTime5)) && Y15)
  785. {
  786. M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
  787. M10 = 0;
  788. CLRQ15;
  789. TBStartCuiQi();
  790. }
  791. }
  792. }
  793. else if(SGZSelect == 1)//下模活动,勾针为单勾针
  794. {
  795. if((X06_UP || M09) && !M10)
  796. {
  797. M09 = 1;M10 = 1;//cMidleCoil[0] |= ((1<<10) | (1<<9)) ; //M10
  798. SETQ05; //先下模升上去
  799. if(X15) //先合模的情况下直接发超声
  800. {
  801. SETQ15; //发超声
  802. cDelayTime5 = dwTickCount + (unsigned long)10 * 200; //限长时间2秒
  803. }
  804. }
  805. if(Y05 && X15_UP)
  806. {
  807. SETQ15; //发超声
  808. cDelayTime5 = dwTickCount + (unsigned long)10 * 200; //限长时间2秒
  809. }
  810. if((!M09 || (dwTickCount >= cDelayTime5)) && Y15)
  811. {
  812. M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
  813. CLRQ15;
  814. cStepMByte3 = 4;
  815. }
  816. }
  817. //手动超声完成
  818. if(!M09 && !Y15 && !X06)
  819. {
  820. M10 = 0;//cMidleCoil[0] &= ~(1<<10); //M10
  821. cStepMByte3 = 0;
  822. user_datas[128] = 0;
  823. if(XiaMoMode == 0) //下模活动
  824. {
  825. CLRQ05;
  826. }
  827. }
  828. }
  829. else
  830. M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
  831. }
  832. else if(X06_DW)
  833. {
  834. M10 = 0;//cMidleCoil[0] &= ~(1<<10); //M10
  835. M09 = 0;//cMidleCoil[0] &= ~(1<<9); //M9
  836. CLRQ15;
  837. cStepMByte3 = 0;
  838. cDelayTime5 = dwTickCount + (unsigned long)10 * 30;
  839. if(XiaMoMode == 0) //下模活动
  840. {
  841. CLRQ05;
  842. }
  843. }
  844. //手动 上超
  845. // 分胶 分胶前 分胶后 送胶 送胶到位 退胶到位 手动超声
  846. if(M11 && !M12 && (!Y02) && (!X12) && (X13 || FengJiaoSelect) && (((!Y04) && (!X16) && X17) || (SongJiaoMode == 1))&& (!X06) && (dwTickCount >= cDelayTime5))
  847. {
  848. if(((SGZSelect == 0) && X15 && !X20) || ((SGZSelect == 1)&& Y01))
  849. {
  850. M12 = 1;//cMidleCoil[0] |= (1<<12); //M12
  851. cStepMByte3 = 1; //整个合模超声过程
  852. }
  853. M11 = 0;//cMidleCoil[0] &= ~(1<<11); //M11
  854. }
  855. else if((M12 && ((cStepMByte3 == 0) || M11)))
  856. {
  857. M11 = 0;//cMidleCoil[0] &= ~(1<<11); //M11
  858. M12 = 0;//cMidleCoil[0] &= ~(1<<12); //M12
  859. CLRQ03; //上模关
  860. CLRQ15; //超声关
  861. if((SGZSelect == 1) && (XiaMoMode == 0)) //下模活动
  862. CLRQ05; //下模或压带关
  863. cStepMByte3 = 0;
  864. cDelayTime5 = dwTickCount + (unsigned long)10 * 30;
  865. }
  866. //自动送胶动作
  867. if(M0018)
  868. {
  869. M18 = 0;
  870. if(!Y03 && !X14 && (XiaMoMode == 1) && !Y04)
  871. {
  872. M19 = 1;
  873. cStepMByte1 = 1; //分胶送开始
  874. }
  875. }
  876. }
  877. void Auto_Run(void)
  878. {
  879. switch(cStepMByte)
  880. {
  881. case 0:
  882. break;
  883. case 1:
  884. cStepMByte = 2;
  885. CLRDR();
  886. cDelayTime1 = dwTickCount + (unsigned long)200; //先锁轴
  887. cTest1 = 0;
  888. cSetEncode = 0;
  889. break;
  890. case 2: //第一条时
  891. if(dwTickCount >= cDelayTime1)
  892. {
  893. cStepMByte = 3;
  894. cStepMByte1 = 1; //分胶送开始
  895. MV_Set_Command_Pos_CPU(X_AXIS,0);
  896. if(!Y01)
  897. cStepMByte2 = 1; //拖带电机开始
  898. }
  899. break;
  900. case 3:
  901. // 送胶完成
  902. if((cStepMByte1 == 0) && (cStepMByte2 == 0))
  903. {
  904. cStepMByte = 4;
  905. if(cTest1 == 1)
  906. cSetEncode = cEncodePulse;
  907. if(DianJiFanZ == 1)
  908. cStepMByte2 = 20; //拖带电机反转一点
  909. else
  910. SETDR();
  911. cDelayTime1 = dwTickCount + (unsigned long)1000; // 退分胶到位要警告
  912. }
  913. break;
  914. case 4:
  915. //分胶 分胶前 分胶后 送胶 送胶到位 退胶到位 滚轮方式  双勾针方式时勾针要退到位       单勾针方式
  916. if((!Y02) && (!X12) && (X13 || FengJiaoSelect) && (((!Y04) &&(!X16) && X17) || (SongJiaoMode == 1))&& (((SGZSelect == 0) && X15 && !X20) || (SGZSelect == 1)))
  917. {
  918. if(cStepMByte2 == 0)
  919. {
  920. cStepMByte = 5;
  921. cStepMByte3 = 1;
  922. }
  923. }
  924. break;
  925. case 5:
  926. if(cStepMByte3 == 0)
  927. {
  928. cStepMByte = 6;
  929. CLRQ01;
  930. if(TBJ_cOneTimes == 1)
  931. {
  932. SETDR();
  933. tbj_bStop = 1;
  934. }
  935. else
  936. {
  937. CLRDR();
  938. CalProSP(78); //计算生产速度
  939. }
  940. AddToTal(76); //产量加1保存
  941. }
  942. break;
  943. case 6:
  944. if(!X14 && (((SGZSelect == 0) && X15 && !X20) || ((XiaMoMode == 0) && !X15) || ((XiaMoMode == 1) && (SGZSelect == 1)))) //上模离开
  945. {
  946. cStepMByte = 7;
  947. cDelayTime1 = dwTickCount + (unsigned long)30; //先锁轴
  948. }
  949. break;
  950. case 7:
  951. if(dwTickCount >= cDelayTime1)
  952. {
  953. cStepMByte = 2;
  954. cTest1++;
  955. if(cTest1 > 2)
  956. cTest1 = 3;
  957. }
  958. break;
  959. }
  960. }
  961. #endif