TYQueduanChuantou.c 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366
  1. #include "global.h"
  2. #if TONG_YONG_MACHINE
  3. unsigned long cSlowPusle;
  4. unsigned char bStartOnceTime,bOnceProcess;
  5. unsigned short cWorkCnt;
  6. unsigned char TryCnt = 0;
  7. unsigned short cTbCnt = 0;
  8. unsigned char ZhuangLiaoOkFlg = 0;
  9. unsigned char SongLaTouOkFlg = 0;
  10. unsigned char FirstStartFlg = 0;
  11. unsigned char cBackFlg = 0;
  12. static long save_limit_pos;
  13. void QDCT_ManualAction(void);
  14. void QDCT_JiaLianAction(void);
  15. void QDCT_AutoStepAction(void);
  16. void QDCT_TableAction(void);
  17. void QDCT_Motor(void);
  18. void QDCT_CheckStart(void);
  19. void QDCT_SL_Step(void);
  20. void QDCT_XiaQieAction(void);
  21. void QDCT_AlarmProtect(void);
  22. void QDCT_ZLT_Step(void);
  23. void QDCT_TuiLian(void);
  24. void QDCT_ExtiActionX31(void)
  25. {
  26. if(cSeBiaoEn && !cSeBiaoOk)
  27. {
  28. cSeBiaoEn = 0;
  29. cSeBiaoOk = 1;
  30. SetRemainLength(X_AXIS,QDCT_SEBIAO_LENGTH,10);
  31. }
  32. }
  33. //故障报警
  34. void QDCT_SetAlarmCode(unsigned alarm_code)
  35. {
  36. SetAlarmCode(QDCT_ALARM_ADDR,alarm_code);
  37. QDCT_bAlarmStop = 1;
  38. }
  39. //初始化动作
  40. void QDCT_InitAction(void)
  41. {
  42. float buff_pulse,buff_dist;
  43. buff_pulse = QDCT_PARAM_CYCLE_PULSE;
  44. buff_dist = QDCT_PARAM_CYCLE_LENGTH;
  45. XGearRatio = buff_pulse/buff_dist;
  46. QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
  47. }
  48. void QDCT_Action(void)
  49. {
  50. QDCT_AlarmProtect();
  51. QDCT_CheckStart();
  52. QDCT_TuiLian();
  53. QDCT_ZLT_Step();
  54. QDCT_TableAction();
  55. QDCT_SL_Step();
  56. QDCT_JiaLianAction();
  57. QDCT_XiaQieAction();
  58. QDCT_Motor();
  59. QDCT_ManualAction();
  60. QDCT_AutoStepAction();
  61. }
  62. void QDCT_AlarmProtect(void)
  63. {
  64. dwRealPos = GetPos(X_AXIS);
  65. if(QDCT_PARAM_BACK_ALARM_MODE)
  66. { //感应后限模式
  67. if(!bRunning)
  68. {
  69. if(QDCT_BACK_LIMIT_IN_UP)
  70. {
  71. if(X_DRV && (QDCT_bMotorBack) || (QDCT_MotorStep != 0)) //到后限不能再后退但可以点前进
  72. {
  73. QDCT_bMotorBack = 0;
  74. AxisEgmStop(X_AXIS);
  75. QDCT_JD_OUT = 0;
  76. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  77. }
  78. }
  79. }
  80. else
  81. {
  82. if(QDCT_BACK_LIMIT_IN_UP)
  83. {
  84. AxisEgmStop(X_AXIS);
  85. QDCT_JD_OUT = 0;
  86. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  87. }
  88. }
  89. }
  90. else
  91. {
  92. if(QDCT_GO_LIMIT_IN_UP) //数控后限模式
  93. {
  94. save_limit_pos = dwRealPos;
  95. SetData32bits(200,save_limit_pos);
  96. }
  97. if(QDCT_PARAM_MAX_BACK_LENGTH < (dwRealPos - save_limit_pos))
  98. {
  99. if(!bRunning)
  100. {
  101. if((QDCT_MotorStep == 0) && X_DRV && QDCT_bMotorBack) //到后限不能再后退但可以点前进
  102. {
  103. QDCT_bMotorBack = 0;
  104. AxisDecStop(X_AXIS);
  105. QDCT_JD_OUT = 0;
  106. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  107. }
  108. }
  109. else
  110. {
  111. AxisDecStop(X_AXIS);
  112. QDCT_JD_OUT = 0;
  113. QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
  114. }
  115. }
  116. }
  117. if(bRunning)
  118. {
  119. if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  120. }
  121. }
  122. void QDCT_JiaLianAction(void)
  123. {
  124. if(QDCT_JZ_IN_UP && QDCT_GO_LIMIT_IN)
  125. {
  126. QDCT_YD_OUT = 0;
  127. QDCT_TL_OUT = 0;
  128. }
  129. if(QDCT_JiaLianStep == 1)
  130. {
  131. QDCT_JD_Delay = dwTickCount + QDCT_PARAM_JD_DELAY;
  132. QDCT_JiaLianStep = 2;
  133. }
  134. else if((QDCT_JiaLianStep == 2) && (dwTickCount >= QDCT_JD_Delay))
  135. {
  136. QDCT_JD_OUT = 1;
  137. QDCT_JD_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  138. QDCT_JiaLianStep = 3;
  139. }
  140. else if(QDCT_JiaLianStep == 3)
  141. {
  142. if(QDCT_JZ_IN)
  143. {
  144. QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_DELAY;
  145. QDCT_TL_OUT = 0;
  146. QDCT_YD_OUT = 0;
  147. QDCT_JiaLianStep = 4;
  148. }
  149. else if(dwTickCount >= QDCT_JD_Delay)
  150. {
  151. QDCT_SetAlarmCode(QDCT_JD_ALARM);
  152. }
  153. }
  154. else if(QDCT_JiaLianStep == 4)
  155. {
  156. if(QDCT_PARAM_KL_TIME)
  157. {
  158. QDCT_JiaLianStep = 5;
  159. }
  160. else
  161. {
  162. QDCT_JiaLianStep = 7;
  163. }
  164. }
  165. else if((QDCT_JiaLianStep == 5) && (dwTickCount >= QDCT_JD_Delay))
  166. {
  167. QDCT_KL_OUT = 1;
  168. QDCT_JiaLianStep = 6;
  169. QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_TIME;
  170. }
  171. else if((QDCT_JiaLianStep == 6) && (dwTickCount >= QDCT_JD_Delay))
  172. {
  173. QDCT_KL_OUT = 0;
  174. QDCT_JiaLianStep = 7;
  175. }
  176. else if((QDCT_JiaLianStep == 7))
  177. {
  178. QDCT_JiaLianStep = 0;
  179. }
  180. }
  181. //自动动作
  182. void QDCT_AutoStepAction(void)
  183. {
  184. if(bRunning)
  185. {
  186. if(QDCT_AutoStep == 1)
  187. {
  188. QDCT_AutoStep = 2;
  189. QDCT_ZhenDongStep = 1;
  190. if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
  191. }
  192. else if((QDCT_AutoStep == 2) && (dwTickCount >= QDCT_AutoDelay))
  193. {
  194. QDCT_AutoStep = 3;
  195. }
  196. else if(QDCT_AutoStep == 3)
  197. {
  198. if(QDCT_MotorStep == 0)
  199. {
  200. QDCT_MotorStep = 61;
  201. ZhuangLiaoOkFlg = 0;
  202. QDCT_AutoStep = 4;
  203. }
  204. }
  205. else if(QDCT_AutoStep == 4)
  206. {
  207. QDCT_AutoStep = 5;
  208. }
  209. else if(QDCT_AutoStep == 5)
  210. {
  211. if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
  212. QDCT_AutoStep = 6;
  213. }
  214. else if(QDCT_AutoStep == 6)
  215. {
  216. if(QDCT_ZhuangLiaoStep == 0)
  217. {
  218. QDCT_AutoStep = 7;
  219. }
  220. }
  221. else if(QDCT_AutoStep == 7)
  222. {
  223. QDCT_AutoStep = 8;
  224. }
  225. else if(QDCT_AutoStep == 8)
  226. {
  227. QDCT_AutoStep = 9;
  228. }
  229. else if(QDCT_AutoStep == 9)
  230. {
  231. if(QDCT_MotorStep == 0)
  232. {
  233. QDCT_AutoStep = 10;
  234. }
  235. }
  236. else if(QDCT_AutoStep == 10)
  237. {
  238. QDCT_AutoStep = 11;
  239. }
  240. else if(QDCT_AutoStep == 11)
  241. {
  242. if((QDCT_MotorStep == 0) && (QDCT_ZhuangLiaoStep == 0)) //
  243. {
  244. if(QDCT_SEBIAO_MODE)
  245. QDCT_MotorStep = 1;
  246. else
  247. QDCT_MotorStep = 30;
  248. QDCT_AutoStep = 12;
  249. }
  250. }
  251. else if(QDCT_AutoStep == 12)
  252. {
  253. if(QDCT_MotorStep == 0)
  254. {
  255. ZhuangLiaoOkFlg = 0;
  256. if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
  257. QDCT_AutoStep = 13;
  258. }
  259. }
  260. else if(QDCT_AutoStep == 13)
  261. {
  262. QDCT_AutoStep = 14;
  263. }
  264. else if(QDCT_AutoStep == 14)
  265. {
  266. if(bStartOnceTime)
  267. {
  268. bStartOnceTime = 0;
  269. cBackFlg = 1;
  270. QDCT_AutoStep = 0;
  271. bRunning = 0;
  272. }
  273. else
  274. {
  275. if(QDCT_XiaQieStep == 0)
  276. {
  277. QDCT_XiaQieStep = 1;
  278. QDCT_AutoStep = 15;
  279. }
  280. }
  281. }
  282. else if(QDCT_AutoStep == 15)
  283. {
  284. if(((QDCT_XiaQieStep == 0) || (QDCT_XiaQieStep == 6)) && !QDCT_SQ_LIMIT_IN)
  285. {
  286. if(QDCT_MotorStep == 0)
  287. {
  288. QDCT_MotorStep = 40;
  289. QDCT_AutoStep = 16;
  290. }
  291. }
  292. }
  293. else if((QDCT_AutoStep == 16) && (QDCT_MotorStep == 0))
  294. {
  295. CalProSP(QDCT_SPEED_ADDR); //计算生产速度
  296. AddToTal(QDCT_TOTAL_ADDR); //生产总量加1并保存
  297. AddToTal(QDCT_NOWTOTAL_ADDR); //生产总量加1并保存
  298. cWorkCnt++;
  299. dwZipCnt++;
  300. cTbCnt++;
  301. if(cTbCnt >= QDCT_PARAM_TABLE_NUM)
  302. {
  303. QDCT_TB_OUT = 1;
  304. cTbCnt = 0;
  305. QDCT_TableDelay = dwTickCount + QDCT_PARAM_TABLE_TIME;
  306. }
  307. if(QDCT_ZHA_STOP_TIME == 0)
  308. {
  309. if(GetTotal(QDCT_NOWTOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR))
  310. {
  311. bStartOnceTime = 0;
  312. QDCT_SetAlarmCode(QDCT_TOTAL_ALARM);
  313. }
  314. else
  315. {
  316. QDCT_AutoStep = 17;
  317. }
  318. }
  319. else
  320. {
  321. if(GetTotal(QDCT_NOWTOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR))
  322. {
  323. ClrcToTal(QDCT_NOWTOTAL_ADDR);
  324. QDCT_AutoDelay = dwTickCount + QDCT_ZHA_STOP_TIME;
  325. QDCT_AutoStep = 17;
  326. }
  327. else
  328. {
  329. QDCT_AutoDelay = dwTickCount;
  330. QDCT_AutoStep = 17;
  331. }
  332. }
  333. }
  334. else if((QDCT_AutoStep == 17) && (dwTickCount >= QDCT_AutoDelay))
  335. {
  336. {
  337. QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
  338. QDCT_AutoStep = 2;
  339. }
  340. }
  341. }
  342. }
  343. void QDCT_TuiLian(void)
  344. {
  345. switch(QDCT_TuiLianStep)
  346. {
  347. case 0:
  348. break;
  349. case 1:
  350. QDCT_TuiLianStep = 2;
  351. break;
  352. case 2:
  353. if(QDCT_SQ_LIMIT_IN)
  354. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  355. else
  356. {
  357. if(!QDCT_YD_OUT)QDCT_TLDelay = dwTickCount + QDCT_PARAM_TL_DELAY;
  358. else
  359. QDCT_TLDelay = dwTickCount;
  360. QDCT_YD_OUT = 1;
  361. QDCT_TuiLianStep = 3;
  362. }
  363. break;
  364. case 3:
  365. if(dwTickCount >= QDCT_TLDelay)
  366. {
  367. QDCT_TL_OUT = 1;
  368. QDCT_TLDelay = dwTickCount;
  369. QDCT_TuiLianStep = 4;
  370. }
  371. break;
  372. case 4:
  373. if(dwTickCount >= QDCT_TLDelay)
  374. {
  375. QDCT_TuiLianStep = 0;
  376. }
  377. break;
  378. }
  379. }
  380. //台面电机动作
  381. void QDCT_TableAction(void)
  382. {
  383. if(QDCT_TB_OUT && (dwTickCount >= QDCT_TableDelay))QDCT_TB_OUT = 0;
  384. }
  385. void QDCT_CheckStart(void)
  386. {
  387. if(bRunning)
  388. QDCT_PARAM_RUN_STATE = 1;
  389. else
  390. QDCT_PARAM_RUN_STATE = 0;
  391. //启动 自动启动 单一自动
  392. if(START_IN_UP || bStart || QDCT_bOnceStart)
  393. {
  394. if(QDCT_bOnceStart)
  395. {
  396. QDCT_bOnceStart = 0;
  397. bStartOnceTime = 1;
  398. dwZipCnt = 0;
  399. }
  400. bStart = 0;
  401. if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  402. else if(QDCT_LTCZ_IN)QDCT_SetAlarmCode(QDCT_LTCZ_ALARM);
  403. else if(!QDCT_HSL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
  404. else if(QDCT_HSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
  405. else if(!QDCT_XM_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  406. else if(QDCT_SQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  407. else if(QDCT_GO_LIMIT_IN && QDCT_JZ_IN && QDCT_HSL_ORIGIN_IN && !QDCT_SL_LIMIT_IN)
  408. {
  409. if(!bRunning && (QDCT_AutoStep == 0) && (GetAlarmCode(QDCT_ALARM_ADDR) == 0))
  410. {
  411. bRunning = 1;
  412. QDCT_AutoStep = 4;
  413. cWorkCnt = 0;
  414. TryCnt = 0;
  415. SongLaTouOkFlg = 1;
  416. dwZipCnt = 0;
  417. FirstStartFlg = 0;
  418. cBackFlg = 0;
  419. }
  420. }
  421. else
  422. {
  423. if(!bRunning && (QDCT_AutoStep == 0) && (GetAlarmCode(QDCT_ALARM_ADDR) == 0))
  424. {
  425. bRunning = 1;
  426. QDCT_AutoStep = 1;
  427. cWorkCnt = 0;
  428. TryCnt = 0;
  429. SongLaTouOkFlg = 1;
  430. dwZipCnt = 0;
  431. FirstStartFlg = 1;
  432. cBackFlg = 0;
  433. }
  434. }
  435. }
  436. if(bStop)
  437. {
  438. bStop = 0;
  439. if(bRunning)bStartOnceTime = 1;
  440. }
  441. //停止
  442. if(STOP_IN_UP)
  443. {
  444. {
  445. AxisDecStop(X_AXIS);
  446. bRunning = 0;
  447. QDCT_bOnceStart = 0;
  448. bStop = 0;
  449. bStartOnceTime = 0;
  450. QDCT_AutoStep = 0;
  451. QDCT_ZhuangLiaoStep = 0;
  452. QDCT_MotorStep = 0;
  453. QDCT_JiaLianStep = 0;
  454. QDCT_XiaQieStep = 0;
  455. QDCT_ZhenDongStep = 0;
  456. QDCT_SongLiaoStep = 0;
  457. QDCT_TuiLianStep =0;
  458. QDCT_CS_OUT = 0;
  459. QDCT_SQ_OUT = 0;
  460. QDCT_XM_OUT = 0;
  461. QDCT_JD_OUT = 0;
  462. QDCT_SL_OUT = 0;
  463. QDCT_JLT_OUT= 0;
  464. QDCT_HSL_OUT = 0;
  465. QDCT_KL_OUT = 0;
  466. QDCT_TL_OUT = 0;
  467. QDCT_YD_OUT = 0;
  468. cBackFlg = 0;
  469. QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
  470. if(GetAlarmCode(QDCT_ALARM_ADDR) != 0)QDCT_SetAlarmCode(QDCT_NO_ALARM);
  471. if(!X_DRV && (QDCT_GO_DEC_IN) && !bRunning && (QDCT_MotorStep == 0))
  472. {
  473. QDCT_MotorStep = 20;
  474. }
  475. }
  476. }
  477. if(QDCT_bAlarmStop)
  478. {
  479. bRunning = 0;
  480. QDCT_bOnceStart = 0;
  481. QDCT_bAlarmStop = 0;
  482. bStartOnceTime = 0;
  483. AxisDecStop(X_AXIS);
  484. QDCT_AutoStep = 0;
  485. QDCT_ZhuangLiaoStep = 0;
  486. QDCT_MotorStep = 0;
  487. QDCT_JiaLianStep = 0;
  488. QDCT_XiaQieStep = 0;
  489. QDCT_ZhenDongStep = 0;
  490. QDCT_SongLiaoStep = 0;
  491. QDCT_CS_OUT = 0;
  492. QDCT_SQ_OUT = 0;
  493. }
  494. }
  495. //电机控制动作
  496. void QDCT_Motor(void) //
  497. {
  498. static long save_buff,length_buff,gou_zhen_buff,back_dec_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  499. switch(QDCT_MotorStep)
  500. {
  501. case 1:
  502. QDCT_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  503. QDCT_MotorStep = 2;
  504. break;
  505. case 2:
  506. if(dwTickCount >= QDCT_MotorDelay)
  507. {
  508. back_dec_buff = dwRealPos;
  509. if(dwZipCnt == 0)
  510. {
  511. cSeBiaoOk = 0;
  512. cSeBiaoEn = 1;
  513. AxisContinueMove(X_AXIS,20,QDCT_DIR_P);
  514. }
  515. else
  516. {
  517. AxisContinueMove(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_DIR_P);
  518. }
  519. QDCT_MotorStep = 3;
  520. }
  521. break;
  522. case 3:
  523. if(dwZipCnt != 0)
  524. {
  525. if(QDCT_PARAM_SET_ZIPPER_LENGTH >= (QDCT_SEBIAO_LENGTH + QDCT_REMAIN_CHECK_LENGTH))
  526. {
  527. cSeBiaoOk = 0;
  528. cSeBiaoEn = 1;
  529. }
  530. else
  531. {
  532. if((dwRealPos - back_dec_buff) >= (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_LENGTH - QDCT_REMAIN_CHECK_LENGTH))
  533. {
  534. cSeBiaoOk = 0;
  535. cSeBiaoEn = 1;
  536. }
  537. }
  538. }
  539. if((dwRealPos - back_dec_buff) > (QDCT_PARAM_SET_ZIPPER_LENGTH - (QDCT_BACK_LOWSPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDCT_PARAM_JJBACK_SPEED,20,30)))))
  540. {
  541. if(X_DRV)MoveChangSpeed(X_AXIS,20);
  542. }
  543. if(cSeBiaoOk)
  544. {
  545. cSeBiaoOk = 0;
  546. cSeBiaoEn = 0;
  547. QDCT_MotorStep = 4;
  548. }
  549. break;
  550. case 4:
  551. if(!X_DRV)
  552. {
  553. QDCT_MotorStep = 0;
  554. }
  555. break;
  556. case 20:
  557. {
  558. if(QDCT_SZ_OUT == QDCT_MOTOR_DISEN)
  559. {
  560. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  561. QDCT_MotorDelay = dwTickCount + 50;
  562. }
  563. QDCT_MotorStep = 21;
  564. }
  565. break;
  566. case 21:
  567. if(dwTickCount >= QDCT_MotorDelay)
  568. {
  569. AxisMovePos(X_AXIS,20,-QDCT_PARAM_ON_BACK_LENGTH);
  570. QDCT_MotorStep = 22;
  571. }
  572. break;
  573. case 22:
  574. if(!X_DRV)
  575. {
  576. QDCT_MotorStep = 0;
  577. }
  578. break;
  579. case 30:
  580. if(QDCT_SZ_OUT == QDCT_MOTOR_DISEN)
  581. {
  582. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  583. QDCT_MotorDelay = dwTickCount + 50;
  584. }
  585. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
  586. QDCT_MotorStep = 31;
  587. break;
  588. case 31:
  589. if(dwTickCount >= QDCT_MotorDelay)
  590. {
  591. gou_zhen_buff = dwRealPos;
  592. save_buff = dwRealPos;
  593. QDCT_MotorDelay = dwTickCount + QDCT_PARAM_XM_START_TIME;
  594. MoveAction_Pulse2_AccDec(X_AXIS,PosToPulse(X_AXIS,QDCT_PARAM_SET_ZIPPER_LENGTH),PosToPulse(X_AXIS,QDCT_PARAM_PUTIN_SPEED_LENGTH),PosToPulse(X_AXIS,0),QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_PUTIN_SPEED,1, 5,10);
  595. QDCT_MotorStep = 32;
  596. }
  597. break;
  598. case 32:
  599. if(dwTickCount >= QDCT_MotorDelay)
  600. {
  601. back_buff = dwRealPos;
  602. QDCT_MotorStep = 33;
  603. }
  604. break;
  605. case 33:
  606. if((dwRealPos - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH))
  607. {
  608. QDCT_JLT_OUT = 1;
  609. QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  610. QDCT_MotorStep = 34;
  611. }
  612. else if(!X_DRV)
  613. {
  614. QDCT_JLT_OUT = 1;
  615. QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  616. QDCT_MotorStep = 34;
  617. }
  618. break;
  619. case 34:
  620. if(!QDCT_JLT_IN)
  621. {
  622. QDCT_XM_OUT = 0;
  623. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  624. QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  625. QDCT_MotorStep = 35;
  626. }
  627. else if(!X_DRV && !QDCT_JLT_IN)
  628. {
  629. QDCT_XM_OUT = 0;
  630. QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  631. QDCT_MotorStep = 35;
  632. }
  633. else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_JLT_ALARM);
  634. break;
  635. case 35:
  636. if(!X_DRV && QDCT_XM_ORIGIN_IN && QDCT_XM_ORIGIN_IN)
  637. {
  638. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  639. QDCT_MotorStep = 36;
  640. }
  641. else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  642. break;
  643. case 36:
  644. if(!X_DRV)
  645. {
  646. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  647. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_FZ_LENGTH,1,10,10);
  648. QDCT_MotorStep = 37;
  649. }
  650. break;
  651. case 37:
  652. if(!X_DRV)
  653. {
  654. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  655. QDCT_MotorStep = 0;
  656. }
  657. break;
  658. case 40:
  659. // if(dwTickCount >= QDCT_MotorDelay)
  660. {
  661. jz_buff = dwRealPos;
  662. if(QDCT_PARAM_SJZ_LENGTH == 0)
  663. {
  664. QDCT_JD_OUT = 0;
  665. }
  666. QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
  667. QDCT_MotorStep = 41;
  668. }
  669. break;
  670. case 41:
  671. if(QDCT_JD_OUT && (dwTickCount >= QDCT_MotorDelay))
  672. {
  673. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,-(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),1,10,10);
  674. QDCT_MotorStep = 42;
  675. }
  676. break;
  677. case 42: // 切断完成后拉电机动作
  678. if(((QDCT_PARAM_SJZ_LENGTH) <= (dwRealPos - jz_buff)))
  679. {
  680. QDCT_JD_OUT = 0;
  681. QDCT_MotorStep = 43;
  682. }
  683. else if(!X_DRV)
  684. {
  685. QDCT_JD_OUT = 0;
  686. QDCT_MotorStep = 43;
  687. }
  688. break;
  689. case 43: // 切断完成后拉电机动作
  690. if(!X_DRV)
  691. {
  692. QDCT_MotorStep = 0;
  693. QDCT_MotorDelay = dwTickCount;
  694. }
  695. break;
  696. case 61: // 前点定位数控模式
  697. if(QDCT_JD_OUT || (QDCT_SZ_OUT == QDCT_MOTOR_DISEN))
  698. {
  699. QDCT_JD_OUT = 0;
  700. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  701. QDCT_MotorDelay = dwTickCount + 50;
  702. }
  703. if((QDCT_TuiLianStep == 0) && !QDCT_TL_OUT)QDCT_TuiLianStep = 1;
  704. QDCT_MotorStep = 62;
  705. break;
  706. case 62:
  707. if(dwTickCount >= QDCT_MotorDelay)
  708. {
  709. if(QDCT_GO_LIMIT_IN || QDCT_GO_DEC_IN)
  710. {
  711. AxisMovePos(X_AXIS,20,-QDCT_PARAM_ON_BACK_LENGTH);
  712. QDCT_MotorDelay = dwTickCount + 1000;
  713. }
  714. QDCT_MotorStep = 63;
  715. QDCT_JD_OUT = 0;
  716. }
  717. break;
  718. case 63:
  719. if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay))
  720. {
  721. go_buff = dwRealPos;
  722. if(dwZipCnt > 0)
  723. {
  724. MoveAction_Const_Stop_AccDec(X_AXIS,QDCT_DIR_P,QDCT_PARAM_JJGO_SPEED,1,5,10);
  725. }
  726. else
  727. {
  728. MoveAction_Const_Stop_AccDec(X_AXIS,QDCT_DIR_P,QDCT_PARAM_FIRSTSPEED,1,5,10);
  729. }
  730. QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  731. QDCT_MotorStep = 64;
  732. }
  733. break;
  734. case 64:
  735. if(dwZipCnt > 0)
  736. {
  737. if(((go_buff - dwRealPos) > ((QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_PARAM_OFFSET_LENGTH) - (QDCT_PARAM_GO_LOWSPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_GO_LOWSPEED,5))) + QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH)) || QDCT_GO_DEC_IN_UP)
  738. {
  739. MoveChangSpeed(X_AXIS,QDCT_PARAM_GO_LOWSPEED);
  740. QDCT_MotorStep = 66;
  741. QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  742. }
  743. else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  744. }
  745. else
  746. {
  747. QDCT_MotorStep = 66;
  748. }
  749. break;
  750. case 65:
  751. if(QDCT_GO_LIMIT_IN_UP)
  752. {
  753. AxisEgmStop(X_AXIS);
  754. QDCT_MotorStep = 66;
  755. }
  756. else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  757. break;
  758. case 66:
  759. if(!X_DRV)
  760. {
  761. QDCT_MotorDelay = dwTickCount;
  762. QDCT_MotorStep = 67;
  763. }
  764. break;
  765. case 67:
  766. if(dwTickCount >= QDCT_MotorDelay)
  767. {
  768. if(QDCT_JiaLianStep == 0)
  769. {
  770. QDCT_JiaLianStep = 1;
  771. QDCT_MotorStep = 68;
  772. }
  773. }
  774. break;
  775. case 68:
  776. if(QDCT_JiaLianStep == 0)
  777. {
  778. QDCT_MotorStep = 0;
  779. }
  780. break;
  781. case 100:
  782. if((dwTickCount >= QDCT_MotorDelay) && !X_DRV)
  783. {
  784. AxisMovePos(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-(QDCT_PARAM_SET_ZIPPER_LENGTH));
  785. QDCT_MotorStep = 101;
  786. QDCT_MotorDelay = dwTickCount + 1000;
  787. }
  788. break;
  789. case 101:
  790. if((dwTickCount >= QDCT_MotorDelay) && !X_DRV)
  791. {
  792. QDCT_MotorStep = 102;
  793. }
  794. break;
  795. case 102:
  796. AxisMovePos(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH));
  797. QDCT_MotorStep = 100;
  798. QDCT_MotorDelay = dwTickCount + 1000;
  799. break;
  800. }
  801. }
  802. //切断动作
  803. void QDCT_XiaQieAction(void)
  804. {
  805. user_datas[121] = QDCT_AutoStep;
  806. user_datas[122] = QDCT_ZhuangLiaoStep;
  807. user_datas[123] = QDCT_TuiLianStep;
  808. user_datas[124] = QDCT_MotorStep;
  809. user_datas[125] = QDCT_JiaLianStep;
  810. // user_datas[126] = QDCT_XiaQieStep;
  811. // user_datas[127] = PosToPulse(X_AXIS,QDCT_PARAM_PUTIN_SPEED_LENGTH);
  812. if(QDCT_XiaQieStep == 1)
  813. {
  814. if(QDCT_GO_LIMIT_IN)
  815. {
  816. QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
  817. }
  818. else if(!QDCT_TL_ORIGIN_IN)
  819. QDCT_SetAlarmCode(QDCT_TL_ORIGIN_ALARM);
  820. else
  821. {
  822. QDCT_XiaQieStep = 2;
  823. }
  824. }
  825. else if(QDCT_XiaQieStep == 2)
  826. {
  827. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUT_DELAY;
  828. QDCT_XiaQieStep = 3;
  829. }
  830. else if((QDCT_XiaQieStep == 3) && (dwTickCount >= QDCT_XiaQieDelay))
  831. {
  832. QDCT_SQ_OUT = 1;
  833. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  834. QDCT_XiaQieStep = 4;
  835. }
  836. else if(QDCT_XiaQieStep == 4)
  837. {
  838. if(QDCT_SQ_LIMIT_IN)
  839. {
  840. QDCT_XiaQieStep = 5;
  841. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_DELAY_CS;
  842. }
  843. else if(dwTickCount >= QDCT_XiaQieDelay)
  844. {
  845. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  846. }
  847. }
  848. else if((QDCT_XiaQieStep == 5) && (dwTickCount >= QDCT_XiaQieDelay))
  849. {
  850. QDCT_XiaQieStep = 6;
  851. if(QDCT_PARAM_CS_ENABLE)QDCT_CS_OUT = 1;
  852. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_TIME;
  853. }
  854. else if((QDCT_XiaQieStep == 6) && (dwTickCount >= QDCT_XiaQieDelay))
  855. {
  856. QDCT_CS_OUT = 0;
  857. QDCT_XiaQieStep = 7;
  858. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_COLD_TIME;
  859. }
  860. else if((QDCT_XiaQieStep == 7) && (dwTickCount >= QDCT_XiaQieDelay))
  861. {
  862. QDCT_SQ_OUT = 0;
  863. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  864. QDCT_XiaQieStep = 8;
  865. }
  866. else if(QDCT_XiaQieStep == 8)
  867. {
  868. if(!QDCT_SQ_LIMIT_IN)
  869. {
  870. QDCT_XiaQieStep = 0;
  871. if(cBackFlg)
  872. {
  873. cBackFlg = 0;
  874. if(QDCT_MotorStep==0)QDCT_MotorStep = 40;
  875. }
  876. QDCT_YD_OUT = 1;
  877. }
  878. else if(dwTickCount >= QDCT_XiaQieDelay)
  879. {
  880. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  881. }
  882. }
  883. }
  884. //装拉头动作
  885. void QDCT_ZLT_Step(void)
  886. {
  887. if(QDCT_ZhuangLiaoStep == 1)
  888. {
  889. if(ZhuangLiaoOkFlg)
  890. {
  891. QDCT_ZhuangLiaoStep = 0;
  892. }
  893. else
  894. {
  895. if(FirstStartFlg && QDCT_JLT_IN)
  896. {
  897. QDCT_ZhuangLiaoStep = 7;
  898. }
  899. else
  900. {
  901. FirstStartFlg = 0;
  902. if(QDCT_SongLiaoStep == 0)
  903. {
  904. QDCT_SongLiaoStep = 1;
  905. QDCT_ZhuangLiaoStep = 2;
  906. }
  907. }
  908. }
  909. }
  910. else if(QDCT_ZhuangLiaoStep == 2)
  911. {
  912. if(QDCT_SongLiaoStep == 0)
  913. {
  914. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  915. if(QDCT_JLT_IN)QDCT_JLT_OUT = 1;
  916. QDCT_ZhuangLiaoStep = 3;
  917. }
  918. }
  919. else if(QDCT_ZhuangLiaoStep == 3)
  920. {
  921. if(QDCT_HSL_ORIGIN_IN && QDCT_XM_ORIGIN_IN && !QDCT_JLT_IN && (QDCT_XiaQieStep == 0))
  922. {
  923. QDCT_HSL_OUT = 1;
  924. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  925. QDCT_ZhuangLiaoStep = 4;
  926. }
  927. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  928. {
  929. if(!QDCT_HSL_ORIGIN_IN)
  930. QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
  931. else
  932. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  933. }
  934. }
  935. else if(QDCT_ZhuangLiaoStep == 4)
  936. {
  937. if(QDCT_HSL_LIMIT_IN)
  938. {
  939. QDCT_JLT_OUT = 0;
  940. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  941. QDCT_ZhuangLiaoStep = 5;
  942. }
  943. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  944. {
  945. QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
  946. }
  947. }
  948. else if(QDCT_ZhuangLiaoStep == 5)
  949. {
  950. if(QDCT_JLT_IN)
  951. {
  952. QDCT_ZhuangLiaoStep = 6;
  953. }
  954. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  955. {
  956. QDCT_SetAlarmCode(QDCT_JLT_ALARM);
  957. }
  958. }
  959. else if(QDCT_ZhuangLiaoStep == 6)
  960. {
  961. QDCT_HSL_OUT = 0;
  962. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  963. if(!bRunning)
  964. {
  965. QDCT_ZhuangLiaoStep = 0;
  966. SongLaTouOkFlg = 0;
  967. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  968. }
  969. else
  970. QDCT_ZhuangLiaoStep = 7;
  971. }
  972. else if(QDCT_ZhuangLiaoStep == 7)
  973. {
  974. if(!QDCT_HSL_LIMIT_IN && QDCT_GO_LIMIT_IN)
  975. {
  976. QDCT_XM_OUT = 1;
  977. if(FirstStartFlg)
  978. {
  979. FirstStartFlg = 0;
  980. }
  981. else
  982. SongLaTouOkFlg = 0;
  983. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  984. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  985. QDCT_ZhuangLiaoStep = 8;
  986. }
  987. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  988. {
  989. if(QDCT_HSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
  990. }
  991. }
  992. else if(QDCT_ZhuangLiaoStep == 8)
  993. {
  994. if(!QDCT_XM_ORIGIN_IN)
  995. {
  996. QDCT_ZhuangLiaoStep = 9;
  997. QDCT_ZhuangLiaoDelay = dwTickCount + 1000;
  998. }
  999. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  1000. {
  1001. QDCT_SetAlarmCode(QDCT_XM_LIMIT_ALARM);
  1002. }
  1003. }
  1004. else if(QDCT_ZhuangLiaoStep == 9)
  1005. {
  1006. if(QDCT_LTCZ_IN)
  1007. {
  1008. QDCT_ZhuangLiaoStep = 0;
  1009. ZhuangLiaoOkFlg = 1;
  1010. TryCnt = 0;
  1011. }
  1012. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  1013. {
  1014. if(bRunning)
  1015. {
  1016. TryCnt++;
  1017. if(TryCnt > 4)
  1018. {
  1019. QDCT_SetAlarmCode(QDCT_LTCZ_ALARM);
  1020. QDCT_JLT_OUT = 1;
  1021. QDCT_XM_OUT = 0;
  1022. }
  1023. else
  1024. {
  1025. QDCT_ZhuangLiaoStep = 10;
  1026. }
  1027. }
  1028. else
  1029. {
  1030. QDCT_ZhuangLiaoStep = 0;
  1031. QDCT_ZhuangLiaoDelay = dwTickCount;
  1032. }
  1033. }
  1034. }
  1035. else if(QDCT_ZhuangLiaoStep == 10) //装拉头失败重复装几次拉头
  1036. {
  1037. QDCT_XM_OUT = 0;
  1038. QDCT_JLT_OUT = 0;
  1039. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1040. QDCT_ZhuangLiaoStep = 11;
  1041. }
  1042. else if(QDCT_ZhuangLiaoStep == 11)
  1043. {
  1044. if(QDCT_XM_ORIGIN_IN)
  1045. {
  1046. QDCT_ZhuangLiaoStep = 12;
  1047. }
  1048. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  1049. {
  1050. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  1051. }
  1052. }
  1053. else if(QDCT_ZhuangLiaoStep == 12)
  1054. {
  1055. QDCT_ZhuangLiaoStep = 1;
  1056. }
  1057. }
  1058. void QDCT_SL_Step(void)
  1059. {
  1060. if(QDCT_SongLiaoStep == 1)
  1061. {
  1062. if(SongLaTouOkFlg)
  1063. {
  1064. QDCT_SongLiaoStep = 0;
  1065. }
  1066. else
  1067. {
  1068. QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1069. QDCT_SongLiaoStep = 2;
  1070. }
  1071. }
  1072. else if(QDCT_SongLiaoStep == 2)
  1073. {
  1074. if(QDCT_HSL_ORIGIN_IN && !QDCT_HSL_LIMIT_IN)
  1075. {
  1076. QDCT_SL_OUT = 1;
  1077. QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1078. QDCT_SongLiaoStep = 3;
  1079. }
  1080. else if(dwTickCount >= QDCT_SL_Delay)
  1081. QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
  1082. }
  1083. else if(QDCT_SongLiaoStep == 3)
  1084. {
  1085. if(QDCT_SL_LIMIT_IN)
  1086. {
  1087. QDCT_SL_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
  1088. QDCT_SongLiaoStep = 4;
  1089. }
  1090. else if(dwTickCount >= QDCT_SL_Delay)
  1091. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  1092. }
  1093. else if((QDCT_SongLiaoStep == 4) && (dwTickCount >= QDCT_SL_Delay))
  1094. {
  1095. QDCT_SL_OUT = 0;
  1096. QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1097. QDCT_SongLiaoStep = 5;
  1098. }
  1099. else if(QDCT_SongLiaoStep == 5)
  1100. {
  1101. if(!QDCT_SL_LIMIT_IN)
  1102. {
  1103. QDCT_SongLiaoStep = 0;
  1104. QDCT_SL_Delay = dwTickCount;
  1105. SongLaTouOkFlg = 1;
  1106. }
  1107. else if(dwTickCount >= QDCT_SL_Delay)
  1108. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  1109. }
  1110. }
  1111. //手动动作
  1112. void QDCT_ManualAction(void)
  1113. {
  1114. if(bRunning == 0)
  1115. {
  1116. if(bClearTotal) //切断计数清零
  1117. {
  1118. bClearTotal = 0;
  1119. ClrcToTal(QDCT_TOTAL_ADDR);
  1120. }
  1121. if(QDCT_bClerNowTotal)
  1122. {
  1123. QDCT_bClerNowTotal = 0;
  1124. cTbCnt = 0;
  1125. ClrcToTal(QDCT_NOWTOTAL_ADDR);
  1126. }
  1127. if(QDCT_bQieDuan)
  1128. {
  1129. QDCT_bQieDuan = 0;
  1130. if(QDCT_XiaQieStep == 0)QDCT_XiaQieStep = 1;
  1131. }
  1132. if(QDCT_bQianDianDW)
  1133. {
  1134. QDCT_bQianDianDW = 0;
  1135. if((QDCT_MotorStep == 0) && !QDCT_SQ_LIMIT_IN)
  1136. {
  1137. QDCT_MotorStep = 61;
  1138. dwZipCnt = 0;
  1139. }
  1140. else if(QDCT_SQ_LIMIT_IN)
  1141. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  1142. }
  1143. if(QDCT_bManXM)
  1144. {
  1145. QDCT_bManXM = 0;
  1146. QDCT_XM_OUT = ~QDCT_XM_OUT;
  1147. if(QDCT_HSL_OUT == 1)QDCT_XM_OUT = 0;
  1148. }
  1149. if(QDCT_bManSQ)
  1150. {
  1151. QDCT_bManSQ = 0;
  1152. QDCT_SQ_OUT = ~QDCT_SQ_OUT;
  1153. if(QDCT_GO_LIMIT_IN) QDCT_SQ_OUT = 0;
  1154. }
  1155. if(QDCT_bManJD)
  1156. {
  1157. QDCT_bManJD = 0;
  1158. QDCT_JD_OUT = ~QDCT_JD_OUT;
  1159. }
  1160. if(QDCT_bManSL)
  1161. {
  1162. QDCT_bManSL = 0;
  1163. QDCT_SL_OUT = ~QDCT_SL_OUT;
  1164. if(!QDCT_HSL_ORIGIN_IN)QDCT_SL_OUT = 0;
  1165. }
  1166. if(QDCT_bManHSL)
  1167. {
  1168. QDCT_bManHSL = 0;
  1169. QDCT_HSL_OUT = ~QDCT_HSL_OUT;
  1170. if(QDCT_JLT_IN)QDCT_JLT_OUT = 1;
  1171. if(QDCT_XM_OUT || QDCT_SL_LIMIT_IN)QDCT_HSL_OUT = 0;
  1172. }
  1173. if(QDCT_bManZD)
  1174. {
  1175. QDCT_bManZD = 0;
  1176. QDCT_ZDP_OUT = ~QDCT_ZDP_OUT;
  1177. }
  1178. if(QDCT_bManKL)
  1179. {
  1180. QDCT_bManKL = 0;
  1181. QDCT_KL_OUT = ~QDCT_KL_OUT;
  1182. }
  1183. if(QDCT_bManJLT)
  1184. {
  1185. QDCT_bManJLT = 0;
  1186. QDCT_JLT_OUT = ~QDCT_JLT_OUT;
  1187. }
  1188. if(QDCT_bManYD)
  1189. {
  1190. QDCT_bManYD = 0;
  1191. QDCT_YD_OUT = ~QDCT_YD_OUT;
  1192. }
  1193. if(QDCT_bManTL)
  1194. {
  1195. QDCT_bManTL = 0;
  1196. if(QDCT_TL_OUT)
  1197. {
  1198. QDCT_TL_OUT = 0;
  1199. QDCT_YD_OUT = 0;
  1200. }
  1201. else
  1202. {
  1203. if(QDCT_TuiLianStep==0)QDCT_TuiLianStep=1;
  1204. }
  1205. }
  1206. if(QDCT_bZhuangLiao)
  1207. {
  1208. QDCT_bZhuangLiao = 0;
  1209. if(QDCT_ZhuangLiaoStep == 0)
  1210. {
  1211. TryCnt = 0;
  1212. SongLaTouOkFlg = 1;
  1213. QDCT_ZhuangLiaoStep = 1;
  1214. FirstStartFlg = 0;
  1215. }
  1216. }
  1217. if(QDCT_bSongLT)
  1218. {
  1219. QDCT_bSongLT = 0;
  1220. if(QDCT_SongLiaoStep == 0)
  1221. {
  1222. QDCT_SongLiaoStep = 1;
  1223. SongLaTouOkFlg = 0;
  1224. }
  1225. }
  1226. if(QDCT_bChuanLT)
  1227. {
  1228. QDCT_bChuanLT = 0;
  1229. if(!QDCT_BACK_LIMIT_IN)
  1230. {
  1231. if(QDCT_MotorStep == 0)QDCT_MotorStep = 30;
  1232. }
  1233. }
  1234. if(QDCT_bManSZ)
  1235. {
  1236. QDCT_bManSZ = 0;
  1237. QDCT_SZ_OUT = ~QDCT_SZ_OUT;
  1238. }
  1239. //电机控制
  1240. if(QDCT_bMotorGo && !QDCT_GO_LIMIT_IN && !QDCT_SQ_LIMIT_IN)
  1241. {
  1242. QDCT_JD_OUT = 0;
  1243. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  1244. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_P, 5,5,10,10);
  1245. }
  1246. else if(QDCT_bMotorGo && QDCT_SQ_LIMIT_IN)
  1247. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  1248. if(QDCT_bMotorBack && !QDCT_BACK_LIMIT_IN)
  1249. {
  1250. QDCT_JD_OUT = 0;
  1251. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  1252. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_N, 5,5,10,10);
  1253. }
  1254. if(!QDCT_bMotorGo && !QDCT_bMotorBack && (QDCT_MotorStep == 0))
  1255. {
  1256. if(X_DRV)AxisDecStop(X_AXIS);
  1257. }
  1258. if(QDCT_GO_LIMIT_IN && (QDCT_MotorStep == 0) && !QDCT_bMotorBack &&(QDCT_AutoStep == 0))
  1259. {
  1260. if(X_DRV)AxisEgmStop(X_AXIS);
  1261. }
  1262. }
  1263. if(QDCT_PARAM_ZD_ENABLE)QDCT_ZDP_OUT = 1;
  1264. else QDCT_ZDP_OUT = 0;
  1265. }
  1266. #endif