JCWYChuanTouJi.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012
  1. #include "global.h"
  2. #if 0
  3. void ChuanTou_AlarmProtect(void);
  4. void ChuanTou_ManualAction(void);
  5. void ChuanTou_AutoAction(void);
  6. void ChuanTou_StepCheckStart(void);
  7. void ChuanTou_Motor(void);
  8. void ChuanTou_SongLiaoAction(void);
  9. static unsigned cSongLiaoOk = 0;
  10. void CT_SetAlarmCode(unsigned alarm_code)
  11. {
  12. SetAlarmCode(CT_ALARM_ADDR,alarm_code);
  13. bAlarmStop = 1;
  14. }
  15. void ChuanTou_InitAction(void)
  16. {
  17. float length_buff,pulse_buff;
  18. save_limit_pos = CT_SAVE_POS;
  19. axis_x->speed_unit = 500;
  20. length_buff = CT_PARAM_CYCLE_LENGTH;
  21. pulse_buff = CT_PARAM_CYCLE_PULSE;
  22. XGearRatio = pulse_buff/length_buff;
  23. }
  24. void ChuanTou_Action(void)
  25. {
  26. ChuanTou_AlarmProtect();
  27. ChuanTou_Motor();
  28. ChuanTou_ManualAction();
  29. ChuanTou_AutoAction();
  30. ChuanTou_SongLiaoAction();
  31. ChuanTou_StepCheckStart(); // 调用脚踏开关检测程序
  32. }
  33. //手动动作
  34. void ChuanTou_ManualAction(void)
  35. {
  36. if(bRunning == 0)
  37. {
  38. if(bClearTotal) //切断计数清零
  39. {
  40. bClearTotal = 0;
  41. ClrcToTal(CT_TOTAL_ADDR);
  42. }
  43. if(CT_bGZ)
  44. {
  45. CT_bGZ = 0;
  46. CT_GZ_VAVLE = ~CT_GZ_VAVLE;
  47. }
  48. if(CT_bHL)
  49. {
  50. CT_bHL = 0;
  51. CT_HL_VAVLE = ~CT_HL_VAVLE;
  52. }
  53. if(CT_bJL)
  54. {
  55. CT_bJL = 0;
  56. CT_JL_VAVLE = ~CT_JL_VAVLE;
  57. }
  58. if(CT_bSL)
  59. {
  60. CT_bSL = 0;
  61. CT_SL_VAVEL = ~CT_SL_VAVEL;
  62. }
  63. if(CT_bHSL)
  64. {
  65. CT_bHSL = 0;
  66. CT_HSL_VAVLE = ~CT_HSL_VAVLE;
  67. }
  68. if(CT_bZL)
  69. {
  70. CT_bZL = 0;
  71. }
  72. if(CT_bGJ)
  73. {
  74. CT_bGJ = 0;
  75. CT_GJ_VAVLE = ~CT_GJ_VAVLE;
  76. }
  77. if(CT_bFZ)
  78. {
  79. CT_bFZ = 0;
  80. CT_FD_VAVLE = ~CT_FD_VAVLE;
  81. }
  82. if(CT_bCT_XM)
  83. {
  84. CT_bCT_XM = 0;
  85. }
  86. if(CT_bDW)
  87. {
  88. CT_bDW = 0;
  89. }
  90. if(CT_bAuto_ZL)
  91. {
  92. CT_bAuto_ZL = 0;
  93. }
  94. if(CT_bHM)
  95. {
  96. CT_bHM = 0;
  97. }
  98. }
  99. }
  100. void ChuanTou_AlarmProtect(void)
  101. {
  102. }
  103. void ChuanTou_HeMu_Action(void)
  104. {
  105. switch (CT_HeMuStep)
  106. {
  107. case 1:
  108. CT_HeMuStep = 2;
  109. break;
  110. case 2:
  111. CT_HeMuStep = 3;
  112. break;
  113. case 3:
  114. CT_HeMuStep = 4;
  115. break;
  116. }
  117. }
  118. //送料
  119. void ChuanTou_SongLiaoAction(void)
  120. {
  121. switch(CT_SL_Step)
  122. {
  123. case 1:
  124. {
  125. if(cSongLiaoOk)
  126. {
  127. CT_SL_Step = 0;
  128. }
  129. else
  130. {
  131. if(CT_HSL_ORIGIN_IN && CT_SONG_LIAO_ORIGIN_IN)
  132. {
  133. CT_SL_VAVEL = 1;
  134. CT_SL_Delay = dwTickCount + VAVLE_ALARM_TIME;
  135. CT_SL_Step = 2;
  136. }
  137. }
  138. }break;
  139. case 2:
  140. {
  141. if(CT_SONG_LIAO_LIMIT_IN)
  142. {
  143. CT_SL_Step = 3;
  144. CT_SL_Delay = dwTickCount + CT_PARAM_SL_DELAY_BACK;
  145. }
  146. else if(dwTickCount >= CT_SL_Delay)
  147. {
  148. CT_SetAlarmCode(CT_SL_LIMIT_ALARM);
  149. }
  150. }break;
  151. case 3:
  152. {
  153. if(dwTickCount >= CT_SL_Delay)
  154. {
  155. CT_SL_VAVEL = 0;
  156. CT_SL_Delay = dwTickCount + VAVLE_ALARM_TIME;
  157. CT_SL_Step = 4;
  158. }
  159. }break;
  160. case 4:
  161. {
  162. if(CT_SONG_LIAO_ORIGIN_IN)
  163. {
  164. cSongLiaoOk = 1;
  165. CT_SL_Step = 0;
  166. }
  167. else if(dwTickCount >= CT_SL_Delay)
  168. {
  169. CT_SetAlarmCode(CT_SL_ORIGIN_ALARM);
  170. }
  171. }
  172. break;
  173. }
  174. }
  175. //横送料
  176. void ChuanTou_HengSongLiao_Action(void)
  177. {
  178. switch(CT_HSL_Step)
  179. {
  180. case 1:
  181. {
  182. if(CT_SONG_LIAO_ORIGIN_IN && CT_HSL_ORIGIN_IN && CT_XIA_MU_IN && cSongLiaoOk)
  183. {
  184. CT_GJ_VAVLE = 0;
  185. CT_HSL_Step = 2;
  186. }
  187. else if(!bRunning)
  188. {
  189. CT_HSL_Step = 0;
  190. }
  191. }
  192. break;
  193. case 2:
  194. {
  195. CT_HSL_VAVLE = 1;
  196. cSongLiaoOk = 0;
  197. CT_HSL_Delay = dwTickCount + VAVLE_ALARM_TIME;
  198. CT_HSL_Step = 3;
  199. }
  200. break;
  201. case 3:
  202. {
  203. if(CT_HSL_LIMIT_IN)
  204. {
  205. CT_ZL_XM_VAVLE = 1;
  206. CT_HSL_Delay = dwTickCount + VAVLE_ALARM_TIME;
  207. CT_HSL_Step = 4;
  208. }
  209. else if(dwTickCount >= CT_HSL_Delay)
  210. {
  211. CT_SetAlarmCode(CT_HSL_LIMIT_ALARM);
  212. }
  213. }
  214. break;
  215. case 4:
  216. {
  217. if(CT_ZHUANG_LIAO_IN)
  218. {
  219. CT_HSL_Delay = dwTickCount + CT_PARAM_LOCK_TIME;
  220. CT_HSL_Step = 5;
  221. }
  222. else if(dwTickCount >= CT_HSL_Delay)
  223. {
  224. CT_SetAlarmCode(CT_ZL_LIMIT_ALARM);
  225. }
  226. }
  227. break;
  228. case 5:
  229. if(dwTickCount >= CT_HSL_Delay)
  230. {
  231. CT_GJ_VAVLE = 1;
  232. CT_HSL_Delay = dwTickCount + CT_PARAM_GJ_TIME;
  233. CT_HSL_Step = 6;
  234. }
  235. break;
  236. case 6:
  237. CT_HSL_VAVLE = 0;
  238. CT_HSL_Delay = dwTickCount + VAVLE_ALARM_TIME;
  239. CT_HSL_Step = 7;
  240. break;
  241. case 7:
  242. if(CT_HSL_ORIGIN_IN)
  243. {
  244. CT_ZL_XM_VAVLE = 0;
  245. CT_HSL_Step = 8;
  246. }
  247. else if(dwTickCount >= CT_HSL_Delay)
  248. {
  249. CT_SetAlarmCode(CT_HSL_ORIGIN_ALARM);
  250. }
  251. break;
  252. case 8:
  253. CT_HSL_Step = 0;
  254. CT_SL_Step = 1;
  255. break;
  256. }
  257. }
  258. void ChuanTou_AutoAction(void)
  259. {
  260. if(bRunning)
  261. {
  262. switch(CT_AutoStep)
  263. {
  264. case 1:
  265. if(dwTickCount >= CT_AutoDelay)
  266. {
  267. CT_AutoStep = 2;
  268. if(CT_MotorStep == 0)
  269. {
  270. CT_MotorStep = 61; //前点定位
  271. // else CT_MotorStep = 1;
  272. }
  273. }
  274. break;
  275. case 2:
  276. if(CT_MotorStep == 0)
  277. {
  278. if(CT_PARAM_DC_MODE == 0)
  279. CT_MotorStep = 20; //后退到位
  280. else
  281. CT_MotorStep = 30;
  282. CT_AutoStep = 3;
  283. }
  284. break;
  285. case 3:
  286. if(CT_MotorStep == 0)
  287. {
  288. if(CT_XiaQieStep == 0)CT_XiaQieStep = 1;
  289. CT_AutoStep = 4;
  290. }
  291. break;
  292. case 4:
  293. break;
  294. case 5:
  295. if(CT_MotorStep == 0)
  296. {
  297. cZipCnt++;
  298. CT_PARAM_NOW_CNT++;
  299. cTableCnt++;
  300. AddToTal(CT_TOTAL_ADDR);
  301. CalProSP(CT_PROSPEED_ADDR);
  302. if(cTableCnt >= CT_PARAM_TABLE_NUM)
  303. {
  304. cTableCnt = 0;
  305. CT_TABLE_VAVLE = 1;
  306. CT_TBDelay = dwTickCount + CT_PARAM_TB_TIME;
  307. }
  308. if((GetTotal(CT_TOTAL_ADDR) >= CT_PARAM_SET_TOTAL) || SingOneFlg)
  309. {
  310. bRunning = 0;
  311. CT_AutoStep = 0;
  312. SingOneFlg = 0;
  313. if(GetTotal(CT_TOTAL_ADDR) >= CT_PARAM_SET_TOTAL) CT_SetAlarmCode(CT_TOTAL_ALARM);
  314. }
  315. else
  316. {
  317. CT_AutoStep = 1;
  318. if(CT_PARAM_NOW_CNT >= CT_PARAM_ZHA_SHU)
  319. {
  320. CT_AutoDelay = dwTickCount + CT_PARAM_ZS_STOP_TIME + 50;
  321. CT_PARAM_NOW_CNT = 0;
  322. }
  323. else
  324. CT_AutoDelay = dwTickCount + CT_PARAM_CYCLE_DELAY;
  325. }
  326. }
  327. break;
  328. }
  329. }
  330. }
  331. void ChuanTou_StepCheckStart(void)
  332. {
  333. // 启动
  334. if((START_IN_UP) || bStart || CT_bSingle)
  335. {
  336. bStart = 0;
  337. if(!bRunning && (CT_AutoStep == 0))
  338. {
  339. if(!CT_SHANG_MU_ORIGIN_IN)CT_SetAlarmCode(CT_SM_YUANWEI);
  340. else if(CT_XIA_MU_LIMIT_IN)CT_SetAlarmCode(CT_XM_DAOWEI);
  341. else if(GetAlarmCode(CT_ALARM_ADDR) != 0);
  342. else if(GetTotal(CT_TOTAL_ADDR) >= CT_PARAM_SET_TOTAL) CT_SetAlarmCode(CT_TOTAL_ALARM);
  343. else if(CT_BL_VAVLE)CT_SetAlarmCode(CT_BL_ALARM);
  344. else if(CT_SM_VAVLE)CT_SetAlarmCode(CT_SM_ALARM);
  345. else
  346. {
  347. bRunning = 1;
  348. CT_AutoStep = 1;
  349. if(CT_bSingle) SingOneFlg= 1;
  350. cZhuangLiaoOk = 0;
  351. dwZipCnt = 0;
  352. }
  353. }
  354. CT_bSingle = 0;
  355. }
  356. //停止
  357. if(STOP_IN_UP || bStop)
  358. {
  359. bStop = 0;
  360. user_datas[127] = 0;
  361. if(bRunning)
  362. {
  363. bRunning = 0;
  364. CT_AutoStep = 0;
  365. CT_MotorStep = 0;
  366. CT_AutoDelay = dwTickCount;
  367. CT_MotorDelay = dwTickCount;
  368. SingOneFlg = 0;
  369. if(GetAlarmCode(CT_ALARM_ADDR) != 0)SetAlarmCode(CT_ALARM_ADDR,0);
  370. }
  371. else
  372. {
  373. bRunning = 0;
  374. CT_AutoStep = 0;
  375. CT_MotorStep = 0;
  376. CT_AutoDelay = dwTickCount;
  377. CT_MotorDelay = dwTickCount;
  378. SingOneFlg = 0;
  379. AxisDecStop(X_AXIS);
  380. if(GetAlarmCode(CT_ALARM_ADDR) != 0)SetAlarmCode(CT_ALARM_ADDR,0);
  381. }
  382. }
  383. if(bAlarmStop)
  384. {
  385. bAlarmStop = 0;
  386. bRunning = 0;
  387. CT_AutoStep = 0;
  388. CT_MotorStep = 0;
  389. CT_AutoDelay = dwTickCount;
  390. CT_MotorDelay = dwTickCount;
  391. SingOneFlg = 0;
  392. AxisDecStop(X_AXIS);
  393. }
  394. }
  395. //电机动作
  396. void ChuanTou_Motor(void) //
  397. {
  398. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff;
  399. user_datas[124]= CT_MotorStep;
  400. // user_datas[125]= go_length_buff;
  401. // user_datas[123] = length_buff;
  402. user_datas[127] = cRealPos;
  403. user_datas[126] = go_buff - cRealPos;
  404. user_datas[121] = CT_PARAM_GOUZHEN_LENGTH;
  405. if(CT_GUO_LIAN_IN_DW)user_datas[122]++;
  406. switch(CT_MotorStep)
  407. {
  408. case 0:
  409. break;
  410. case 1: // 前点定位数控模式
  411. if(CT_SZ_OUT)
  412. {
  413. CT_SZ_OUT = 0;
  414. CT_MotorDelay = dwTickCount + 50;
  415. }
  416. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
  417. if((CT_TuiLianStep == 0) && !CT_TL_VAVLE && !CT_PARAM_TL_MODE)CT_TuiLianStep = 1;
  418. CT_MotorStep = 2;
  419. break;
  420. case 2:
  421. if(dwTickCount >= CT_MotorDelay)
  422. {
  423. if(CT_QIAN_LIMIT_IN)
  424. {
  425. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_P;
  426. MV_Set_Acc_CPU(X_AXIS, 10);
  427. AxisMovePos(X_AXIS,CT_PARAM_GO_HIGH_SPEED,CT_PARAM_ON_BACK_LENGTH);
  428. CT_MotorDelay = dwTickCount + 1000;
  429. }
  430. CT_MotorStep = 3;
  431. CT_JD_VAVEL = 0;
  432. }
  433. break;
  434. case 3:
  435. if(!X_DRV && !CT_QIAN_LIMIT_IN && (dwTickCount >= CT_MotorDelay))
  436. {
  437. if(cZipCnt == 0)
  438. {
  439. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
  440. AxisContinueMove(X_AXIS,CT_PARAM_FIRST_SPEED,CT_DIR_P); //第一条走低速
  441. }
  442. else
  443. {
  444. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
  445. AxisMoveTwoPos(X_AXIS,CT_PARAM_GO_HIGH_SPEED,(length_buff - CT_PARAM_Go_LOW_SPEED_LENGTH + CT_PARAM_BACK_LENGTH +CT_PARAM_SJZ_LENGTH),CT_PARAM_GO_LOW_SPEED,0xFFFFFF,CT_DIR_P);//第二条开始走两段速
  446. }
  447. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  448. CT_MotorStep = 4;
  449. }
  450. break;
  451. case 4:
  452. if(CT_QIAN_LIMIT_IN_UP)
  453. {
  454. AxisEgmStop(X_AXIS);
  455. CT_MotorStep = 5;
  456. }
  457. else if(dwTickCount >= CT_MotorDelay)CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
  458. else if(CT_JD_ORIGIN_IN)CT_SetAlarmCode(CT_JD_ORIGIN_ALARM);
  459. break;
  460. case 5:
  461. if(!X_DRV)
  462. {
  463. CT_MotorDelay = dwTickCount;
  464. CT_MotorStep = 6;
  465. }
  466. break;
  467. case 6:
  468. if((dwTickCount >= CT_MotorDelay) && (CT_TuiLianStep == 0))
  469. {
  470. if(bRunning)
  471. {
  472. CT_JD_VAVEL = 1;
  473. }
  474. CT_MotorStep = 7;
  475. CT_MotorDelay = dwTickCount + 100;
  476. }
  477. break;
  478. case 7:
  479. if(dwTickCount >= CT_MotorDelay)
  480. {
  481. CT_YBD_VAVLE = 0;
  482. CT_TL_VAVLE = 0;
  483. CT_MotorStep = 0;
  484. }
  485. break;
  486. case 20:// 后退使用电机定长
  487. CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_BACK;
  488. CT_MotorStep = 21;
  489. break;
  490. case 21:
  491. if(dwTickCount >= CT_MotorDelay)
  492. {
  493. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
  494. AxisMovePos(X_AXIS,CT_PARAM_BACK_SPEED,-CT_PARAM_ZIPPER_LENGTH);
  495. CT_MotorStep = 22;
  496. }
  497. break;
  498. case 22:
  499. if(!X_DRV)
  500. {
  501. CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_FZ;
  502. CT_MotorStep = 23;
  503. }
  504. break;
  505. case 23:
  506. if(dwTickCount >= CT_MotorDelay)
  507. {
  508. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_P;
  509. AxisMovePos(X_AXIS,CT_PARAM_GO_LOW_SPEED,CT_PARAM_FZ_LENGTH);
  510. CT_MotorStep = 24;
  511. }
  512. break;
  513. case 24:
  514. if(!X_DRV)
  515. {
  516. CT_MotorStep = 0;
  517. CT_MotorDelay = dwTickCount;
  518. }
  519. break;
  520. case 30:
  521. CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_BACK;
  522. CT_MotorStep = 31;
  523. if(CT_PARAM_BL_ENABLE)CT_BinLianStep = 1;
  524. break;
  525. case 31: // 后退使用钩针定长
  526. if(dwTickCount >= CT_MotorDelay)
  527. {
  528. save_buff = cRealPos;
  529. back_buff = cRealPos;
  530. SetAccTime(X_AXIS,5);
  531. SetDecTime(X_AXIS,5);
  532. if(CT_PARAM_DEC_MODE == 0)
  533. {
  534. if(CT_PARAM_BACK_MODE)
  535. {
  536. if(cZipCnt < 2)
  537. {
  538. AxisContinueMove(X_AXIS,CT_PARAM_FIRST_SPEED,CT_DIR_P);
  539. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  540. CT_MotorStep = 32;
  541. }
  542. else
  543. {
  544. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
  545. AxisContinueMove(X_AXIS,CT_PARAM_BACK_SPEED,CT_DIR_P);
  546. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  547. CT_MotorStep = 32;
  548. }
  549. }
  550. else
  551. {
  552. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
  553. AxisContinueMove(X_AXIS,CT_PARAM_BACK_SPEED,CT_DIR_P);
  554. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  555. CT_MotorStep = 32;
  556. }
  557. }
  558. else
  559. {
  560. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
  561. if(cZipCnt < 2)
  562. {
  563. CT_XHG_VAVLE = 0;
  564. AxisContinueMove(X_AXIS,CT_PARAM_FIRST_SPEED,CT_DIR_P);
  565. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  566. CT_MotorStep = 32;
  567. }
  568. else
  569. {
  570. gouzhen_buff = cRealPos;
  571. CT_XHG_VAVLE = 1;
  572. //AxisMoveTwoPos(X_AXIS,CT_PARAM_BACK_SPEED,(length_buff - CT_PARAM_Back_LOW_SPEED_LENGTH),CT_PARAM_GO_LOW_SPEED,CT_PARAM_Back_LOW_SPEED_LENGTH,CT_DIR_N);
  573. MV_Set_Acc_CPU(X_AXIS, 10);
  574. AxisMovePos(X_AXIS,CT_PARAM_BACK_SPEED,-length_buff);
  575. MoveChangSpeedPos(X_AXIS, CT_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,CT_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(CT_PARAM_BACK_SPEED,CT_PARAM_BACK_LOW_SPEED,10)));
  576. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  577. CT_MotorStep = 33;
  578. }
  579. // AxisContinueMove(X_AXIS,CT_PARAM_BACK_SPEED,CT_DIR_N);
  580. }
  581. }
  582. break;
  583. case 32:
  584. if(CT_PARAM_DEC_MODE)
  585. {
  586. if(cZipCnt < 2)
  587. {
  588. if(CT_GUO_LIAN_IN_UP)
  589. {
  590. checkdelay_buff = cRealPos;
  591. CT_MotorDelay = dwTickCount;
  592. if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
  593. CT_MotorStep = 33;
  594. }
  595. else if(dwTickCount >= CT_MotorDelay)
  596. {
  597. CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
  598. }
  599. }
  600. else
  601. {
  602. CT_MotorStep = 36;
  603. }
  604. }
  605. else
  606. {
  607. if(CT_PARAM_BACK_MODE)
  608. {
  609. if(cZipCnt < 2)
  610. {
  611. if(CT_GUO_LIAN_IN_UP)
  612. {
  613. checkdelay_buff = cRealPos;
  614. CT_MotorDelay = dwTickCount;
  615. if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
  616. CT_MotorStep = 33;
  617. }
  618. else if(dwTickCount >= CT_MotorDelay)
  619. {
  620. CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
  621. }
  622. }
  623. else
  624. {
  625. if((cRealPos - back_buff) > (length_buff - (CT_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(CT_PARAM_BACK_SPEED,CT_PARAM_BACK_LOW_SPEED,10)))))
  626. {
  627. if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
  628. }
  629. if(CT_GUO_LIAN_IN_UP)
  630. {
  631. checkdelay_buff = cRealPos;
  632. CT_MotorDelay = dwTickCount;
  633. if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
  634. CT_MotorStep = 33;
  635. }
  636. else if(dwTickCount >= CT_MotorDelay)
  637. {
  638. CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
  639. }
  640. }
  641. }
  642. else
  643. {
  644. if(CT_GUO_LIAN_IN_UP)
  645. {
  646. checkdelay_buff = cRealPos;
  647. if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
  648. CT_MotorDelay = dwTickCount;
  649. CT_MotorStep = 33;
  650. }
  651. else if(dwTickCount >= CT_MotorDelay)
  652. {
  653. CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
  654. }
  655. }
  656. }
  657. break;
  658. case 33:
  659. if((cZipCnt < 2) || (CT_PARAM_DEC_MODE == 0))
  660. {
  661. if((cRealPos - checkdelay_buff) >= CT_PARAM_DELAY_CHECK)
  662. {
  663. if(CT_PARAM_GOUZHEN_LENGTH != 0)CT_GZ_VAVLE = 1;
  664. CT_MotorStep = 34;
  665. }
  666. }
  667. else
  668. {
  669. if((cRealPos - back_buff) > (length_buff - CT_PARAM_Back_LOW_SPEED_LENGTH))
  670. {
  671. if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
  672. CT_MotorStep = 34;
  673. }
  674. }
  675. break;
  676. case 34:
  677. if((cZipCnt < 2) || (CT_PARAM_DEC_MODE == 0))
  678. {
  679. if(CT_GUO_LIAN_IN_DW)
  680. {
  681. gou_zhen_buff = cRealPos;
  682. CT_MotorStep = 35;
  683. }
  684. }
  685. else
  686. {
  687. if(CT_PARAM_GOUZHEN_LENGTH != 0)
  688. {
  689. if((cRealPos - gouzhen_buff) >= (length_buff - CT_PARAM_GOUZHEN_LENGTH))
  690. {
  691. if(CT_PARAM_GOUZHEN_LENGTH != 0)CT_GZ_VAVLE = 1;
  692. CT_MotorStep = 36;
  693. }
  694. }
  695. else
  696. {
  697. CT_MotorStep = 36;
  698. }
  699. }
  700. break;
  701. case 35:
  702. if(CT_GUO_LIAN_IN_DW)
  703. {
  704. gou_zhen_buff = cRealPos;
  705. }
  706. if(CT_GUO_LIAN_IN_UP)
  707. {
  708. gou_zhen_buff = cRealPos;
  709. }
  710. if((cRealPos - gou_zhen_buff) >= CT_PARAM_MOTOR_DELAY_LENGTH)
  711. {
  712. AxisEgmStop(X_AXIS);
  713. CT_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  714. CT_MotorStep = 36;
  715. }
  716. break;
  717. case 36:
  718. if(!X_DRV && ((CT_PARAM_TIAOSHI_MODE && CT_bTS) || (CT_PARAM_TIAOSHI_MODE == 0)))
  719. {
  720. if(CT_PARAM_GOUZHEN_LENGTH == 0)CT_GZ_VAVLE = 1;
  721. if(CT_PARAM_DEC_MODE == 0)CT_GZ_VAVLE = 1;
  722. if(!CT_PARAM_TL_MODE)CT_YBD_VAVLE = 1;
  723. CT_MotorDelay = dwTickCount + CT_PARAM_TFK_DELAY;
  724. CT_MotorStep = 37;
  725. }
  726. break;
  727. case 37:
  728. if(dwTickCount >= CT_MotorDelay)
  729. {
  730. CT_TFK_VAVEL = 1;
  731. CT_MotorDelay = dwTickCount + 1000;
  732. CT_MotorStep = 38;
  733. }
  734. break;
  735. case 38:
  736. if(CT_GOUZHEN_IN && !X_DRV && ((CT_PARAM_TIAOSHI_MODE && CT_bTS) || (CT_PARAM_TIAOSHI_MODE == 0)))
  737. {
  738. if(CT_PARAM_TL_MODE)CT_YBD_VAVLE = 1;
  739. if(cZipCnt == 1)
  740. {
  741. length_buff = cRealPos - save_buff - CT_PARAM_OFFSET_LENGTH;
  742. }
  743. if(cZipCnt == 0)
  744. {
  745. go_length_buff = cRealPos - save_buff;
  746. }
  747. cTuiFangKuaiCnt = 0;
  748. CT_MotorStep = 0;
  749. }
  750. else if(dwTickCount >= CT_MotorDelay)
  751. {
  752. if(cTuiFangKuaiCnt == 0)
  753. {
  754. CT_MotorStep = 100;
  755. CT_TFK_VAVEL = 0;
  756. cTuiFangKuaiCnt++;
  757. CT_MotorDelay = dwTickCount + 1000;
  758. }
  759. else
  760. CT_SetAlarmCode(CT_GZ_ALARM);
  761. }
  762. break;
  763. case 100:
  764. if(dwTickCount >= CT_MotorDelay)
  765. {
  766. CT_MotorStep = 37;
  767. }
  768. break;
  769. case 40:
  770. if(dwTickCount >= CT_MotorDelay)
  771. {
  772. AxisMovePos(X_AXIS,CT_PARAM_CUT_BACK_SPEED,-(CT_PARAM_SJZ_LENGTH));
  773. CT_MotorStep = 41;
  774. }
  775. break;
  776. case 41:
  777. if(!X_DRV)
  778. {
  779. CT_JD_VAVEL = 0;
  780. CT_MotorDelay = dwTickCount + 5;
  781. CT_MotorStep = 42;
  782. }
  783. break;
  784. case 42:
  785. if(dwTickCount >= CT_MotorDelay)
  786. {
  787. save_buff = cRealPos;
  788. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
  789. MV_Set_Acc_CPU(X_AXIS, 10);
  790. AxisMovePos(X_AXIS,CT_PARAM_CUT_BACK_SPEED,-(CT_PARAM_BACK_LENGTH));
  791. CT_MotorStep = 44;
  792. }
  793. break;
  794. case 43: // 切断完成后拉电机动作
  795. if(((CT_PARAM_SJZ_LENGTH) <= (cRealPos - save_buff)))
  796. {
  797. CT_JD_VAVEL = 0;
  798. CT_MotorStep = 44;
  799. }
  800. else if(!X_DRV)
  801. {
  802. CT_JD_VAVEL = 0;
  803. CT_MotorStep = 44;
  804. }
  805. break;
  806. case 44: // 切断完成后拉电机动作
  807. if(!X_DRV)
  808. {
  809. CT_MotorStep = 0;
  810. CT_MotorDelay = dwTickCount;
  811. }
  812. break;
  813. case 61: // 前点定位数控模式
  814. if(CT_SZ_OUT)
  815. {
  816. CT_SZ_OUT = 0;
  817. CT_MotorDelay = dwTickCount + 50;
  818. }
  819. if(CT_PARAM_TL_MODE)
  820. {
  821. // if(CT_TuiLianStep == 0)CT_TuiLianStep = 1;
  822. }
  823. else
  824. {
  825. if((CT_TuiLianStep == 0) && !CT_TL_VAVLE)CT_TuiLianStep = 1;
  826. }
  827. CT_MotorStep = 62;
  828. break;
  829. case 62:
  830. if(dwTickCount >= CT_MotorDelay)
  831. {
  832. if(CT_QIAN_LIMIT_IN)
  833. {
  834. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
  835. MV_Set_Acc_CPU(X_AXIS, 10);
  836. AxisMovePos(X_AXIS,CT_PARAM_FIRST_SPEED,-CT_PARAM_ON_BACK_LENGTH);
  837. CT_MotorDelay = dwTickCount + 1000;
  838. }
  839. CT_MotorStep = 63;
  840. CT_JD_VAVEL = 0;
  841. }
  842. break;
  843. case 63:
  844. if(!X_DRV && !CT_QIAN_LIMIT_IN && (dwTickCount >= CT_MotorDelay))
  845. {
  846. if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_N;
  847. go_buff = cRealPos;
  848. if(cZipCnt > 0)
  849. {
  850. MoveAction_Const_Stop(X_AXIS, CT_DIR_N,CT_PARAM_GO_HIGH_SPEED);//
  851. }
  852. else
  853. {
  854. MoveAction_Const_Stop(X_AXIS, CT_DIR_N,CT_PARAM_GO_LOW_SPEED);
  855. }
  856. // MoveAction_Const_Stop(X_AXIS, CT_DIR_P,CT_PARAM_GO_HIGH_SPEED);//
  857. // AxisContinueMove(X_AXIS,CT_PARAM_GO_HIGH_SPEED,CT_DIR_P); //第一条走低速
  858. CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  859. CT_MotorStep =64;
  860. }
  861. break;
  862. case 64:
  863. if(CT_PARAM_GO_MODE)
  864. {
  865. if(cZipCnt > 0)
  866. {
  867. if((go_buff - cRealPos) > (go_length_buff - (CT_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(CT_PARAM_BACK_SPEED,CT_PARAM_BACK_LOW_SPEED,10))) + CT_PARAM_BACK_LENGTH + CT_PARAM_SJZ_LENGTH))
  868. {
  869. MoveChangSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);
  870. CT_MotorStep =65;
  871. }
  872. }
  873. else
  874. {
  875. // if(CT_QIAN_DEC_IN)
  876. {
  877. // if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);
  878. CT_MotorStep =65;
  879. }
  880. }
  881. }
  882. else
  883. {
  884. // if(CT_QIAN_DEC_IN)
  885. {
  886. // if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);
  887. CT_MotorStep =65;
  888. }
  889. }
  890. break;
  891. case 65:
  892. if(CT_QIAN_LIMIT_IN_UP)
  893. {
  894. if(CT_PARAM_DAO_MODE)
  895. {
  896. dandao_buff = cRealPos;
  897. CT_MotorStep = 70;
  898. }
  899. else
  900. {
  901. AxisEgmStop(X_AXIS);
  902. CT_MotorStep = 66;
  903. }
  904. }
  905. else if(dwTickCount >= CT_MotorDelay)CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
  906. else if(CT_JD_ORIGIN_IN)CT_SetAlarmCode(CT_JD_ORIGIN_ALARM);
  907. break;
  908. case 70:
  909. if((dandao_buff - cRealPos) >= CT_PARAM_DANDAO_MODE_LENGTH)
  910. {
  911. AxisEgmStop(X_AXIS);
  912. CT_MotorStep = 66;
  913. }
  914. break;
  915. case 66:
  916. if(!X_DRV)
  917. {
  918. CT_MotorDelay = dwTickCount;
  919. CT_MotorStep = 67;
  920. }
  921. break;
  922. case 67:
  923. if((dwTickCount >= CT_MotorDelay) && (CT_TuiLianStep == 0) && ((CT_PARAM_TIAOSHI_MODE && CT_bTS) || (CT_PARAM_TIAOSHI_MODE == 0)) )
  924. {
  925. if(bRunning)
  926. {
  927. CT_JD_VAVEL = 1;
  928. }
  929. CT_MotorStep = 68;
  930. CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_BACK;
  931. }
  932. break;
  933. case 68:
  934. if(dwTickCount >= CT_MotorDelay)
  935. {
  936. CT_YBD_VAVLE = 0;
  937. CT_TL_VAVLE = 0;
  938. CT_MotorStep = 0;
  939. }
  940. break;
  941. }
  942. }
  943. #endif