GLHeLian.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. #include "global.h"
  2. #if CHANG_SHENG_GEI_LI_MACHINE
  3. void HL_InitAction(void);
  4. void HL_Action(void);
  5. void HL_SetAlarmCode(unsigned alarm_code);
  6. void HL_StartStopAction(void);
  7. void HL_AutoRunStep(void);
  8. void HL_Motor(void);
  9. void HL_Step(void);
  10. void HL_PWMAction(void);
  11. unsigned char cDWflg=0,cZCXflg=0,cHLflg=0;
  12. unsigned char cBBflg = 0;
  13. short *offset_length_buff;
  14. static unsigned char OldGuoLian,GuoLian;
  15. static unsigned long guolian_flter;
  16. unsigned char work_flg,work_Num,cErrorStop_Flg;
  17. unsigned short cCheckStep;
  18. void HL_ConectAction(void)
  19. {
  20. static unsigned long start_delay;
  21. if(HL_PARAM_CONNECT_MODE)
  22. {
  23. if(cCheckStep == 1)
  24. {
  25. if(HL_LW_STOP_IN_DW)
  26. {
  27. start_delay = HL_PARAM_DELAY_START + dwTickCount;
  28. cCheckStep = 2;
  29. }
  30. else if(HL_LW_STOP_IN)
  31. work_flg = 0;
  32. }
  33. else if((cCheckStep == 2) && (dwTickCount >= start_delay))
  34. {
  35. work_flg = 1;
  36. cCheckStep = 3;
  37. }
  38. else if(cCheckStep == 3)
  39. {
  40. if(HL_LW_STOP_IN)
  41. {
  42. work_flg = 0;
  43. cCheckStep = 1;
  44. }
  45. }
  46. }
  47. else
  48. work_flg = 1;
  49. }
  50. void HL_SetAlarmCode(unsigned alarm_code)
  51. {
  52. SetAlarmCode(HL_ALARM_ADDR,alarm_code);
  53. HL_bAlarmStop = 1;
  54. }
  55. void HL_InitAction(void)
  56. {
  57. CalFreqTab_X_Free(14);
  58. // length_buff = 54.1*3.14;//JYDC_CYCLE_LENGTH;
  59. // pulse_buff = 2000;//JYDC_CYCLE_PULSE;
  60. // XGearRatio = 2000pulse_buff/length_buff;
  61. XGearRatio = 1;
  62. SetEn(X_AXIS,HL_MOTOR_DISEN);
  63. #if IO_Change
  64. IOPinConfigure(); //可变IO初始化
  65. #endif
  66. }
  67. //手动动作
  68. void HL_ManualAction(void)
  69. {
  70. if(!HL_bRunning)
  71. {
  72. //清产量
  73. if(bClearTotal)
  74. {
  75. bClearTotal = 0;
  76. ClrcToTal(HL_TOTAL_ADDR);
  77. HL_bSetWorkData = 1;
  78. }
  79. //定位数据加
  80. if(HL_bAdd)
  81. {
  82. HL_bAdd = 0;
  83. HL_PARAM_DELAY_STOP += 10;
  84. }
  85. //定位数据减
  86. if(HL_bDec)
  87. {
  88. HL_bDec = 0;
  89. if(HL_PARAM_DELAY_STOP >= 10)
  90. HL_PARAM_DELAY_STOP -= 10;
  91. }
  92. //合模
  93. if(HL_bHM)
  94. {
  95. HL_bHM = 0;
  96. if(HL_HM_VAVLE)
  97. {
  98. HL_HM_VAVLE = 0;
  99. HL_YD_VAVLE = 0;
  100. }
  101. else if((!HL_TFK_VAVLE) || (!HL_BB_VAVLE))
  102. HL_HM_VAVLE = 1;
  103. }
  104. //推方块
  105. if(HL_bTFK)
  106. {
  107. HL_bTFK = 0;
  108. HL_TFK_VAVLE = ~HL_TFK_VAVLE;
  109. }
  110. //摆 臂
  111. if(HL_bBB)
  112. {
  113. HL_bBB = 0;
  114. HL_BB_VAVLE = ~HL_BB_VAVLE;
  115. if(HL_BB_VAVLE)cBBflg = 1;
  116. }
  117. if(cBBflg)
  118. {
  119. if(HL_BB_LIMIT_IN)
  120. {
  121. cBBflg = 0;
  122. }
  123. }
  124. //压插销
  125. if(HL_bYCX)
  126. {
  127. HL_bYCX = 0;
  128. HL_YCX_VAVLE = 1;
  129. HL_YCXDelay = dwTickCount + HL_PARAM_YCX_TIME;
  130. }
  131. //上挡块
  132. if(HL_bDK_UP)
  133. {
  134. HL_bDK_UP = 0;
  135. HL_DK_UP_VAVLE = ~HL_DK_UP_VAVLE;
  136. }
  137. //夹 带
  138. if(HL_bJD)
  139. {
  140. HL_bJD = 0;
  141. HL_JD_VAVLE = ~HL_JD_VAVLE;
  142. }
  143. //穿插销
  144. if(HL_bCCX)
  145. {
  146. HL_bCCX = 0;
  147. HL_CCX_VAVLE = ~HL_CCX_VAVLE;
  148. }
  149. //挡块前后
  150. if(HL_bDK_GO)
  151. {
  152. HL_bDK_GO = 0;
  153. HL_DK_GO_VAVLE = ~HL_DK_GO_VAVLE;
  154. }
  155. //压 带
  156. if(HL_bYD)
  157. {
  158. HL_bYD = 0;
  159. HL_YD_VAVLE = ~HL_YD_VAVLE;
  160. }
  161. //松 紧
  162. if(HL_bSJ)
  163. {
  164. HL_bSJ = 0;
  165. HL_SJ_VAVLE = ~HL_SJ_VAVLE;
  166. }
  167. if(HL_bHMYD)
  168. {
  169. HL_bHMYD = 0;
  170. if(HL_HM_VAVLE)
  171. {
  172. HL_HM_VAVLE = 0;
  173. }
  174. else
  175. {
  176. HL_HM_VAVLE = 1;
  177. }
  178. }
  179. //上挡块
  180. if(HL_bDKUP)
  181. {
  182. HL_bDKUP = 0;
  183. if(HL_DK_UP_VAVLE)
  184. {
  185. HL_DK_UP_VAVLE = 0;
  186. HL_DK_GO_VAVLE = 0;
  187. HL_YD_VAVLE = 0;
  188. }
  189. else
  190. {
  191. if(HL_ManDKStep == 0)HL_ManDKStep=1;
  192. }
  193. }
  194. if(HL_ManDKStep == 1)
  195. {
  196. HL_DK_UP_VAVLE = 1; //挡块上下
  197. HL_ManDKStep = 2;
  198. }
  199. else if((HL_ManDKStep == 2) && HL_DK_UP_LIMIT_IN)
  200. {
  201. HL_ManDKDelay = dwTickCount + HL_PARAM_DELAY_DK_UP;
  202. HL_ManDKStep = 3;
  203. }
  204. else if((HL_ManDKStep == 3) && (dwTickCount >= HL_ManDKDelay))
  205. {
  206. HL_DK_GO_VAVLE = 1; //挡块前后
  207. HL_ManDKStep = 0;
  208. }
  209. if(HL_bCD)
  210. {
  211. HL_bCD = 0;
  212. HL_CD_MOTOR = ~HL_CD_MOTOR;
  213. }
  214. if(HL_bYCD)
  215. {
  216. HL_bYCD = 0;
  217. HL_CD_VAVLE = ~HL_CD_VAVLE;
  218. }
  219. if(HL_bMotor)
  220. {
  221. SetEn(X_AXIS,HL_MOTOR_EN);
  222. if(!X_DRV)AxisContinueMove(X_AXIS,10,HL_DIR_P);
  223. }
  224. else
  225. {
  226. if(X_DRV)AxisDecStop(X_AXIS);
  227. }
  228. }
  229. }
  230. //合链动作
  231. void HL_Action(void)
  232. {
  233. #if IO_Change
  234. InputPinConfig();
  235. #endif
  236. HL_ConectAction();
  237. HL_ManualAction();
  238. HL_StartStopAction();
  239. HL_Motor();
  240. HL_Step();
  241. HL_AutoRunStep();
  242. #if IO_Change
  243. OutputPinConfig();
  244. #endif
  245. }
  246. //启动停止故障停止动作
  247. void HL_StartStopAction(void)
  248. {
  249. static unsigned long dwstop_cnt = 0;
  250. if((HL_START_IN_UP || HL_bStart || HL_bSingStart || HL_bDW || HL_bZCX || HL_bHL) && !HL_bRunning && (HL_AutoStep ==0))
  251. {
  252. if((GetTotal(HL_TOTAL_ADDR) >= SET_TOTAL) && !HL_bDW && SET_TOTAL)HL_SetAlarmCode(HL_TOTAL_ALARM);
  253. // else if(HL_SM_LIMIT_IN)HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  254. // else if(HL_XM_LIMIT_IN)HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  255. // else if(HL_BB_LIMIT_IN)HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  256. // else if(HL_DK_LIMIT_IN)HL_SetAlarmCode(HL_DK_LIMIT_ALARM);
  257. // else if(!HL_DK_ORIGIN_IN)HL_SetAlarmCode(HL_DK_ORIGIN_ALARM);
  258. // else if(HL_DK_UP_LIMIT_IN)HL_SetAlarmCode(HL_DK_UP_LIMIT_ALARM);
  259. // else if(HL_CCX_LIMIT_IN)HL_SetAlarmCode(HL_CCX_LIMIT_ALARM);
  260. // else if(!HL_CCX_ORIGIN_IN)HL_SetAlarmCode(HL_CCX_ORIGIN_ALARM);
  261. // else if(HL_TFK_LIMIT_IN)HL_SetAlarmCode(HL_TFK_LIMIT_ALARM);
  262. // else if(!HL_TFK_ORIGIN_IN)HL_SetAlarmCode(HL_TFK_ORIGIN_ALARM);
  263. else
  264. {
  265. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  266. HL_bRunning = 1;
  267. cCheckStep = 1;
  268. dwZipCnt = 0;
  269. if(HL_PARAM_CONNECT_MODE)
  270. {
  271. work_Num = 0;
  272. HL_OVEROUt_VAVLE = 1;
  273. HL_Y15Delay = dwTickCount + 100;
  274. }
  275. //单次启动
  276. if(HL_bSingStart)
  277. {
  278. HL_bSingStart = 0;
  279. SingOneFlg = 1;
  280. }
  281. //定位
  282. if(HL_bDW)
  283. {
  284. cDWflg = 1;
  285. dwZipCnt = 1;
  286. }
  287. work_Num = 0;
  288. bCheckOK = 1;
  289. cErrorStop_Flg = 0;
  290. if(HL_bZCX)cZCXflg = 1;//装插销
  291. if(HL_bHL)cHLflg = 1; //合链
  292. work_flg = 1;
  293. if(HL_bZCX)HL_AutoStep = 4;
  294. else if(HL_bHL)HL_AutoStep = 1;
  295. else HL_AutoStep = 1;
  296. }
  297. HL_bDW = 0;
  298. HL_bZCX = 0;
  299. HL_bHL = 0;
  300. HL_bSingStart = 0;
  301. HL_bStart = 0;
  302. }
  303. if(!HL_bMotor && !X_DRV && !HL_bRunning && (HL_MotorStep==0))
  304. SetEn(X_AXIS,HL_MOTOR_DISEN);
  305. if(HL_bStop)
  306. {
  307. HL_bStop = 0;
  308. if(HL_bRunning)
  309. SingOneFlg = 1;
  310. else
  311. {
  312. HL_HM_VAVLE = 0;
  313. HL_TFK_VAVLE = 0;
  314. HL_BB_VAVLE = 0;
  315. HL_DK_UP_VAVLE = 0;
  316. HL_JD_VAVLE = 0;
  317. HL_CCX_VAVLE = 0;
  318. HL_DK_GO_VAVLE = 0;
  319. HL_YD_VAVLE = 0;
  320. HL_SJ_VAVLE = 0;
  321. HL_CD_MOTOR = 0;
  322. HL_ALARM_OUT = 0;
  323. HL_bRunning = 0;
  324. HL_AutoStep = 0;
  325. HL_MotorStep = 0;
  326. SingOneFlg = 0;
  327. HL_bMotor = 0;
  328. cDWflg = 0;
  329. cZCXflg = 0;
  330. cHLflg = 0;
  331. HL_ManDKStep = 0;
  332. HL_CD_VAVLE = 0;
  333. AxisEgmStop(X_AXIS);
  334. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  335. }
  336. }
  337. if(STOP_IN)dwstop_cnt++;
  338. else dwstop_cnt = 0;
  339. if(dwstop_cnt >= 10000)
  340. {
  341. HL_HM_VAVLE = 0;
  342. HL_BB_VAVLE = 0;
  343. }
  344. if(HL_STOP_IN_UP)
  345. {
  346. HL_bStop = 0;
  347. // if(HL_bRunning)
  348. {
  349. HL_TFK_VAVLE = 0;
  350. // HL_BB_VAVLE = 0;
  351. HL_DK_UP_VAVLE = 0;
  352. HL_JD_VAVLE = 0;
  353. HL_CCX_VAVLE = 0;
  354. HL_DK_GO_VAVLE = 0;
  355. HL_YD_VAVLE = 0;
  356. HL_SJ_VAVLE = 0;
  357. HL_CD_MOTOR = 0;
  358. HL_ALARM_OUT = 0;
  359. HL_bRunning = 0;
  360. HL_AutoStep = 0;
  361. HL_MotorStep = 0;
  362. HL_HLStep = 0;
  363. HL_ManDKStep = 0;
  364. SingOneFlg = 0;
  365. HL_bMotor = 0;
  366. cDWflg = 0;
  367. cZCXflg = 0;
  368. cHLflg = 0;
  369. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  370. if(X_DRV)
  371. AxisEgmStop(X_AXIS);
  372. else
  373. SetEn(X_AXIS,HL_MOTOR_DISEN);
  374. }
  375. /* else
  376. {
  377. HL_HM_VAVLE = 0;
  378. HL_TFK_VAVLE = 0;
  379. HL_BB_VAVLE = 0;
  380. HL_DK_UP_VAVLE = 0;
  381. HL_JD_VAVLE = 0;
  382. HL_CCX_VAVLE = 0;
  383. HL_DK_GO_VAVLE = 0;
  384. HL_YD_VAVLE = 0;
  385. HL_SJ_VAVLE = 0;
  386. HL_CD_MOTOR = 0;
  387. HL_bRunning = 0;
  388. HL_AutoStep = 0;
  389. HL_MotorStep = 0;
  390. HL_HLStep = 0;
  391. SingOneFlg = 0;
  392. cDWflg = 0;
  393. cZCXflg = 0;
  394. cHLflg = 0;
  395. HL_bMotor = 0;
  396. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  397. AxisEgmStop(X_AXIS);
  398. }*/
  399. }
  400. if(HL_bAlarmStop)
  401. {
  402. HL_ALARM_OUT = 1;
  403. HL_bAlarmStop = 0;
  404. AxisEgmStop(X_AXIS);
  405. HL_AutoStep = 0;
  406. HL_ManDKStep = 0;
  407. HL_MotorStep = 0;
  408. HL_HLStep = 0;
  409. HL_bRunning = 0;
  410. SingOneFlg = 0;
  411. cDWflg = 0;
  412. cZCXflg = 0;
  413. cHLflg = 0;
  414. }
  415. }
  416. //合链动作
  417. void HL_Step(void)
  418. {
  419. static long hm_save_buff;
  420. switch(HL_HLStep)
  421. {
  422. case 1:
  423. if(HL_GUO_LIAN_IN_UP)//过链上升沿
  424. {
  425. hm_save_buff = dwRealPos;
  426. HL_HLStep = 2;
  427. }
  428. break;
  429. case 2://上升沿后延迟长度开合模
  430. if(cErrorStop_Flg == 0)
  431. {
  432. if(((dwRealPos + HL_PARAM_DELAY_HM_BACK) <= hm_save_buff) || (!X_DRV))
  433. {
  434. HL_HM_VAVLE = 0;//开模
  435. HL_HLDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  436. HL_HLStep = 3;
  437. }
  438. // else if(!X_DRV)HL_SetAlarmCode(HL_HM_BACK_ALARM);
  439. }
  440. else
  441. {
  442. if(((dwRealPos + HL_PARAM_ERROR_DELAY_STOP-150) <= hm_save_buff) || (!X_DRV))
  443. {
  444. HL_HM_VAVLE = 0;//开模
  445. HL_HLDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  446. HL_HLStep = 3;
  447. }
  448. }
  449. break;
  450. case 3: //上下模到位离开
  451. if(!HL_SM_LIMIT_IN && !HL_XM_LIMIT_IN)
  452. {
  453. HL_HLStep = 4;
  454. //延时关摆臂
  455. HL_HLDelay = dwTickCount + HL_PARAM_DELAY_BB_BACK;
  456. }
  457. else if(dwTickCount >= HL_HLDelay)
  458. {
  459. if(HL_SM_LIMIT_IN)HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  460. else HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  461. }
  462. break;
  463. case 4:
  464. if(dwTickCount >= HL_HLDelay) //开模延时关摆臂
  465. {
  466. HL_HLStep = 5;
  467. HL_BB_VAVLE = 0; //
  468. HL_HLDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  469. HL_TFK_VAVLE = 1; //推方块输出
  470. }
  471. break;
  472. case 5:
  473. if(!HL_BB_LIMIT_IN) //摆臂到位信号灭
  474. {
  475. HL_HLStep = 0;
  476. if(SingOneFlg) //单一自动
  477. {
  478. SingOneFlg = 0;
  479. HL_AutoStep = 0;
  480. HL_bRunning = 0;
  481. HL_MotorStep = 0;
  482. }
  483. HL_HLDelay = dwTickCount;
  484. }
  485. else if(dwTickCount >= HL_HLDelay)
  486. {
  487. HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  488. }
  489. break;
  490. }
  491. }
  492. void HL_PWMAction(void)
  493. {
  494. }
  495. //电机动作
  496. void HL_Motor(void) //
  497. {
  498. static long save_buff;
  499. dwRealPos = GetPos(X_AXIS);
  500. DISPLAY_DATA0 = dwRealPos;
  501. DISPLAY_DATA1 = HL_AutoStep;
  502. DISPLAY_DATA2 = HL_MotorStep;
  503. DISPLAY_DATA3 = tXAxisStepper.cPmovPulse;//HL_HLStep;
  504. DISPLAY_DATA4 = tXAxisStepper.bAuto_Mov;//save_buff;
  505. //实时位置
  506. switch(HL_MotorStep)
  507. {
  508. case 0:break;
  509. case 1:
  510. // if(GetEn(X_AXIS) == 0) //未锁轴情况下有锁轴时间
  511. // {
  512. // SetEn(X_AXIS,HL_MOTOR_EN);
  513. // HL_MotorDelay = dwTickCount + 300; //100MSq锁轴时间
  514. // else
  515. HL_MotorDelay = dwTickCount + 0;
  516. HL_MotorStep = 2;
  517. break;
  518. case 2:
  519. if(dwTickCount >= HL_MotorDelay)
  520. {
  521. // if(START_IN)
  522. {
  523. HL_MotorDelay = dwTickCount + HL_PARAM_MOTOR_ALARM_TIME;
  524. SetPos(X_AXIS, 0);
  525. // DISPLAY_DATA5 = -dwRealPos-HL_PARAM_DELAY_STOP-300;
  526. if(dwZipCnt >= 2) //2条后测出拉链长度
  527. {
  528. AxisMovePosAccDecNotStop(X_AXIS,HL_PARAM_HIGH_SPEED*6/5,-(-dwRealPos-HL_PARAM_DELAY_STOP-200),6,HL_PARAM_HIGH_SPEED,2,4);
  529. // DISPLAY_DATA6 = tXAxisStepper.cCalAccPulse;
  530. // DISPLAY_DATA7 = tXAxisStepper.cCalSpeed;
  531. }
  532. else
  533. {
  534. if(cErrorStop_Flg)
  535. MoveAction_Const_AccDec(X_AXIS,HL_DIR_P,6,2,6,1);
  536. else
  537. MoveAction_Const_AccDec(X_AXIS,HL_DIR_P,HL_PARAM_HIGH_SPEED,2,6,1);
  538. }
  539. HL_MotorStep = 3;
  540. *offset_length_buff = 0;
  541. if(HL_HM_VAVLE) //如果合模有输出启动合链
  542. {
  543. if(HL_HLStep == 0)
  544. HL_HLStep = 1;
  545. }
  546. }
  547. }
  548. break;
  549. case 3://过链感应下降沿
  550. if(HL_GUO_LIAN_IN)
  551. { //变为低速
  552. if(cErrorStop_Flg == 0)
  553. {
  554. if(dwZipCnt >= 2)
  555. {
  556. tXAxisStepper.State = 1;
  557. // CancelPmoveState(X_AXIS);
  558. }
  559. if(tXAxisStepper.cCurSpeed >= HL_PARAM_HIGH_SPEED)
  560. AxisMovePosAccDec_LYQ(X_AXIS,tXAxisStepper.cCurSpeed,HL_PARAM_DELAY_STOP,
  561. tXAxisStepper.cCurSpeed,4,5,5);
  562. else
  563. AxisMovePosAccDec_LYQ(X_AXIS,HL_PARAM_HIGH_SPEED,HL_PARAM_DELAY_STOP,
  564. tXAxisStepper.cCurSpeed,4,5,5);
  565. // AxisChangeSpeed(X_AXIS,HL_PARAM_LOW_SPEED);
  566. //空位延时检测
  567. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_CHECK_TIME;
  568. HL_MotorStep = 6;
  569. save_buff = dwRealPos; //当位置保存
  570. }
  571. else //联网故障停时慢速停止
  572. {
  573. HL_MotorStep = 6;
  574. save_buff = dwRealPos; //当位置保存
  575. AxisMovePosAccDec_LYQ(X_AXIS,tXAxisStepper.cCurSpeed,HL_PARAM_ERROR_DELAY_STOP,
  576. tXAxisStepper.cCurSpeed,4,2,5);
  577. }
  578. }
  579. else if(dwTickCount >= HL_MotorDelay)//长时间没信号警告
  580. HL_SetAlarmCode(HL_GUOLIAN_ALARM);
  581. else //联机控制
  582. {
  583. if(HL_PARAM_CONNECT_MODE)
  584. {
  585. if(HL_LW_START_IN)
  586. {
  587. if(dwTickCount >= HL_MotorDelay)
  588. {
  589. if(!X_DRV)
  590. {
  591. HL_MotorStep = 2;
  592. HL_MotorDelay = dwTickCount;
  593. }
  594. }
  595. }
  596. else
  597. {
  598. if(HL_LW_STOP_IN)
  599. {
  600. HL_MotorStep = 50;
  601. AxisEgmStop(X_AXIS);
  602. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_START;
  603. }
  604. }
  605. }
  606. #if 0 //郑广程序
  607. if(work_flg)
  608. {
  609. if(!X_DRV)
  610. {
  611. HL_MotorStep = 2;
  612. HL_MotorDelay = dwTickCount;
  613. }
  614. }
  615. else if(HL_GUO_LIAN_IN)
  616. {
  617. if(X_DRV)AxisEgmStop(X_AXIS);
  618. }
  619. #endif
  620. }
  621. break;
  622. case 4:
  623. if(dwTickCount >= HL_MotorDelay)
  624. {
  625. HL_MotorStep = 5;
  626. HL_MotorDelay = dwTickCount + HL_PARAM_MOTOR_ALARM_TIME;
  627. }
  628. break;
  629. case 5:
  630. //过链上升沿
  631. if(HL_GUO_LIAN_IN_UP)
  632. {
  633. AxisChangeSpeed(X_AXIS,HL_PARAM_LOW_SPEED);
  634. save_buff = dwRealPos; //当位置保存
  635. HL_MotorStep = 6;
  636. }
  637. else if(dwTickCount >= HL_MotorDelay)//规定时间没到链上警告
  638. HL_SetAlarmCode(HL_GUOLIAN_ALARM);
  639. case 6: // 定位长度
  640. if(!X_DRV)
  641. {
  642. HL_MotorStep = 7;
  643. }
  644. if((dwRealPos + HL_PARAM_DELAY_STOP) <= save_buff)
  645. {
  646. // AxisEgmStop(X_AXIS);
  647. // HL_MotorStep = 7;
  648. }
  649. break;
  650. case 7://定位和合链完成
  651. if(!X_DRV && (HL_HLStep == 0))
  652. {
  653. HL_MotorStep = 0;
  654. HL_MotorDelay = dwTickCount;
  655. }
  656. break;
  657. case 50:
  658. if(HL_LW_START_IN)
  659. {
  660. if(dwTickCount >= HL_MotorDelay)
  661. {
  662. if(!X_DRV)
  663. {
  664. HL_MotorStep = 2;
  665. HL_MotorDelay = dwTickCount;
  666. dwZipCnt = 0;
  667. cErrorStop_Flg = 1;
  668. }
  669. }
  670. }
  671. else
  672. {
  673. if(HL_LW_STOP_IN)
  674. {
  675. AxisEgmStop(X_AXIS);
  676. }
  677. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_START;
  678. }
  679. break;
  680. /*
  681. case 20:
  682. // if(!X_DRV)
  683. {
  684. HL_MotorStep = 21;
  685. HL_HM_VAVLE = 0;
  686. HL_MotorDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  687. }
  688. break;
  689. case 21:
  690. if(!HL_SM_LIMIT_IN && !HL_XM_LIMIT_IN)
  691. {
  692. HL_MotorStep = 22;
  693. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_BB_BACK;
  694. }
  695. else if(dwTickCount >= HL_MotorDelay)
  696. {
  697. if(HL_SM_LIMIT_IN)HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  698. else HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  699. }
  700. break;
  701. case 22:
  702. if(dwTickCount >= HL_MotorDelay)
  703. {
  704. if(cHLflg)
  705. HL_MotorStep = 0;
  706. else
  707. HL_MotorStep = 23;
  708. HL_BB_VAVLE = 0;
  709. if(SingOneFlg)
  710. {
  711. SingOneFlg = 0;
  712. HL_MotorStep = 0;
  713. HL_AutoStep = 0;
  714. HL_bRunning = 0;
  715. }
  716. HL_MotorDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  717. }
  718. break;
  719. case 23:
  720. if(!HL_BB_LIMIT_IN)
  721. {
  722. HL_MotorStep = 0;
  723. // if(!X_DRV)AxisMovePosAccDec(X_AXIS,HL_PARAM_LOW_SPEED,HL_PARAM_DELAY_STOP2,1,5,5);
  724. }
  725. else if(dwTickCount >= HL_MotorDelay)
  726. {
  727. HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  728. }
  729. break;
  730. case 24:
  731. if(!X_DRV)
  732. {
  733. HL_MotorStep = 0;
  734. HL_MotorDelay = dwTickCount;
  735. }
  736. break;
  737. */
  738. }
  739. }
  740. //自动运行动作
  741. void HL_AutoRunStep(void)
  742. {
  743. static long save_buff;
  744. static unsigned long yd_delay_back;
  745. static unsigned char yd_back_flg = 0;
  746. static unsigned long dk_up_delay;
  747. if((dwTickCount >= HL_YCXDelay) && HL_YCX_VAVLE)HL_YCX_VAVLE = 0;
  748. // if((dwTickCount >= HL_Y14Delay) && Y14)Y14 = 0;
  749. if(dwTickCount >= HL_Y15Delay) //工作完成输出信号延时关
  750. HL_OVEROUt_VAVLE = 0;
  751. if(HL_front_IN_DW)
  752. bCheckOK = 1;
  753. if(HL_bRunning)
  754. {
  755. if(yd_back_flg)
  756. {
  757. if(dwTickCount >= yd_delay_back)
  758. {
  759. yd_back_flg = 0;
  760. HL_YD_VAVLE = 0; //压带
  761. }
  762. }
  763. switch(HL_AutoStep)
  764. {
  765. case 1:
  766. HL_AutoStep = 2;
  767. SetEn(X_AXIS,HL_MOTOR_EN);
  768. HL_AutoDelay = dwTickCount + 300;
  769. break;
  770. case 2:
  771. if((dwTickCount >= HL_AutoDelay))
  772. {
  773. if(HL_MotorStep == 0)
  774. {////1为联机模式 //联网信号上 前机态拖带电机输出
  775. // if((!HL_PARAM_CONNECT_MODE))// || (!HL_STOP_IN && HL_front_IN && bCheckOK))//屏蔽部分为和前机有信号联动
  776. {
  777. HL_AutoStep = 3;
  778. HL_MotorStep = 1; //电机启动
  779. bCheckOK = 0;
  780. }
  781. // if((HL_front_IN_DW) && (work_Num == 0))
  782. // {
  783. // / work_Num++;
  784. // HL_OVEROUt_VAVLE = 1;
  785. // HL_Y15Delay = dwTickCount + 100;
  786. // }
  787. HL_CD_VAVLE = 0; //扯带电磁阀
  788. HL_SJ_VAVLE = 0; //松紧气缸
  789. }
  790. }
  791. break;
  792. case 3:
  793. if(HL_MotorStep == 0)
  794. {
  795. if(cDWflg | cHLflg)
  796. {
  797. HL_AutoDelay = dwTickCount + 150;
  798. HL_AutoStep =200;
  799. }
  800. else
  801. {
  802. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_TFK; // 延时推方块
  803. HL_AutoStep = 4;
  804. }
  805. }
  806. break;
  807. #if 0
  808. if((HL_front_IN_DW) && (work_Num == 0))
  809. {
  810. work_Num++;
  811. HL_OVEROUt_VAVLE = 1;
  812. HL_Y15Delay = dwTickCount + 100;
  813. }
  814. #endif
  815. case 4:
  816. if(dwTickCount >= HL_AutoDelay)
  817. {
  818. HL_TFK_VAVLE = 1; //推方块输出
  819. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  820. HL_AutoStep = 5;
  821. }
  822. break;
  823. case 5:
  824. if(HL_TFK_LIMIT_IN) //推方块到位
  825. {
  826. HL_AutoStep = 6;
  827. //延时合模
  828. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_HM;
  829. }
  830. else if(dwTickCount >= HL_AutoDelay)
  831. {
  832. HL_SetAlarmCode(HL_TFK_LIMIT_ALARM);
  833. }
  834. break;
  835. case 6:
  836. if(dwTickCount >= HL_AutoDelay)
  837. {
  838. HL_HM_VAVLE = 1; //Y00 //合模
  839. HL_SJ_VAVLE = 1; //Y10 //松紧气缸
  840. HL_YD_VAVLE = 1; // 压带
  841. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  842. HL_AutoStep = 7;
  843. }
  844. break;
  845. case 7:
  846. //上下模合模到位
  847. if(HL_SM_LIMIT_IN && HL_XM_LIMIT_IN)
  848. {
  849. HL_AutoStep = 8;
  850. //延时关推方块
  851. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_TFK_BACK;
  852. }
  853. else if(dwTickCount >= HL_AutoDelay)
  854. {
  855. if(!HL_SM_LIMIT_IN)
  856. HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  857. else
  858. HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  859. }
  860. break;
  861. case 8:
  862. if(dwTickCount >= HL_AutoDelay)
  863. {
  864. HL_AutoStep = 9;
  865. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  866. HL_TFK_VAVLE = 0;
  867. }
  868. break;
  869. case 9:
  870. if(!HL_TFK_LIMIT_IN)//HL_TFK_ORIGIN_IN) //推方块离开到位信号,回到原点
  871. {
  872. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_DK_UP;
  873. HL_AutoStep = 10;
  874. }
  875. else if(dwTickCount >= HL_AutoDelay)
  876. HL_SetAlarmCode(HL_TFK_ORIGIN_ALARM);
  877. break;
  878. case 10:
  879. if((dwTickCount >= HL_AutoDelay))
  880. {
  881. HL_DK_UP_VAVLE = 1; //Y03 //挡块上下
  882. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  883. HL_AutoStep = 11;
  884. }
  885. break;
  886. case 11:
  887. // if(!HL_DK_UP_LIMIT_IN) //挡块上到位
  888. {
  889. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_DK_GO; //延时输出挡块前后
  890. HL_AutoStep = 100;
  891. }
  892. // else if(dwTickCount >= HL_AutoDelay)
  893. // HL_SetAlarmCode(HL_DK_UP_LIMIT_ALARM);
  894. break;
  895. case 100:
  896. if(dwTickCount >= HL_AutoDelay)
  897. {
  898. HL_DK_GO_VAVLE = 1; ////挡块前后输出
  899. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  900. HL_AutoStep = 12;
  901. }
  902. break;
  903. case 12:
  904. if(HL_DK_LIMIT_IN && (!HL_DK_UP_LIMIT_IN) && HL_TFK_ORIGIN_IN)//挡块前后输出到位
  905. {
  906. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_BB;
  907. HL_YCX_VAVLE = 1; //压插销电磁阀
  908. // Y14 = 1;
  909. HL_YCXDelay = dwTickCount + HL_PARAM_YCX_TIME;
  910. HL_Y14Delay = dwTickCount + HL_PARAM_DELAY_Y14_BACK;
  911. HL_AutoStep = 13;
  912. }
  913. else if(dwTickCount >= HL_AutoDelay)
  914. {
  915. if(HL_DK_UP_LIMIT_IN)
  916. HL_SetAlarmCode(HL_DK_UP_LIMIT_ALARM);
  917. else if(!HL_TFK_ORIGIN_IN)
  918. HL_SetAlarmCode(HL_TFK_ORIGIN_ALARM);
  919. else
  920. HL_SetAlarmCode(HL_DK_LIMIT_ALARM);
  921. }
  922. break;
  923. case 13:
  924. if(dwTickCount >= HL_AutoDelay)
  925. {
  926. // if(HL_PARAM_BB_ENABLE == 0)
  927. HL_BB_VAVLE = 1; //摆臂输出
  928. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  929. HL_AutoStep = 14;
  930. }
  931. break;
  932. case 14:
  933. // if(HL_PARAM_BB_ENABLE == 0)
  934. {
  935. if(HL_BB_LIMIT_IN)//摆臂到位
  936. {
  937. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  938. HL_AutoStep = 15;
  939. if(HL_PARAM_CCX_MODE == 0) //气缸穿入
  940. {
  941. // AxisMovePosAccDec(X_AXIS,8,120,3,5,5);
  942. save_buff = dwRealPos;
  943. AxisMovePosAccDec(X_AXIS,HL_PARAM_CCX_SPEED,HL_PARAM_CCX_LENGTH,4,5,5);
  944. HL_AutoDelay = dwTickCount + 2;
  945. }
  946. }
  947. else if(dwTickCount >= HL_AutoDelay)
  948. HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  949. }
  950. // else
  951. // {
  952. // HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_BB;
  953. // HL_AutoStep = 15;
  954. // }
  955. break;
  956. case 15:
  957. if(dwTickCount >= HL_AutoDelay)
  958. {
  959. if(HL_PARAM_CCX_MODE)////穿插销模式 1为电机穿 0为夹带气缸穿
  960. {
  961. if(HL_PARAM_BB_ENABLE) //后输出模式
  962. {
  963. HL_BB_VAVLE = 1;
  964. HL_AutoStep = 180;
  965. HL_AutoDelay = dwTickCount+HL_PARAM_DELAY_CCX;
  966. }
  967. else
  968. {
  969. if(!X_DRV)
  970. {
  971. AxisMovePosAccDec(X_AXIS,HL_PARAM_CCX_SPEED,HL_PARAM_CCX_LENGTH,1,5,5);
  972. HL_AutoDelay = dwTickCount;
  973. HL_AutoStep = 16;
  974. }
  975. }
  976. }
  977. else
  978. {
  979. if(HL_PARAM_BB_ENABLE)
  980. HL_BB_VAVLE = 1;
  981. //原来45
  982. if(((dwRealPos + 12) <= save_buff) || !X_DRV)
  983. {
  984. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  985. HL_JD_VAVLE = 1;
  986. HL_AutoStep = 16;
  987. }
  988. }
  989. }
  990. break;
  991. case 180:
  992. if((dwTickCount >= HL_AutoDelay))
  993. {
  994. if(!X_DRV)
  995. AxisMovePosAccDec(X_AXIS,HL_PARAM_CCX_SPEED,HL_PARAM_CCX_LENGTH,1,5,5);
  996. HL_AutoDelay = dwTickCount;
  997. HL_AutoStep = 16;
  998. }
  999. break;
  1000. case 16:
  1001. if((dwTickCount >= HL_AutoDelay) && !HL_YCX_VAVLE)
  1002. {
  1003. if(HL_PARAM_CCX_MODE)
  1004. {
  1005. if(!X_DRV)
  1006. {
  1007. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  1008. HL_CheckDelay = dwTickCount + HL_PARAM_DELAY_CHECK_CCX;
  1009. HL_AutoStep = 17;
  1010. if(HL_PARAM_CD_ENABLE) //1为带扯带功能
  1011. HL_JD_VAVLE = 1;
  1012. }
  1013. }
  1014. else
  1015. {
  1016. HL_CCX_VAVLE = 1;
  1017. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  1018. HL_CheckDelay = dwTickCount + HL_PARAM_DELAY_CHECK_CCX;
  1019. HL_AutoStep = 17;
  1020. if(HL_PARAM_CD_ENABLE)
  1021. HL_JD_VAVLE = 1;
  1022. }
  1023. }
  1024. break;
  1025. case 17:
  1026. if((dwTickCount >= HL_CheckDelay))
  1027. {
  1028. if(HL_CCX_LIMIT_IN)
  1029. {
  1030. if(HL_PARAM_CCX_MODE)
  1031. {
  1032. HL_DK_UP_VAVLE = 0;
  1033. HL_DK_GO_VAVLE = 0; ////挡块前后关
  1034. // if(HL_PARAM_CD_ENABLE)
  1035. // SetEn(X_AXIS,HL_MOTOR_DISEN);
  1036. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  1037. HL_AutoStep = 18;
  1038. }
  1039. else
  1040. {
  1041. HL_DK_UP_VAVLE = 0;
  1042. HL_DK_GO_VAVLE = 0; ////挡块前后关
  1043. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD_BACK;
  1044. HL_AutoStep = 50;
  1045. }
  1046. }
  1047. else if(dwTickCount >= HL_AutoDelay)
  1048. HL_SetAlarmCode(HL_CCX_LIMIT_ALARM);
  1049. }
  1050. break;
  1051. case 50:
  1052. if(dwTickCount >= HL_AutoDelay)
  1053. {
  1054. HL_JD_VAVLE = 0;
  1055. HL_AutoDelay = dwTickCount + 5;
  1056. HL_AutoStep = 51;
  1057. }
  1058. break;
  1059. case 51:
  1060. if(dwTickCount >= HL_AutoDelay)
  1061. {
  1062. // if(!X_DRV)AxisMovePosAccDec(X_AXIS,HL_PARAM_CCX_SPEED,HL_PARAM_CCX_LENGTH,4,5,5);
  1063. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  1064. HL_AutoStep = 18;
  1065. }
  1066. break;
  1067. case 18:
  1068. if(HL_DK_UP_LIMIT_IN && !X_DRV && ((HL_BB_LIMIT_IN && (HL_PARAM_BB_ENABLE == 0)) || (HL_PARAM_BB_ENABLE == 1)))
  1069. {
  1070. HL_CCX_VAVLE = 0;
  1071. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_BACK_DK_UP;
  1072. HL_AutoStep = 19;
  1073. }
  1074. else if(dwTickCount >= HL_AutoDelay)
  1075. {
  1076. if(!HL_DK_UP_LIMIT_IN)HL_SetAlarmCode(HL_DK_UP_LIMIT_ALARM);
  1077. else HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  1078. }
  1079. break;
  1080. case 19:
  1081. if(dwTickCount >= HL_AutoDelay)
  1082. {
  1083. HL_DK_GO_VAVLE = 0;
  1084. if(!HL_PARAM_CCX_TIMES)
  1085. {
  1086. yd_back_flg = 1;
  1087. yd_delay_back = dwTickCount + HL_PARAM_DELAY_YD_BACK;
  1088. }
  1089. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  1090. HL_AutoStep = 20;
  1091. }
  1092. break;
  1093. case 20:
  1094. if(HL_DK_ORIGIN_IN)
  1095. {
  1096. if(HL_PARAM_CCX_MODE)
  1097. {
  1098. HL_AutoDelay = dwTickCount;
  1099. if(HL_PARAM_CD_ENABLE)
  1100. HL_AutoStep = 21;
  1101. else
  1102. HL_AutoStep = 25;
  1103. }
  1104. else
  1105. {
  1106. if(!HL_PARAM_CCX_TIMES)
  1107. {
  1108. HL_AutoDelay = dwTickCount;
  1109. HL_AutoStep = 25;
  1110. }
  1111. else
  1112. {
  1113. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD;
  1114. HL_AutoStep = 21;
  1115. }
  1116. }
  1117. }
  1118. else if(dwTickCount >= HL_AutoDelay)
  1119. HL_SetAlarmCode(HL_DK_ORIGIN_ALARM);
  1120. break;
  1121. case 21:
  1122. if(dwTickCount >= HL_AutoDelay)
  1123. {
  1124. HL_JD_VAVLE = 1;
  1125. if(HL_PARAM_CD_ENABLE)
  1126. {
  1127. HL_AutoStep = 150;
  1128. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CD;
  1129. }
  1130. else
  1131. {
  1132. HL_AutoStep = 22;
  1133. if(!HL_PARAM_CCX_MODE)HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  1134. }
  1135. }
  1136. break;
  1137. case 150:
  1138. if((dwTickCount >= HL_AutoDelay))
  1139. {
  1140. HL_CD_VAVLE = 1;
  1141. if(!HL_PARAM_CCX_MODE)HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  1142. HL_AutoStep = 22;
  1143. }
  1144. break;
  1145. case 22:
  1146. if((dwTickCount >= HL_AutoDelay))
  1147. {
  1148. HL_CCX_VAVLE = 1;
  1149. HL_AutoStep = 23;
  1150. }
  1151. break;
  1152. case 23:
  1153. if(dwTickCount >= HL_AutoDelay)
  1154. {
  1155. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD_BACK;
  1156. HL_AutoStep = 24;
  1157. }
  1158. break;
  1159. case 24:
  1160. if(dwTickCount >= HL_AutoDelay)
  1161. {
  1162. HL_JD_VAVLE = 0;
  1163. // HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  1164. HL_AutoStep = 25;
  1165. }
  1166. break;
  1167. case 25:
  1168. if((dwTickCount >= HL_AutoDelay))
  1169. {
  1170. if(HL_PARAM_BB_ENABLE)HL_BB_VAVLE = 0;
  1171. HL_CCX_VAVLE = 0;
  1172. HL_JD_VAVLE = 0;
  1173. yd_back_flg = 1;
  1174. cErrorStop_Flg = 0;
  1175. yd_delay_back = dwTickCount + HL_PARAM_DELAY_YD_BACK;
  1176. if(cZCXflg)
  1177. {
  1178. cZCXflg = 0;
  1179. HL_AutoStep = 0;
  1180. HL_bRunning = 0;
  1181. }
  1182. else
  1183. {
  1184. HL_AutoStep = 26;
  1185. }
  1186. }
  1187. break;
  1188. case 26:
  1189. if(HL_PARAM_CONNECT_MODE)
  1190. {
  1191. work_Num = 0;
  1192. HL_OVEROUt_VAVLE = 1;
  1193. HL_Y15Delay = dwTickCount + 100;
  1194. }
  1195. AddToTal(HL_TOTAL_ADDR);
  1196. dwZipCnt++;
  1197. if(GetTotal(HL_TOTAL_ADDR) >= HL_PARAM_SET_TOTAL)
  1198. {
  1199. HL_SetAlarmCode(HL_TOTAL_ALARM);
  1200. }
  1201. else
  1202. {
  1203. HL_AutoStep = 2;
  1204. HL_AutoDelay = HL_PARAM_CYCLE_DELAY + dwTickCount;
  1205. CalProSP(HL_PROSPEED_ADDR);
  1206. }
  1207. break;
  1208. case 71:
  1209. if(dwTickCount >= HL_AutoDelay)
  1210. {
  1211. HL_JD_VAVLE = 1;
  1212. HL_DK_GO_VAVLE = 0;
  1213. HL_AutoStep = 72;
  1214. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  1215. dk_up_delay = dwTickCount +HL_PARAM_DELAY_BACK_DK_UP;
  1216. }
  1217. break;
  1218. case 72:
  1219. if(dwTickCount >= HL_AutoDelay)
  1220. {
  1221. if(dwTickCount >= dk_up_delay)HL_DK_UP_VAVLE = 0;
  1222. HL_CCX_VAVLE = 1;
  1223. HL_AutoStep = 73;
  1224. }
  1225. break;
  1226. case 73:
  1227. if(dwTickCount >= HL_AutoDelay)
  1228. {
  1229. if(dwTickCount >= dk_up_delay)HL_DK_UP_VAVLE = 0;
  1230. if(HL_CCX_LIMIT_IN)
  1231. {
  1232. HL_AutoDelay = dwTickCount;
  1233. HL_AutoStep = 74;
  1234. }
  1235. }
  1236. break;
  1237. case 74:
  1238. if(dwTickCount >= HL_AutoDelay)
  1239. {
  1240. if(dwTickCount >= dk_up_delay)HL_DK_UP_VAVLE = 0;
  1241. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD_BACK;
  1242. HL_AutoStep = 75;
  1243. }
  1244. break;
  1245. case 75:
  1246. if(dwTickCount >= HL_AutoDelay)
  1247. {
  1248. HL_JD_VAVLE = 0;
  1249. {
  1250. HL_AutoStep = 76;
  1251. HL_AutoDelay = dwTickCount;
  1252. }
  1253. }
  1254. break;
  1255. case 76:
  1256. if(dwTickCount >= HL_AutoDelay)
  1257. {
  1258. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  1259. HL_AutoStep = 77;
  1260. }
  1261. break;
  1262. case 77:
  1263. if(dwTickCount >= HL_AutoDelay)
  1264. {
  1265. HL_DK_UP_VAVLE = 0;
  1266. HL_CCX_VAVLE = 0;
  1267. yd_back_flg = 1;
  1268. yd_delay_back = dwTickCount + HL_PARAM_DELAY_YD_BACK;
  1269. if(HL_DK_UP_LIMIT_IN && (HL_DK_ORIGIN_IN))
  1270. {
  1271. if(cZCXflg)
  1272. {
  1273. cZCXflg = 0;
  1274. HL_AutoStep = 0;
  1275. HL_bRunning = 0;
  1276. }
  1277. else
  1278. {
  1279. HL_AutoStep = 26;
  1280. }
  1281. }
  1282. }
  1283. break;
  1284. case 200:
  1285. if(dwTickCount >= HL_AutoDelay)
  1286. {
  1287. cDWflg = 0;
  1288. cHLflg = 0;
  1289. HL_AutoStep = 0;
  1290. HL_bRunning = 0;
  1291. }
  1292. break;
  1293. }
  1294. }
  1295. }
  1296. #endif