TYHeLian.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. #include "global.h"
  2. #if TONG_YONG_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. unsigned char cDWflg=0,cZCXflg=0,cHLflg=0;
  11. unsigned char cBBflg = 0;
  12. short *offset_length_buff;
  13. void HL_SetAlarmCode(unsigned alarm_code)
  14. {
  15. SetAlarmCode(HL_ALARM_ADDR,alarm_code);
  16. HL_bAlarmStop = 1;
  17. }
  18. void HL_InitAction(void)
  19. {
  20. CalFreqTab_X_Free(14);
  21. XGearRatio = 1;
  22. }
  23. //手动动作
  24. void HL_ManualAction(void)
  25. {
  26. if(!HL_bRunning)
  27. {
  28. //警告跳出
  29. if(bClearTotal)
  30. {
  31. bClearTotal = 0;
  32. ClrcToTal(HL_TOTAL_ADDR);
  33. HL_bSetWorkData = 1;
  34. }
  35. if(HL_bAdd)
  36. {
  37. HL_bAdd = 0;
  38. HL_PARAM_DELAY_STOP += 10;
  39. }
  40. if(HL_bDec)
  41. {
  42. HL_bDec = 0;
  43. if(HL_PARAM_DELAY_STOP >= 10)HL_PARAM_DELAY_STOP -= 10;
  44. }
  45. if(HL_bHM)
  46. {
  47. HL_bHM = 0;
  48. HL_HM_VAVLE = ~HL_HM_VAVLE;
  49. if(HL_HM_VAVLE == 0)HL_YD_VAVLE = 0;
  50. }
  51. if(HL_bTFK)
  52. {
  53. HL_bTFK = 0;
  54. HL_TFK_VAVLE = ~HL_TFK_VAVLE;
  55. }
  56. if(HL_bBB)
  57. {
  58. HL_bBB = 0;
  59. HL_BB_VAVLE = ~HL_BB_VAVLE;
  60. if(HL_BB_VAVLE)cBBflg = 1;
  61. }
  62. if(cBBflg)
  63. {
  64. if(HL_BB_LIMIT_IN)
  65. {
  66. cBBflg = 0;
  67. }
  68. }
  69. if(HL_bYCX)
  70. {
  71. HL_bYCX = 0;
  72. HL_YCX_VAVLE = 1;
  73. HL_YCXDelay = dwTickCount + HL_PARAM_YCX_TIME;
  74. }
  75. if(HL_bDK_UP)
  76. {
  77. HL_bDK_UP = 0;
  78. HL_DK_UP_VAVLE = ~HL_DK_UP_VAVLE;
  79. }
  80. if(HL_bJD)
  81. {
  82. HL_bJD = 0;
  83. HL_JD_VAVLE = ~HL_JD_VAVLE;
  84. }
  85. if(HL_bCCX)
  86. {
  87. HL_bCCX = 0;
  88. HL_CCX_VAVLE = ~HL_CCX_VAVLE;
  89. }
  90. if(HL_bYD)
  91. {
  92. HL_bYD = 0;
  93. HL_YD_VAVLE = ~HL_YD_VAVLE;
  94. }
  95. if(HL_bSJ)
  96. {
  97. HL_bSJ = 0;
  98. HL_SJ_VAVLE = ~HL_SJ_VAVLE;
  99. }
  100. if(HL_bHMYD)
  101. {
  102. HL_bHMYD = 0;
  103. if(HL_HM_VAVLE)
  104. {
  105. HL_HM_VAVLE = 0;
  106. }
  107. else
  108. {
  109. HL_HM_VAVLE = 1;
  110. }
  111. }
  112. if(HL_bDKUP)
  113. {
  114. HL_bDKUP = 0;
  115. if(HL_DK_UP_VAVLE)
  116. {
  117. HL_DK_UP_VAVLE = 0;
  118. HL_YD_VAVLE = 0;
  119. }
  120. else
  121. {
  122. HL_DK_UP_VAVLE = 1;
  123. }
  124. }
  125. if(HL_bCD)
  126. {
  127. HL_bCD = 0;
  128. HL_CD_MOTOR = ~HL_CD_MOTOR;
  129. }
  130. if(HL_bMotor)
  131. {
  132. SetEn(X_AXIS,HL_MOTOR_EN);
  133. if(!X_DRV)AxisContinueMove(X_AXIS,10,HL_DIR_P);
  134. }
  135. else
  136. {
  137. if(X_DRV)AxisDecStop(X_AXIS);
  138. }
  139. }
  140. }
  141. //合链动作
  142. void HL_Action(void)
  143. {
  144. HL_ManualAction();
  145. HL_StartStopAction();
  146. HL_Motor();
  147. HL_Step();
  148. HL_AutoRunStep();
  149. }
  150. //启动停止故障停止动作
  151. void HL_StartStopAction(void)
  152. {
  153. static unsigned long dwstop_cnt = 0;
  154. if((START_IN_UP || HL_bStart || HL_bSingStart || HL_bDW || HL_bZCX || HL_bHL) && !HL_bRunning && (HL_AutoStep ==0))
  155. {
  156. if(GetTotal(HL_TOTAL_ADDR) >= SET_TOTAL)HL_SetAlarmCode(HL_TOTAL_ALARM);
  157. else
  158. {
  159. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  160. HL_bRunning = 1;
  161. dwZipCnt = 0;
  162. if(HL_bSingStart)
  163. {
  164. HL_bSingStart = 0;
  165. SingOneFlg = 1;
  166. }
  167. if(HL_bDW)
  168. {
  169. cDWflg = 1;
  170. dwZipCnt = 1;
  171. }
  172. if(HL_bZCX)cZCXflg = 1;
  173. if(HL_bHL)cHLflg = 1;
  174. if(HL_bZCX)HL_AutoStep = 4;
  175. else if(HL_bHL)HL_AutoStep = 1;
  176. else HL_AutoStep = 1;
  177. }
  178. HL_bDW = 0;
  179. HL_bZCX = 0;
  180. HL_bHL = 0;
  181. HL_bSingStart = 0;
  182. HL_bStart = 0;
  183. }
  184. if(!HL_bMotor && !X_DRV && !HL_bRunning && (HL_MotorStep==0))SetEn(X_AXIS,HL_MOTOR_DISEN);
  185. if(HL_bStop)
  186. {
  187. HL_bStop = 0;
  188. if(HL_bRunning)
  189. SingOneFlg = 1;
  190. else
  191. {
  192. HL_HM_VAVLE = 0;
  193. HL_TFK_VAVLE = 0;
  194. HL_BB_VAVLE = 0;
  195. HL_DK_UP_VAVLE = 0;
  196. HL_JD_VAVLE = 0;
  197. HL_CCX_VAVLE = 0;
  198. HL_YD_VAVLE = 0;
  199. HL_SJ_VAVLE = 0;
  200. HL_CD_MOTOR = 0;
  201. HL_ALARM_OUT = 0;
  202. HL_bRunning = 0;
  203. HL_AutoStep = 0;
  204. HL_MotorStep = 0;
  205. SingOneFlg = 0;
  206. HL_bMotor = 0;
  207. cDWflg = 0;
  208. cZCXflg = 0;
  209. cHLflg = 0;
  210. HL_ManDKStep = 0;
  211. AxisEgmStop(X_AXIS);
  212. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  213. }
  214. }
  215. if(STOP_IN_UP)
  216. {
  217. HL_bStop = 0;
  218. if(HL_bRunning)
  219. {
  220. HL_TFK_VAVLE = 0;
  221. HL_DK_UP_VAVLE = 0;
  222. HL_JD_VAVLE = 0;
  223. HL_CCX_VAVLE = 0;
  224. HL_YD_VAVLE = 0;
  225. HL_SJ_VAVLE = 0;
  226. HL_CD_MOTOR = 0;
  227. HL_ALARM_OUT = 0;
  228. HL_bRunning = 0;
  229. HL_AutoStep = 0;
  230. HL_MotorStep = 0;
  231. HL_HLStep = 0;
  232. HL_ManDKStep = 0;
  233. SingOneFlg = 0;
  234. HL_bMotor = 0;
  235. cDWflg = 0;
  236. cZCXflg = 0;
  237. cHLflg = 0;
  238. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  239. AxisEgmStop(X_AXIS);
  240. }
  241. else
  242. {
  243. HL_TFK_VAVLE = 0;
  244. HL_BB_VAVLE = 0;
  245. HL_HM_VAVLE = 0;
  246. HL_DK_UP_VAVLE = 0;
  247. HL_JD_VAVLE = 0;
  248. HL_CCX_VAVLE = 0;
  249. HL_YD_VAVLE = 0;
  250. HL_SJ_VAVLE = 0;
  251. HL_CD_MOTOR = 0;
  252. HL_bRunning = 0;
  253. HL_AutoStep = 0;
  254. HL_MotorStep = 0;
  255. HL_HLStep = 0;
  256. SingOneFlg = 0;
  257. cDWflg = 0;
  258. cZCXflg = 0;
  259. cHLflg = 0;
  260. HL_bMotor = 0;
  261. SetAlarmCode(HL_ALARM_ADDR,HL_NO_ALARM);
  262. AxisEgmStop(X_AXIS);
  263. }
  264. }
  265. if(HL_bAlarmStop)
  266. {
  267. HL_ALARM_OUT = 1;
  268. HL_bAlarmStop = 0;
  269. AxisEgmStop(X_AXIS);
  270. HL_AutoStep = 0;
  271. HL_ManDKStep = 0;
  272. HL_MotorStep = 0;
  273. HL_HLStep = 0;
  274. HL_bRunning = 0;
  275. SingOneFlg = 0;
  276. cDWflg = 0;
  277. cZCXflg = 0;
  278. cHLflg = 0;
  279. }
  280. }
  281. void HL_Step(void)
  282. {
  283. static long hm_save_buff;
  284. switch(HL_HLStep)
  285. {
  286. case 1:
  287. if(HL_GUO_LIAN_IN_UP)
  288. {
  289. hm_save_buff = dwRealPos;
  290. HL_HLStep = 2;
  291. }
  292. break;
  293. case 2:
  294. if((dwRealPos + HL_PARAM_DELAY_HM_BACK) <= hm_save_buff)
  295. {
  296. HL_HM_VAVLE = 0;
  297. HL_HLDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  298. HL_HLStep = 3;
  299. }
  300. else if(!X_DRV)HL_SetAlarmCode(HL_HM_BACK_ALARM);
  301. break;
  302. case 3:
  303. if(!HL_SM_LIMIT_IN && !HL_XM_LIMIT_IN)
  304. {
  305. HL_HLStep = 4;
  306. HL_HLDelay = dwTickCount + HL_PARAM_DELAY_BB_BACK;
  307. }
  308. else if(dwTickCount >= HL_HLDelay)
  309. {
  310. if(HL_SM_LIMIT_IN)HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  311. else HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  312. }
  313. break;
  314. case 4:
  315. if(dwTickCount >= HL_HLDelay)
  316. {
  317. HL_HLStep = 5;
  318. HL_BB_VAVLE = 0;
  319. HL_HLDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  320. }
  321. break;
  322. case 5:
  323. if(!HL_BB_LIMIT_IN)
  324. {
  325. HL_HLStep = 0;
  326. if(SingOneFlg)
  327. {
  328. SingOneFlg = 0;
  329. HL_AutoStep = 0;
  330. HL_bRunning = 0;
  331. HL_MotorStep = 0;
  332. }
  333. HL_HLDelay = dwTickCount;
  334. }
  335. else if(dwTickCount >= HL_HLDelay)
  336. {
  337. HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  338. }
  339. break;
  340. }
  341. }
  342. //电机动作
  343. void HL_Motor(void) //
  344. {
  345. static long save_buff,hm_save_buff;
  346. DISPLAY_DATA0 = user_datas[100];
  347. DISPLAY_DATA1 = HL_AutoStep;
  348. DISPLAY_DATA2 = HL_MotorStep;
  349. DISPLAY_DATA3 = HL_HLStep;
  350. dwRealPos = GetPos(X_AXIS);
  351. switch(HL_MotorStep)
  352. {
  353. case 0:break;
  354. case 1:
  355. if(GetEn(X_AXIS) == 0)
  356. {
  357. SetEn(X_AXIS,HL_MOTOR_EN);
  358. HL_MotorDelay = dwTickCount + 100;
  359. }
  360. HL_MotorStep = 2;
  361. break;
  362. case 2:
  363. if(dwTickCount >= HL_MotorDelay)
  364. {
  365. HL_MotorDelay = dwTickCount + HL_PARAM_MOTOR_ALARM_TIME;
  366. if(!HL_GUO_LIAN_IN)
  367. {
  368. MoveAction_Const_AccDec(X_AXIS,HL_DIR_P,HL_PARAM_LOW_SPEED,1,5,1);
  369. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_CHECK_TIME;
  370. HL_MotorStep = 4;
  371. }
  372. else
  373. {
  374. if(dwZipCnt == 0)
  375. MoveAction_Const_AccDec(X_AXIS,HL_DIR_P,HL_PARAM_HIGH_SPEED/3,1,5,1);
  376. else
  377. MoveAction_Const_AccDec(X_AXIS,HL_DIR_P,HL_PARAM_HIGH_SPEED,1,5,1);
  378. HL_MotorStep = 3;
  379. }
  380. if(HL_HM_VAVLE)
  381. {
  382. *offset_length_buff = 0;
  383. if(HL_HLStep == 0)HL_HLStep = 1;
  384. }
  385. else
  386. {
  387. *offset_length_buff = 0;
  388. }
  389. }
  390. break;
  391. case 3:
  392. if(HL_GUO_LIAN_IN_DW)
  393. {
  394. AxisChangeSpeed(X_AXIS,HL_PARAM_LOW_SPEED);
  395. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_CHECK_TIME;
  396. HL_MotorStep = 4;
  397. }
  398. else if(dwTickCount >= HL_MotorDelay)
  399. HL_SetAlarmCode(HL_GUOLIAN_ALARM);
  400. break;
  401. case 4:
  402. if(dwTickCount >= HL_MotorDelay)
  403. {
  404. HL_MotorStep = 5;
  405. HL_MotorDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  406. }
  407. break;
  408. case 5:
  409. if(HL_GUO_LIAN_IN_UP)
  410. {
  411. save_buff = dwRealPos;
  412. HL_MotorStep = 6;
  413. }
  414. else if(dwTickCount >= HL_MotorDelay)
  415. HL_SetAlarmCode(HL_GUOLIAN_ALARM);
  416. break;
  417. case 6:
  418. if((dwRealPos + HL_PARAM_DELAY_STOP) <= save_buff)
  419. {
  420. AxisEgmStop(X_AXIS);
  421. HL_MotorStep = 7;
  422. }
  423. break;
  424. case 7:
  425. if(!X_DRV && (HL_HLStep == 0))
  426. {
  427. HL_MotorStep = 0;
  428. HL_MotorDelay = dwTickCount;
  429. }
  430. break;
  431. /* case 20:
  432. // if(!X_DRV)
  433. {
  434. HL_MotorStep = 21;
  435. HL_HM_VAVLE = 0;
  436. HL_MotorDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  437. }
  438. break;
  439. case 21:
  440. if(!HL_SM_LIMIT_IN && !HL_XM_LIMIT_IN)
  441. {
  442. HL_MotorStep = 22;
  443. HL_MotorDelay = dwTickCount + HL_PARAM_DELAY_BB_BACK;
  444. }
  445. else if(dwTickCount >= HL_MotorDelay)
  446. {
  447. if(HL_SM_LIMIT_IN)HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  448. else HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  449. }
  450. break;
  451. case 22:
  452. if(dwTickCount >= HL_MotorDelay)
  453. {
  454. if(cHLflg)
  455. HL_MotorStep = 0;
  456. else
  457. HL_MotorStep = 23;
  458. HL_BB_VAVLE = 0;
  459. if(SingOneFlg)
  460. {
  461. SingOneFlg = 0;
  462. HL_MotorStep = 0;
  463. HL_AutoStep = 0;
  464. HL_bRunning = 0;
  465. }
  466. HL_MotorDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  467. }
  468. break;
  469. case 23:
  470. if(!HL_BB_LIMIT_IN)
  471. {
  472. HL_MotorStep = 0;
  473. // if(!X_DRV)AxisMovePosAccDec(X_AXIS,HL_PARAM_LOW_SPEED,HL_PARAM_DELAY_STOP2,1,5,5);
  474. }
  475. else if(dwTickCount >= HL_MotorDelay)
  476. {
  477. HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  478. }
  479. break;
  480. case 24:
  481. if(!X_DRV)
  482. {
  483. HL_MotorStep = 0;
  484. HL_MotorDelay = dwTickCount;
  485. }
  486. break;*/
  487. }
  488. }
  489. //自动运行动作
  490. void HL_AutoRunStep(void)
  491. {
  492. if((dwTickCount >= HL_YCXDelay) && HL_YCX_VAVLE)HL_YCX_VAVLE = 0;
  493. if(HL_bRunning)
  494. {
  495. if(HL_AutoStep == 1)
  496. {
  497. HL_AutoStep = 2;
  498. }
  499. else if((HL_AutoStep == 2) && (dwTickCount >= HL_AutoDelay))
  500. {
  501. if(HL_MotorStep == 0)
  502. {
  503. HL_AutoStep = 3;
  504. HL_MotorStep = 1;
  505. HL_SJ_VAVLE = 0;
  506. }
  507. }
  508. else if(HL_AutoStep == 3)
  509. {
  510. if(HL_MotorStep == 0)
  511. {
  512. if(cDWflg | cHLflg)
  513. {
  514. cDWflg = 0;
  515. cHLflg = 0;
  516. HL_AutoStep = 0;
  517. HL_bRunning = 0;
  518. }
  519. else
  520. {
  521. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_TFK;
  522. HL_AutoStep = 4;
  523. }
  524. }
  525. }
  526. else if((HL_AutoStep == 4) && (dwTickCount >= HL_AutoDelay))
  527. {
  528. HL_TFK_VAVLE = 1;
  529. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  530. HL_AutoStep = 5;
  531. }
  532. else if(HL_AutoStep == 5)
  533. {
  534. if(HL_TFK_LIMIT_IN)
  535. {
  536. HL_AutoStep = 6;
  537. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_HM;
  538. }
  539. else if(dwTickCount >= HL_AutoDelay)
  540. {
  541. HL_SetAlarmCode(HL_TFK_LIMIT_ALARM);
  542. }
  543. }
  544. else if((HL_AutoStep == 6) && (dwTickCount >= HL_AutoDelay))
  545. {
  546. HL_HM_VAVLE = 1;
  547. HL_DK_UP_VAVLE = 1;
  548. HL_SJ_VAVLE = 1;
  549. HL_YD_VAVLE = 1;
  550. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  551. HL_AutoStep = 7;
  552. }
  553. else if(HL_AutoStep == 7)
  554. {
  555. if(HL_SM_LIMIT_IN && HL_XM_LIMIT_IN)
  556. {
  557. HL_AutoStep = 8;
  558. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_TFK_BACK;
  559. }
  560. else if(dwTickCount >= HL_AutoDelay)
  561. {
  562. if(!HL_SM_LIMIT_IN)
  563. HL_SetAlarmCode(HL_SM_LIMIT_ALARM);
  564. else
  565. HL_SetAlarmCode(HL_XM_LIMIT_ALARM);
  566. }
  567. }
  568. else if((HL_AutoStep == 8) && (dwTickCount >= HL_AutoDelay))
  569. {
  570. HL_AutoStep = 9;
  571. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  572. HL_TFK_VAVLE = 0;
  573. }
  574. else if(HL_AutoStep == 9)
  575. {
  576. if(HL_TFK_ORIGIN_IN)
  577. {
  578. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_BB;
  579. HL_AutoStep = 10;
  580. }
  581. else if(dwTickCount >= HL_AutoDelay)
  582. HL_SetAlarmCode(HL_TFK_ORIGIN_ALARM);
  583. }
  584. else if((HL_AutoStep == 10) && (dwTickCount >= HL_AutoDelay))
  585. {
  586. HL_BB_VAVLE = 1;
  587. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  588. HL_AutoStep = 12;
  589. }
  590. else if(HL_AutoStep == 12)
  591. {
  592. if(HL_BB_LIMIT_IN)
  593. {
  594. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_DK_UP;
  595. HL_AutoStep = 13;
  596. }
  597. else if(dwTickCount >= HL_AutoDelay)
  598. HL_SetAlarmCode(HL_BB_LIMIT_ALARM);
  599. }
  600. else if((HL_AutoStep == 13) && (dwTickCount >= HL_AutoDelay))
  601. {
  602. HL_DK_UP_VAVLE = 1;
  603. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  604. HL_AutoStep = 14;
  605. }
  606. else if(HL_AutoStep == 14)
  607. {
  608. if(HL_DK_UP_LIMIT_IN)
  609. {
  610. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD;
  611. HL_YCX_VAVLE = 1;
  612. HL_YCXDelay = dwTickCount + HL_PARAM_YCX_TIME;
  613. HL_AutoStep = 15;
  614. }
  615. else if(dwTickCount >= HL_AutoDelay)
  616. HL_SetAlarmCode(HL_DK_UP_LIMIT_ALARM);
  617. }
  618. else if((HL_AutoStep == 15) && (dwTickCount >= HL_AutoDelay))
  619. {
  620. if(HL_PARAM_CCX_MODE)
  621. {
  622. if(!X_DRV)AxisMovePosAccDec(X_AXIS,HL_PARAM_CCX_SPEED,HL_PARAM_CCX_LENGTH,1,5,5);
  623. HL_AutoDelay = dwTickCount;
  624. HL_AutoStep = 16;
  625. }
  626. else
  627. {
  628. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  629. HL_JD_VAVLE = 1;
  630. HL_AutoStep = 16;
  631. }
  632. }
  633. else if((HL_AutoStep == 16) && (dwTickCount >= HL_AutoDelay) && !HL_YCX_VAVLE)
  634. {
  635. if(HL_PARAM_CCX_MODE)
  636. {
  637. if(!X_DRV)
  638. {
  639. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  640. HL_CheckDelay = dwTickCount + HL_PARAM_DELAY_CHECK_CCX;
  641. HL_AutoStep = 17;
  642. }
  643. }
  644. else
  645. {
  646. HL_CCX_VAVLE = 1;
  647. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  648. HL_CheckDelay = dwTickCount + HL_PARAM_DELAY_CHECK_CCX;
  649. HL_AutoStep = 17;
  650. }
  651. }
  652. else if((HL_AutoStep == 17) && (dwTickCount >= HL_CheckDelay))
  653. {
  654. if(HL_CCX_LIMIT_IN)
  655. {
  656. if(HL_PARAM_CCX_MODE)
  657. {
  658. HL_DK_UP_VAVLE = 0;
  659. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  660. HL_AutoStep = 18;
  661. }
  662. else
  663. {
  664. HL_DK_UP_VAVLE = 0;
  665. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD_BACK;
  666. HL_AutoStep = 50;
  667. }
  668. }
  669. else if(dwTickCount >= HL_AutoDelay)
  670. HL_SetAlarmCode(HL_CCX_LIMIT_ALARM);
  671. }
  672. else if((HL_AutoStep == 50) && (dwTickCount >= HL_AutoDelay))
  673. {
  674. HL_JD_VAVLE = 0;
  675. HL_AutoDelay = dwTickCount + 0;
  676. HL_AutoStep = 51;
  677. }
  678. else if((HL_AutoStep == 51) && (dwTickCount >= HL_AutoDelay))
  679. {
  680. if(!X_DRV)AxisMovePosAccDec(X_AXIS,HL_PARAM_LOW_SPEED,HL_PARAM_CCX_LENGTH,1,5,5);
  681. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  682. HL_AutoStep = 18;
  683. }
  684. else if(HL_AutoStep == 18)
  685. {
  686. if(!HL_DK_UP_LIMIT_IN && !X_DRV)
  687. {
  688. HL_CCX_VAVLE = 0;
  689. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_BACK_DK_UP;
  690. HL_AutoStep = 19;
  691. }
  692. else if(dwTickCount >= HL_AutoDelay)
  693. {
  694. HL_SetAlarmCode(HL_DK_UP_LIMIT_ALARM);
  695. }
  696. }
  697. else if(HL_AutoStep == 19)
  698. {
  699. if(!HL_PARAM_CCX_TIMES)HL_YD_VAVLE = 0;
  700. HL_AutoDelay = dwTickCount + HL_VAVLE_ALARM_TIME;
  701. HL_AutoStep = 20;
  702. }
  703. else if(HL_AutoStep == 20)
  704. {
  705. if(HL_PARAM_CCX_MODE)
  706. {
  707. HL_AutoDelay = dwTickCount;
  708. HL_AutoStep = 25;
  709. }
  710. else
  711. {
  712. if(!HL_PARAM_CCX_TIMES)
  713. {
  714. HL_AutoDelay = dwTickCount;
  715. HL_AutoStep = 25;
  716. }
  717. else
  718. {
  719. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD;
  720. HL_AutoStep = 21;
  721. }
  722. }
  723. }
  724. else if((HL_AutoStep == 21) && (dwTickCount >= HL_AutoDelay))
  725. {
  726. HL_JD_VAVLE = 1;
  727. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  728. HL_AutoStep = 22;
  729. }
  730. else if((HL_AutoStep == 22) && (dwTickCount >= HL_AutoDelay))
  731. {
  732. HL_CCX_VAVLE = 1;
  733. HL_AutoStep = 23;
  734. }
  735. else if((HL_AutoStep == 23) && (dwTickCount >= HL_AutoDelay))
  736. {
  737. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_JD_BACK;
  738. HL_AutoStep = 24;
  739. }
  740. else if((HL_AutoStep == 24) && (dwTickCount >= HL_AutoDelay))
  741. {
  742. HL_JD_VAVLE = 0;
  743. HL_AutoDelay = dwTickCount + HL_PARAM_DELAY_CCX;
  744. HL_AutoStep = 25;
  745. }
  746. else if((HL_AutoStep == 25) && (dwTickCount >= HL_AutoDelay))
  747. {
  748. HL_CCX_VAVLE = 0;
  749. HL_YD_VAVLE = 0;
  750. if(cZCXflg)
  751. {
  752. cZCXflg = 0;
  753. HL_AutoStep = 0;
  754. HL_bRunning = 0;
  755. }
  756. else
  757. {
  758. HL_AutoStep = 26;
  759. }
  760. }
  761. else if(HL_AutoStep == 26)
  762. {
  763. AddToTal(HL_TOTAL_ADDR);
  764. dwZipCnt++;
  765. if(GetTotal(HL_TOTAL_ADDR) >= HL_PARAM_SET_TOTAL)
  766. {
  767. HL_SetAlarmCode(HL_TOTAL_ALARM);
  768. }
  769. else
  770. {
  771. HL_AutoStep = 2;
  772. HL_AutoDelay = HL_PARAM_CYCLE_DELAY + dwTickCount;
  773. CalProSP(HL_PROSPEED_ADDR);
  774. }
  775. }
  776. }
  777. }
  778. #endif