PWCQueduanChuantou.c 41 KB

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