YXTWOChuantou_HeLian.c 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822
  1. #include "global.h"
  2. #if FJ_YING_XING_MACHINE == 1
  3. void YX_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag);
  4. void YX_CTHL_ManualAction(void);
  5. void YX_CTHL_AutoStepAction(void);
  6. void YX_CTHL_TD_Motor(void);
  7. void YX_CTHL_FZ_Motor(void);
  8. void YX_CTHL_CheckStart(void);
  9. void YX_CTHL_TLiao_Step(void); //推料(推拉头)
  10. void YX_CTHL_AlarmProtect(void);
  11. void YX_CTHL_ZLT_Step(void);
  12. void YX_CTHL_ZhenDongAction(void);
  13. void YX_CTHL_Color_Action(void);
  14. /*
  15. void YXExtiAcitionX02(void)
  16. {
  17. if(bCheckEN_FLG)
  18. {
  19. bCheckEN_FLG = 0;
  20. YX_CTHL_CheckInX02PosBuff = GetPos(X_AXIS);
  21. }
  22. }
  23. */
  24. void YX_CTHL_Color_Action(void)
  25. {
  26. if(bRunning && YX_CTHL_Colorcode_IN_UP)
  27. {
  28. YX_CTHL_ColorStep=1;
  29. }
  30. if(bRunning && YX_CTHL_XIAOCHA_IN_DW)
  31. {
  32. YX_CTHL_SetAlarmCode(YX_CTHL_XIAOCHA_ALARM,bRunning);
  33. }
  34. if(YX_CTHL_PARAM_COLOR_CODE)
  35. {
  36. switch(YX_CTHL_ColorStep)
  37. {
  38. case 1:
  39. {
  40. bRunning=0;
  41. cStopMode=0;
  42. bSingOneFlg=0;
  43. YX_CTHL_wltzi=0;
  44. YX_CTHL_MOTOR_MODE=0;
  45. AxisEgmStop(X_AXIS);
  46. AxisEgmStop(Y_AXIS);
  47. // SetEn(X_AXIS, MOTOR_DISEN);
  48. // SetEn(Y_AXIS, MOTOR_DISEN);
  49. YX_CTHL_AutoStep = 0;
  50. YX_CTHL_stop=0;
  51. YX_CTHL_FZ_MotorStep =0;
  52. YX_CTHL_TD_MotorStep =0;
  53. YX_CTHL_ZhuangLiaoStep=0;
  54. YX_CTHL_TLiao_VAVLE=0;
  55. YX_CTHL_HSLiao_VAVLE =0;
  56. YX_CTHL_JLTou_VAVLE =0;
  57. YX_CTHL_CTXM_VAVLE =0;
  58. YX_CTHL_FKGD_VAVLE =0;
  59. YX_CTHL_YADAI_VAVLE = 0;
  60. YX_CTHL_LYLun_VAVLE = 0; //
  61. YX_CTHL_RYLun_VAVLE = 0; //Y16插销压轮
  62. YX_CTHL_MGuo_VAVLE = 0;
  63. YX_CTHL_CXC_VAVLE = 0;
  64. YX_CTHL_GDQM_VAVLE =0;
  65. YX_CTHL_TQM_VAVLE=0;
  66. SetPos(X_AXIS, 0);
  67. SetPos(Y_AXIS, 0);
  68. SetEn(X_AXIS, MOTOR_EN);
  69. SetEn(Y_AXIS, MOTOR_EN);
  70. }
  71. YX_CTHL_ColorStep=2;
  72. YX_CTHL_bColor_Delay=dwTickCount+500;
  73. break;
  74. case 2:
  75. if(dwTickCount >= YX_CTHL_bColor_Delay)
  76. {
  77. if(YX_CTHL_AUTO_run_LENGTH)
  78. {
  79. AxisMovePosAccDec(X_AXIS,3000,YX_CTHL_AUTO_run_LENGTH,800,600,20,20,0);
  80. YX_CTHL_ColorStep=3;
  81. }
  82. else
  83. {
  84. YX_CTHL_SetAlarmCode(YX_CTHL_COLOR_IN_ALARM,bRunning);
  85. }
  86. }
  87. break;
  88. case 3:
  89. if(!X_DRV)
  90. {
  91. YX_CTHL_bYJDW=1;
  92. YX_CTHL_ColorStep=4;
  93. YX_CTHL_bColor_Delay=dwTickCount+20;
  94. }
  95. break;
  96. case 4:
  97. if(dwTickCount >= YX_CTHL_bColor_Delay)
  98. {
  99. if(YX_CTHL_TD_MotorStep==0)
  100. {
  101. bStart=1;
  102. YX_CTHL_ColorStep=0;
  103. }
  104. }
  105. break;
  106. }
  107. }
  108. else
  109. {
  110. YX_CTHL_ColorStep=0;
  111. }
  112. }
  113. //故障报警
  114. void YX_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag)
  115. {
  116. if(!YX_CTHL_cONERROR)
  117. {
  118. SetAlarmCode(YX_CTHL_ALARM_ADDR,alarm_code);
  119. YX_CTHL_cONERROR=1;
  120. }
  121. if(!YX_CTHL_wltzi)
  122. bAlarmStop = 1;
  123. else
  124. {
  125. YX_CTHL_AutoStep = 0;
  126. }
  127. }
  128. //初始化动作
  129. void YX_CTHL_InitAction(void)
  130. {
  131. float buff_pulse,buff_dist;
  132. buff_pulse = YX_CTHL_PARAM_TDCYCLE_PULSE;
  133. buff_dist = YX_CTHL_PARAM_TDCYCLE_LENGTH;
  134. XGearRatio = buff_pulse/buff_dist;
  135. buff_pulse = YX_CTHL_PARAM_TDCYCLE_PULSE;
  136. buff_dist = YX_CTHL_PARAM_FZCYCLE_LENGTH;
  137. YGearRatio = buff_pulse/buff_dist;
  138. buff_pulse = YX_CTHL_PARAM_TDCYCLE_PULSE;
  139. buff_dist = YX_CTHL_PARAM_FZLDCYCLE_LENGTH;
  140. ZGearRatio = buff_pulse/buff_dist;
  141. SetAlarmCode(YX_CTHL_ALARM_ADDR,0);
  142. user_datas[121] = 0;
  143. user_datas[122] = 0;
  144. user_datas[123] = 0;
  145. SetEnReverse(X_AXIS, 0);
  146. SetEnReverse(Y_AXIS, 0);
  147. SetEnReverse(Z_AXIS, 0);
  148. SetDirReverse(X_AXIS, 0);
  149. SetDirReverse(Y_AXIS, 0);
  150. SetDirReverse(Z_AXIS, 0);
  151. SetEn(X_AXIS, MOTOR_DISEN);
  152. SetEn(Y_AXIS, MOTOR_DISEN);
  153. SetEn(Z_AXIS, MOTOR_DISEN);
  154. SetPos(X_AXIS, 0); //启动位置设为0点
  155. SetPos(Y_AXIS, 0); //启动位置设为0点
  156. SetPos(Z_AXIS, 0); //启动位置设为0点
  157. }
  158. void YX_CTHL_Action(void)
  159. {
  160. dwXRealPos = GetPos(X_AXIS);
  161. dwYRealPos = GetPos(Y_AXIS);
  162. dwZRealPos = GetPos(Z_AXIS);
  163. user_datas[121] = YX_CTHL_ColorStep;
  164. user_datas[122] = dwYRealPos;
  165. user_datas[123] = dwXRealPos;
  166. user_datas[124] = YX_CTHL_TLiaoStep;
  167. user_datas[125] = YX_CTHL_ZhuangLiaoStep;
  168. user_datas[126] = YX_CTHL_FZ_MotorStep;
  169. user_datas[127] = YX_CTHL_TD_MotorStep;
  170. user_datas[128] = YX_CTHL_AutoStep;
  171. YX_CTHL_ZhenDongAction();
  172. YX_CTHL_AlarmProtect();
  173. YX_CTHL_CheckStart();
  174. YX_CTHL_ZLT_Step();
  175. YX_CTHL_TLiao_Step();
  176. YX_CTHL_Color_Action();
  177. YX_CTHL_TD_Motor();
  178. YX_CTHL_FZ_Motor();
  179. YX_CTHL_ManualAction();
  180. YX_CTHL_AutoStepAction();
  181. YX_CTHL_Test++;
  182. }
  183. void YX_CTHL_AlarmProtect(void)
  184. {
  185. }
  186. //自动动作
  187. void YX_CTHL_AutoStepAction(void)
  188. {
  189. //测试用
  190. if(dwTickCount >= YX_CTHL_TestDelay)
  191. {
  192. YX_CTHL_TestDelay = dwTickCount + 200;
  193. YX_CTHL_TestLED = !YX_CTHL_TestLED;
  194. YX_CTHL_Test = 0;
  195. }
  196. if(bRunning)
  197. {
  198. switch(YX_CTHL_AutoStep)
  199. {
  200. case 1:
  201. if(dwTickCount >= YX_CTHL_AutoDelay && YX_CTHL_TD_MotorStep==0 )
  202. {
  203. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  204. {
  205. YX_CTHL_LYLun_VAVLE = 0;
  206. YX_CTHL_RYLun_VAVLE = 0;
  207. YX_CTHL_CXC_VAVLE=0;
  208. YX_CTHL_GDQM_VAVLE=1;
  209. YX_CTHL_TQM_VAVLE=0;
  210. YX_CTHL_AutoStep = 2;
  211. YX_CTHL_AutoDelay = dwTickCount + 10;
  212. if(YX_CTHL_ZhuangLiaoStep == 0)
  213. {
  214. YX_CTHL_ZhuangLiaoStep = 1;
  215. YX_CTHL_TryCnt = 0;
  216. }
  217. }
  218. }
  219. break;
  220. case 2:
  221. if(bZhuangLiaoOkFlg && (YX_CTHL_ZhuangLiaoStep == 0))
  222. {
  223. if(dwTickCount >= YX_CTHL_AutoDelay && YX_CTHL_HSLiao_Origin_IN)
  224. {
  225. if(!YX_CTHL_LTou_Check )
  226. {
  227. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  228. {
  229. YX_CTHL_CTXM_VAVLE=1;
  230. YX_CTHL_AutoStep = 3;
  231. // YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_PARAM_GDQM_DELAY;
  232. }
  233. }
  234. else
  235. {
  236. YX_CTHL_wltzi=1;
  237. YX_CTHL_SetAlarmCode(YX_CTHL_ZLT_ALARM,bRunning); // 没有拉头
  238. }
  239. }
  240. }
  241. break;
  242. case 3:
  243. // if(dwTickCount >= YX_CTHL_AutoDelay)
  244. {
  245. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  246. {
  247. YX_CTHL_AutoStep = 4;
  248. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_VAVLE_ERROR_TIME;
  249. }
  250. }
  251. break;
  252. case 4:
  253. if(YX_CTHL_CTM_Limit_IN)
  254. {
  255. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  256. {
  257. YX_CTHL_GDQM_VAVLE=1;
  258. YX_CTHL_JLTou_VAVLE=0;
  259. if(!YX_CTHL_PARAM_QM_MODE)
  260. {
  261. YX_CTHL_AutoStep = 5;
  262. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_PARAM_QMFZ_DELAY;
  263. }
  264. else
  265. {
  266. YX_CTHL_AutoStep = 6;
  267. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_PARAM_TQM_DELAY;
  268. }
  269. }
  270. }
  271. else if(dwTickCount >= YX_CTHL_AutoDelay)
  272. {
  273. YX_CTHL_SetAlarmCode(YX_CTHL_CTM_Limit_ALARM,bRunning); // 没有拉头
  274. }
  275. break;
  276. case 5:
  277. if(dwTickCount >= YX_CTHL_AutoDelay)
  278. {
  279. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  280. {
  281. AxisMovePosAccDec(X_AXIS,5000,-YX_CTHL_PARAM_DWFZ_LENGTH,800,800,20,20,0);
  282. YX_CTHL_AutoStep = 6;
  283. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_PARAM_TQM_DELAY;
  284. }
  285. }
  286. break;
  287. case 6:
  288. if(dwTickCount >= YX_CTHL_AutoDelay && !X_DRV)
  289. {
  290. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  291. {
  292. YX_CTHL_LYLun_VAVLE=1;
  293. YX_CTHL_RYLun_VAVLE=1;
  294. YX_CTHL_TQM_VAVLE=1;
  295. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_VAVLE_ERROR_TIME; //延时输出压轮
  296. YX_CTHL_AutoStep = 7;
  297. }
  298. }
  299. break;
  300. case 7:
  301. if(YX_CTHL_TQM_Limit_IN)
  302. {
  303. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  304. {
  305. if(!YX_CTHL_PARAM_QM_MODE)
  306. YX_CTHL_GDQM_VAVLE=0;
  307. YX_CTHL_FZ_MotorStep=1;
  308. YX_CTHL_FZ_MotorDelay = dwTickCount + YX_CTHL_PARAM_GDQMTD_BACK_DELAY; //延时反转
  309. YX_CTHL_AutoStep =8;
  310. }
  311. }
  312. else if(dwTickCount >= YX_CTHL_AutoDelay)
  313. {
  314. YX_CTHL_SetAlarmCode(YX_CTHL_TQM_Limit_ALARM,bRunning); // 没有拉头
  315. }
  316. break;
  317. case 8:
  318. if(YX_CTHL_FZ_MotorStep == 0)
  319. {
  320. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  321. {
  322. YX_CTHL_RYLun_VAVLE=0;//大插压轮
  323. YX_CTHL_FZ_MotorStep=20;
  324. YX_CTHL_AutoStep =9;
  325. YX_CTHL_FZ_MotorDelay = dwTickCount + YX_CTHL_PARAM_XCDWTD_BACK_DELAY; //小插定位延时拖带
  326. }
  327. }
  328. break;
  329. case 9:
  330. if(YX_CTHL_FZ_MotorStep == 0)
  331. {
  332. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  333. {
  334. bZhuangLiaoOkFlg=0;
  335. YX_CTHL_CXC_VAVLE=1;
  336. YX_CTHL_LYLun_VAVLE=0;
  337. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_PARAM_TXCYL_BACK_DELAY; //延时退小插压轮
  338. YX_CTHL_AutoStep =10;
  339. }
  340. }
  341. break;
  342. case 10:
  343. if(dwTickCount >= YX_CTHL_AutoDelay)
  344. {
  345. if(!YX_CTHL_bDanBu_MODE || YX_CTHL_START_IN_UP)
  346. {
  347. YX_CTHL_TD_MotorStep=10;
  348. YX_CTHL_TD_MotorDelay = dwTickCount + YX_CTHL_PARAM_YSHL_DELAY; //延时合链
  349. YX_CTHL_AutoStep =11;
  350. YX_CTHL_AutoDelay1 = dwTickCount + YX_CTHL_MOTOR_ALARM_TIME;
  351. YX_CTHL_AutoStep1=1;
  352. }
  353. }
  354. break;
  355. /*
  356. case 10:
  357. if(YX_CTHL_FK_Check_DW)
  358. {
  359. YX_CTHL_AutoStep =11;
  360. YX_CTHL_AutoDelay = dwTickCount + YX_CTHL_PARAM_GYH_DELAY;
  361. }
  362. break;*/
  363. case 11:
  364. /* if(dwTickCount >= YX_CTHL_AutoDelay)
  365. {
  366. YX_CTHL_FKGD_VAVLE=0;
  367. YX_CTHL_CXC_VAVLE=0;
  368. }*/
  369. if(YX_CTHL_TD_MotorStep==0 && (!YX_CTHL_CTXM_VAVLE ))
  370. {
  371. YX_CTHL_AutoStep = 2;
  372. AddToTal(YX_CTHL_TOTAL_ADDR);
  373. AddToTal(YX_CTHL_TRUST_ALARM_ADDR);
  374. AddToTal( YX_CTHL_TEST_ALARM_ADDR);
  375. CalProSP(YX_CTHL_SPEED_ADDR);
  376. YX_CTHL_cONERROR=0;
  377. if(YX_CTHL_cZipCnt<3)
  378. YX_CTHL_cZipCnt++;
  379. }
  380. break;
  381. }
  382. }
  383. //退下模后启动送拉头
  384. switch(YX_CTHL_AutoStep1)
  385. {
  386. case 1:
  387. if(YX_CTHL_CTM_Origin_IN)
  388. {
  389. YX_CTHL_ZhuangLiaoStep = 1;
  390. YX_CTHL_TryCnt = 0;
  391. bZhuangLiaoOkFlg=0;
  392. YX_CTHL_AutoStep1 = 0;
  393. YX_CTHL_MGuo_VAVLE = 0;
  394. }
  395. /*
  396. else if(dwTickCount >= YX_CTHL_AutoDelay1)
  397. {
  398. //穿头模和一次穿入回位异常
  399. if(!YX_CTHL_CTM_Origin_IN)
  400. YX_CTHL_SetAlarmCode(YX_CTHL_CTM_Origin_ALARM,bRunning);
  401. } */
  402. break;
  403. }
  404. }
  405. void YX_CTHL_CheckStart(void)
  406. {
  407. /*
  408. if(YX_CTHL_SGY_START_IN)
  409. {
  410. YX_CTHL_MOTOR_MODE=1;
  411. SetEn(Z_AXIS, MOTOR_EN);
  412. // SetPos(Z_AXIS, 0); //启动位置设为0点
  413. YX_CTHL_AutoDelay = dwTickCount + 100;
  414. if(!Z_DRV)
  415. {
  416. // Y轴 运行速度 启动速度 加速度 减速度
  417. AxisContinueMoveAcc(Z_AXIS,6000,DIR_P,1000,1000,15,15);
  418. }
  419. }
  420. if(YX_CTHL_XGY_STOP_IN || (dwTickCount >= YX_CTHL_AutoDelay && YX_CTHL_MOTOR_MODE) )
  421. {
  422. YX_CTHL_MOTOR_MODE=0;
  423. AxisEgmStop(Z_AXIS);
  424. }
  425. */
  426. #if 1
  427. if(YX_CTHL_wltzi)
  428. {
  429. if(YX_CTHL_START_IN_UP || bStart || YX_CTHL_bSingOne )
  430. {
  431. YX_CTHL_wltzi=0;
  432. // if(!YX_CTHL_CTM_Origin_IN) YX_CTHL_SetAlarmCode(YX_CTHL_CTM_Origin_ALARM,bRunning);
  433. if(!YX_CTHL_FKJC)
  434. {
  435. if(bRunning)
  436. {
  437. YX_CTHL_cONERROR=0;
  438. YX_CTHL_CTXM_VAVLE =0;
  439. YX_CTHL_AutoStep = 1;
  440. YX_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
  441. YX_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
  442. YX_CTHL_ZhuangLiaoStep=1;
  443. }
  444. }
  445. }
  446. }
  447. //启动 自动启动 单一自动
  448. if((YX_CTHL_START_IN_UP || bStart || YX_CTHL_bSingOne ) && !YX_CTHL_wltzi)
  449. {
  450. // if(!YX_CTHL_CTM_Origin_IN) YX_CTHL_SetAlarmCode(YX_CTHL_CTM_Origin_ALARM,bRunning);
  451. if(!bRunning)
  452. {
  453. bRunning = 1;
  454. if( YX_CTHL_bSingOne)
  455. {
  456. bSingOneFlg=1;
  457. }
  458. SetEn(X_AXIS, MOTOR_EN);
  459. SetEn(Y_AXIS, MOTOR_EN);
  460. SetEn(Z_AXIS, MOTOR_EN);
  461. YX_CTHL_FZ_MotorStep = 0;
  462. YX_CTHL_cONERROR=0;
  463. bTuiLaTouOkFlg = 1;
  464. bZhuangLiaoOkFlg= 0;
  465. YX_CTHL_TryCnt = 0;
  466. bCL_EN_FLG = 0;
  467. YX_CTHL_MOTOR_MODE=0;
  468. YX_CTHL_stop=0;
  469. YX_CTHL_cZipCnt = 0;
  470. SetAlarmCode(YX_CTHL_ALARM_ADDR,0);
  471. YX_CTHL_AutoDelay = dwTickCount + 0;
  472. YX_CTHL_CTXM_VAVLE =0;
  473. YX_CTHL_FKGD_VAVLE =0;
  474. YX_CTHL_YADAI_VAVLE = 0;
  475. YX_CTHL_LYLun_VAVLE = 0; //
  476. YX_CTHL_RYLun_VAVLE = 0; //Y16插销压轮
  477. YX_CTHL_CXC_VAVLE = 0;
  478. // YX_CTHL_GDQM_VAVLE =0;
  479. YX_CTHL_TQM_VAVLE=0;
  480. if(!YX_CTHL_GDQM_VAVLE)
  481. {
  482. YX_CTHL_TD_MotorStep = 1;
  483. YX_CTHL_TD_MotorDelay = dwTickCount + 300;
  484. }
  485. else
  486. YX_CTHL_TD_MotorStep=0;
  487. YX_CTHL_AutoStep = 1;
  488. YX_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
  489. YX_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
  490. YX_CTHL_ZhuangLiaoStep=1;
  491. }
  492. bStart = 0;
  493. YX_CTHL_bSingOne=0;
  494. }
  495. if(YX_CTHL_ZhouWantwo)
  496. {
  497. YX_CTHL_ZhouWantwo=0;
  498. if(YX_CTHL_ZhouWanone)
  499. {
  500. YX_CTHL_ZhouWanone=0;
  501. bRunning=0;
  502. cStopMode=0;
  503. AxisEgmStop(X_AXIS);
  504. AxisEgmStop(Y_AXIS);
  505. SetEn(X_AXIS, MOTOR_DISEN);
  506. SetEn(Y_AXIS, MOTOR_DISEN);
  507. bSingOneFlg=0;
  508. YX_CTHL_AutoStep = 0;
  509. YX_CTHL_FZ_MotorStep =0;
  510. YX_CTHL_TD_MotorStep =0;
  511. }
  512. }
  513. //停止
  514. if(YX_CTHL_STOP_IN_UP || bStop)
  515. {
  516. if(cStopMode < 2)
  517. cStopMode++;
  518. if(cStopMode==1 && bRunning)
  519. YX_CTHL_ZhouWanone=1;
  520. if(bRunning && cStopMode == 2)
  521. {
  522. bRunning=0;
  523. cStopMode=0;
  524. bSingOneFlg=0;
  525. YX_CTHL_wltzi=0;
  526. YX_CTHL_MOTOR_MODE=0;
  527. AxisEgmStop(X_AXIS);
  528. AxisEgmStop(Y_AXIS);
  529. AxisEgmStop(Z_AXIS);
  530. SetEn(X_AXIS, MOTOR_DISEN);
  531. SetEn(Y_AXIS, MOTOR_DISEN);
  532. SetEn(Z_AXIS, MOTOR_DISEN);
  533. YX_CTHL_AutoStep = 0;
  534. YX_CTHL_stop=0;
  535. YX_CTHL_FZ_MotorStep =0;
  536. YX_CTHL_TD_MotorStep =0;
  537. YX_CTHL_ZhuangLiaoStep=0;
  538. YX_CTHL_TLiao_VAVLE=0;
  539. YX_CTHL_HSLiao_VAVLE =0;
  540. YX_CTHL_JLTou_VAVLE =0;
  541. YX_CTHL_CTXM_VAVLE =0;
  542. YX_CTHL_FKGD_VAVLE =0;
  543. YX_CTHL_YADAI_VAVLE = 0;
  544. YX_CTHL_LYLun_VAVLE = 0; //
  545. YX_CTHL_RYLun_VAVLE = 0; //Y16插销压轮
  546. YX_CTHL_MGuo_VAVLE = 0;
  547. YX_CTHL_CXC_VAVLE = 0;
  548. YX_CTHL_GDQM_VAVLE =0;
  549. YX_CTHL_TQM_VAVLE=0;
  550. SetPos(X_AXIS, 0);
  551. SetPos(Y_AXIS, 0);
  552. SetPos(Z_AXIS, 0);
  553. SetAlarmCode(YX_CTHL_ALARM_ADDR,0);
  554. }
  555. else if(!bRunning)
  556. {
  557. bRunning=0;
  558. cStopMode=0;
  559. bSingOneFlg=0;
  560. YX_CTHL_wltzi=0;
  561. YX_CTHL_stop=0;
  562. YX_CTHL_MOTOR_MODE=0;
  563. YX_CTHL_RunStepSave = 0;
  564. AxisEgmStop(X_AXIS);
  565. AxisEgmStop(Y_AXIS);
  566. AxisEgmStop(Z_AXIS);
  567. SetEn(X_AXIS, MOTOR_DISEN);
  568. SetEn(Y_AXIS, MOTOR_DISEN);
  569. SetEn(Z_AXIS, MOTOR_DISEN);
  570. YX_CTHL_TLiao_VAVLE=0;
  571. YX_CTHL_HSLiao_VAVLE =0;
  572. YX_CTHL_JLTou_VAVLE =0;
  573. YX_CTHL_CTXM_VAVLE =0;
  574. YX_CTHL_FKGD_VAVLE =0;
  575. YX_CTHL_YADAI_VAVLE = 0;
  576. YX_CTHL_LYLun_VAVLE = 0; //
  577. YX_CTHL_RYLun_VAVLE = 0; //Y16插销压轮
  578. YX_CTHL_MGuo_VAVLE = 0;
  579. YX_CTHL_CXC_VAVLE = 0;
  580. YX_CTHL_GDQM_VAVLE =0;
  581. YX_CTHL_TQM_VAVLE=0;
  582. YX_CTHL_AutoStep = 0;
  583. YX_CTHL_ZhuangLiaoStep=0;
  584. YX_CTHL_TLiaoStep=0;
  585. YX_CTHL_TD_MotorStep=0;
  586. YX_CTHL_SongLiaoStep =0;
  587. YX_CTHL_FZ_MotorStep =0;
  588. YX_CTHL_AutoStep1 =0;
  589. SetAlarmCode(YX_CTHL_ALARM_ADDR,0);
  590. SetPos(X_AXIS, 0);
  591. SetPos(Y_AXIS, 0);
  592. SetPos(Z_AXIS, 0);
  593. YX_CTHL_TLiaoStep = 0;
  594. YX_CTHL_AutoStep = 0;
  595. YX_CTHL_bQDinWeiOK = 0;
  596. YX_CTHL_LianLengthCheck = 0;
  597. YX_CTHL_LianLengthCheckOld = 0;
  598. }
  599. bStop=0;
  600. }
  601. if(bAlarmStop)
  602. {
  603. bRunning = 0;
  604. bAlarmStop=0;
  605. cStopMode=0;
  606. cXcxcrCnt=0;
  607. AxisEgmStop(X_AXIS);
  608. AxisEgmStop(Y_AXIS);
  609. AxisEgmStop(Z_AXIS);
  610. YX_CTHL_AutoStep = 0;
  611. YX_CTHL_FZ_MotorStep =0;
  612. YX_CTHL_TD_MotorStep =0;
  613. }
  614. #endif
  615. }
  616. //拖带电机控制动作 X轴
  617. void YX_CTHL_TD_Motor(void) //
  618. {
  619. #if 1
  620. switch(YX_CTHL_TD_MotorStep)
  621. {
  622. //1步开始,纯定位, 没有穿入
  623. case 1:
  624. if(dwTickCount >= YX_CTHL_TD_MotorDelay) //给锁轴时间
  625. {
  626. bCheckEN_FLG = 1;
  627. YX_CTHL_CheckInX02PosBuff=0;
  628. YX_CTHL_TD_MotorStep = 2;
  629. SetPos(X_AXIS, 0); //启动位置设为0点
  630. // SetPos(Y_AXIS, 0); //启动位置设为0点
  631. dwXRealPos=0;
  632. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_TD_RunSpeed * 66/100,DIR_P,1500,600,25,20);
  633. AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_TD_RunSpeed * 1/2,DIR_N,1500,600,25,20);
  634. // AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_TD_RunSpeed * 2/3,DIR_N,1500,600,15,15);
  635. YX_CTHL_bQDinWeiOK = 0;
  636. }
  637. break;
  638. case 2:
  639. if(dwXRealPos > 100)
  640. {
  641. if(YX_CTHL_FK_Check_UP )
  642. {
  643. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_BinLin_SPEED,DIR_P,3000,600,20,25);
  644. AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_BinLin_SPEED,DIR_N,3000,600,20,25);
  645. SetStartSpeed(X_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  646. SetStartSpeed(Y_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  647. AxisChangeSpeed(X_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  648. AxisChangeSpeed(Y_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  649. YX_CTHL_TD_MotorStep = 3;
  650. YX_CTHL_YADAI_VAVLE=1;
  651. }
  652. }
  653. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  654. {
  655. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  656. }
  657. break;
  658. case 3://检测到过链
  659. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  660. {
  661. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  662. }
  663. if(YX_CTHL_FKDWE_IN_UP)
  664. {
  665. YX_CTHL_TD_MotorDelay = dwTickCount + YX_CTHL_PARAM_GYH_DELAY;
  666. YX_CTHL_XSavePosBuff = dwXRealPos;
  667. AxisMovePosAccDec(X_AXIS,YX_CTHL_PARAM_FKDW_Speed,YX_CTHL_PARAM_FKDW_Length,
  668. 1000,1000,20,130,50);
  669. AxisMovePosAccDec(Y_AXIS,YX_CTHL_PARAM_FKDW_Speed*1/2,-YX_CTHL_PARAM_FKDW_Length,
  670. 1000,1000,20,130,50);
  671. // AxisMovePosAccDec(Y_AXIS,YX_CTHL_PARAM_TD_RunSpeed * 2/3,-YX_CTHL_PARAM_FKDW_Length,
  672. // YX_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,10,50,150);
  673. YX_CTHL_TD_MotorStep = 4;
  674. }
  675. break;
  676. case 4:
  677. if(dwTickCount >= YX_CTHL_TD_MotorDelay)
  678. {
  679. YX_CTHL_GDQM_VAVLE=1;
  680. }
  681. if(!X_DRV || (dwXRealPos >= (YX_CTHL_XSavePosBuff + YX_CTHL_PARAM_FKDW_Length)))
  682. {
  683. YX_CTHL_TD_MotorStep = 0;
  684. AxisEgmStop(X_AXIS);
  685. AxisEgmStop(Y_AXIS);
  686. }
  687. break;
  688. //穿拉头定位
  689. case 10:
  690. if(dwTickCount >= YX_CTHL_TD_MotorDelay)
  691. {
  692. YX_CTHL_TD_MotorDelay = dwTickCount + YX_CTHL_PARAM_TCXC_BACK_DELAY;
  693. YX_CTHL_TD_MotorStep = 50;
  694. SetPos(X_AXIS, 0); //启动位置设为0点
  695. AxisContinueMoveAcc(X_AXIS,3000,DIR_P,1500,600,20,20);
  696. AxisContinueMoveAcc(Y_AXIS,1500,DIR_N,1500,600,20,20);
  697. YX_CTHL_XSavePosBuff = dwXRealPos;
  698. bCheckEN_FLG = 1;
  699. }
  700. break;
  701. case 50:
  702. if(dwTickCount >= YX_CTHL_TD_MotorDelay)
  703. {
  704. YX_CTHL_FKGD_VAVLE=0;
  705. YX_CTHL_CXC_VAVLE=0;
  706. }
  707. if(!YX_CTHL_FKGD_VAVLE)
  708. {
  709. YX_CTHL_TD_MotorDelay = dwTickCount + 20;
  710. YX_CTHL_TD_MotorStep = 11;
  711. }
  712. break;
  713. case 11:
  714. if(dwTickCount >= YX_CTHL_TD_MotorDelay)
  715. {
  716. YX_CTHL_XSavePosBuff3=dwXRealPos;
  717. if((YX_CTHL_cZipCnt < 2) || (YX_CTHL_LianLengthAutoCRCDcheck < 350))
  718. {
  719. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_HLT_SPEED_Speed * 66/100,DIR_P,3000,600,20,20);
  720. AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_HLT_SPEED_Speed * 1/2,DIR_N,3000,600,20,20);
  721. }
  722. else
  723. {
  724. AxisMovePosAccDecNotStop(X_AXIS,YX_CTHL_PARAM_HLT_SPEED_Speed,YX_CTHL_LianLengthAutoCRCDcheck-YX_CTHL_XSavePosBuff3,1000,YX_CTHL_PARAM_FKDW_Speed,30,300,250);
  725. AxisMovePosAccDecNotStop(Y_AXIS,YX_CTHL_PARAM_HLT_SPEED_Speed*1/2,-(YX_CTHL_LianLengthAutoCRCDcheck-YX_CTHL_XSavePosBuff3),1000,YX_CTHL_PARAM_FKDW_Speed,30,300,250);
  726. }
  727. YX_CTHL_TD_MotorStep = 12;
  728. YX_CTHL_FKJC=0;
  729. }
  730. if(YX_CTHL_cZipCnt < 2)
  731. {
  732. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  733. {
  734. YX_CTHL_SetAlarmCode(YX_CTHL_FKYC_ALARM,bRunning); //无拉链自动停机
  735. }
  736. }
  737. else
  738. {
  739. if((YX_CTHL_LianLengthAutoFZcheck<YX_CTHL_LianLengthAutoCRCDcheck*0.7) && (YX_CTHL_LianLengthAutoFZcheck<1500))
  740. {
  741. if(dwXRealPos >= 300)
  742. {
  743. YX_CTHL_LYLun_VAVLE=1;
  744. YX_CTHL_RYLun_VAVLE=1;
  745. YX_CTHL_MGuo_VAVLE=0;
  746. YX_CTHL_CTXM_VAVLE=0;
  747. AxisEgmStop(X_AXIS);
  748. AxisEgmStop(Y_AXIS);
  749. YX_CTHL_TD_MotorStep = 13;
  750. }
  751. }
  752. if(dwXRealPos >= (100+YX_CTHL_LianLengthAutoCRCDcheck))
  753. {
  754. YX_CTHL_MGuo_VAVLE=0;
  755. YX_CTHL_CTXM_VAVLE=0;
  756. }
  757. if(dwXRealPos >=(YX_CTHL_PARAM_WLCDSHEZHI_LENTH+ YX_CTHL_LianLengthAutoCRCDcheck))
  758. {
  759. YX_CTHL_SetAlarmCode(YX_CTHL_FKYC_ALARM,bRunning); //无拉链自动停机
  760. }
  761. }
  762. break;
  763. case 12:
  764. if(YX_CTHL_cZipCnt < 2)
  765. {
  766. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  767. {
  768. YX_CTHL_SetAlarmCode(YX_CTHL_FKYC_ALARM,bRunning); //无拉链自动停机
  769. }
  770. }
  771. else
  772. {
  773. if((YX_CTHL_LianLengthAutoFZcheck<YX_CTHL_LianLengthAutoCRCDcheck*0.7) && (YX_CTHL_LianLengthAutoFZcheck<1500))
  774. {
  775. if(dwXRealPos >= 300)
  776. {
  777. YX_CTHL_LYLun_VAVLE=1;
  778. YX_CTHL_RYLun_VAVLE=1;
  779. YX_CTHL_MGuo_VAVLE=0;
  780. YX_CTHL_CTXM_VAVLE=0;
  781. AxisEgmStop(X_AXIS);
  782. AxisEgmStop(Y_AXIS);
  783. YX_CTHL_TD_MotorStep = 13;
  784. if(YX_CTHL_cZipCnt ==1 )
  785. YX_CTHL_LianLengthAutoCRCDcheck=dwXRealPos;
  786. if(YX_CTHL_cZipCnt >1 && dwXRealPos < YX_CTHL_LianLengthAutoCRCDcheck*0.8)
  787. {
  788. YX_CTHL_cZipCnt=0;
  789. }
  790. }
  791. }
  792. if(dwXRealPos >= (100+YX_CTHL_LianLengthAutoCRCDcheck))
  793. {
  794. YX_CTHL_MGuo_VAVLE=0;
  795. YX_CTHL_CTXM_VAVLE=0;
  796. }
  797. if(dwXRealPos >=(YX_CTHL_PARAM_WLCDSHEZHI_LENTH+ YX_CTHL_LianLengthAutoCRCDcheck))
  798. {
  799. YX_CTHL_SetAlarmCode(YX_CTHL_FKYC_ALARM,bRunning); //无拉链自动停机
  800. }
  801. }
  802. if(YX_CTHL_FK_Check_UP)
  803. {
  804. YX_CTHL_LYLun_VAVLE=1;
  805. YX_CTHL_RYLun_VAVLE=1;
  806. AxisEgmStop(X_AXIS);
  807. AxisEgmStop(Y_AXIS);
  808. YX_CTHL_TD_MotorDelay= dwTickCount+YX_CTHL_PARAM_TJSJ_TIME;
  809. if(YX_CTHL_cZipCnt ==1 )
  810. YX_CTHL_LianLengthAutoCRCDcheck=dwXRealPos;
  811. if(YX_CTHL_cZipCnt >1 && dwXRealPos < YX_CTHL_LianLengthAutoCRCDcheck*0.8)
  812. {
  813. YX_CTHL_cZipCnt=0;
  814. }
  815. YX_CTHL_MGuo_VAVLE=0;
  816. YX_CTHL_CTXM_VAVLE=0;
  817. YX_CTHL_XSavePosBuff = dwXRealPos;
  818. if(cStopMode==1 || bSingOneFlg)
  819. {
  820. // cStopMode=2;
  821. YX_CTHL_ZhouWantwo=1;
  822. }
  823. else
  824. {
  825. YX_CTHL_TD_MotorStep = 13;
  826. }
  827. if(bSingOneFlg)
  828. {
  829. YX_CTHL_AutoStep = 0;
  830. bRunning = 0;
  831. YX_CTHL_TD_MotorStep = 0;
  832. bSingOneFlg = 0;
  833. }
  834. }
  835. break;
  836. case 13:
  837. if(dwXRealPos > 350)
  838. {
  839. YX_CTHL_CheckInX02PosBuff=0;
  840. }
  841. if(YX_CTHL_CTM_Origin_IN)//YX_CTHL_FKDWE_IN_UP)
  842. {
  843. YX_CTHL_LianLengthAutoSECONDcheck=dwXRealPos;
  844. YX_CTHL_TD_MotorStep = 14;
  845. if((YX_CTHL_cZipCnt < 2) || (YX_CTHL_LianLengthAutoSECONDONEcheck < 350))
  846. {
  847. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_TD_RunSpeed * 66/100,DIR_P,3000,600,20,25);
  848. AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_TD_RunSpeed * 66/100,DIR_N,3000,600,20,25);
  849. }
  850. else
  851. {
  852. AxisMovePosAccDecNotStop(X_AXIS,YX_CTHL_PARAM_TD_RunSpeed,YX_CTHL_LianLengthAutoSECONDONEcheck,1500,YX_CTHL_PARAM_FKDW_Speed,25,300,250);
  853. AxisMovePosAccDecNotStop(Y_AXIS,YX_CTHL_PARAM_TD_RunSpeed,-YX_CTHL_LianLengthAutoSECONDONEcheck,1500,YX_CTHL_PARAM_FKDW_Speed,25,300,250);
  854. }
  855. }
  856. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  857. {
  858. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  859. }
  860. break;
  861. case 14:
  862. if(dwXRealPos>(YX_CTHL_LianLengthAutoSECONDcheck+800))
  863. {
  864. if(YX_CTHL_FK_Check_UP)
  865. {
  866. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_BinLin_SPEED,DIR_P,3000,600,20,25);
  867. AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_BinLin_SPEED,DIR_N,3000,600,20,25);
  868. SetStartSpeed(X_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  869. SetStartSpeed(Y_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  870. AxisChangeSpeed(X_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  871. AxisChangeSpeed(Y_AXIS,YX_CTHL_PARAM_BinLin_SPEED);
  872. YX_CTHL_YADAI_VAVLE=1;
  873. YX_CTHL_TD_MotorStep = 15;
  874. }
  875. }
  876. if(YX_CTHL_cZipCnt > 1)
  877. {
  878. if(dwXRealPos >= (YX_CTHL_PARAM_WLCDSHEZHI_LENTH+YX_CTHL_LianLengthAutoCheck))
  879. {
  880. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  881. }
  882. if(dwXRealPos>(YX_CTHL_LianLengthAutoCheck- YX_CTHL_PARAM_YAdai_lenth))
  883. {
  884. YX_CTHL_YADAI_VAVLE=1;
  885. }
  886. }
  887. else
  888. {
  889. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length+ YX_CTHL_LianLengthAutoFZcheck)
  890. {
  891. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  892. }
  893. }
  894. break;
  895. case 15://检测到过链
  896. if(YX_CTHL_cZipCnt > 1)
  897. {
  898. if(dwXRealPos >= (YX_CTHL_PARAM_WLCDSHEZHI_LENTH+YX_CTHL_LianLengthAutoCheck))
  899. {
  900. YX_CTHL_AUTO_start=2;
  901. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  902. }
  903. }
  904. else
  905. {
  906. if(dwXRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length+ YX_CTHL_LianLengthAutoFZcheck)
  907. {
  908. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  909. }
  910. if(dwXRealPos>(YX_CTHL_LianLengthAutoCheck- YX_CTHL_PARAM_YAdai_lenth))
  911. {
  912. YX_CTHL_YADAI_VAVLE=1;
  913. }
  914. }
  915. if(YX_CTHL_FKDWE_IN_UP)
  916. {
  917. YX_CTHL_YADAI_VAVLE=1;
  918. YX_CTHL_TD_MotorDelay = dwTickCount + YX_CTHL_PARAM_GYH_DELAY;
  919. YX_CTHL_XSavePosBuff = dwXRealPos;
  920. if(YX_CTHL_cZipCnt ==1)
  921. YX_CTHL_LianLengthAutoSECONDONEcheck= dwXRealPos-YX_CTHL_LianLengthAutoSECONDcheck;
  922. AxisMovePosAccDec(X_AXIS,YX_CTHL_PARAM_FKDW_Speed,YX_CTHL_PARAM_FKDW_Length,
  923. 1000,1000,20,250,50);
  924. AxisMovePosAccDec(Y_AXIS,YX_CTHL_PARAM_FKDW_Speed,-YX_CTHL_PARAM_FKDW_Length,
  925. 1000,1000,20,250,50);
  926. YX_CTHL_TD_MotorStep = 16;
  927. }
  928. break;
  929. case 16:
  930. if(dwTickCount >= YX_CTHL_TD_MotorDelay)
  931. {
  932. YX_CTHL_GDQM_VAVLE=1;
  933. }
  934. if(!X_DRV || (dwXRealPos >= (YX_CTHL_XSavePosBuff + YX_CTHL_PARAM_FKDW_Length)))
  935. {
  936. YX_CTHL_LYLun_VAVLE=0;
  937. YX_CTHL_RYLun_VAVLE=0;
  938. YX_CTHL_TD_MotorStep = 0;
  939. AxisEgmStop(X_AXIS);
  940. AxisEgmStop(Y_AXIS);
  941. YX_CTHL_LianLengthAutoTHREEcheck= dwXRealPos;
  942. if(YX_CTHL_cZipCnt ==1)
  943. YX_CTHL_LianLengthAutoCheck = dwXRealPos;
  944. }
  945. break;
  946. }
  947. #endif
  948. }
  949. //穿入电机动作,Y轴
  950. void YX_CTHL_FZ_Motor(void) //
  951. {
  952. #if 1
  953. //1步开始, 穿链反转长度开始
  954. //20步开始 插销定位开始
  955. switch(YX_CTHL_FZ_MotorStep)
  956. {
  957. //穿入长度位置
  958. case 1:
  959. if(dwTickCount >= YX_CTHL_FZ_MotorDelay)
  960. {
  961. SetPos(Y_AXIS, 0); //启动位置设为0点
  962. AxisContinueMoveAcc(Y_AXIS,YX_CTHL_PARAM_CRSD_SPEED,DIR_P,1000,1200,15,20);
  963. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_CRSD_SPEED*YX_CTHL_PARAM_FMOTOR_BILI,DIR_N,1000,1200,15,20);
  964. YX_CTHL_FZ_MotorStep=2;
  965. YX_CTHL_YADAI_VAVLE=0;
  966. }
  967. break;
  968. case 2:
  969. if(YX_CTHL_cZipCnt < 2)
  970. {
  971. if(dwYRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  972. {
  973. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  974. }
  975. }
  976. else
  977. {
  978. if(dwYRealPos >= (YX_CTHL_PARAM_WLCDSHEZHI_LENTH+ YX_CTHL_LianLengthAutoFZcheck))
  979. {
  980. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  981. }
  982. }
  983. if(dwYRealPos>YX_CTHL_PARAM_XKCR_LENGTH)
  984. {
  985. YX_CTHL_TQM_VAVLE=0;
  986. YX_CTHL_GDQM_VAVLE=0;
  987. if(YX_CTHL_cZipCnt<2)
  988. {
  989. AxisContinueMoveAcc(X_AXIS,YX_CTHL_PARAM_FZ_Speed * 2/3,DIR_N,3000,600,25,30);
  990. AxisContinueMoveAcc(Y_AXIS,(YX_CTHL_PARAM_FZ_Speed * 2/3),DIR_P,3000,600,25,30);
  991. }
  992. else
  993. {
  994. AxisMovePosAccDecNotStop(X_AXIS,YX_CTHL_PARAM_FZ_Speed,-(YX_CTHL_LianLengthAutoFZcheck-YX_CTHL_PARAM_XKCR_LENGTH),1500*YX_CTHL_PARAM_FMOTOR_BILI,YX_CTHL_PARAM_FKDW_Speed,20,300,250);
  995. AxisMovePosAccDecNotStop(Y_AXIS,YX_CTHL_PARAM_FZ_Speed,YX_CTHL_LianLengthAutoFZcheck-YX_CTHL_PARAM_XKCR_LENGTH,1500,YX_CTHL_PARAM_FKDW_Speed,20,300,250);
  996. }
  997. YX_CTHL_FZ_MotorStep=3;
  998. }
  999. break;
  1000. case 3:
  1001. if(YX_CTHL_cZipCnt < 2)
  1002. {
  1003. if(dwYRealPos >= YX_CTHL_PARAM_first_CL_MAX_Length)
  1004. {
  1005. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  1006. }
  1007. }
  1008. else
  1009. {
  1010. if(dwYRealPos >= (YX_CTHL_PARAM_WLCDSHEZHI_LENTH+ YX_CTHL_LianLengthAutoFZcheck))
  1011. {
  1012. YX_CTHL_SetAlarmCode(YX_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  1013. }
  1014. }
  1015. if(YX_CTHL_FKQL_IN_UP)
  1016. {
  1017. AxisEgmStop(X_AXIS);
  1018. AxisEgmStop(Y_AXIS);
  1019. YX_CTHL_FKGD_VAVLE=1;
  1020. YX_CTHL_FZ_MotorStep = 0;
  1021. if(YX_CTHL_cZipCnt ==1 || dwYRealPos<(YX_CTHL_LianLengthAutoFZcheck*0.7))
  1022. YX_CTHL_LianLengthAutoFZcheck = dwYRealPos;
  1023. }
  1024. break;
  1025. case 20: //此处最好算好定位长度相减
  1026. if(dwTickCount >= YX_CTHL_FZ_MotorDelay)
  1027. {
  1028. YX_CTHL_FZ_MotorStep = 21;
  1029. SetPos(Y_AXIS, 0); //启动位置设为0点
  1030. }
  1031. break;
  1032. case 21:
  1033. if(YX_CTHL_PARAM_CXDW_Length)
  1034. {
  1035. // YX_CTHL_FZ_MotorDelay=dwTickCount+ YX_CTHL_PARAM_CXCSC_DELAY;
  1036. YX_CTHL_FZ_MotorStep = 22;
  1037. AxisMovePosAccDec(Y_AXIS,5000,YX_CTHL_PARAM_CXDW_Length,800,800,25,25,0);
  1038. if(YX_CTHL_PARAM_CXDW_Length> 20)
  1039. AxisMovePosAccDec(X_AXIS,5000,-(YX_CTHL_PARAM_CXDW_Length- YX_CTHL_PARAM_CXDW_Length/30),800,800,25,25,0);
  1040. }
  1041. break;
  1042. case 22:
  1043. if(!Y_DRV || (dwYRealPos >= YX_CTHL_PARAM_CXDW_Length)) //插销定位已经结束
  1044. {
  1045. AxisEgmStop(Y_AXIS);
  1046. AxisEgmStop(X_AXIS);
  1047. YX_CTHL_FZ_MotorStep = 0;
  1048. }
  1049. break;
  1050. }
  1051. #endif
  1052. }
  1053. //装拉头动作
  1054. void YX_CTHL_ZLT_Step(void)
  1055. {
  1056. switch(YX_CTHL_ZhuangLiaoStep)
  1057. {
  1058. case 1:
  1059. if(bZhuangLiaoOkFlg)
  1060. {
  1061. YX_CTHL_ZhuangLiaoStep = 0;
  1062. }
  1063. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1064. {
  1065. if(((YX_CTHL_MGuo_VAVLE && YX_CTHL_LTou_Check) || (!YX_CTHL_MGuo_VAVLE)) && !YX_CTHL_JLiao_Limit_IN )//说明没有拉头
  1066. {
  1067. //穿头模和一次穿入必须在原位,接料不能有输出
  1068. if(YX_CTHL_CTM_Origin_IN && !YX_CTHL_CTXM_VAVLE)
  1069. {
  1070. YX_CTHL_JLTou_VAVLE = 0;
  1071. YX_CTHL_MGuo_VAVLE = 0;
  1072. if(YX_CTHL_TLiaoStep == 0)
  1073. {
  1074. YX_CTHL_TLiaoStep = 1;
  1075. YX_CTHL_ZhuangLiaoStep = 2;
  1076. }
  1077. }
  1078. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay + 500) //警告横送拉必须保证穿头模和一次穿入在原位,接料不能有输出
  1079. {
  1080. YX_CTHL_wltzi=1;
  1081. YX_CTHL_SetAlarmCode(YX_CTHL_CTM_Origin_ALARM,bRunning);
  1082. }
  1083. }
  1084. else //已经有拉头直接跳到结束
  1085. {
  1086. YX_CTHL_ZhuangLiaoDelay = dwTickCount + 40;
  1087. YX_CTHL_ZhuangLiaoStep = 9;
  1088. }
  1089. }
  1090. break;
  1091. case 2:
  1092. if(YX_CTHL_TLiaoStep == 0) //推料已经完成
  1093. {
  1094. YX_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1095. YX_CTHL_JLTou_VAVLE = 0;
  1096. YX_CTHL_MGuo_VAVLE = 0;
  1097. if(!YX_CTHL_JLiao_Limit_IN)
  1098. {
  1099. YX_CTHL_ZhuangLiaoStep = 3;
  1100. YX_CTHL_HSLiao_VAVLE = 1;
  1101. }
  1102. }
  1103. break;
  1104. case 3:
  1105. //横送到位
  1106. if(YX_CTHL_HSLiao_Limit_IN && !YX_CTHL_HSLiao_Origin_IN)
  1107. {
  1108. YX_CTHL_ZhuangLiaoStep = 4;
  1109. // YX_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
  1110. YX_CTHL_ZhuangLiaoDelay = dwTickCount + 10;
  1111. }
  1112. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1113. {
  1114. YX_CTHL_wltzi=1;
  1115. YX_CTHL_SetAlarmCode(YX_CTHL_HSLiao_Limit_ALARM,bRunning);
  1116. YX_CTHL_ZhuangLiaoStep = 0;
  1117. YX_CTHL_HSLiao_VAVLE = 0;
  1118. }
  1119. break;
  1120. case 4:
  1121. if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1122. {
  1123. YX_CTHL_ZhuangLiaoStep = 5;
  1124. YX_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
  1125. YX_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1126. }
  1127. break;
  1128. case 5:
  1129. if(YX_CTHL_JLiao_Limit_IN)
  1130. {
  1131. YX_CTHL_ZhuangLiaoStep = 6;
  1132. YX_CTHL_ZhuangLiaoDelay = dwTickCount + YX_CTHL_PARAM_MaGou_DELAY;
  1133. }
  1134. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay) //接拉头(接料)到们信号异常
  1135. {
  1136. YX_CTHL_SetAlarmCode(YX_CTHL_JLiao_Origin_ALARM,bRunning);
  1137. YX_CTHL_HSLiao_VAVLE = 0;
  1138. YX_CTHL_JLTou_VAVLE = 0;
  1139. YX_CTHL_ZhuangLiaoStep = 0;
  1140. }
  1141. break;
  1142. case 6:
  1143. if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay) //延时码勾
  1144. {
  1145. YX_CTHL_MGuo_VAVLE = 1; //码勾输出
  1146. YX_CTHL_ZhuangLiaoStep = 7;
  1147. YX_CTHL_ZhuangLiaoDelay = dwTickCount + YX_CTHL_PARAM_HSLiaoOff_DELAY;
  1148. bTuiLaTouOkFlg = 0; //认为拉头没法带出
  1149. }
  1150. break;
  1151. case 7:
  1152. if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1153. {
  1154. YX_CTHL_HSLiao_VAVLE = 0;
  1155. YX_CTHL_ZhuangLiaoStep = 8;
  1156. YX_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1157. }
  1158. break;
  1159. case 8:
  1160. if(!YX_CTHL_HSLiao_Limit_IN) //
  1161. {
  1162. YX_CTHL_ZhuangLiaoStep = 9;
  1163. YX_CTHL_TLiaoStep = 1; //推拉头
  1164. YX_CTHL_ZhuangLiaoDelay = dwTickCount + YX_CTHL_PARAM_CheckLT_DELAY; //也是给下模能上升的时间
  1165. }
  1166. else if (YX_CTHL_LTou_Check) //时间内信号这说明没有拉头
  1167. {
  1168. //重送3次
  1169. YX_CTHL_TryCnt++;
  1170. YX_CTHL_JLTou_VAVLE = 0; //接拉头关
  1171. YX_CTHL_MGuo_VAVLE = 0; //码勾打开
  1172. if(YX_CTHL_TryCnt >= 3)
  1173. {
  1174. YX_CTHL_TryCnt = 0;
  1175. bZhuangLiaoOkFlg = 0;
  1176. YX_CTHL_ZhuangLiaoStep = 0;
  1177. YX_CTHL_wltzi=1;
  1178. YX_CTHL_SetAlarmCode(YX_CTHL_ZLT_ALARM,bRunning);
  1179. }
  1180. else
  1181. {
  1182. YX_CTHL_ZhuangLiaoStep = 20; //重新送3次
  1183. YX_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1184. }
  1185. }
  1186. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1187. {
  1188. YX_CTHL_wltzi=1;
  1189. YX_CTHL_SetAlarmCode(YX_CTHL_HSLiao_Limit_ALARM,bRunning);
  1190. if(bRunning)
  1191. {
  1192. YX_CTHL_ZhuangLiaoStep = 0 ;
  1193. }
  1194. }
  1195. break;
  1196. case 9:
  1197. if(YX_CTHL_LTou_Check) //时间内信号这说明没有拉头
  1198. {
  1199. YX_CTHL_TryCnt++;
  1200. YX_CTHL_JLTou_VAVLE = 0; //接拉头关
  1201. YX_CTHL_MGuo_VAVLE = 0; //码勾打开
  1202. if(YX_CTHL_TryCnt >= 3)
  1203. {
  1204. YX_CTHL_TryCnt=0;
  1205. bZhuangLiaoOkFlg = 0;
  1206. YX_CTHL_ZhuangLiaoStep = 0;
  1207. YX_CTHL_wltzi=1;
  1208. YX_CTHL_SetAlarmCode(YX_CTHL_ZLT_ALARM,bRunning);
  1209. }
  1210. else
  1211. {
  1212. YX_CTHL_ZhuangLiaoStep = 20; //重新送3次
  1213. YX_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1214. }
  1215. }
  1216. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1217. {
  1218. bZhuangLiaoOkFlg = 1;
  1219. YX_CTHL_ZhuangLiaoStep = 0;
  1220. }
  1221. break;
  1222. //装拉头不成攻重新送拉头
  1223. case 20:
  1224. if(YX_CTHL_HSLiao_Origin_IN)
  1225. {
  1226. YX_CTHL_JLTou_VAVLE = 0; //接拉头关
  1227. YX_CTHL_MGuo_VAVLE = 0; //码勾打开
  1228. YX_CTHL_ZhuangLiaoStep = 1;
  1229. YX_CTHL_ZhuangLiaoDelay = dwTickCount + 10;
  1230. }
  1231. else if(dwTickCount >= YX_CTHL_ZhuangLiaoDelay)
  1232. {
  1233. YX_CTHL_wltzi=1;
  1234. YX_CTHL_SetAlarmCode(YX_CTHL_HSLiao_Origin_ALARM,bRunning);
  1235. }
  1236. break;
  1237. }
  1238. }
  1239. void YX_CTHL_TLiao_Step(void)
  1240. {
  1241. switch(YX_CTHL_TLiaoStep)
  1242. {
  1243. case 1:
  1244. if(bTuiLaTouOkFlg)
  1245. {
  1246. YX_CTHL_TLiaoStep = 0;
  1247. }
  1248. else
  1249. {
  1250. YX_CTHL_TLiao_Delay = dwTickCount + YX_CTHL_VAVLE_ERROR_TIME;
  1251. YX_CTHL_TLiaoStep = 2;
  1252. }
  1253. break;
  1254. case 2: //横送料在原位
  1255. if(YX_CTHL_HSLiao_Origin_IN && !YX_CTHL_HSLiao_Limit_IN && !YX_CTHL_HSLiao_VAVLE)
  1256. {
  1257. YX_CTHL_TLiao_VAVLE = 1; //推料(推拉头)输出
  1258. YX_CTHL_TLiao_Delay = dwTickCount + YX_CTHL_VAVLE_ERROR_TIME;
  1259. YX_CTHL_TLiaoStep = 3;
  1260. }
  1261. else if(dwTickCount >= YX_CTHL_TLiao_Delay)
  1262. {
  1263. YX_CTHL_SetAlarmCode(YX_CTHL_HSLiao_Origin_ALARM,1);
  1264. YX_CTHL_wltzi=1;
  1265. }
  1266. break;
  1267. case 3: //推拉头到位
  1268. if(!YX_CTHL_TLiao_Origin_IN)
  1269. {
  1270. YX_CTHL_TLiao_Delay = dwTickCount + YX_CTHL_PARAM_TLiao_BACKDELAY;
  1271. YX_CTHL_TLiaoStep = 4;
  1272. }
  1273. else if(dwTickCount >= YX_CTHL_TLiao_Delay)
  1274. {
  1275. YX_CTHL_SetAlarmCode(YX_CTHL_TLiao_Limit_ALARM,1);
  1276. YX_CTHL_wltzi=1;
  1277. }
  1278. break;
  1279. case 4:
  1280. if(dwTickCount >= YX_CTHL_TLiao_Delay)
  1281. {
  1282. YX_CTHL_TLiao_VAVLE = 0;
  1283. YX_CTHL_TLiao_Delay = dwTickCount + YX_CTHL_VAVLE_ERROR_TIME;
  1284. YX_CTHL_TLiaoStep = 5;
  1285. }
  1286. break;
  1287. case 5:
  1288. if(YX_CTHL_TLiao_Origin_IN)
  1289. {
  1290. YX_CTHL_TLiaoStep = 0;
  1291. YX_CTHL_TLiao_Delay = dwTickCount;
  1292. bTuiLaTouOkFlg = 1;
  1293. }
  1294. else if(dwTickCount >= YX_CTHL_TLiao_Delay)
  1295. {
  1296. YX_CTHL_SetAlarmCode(YX_CTHL_TLiao_Limit_ALARM,0);
  1297. YX_CTHL_wltzi=1;
  1298. }
  1299. break;
  1300. }
  1301. }
  1302. //振动盘控制
  1303. void YX_CTHL_ZhenDongAction(void)
  1304. {
  1305. #if 0
  1306. if((YX_CTHL_bDLP || bRunning) && YX_CTHL_ZhenDongPian_OUT && YX_CTHL_PARAM_DALIAOPIAN)
  1307. {
  1308. if(CT_DLP_Time >= dwTickCount)
  1309. {
  1310. CT_ZDP_Delay = dwTickCount + CT_PARAM_DLP_TIME + 40;
  1311. CT_DaLaPian_VAVLE = ~CT_DaLaPian_VAVLE;
  1312. }
  1313. }
  1314. else
  1315. CT_DaLaPian_VAVLE = 0;
  1316. #endif
  1317. #if 1
  1318. // if(bRunning)
  1319. // {
  1320. if(!XY_CTHL_PARAM_ZDP_AUTO)
  1321. {
  1322. if(YX_CTHL_ZhenDongPian_OUT == 0)
  1323. {
  1324. if(!YX_CTHL_ZDP_IN)
  1325. {
  1326. if(dwTickCount >= YX_CTHL_ZDP_Delay)
  1327. {
  1328. YX_CTHL_ZhenDongPian_OUT = 1;
  1329. YX_CTHL_ZDP_Delay = dwTickCount + YX_CTHL_PARAM_ZDP_Stop_TIME;//YX_CTHL_PARAM_ZDP_Stop_TIME + 50;
  1330. }
  1331. }
  1332. else
  1333. {
  1334. YX_CTHL_ZDP_Delay = dwTickCount + YX_CTHL_PARAM_ZDP_Start_TIME;//YX_CTHL_PARAM_ZDP_Start_TIME;
  1335. }
  1336. }
  1337. else
  1338. {
  1339. if(YX_CTHL_ZDP_IN)
  1340. {
  1341. if(dwTickCount >= YX_CTHL_ZDP_Delay)
  1342. {
  1343. YX_CTHL_ZhenDongPian_OUT = 0;
  1344. YX_CTHL_ZDP_Delay = dwTickCount + YX_CTHL_PARAM_ZDP_Start_TIME;//YX_CTHL_PARAM_ZDP_Start_TIME
  1345. }
  1346. }
  1347. else
  1348. YX_CTHL_ZDP_Delay = dwTickCount + YX_CTHL_PARAM_ZDP_Stop_TIME;//YX_CTHL_PARAM_ZDP_Stop_TIME+ 50;
  1349. }
  1350. }
  1351. else if (YX_CTHL_PARAM_ZDP_AUTO ==1 )
  1352. {
  1353. YX_CTHL_ZhenDongPian_OUT=0;
  1354. YX_CTHL_ZDP_Delay = dwTickCount + 0;
  1355. }
  1356. else if(YX_CTHL_PARAM_ZDP_AUTO == 2)
  1357. {
  1358. YX_CTHL_ZhenDongPian_OUT=1;
  1359. YX_CTHL_ZDP_Delay = dwTickCount + 0;
  1360. }
  1361. #endif
  1362. }
  1363. //手动动作
  1364. void YX_CTHL_ManualAction(void)
  1365. {
  1366. if(bRunning == 0)
  1367. {
  1368. if(bClearTotal) //切断计数清零
  1369. {
  1370. bClearTotal = 0;
  1371. ClrcToTal(QDCT_TOTAL_ADDR);
  1372. }
  1373. if(YX_CTHL_bHSL) //手动横送料
  1374. {
  1375. YX_CTHL_bHSL= 0;
  1376. if(YX_CTHL_HSLiao_VAVLE)
  1377. {
  1378. YX_CTHL_HSLiao_VAVLE = 0;//~XY_CTHL_HSLiao_VAVLE;
  1379. }
  1380. else if(!YX_CTHL_TLiao_VAVLE && !YX_CTHL_JLTou_VAVLE && !YX_CTHL_CTXM_VAVLE && (!YX_CTHL_bMG || (YX_CTHL_bMG && YX_CTHL_LTou_Check)))
  1381. {
  1382. if(YX_CTHL_CTM_Origin_IN)
  1383. YX_CTHL_HSLiao_VAVLE = 1;
  1384. }
  1385. else
  1386. {
  1387. YX_CTHL_SetAlarmCode(YX_CTHL_JLiao_Origin_ALARM,0);
  1388. }
  1389. }
  1390. if(YX_CTHL_bTLiao ) //手动推料(推拉头)
  1391. {
  1392. YX_CTHL_bTLiao = 0;
  1393. if(YX_CTHL_TLiao_VAVLE)
  1394. YX_CTHL_TLiao_VAVLE = 0;//YX_CTHL_TLiao_VAVLE;
  1395. else if(!YX_CTHL_HSLiao_VAVLE && YX_CTHL_HSLiao_Origin_IN)
  1396. {
  1397. YX_CTHL_TLiao_VAVLE = 1;
  1398. }
  1399. else//条件警告
  1400. {
  1401. YX_CTHL_SetAlarmCode(YX_CTHL_HSLiao_Origin_ALARM,0); // 横送料不能输出
  1402. }
  1403. }
  1404. if(YX_CTHL_bJLT) //接拉头
  1405. {
  1406. YX_CTHL_bJLT = 0;
  1407. if(YX_CTHL_JLTou_VAVLE)
  1408. YX_CTHL_JLTou_VAVLE = 0;
  1409. else if( !YX_CTHL_CTXM_VAVLE && YX_CTHL_CTM_Origin_IN)
  1410. {
  1411. YX_CTHL_MGuo_VAVLE = 0;
  1412. YX_CTHL_JLTou_VAVLE = 1;
  1413. }
  1414. else//条件警告
  1415. {
  1416. YX_CTHL_SetAlarmCode(YX_CTHL_CTM_Origin_ALARM,0);
  1417. }
  1418. }
  1419. if(YX_CTHL_bMG) //码勾
  1420. {
  1421. YX_CTHL_bMG = 0;
  1422. YX_CTHL_MGuo_VAVLE = !YX_CTHL_MGuo_VAVLE;
  1423. }
  1424. if(YX_CTHL_bLYLun) //前压轮
  1425. {
  1426. YX_CTHL_bLYLun = 0;
  1427. YX_CTHL_LYLun_VAVLE = ~YX_CTHL_LYLun_VAVLE;
  1428. }
  1429. if(YX_CTHL_bFKGD) //方块固定
  1430. {
  1431. YX_CTHL_bFKGD = 0;
  1432. YX_CTHL_FKGD_VAVLE = ~YX_CTHL_FKGD_VAVLE;
  1433. }
  1434. if(YX_CTHL_bCXC) //插小插
  1435. {
  1436. YX_CTHL_bCXC=0;
  1437. YX_CTHL_CXC_VAVLE = ~YX_CTHL_CXC_VAVLE;
  1438. }
  1439. if(YX_CTHL_bXCDWGYZ) //固定前码
  1440. {
  1441. YX_CTHL_bXCDWGYZ=0;
  1442. YX_CTHL_GDQM_VAVLE = ~YX_CTHL_GDQM_VAVLE ;
  1443. }
  1444. if(YX_CTHL_bFKGM) //方块勾模
  1445. {
  1446. YX_CTHL_bFKGM=0;
  1447. YX_CTHL_TQM_VAVLE = ~YX_CTHL_TQM_VAVLE ;
  1448. }
  1449. if(YX_CTHL_bRYLun) //后压轮
  1450. {
  1451. YX_CTHL_bRYLun= 0;
  1452. YX_CTHL_RYLun_VAVLE = ~YX_CTHL_RYLun_VAVLE;
  1453. }
  1454. if(YX_CTHL_bCTXM) //下模
  1455. {
  1456. YX_CTHL_bCTXM = 0;
  1457. if(YX_CTHL_CTXM_VAVLE)
  1458. {
  1459. YX_CTHL_CTXM_VAVLE = 0;
  1460. YX_CTHL_JLTou_VAVLE = 0;
  1461. }
  1462. else if(!YX_CTHL_HSLiao_VAVLE && YX_CTHL_HSLiao_Origin_IN)
  1463. {
  1464. YX_CTHL_CTXM_VAVLE = 1;
  1465. }
  1466. }
  1467. //压带
  1468. if(YX_CTHL_bYD)
  1469. {
  1470. YX_CTHL_bYD = 0;
  1471. YX_CTHL_YADAI_VAVLE =~YX_CTHL_YADAI_VAVLE;
  1472. }
  1473. //自动装料
  1474. if(YX_CTHL_bAutoZhuangLiao)
  1475. {
  1476. YX_CTHL_bAutoZhuangLiao = 0;
  1477. if(YX_CTHL_ZhuangLiaoStep == 0)
  1478. {
  1479. bTuiLaTouOkFlg = 1;
  1480. bZhuangLiaoOkFlg = 0;
  1481. YX_CTHL_ZhuangLiaoStep = 1;
  1482. YX_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
  1483. YX_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
  1484. }
  1485. }
  1486. if(YX_CTHL_bYJDW) //一键定位
  1487. {
  1488. YX_CTHL_bYJDW=0;
  1489. if(YX_CTHL_TD_MotorStep==0)
  1490. {
  1491. YX_CTHL_CTXM_VAVLE =0;
  1492. YX_CTHL_FKGD_VAVLE =0;
  1493. YX_CTHL_YADAI_VAVLE = 0;
  1494. YX_CTHL_LYLun_VAVLE = 0; //
  1495. YX_CTHL_RYLun_VAVLE = 0; //Y16插销压轮
  1496. YX_CTHL_CXC_VAVLE = 0;
  1497. YX_CTHL_GDQM_VAVLE =0;
  1498. YX_CTHL_TQM_VAVLE=0;
  1499. if((GetEn(X_AXIS) == MOTOR_DISEN))
  1500. {
  1501. SetEn(X_AXIS, MOTOR_EN);
  1502. SetEn(Y_AXIS, MOTOR_EN);
  1503. YX_CTHL_TD_MotorDelay = dwTickCount + 200;
  1504. }
  1505. else
  1506. YX_CTHL_TD_MotorDelay = dwTickCount + 50;
  1507. YX_CTHL_TD_MotorStep=1;
  1508. }
  1509. }
  1510. //X轴Y轴电机测试
  1511. if(YX_CTHL_bCLMotor_N)
  1512. {
  1513. SetEn(Y_AXIS, MOTOR_EN);
  1514. SetEn(X_AXIS, MOTOR_EN);
  1515. if(!X_DRV)
  1516. {
  1517. // Y轴 运行速度 启动速度 加速度 减速度
  1518. AxisContinueMoveAcc(X_AXIS,2000,DIR_P,1000,1000,15,15);
  1519. AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,1000,15,15);
  1520. }
  1521. }
  1522. if(YX_CTHL_bCLMotor_P) //后退限位已经取消
  1523. {
  1524. SetEn(Y_AXIS, MOTOR_EN);
  1525. SetEn(X_AXIS, MOTOR_EN);
  1526. if(!X_DRV)
  1527. {
  1528. // Y轴 运行速度 启动速度 加速度 减速度
  1529. AxisContinueMoveAcc(Y_AXIS,2000,DIR_P,1000,1000,15,15);
  1530. AxisContinueMoveAcc(X_AXIS,2000,DIR_N,1000,1000,15,15);
  1531. }
  1532. }
  1533. if(!YX_CTHL_bCLMotor_P && !YX_CTHL_bCLMotor_N && (YX_CTHL_TD_MotorStep == 0) && YX_CTHL_ColorStep==0)
  1534. {
  1535. AxisEgmStop(Y_AXIS);
  1536. AxisEgmStop(X_AXIS);
  1537. }
  1538. //Z轴电机测试
  1539. if(YX_CTHL_bCLMotor_Z)
  1540. {
  1541. SetEn(Z_AXIS, MOTOR_EN);
  1542. if(!Z_DRV)
  1543. {
  1544. // Y轴 运行速度 启动速度 加速度 减速度
  1545. AxisContinueMoveAcc(Z_AXIS,2000,DIR_P,1000,1000,15,15);
  1546. }
  1547. }
  1548. if(!YX_CTHL_bCLMotor_Z && (YX_CTHL_TD_MotorStep == 0) && !YX_CTHL_MOTOR_MODE)
  1549. {
  1550. AxisEgmStop(Z_AXIS);
  1551. }
  1552. }
  1553. }
  1554. #endif