JTQueduanChuantou.c 44 KB

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