JXKKQueDuanJi.c 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802
  1. #include "global.h"
  2. #if JU_XING_MACHINE ==1
  3. void KK_QueDuan_AlarmProtect(void);
  4. void KK_QueDuan_ManualAction(void);
  5. void KK_QueDuan_AutoAction(void);
  6. void KK_QueDuan_StepCheckStart(void);
  7. void KK_QueDuan_XiaQue(void);
  8. void KK_QueDuan_Motor(void);
  9. void KK_QueDuan_YuanDianAction(void);
  10. void KK_QueDuan_TuiLianAction(void);
  11. void KK_QueDuan_ExtiActionX31(void);
  12. void KK_QueDuan_BingLian(void);
  13. void KK_StopCode(void);
  14. void KKQD_TuiDaiAction(void);
  15. short *KK_length_buffer;
  16. void KKQD_SetAlarmCode(unsigned alarm_code)
  17. {
  18. SetAlarmCode(KKQD_ALARM_ADDR,alarm_code);
  19. bAlarmStop = 1;
  20. }
  21. void KK_QueDuan_ExtiActionX31(void)
  22. {
  23. KK_cCheckLianFlg = 1;
  24. }
  25. void KK_StopCode(void)
  26. {
  27. switch(KKQD_StopStep)
  28. {
  29. case 1:
  30. KKQD_StopStep=2;
  31. if(X_DRV)
  32. {
  33. AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS) * 2/3);
  34. AxisDecStop(X_AXIS);
  35. }
  36. break;
  37. case 2:
  38. if(!X_DRV || (KK_cRealPos < 10))
  39. {
  40. KKQD_StopCodeDelay=dwTickCount+350;
  41. KKQD_StopStep = 3;
  42. }
  43. break;
  44. case 3:
  45. if(dwTickCount >= KKQD_StopCodeDelay)
  46. {
  47. if(!cSTOPONE)
  48. {
  49. KKQD_StopStep=0;
  50. }
  51. else
  52. {
  53. KKQD_SetAlarmCode(KKQD_PARAM_ANQUANMEN_ALARM);
  54. KKQD_StopStep=0;
  55. cSTOPONE=0;
  56. }
  57. KKQD_SZ_OUT = 1; //电机松轴
  58. }
  59. break;
  60. }
  61. }
  62. void KK_QueDuan_InitAction(void)
  63. {
  64. float length_buff,pulse_buff;
  65. length_buff = KKQD_PARAM_CYCLE_LENGTH;
  66. pulse_buff = KKQD_PARAM_CYCLE_PULSE;
  67. XGearRatio = pulse_buff/length_buff;
  68. // KKQD_SZ_OUT = 1;
  69. KKQD_SetAlarmCode(0);
  70. SetDirReverse(X_AXIS, 1);
  71. }
  72. void KK_QueDuan_Action(void)
  73. {
  74. KK_QueDuan_AlarmProtect();
  75. KK_QueDuan_Motor();
  76. KK_QueDuan_XiaQue();
  77. KK_QueDuan_ManualAction();
  78. KK_QueDuan_TuiLianAction();
  79. KK_QueDuan_BingLian();
  80. KK_StopCode();
  81. KK_QueDuan_AutoAction();
  82. KK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
  83. }
  84. //手动动作
  85. void KK_QueDuan_ManualAction(void)
  86. {
  87. //条数或扎数达到后,台面电机转两秒之后再停机
  88. if(KK_cTABLETIME)
  89. {
  90. if(KK_cTABLETOTAL)
  91. {
  92. KK_cTABLETOTAL=0;
  93. KKQD_TABLE_VAVLE = 1;
  94. KKQD_TableDelay=dwTickCount + 2000;
  95. }
  96. if(dwTickCount >= KKQD_TableDelay)
  97. {
  98. KKQD_TABLE_VAVLE = 0;
  99. KK_cTABLETIME=0;
  100. }
  101. }
  102. if(bRunning == 0)
  103. {
  104. KK_cGoLimitEn = 0;
  105. if(KKQD_bClearTotal) //切断计数清零
  106. {
  107. KKQD_bClearTotal = 0;
  108. ClrcToTal(KKQD_TOTAL_ADDR);
  109. }
  110. if(KKQD_bClearNowTotal)
  111. {
  112. KKQD_bClearNowTotal = 0;
  113. KKQD_PARAM_NOW_CNT = 0;
  114. }
  115. if(KKQD_bXiaQie)
  116. {
  117. KKQD_bXiaQie = 0;
  118. if((KKQD_XiaQieStep == 0) && !KKQD_TL_VAVLE)
  119. {
  120. KKQD_XiaQieStep = 1;
  121. }
  122. }
  123. if(KKQD_bQianDianDW)
  124. {
  125. KKQD_bQianDianDW = 0;
  126. if(KKQD_MotorStep == 0)
  127. {
  128. KKQD_MotorStep = 61;
  129. cZipCnt = 0;
  130. }
  131. }
  132. if(KKQD_bTL)
  133. {
  134. KKQD_bTL = 0;
  135. if(KKQD_TL_VAVLE)
  136. {
  137. KKQD_TL_VAVLE = 0;
  138. }
  139. else if(!KKQD_GZ_VAVLE && !KKQD_SM_VAVLE)
  140. {
  141. KKQD_TL_VAVLE = ~KKQD_TL_VAVLE;
  142. }
  143. }
  144. if(KKQD_bECQ)
  145. {
  146. KKQD_bECQ=0;
  147. KK_cShuangDao=1;
  148. KK_cDiErLaChu=1;
  149. KK_cECQ_STOP=1;
  150. bRunning = 1;
  151. KKQD_AutoStep = 1;
  152. }
  153. // if(!Y_DRV)KKQD_bTL = 0;
  154. if(KKQD_bYD)
  155. {
  156. KKQD_bYD = 0;
  157. KKQD_YD_VAVLE = ~KKQD_YD_VAVLE;
  158. }
  159. if(KKQD_bGZ)
  160. {
  161. KKQD_bGZ = 0;
  162. KKQD_GZ_VAVLE = ~KKQD_GZ_VAVLE;
  163. }
  164. if(KKQD_bJD)
  165. {
  166. KKQD_bJD = 0;
  167. KKQD_JD_VAVLE = ~KKQD_JD_VAVLE;
  168. }
  169. if(KKQD_bXM)
  170. {
  171. KKQD_bXM = 0;
  172. KKQD_XM_VAVLE = ~KKQD_XM_VAVLE;
  173. if(!KKQD_XM_VAVLE)KKQD_GZ_VAVLE = 0;
  174. }
  175. if(KKQD_GOUZHEN_IN_UP)
  176. {
  177. KKQD_YD_VAVLE=1;
  178. }
  179. if(KKQD_bSM)
  180. {
  181. KKQD_bSM = 0;
  182. if(KKQD_SM_VAVLE)
  183. KKQD_SM_VAVLE = 0;
  184. else if(!KKQD_TL_VAVLE || !KKQD_PARAM_XM_ENABLE)
  185. KKQD_SM_VAVLE = 1;
  186. }
  187. //推方块
  188. if(KKQD_bTFK)
  189. {
  190. KKQD_bTFK = 0;
  191. KKQD_TFK_VAVLE = ~KKQD_TFK_VAVLE;
  192. }
  193. //台面电机
  194. if(KKQD_bTB)
  195. {
  196. KKQD_bTB = 0;
  197. KKQD_TABLE_VAVLE = ~KKQD_TABLE_VAVLE;
  198. }
  199. // if(KKQD_bYBD)
  200. // / {
  201. // KKQD_bYBD = 0;
  202. // KKQD_YBD_VAVLE = ~KKQD_YBD_VAVLE;
  203. // }
  204. if(KKQD_bTestCS)
  205. {
  206. KKQD_bTestCS = 0;
  207. KKQD_CS_OUT = 1;
  208. KKQD_CSDelay = dwTickCount + KKQD_PARAM_CS_TIME;
  209. }
  210. if(KKQD_bBL)//吹气
  211. {
  212. KKQD_bBL = 0;
  213. KKQD_CQ_VAVLE = ~KKQD_CQ_VAVLE;
  214. }
  215. if(KKQD_bHL) //护链,双开用
  216. {
  217. KKQD_bHL = 0;
  218. KKQD_HL_VAVLE = ~KKQD_HL_VAVLE;
  219. }
  220. if(KKQD_bYX)
  221. {
  222. KKQD_bYX = 0;
  223. KKQD_YX_VAVLE = ~KKQD_YX_VAVLE;
  224. }
  225. if(KKQD_XiaQieStep == 0)
  226. {
  227. if(dwTickCount >= KKQD_CSDelay)KKQD_CS_OUT = 0;
  228. }
  229. //电机控制
  230. if(KKQD_bGoMotor && !KKQD_QIAN_LIMIT_IN)
  231. {
  232. KKQD_SZ_OUT = 0;
  233. // KKQD_JZ_DIR = KKQD_YDIR_N;
  234. if(!X_DRV)
  235. // X轴 运行速度 启动速度 加速度 减速度
  236. AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED,KKQD_PARAM_GO_LOW_SPEED,10,12);
  237. }
  238. if(KKQD_bBackMotor) //后退限位已经取消
  239. {
  240. KKQD_SZ_OUT = 0;
  241. // KKQD_JZ_DIR = KKQD_YDIR_P;
  242. if(!X_DRV)
  243. // X轴 运行速度 启动速度 加速度 减速度
  244. AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_P,KKQD_PARAM_GO_LOW_SPEED,KKQD_PARAM_GO_LOW_SPEED,10,12);
  245. }
  246. if(!KKQD_bGoMotor && !KKQD_bBackMotor && (KKQD_MotorStep == 0))
  247. {
  248. if(X_DRV)AxisDecStop(X_AXIS);
  249. }
  250. if(KKQD_QIAN_LIMIT_IN && (KKQD_MotorStep == 0) && !KKQD_bBackMotor &&(KKQD_AutoStep == 0))
  251. {
  252. if(X_DRV)AxisEgmStop(X_AXIS);
  253. }
  254. }
  255. }
  256. void KK_QueDuan_AlarmProtect(void)
  257. {
  258. KK_cRealPos = GetPos(X_AXIS);
  259. if(!bRunning)
  260. {
  261. ;
  262. }
  263. else
  264. {
  265. if((KK_cRealPos > KKQD_PARAM_RUN_LENGTH) && (KKQD_PARAM_RUN_LENGTH > 3000)
  266. && (KK_cGoLimitEn != 0))
  267. {
  268. AxisEgmStop(X_AXIS);
  269. KKQD_JD_VAVLE = 0;
  270. KKQD_SetAlarmCode(KKQD_BACK_ALARM);
  271. }
  272. }
  273. }
  274. void KK_QueDuan_AutoAction(void)
  275. {
  276. //台面电机定时关掉
  277. if(KKQD_QIAN_STOP_Auto)
  278. {
  279. KK_cDLJ_ATUO=1;
  280. AxisEgmStop(X_AXIS);
  281. }
  282. if(KKQD_QIAN_START_Auto)
  283. {
  284. if(KK_cDLJ_ATUO)
  285. {
  286. KK_cDLJ_ATUO=0;
  287. KKQD_AutoDelay = dwTickCount + 1000;
  288. KKQD_MotorDelay = dwTickCount + 2000;
  289. if((KKQD_MotorStep==63 || KKQD_MotorStep==64 || KKQD_MotorStep==65) && !KKQD_QIAN_LIMIT_IN)
  290. AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED/3,KKQD_PARAM_GO_LOW_SPEED/3,15,15);
  291. else if((KK_cRealPos < KKQD_PARAM_ZIPPER_LENGTH) && (KKQD_MotorStep > 311))
  292. AxisMoveTwoPos(X_AXIS,1000,(KKQD_PARAM_ZIPPER_LENGTH - KK_cRealPos) + (*KK_length_buffer),
  293. KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED_LENGTH,KKQD_DIR_P,5000,3000,20,30);
  294. }
  295. }
  296. if(!KK_cDLJ_ATUO)
  297. {
  298. if(bRunning)
  299. {
  300. if(!KK_cTABLETIME)
  301. {
  302. if(dwTickCount >= KKQD_TBDelay)
  303. KKQD_TABLE_VAVLE = 0;
  304. }
  305. switch(KKQD_AutoStep)
  306. {
  307. case 1:
  308. if(dwTickCount >= KKQD_AutoDelay)
  309. {
  310. KKQD_AutoStep = 2;
  311. if(KKQD_MotorStep == 0)
  312. {
  313. KKQD_MotorStep = 61; //前点定位
  314. }
  315. KK_cGoLimitEn = 0;
  316. }
  317. break;
  318. case 2:
  319. if(KKQD_MotorStep == 0)
  320. {
  321. if(!KK_cShuangDao)
  322. KKQD_MotorStep = 30;
  323. else
  324. KKQD_MotorStep = 801;
  325. KKQD_AutoStep = 3;
  326. KK_cGoLimitEn = 1;
  327. }
  328. break;
  329. case 3:
  330. if(KKQD_MotorStep == 0)
  331. {
  332. if(KKQD_SAFE_IN)
  333. {
  334. bStop = 1;
  335. }
  336. else
  337. {
  338. if(!KK_cShuangDao)
  339. {
  340. if(KKQD_XiaQieStep == 0)
  341. KKQD_XiaQieStep = 1;
  342. }
  343. else
  344. {
  345. if(KKQD_XiaQieStep == 0)
  346. KKQD_XiaQieStep = 201;
  347. }
  348. KKQD_AutoStep = 4;
  349. }
  350. }
  351. break;
  352. case 4:
  353. // 闭口
  354. if((KKQD_XiaQieStep == 0) || ((KKQD_XiaQieStep == 6) && KKQD_KB_MODE)|| ((KKQD_XiaQieStep == 14) && (KKQD_KB_MODE == 0)))// && !KKQD_SHANG_MU_LIMIT_IN)
  355. {
  356. if(KKQD_MotorStep == 0)
  357. {
  358. KK_cGoLimitEn=0;
  359. KKQD_MotorStep = 40; //切完后退
  360. }
  361. KKQD_AutoStep = 5;
  362. }
  363. break;
  364. case 5:
  365. if(KKQD_MotorStep == 0)
  366. {
  367. if(!KK_cDiErLaChu)
  368. cZipCnt++;
  369. KKQD_PARAM_NOW_CNT++;
  370. cTableCnt++;
  371. AddToTal(KKQD_TOTAL_ADDR);
  372. AddToTal(CT_WORKTOTAL_ADDR);
  373. CalProSP(KKQD_PROSPEED_ADDR);
  374. if(cTableCnt >= KKQD_PARAM_TABLE_NUM)
  375. {
  376. cTableCnt = 0;
  377. KKQD_TABLE_VAVLE = 1;
  378. KKQD_TBDelay = dwTickCount + KKQD_PARAM_TB_TIME;
  379. }
  380. if( SingOneFlg || cZhouWanone)
  381. {
  382. {
  383. cZhouWanone=0;
  384. cStopMode=0;
  385. bRunning = 0;
  386. KKQD_AutoStep = 0;
  387. SingOneFlg = 0;
  388. KKQD_TABLE_VAVLE = 0;
  389. }
  390. // if(GetTotal(KKQD_TOTAL_ADDR) >= KKQD_PARAM_SET_TOTAL) KKQD_SetAlarmCode(KKQD_TOTAL_ALARM);
  391. }
  392. else
  393. {
  394. KKQD_AutoStep = 1;
  395. if((KKQD_PARAM_NOW_CNT >= KKQD_PARAM_ZHA_SHU) && (KKQD_PARAM_ZHA_SHU > 0))
  396. {
  397. KKQD_AutoDelay = dwTickCount + KKQD_PARAM_ZS_STOP_TIME;
  398. KKQD_PARAM_NOW_CNT = 0;
  399. KK_cTABLETIME = 1;
  400. KK_cTABLETOTAL= 1;
  401. if(KKQD_PARAM_ZS_STOP_TIME == 0)
  402. {
  403. bRunning = 0;
  404. KKQD_AutoStep = 0;
  405. SingOneFlg = 0;
  406. KK_cTABLETIME = 1;
  407. KK_cTABLETOTAL= 1;
  408. KKQD_SetAlarmCode(KKQD_TOTAL_ALARM);
  409. }
  410. }
  411. else
  412. KKQD_AutoDelay = dwTickCount + KKQD_PARAM_CYCLE_DELAY;
  413. }
  414. }
  415. break;
  416. }
  417. }
  418. }
  419. }
  420. void KK_QueDuan_StepCheckStart(void)
  421. {
  422. // 启动
  423. if((START_IN_UP) || bStart || KKQD_bSingle)
  424. {
  425. bStart = 0;
  426. if(!bRunning && (KKQD_AutoStep == 0))
  427. {
  428. if(KKQD_XIA_MU_LIMIT_IN && !KKQD_PARAM_XM_ENABLE)KKQD_SetAlarmCode(KKQD_XM_DAOWEI);
  429. // else if(GetAlarmCode(KKQD_ALARM_ADDR) != 0);
  430. //else if(GetTotal(KKQD_TOTAL_ADDR) >= KKQD_PARAM_SET_TOTAL) KKQD_SetAlarmCode(KKQD_TOTAL_ALARM);
  431. // else if(KKQD_BL_VAVLE)KKQD_SetAlarmCode(KKQD_BL_ALARM);
  432. else if(KKQD_SM_VAVLE)KKQD_SetAlarmCode(KKQD_SM_ALARM);
  433. else
  434. {
  435. bRunning = 1;
  436. KKQD_AutoStep = 1;
  437. if(KKQD_PARAM_BL_ENABLE)
  438. KKQD_PARAM_BL_ENABLE=1 ; //并链起动
  439. if(KKQD_bSingle)
  440. {
  441. SingOneFlg= 1;
  442. KKQD_bSingle=0;
  443. }
  444. else
  445. {
  446. SingOneFlg=0;
  447. }
  448. cZipCnt = 0;
  449. KK_cTABLETIME = 0;
  450. KK_cTABLETOTAL= 0;
  451. cSTOPONE=0;
  452. cTuiFangKuaiCnt = 0;
  453. KKQD_BL_VAVLE = 0; //并链关
  454. KK_cDLJ_ATUO=0;
  455. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  456. SetAlarmCode(KKQD_ALARM_ADDR,0);
  457. }
  458. }
  459. KKQD_bSingle = 0;
  460. }
  461. if(KKQD_STOP_ANNIU_IN_UP)
  462. {
  463. bRunning = 0;
  464. KKQD_XiaQieStep = 0;
  465. KKQD_AutoStep = 0;
  466. KKQD_MotorStep = 0;
  467. KKQD_TuiLianStep = 0;
  468. KKQD_AutoDelay = dwTickCount;
  469. KKQD_MotorDelay = dwTickCount;
  470. KKQD_XiaQieDelay = dwTickCount;
  471. KKQD_KaDaiDelay = dwTickCount;
  472. KKQD_CSDelay = dwTickCount;
  473. KKQD_TBDelay = dwTickCount;
  474. KKQD_TFKDelay = dwTickCount;
  475. KKQD_TLDelay = dwTickCount;
  476. dwTickCount = KKQD_TBDelay;
  477. KKQD_CHUIQIStep=0;
  478. SingOneFlg = 0;
  479. KKQD_JD_VAVLE = 0;
  480. KKQD_SM_VAVLE = 0;
  481. KKQD_XM_VAVLE = 0;
  482. KKQD_YD_VAVLE = 0;
  483. KKQD_TFK_VAVLE= 0;
  484. KKQD_YX_VAVLE = 0;
  485. KKQD_HL_VAVLE = 0;
  486. KKQD_TL_VAVLE = 0;
  487. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  488. KKQD_CS_OUT = 0;
  489. KKQD_XiaQieStep = 0;
  490. KKQD_MotorStep = 0;
  491. KKQD_TuiLianStep = 0;
  492. KKQD_SZ_OUT = 1;
  493. KKQD_GZ_VAVLE = 0;
  494. KKQD_TABLE_VAVLE = 0;
  495. KKQD_StopStep=1;
  496. KK_cTABLETIME = 0;
  497. KK_cTABLETOTAL= 0;
  498. KKQD_BinLianStep = 0;
  499. KKQD_BL_VAVLE = 0;
  500. SetAlarmCode(KKQD_ALARM_ADDR,0);
  501. }
  502. if((KKQD_ANQUANMEN_LIMIT_IN_UP || KKQD_ANQUANMEN_LIMIT_IN) && bRunning)
  503. {
  504. KKQD_StopStep=1;
  505. cSTOPONE=1;
  506. }
  507. if(STOP_IN_UP)
  508. {
  509. if(bRunning)
  510. {
  511. KK_cShuangDao=0;
  512. KK_cDiErLaChu=0;
  513. KKQD_AutoDelay = dwTickCount;
  514. KKQD_MotorDelay = dwTickCount;
  515. KKQD_XiaQieDelay = dwTickCount;
  516. KKQD_KaDaiDelay = dwTickCount;
  517. KKQD_CSDelay = dwTickCount;
  518. KKQD_TBDelay = dwTickCount;
  519. KKQD_TFKDelay = dwTickCount;
  520. KKQD_TLDelay = dwTickCount;
  521. dwTickCount = KKQD_TBDelay;
  522. KKQD_CHUIQIStep=0;
  523. SingOneFlg = 0;
  524. KKQD_JD_VAVLE = 0;
  525. KKQD_SM_VAVLE = 0;
  526. KKQD_XM_VAVLE = 0;
  527. KKQD_YD_VAVLE = 0;
  528. KKQD_TFK_VAVLE= 0;
  529. KKQD_YX_VAVLE = 0;
  530. KKQD_HL_VAVLE = 0;
  531. cStopMode=0;
  532. cZhouWanone=0;
  533. KKQD_TL_VAVLE = 0;
  534. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  535. KKQD_CS_OUT = 0;
  536. KKQD_XiaQieStep = 0;
  537. KKQD_MotorStep = 0;
  538. KKQD_TuiLianStep = 0;
  539. // KKQD_SZ_OUT = 1;
  540. KKQD_GZ_VAVLE = 0;
  541. KKQD_TABLE_VAVLE = 0;
  542. if((KKQD_StopStep == 0) && X_DRV)
  543. KKQD_StopStep = 1;
  544. KK_cTABLETIME = 0;
  545. KK_cTABLETOTAL= 0;
  546. KKQD_BinLianStep = 0;
  547. KKQD_BL_VAVLE = 0;
  548. SetAlarmCode(KKQD_ALARM_ADDR,0);
  549. bRunning = 0;
  550. KKQD_XiaQieStep = 0;
  551. KKQD_AutoStep = 0;
  552. KKQD_MotorStep = 0;
  553. KKQD_TuiLianStep = 0;
  554. }
  555. else
  556. {
  557. KK_cShuangDao=0;
  558. KK_cDiErLaChu=0;
  559. KKQD_AutoDelay = dwTickCount;
  560. KKQD_MotorDelay = dwTickCount;
  561. KKQD_XiaQieDelay = dwTickCount;
  562. KKQD_KaDaiDelay = dwTickCount;
  563. KKQD_CSDelay = dwTickCount;
  564. KKQD_TBDelay = dwTickCount;
  565. KKQD_TFKDelay = dwTickCount;
  566. KKQD_TLDelay = dwTickCount;
  567. dwTickCount = KKQD_TBDelay;
  568. KKQD_CHUIQIStep=0;
  569. SingOneFlg = 0;
  570. KKQD_JD_VAVLE = 0;
  571. KKQD_SM_VAVLE = 0;
  572. KKQD_XM_VAVLE = 0;
  573. KKQD_YD_VAVLE = 0;
  574. KKQD_TFK_VAVLE= 0;
  575. KKQD_YX_VAVLE = 0;
  576. KKQD_HL_VAVLE = 0;
  577. cStopMode=0;
  578. cZhouWanone=0;
  579. KKQD_TL_VAVLE = 0;
  580. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  581. KKQD_CS_OUT = 0;
  582. KKQD_XiaQieStep = 0;
  583. KKQD_MotorStep = 0;
  584. KKQD_TuiLianStep = 0;
  585. KKQD_SZ_OUT = 1;
  586. KKQD_GZ_VAVLE = 0;
  587. KKQD_TABLE_VAVLE = 0;
  588. if((KKQD_StopStep == 0))
  589. {
  590. KK_cSTOPONE = 0;
  591. AxisEgmStop(X_AXIS);
  592. KKQD_SZ_OUT = 1;
  593. }
  594. KK_cTABLETIME = 0;
  595. KK_cTABLETOTAL= 0;
  596. KKQD_BinLianStep = 0;
  597. KKQD_BL_VAVLE = 0;
  598. SetAlarmCode(KKQD_ALARM_ADDR,0);
  599. bRunning = 0;
  600. KKQD_XiaQieStep = 0;
  601. KKQD_AutoStep = 0;
  602. KKQD_MotorStep = 0;
  603. KKQD_TuiLianStep = 0;
  604. }
  605. }
  606. //停止
  607. if( bStop)
  608. {
  609. bStop = 0;
  610. if(cStopMode < 2)
  611. cStopMode++;
  612. if(cStopMode==1 && bRunning)
  613. cZhouWanone=1;
  614. if(bRunning && cStopMode==2)
  615. {
  616. KK_cShuangDao=0;
  617. KK_cDiErLaChu=0;
  618. KKQD_AutoDelay = dwTickCount;
  619. KKQD_MotorDelay = dwTickCount;
  620. KKQD_XiaQieDelay = dwTickCount;
  621. KKQD_KaDaiDelay = dwTickCount;
  622. KKQD_CSDelay = dwTickCount;
  623. KKQD_TBDelay = dwTickCount;
  624. KKQD_TFKDelay = dwTickCount;
  625. KKQD_TLDelay = dwTickCount;
  626. dwTickCount = KKQD_TBDelay;
  627. SingOneFlg = 0;
  628. bRunning = 0;
  629. KKQD_XiaQieStep = 0;
  630. KKQD_AutoStep = 0;
  631. KKQD_MotorStep = 0;
  632. KKQD_TuiLianStep = 0;
  633. KKQD_JD_VAVLE = 0;
  634. KKQD_SM_VAVLE = 0;
  635. KKQD_XM_VAVLE = 0;
  636. KKQD_YD_VAVLE = 0;
  637. KKQD_TFK_VAVLE= 0;
  638. KKQD_TL_VAVLE = 0;
  639. KKQD_HL_VAVLE = 0;
  640. KKQD_CS_OUT = 0;
  641. KKQD_XiaQieStep = 0;
  642. KKQD_MotorStep = 0;
  643. KKQD_TuiLianStep = 0;
  644. //KKQD_SZ_OUT = 1;
  645. KKQD_GZ_VAVLE = 0;
  646. KKQD_TABLE_VAVLE = 0;
  647. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  648. if((KKQD_StopStep == 0) && X_DRV)
  649. KKQD_StopStep = 1;
  650. KKQD_BinLianStep = 0;
  651. KKQD_BL_VAVLE = 0;
  652. KK_cTABLETIME = 0;
  653. KK_cTABLETOTAL= 0;
  654. user_datas[121] = 0;
  655. user_datas[122] = 0;
  656. SetAlarmCode(KKQD_ALARM_ADDR,0);
  657. }
  658. else if(!bRunning)
  659. {
  660. KK_cShuangDao=0;
  661. KK_cDiErLaChu=0;
  662. KKQD_AutoDelay = dwTickCount;
  663. KKQD_MotorDelay = dwTickCount;
  664. KKQD_XiaQieDelay = dwTickCount;
  665. KKQD_KaDaiDelay = dwTickCount;
  666. KKQD_CSDelay = dwTickCount;
  667. KKQD_TBDelay = dwTickCount;
  668. KKQD_TFKDelay = dwTickCount;
  669. KKQD_TLDelay = dwTickCount;
  670. dwTickCount = KKQD_TBDelay;
  671. KKQD_CHUIQIStep=0;
  672. SingOneFlg = 0;
  673. KKQD_JD_VAVLE = 0;
  674. KKQD_SM_VAVLE = 0;
  675. KKQD_XM_VAVLE = 0;
  676. KKQD_YD_VAVLE = 0;
  677. KKQD_TFK_VAVLE= 0;
  678. KKQD_YX_VAVLE = 0;
  679. KKQD_HL_VAVLE = 0;
  680. cStopMode=0;
  681. cZhouWanone=0;
  682. KKQD_TL_VAVLE = 0;
  683. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  684. KKQD_CS_OUT = 0;
  685. KKQD_XiaQieStep = 0;
  686. KKQD_MotorStep = 0;
  687. KKQD_TuiLianStep = 0;
  688. KKQD_SZ_OUT = 1;
  689. KKQD_GZ_VAVLE = 0;
  690. KKQD_TABLE_VAVLE = 0;
  691. if((KKQD_StopStep == 0))
  692. {
  693. KK_cSTOPONE = 0;
  694. AxisEgmStop(X_AXIS);
  695. KKQD_SZ_OUT = 1;
  696. }
  697. KK_cTABLETIME = 0;
  698. KK_cTABLETOTAL= 0;
  699. KKQD_BinLianStep = 0;
  700. KKQD_BL_VAVLE = 0;
  701. SetAlarmCode(KKQD_ALARM_ADDR,0);
  702. bRunning = 0;
  703. KKQD_XiaQieStep = 0;
  704. KKQD_AutoStep = 0;
  705. KKQD_MotorStep = 0;
  706. KKQD_TuiLianStep = 0;
  707. }
  708. }
  709. if(bAlarmStop)
  710. {
  711. bAlarmStop = 0;
  712. KKQD_XiaQieStep = 0;
  713. KKQD_AutoStep = 0;
  714. KKQD_MotorStep = 0;
  715. KKQD_TuiLianStep = 0;
  716. KKQD_XiaQieStep = 0;
  717. KKQD_MotorStep = 0;
  718. KKQD_TuiLianStep = 0;
  719. KKQD_AutoDelay = dwTickCount;
  720. KKQD_MotorDelay = dwTickCount;
  721. KKQD_XiaQieDelay = dwTickCount;
  722. KKQD_KaDaiDelay = dwTickCount;
  723. KKQD_CSDelay = dwTickCount;
  724. KKQD_TBDelay = dwTickCount;
  725. KKQD_TFKDelay = dwTickCount;
  726. KKQD_TLDelay = dwTickCount;
  727. SingOneFlg = 0;
  728. bRunning = 0;
  729. // KKQD_StopStep=1;
  730. cStopMode=0;
  731. cZhouWanone=0;
  732. dwTickCount = KKQD_TBDelay;
  733. KKQD_TABLE_VAVLE = 0;
  734. KKQD_TFK_VAVLE =0;
  735. KKQD_JD_VAVLE=0;
  736. KKQD_GZ_VAVLE=0;
  737. }
  738. }
  739. //记忆长度模式误差检测
  740. void KK_QueDuan_CheckLength(long zip_length)
  741. {
  742. static long start_dist;
  743. switch(KKQD_CheckLengthStep)
  744. {
  745. case 0:break;
  746. case 1:
  747. start_dist = KK_cRealPos;
  748. dwSaveLength = 0;
  749. KKQD_CheckLengthStep = 2;
  750. break;
  751. case 2:
  752. if(KKQD_GUO_LIAN_IN_DW)
  753. {
  754. dwSaveLength = KK_cRealPos - start_dist;
  755. // user_datas[127] = KK_cRealPos;
  756. }
  757. break;
  758. }
  759. }
  760. void KK_QueDuan_Motor(void)
  761. {
  762. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  763. unsigned short ch;
  764. user_datas[121]= KKQD_MotorStep;
  765. user_datas[122]= length_buff;
  766. user_datas[123] = KK_cRealPos;
  767. user_datas[124] = dwSaveLength;//QD_BinLianStep;
  768. user_datas[125] = KKQD_CheckLengthStep;//QD_AutoStep;
  769. user_datas[126] = KKQD_XiaQieStep;
  770. // user_datas[127] = KKQD_XiaQieStep;
  771. KK_QueDuan_CheckLength(length_buff);
  772. if(!KK_cDLJ_ATUO)
  773. {
  774. switch(KKQD_MotorStep)
  775. {
  776. case 30:
  777. switch(KKQD_PARAM_BACK_MODE) //开口分四种模式
  778. {
  779. case 0: //单数控模式
  780. KKQD_MotorStep = 310; //每种模式留20步
  781. break;
  782. case 1://单感应模式
  783. KKQD_MotorStep = 330; //每种模式留20步
  784. break;
  785. case 2: //先感应后数控模式+检测
  786. KKQD_MotorStep = 350; //每种模式留20步
  787. break;
  788. default: //数控模式+过链检测长度
  789. KKQD_MotorStep = 370; //每种模式留20步
  790. break;
  791. }
  792. KKQD_MotorDelay = dwTickCount + KKQD_PARAM_DELAY_BACK;
  793. break;
  794. //310步到315步为数控模式
  795. case 310:
  796. SetDir(X_AXIS, KKQD_DIR_P);
  797. if(KKQD_PARAM_BL_ENABLE)
  798. KKQD_BinLianStep = 1; //并链起动
  799. KKQD_MotorStep = 311;
  800. break;
  801. case 311:
  802. if(dwTickCount >= KKQD_MotorDelay)
  803. {
  804. KK_length_buffer = &KKQD_PARAM_OFFSET_LENGTH;
  805. SetPos(X_AXIS, 0);
  806. //李永庆代码
  807. //两段速度移动距离 拉链长度+慢速长度停止
  808. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  809. KK_DCC_TIME_BL=KKQD_PARAM_BACK_SPEED/400;
  810. AxisMovePosAccDecNotStop(X_AXIS,KKQD_PARAM_BACK_SPEED,KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer), KKQD_PARAM_START_SPEED,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_ACC,KK_DCC_TIME_BL,KKQD_PARAM_BACK_LOW_SPEED_LENGTH);
  811. gou_zhen_buff = KK_cRealPos;
  812. save_buff = KK_cRealPos;
  813. KKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  814. KKQD_MotorStep = 312;
  815. }
  816. break;
  817. case 312:
  818. //勾针提前输出 ,争取时间推方块
  819. if(KK_cRealPos>300)
  820. KKQD_DGLG_VAVLE = 1; //顶过链杆关
  821. if (!KKQD_GZ_VAVLE && (KK_cRealPos >= (KKQD_PARAM_ZIPPER_LENGTH- 230)))
  822. KKQD_GZ_VAVLE = 1;
  823. if((KK_cRealPos) > (KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer)-KKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*KK_length_buffer) - (KKQD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(KKQD_PARAM_BACK_SPEED,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_DCC)))))
  824. {
  825. KKQD_MotorStep = 313;
  826. }
  827. else if(KK_cRealPos >= (KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer) + KKQD_PARAM_ERROR_LENGTH))
  828. {
  829. KKQD_SetAlarmCode(KKQD_GZ_ALARM);
  830. }
  831. break;
  832. case 313:
  833. if (!KKQD_GZ_VAVLE && (KK_cRealPos >= (KKQD_PARAM_ZIPPER_LENGTH- 230)))
  834. KKQD_GZ_VAVLE = 1;
  835. if(!X_DRV || KK_cRealPos>=(KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer)))
  836. {
  837. AxisEgmStop(X_AXIS);
  838. KKQD_MotorDelay = dwTickCount + KKQD_PARAM_TFK_DELAY;
  839. KKQD_MotorStep = 314;
  840. KKQD_BL_VAVLE = 0; //停止时并链一定要打开
  841. if(KKQD_PARAM_BACK_MODE == 2) //模式2,先检测长度后数控
  842. {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
  843. if(cZipCnt > 1) //长度检测
  844. {
  845. if(KKQD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  846. {
  847. if(((dwSaveLength + KKQD_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + KKQD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
  848. {
  849. KKQD_SetAlarmCode(KKQD_LENGTH_LONG_ALARM);//拉链变长,对比警告
  850. }
  851. else if((dwSaveLength + KKQD_PARAM_MOTOR_DELAY_LENGTH+ KKQD_PARAM_ERROR_LENGTH) < length_buff)
  852. {
  853. KKQD_SetAlarmCode(KKQD_LENGTH_SHORT_ALARM); ////拉链变短
  854. }
  855. KKQD_CheckLengthStep = 0;
  856. }
  857. }
  858. }
  859. }
  860. break;
  861. case 314:
  862. if(!X_DRV && (dwTickCount >= KKQD_MotorDelay)) //数控到停止
  863. {
  864. KKQD_MotorStep = 0;
  865. KKQD_TFK_VAVLE = 1; //推方块输出
  866. }
  867. break;
  868. //330步到349步单感应模式
  869. case 330:
  870. back_buff = KK_cRealPos;
  871. gou_zhen_buff = KK_cRealPos;
  872. SetDir(X_AXIS, KKQD_DIR_P);
  873. KKQD_MotorStep = 331;
  874. user_datas[127] = 0;
  875. break;
  876. case 331:
  877. if(dwTickCount >= KKQD_MotorDelay)
  878. {
  879. if(cZipCnt < 2)
  880. {
  881. if(KKQD_PARAM_BL_ENABLE)
  882. KKQD_BinLianStep = 10; //并链起动
  883. //第一条都是过链感应,后拉速度减半//原来KKQD_PARAM_CHECK_BACK_HSPEED/2
  884. // X轴 运行速度 启动速度 加速度 减速度
  885. AxisContinueMoveAcc(X_AXIS,9000,KKQD_DIR_P,KKQD_PARAM_START_SPEED,2000,8,13);
  886. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  887. // AxisMoveTwoPos(X_AXIS,KKQD_PARAM_BACK_SPEED,KKQD_PARAM_ZIPPER_LENGTH + (*KK_length_buffer)-KKQD_PARAM_BACK_LOW_SPEED_LENGTH,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED_LENGTH,KKQD_DIR_P);
  888. }
  889. else
  890. {
  891. if(KKQD_PARAM_BL_ENABLE)
  892. KKQD_BinLianStep = 1; //并链起动
  893. //因为每条都是过链感应,所以直接运行检测模式后拉速度
  894. // X轴 运行速度 启动速度 加速度 减速度
  895. AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_CHECK_BACK_HSPEED,KKQD_DIR_P,KKQD_PARAM_START_SPEED,2000,KKQD_PARAM_ACC,KKQD_PARAM_DCC);
  896. }
  897. KKQD_MotorStep = 332;
  898. }
  899. break;
  900. case 332:
  901. if(KK_cRealPos>300)
  902. {
  903. if(cZipCnt > 1) //第二条开始数控降速
  904. {
  905. if((KK_cRealPos + KKQD_PARAM_BACK_LOW_SPEED_LENGTH + 600)>= length_buff)
  906. {
  907. AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15);
  908. user_datas[127] = KK_cRealPos;
  909. KKQD_MotorStep = 334; //到检测定位
  910. }
  911. if(KKQD_GUO_LIAN_IN_DW) //重新到链上
  912. {
  913. AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15);
  914. gou_zhen_buff = KK_cRealPos;
  915. KKQD_MotorStep = 335; //到检测定位
  916. }
  917. //
  918. // if((KK_cRealPos >= (KKQD_PARAM_BACK_LOW_SPEED_LENGTH + 60)) && KKQD_GUO_LIAN_IN)
  919. // {
  920. // }
  921. }
  922. else //第一条工作
  923. {
  924. if(KKQD_GUO_LIAN_IN_UP)
  925. {
  926. checkdelay_buff = KK_cRealPos;
  927. AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15);
  928. KKQD_MotorDelay = dwTickCount + 0;//KKQD_PARAM_DELAY_XM;
  929. KKQD_MotorStep = 333;
  930. }
  931. else if((KK_cRealPos >= KKQD_PARAM_RUN_LENGTH) && (KKQD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
  932. {
  933. // KKQD_SetAlarmCode(KKQD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
  934. }
  935. }
  936. }
  937. break;
  938. case 333:
  939. if(dwTickCount >= KKQD_MotorDelay)
  940. {
  941. KKQD_MotorStep = 334;
  942. }
  943. break;
  944. case 334:
  945. if(KKQD_GUO_LIAN_IN_DW) //下降沿,定位长度
  946. {
  947. //滤波有待调试
  948. // if((((KK_cRealPos - checkdelay_buff) >= KKQD_PARAM_DELAY_CHECK) && (KKQD_PARAM_LT_ENABLE)) || (((KK_cRealPos - checkdelay_buff) >= KKQD_PARAM_NO_LT_DELAY_CHECK) && (KKQD_PARAM_LT_ENABLE == 0)))
  949. // {
  950. if(KKQD_GUO_LIAN_IN_DW)
  951. {
  952. gou_zhen_buff = KK_cRealPos;
  953. KKQD_MotorStep = 335;
  954. }
  955. // }
  956. }
  957. break;
  958. case 335:
  959. if(KKQD_GUO_LIAN_IN_DW)
  960. {
  961. gou_zhen_buff = KK_cRealPos;
  962. }
  963. //在空们都把延时清零
  964. if(KKQD_GUO_LIAN_IN)
  965. {
  966. gou_zhen_buff = KK_cRealPos;
  967. }
  968. //定位停止
  969. if(((KK_cRealPos - gou_zhen_buff) >= KKQD_PARAM_MOTOR_DELAY_LENGTH) && !KKQD_GUO_LIAN_IN)
  970. {
  971. AxisEgmStop(X_AXIS);
  972. KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  973. KKQD_MotorStep = 336;
  974. KKQD_GZ_VAVLE = 1;
  975. }
  976. break;
  977. case 336:
  978. if(!X_DRV)
  979. {
  980. KKQD_GZ_VAVLE = 1;
  981. KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  982. // KKQD_XM_VAVLE = 1;
  983. KKQD_MotorStep = 337;
  984. }
  985. break;
  986. case 337:
  987. if(1)
  988. {
  989. KKQD_MotorStep = 338;
  990. KKQD_MotorDelay = dwTickCount + KKQD_PARAM_TFK_DELAY;
  991. }
  992. // else if(dwTickCount >= KKQD_MotorDelay) KKQD_SetAlarmCode(KKQD_XM_DAOWEI);
  993. break;
  994. case 338:
  995. if((dwTickCount >= KKQD_MotorDelay))
  996. {
  997. KKQD_TFK_VAVLE = 1; //推方块输出
  998. KKQD_MotorStep = 339;
  999. KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1000. }
  1001. break;
  1002. case 339:
  1003. if(cZipCnt == 1)
  1004. {
  1005. length_buff = KK_cRealPos - save_buff;
  1006. SetData32bits(KKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
  1007. }
  1008. else if(cZipCnt > 1) //长度检测
  1009. {
  1010. if(KKQD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  1011. {
  1012. if(KK_cRealPos >= length_buff) //拉链变长,对比警告
  1013. {
  1014. if((KK_cRealPos - save_buff) > (length_buff+KKQD_PARAM_ERROR_LENGTH))
  1015. KKQD_SetAlarmCode(KKQD_LENGTH_LONG_ALARM);
  1016. }
  1017. else //拉链变短
  1018. {
  1019. if((KK_cRealPos - save_buff + KKQD_PARAM_ERROR_LENGTH) < (length_buff))
  1020. KKQD_SetAlarmCode(KKQD_LENGTH_SHORT_ALARM);
  1021. }
  1022. }
  1023. }
  1024. KKQD_MotorStep = 0;
  1025. break;
  1026. //350步到369步单感应模式
  1027. case 350:
  1028. back_buff = KK_cRealPos;
  1029. gou_zhen_buff = KK_cRealPos;
  1030. SetDir(X_AXIS, KKQD_DIR_P);
  1031. KKQD_MotorStep = 351;
  1032. break;
  1033. case 351:
  1034. if(dwTickCount >= KKQD_MotorDelay)
  1035. {
  1036. //第一,二条都是过链感应,测量长度
  1037. if(cZipCnt < 2)
  1038. {
  1039. if(KKQD_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
  1040. KKQD_BinLianStep = 10; //并链起动
  1041. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  1042. // X轴 运行速度 启动速度 加速度 减速度
  1043. AxisContinueMoveAcc(X_AXIS,9000,KKQD_DIR_P,KKQD_PARAM_START_SPEED,2000,8,12);
  1044. KKQD_MotorStep = 352;
  1045. }
  1046. else
  1047. {
  1048. if(KKQD_PARAM_BL_ENABLE)
  1049. KKQD_BinLianStep = 1; //并链起动
  1050. KKQD_DGLG_VAVLE = 1; //顶过链杆关
  1051. KKQD_CheckLengthStep = 1; //长度检测,第3条才有对比
  1052. //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
  1053. KKQD_MotorStep = 311;
  1054. }
  1055. }
  1056. break;
  1057. case 352:
  1058. if(KK_cRealPos>300)
  1059. {
  1060. //前两条都按最低速度工作
  1061. if(KKQD_GUO_LIAN_IN_UP)
  1062. {
  1063. checkdelay_buff = KK_cRealPos;
  1064. AxisContinueMoveChangeSpeed(X_AXIS,KKQD_PARAM_BACK_LOW_SPEED,KKQD_PARAM_BACK_LOW_SPEED/2,25,15);
  1065. KKQD_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波
  1066. KKQD_MotorStep = 353;
  1067. }
  1068. else if((KK_cRealPos >= KKQD_PARAM_RUN_LENGTH) && (KKQD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
  1069. {
  1070. // KKQD_SetAlarmCode(KKQD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
  1071. }
  1072. }
  1073. break;
  1074. case 353:
  1075. if(dwTickCount >= KKQD_MotorDelay)
  1076. {
  1077. KKQD_MotorStep = 354;
  1078. }
  1079. break;
  1080. case 354:
  1081. if(KKQD_GUO_LIAN_IN_DW) //下降沿,定位长度
  1082. {
  1083. if(KKQD_GUO_LIAN_IN_DW)
  1084. {
  1085. gou_zhen_buff = KK_cRealPos;
  1086. KKQD_MotorStep = 355;
  1087. }
  1088. }
  1089. break;
  1090. case 355:
  1091. if(KKQD_GUO_LIAN_IN_DW)
  1092. {
  1093. gou_zhen_buff = KK_cRealPos;
  1094. }
  1095. //在空们都把延时清零
  1096. if(KKQD_GUO_LIAN_IN)
  1097. {
  1098. gou_zhen_buff = KK_cRealPos;
  1099. }
  1100. //定位停止
  1101. if(((KK_cRealPos - gou_zhen_buff) >= KKQD_PARAM_MOTOR_DELAY_LENGTH) && !KKQD_GUO_LIAN_IN)
  1102. {
  1103. AxisEgmStop(X_AXIS);
  1104. KKQD_MotorStep = 356;
  1105. KKQD_GZ_VAVLE = 1;
  1106. }
  1107. break;
  1108. case 356:
  1109. if(!X_DRV)
  1110. {
  1111. KKQD_GZ_VAVLE = 1;
  1112. KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1113. // KKQD_XM_VAVLE = 1;
  1114. KKQD_MotorStep = 357;
  1115. }
  1116. break;
  1117. case 357:
  1118. if(1)
  1119. {
  1120. KKQD_MotorStep = 358;
  1121. KKQD_MotorDelay = dwTickCount + KKQD_PARAM_TFK_DELAY;
  1122. }
  1123. break;
  1124. case 358:
  1125. if((dwTickCount >= KKQD_MotorDelay))
  1126. {
  1127. KKQD_TFK_VAVLE = 1; //推方块输出
  1128. KKQD_MotorStep = 359;
  1129. KKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1130. }
  1131. break;
  1132. case 359:
  1133. if(cZipCnt == 1)
  1134. {
  1135. length_buff = KK_cRealPos - save_buff;
  1136. //测量出来长度
  1137. SetData32bits(KKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
  1138. }
  1139. KKQD_MotorStep = 0;
  1140. break;
  1141. case 40:
  1142. //切完延时后拉带松夹子
  1143. if(KKQD_PARAM_SJZ_LENGTH == 0 )
  1144. {
  1145. KKQD_JD_VAVLE = 0;
  1146. SetDir(X_AXIS, KKQD_DIR_P);
  1147. jz_buff = KK_cRealPos;
  1148. AxisMovePosAccDec(X_AXIS,KKQD_PARAM_CUT_BACK_SPEED,KKQD_PARAM_BACK_LENGTH,1000,1000,100,50,0);
  1149. // AxisMovePosAccDec(X_AXIS,KKQD_PARAM_CUT_BACK_SPEED,KKQD_PARAM_SJZ_LENGTH + KKQD_PARAM_BACK_LENGTH,2000,2000,25,25,40);
  1150. KKQD_MotorStep = 44;
  1151. }
  1152. else
  1153. {
  1154. jz_buff = KK_cRealPos;
  1155. SetDir(X_AXIS, KKQD_DIR_P);
  1156. KKQD_MotorStep = 41;
  1157. }
  1158. break;
  1159. case 41:
  1160. AxisMovePosAccDec(X_AXIS,KKQD_PARAM_CUT_BACK_SPEED,(KKQD_PARAM_SJZ_LENGTH+KKQD_PARAM_BACK_LENGTH),1000,1000,100,50,0);
  1161. KKQD_MotorStep = 42;
  1162. break;
  1163. case 42:
  1164. if((KKQD_PARAM_SJZ_LENGTH <= (KK_cRealPos - jz_buff)))
  1165. {
  1166. KKQD_JD_VAVLE = 0;
  1167. KKQD_GZ_VAVLE=0;
  1168. KKQD_MotorStep = 44;
  1169. }
  1170. break;
  1171. case 44: // 切断完成后拉电机动作
  1172. if((KKQD_PARAM_SJZ_LENGTH+KKQD_PARAM_BACK_LENGTH) <= (KK_cRealPos - jz_buff) || !X_DRV)
  1173. {
  1174. AxisEgmStop(X_AXIS);
  1175. KKQD_MotorStep = 0;
  1176. KKQD_GZ_VAVLE=0;
  1177. KKQD_MotorDelay = dwTickCount;
  1178. }
  1179. break;
  1180. case 61: // 前点定位数控模式
  1181. if(KKQD_SZ_OUT)
  1182. {
  1183. KKQD_SZ_OUT = 0;
  1184. KKQD_MotorDelay = dwTickCount + 150;
  1185. SetDir(X_AXIS, KKQD_DIR_N);
  1186. SetPos(X_AXIS, 0);
  1187. }
  1188. else
  1189. KKQD_MotorDelay = dwTickCount;
  1190. KKQD_BL_VAVLE = 0;//并链也要打开
  1191. // KKQD_JZ_DIR = KKQD_YDIR_N;
  1192. if(KKQD_TuiLianStep==0)
  1193. {
  1194. if(!KKQD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
  1195. {
  1196. if(!KKQD_SHANG_MU_LIMIT_IN && (KKQD_TuiLianStep == 0))
  1197. {
  1198. KKQD_TuiLianStep = 1;
  1199. KKQD_MotorStep = 62;
  1200. }
  1201. }
  1202. else
  1203. KKQD_MotorStep = 62;
  1204. }
  1205. else
  1206. KKQD_MotorStep = 62;
  1207. break;
  1208. case 62:
  1209. if(dwTickCount >= KKQD_MotorDelay)
  1210. {
  1211. if(KKQD_QIAN_LIMIT_IN)
  1212. {
  1213. SetPos(X_AXIS, 0);//在前点,直接置零点
  1214. // KKQD_JZ_DIR = KKQD_YDIR_P;
  1215. //前点亮的情况下先退出
  1216. AxisMovePos(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,1000);
  1217. KKQD_MotorDelay = dwTickCount + 300;
  1218. }
  1219. KKQD_MotorStep = 63;
  1220. KKQD_JD_VAVLE = 0;
  1221. }
  1222. break;
  1223. case 63:
  1224. if(!X_DRV && !KKQD_QIAN_LIMIT_IN && (dwTickCount >= KKQD_MotorDelay))// && !KKQD_SHANG_MU_LIMIT_IN)
  1225. {
  1226. // KKQD_JZ_DIR = KKQD_YDIR_N;
  1227. SetDir(X_AXIS, KKQD_DIR_N);
  1228. go_buff = KK_cRealPos;
  1229. KKQD_YD_VAVLE = 1;
  1230. KKQD_HL_VAVLE = 1;
  1231. KKQD_YX_VAVLE = 1;
  1232. //李永庆代码,当位置在慢速之外,走数控到慢速点
  1233. if(cZipCnt > 0)
  1234. {
  1235. if(KK_cRealPos>(KKQD_PARAM_GO_LOW_SPEED_LENGTH))
  1236. {
  1237. KK_DCC_TIME_BL=KKQD_PARAM_GO_HIGH_SPEED/400;
  1238. AxisMovePosAccDecNotStop(X_AXIS,KKQD_PARAM_GO_HIGH_SPEED,-KK_cRealPos,
  1239. KKQD_PARAM_START_SPEED,KKQD_PARAM_GO_LOW_SPEED,KKQD_PARAM_ACC,KK_DCC_TIME_BL,
  1240. KKQD_PARAM_GO_LOW_SPEED_LENGTH);
  1241. }
  1242. else
  1243. {
  1244. // X轴 运行速度 启动速度 加速度 减速度
  1245. AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED/3,1000,15,15);
  1246. }
  1247. }
  1248. else
  1249. {
  1250. // X轴 运行速度 启动速度 加速度 减速度
  1251. AxisContinueMoveAcc(X_AXIS,KKQD_PARAM_GO_LOW_SPEED,KKQD_DIR_N,KKQD_PARAM_GO_LOW_SPEED/3,1000,15,15);
  1252. }
  1253. KKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1254. KKQD_MotorStep =64;
  1255. }
  1256. break;
  1257. case 64:
  1258. if(cZipCnt > 1)
  1259. {
  1260. //李永庆代码
  1261. if(((KK_cRealPos) < (KKQD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (KKQD_QIAN_DEC_IN))
  1262. {
  1263. user_datas[126]= GetCurSpeed(X_AXIS);
  1264. // MoveChangSpeedDec(X_AXIS,KKQD_PARAM_GO_HIGH_SPEED*2/3,6,8);
  1265. // AxisChangeSpeed(X_AXIS,40);
  1266. KKQD_MotorStep =65;
  1267. }
  1268. if(KKQD_QIAN_LIMIT_IN) //前点限位
  1269. {
  1270. AxisEgmStop(X_AXIS);
  1271. KKQD_MotorStep = 66;
  1272. }
  1273. }
  1274. else
  1275. {
  1276. if(KKQD_QIAN_LIMIT_IN) //前点限位
  1277. {
  1278. AxisEgmStop(X_AXIS);
  1279. KKQD_MotorStep = 66;
  1280. }
  1281. }
  1282. break;
  1283. case 65:
  1284. if(KKQD_QIAN_LIMIT_IN)
  1285. {
  1286. KKQD_TFK_VAVLE = 0;
  1287. AxisEgmStop(X_AXIS);
  1288. KKQD_MotorStep = 66;
  1289. }
  1290. else if(dwTickCount >= KKQD_MotorDelay)
  1291. KKQD_SetAlarmCode(KKQD_NO_ZIPPER_ALARM);
  1292. break;
  1293. case 66:
  1294. if(!X_DRV)
  1295. {
  1296. KKQD_TFK_VAVLE=0;
  1297. SetPos(X_AXIS, 0);
  1298. KKQD_MotorDelay = dwTickCount;
  1299. KKQD_MotorStep = 67;
  1300. }
  1301. break;
  1302. case 67: //等推链完成后,
  1303. if((dwTickCount >= KKQD_MotorDelay) && (KKQD_TuiLianStep == 0) && ((KKQD_PARAM_TIAOSHI_MODE && KKQD_bTS) || (KKQD_PARAM_TIAOSHI_MODE == 0)) )
  1304. {
  1305. if(bRunning)
  1306. {
  1307. KKQD_JD_VAVLE = 1;
  1308. KKQD_MotorDelay = dwTickCount + KKQD_PARAM_DELAY_BACK;
  1309. }
  1310. KKQD_MotorStep = 68;
  1311. }
  1312. break;
  1313. case 68:
  1314. if(dwTickCount >= KKQD_MotorDelay)
  1315. {
  1316. KKQD_YD_VAVLE = 0;
  1317. KKQD_HL_VAVLE = 0;
  1318. KKQD_YX_VAVLE = 0;
  1319. KKQD_TL_VAVLE = 0;
  1320. KKQD_MotorStep = 0;
  1321. KKQD_MotorDelay = dwTickCount;
  1322. }
  1323. break;
  1324. }
  1325. }
  1326. }
  1327. void KK_QueDuan_BingLian(void)
  1328. {
  1329. static long bl_pos_buff,HL_delay;
  1330. switch(KKQD_BinLianStep)
  1331. {
  1332. case 1:
  1333. bl_pos_buff = KK_cRealPos;
  1334. KKQD_BinLianStep = 2;
  1335. break;
  1336. case 2:
  1337. if((KK_cRealPos - bl_pos_buff) >= KKQD_PARAM_DELAY_HL_LENGTH)
  1338. {
  1339. KKQD_BL_VAVLE = 1;
  1340. KKQD_BinLianStep = 3;
  1341. }
  1342. break;
  1343. case 3://有过链检测
  1344. if((KK_cRealPos - bl_pos_buff) >= (KKQD_PARAM_ZIPPER_LENGTH - KKQD_PARAM_HL_DELAY_BACK))
  1345. {
  1346. KKQD_BL_VAVLE = 0;
  1347. KKQD_BinLianStep = 0;
  1348. }
  1349. if(KKQD_GUO_LIAN_IN_DW && KKQD_PARAM_BACK_MODE ==1) //|| (KKQD_PARAM_BACK_MODE==2 && cZipCnt < 2)))
  1350. {
  1351. KKQD_BL_VAVLE = 0;
  1352. KKQD_BinLianStep = 0;
  1353. }
  1354. break;
  1355. case 10:
  1356. bl_pos_buff = KK_cRealPos;
  1357. KKQD_BinLianStep = 11;
  1358. break;
  1359. case 11:
  1360. if((KK_cRealPos - bl_pos_buff) >= KKQD_PARAM_DELAY_HL_LENGTH)
  1361. {
  1362. KKQD_BL_VAVLE = 1;
  1363. KKQD_BinLianStep = 12;
  1364. }
  1365. break;
  1366. case 12://有过链检测
  1367. if(KKQD_GUO_LIAN_IN_DW)
  1368. {
  1369. KKQD_BL_VAVLE = 0;
  1370. KKQD_BinLianStep = 0;
  1371. }
  1372. break;
  1373. default:;
  1374. }
  1375. }
  1376. //超声方式下切,开口专用
  1377. void KK_QueDuan_XiaQue_KK(void)
  1378. {
  1379. switch(KKQD_XiaQieStep)
  1380. {
  1381. case 0:
  1382. break;
  1383. case 1:
  1384. KKQD_XiaQieStep = 2;
  1385. break;
  1386. case 2:
  1387. KKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1388. KKQD_XiaQieStep = 3;
  1389. break;
  1390. case 3:
  1391. if(1)
  1392. {
  1393. KKQD_XiaQieDelay = dwTickCount + 0;//KKQD_PARAM_GZ_DELAY;
  1394. KKQD_XiaQieStep = 4;
  1395. }
  1396. else if(dwTickCount >= KKQD_XiaQieDelay)
  1397. {
  1398. KKQD_SetAlarmCode(KKQD_XM_DAOWEI);
  1399. }
  1400. break;
  1401. case 4:
  1402. if(KKQD_GZ_VAVLE) //勾针已经有输出就不需要延时
  1403. {
  1404. KKQD_XiaQieDelay = dwTickCount + 0;
  1405. }
  1406. else
  1407. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_TFK_DELAY;
  1408. KKQD_GZ_VAVLE = 1;
  1409. cTuiFangKuaiCnt=0;
  1410. KKQD_XiaQieStep = 5;
  1411. break;
  1412. case 5:
  1413. if(dwTickCount >= KKQD_XiaQieDelay)
  1414. {
  1415. KKQD_TFK_VAVLE = 1;
  1416. KKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1417. KKQD_XiaQieStep = 6;
  1418. }
  1419. break;
  1420. case 6:
  1421. if(1)
  1422. {
  1423. KKQD_XiaQieStep = 7;
  1424. KKQD_XiaQieDelay = dwTickCount + 1000;
  1425. }
  1426. else if(dwTickCount >= KKQD_XiaQieDelay)
  1427. {
  1428. KKQD_SetAlarmCode(KKQD_XM_DAOWEI);
  1429. }
  1430. break;
  1431. case 7:
  1432. if(KKQD_GOUZHEN_IN)
  1433. {
  1434. cTuiFangKuaiCnt = 0;
  1435. KKQD_YD_VAVLE = 1;
  1436. if(!bRunning)
  1437. KKQD_XiaQieDelay = dwTickCount + 200;
  1438. else
  1439. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_CUT_DELAY;
  1440. if(!KKQD_QIAN_LIMIT_IN)
  1441. KKQD_XiaQieStep = 8;
  1442. else
  1443. KKQD_SetAlarmCode(KKQD_QIAN_LIMIT_ALARM);
  1444. }
  1445. else if((dwTickCount >= KKQD_XiaQieDelay))
  1446. {
  1447. if(cTuiFangKuaiCnt < KKQD_PARAM_TFK_NUMBER)
  1448. {
  1449. KKQD_TFK_VAVLE = 0;
  1450. cTuiFangKuaiCnt++;
  1451. KKQD_XiaQieDelay = dwTickCount + 500;
  1452. KKQD_XiaQieStep = 100;
  1453. }
  1454. else
  1455. KKQD_SetAlarmCode(KKQD_GZ_ALARM);
  1456. }
  1457. break;
  1458. case 100:
  1459. if((dwTickCount >= KKQD_XiaQieDelay))
  1460. {
  1461. KKQD_XiaQieStep = 5;
  1462. }
  1463. break;
  1464. case 8://上下模同时输出
  1465. if(KKQD_GOUZHEN_IN)
  1466. {
  1467. if(KKQD_SHANG_MU_ORIGIN_IN)
  1468. {
  1469. if(dwTickCount >= KKQD_XiaQieDelay)
  1470. {
  1471. KKQD_SM_VAVLE = 1;
  1472. if(KKQD_PARAM_XM_ENABLE == 0) //配置下模动
  1473. KKQD_XM_VAVLE = 1;
  1474. KKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1475. KKQD_XiaQieStep = 9;
  1476. }
  1477. }
  1478. else if(dwTickCount >= (KKQD_XiaQieDelay+3000))
  1479. {
  1480. KKQD_SetAlarmCode(KKQD_SM_YUANWEI);
  1481. }
  1482. }
  1483. else
  1484. {
  1485. KKQD_SetAlarmCode(KKQD_GZ_ALARM);
  1486. }
  1487. break;
  1488. case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
  1489. if(KKQD_SHANG_MU_LIMIT_IN && (KKQD_XIA_MU_LIMIT_IN || KKQD_PARAM_XM_ENABLE) && ((KKQD_PARAM_TIAOSHI_MODE && KKQD_bTS) || (KKQD_PARAM_TIAOSHI_MODE == 0)) )
  1490. {
  1491. if(!KKQD_PARAM_CS_MODE) //无超声配置
  1492. {
  1493. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_DELAYBACK_SM; //
  1494. KKQD_XiaQieStep = 12;
  1495. }
  1496. else
  1497. {
  1498. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_DELAY_CS; //
  1499. KKQD_XiaQieStep = 10;
  1500. }
  1501. }
  1502. else if(dwTickCount >= KKQD_XiaQieDelay)
  1503. {
  1504. if(!KKQD_SHANG_MU_LIMIT_IN)KKQD_SetAlarmCode(KKQD_SM_DAOWEI);
  1505. else KKQD_SetAlarmCode(KKQD_XM_DAOWEI);
  1506. }
  1507. break;
  1508. case 10:
  1509. if(dwTickCount >= KKQD_XiaQieDelay)
  1510. {
  1511. KKQD_CS_OUT = 1;
  1512. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_CS_TIME; //
  1513. KKQD_XiaQieStep = 11;
  1514. }
  1515. break;
  1516. case 11:
  1517. if(dwTickCount >= KKQD_XiaQieDelay)
  1518. {
  1519. KKQD_CS_OUT = 0;
  1520. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_CS_COLD_TIME; //
  1521. KKQD_XiaQieStep = 12;
  1522. }
  1523. break;
  1524. case 12:
  1525. if(dwTickCount >= KKQD_XiaQieDelay)
  1526. {
  1527. KKQD_SM_VAVLE = 0;
  1528. if(KKQD_PARAM_XM_ENABLE == 0) //配置下模动
  1529. KKQD_XM_VAVLE = 0;
  1530. KKQD_DGLG_VAVLE = 0; //顶过链杆关
  1531. KKQD_TFK_VAVLE = 0;
  1532. // KKQD_GZ_VAVLE = 0
  1533. KKQD_XiaQieStep = 13;
  1534. }//
  1535. break;
  1536. case 13:
  1537. KKQD_GZ_VAVLE = 0;
  1538. KKQD_XiaQieDelay = dwTickCount + KKQD_PARAM_TTFK_TIME;
  1539. KKQD_XiaQieStep = 14;
  1540. break;
  1541. case 14:
  1542. if(dwTickCount >= KKQD_XiaQieDelay)
  1543. {
  1544. KKQD_TFK_VAVLE = 1;
  1545. }
  1546. if(!KKQD_SHANG_MU_LIMIT_IN)
  1547. {
  1548. //启动推链(送链)
  1549. if((KKQD_TuiLianStep == 0) && !KKQD_TL_VAVLE)
  1550. KKQD_TuiLianStep = 1;
  1551. }
  1552. if(!KKQD_SHANG_MU_LIMIT_IN && (!KKQD_XIA_MU_LIMIT_IN || KKQD_PARAM_XM_ENABLE) && KKQD_TFK_VAVLE)
  1553. {
  1554. KKQD_XiaQieStep = 0;
  1555. }
  1556. else if(dwTickCount >= (KKQD_XiaQieDelay+3000))
  1557. {
  1558. KKQD_SetAlarmCode(KKQD_SM_YUANWEI);
  1559. }
  1560. break;
  1561. }
  1562. }
  1563. void KK_QueDuan_TuiLianAction(void)
  1564. {
  1565. if(KKQD_PARAM_XM_ENABLE == 0)
  1566. {
  1567. KKQD_TuiLianStep = 0;
  1568. }
  1569. else
  1570. {
  1571. switch(KKQD_TuiLianStep)
  1572. {
  1573. case 1:
  1574. KKQD_TuiLianStep = 2;
  1575. break;
  1576. case 2:
  1577. KKQD_TLDelay = dwTickCount + KKQD_PARAM_YD_DELAY;
  1578. KKQD_TuiLianStep = 3;
  1579. break;
  1580. case 3:
  1581. if(!KKQD_SM_VAVLE && !KKQD_SHANG_MU_LIMIT_IN)//dwTickCount >= KKQD_TLDelay)
  1582. {
  1583. KKQD_TL_VAVLE = 1;
  1584. // KKQD_TFK_VAVLE = 0;
  1585. // if(!bRunning)KKQD_TFK_VAVLE = 1;
  1586. KKQD_TLDelay = dwTickCount + KKQD_PARAM_TL_DELAY;
  1587. KKQD_TuiLianStep = 4;
  1588. }
  1589. break;
  1590. case 4:
  1591. if(dwTickCount >= KKQD_TLDelay)
  1592. {
  1593. KKQD_TuiLianStep = 0;
  1594. }
  1595. break;
  1596. case 10:
  1597. KKQD_TuiLianStep = 11;
  1598. break;
  1599. case 11:
  1600. if(!Y_DRV)
  1601. {
  1602. {
  1603. KKQD_TuiLianStep = 0;
  1604. }
  1605. }
  1606. break;
  1607. }
  1608. }
  1609. }
  1610. //切断动作
  1611. void KK_QueDuan_XiaQue(void)
  1612. {
  1613. KK_QueDuan_XiaQue_KK();
  1614. }
  1615. #endif