PWCJinShuKLShuangSZ.c 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324
  1. #include "global.h"
  2. #if PENG_WEI_CHANG_MACHINE == 1
  3. void JSKL_CheckStart(void);
  4. void JSKL_Motor(void);
  5. void JSKL_ManualAction(void);
  6. void JSKL_AutoAction(void);
  7. void JSKL_FD_Action(void);
  8. void JSKL_Check(void);
  9. unsigned char cJSKL_CheckLTimes =0;
  10. unsigned char cJSKL_CheckRTimes =0;
  11. unsigned char cStopFlg =0;
  12. unsigned char cCheckOkLFlg = 0;
  13. unsigned char cCheckOkRFlg = 0;
  14. unsigned char cBackFDFlag = 0;
  15. unsigned char cJSKL_left_enable = 0;
  16. unsigned char cJSKL_right_enable = 0;
  17. unsigned char cManPJStep = 0;
  18. unsigned char cErrorLflg,cErrorRflg;
  19. //故障报警
  20. void JSKL_SetAlarmCode(unsigned alarm_code)
  21. {
  22. SetAlarmCode(JSKL_ALARM_ADDR,alarm_code);
  23. JSKL_bAlarmStop = 1;
  24. }
  25. void JSKL_InitAction(void)
  26. {
  27. float length_buff,pulse_buff;
  28. length_buff = 2480;
  29. pulse_buff = 1600;
  30. XGearRatio = pulse_buff/length_buff;
  31. CalFreqTab_X_Free(14);
  32. JSKL_SZ_OUT = 1;
  33. cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
  34. cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
  35. }
  36. void JSKL_Action(void)
  37. {
  38. JSKL_CheckStart(); //启动
  39. JSKL_Check();
  40. JSKL_Motor(); //拖带控制
  41. JSKL_FD_Action();
  42. JSKL_ManualAction();
  43. JSKL_AutoAction();
  44. }
  45. void JSKL_ManualAction(void)
  46. {
  47. //清总产量
  48. if(JSKL_bClear) //清总产量
  49. {
  50. JSKL_bClear = 0;
  51. ClrcToTal(JSKL_TOTAL_ADDR);
  52. }
  53. if(bRunning == 0) ////手动
  54. {
  55. if(JSKL_bGZ)
  56. {
  57. JSKL_bGZ = 0;
  58. JSKL_GZ_VAVLE = ~JSKL_GZ_VAVLE;
  59. }
  60. if(JSKL_bFD)
  61. {
  62. JSKL_bFD = 0;
  63. JSKL_FD_VAVLE = ~JSKL_FD_VAVLE;
  64. }
  65. if(JSKL_bXM)
  66. {
  67. JSKL_bXM = 0;
  68. if(JSKL_XM_VAVLE)
  69. {
  70. if(!JSKL_SM_LIMIT_IN)JSKL_XM_VAVLE = 0;
  71. else
  72. JSKL_SM_VAVLE = 0;
  73. }
  74. else
  75. JSKL_XM_VAVLE = 1;
  76. }
  77. if(JSKL_bSM)
  78. {
  79. JSKL_bSM = 0;
  80. JSKL_SM_VAVLE = ~JSKL_SM_VAVLE;
  81. }
  82. if(JSKL_bTL)
  83. {
  84. JSKL_bTL = 0;
  85. if(JSKL_cMotorStep==0)JSKL_cMotorStep=20;
  86. }
  87. if(JSKL_bPJ)
  88. {
  89. JSKL_bPJ = 0;
  90. cManPJStep = 1;
  91. }
  92. switch(cManPJStep)
  93. {
  94. case 1:
  95. JSKL_PJ_VAVLE = 1;
  96. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  97. cManPJStep = 2;
  98. break;
  99. case 2:
  100. {
  101. if(JSKL_PJ_LIMIT_IN)
  102. {
  103. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_PJ_DELAYBACK;
  104. cManPJStep = 3;
  105. }
  106. else if(dwTickCount >= JSKL_cFDDelay)
  107. JSKL_SetAlarmCode(JSKL_PJ_LIMIT_ALARM);
  108. }break;
  109. case 3:
  110. {
  111. if(dwTickCount >= JSKL_cFDDelay)
  112. {
  113. JSKL_PJ_VAVLE = 0;
  114. cManPJStep = 0;
  115. }
  116. }break;
  117. }
  118. /* if(JSKL_bZDP)
  119. {
  120. JSKL_bZDP = 0;
  121. JSKL_ZDP_VAVLE =~JSKL_ZDP_VAVLE;
  122. }*/
  123. if(JSKL_bLTM)
  124. {
  125. JSKL_bLTM = 0;
  126. JSKL_LTM_VAVLE =~JSKL_LTM_VAVLE;
  127. }
  128. if(JSKL_bRTM)
  129. {
  130. JSKL_bRTM = 0;
  131. JSKL_RTM_VAVLE =~JSKL_RTM_VAVLE;
  132. }
  133. if(JSKL_bMotor)
  134. {
  135. JSKL_SZ_OUT = 0;
  136. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, JSKL_DIR_P, 5,5,10,10);
  137. }
  138. else
  139. {
  140. if(JSKL_cMotorStep == 0)
  141. {
  142. if(X_DRV)AxisDecStop(X_AXIS);
  143. }
  144. }
  145. }
  146. if(JSKL_PARAM_ZDP_ENABLE)
  147. JSKL_ZDP_VAVLE = 1;
  148. else
  149. JSKL_ZDP_VAVLE = 0;
  150. }
  151. unsigned char JSKL_SingleLeftWork(void)
  152. {
  153. if(JSKL_PARAM_SINGLE_MODE)
  154. {
  155. return 1;
  156. }
  157. else
  158. {
  159. if(cJSKL_left_enable)return 1;
  160. else return 0;
  161. }
  162. }
  163. unsigned char JSKL_SingleRightWork(void)
  164. {
  165. if(JSKL_PARAM_SINGLE_MODE)
  166. {
  167. return 1;
  168. }
  169. else
  170. {
  171. if(cJSKL_right_enable)return 1;
  172. else return 0;
  173. }
  174. }
  175. void JSKL_AutoAction(void)
  176. {
  177. if(bRunning)
  178. {
  179. switch(JSKL_cAutoStep)
  180. {
  181. case 0:
  182. break;
  183. case 1:
  184. if(dwTickCount >= JSKL_cAutoDelay)
  185. {
  186. JSKL_cAutoStep = 2;
  187. JSKL_cMotorStep = 1; //启动拖带
  188. }
  189. break;
  190. case 2:
  191. //拖带已经完成
  192. if(JSKL_cMotorStep == 0)
  193. {
  194. JSKL_cAutoStep = 3;
  195. }
  196. break;
  197. case 3:
  198. {
  199. if(JSKL_cFDStep == 0)
  200. {
  201. JSKL_cFDStep = 1; //分带动作启动
  202. JSKL_cAutoStep = 4;
  203. }
  204. }
  205. break;
  206. case 4:
  207. if(JSKL_cFDStep == 0)
  208. {
  209. JSKL_cAutoStep = 5;
  210. }
  211. break;
  212. case 5:
  213. {
  214. JSKL_cAutoStep = 6;
  215. }
  216. break;
  217. case 6:
  218. {
  219. JSKL_cAutoStep = 7;
  220. }
  221. break;
  222. case 7:
  223. {
  224. {
  225. JSKL_cAutoDelay = dwTickCount + JSKL_PARAM_DELAY_START;
  226. AddToTal(JSKL_TOTAL_ADDR);
  227. CalProSP(JSKL_PROSPEED_ADDR);
  228. cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
  229. cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
  230. JSKL_cAutoStep = 1;
  231. }
  232. }
  233. break;
  234. }
  235. }
  236. }
  237. // 检测是否踏了脚踏开关
  238. void JSKL_CheckStart(void)
  239. {
  240. DISPLAY_DATA0 = JSKL_cAutoStep;
  241. DISPLAY_DATA1 = JSKL_cMotorStep;
  242. DISPLAY_DATA2 = JSKL_cFDStep;
  243. DISPLAY_DATA3 = JSKL_cCheckLStep;
  244. DISPLAY_DATA4 = JSKL_cCheckRStep;
  245. DISPLAY_DATA5 = cJSKL_CheckLTimes;
  246. DISPLAY_DATA6 = cJSKL_CheckRTimes;
  247. DISPLAY_DATA7 = 0-dwRealPos;//dwRealPos;
  248. static unsigned short Fd_flg =0;
  249. static unsigned short Tm_flg = 0;
  250. if((START_IN_UP || JSKL_bStart || JSKL_bGZStart || JSKL_bOnceStart) && !bRunning && (JSKL_cAutoStep==0))
  251. {
  252. if(JSKL_FD_IN)
  253. JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
  254. else if(!JSKL_XM_ORIGIN_IN)
  255. JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
  256. else if(!JSKL_PJ_ORIGIN_IN)
  257. JSKL_SetAlarmCode(JSKL_PJ_ORIGIN_ALARM);
  258. else if(JSKL_SM_LIMIT_IN)
  259. JSKL_SetAlarmCode(JSKL_SM_LIMIT_ALARM);
  260. else
  261. {
  262. if(JSKL_bStart || JSKL_bOnceStart || JSKL_bStart || START_IN_UP)
  263. {
  264. JSKL_bStart = 0;
  265. JSKL_cAutoStep = 1;
  266. bRunning = 1;
  267. cJSKL_CheckRTimes = 0;
  268. cJSKL_CheckLTimes = 0;
  269. cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
  270. cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
  271. Fd_flg = 0;
  272. cBackFDFlag = 0;
  273. }
  274. if(JSKL_bGZStart)
  275. {
  276. JSKL_bGZStart = 0;
  277. JSKL_cAutoStep = 2;
  278. JSKL_cMotorStep = 40;
  279. bRunning = 1;
  280. cJSKL_CheckRTimes = 0;
  281. cJSKL_CheckLTimes = 0;
  282. cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
  283. cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
  284. Fd_flg = 0;
  285. cBackFDFlag = 0;
  286. }
  287. if(JSKL_bOnceStart)
  288. {
  289. JSKL_bOnceStart = 0;
  290. JSKL_cAutoStep = 2;
  291. JSKL_cMotorStep = 40;
  292. SingOneFlg = 1;
  293. bRunning = 1;
  294. cJSKL_CheckRTimes = 0;
  295. cJSKL_CheckLTimes = 0;
  296. cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
  297. cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
  298. Fd_flg = 0;
  299. cBackFDFlag = 0;
  300. }
  301. else
  302. SingOneFlg = 0;
  303. SetAlarmCode(JSKL_ALARM_ADDR,JSKL_NO_ALARM);
  304. }
  305. }
  306. if(GetAlarmCode(JSKL_ALARM_ADDR) != 0)JSKL_FMQ_OUT = 1;
  307. else
  308. JSKL_FMQ_OUT = 0;
  309. //停止
  310. if(STOP_IN_UP || JSKL_bStop)
  311. {
  312. JSKL_cAutoStep = 0;
  313. JSKL_cMotorStep = 0;
  314. // JSKL_cCheckLStep = 0;
  315. // JSKL_cCheckRStep = 0;
  316. JSKL_cFDStep = 0;
  317. bRunning = 0;
  318. JSKL_bStop = 0;
  319. JSKL_FMQ_OUT = 0;
  320. JSKL_SM_VAVLE = 0;
  321. if(JSKL_XM_VAVLE)
  322. {
  323. cBackFDFlag = 1;
  324. JSKL_FD_VAVLE = 1;
  325. if(JSKL_L_QL_IN)cErrorLflg = 1;
  326. else
  327. cErrorLflg = 0;
  328. if(JSKL_R_QL_IN)cErrorRflg = 1;
  329. else
  330. cErrorRflg = 0;
  331. if(cJSKL_left_enable)
  332. {
  333. if(cErrorLflg)
  334. {
  335. cErrorLflg = 0;
  336. JSKL_LTM_VAVLE = 0;
  337. }
  338. else
  339. {
  340. if(JSKL_cCheckLStep==0)
  341. {
  342. JSKL_cCheckLStep=2;
  343. JSKL_LTM_VAVLE = 1;
  344. JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  345. }
  346. }
  347. }
  348. else
  349. {
  350. if(JSKL_cCheckLStep==0)
  351. {
  352. JSKL_cCheckLStep=2;
  353. JSKL_LTM_VAVLE = 1;
  354. JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  355. }
  356. }
  357. if(cJSKL_right_enable)
  358. {
  359. if(cErrorRflg)
  360. {
  361. cErrorRflg = 0;
  362. JSKL_RTM_VAVLE = 0;
  363. }
  364. else
  365. {
  366. if(JSKL_cCheckRStep==0)
  367. {
  368. JSKL_cCheckRStep=2;
  369. JSKL_RTM_VAVLE = 1;
  370. JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  371. }
  372. }
  373. }
  374. else
  375. {
  376. if(JSKL_cCheckRStep==0)
  377. {
  378. JSKL_cCheckRStep=2;
  379. JSKL_RTM_VAVLE = 1;
  380. JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  381. }
  382. }
  383. if(!cJSKL_left_enable || !cJSKL_right_enable)
  384. {
  385. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_ALL_BACK + JSKL_PARAM_DELAY_FD_BACK2;
  386. }
  387. else
  388. {
  389. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_FD_BACK2;
  390. }
  391. }
  392. else
  393. {
  394. /*
  395. if(JSKL_SingleLeftWork())
  396. {
  397. if(!cCheckOkLFlg)JSKL_LTM_VAVLE = 1;
  398. }
  399. if(JSKL_SingleRightWork())
  400. {
  401. if(!cCheckOkRFlg)JSKL_RTM_VAVLE = 1;
  402. }
  403. */
  404. cStopFlg = 1;
  405. }
  406. // if(!JSKL_SM_LIMIT_IN )JSKL_XM_VAVLE = 0;
  407. JSKL_PJ_VAVLE = 0;
  408. JSKL_SZ_OUT = 1;
  409. SingOneFlg = 0;
  410. cStopFlg = 1;
  411. SetAlarmCode(JSKL_ALARM_ADDR,JSKL_NO_ALARM);
  412. }
  413. if(Fd_flg)
  414. {
  415. if(dwTickCount >= JSKL_cFDDelay)
  416. {
  417. Fd_flg = 0;
  418. JSKL_FD_VAVLE = 0;
  419. JSKL_GZ_VAVLE = 0;
  420. }
  421. }
  422. if(cStopFlg)
  423. {
  424. if(JSKL_XM_ORIGIN_IN)
  425. {
  426. cStopFlg = 0;
  427. if(cJSKL_left_enable)
  428. {
  429. if((JSKL_cCheckLStep==0))
  430. {
  431. JSKL_LTM_VAVLE = 1;
  432. JSKL_cCheckLStep=2;
  433. JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  434. }
  435. }
  436. else
  437. {
  438. JSKL_LTM_VAVLE = 0;
  439. }
  440. if(cJSKL_right_enable)
  441. {
  442. if((JSKL_cCheckRStep==0))
  443. {
  444. JSKL_RTM_VAVLE = 1;
  445. JSKL_cCheckRStep=2;
  446. JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  447. }
  448. }
  449. else
  450. {
  451. JSKL_RTM_VAVLE = 0;
  452. }
  453. Fd_flg = 1;
  454. JSKL_cFDDelay = dwTickCount + 50;
  455. }
  456. }
  457. if(cBackFDFlag)
  458. {
  459. if(SingOneFlg)
  460. {
  461. cBackFDFlag = 0;
  462. JSKL_XM_VAVLE = 0;
  463. Tm_flg = 1;
  464. SingOneFlg = 0;
  465. }
  466. else
  467. {
  468. if(JSKL_FD_IN)
  469. {
  470. cBackFDFlag = 0;
  471. JSKL_XM_VAVLE = 0;
  472. Tm_flg = 1;
  473. }
  474. }
  475. }
  476. if(Tm_flg)
  477. {
  478. if(!JSKL_XM_LIMIT_IN)
  479. {
  480. Tm_flg = 0;
  481. JSKL_LTM_VAVLE = 0;
  482. JSKL_RTM_VAVLE = 0;
  483. }
  484. }
  485. if(JSKL_bAlarmStop)
  486. {
  487. JSKL_bAlarmStop = 0;
  488. JSKL_cFDStep = 0;
  489. JSKL_cCheckLStep = 0;
  490. JSKL_cCheckRStep = 0;
  491. bRunning = 0;
  492. JSKL_cAutoStep = 0;
  493. JSKL_cMotorStep = 0;
  494. SingOneFlg = 0;
  495. }
  496. }
  497. //高速输入X31/X17外部色标信号中断
  498. void JSKL_ExtiActionX31(void)
  499. {
  500. }
  501. long JSKL_GetMod(long dist0,long dist1)
  502. {
  503. if(dist0 > dist1)return(dist0-dist1);
  504. else return(dist1-dist0);
  505. }
  506. void JSKL_Motor(void)
  507. {
  508. static long save_dist;
  509. dwRealPos = GetPos(X_AXIS);
  510. switch(JSKL_cMotorStep)
  511. {
  512. case 0:break;
  513. case 1:
  514. if(JSKL_SZ_OUT)
  515. {
  516. JSKL_SZ_OUT = 0;
  517. JSKL_cMotorDelay = dwTickCount + 100;
  518. }
  519. JSKL_cMotorStep = 2;
  520. break;
  521. case 2:
  522. if(dwTickCount >= JSKL_cMotorDelay)
  523. {
  524. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,JSKL_DIR_P,JSKL_PARAM_HIGH_SPEED,1,10,1);
  525. JSKL_cMotorDelay = dwTickCount + JSKL_PARAM_ZIPPER_TIME+200;
  526. JSKL_cMotorStep = 3;
  527. }
  528. break;
  529. case 40:
  530. if(JSKL_SZ_OUT)
  531. {
  532. JSKL_SZ_OUT = 0;
  533. JSKL_cMotorDelay = dwTickCount + 100;
  534. }
  535. JSKL_cMotorStep = 41;
  536. break;
  537. case 41:
  538. if(dwTickCount >= JSKL_cMotorDelay)
  539. {
  540. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,JSKL_DIR_P,JSKL_PARAM_HIGH_SPEED,1,10,1);
  541. JSKL_cMotorStep = 4;
  542. }
  543. break;
  544. case 3:
  545. if(JSKL_GuoLian_IN_DW)
  546. {
  547. JSKL_cMotorDelay = dwTickCount + JSKL_PARAM_GZ_DELAY;
  548. JSKL_cMotorStep = 4;
  549. }
  550. else if(dwTickCount >= JSKL_cMotorDelay)
  551. JSKL_SetAlarmCode(JSKL_GUOLIAN_ALARM);
  552. break;
  553. case 4:
  554. if(dwTickCount >= JSKL_cMotorDelay)
  555. {
  556. JSKL_GZ_VAVLE = 1;
  557. JSKL_cMotorDelay = dwTickCount + 3000;
  558. JSKL_cGLCheckDelay = dwTickCount + JSKL_PARAM_DELAY_CHECK;
  559. JSKL_cMotorStep = 5;
  560. }
  561. break;
  562. case 5:
  563. {
  564. if(JSKL_GZ_ORIGIN_IN_DW)
  565. {
  566. if(X_DRV)MoveChangSpeed(X_AXIS,JSKL_PARAM_LOW_SPEED);
  567. JSKL_cMotorDelay = dwTickCount + 3000;
  568. JSKL_cMotorStep = 6;
  569. }
  570. else if((dwTickCount >= JSKL_cMotorDelay) || ((JSKL_GuoLian_IN_UP || JSKL_GuoLian_IN_DW) && (dwTickCount >= JSKL_cGLCheckDelay)))
  571. JSKL_SetAlarmCode(JSKL_GZ_ALARM);
  572. }break;
  573. case 6:
  574. {
  575. if(!JSKL_GZ_IN)
  576. {
  577. save_dist = dwRealPos;
  578. if(JSKL_PARAM_STOP_DELAY==0)
  579. {
  580. AxisEgmStop(X_AXIS);
  581. JSKL_cMotorStep = 8;
  582. }
  583. else
  584. JSKL_cMotorStep = 7;
  585. }
  586. else if((dwTickCount >= JSKL_cMotorDelay) || ((JSKL_GuoLian_IN_UP || JSKL_GuoLian_IN_DW) && (dwTickCount >= JSKL_cGLCheckDelay)))
  587. JSKL_SetAlarmCode(JSKL_GZ_ALARM);
  588. }break;
  589. case 7:
  590. {//位置是负
  591. if(JSKL_GetMod(save_dist,dwRealPos) >= JSKL_PARAM_STOP_DELAY)
  592. {
  593. AxisEgmStop(X_AXIS);
  594. JSKL_cMotorStep = 8;
  595. }
  596. }break;
  597. case 8:
  598. {
  599. if(!X_DRV)
  600. {
  601. JSKL_cMotorStep = 0;
  602. JSKL_cMotorDelay = dwTickCount;
  603. }
  604. }break;
  605. case 20:
  606. {
  607. if(JSKL_SZ_OUT)
  608. {
  609. JSKL_SZ_OUT = 0;
  610. JSKL_cMotorDelay = dwTickCount + 130;
  611. }
  612. else
  613. JSKL_cMotorDelay = dwTickCount;
  614. JSKL_cMotorStep = 21;
  615. }
  616. break;
  617. case 21:
  618. if(dwTickCount >= JSKL_cMotorDelay)
  619. {
  620. if(!X_DRV)AxisMovePosAccDec(X_AXIS,20,JSKL_PARAM_FZ_LENGTH,1,10,10);
  621. JSKL_cMotorDelay = dwTickCount + 5000;
  622. JSKL_cMotorStep = 22;
  623. }
  624. break;
  625. case 22:
  626. // if(JSKL_GZ_ORIGIN_IN)JSKL_SetAlarmCode(JSKL_TL_ALARM);
  627. if(JSKL_GZ_ORIGIN_IN)
  628. {
  629. JSKL_LTM_VAVLE = 0;
  630. JSKL_RTM_VAVLE = 0;
  631. JSKL_cMotorStep = 0;
  632. JSKL_cMotorDelay = dwTickCount;
  633. }
  634. else if(dwTickCount >= JSKL_cMotorDelay)
  635. JSKL_SetAlarmCode(JSKL_GZ_ALARM);
  636. break;
  637. default:;
  638. }
  639. }
  640. void JSKL_Check(void)
  641. {
  642. switch(JSKL_cCheckLStep)
  643. {
  644. case 0:break;
  645. case 1:
  646. {
  647. if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1;
  648. JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  649. JSKL_cCheckLStep = 2;
  650. }break;
  651. case 2:
  652. {
  653. if(dwTickCount >= JSKL_cCheckLDelay)
  654. {
  655. JSKL_LTM_VAVLE = 0;
  656. JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_DELAY_TM_BACK;
  657. JSKL_cCheckLStep = 3;
  658. }
  659. }break;
  660. case 3:
  661. {
  662. if((dwTickCount >= JSKL_cCheckLDelay))
  663. {
  664. JSKL_cCheckLStep = 0;
  665. }
  666. }break;
  667. }
  668. switch(JSKL_cCheckRStep)
  669. {
  670. case 0:break;
  671. case 1:
  672. {
  673. if(JSKL_SingleRightWork())JSKL_RTM_VAVLE = 1;
  674. JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
  675. JSKL_cCheckRStep = 2;
  676. }break;
  677. case 2:
  678. {
  679. if(dwTickCount >= JSKL_cCheckRDelay)
  680. {
  681. JSKL_RTM_VAVLE = 0;
  682. JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_DELAY_TM_BACK;
  683. JSKL_cCheckRStep = 3;
  684. }
  685. }break;
  686. case 3:
  687. {
  688. if(dwTickCount >= JSKL_cCheckRDelay)
  689. {
  690. JSKL_cCheckRStep = 0;
  691. }
  692. }
  693. break;
  694. }
  695. }
  696. void JSKL_FD_Action(void)
  697. {
  698. unsigned short length_buff;
  699. static unsigned short xm_times = 0;
  700. static unsigned char jl_flg;
  701. static unsigned char tm_flg;
  702. if(JSKL_XM_LIMIT_IN_UP) JSKL_SM_VAVLE = 1;
  703. if(JSKL_SM_LIMIT_IN_DW)JSKL_XM_VAVLE = 0;
  704. if(tm_flg)
  705. {
  706. if(JSKL_XM_ORIGIN_IN)
  707. {
  708. if(cJSKL_left_enable)JSKL_LTM_VAVLE = 1;
  709. if(cJSKL_right_enable)JSKL_RTM_VAVLE = 1;
  710. tm_flg = 0;
  711. }
  712. }
  713. if(jl_flg)
  714. {
  715. if(JSKL_XM_ORIGIN_IN && !JSKL_XM_VAVLE) //X07 下模退到位
  716. {
  717. jl_flg = 0;
  718. if(!cJSKL_left_enable)JSKL_LTM_VAVLE = 0;
  719. else
  720. {
  721. if(JSKL_cCheckLStep == 0)JSKL_cCheckLStep = 1;
  722. }
  723. if(!cJSKL_right_enable)JSKL_RTM_VAVLE = 0;
  724. else
  725. {
  726. if(JSKL_cCheckRStep == 0)JSKL_cCheckRStep = 1;
  727. }
  728. }
  729. }
  730. switch(JSKL_cFDStep)
  731. {
  732. case 0:break;
  733. case 1:
  734. {
  735. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_FD_DELAY;
  736. JSKL_cFDStep = 2;
  737. }break;
  738. case 2:
  739. {
  740. if(dwTickCount >= JSKL_cFDDelay)
  741. {
  742. if(JSKL_PARAM_FD_ENABLE)JSKL_FD_VAVLE = 1;
  743. JSKL_cXMDelay = dwTickCount + JSKL_PARAM_DELAY_TM_BACK;
  744. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  745. JSKL_cFDStep = 3;
  746. }
  747. }break;
  748. case 3:
  749. {
  750. if((JSKL_FD_IN || (JSKL_PARAM_FD_ENABLE==0)))// && (dwTickCount >= JSKL_cXMDelay)) //分带到位
  751. {
  752. if((JSKL_cCheckLStep == 0) && (JSKL_cCheckRStep == 0))
  753. {
  754. JSKL_XM_VAVLE = 1; // 下模Y03
  755. cCheckOkLFlg = 0;
  756. cCheckOkRFlg = 0;
  757. JSKL_cFDDelay = dwTickCount + 1000;
  758. JSKL_cFDStep = 4;
  759. }
  760. }
  761. else if(dwTickCount >= JSKL_cFDDelay)
  762. {
  763. JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
  764. }
  765. }break;
  766. case 4:
  767. {
  768. /*
  769. if(!cJSKL_left_enable && !cJSKL_right_enable ) //双边同时不选择
  770. {
  771. // if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1; //左入料Y06
  772. // if(JSKL_SingleRightWork())JSKL_RTM_VAVLE = 1; //右入料Y07
  773. JSKL_LTM_VAVLE = 0; //左入料Y06
  774. JSKL_RTM_VAVLE = 0; //右入料Y07
  775. cCheckOkLFlg = 1;
  776. cCheckOkRFlg = 1;
  777. }
  778. else if(cJSKL_left_enable && !cJSKL_right_enable)
  779. {
  780. cCheckOkRFlg = 1;
  781. if(JSKL_L_QL_IN) //左有料检测 X13
  782. {
  783. JSKL_LTM_VAVLE = 0;
  784. cCheckOkLFlg = 1;
  785. cJSKL_CheckLTimes = 0;
  786. }
  787. else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES) //检测次数
  788. {
  789. JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
  790. }
  791. }
  792. else if(!cJSKL_left_enable && cJSKL_right_enable)
  793. {
  794. cCheckOkLFlg = 1;
  795. if(JSKL_R_QL_IN) //右有料检测 X14
  796. {
  797. JSKL_RTM_VAVLE = 0;
  798. cCheckOkRFlg = 1;
  799. cJSKL_CheckRTimes = 0;
  800. }
  801. else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
  802. {
  803. JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
  804. }
  805. }
  806. else
  807. {
  808. if(JSKL_L_QL_IN)
  809. {
  810. JSKL_LTM_VAVLE = 0;
  811. cCheckOkLFlg = 1;
  812. cJSKL_CheckLTimes = 0;
  813. }
  814. else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES)
  815. {
  816. JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
  817. }
  818. if(JSKL_R_QL_IN)
  819. {
  820. JSKL_RTM_VAVLE = 0;
  821. cCheckOkRFlg = 1;
  822. cJSKL_CheckRTimes = 0;
  823. }
  824. else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
  825. {
  826. JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
  827. }
  828. }
  829. */
  830. //下模到位X06 锁模到位 X10
  831. if(JSKL_XM_LIMIT_IN && JSKL_SM_LIMIT_IN)
  832. {
  833. if(!cJSKL_left_enable && !cJSKL_right_enable ) //双边同时不选择
  834. {
  835. // if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1; //左入料Y06
  836. // if(JSKL_SingleRightWork())JSKL_RTM_VAVLE = 1; //右入料Y07
  837. JSKL_LTM_VAVLE = 0; //左入料Y06
  838. JSKL_RTM_VAVLE = 0; //右入料Y07
  839. cCheckOkLFlg = 1;
  840. cCheckOkRFlg = 1;
  841. }
  842. else if(cJSKL_left_enable && !cJSKL_right_enable)
  843. {
  844. cCheckOkRFlg = 1;
  845. if(JSKL_L_QL_IN) //左有料检测 X13
  846. {
  847. JSKL_LTM_VAVLE = 0;
  848. cCheckOkLFlg = 1;
  849. cJSKL_CheckLTimes = 0;
  850. }
  851. else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES) //检测次数
  852. {
  853. JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
  854. break;
  855. }
  856. }
  857. else if(!cJSKL_left_enable && cJSKL_right_enable)
  858. {
  859. cCheckOkLFlg = 1;
  860. if(JSKL_R_QL_IN) //右有料检测 X14
  861. {
  862. JSKL_RTM_VAVLE = 0;
  863. cCheckOkRFlg = 1;
  864. cJSKL_CheckRTimes = 0;
  865. }
  866. else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
  867. {
  868. JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
  869. break;
  870. }
  871. }
  872. else
  873. {
  874. if(JSKL_L_QL_IN)
  875. {
  876. JSKL_LTM_VAVLE = 0;
  877. cCheckOkLFlg = 1;
  878. cJSKL_CheckLTimes = 0;
  879. }
  880. else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES)
  881. {
  882. JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
  883. break;
  884. }
  885. if(JSKL_R_QL_IN)
  886. {
  887. JSKL_RTM_VAVLE = 0;
  888. cCheckOkRFlg = 1;
  889. cJSKL_CheckRTimes = 0;
  890. }
  891. else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
  892. {
  893. JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
  894. break;
  895. }
  896. }
  897. xm_times = 0;
  898. if(cCheckOkLFlg && cCheckOkRFlg) //两边同时OK
  899. {
  900. if(cJSKL_left_enable && !cJSKL_right_enable)
  901. {
  902. if(JSKL_SingleRightWork()) JSKL_RTM_VAVLE = 1; //
  903. }
  904. else if(!cJSKL_left_enable && cJSKL_right_enable)
  905. {
  906. if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1;
  907. }
  908. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_FD_BACK; //
  909. JSKL_cFDStep = 5;
  910. }
  911. else
  912. {
  913. JSKL_SM_VAVLE = 0; //Y04 锁模关
  914. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  915. if(cJSKL_left_enable && !cJSKL_right_enable) //选择左边,
  916. {
  917. //if(JSKL_SingleRightWork())
  918. JSKL_LTM_VAVLE = 1;
  919. JSKL_RTM_VAVLE = 1;
  920. JSKL_cFDStep = 40;
  921. }
  922. else if(!cJSKL_left_enable && cJSKL_right_enable) //选择右边
  923. {
  924. // if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1;
  925. JSKL_LTM_VAVLE = 1;
  926. JSKL_RTM_VAVLE = 1;
  927. JSKL_cFDStep = 50;
  928. }
  929. else //两边选择
  930. {
  931. JSKL_cFDStep = 60;
  932. if(!cCheckOkLFlg)
  933. JSKL_LTM_VAVLE = 1;
  934. if(!cCheckOkRFlg)
  935. JSKL_RTM_VAVLE = 1;
  936. }
  937. }
  938. }
  939. else if(dwTickCount >= JSKL_cFDDelay)
  940. {
  941. if(xm_times >= JSKL_PARAM_TM_TIMES)
  942. {
  943. JSKL_SetAlarmCode(JSKL_XM_LIMIT_ALARM);
  944. }
  945. else
  946. {
  947. xm_times++;
  948. JSKL_XM_VAVLE = 0;
  949. JSKL_cFDStep = 70;
  950. JSKL_cXMDelay = dwTickCount + 250;
  951. }
  952. }
  953. }break;
  954. case 70:
  955. if(JSKL_XM_ORIGIN_IN && (dwTickCount >= JSKL_cXMDelay))
  956. {
  957. if((JSKL_cCheckLStep== 0) && cJSKL_left_enable)
  958. JSKL_cCheckLStep = 1;
  959. if((JSKL_cCheckRStep == 0) && cJSKL_right_enable)
  960. JSKL_cCheckRStep = 1;
  961. JSKL_cFDStep = 3;
  962. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  963. }
  964. break;
  965. case 40:
  966. if(JSKL_XM_LIMIT_IN_DW)
  967. JSKL_RTM_VAVLE = 0;
  968. if(JSKL_XM_ORIGIN_IN)
  969. {
  970. JSKL_cFDStep = 41;
  971. if(JSKL_cCheckLStep == 0)JSKL_cCheckLStep = 1;
  972. }
  973. else if(dwTickCount >= JSKL_cFDDelay)
  974. JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
  975. break;
  976. case 41:
  977. if(JSKL_cCheckLStep == 0)
  978. {
  979. JSKL_XM_VAVLE = 1;
  980. cJSKL_CheckLTimes++;
  981. JSKL_cFDStep = 42;
  982. }
  983. break;
  984. case 42:
  985. if(!JSKL_XM_ORIGIN_IN)
  986. {
  987. JSKL_cFDStep = 4;
  988. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  989. }
  990. break;
  991. case 50:
  992. if(JSKL_XM_LIMIT_IN_DW)
  993. JSKL_LTM_VAVLE = 0;
  994. if(JSKL_XM_ORIGIN_IN)
  995. {
  996. JSKL_cFDStep = 51;
  997. if(JSKL_cCheckRStep == 0)JSKL_cCheckRStep = 1;
  998. }
  999. else if(dwTickCount >= JSKL_cFDDelay)
  1000. JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
  1001. break;
  1002. case 51:
  1003. if(JSKL_cCheckRStep == 0)
  1004. {
  1005. JSKL_XM_VAVLE = 1;
  1006. cJSKL_CheckRTimes++;
  1007. JSKL_cFDStep = 52;
  1008. }
  1009. break;
  1010. case 52:
  1011. if(!JSKL_XM_ORIGIN_IN)
  1012. {
  1013. JSKL_cFDStep = 4;
  1014. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1015. }
  1016. break;
  1017. case 60:
  1018. if(JSKL_XM_ORIGIN_IN)
  1019. {
  1020. JSKL_cFDStep = 61;
  1021. if(!cCheckOkRFlg)
  1022. {
  1023. if(JSKL_cCheckRStep == 0)JSKL_cCheckRStep = 1;
  1024. cJSKL_CheckRTimes++;
  1025. }
  1026. if(!cCheckOkLFlg)
  1027. {
  1028. if(JSKL_cCheckLStep == 0)JSKL_cCheckLStep = 1;
  1029. cJSKL_CheckLTimes++;
  1030. }
  1031. }
  1032. else if(dwTickCount >= JSKL_cFDDelay)
  1033. JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
  1034. break;
  1035. case 61:
  1036. if((JSKL_cCheckRStep == 0) && (JSKL_cCheckLStep == 0))
  1037. {
  1038. JSKL_XM_VAVLE = 1;
  1039. JSKL_cFDStep = 62;
  1040. }
  1041. break;
  1042. case 62:
  1043. if(!JSKL_XM_ORIGIN_IN)
  1044. {
  1045. JSKL_cFDStep = 4;
  1046. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1047. }
  1048. break;
  1049. case 5:
  1050. if(dwTickCount >= JSKL_cFDDelay)
  1051. {
  1052. JSKL_FD_VAVLE = 0; //Y02分带退
  1053. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1054. JSKL_cFDStep = 6;
  1055. }
  1056. break;
  1057. case 6:
  1058. {
  1059. if(!JSKL_FD_IN) //分带到位信号离开
  1060. {
  1061. if(!X_DRV)AxisMovePosAccDec(X_AXIS,20,-JSKL_PARAM_FD_GO_LENGTH,1,10,10);
  1062. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_FZ_DELAY; //P05延时反转
  1063. JSKL_cPJDelay = dwTickCount + JSKL_PARAM_PJ_DELAY;
  1064. JSKL_cFDStep = 7;
  1065. }
  1066. else if(dwTickCount >= JSKL_cFDDelay)
  1067. JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
  1068. }break;
  1069. case 7:
  1070. {
  1071. if((dwTickCount >= JSKL_cFDDelay) && !X_DRV)
  1072. {
  1073. JSKL_cMotorStep = 20;
  1074. JSKL_cFDStep = 8;
  1075. }
  1076. }break;
  1077. case 8:
  1078. {
  1079. if(((X_DRV) || (JSKL_cMotorStep == 0)) && (dwTickCount >= JSKL_cPJDelay))
  1080. {
  1081. if(SingOneFlg && bRunning)
  1082. {
  1083. JSKL_cAutoStep = 0;
  1084. JSKL_cFDStep = 0;
  1085. bRunning = 0;
  1086. }
  1087. else
  1088. {
  1089. JSKL_cFDStep = 100;
  1090. // JSKL_cFDDelay = dwTickCount + JSKL_PARAM_PJ_DELAY;
  1091. }
  1092. }
  1093. }break;
  1094. case 100:
  1095. if(dwTickCount >= JSKL_cFDDelay)
  1096. {
  1097. JSKL_PJ_VAVLE = 1;
  1098. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1099. JSKL_cFDStep = 9;
  1100. }
  1101. break;
  1102. case 9:
  1103. {
  1104. if(JSKL_PJ_ORIGIN_IN)JSKL_cPJDelay = dwTickCount + 40;
  1105. if((dwTickCount >= JSKL_cPJDelay) && !JSKL_PJ_ORIGIN_IN)
  1106. {
  1107. JSKL_LTM_VAVLE = 0;
  1108. JSKL_RTM_VAVLE = 0;
  1109. }
  1110. if(JSKL_PJ_LIMIT_IN)
  1111. {
  1112. AxisEgmStop(X_AXIS);
  1113. JSKL_cMotorDelay = dwTickCount;
  1114. JSKL_cMotorStep = 0;
  1115. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_PJ_DELAYBACK;
  1116. JSKL_cFDStep = 10;
  1117. }
  1118. else if(dwTickCount >= JSKL_cFDDelay)
  1119. JSKL_SetAlarmCode(JSKL_PJ_LIMIT_ALARM);
  1120. }break;
  1121. case 10:
  1122. {
  1123. if(dwTickCount >= JSKL_cFDDelay)
  1124. {
  1125. JSKL_PJ_VAVLE = 0; //迫紧关
  1126. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1127. JSKL_cFDStep = 11;
  1128. if(JSKL_PARAM_PJ_PUSH_LENGTH > JSKL_PARAM_FZ_LENGTH)length_buff = JSKL_PARAM_FZ_LENGTH- 10;
  1129. else length_buff = JSKL_PARAM_PJ_PUSH_LENGTH;
  1130. if(!X_DRV)AxisMovePosAccDec(X_AXIS,20,-length_buff,1,10,10);
  1131. JSKL_FD_VAVLE = 1; //分带输出
  1132. JSKL_LTM_VAVLE = 1;//左进料打开
  1133. JSKL_RTM_VAVLE = 1;//右进料打开
  1134. }
  1135. }break;
  1136. case 11:
  1137. {
  1138. if(!JSKL_PJ_LIMIT_IN)
  1139. {
  1140. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1141. JSKL_cFDStep = 12;
  1142. JSKL_SM_VAVLE = 0; //锁模关
  1143. }
  1144. else if(dwTickCount >= JSKL_cFDDelay)
  1145. JSKL_SetAlarmCode(JSKL_PJ_LIMIT_ALARM);
  1146. }break;
  1147. case 12:
  1148. {
  1149. if(JSKL_PJ_ORIGIN_IN&&!X_DRV)
  1150. {
  1151. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1152. JSKL_cFDStep = 13;
  1153. }
  1154. else if(dwTickCount >= JSKL_cFDDelay)
  1155. JSKL_SetAlarmCode(JSKL_PJ_ORIGIN_ALARM);
  1156. }break;
  1157. case 13:
  1158. if(JSKL_FD_IN)
  1159. {
  1160. JSKL_cFDStep = 14;
  1161. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1162. }
  1163. else if(dwTickCount >= JSKL_cFDDelay)
  1164. JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
  1165. break;
  1166. case 14:
  1167. {
  1168. if(!JSKL_SM_LIMIT_IN)
  1169. {
  1170. JSKL_XM_VAVLE = 0;
  1171. jl_flg = 1; //由下模退到位启动进料时间
  1172. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1173. JSKL_cFDStep = 15;
  1174. }
  1175. else if(dwTickCount >= JSKL_cFDDelay)
  1176. JSKL_SetAlarmCode(JSKL_SM_LIMIT_ALARM);
  1177. }break;
  1178. case 15:
  1179. {
  1180. if(!JSKL_XM_LIMIT_IN)
  1181. {
  1182. JSKL_FD_VAVLE = 0; //分带关
  1183. tm_flg = 1;
  1184. JSKL_LTM_VAVLE = 0;
  1185. JSKL_RTM_VAVLE = 0;
  1186. if(!cJSKL_left_enable || !cJSKL_right_enable)
  1187. {
  1188. JSKL_cFDStep = 16;
  1189. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_ALL_BACK+JSKL_PARAM_DELAY_FD_BACK2;
  1190. }
  1191. else
  1192. {
  1193. JSKL_cFDStep = 17;
  1194. JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_FD_BACK2;
  1195. }
  1196. }
  1197. else if(dwTickCount >= JSKL_cFDDelay)
  1198. JSKL_SetAlarmCode(JSKL_XM_LIMIT_ALARM);
  1199. }break;
  1200. case 16:
  1201. if((dwTickCount >= JSKL_cFDDelay))
  1202. {
  1203. // if(!cJSKL_left_enable)JSKL_LTM_VAVLE = 0; //不选择就关闭
  1204. // if(!cJSKL_right_enable)JSKL_RTM_VAVLE = 0; //不选择就关闭
  1205. JSKL_FD_VAVLE = 0;
  1206. JSKL_GZ_VAVLE = 0;
  1207. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1208. JSKL_cFDStep = 18;
  1209. }
  1210. break;
  1211. case 17:
  1212. {
  1213. if(dwTickCount >= JSKL_cFDDelay)
  1214. {
  1215. // if(!cJSKL_left_enable)JSKL_LTM_VAVLE = 0; //不选择就关闭
  1216. // if(!cJSKL_right_enable)JSKL_RTM_VAVLE = 0; //不选择就关闭
  1217. JSKL_FD_VAVLE = 0;
  1218. JSKL_GZ_VAVLE = 0;
  1219. JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
  1220. JSKL_cFDStep = 18;
  1221. }
  1222. }break;
  1223. case 18:
  1224. {
  1225. if(!JSKL_FD_IN)
  1226. {
  1227. JSKL_cFDStep = 0;
  1228. JSKL_cFDDelay = dwTickCount;
  1229. }
  1230. else if(dwTickCount >= JSKL_cFDDelay)
  1231. {
  1232. JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
  1233. }
  1234. }break;
  1235. default:;
  1236. }
  1237. }
  1238. #endif