LYQueduanChuantou.c 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365
  1. #include "global.h"
  2. #if XIN_YE_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. dwXRealPos = 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 = dwXRealPos;
  95. SetData32bits(200,save_limit_pos);
  96. }
  97. if(QDCT_PARAM_MAX_BACK_LENGTH < (dwXRealPos - 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 = dwXRealPos;
  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((dwXRealPos - 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((dwXRealPos - 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 = dwXRealPos;
  592. save_buff = dwXRealPos;
  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 = dwXRealPos;
  602. QDCT_MotorStep = 33;
  603. }
  604. break;
  605. case 33:
  606. if((dwXRealPos - 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)
  647. QDCT_SongLiaoStep = 1;
  648. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_FZ_LENGTH,1,1,10,10,0);
  649. QDCT_MotorStep = 37;
  650. }
  651. break;
  652. case 37:
  653. if(!X_DRV)
  654. {
  655. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  656. QDCT_MotorStep = 0;
  657. }
  658. break;
  659. case 40:
  660. // if(dwTickCount >= QDCT_MotorDelay)
  661. {
  662. jz_buff = dwXRealPos;
  663. if(QDCT_PARAM_SJZ_LENGTH == 0)
  664. {
  665. QDCT_JD_OUT = 0;
  666. }
  667. QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
  668. QDCT_MotorStep = 41;
  669. }
  670. break;
  671. case 41:
  672. if(QDCT_JD_OUT && (dwTickCount >= QDCT_MotorDelay))
  673. {
  674. AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,-(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),1,1,10,10,0);
  675. QDCT_MotorStep = 42;
  676. }
  677. break;
  678. case 42: // 切断完成后拉电机动作
  679. if(((QDCT_PARAM_SJZ_LENGTH) <= (dwXRealPos - jz_buff)))
  680. {
  681. QDCT_JD_OUT = 0;
  682. QDCT_MotorStep = 43;
  683. }
  684. else if(!X_DRV)
  685. {
  686. QDCT_JD_OUT = 0;
  687. QDCT_MotorStep = 43;
  688. }
  689. break;
  690. case 43: // 切断完成后拉电机动作
  691. if(!X_DRV)
  692. {
  693. QDCT_MotorStep = 0;
  694. QDCT_MotorDelay = dwTickCount;
  695. }
  696. break;
  697. case 61: // 前点定位数控模式
  698. if(QDCT_JD_OUT || (QDCT_SZ_OUT == QDCT_MOTOR_DISEN))
  699. {
  700. QDCT_JD_OUT = 0;
  701. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  702. QDCT_MotorDelay = dwTickCount + 50;
  703. }
  704. if((QDCT_TuiLianStep == 0) && !QDCT_TL_OUT)QDCT_TuiLianStep = 1;
  705. QDCT_MotorStep = 62;
  706. break;
  707. case 62:
  708. if(dwTickCount >= QDCT_MotorDelay)
  709. {
  710. if(QDCT_GO_LIMIT_IN || QDCT_GO_DEC_IN)
  711. {
  712. AxisMovePos(X_AXIS,20,-QDCT_PARAM_ON_BACK_LENGTH);
  713. QDCT_MotorDelay = dwTickCount + 1000;
  714. }
  715. QDCT_MotorStep = 63;
  716. QDCT_JD_OUT = 0;
  717. }
  718. break;
  719. case 63:
  720. if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay))
  721. {
  722. go_buff = dwXRealPos;
  723. if(dwZipCnt > 0)
  724. {
  725. MoveAction_Const_Stop_AccDec(X_AXIS,QDCT_DIR_P,QDCT_PARAM_JJGO_SPEED,1,5,10);
  726. }
  727. else
  728. {
  729. MoveAction_Const_Stop_AccDec(X_AXIS,QDCT_DIR_P,QDCT_PARAM_FIRSTSPEED,1,5,10);
  730. }
  731. QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  732. QDCT_MotorStep = 64;
  733. }
  734. break;
  735. case 64:
  736. if(dwZipCnt > 0)
  737. {
  738. if(((go_buff - dwXRealPos) > ((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)
  739. {
  740. MoveChangSpeed(X_AXIS,QDCT_PARAM_GO_LOWSPEED);
  741. QDCT_MotorStep = 66;
  742. QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  743. }
  744. else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  745. }
  746. else
  747. {
  748. QDCT_MotorStep = 66;
  749. }
  750. break;
  751. case 65:
  752. if(QDCT_GO_LIMIT_IN_UP)
  753. {
  754. AxisEgmStop(X_AXIS);
  755. QDCT_MotorStep = 66;
  756. }
  757. else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
  758. break;
  759. case 66:
  760. if(!X_DRV)
  761. {
  762. QDCT_MotorDelay = dwTickCount;
  763. QDCT_MotorStep = 67;
  764. }
  765. break;
  766. case 67:
  767. if(dwTickCount >= QDCT_MotorDelay)
  768. {
  769. if(QDCT_JiaLianStep == 0)
  770. {
  771. QDCT_JiaLianStep = 1;
  772. QDCT_MotorStep = 68;
  773. }
  774. }
  775. break;
  776. case 68:
  777. if(QDCT_JiaLianStep == 0)
  778. {
  779. QDCT_MotorStep = 0;
  780. }
  781. break;
  782. case 100:
  783. if((dwTickCount >= QDCT_MotorDelay) && !X_DRV)
  784. {
  785. AxisMovePos(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-(QDCT_PARAM_SET_ZIPPER_LENGTH));
  786. QDCT_MotorStep = 101;
  787. QDCT_MotorDelay = dwTickCount + 1000;
  788. }
  789. break;
  790. case 101:
  791. if((dwTickCount >= QDCT_MotorDelay) && !X_DRV)
  792. {
  793. QDCT_MotorStep = 102;
  794. }
  795. break;
  796. case 102:
  797. AxisMovePos(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH));
  798. QDCT_MotorStep = 100;
  799. QDCT_MotorDelay = dwTickCount + 1000;
  800. break;
  801. }
  802. }
  803. //切断动作
  804. void QDCT_XiaQieAction(void)
  805. {
  806. user_datas[121] = QDCT_AutoStep;
  807. user_datas[122] = QDCT_ZhuangLiaoStep;
  808. user_datas[123] = QDCT_TuiLianStep;
  809. user_datas[124] = QDCT_MotorStep;
  810. user_datas[125] = QDCT_JiaLianStep;
  811. // user_datas[126] = QDCT_XiaQieStep;
  812. // user_datas[127] = PosToPulse(X_AXIS,QDCT_PARAM_PUTIN_SPEED_LENGTH);
  813. if(QDCT_XiaQieStep == 1)
  814. {
  815. if(QDCT_GO_LIMIT_IN)
  816. {
  817. QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
  818. }
  819. else if(!QDCT_TL_ORIGIN_IN)
  820. QDCT_SetAlarmCode(QDCT_TL_ORIGIN_ALARM);
  821. else
  822. {
  823. QDCT_XiaQieStep = 2;
  824. }
  825. }
  826. else if(QDCT_XiaQieStep == 2)
  827. {
  828. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUT_DELAY;
  829. QDCT_XiaQieStep = 3;
  830. }
  831. else if((QDCT_XiaQieStep == 3) && (dwTickCount >= QDCT_XiaQieDelay))
  832. {
  833. QDCT_SQ_OUT = 1;
  834. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  835. QDCT_XiaQieStep = 4;
  836. }
  837. else if(QDCT_XiaQieStep == 4)
  838. {
  839. if(QDCT_SQ_LIMIT_IN)
  840. {
  841. QDCT_XiaQieStep = 5;
  842. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_DELAY_CS;
  843. }
  844. else if(dwTickCount >= QDCT_XiaQieDelay)
  845. {
  846. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  847. }
  848. }
  849. else if((QDCT_XiaQieStep == 5) && (dwTickCount >= QDCT_XiaQieDelay))
  850. {
  851. QDCT_XiaQieStep = 6;
  852. if(QDCT_PARAM_CS_ENABLE)QDCT_CS_OUT = 1;
  853. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_TIME;
  854. }
  855. else if((QDCT_XiaQieStep == 6) && (dwTickCount >= QDCT_XiaQieDelay))
  856. {
  857. QDCT_CS_OUT = 0;
  858. QDCT_XiaQieStep = 7;
  859. QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_COLD_TIME;
  860. }
  861. else if((QDCT_XiaQieStep == 7) && (dwTickCount >= QDCT_XiaQieDelay))
  862. {
  863. QDCT_SQ_OUT = 0;
  864. QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  865. QDCT_XiaQieStep = 8;
  866. }
  867. else if(QDCT_XiaQieStep == 8)
  868. {
  869. if(!QDCT_SQ_LIMIT_IN)
  870. {
  871. QDCT_XiaQieStep = 0;
  872. if(cBackFlg)
  873. {
  874. cBackFlg = 0;
  875. if(QDCT_MotorStep==0)QDCT_MotorStep = 40;
  876. }
  877. QDCT_YD_OUT = 1;
  878. }
  879. else if(dwTickCount >= QDCT_XiaQieDelay)
  880. {
  881. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  882. }
  883. }
  884. }
  885. //装拉头动作
  886. void QDCT_ZLT_Step(void)
  887. {
  888. if(QDCT_ZhuangLiaoStep == 1)
  889. {
  890. if(ZhuangLiaoOkFlg)
  891. {
  892. QDCT_ZhuangLiaoStep = 0;
  893. }
  894. else
  895. {
  896. if(FirstStartFlg && QDCT_JLT_IN)
  897. {
  898. QDCT_ZhuangLiaoStep = 7;
  899. }
  900. else
  901. {
  902. FirstStartFlg = 0;
  903. if(QDCT_SongLiaoStep == 0)
  904. {
  905. QDCT_SongLiaoStep = 1;
  906. QDCT_ZhuangLiaoStep = 2;
  907. }
  908. }
  909. }
  910. }
  911. else if(QDCT_ZhuangLiaoStep == 2)
  912. {
  913. if(QDCT_SongLiaoStep == 0)
  914. {
  915. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  916. if(QDCT_JLT_IN)QDCT_JLT_OUT = 1;
  917. QDCT_ZhuangLiaoStep = 3;
  918. }
  919. }
  920. else if(QDCT_ZhuangLiaoStep == 3)
  921. {
  922. if(QDCT_HSL_ORIGIN_IN && QDCT_XM_ORIGIN_IN && !QDCT_JLT_IN && (QDCT_XiaQieStep == 0))
  923. {
  924. QDCT_HSL_OUT = 1;
  925. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  926. QDCT_ZhuangLiaoStep = 4;
  927. }
  928. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  929. {
  930. if(!QDCT_HSL_ORIGIN_IN)
  931. QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
  932. else
  933. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  934. }
  935. }
  936. else if(QDCT_ZhuangLiaoStep == 4)
  937. {
  938. if(QDCT_HSL_LIMIT_IN)
  939. {
  940. QDCT_JLT_OUT = 0;
  941. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  942. QDCT_ZhuangLiaoStep = 5;
  943. }
  944. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  945. {
  946. QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
  947. }
  948. }
  949. else if(QDCT_ZhuangLiaoStep == 5)
  950. {
  951. if(QDCT_JLT_IN)
  952. {
  953. QDCT_ZhuangLiaoStep = 6;
  954. }
  955. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  956. {
  957. QDCT_SetAlarmCode(QDCT_JLT_ALARM);
  958. }
  959. }
  960. else if(QDCT_ZhuangLiaoStep == 6)
  961. {
  962. QDCT_HSL_OUT = 0;
  963. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  964. if(!bRunning)
  965. {
  966. QDCT_ZhuangLiaoStep = 0;
  967. SongLaTouOkFlg = 0;
  968. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  969. }
  970. else
  971. QDCT_ZhuangLiaoStep = 7;
  972. }
  973. else if(QDCT_ZhuangLiaoStep == 7)
  974. {
  975. if(!QDCT_HSL_LIMIT_IN && QDCT_GO_LIMIT_IN)
  976. {
  977. QDCT_XM_OUT = 1;
  978. if(FirstStartFlg)
  979. {
  980. FirstStartFlg = 0;
  981. }
  982. else
  983. SongLaTouOkFlg = 0;
  984. if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
  985. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  986. QDCT_ZhuangLiaoStep = 8;
  987. }
  988. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  989. {
  990. if(QDCT_HSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
  991. }
  992. }
  993. else if(QDCT_ZhuangLiaoStep == 8)
  994. {
  995. if(!QDCT_XM_ORIGIN_IN)
  996. {
  997. QDCT_ZhuangLiaoStep = 9;
  998. QDCT_ZhuangLiaoDelay = dwTickCount + 1000;
  999. }
  1000. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  1001. {
  1002. QDCT_SetAlarmCode(QDCT_XM_LIMIT_ALARM);
  1003. }
  1004. }
  1005. else if(QDCT_ZhuangLiaoStep == 9)
  1006. {
  1007. if(QDCT_LTCZ_IN)
  1008. {
  1009. QDCT_ZhuangLiaoStep = 0;
  1010. ZhuangLiaoOkFlg = 1;
  1011. TryCnt = 0;
  1012. }
  1013. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  1014. {
  1015. if(bRunning)
  1016. {
  1017. TryCnt++;
  1018. if(TryCnt > 4)
  1019. {
  1020. QDCT_SetAlarmCode(QDCT_LTCZ_ALARM);
  1021. QDCT_JLT_OUT = 1;
  1022. QDCT_XM_OUT = 0;
  1023. }
  1024. else
  1025. {
  1026. QDCT_ZhuangLiaoStep = 10;
  1027. }
  1028. }
  1029. else
  1030. {
  1031. QDCT_ZhuangLiaoStep = 0;
  1032. QDCT_ZhuangLiaoDelay = dwTickCount;
  1033. }
  1034. }
  1035. }
  1036. else if(QDCT_ZhuangLiaoStep == 10) //装拉头失败重复装几次拉头
  1037. {
  1038. QDCT_XM_OUT = 0;
  1039. QDCT_JLT_OUT = 0;
  1040. QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1041. QDCT_ZhuangLiaoStep = 11;
  1042. }
  1043. else if(QDCT_ZhuangLiaoStep == 11)
  1044. {
  1045. if(QDCT_XM_ORIGIN_IN)
  1046. {
  1047. QDCT_ZhuangLiaoStep = 12;
  1048. }
  1049. else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
  1050. {
  1051. QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
  1052. }
  1053. }
  1054. else if(QDCT_ZhuangLiaoStep == 12)
  1055. {
  1056. QDCT_ZhuangLiaoStep = 1;
  1057. }
  1058. }
  1059. void QDCT_SL_Step(void)
  1060. {
  1061. if(QDCT_SongLiaoStep == 1)
  1062. {
  1063. if(SongLaTouOkFlg)
  1064. {
  1065. QDCT_SongLiaoStep = 0;
  1066. }
  1067. else
  1068. {
  1069. QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1070. QDCT_SongLiaoStep = 2;
  1071. }
  1072. }
  1073. else if(QDCT_SongLiaoStep == 2)
  1074. {
  1075. if(QDCT_HSL_ORIGIN_IN && !QDCT_HSL_LIMIT_IN)
  1076. {
  1077. QDCT_SL_OUT = 1;
  1078. QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1079. QDCT_SongLiaoStep = 3;
  1080. }
  1081. else if(dwTickCount >= QDCT_SL_Delay)
  1082. QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
  1083. }
  1084. else if(QDCT_SongLiaoStep == 3)
  1085. {
  1086. if(QDCT_SL_LIMIT_IN)
  1087. {
  1088. QDCT_SL_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
  1089. QDCT_SongLiaoStep = 4;
  1090. }
  1091. else if(dwTickCount >= QDCT_SL_Delay)
  1092. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  1093. }
  1094. else if((QDCT_SongLiaoStep == 4) && (dwTickCount >= QDCT_SL_Delay))
  1095. {
  1096. QDCT_SL_OUT = 0;
  1097. QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
  1098. QDCT_SongLiaoStep = 5;
  1099. }
  1100. else if(QDCT_SongLiaoStep == 5)
  1101. {
  1102. if(!QDCT_SL_LIMIT_IN)
  1103. {
  1104. QDCT_SongLiaoStep = 0;
  1105. QDCT_SL_Delay = dwTickCount;
  1106. SongLaTouOkFlg = 1;
  1107. }
  1108. else if(dwTickCount >= QDCT_SL_Delay)
  1109. QDCT_SetAlarmCode(QDCT_SL_ALARM);
  1110. }
  1111. }
  1112. //手动动作
  1113. void QDCT_ManualAction(void)
  1114. {
  1115. if(bRunning == 0)
  1116. {
  1117. if(bClearTotal) //切断计数清零
  1118. {
  1119. bClearTotal = 0;
  1120. ClrcToTal(QDCT_TOTAL_ADDR);
  1121. }
  1122. if(QDCT_bClerNowTotal)
  1123. {
  1124. QDCT_bClerNowTotal = 0;
  1125. cTbCnt = 0;
  1126. ClrcToTal(QDCT_NOWTOTAL_ADDR);
  1127. }
  1128. if(QDCT_bQieDuan)
  1129. {
  1130. QDCT_bQieDuan = 0;
  1131. if(QDCT_XiaQieStep == 0)QDCT_XiaQieStep = 1;
  1132. }
  1133. if(QDCT_bQianDianDW)
  1134. {
  1135. QDCT_bQianDianDW = 0;
  1136. if((QDCT_MotorStep == 0) && !QDCT_SQ_LIMIT_IN)
  1137. {
  1138. QDCT_MotorStep = 61;
  1139. dwZipCnt = 0;
  1140. }
  1141. else if(QDCT_SQ_LIMIT_IN)
  1142. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  1143. }
  1144. if(QDCT_bManXM)
  1145. {
  1146. QDCT_bManXM = 0;
  1147. QDCT_XM_OUT = ~QDCT_XM_OUT;
  1148. if(QDCT_HSL_OUT == 1)QDCT_XM_OUT = 0;
  1149. }
  1150. if(QDCT_bManSQ)
  1151. {
  1152. QDCT_bManSQ = 0;
  1153. QDCT_SQ_OUT = ~QDCT_SQ_OUT;
  1154. if(QDCT_GO_LIMIT_IN) QDCT_SQ_OUT = 0;
  1155. }
  1156. if(QDCT_bManJD)
  1157. {
  1158. QDCT_bManJD = 0;
  1159. QDCT_JD_OUT = ~QDCT_JD_OUT;
  1160. }
  1161. if(QDCT_bManSL)
  1162. {
  1163. QDCT_bManSL = 0;
  1164. QDCT_SL_OUT = ~QDCT_SL_OUT;
  1165. if(!QDCT_HSL_ORIGIN_IN)QDCT_SL_OUT = 0;
  1166. }
  1167. if(QDCT_bManHSL)
  1168. {
  1169. QDCT_bManHSL = 0;
  1170. QDCT_HSL_OUT = ~QDCT_HSL_OUT;
  1171. if(QDCT_JLT_IN)QDCT_JLT_OUT = 1;
  1172. if(QDCT_XM_OUT || QDCT_SL_LIMIT_IN)QDCT_HSL_OUT = 0;
  1173. }
  1174. if(QDCT_bManZD)
  1175. {
  1176. QDCT_bManZD = 0;
  1177. QDCT_ZDP_OUT = ~QDCT_ZDP_OUT;
  1178. }
  1179. if(QDCT_bManKL)
  1180. {
  1181. QDCT_bManKL = 0;
  1182. QDCT_KL_OUT = ~QDCT_KL_OUT;
  1183. }
  1184. if(QDCT_bManJLT)
  1185. {
  1186. QDCT_bManJLT = 0;
  1187. QDCT_JLT_OUT = ~QDCT_JLT_OUT;
  1188. }
  1189. if(QDCT_bManYD)
  1190. {
  1191. QDCT_bManYD = 0;
  1192. QDCT_YD_OUT = ~QDCT_YD_OUT;
  1193. }
  1194. if(QDCT_bManTL)
  1195. {
  1196. QDCT_bManTL = 0;
  1197. if(QDCT_TL_OUT)
  1198. {
  1199. QDCT_TL_OUT = 0;
  1200. QDCT_YD_OUT = 0;
  1201. }
  1202. else
  1203. {
  1204. if(QDCT_TuiLianStep==0)QDCT_TuiLianStep=1;
  1205. }
  1206. }
  1207. if(QDCT_bZhuangLiao)
  1208. {
  1209. QDCT_bZhuangLiao = 0;
  1210. if(QDCT_ZhuangLiaoStep == 0)
  1211. {
  1212. TryCnt = 0;
  1213. SongLaTouOkFlg = 1;
  1214. QDCT_ZhuangLiaoStep = 1;
  1215. FirstStartFlg = 0;
  1216. }
  1217. }
  1218. if(QDCT_bSongLT)
  1219. {
  1220. QDCT_bSongLT = 0;
  1221. if(QDCT_SongLiaoStep == 0)
  1222. {
  1223. QDCT_SongLiaoStep = 1;
  1224. SongLaTouOkFlg = 0;
  1225. }
  1226. }
  1227. if(QDCT_bChuanLT)
  1228. {
  1229. QDCT_bChuanLT = 0;
  1230. if(!QDCT_BACK_LIMIT_IN)
  1231. {
  1232. if(QDCT_MotorStep == 0)QDCT_MotorStep = 30;
  1233. }
  1234. }
  1235. if(QDCT_bManSZ)
  1236. {
  1237. QDCT_bManSZ = 0;
  1238. QDCT_SZ_OUT = ~QDCT_SZ_OUT;
  1239. }
  1240. //电机控制
  1241. if(QDCT_bMotorGo && !QDCT_GO_LIMIT_IN && !QDCT_SQ_LIMIT_IN)
  1242. {
  1243. QDCT_JD_OUT = 0;
  1244. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  1245. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_P, 5,5,10,10);
  1246. }
  1247. else if(QDCT_bMotorGo && QDCT_SQ_LIMIT_IN)
  1248. QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
  1249. if(QDCT_bMotorBack && !QDCT_BACK_LIMIT_IN)
  1250. {
  1251. QDCT_JD_OUT = 0;
  1252. QDCT_SZ_OUT = QDCT_MOTOR_EN;
  1253. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_N, 5,5,10,10);
  1254. }
  1255. if(!QDCT_bMotorGo && !QDCT_bMotorBack && (QDCT_MotorStep == 0))
  1256. {
  1257. if(X_DRV)AxisDecStop(X_AXIS);
  1258. }
  1259. if(QDCT_GO_LIMIT_IN && (QDCT_MotorStep == 0) && !QDCT_bMotorBack &&(QDCT_AutoStep == 0))
  1260. {
  1261. if(X_DRV)AxisEgmStop(X_AXIS);
  1262. }
  1263. }
  1264. if(QDCT_PARAM_ZD_ENABLE)QDCT_ZDP_OUT = 1;
  1265. else QDCT_ZDP_OUT = 0;
  1266. }
  1267. #endif