HHQueDuanJi.c 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264
  1. #include "global.h"
  2. #if HAI_HUA_MACHINE ==1
  3. void QueDuan_AlarmProtect(void);
  4. void QueDuan_ManualAction(void);
  5. void QueDuan_AutoAction(void);
  6. void QueDuan_StepCheckStart(void);
  7. void QueDuan_XiaQue(void);
  8. void QueDuan_Motor(void);
  9. void QueDuan_YuanDianAction(void);
  10. void QueDuan_TuiLianAction(void);
  11. void QueDuan_ExtiActionX31(void);
  12. void QueDuan_BingLian(void);
  13. void QD_TuiDaiAction(void);
  14. static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
  15. static long save_limit_pos,cRealPos;
  16. static long dwSaveLength;
  17. unsigned char cCheckLianFlg = 0;
  18. unsigned char cCheckLianFlgEN = 0;
  19. unsigned char cGoLimitEn = 0;
  20. short *length_buffer;
  21. void QueDuan_ExtiActionX31(void)
  22. {
  23. cCheckLianFlg = 1;
  24. }
  25. void QD_SetAlarmCode(unsigned alarm_code)
  26. {
  27. SetAlarmCode(QD_ALARM_ADDR,alarm_code);
  28. bAlarmStop = 1;
  29. }
  30. void QueDuan_InitAction(void)
  31. {
  32. float length_buff,pulse_buff;
  33. length_buff = QD_PARAM_CYCLE_LENGTH;
  34. pulse_buff = QD_PARAM_CYCLE_PULSE;
  35. XGearRatio = pulse_buff/length_buff;
  36. QD_SZ_OUT = 1;
  37. }
  38. void QueDuan_Action(void)
  39. {
  40. QueDuan_AlarmProtect();
  41. QueDuan_Motor();
  42. QueDuan_XiaQue();
  43. QueDuan_ManualAction();
  44. QueDuan_TuiLianAction();
  45. QueDuan_BingLian();
  46. QueDuan_AutoAction();
  47. QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
  48. }
  49. //手动动作
  50. void QueDuan_ManualAction(void)
  51. {
  52. if(bRunning == 0)
  53. {
  54. cGoLimitEn = 0;
  55. if(QD_bClearTotal) //切断计数清零
  56. {
  57. QD_bClearTotal = 0;
  58. ClrcToTal(QD_TOTAL_ADDR);
  59. }
  60. if(QD_bClearNowTotal)
  61. {
  62. QD_bClearNowTotal = 0;
  63. QD_PARAM_NOW_CNT = 0;
  64. }
  65. if(QD_bXiaQie)
  66. {
  67. QD_bXiaQie = 0;
  68. if((QD_XiaQieStep == 0) && !QD_TL_VAVLE)
  69. {
  70. QD_XiaQieStep = 1;
  71. }
  72. }
  73. if(QD_bQianDianDW)
  74. {
  75. QD_bQianDianDW = 0;
  76. if(QD_MotorStep == 0)
  77. {
  78. QD_MotorStep = 61;
  79. cZipCnt = 0;
  80. }
  81. }
  82. if(QD_bTL)
  83. {
  84. QD_bTL = 0;
  85. if(QD_TL_VAVLE)
  86. {
  87. QD_TL_VAVLE = 0;
  88. }
  89. else if(!QD_GZ_VAVLE && !QD_SM_VAVLE)
  90. {
  91. QD_TL_VAVLE = ~QD_TL_VAVLE;
  92. }
  93. }
  94. // if(!Y_DRV)QD_bTL = 0;
  95. if(QD_bYD)
  96. {
  97. QD_bYD = 0;
  98. QD_YD_VAVLE = ~QD_YD_VAVLE;
  99. }
  100. if(QD_bGZ)
  101. {
  102. QD_bGZ = 0;
  103. QD_GZ_VAVLE = ~QD_GZ_VAVLE;
  104. }
  105. if(QD_bJD)
  106. {
  107. QD_bJD = 0;
  108. QD_JD_VAVLE = ~QD_JD_VAVLE;
  109. }
  110. if(QD_bXM)
  111. {
  112. QD_bXM = 0;
  113. QD_XM_VAVLE = ~QD_XM_VAVLE;
  114. if(!QD_XM_VAVLE)QD_GZ_VAVLE = 0;
  115. }
  116. if(QD_bSM)
  117. {
  118. QD_bSM = 0;
  119. if(QD_SM_VAVLE)
  120. QD_SM_VAVLE = 0;
  121. else if(!QD_TL_VAVLE)
  122. QD_SM_VAVLE = 1;
  123. }
  124. //推方块
  125. if(QD_bTFK)
  126. {
  127. QD_bTFK = 0;
  128. QD_TFK_VAVLE = ~QD_TFK_VAVLE;
  129. }
  130. //台面电机
  131. if(QD_bTB)
  132. {
  133. QD_bTB = 0;
  134. QD_TABLE_VAVLE = ~QD_TABLE_VAVLE;
  135. }
  136. // if(QD_bYBD)
  137. // / {
  138. // QD_bYBD = 0;
  139. // QD_YBD_VAVLE = ~QD_YBD_VAVLE;
  140. // }
  141. if(QD_bTestCS)
  142. {
  143. QD_bTestCS = 0;
  144. QD_CS_OUT = 1;
  145. QD_CSDelay = dwTickCount + QD_PARAM_CS_TIME;
  146. }
  147. if(QD_bBL)//合链
  148. {
  149. QD_bBL = 0;
  150. QD_BL_VAVLE = ~QD_BL_VAVLE;
  151. }
  152. if(QD_bHL) //护链,双开用
  153. {
  154. QD_bHL = 0;
  155. QD_HL_VAVLE = ~QD_HL_VAVLE;
  156. }
  157. if(QD_bYX)
  158. {
  159. QD_bYX = 0;
  160. QD_YX_VAVLE = ~QD_YX_VAVLE;
  161. }
  162. if(QD_XiaQieStep == 0)
  163. {
  164. if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0;
  165. }
  166. //电机控制
  167. if(QD_bGoMotor && !QD_QIAN_LIMIT_IN)
  168. {
  169. QD_SZ_OUT = 0;
  170. QD_JZ_DIR = QD_YDIR_N;
  171. if(!X_DRV)
  172. // X轴 运行速度 启动速度 加速度 减速度
  173. AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED/3,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
  174. }
  175. if(QD_bBackMotor) //后退限位已经取消
  176. {
  177. QD_SZ_OUT = 0;
  178. QD_JZ_DIR = QD_YDIR_P;
  179. if(!X_DRV)
  180. // X轴 运行速度 启动速度 加速度 减速度
  181. AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED/3,QD_DIR_P,QD_PARAM_GO_LOW_SPEED/3,15,15);
  182. }
  183. if(!QD_bGoMotor && !QD_bBackMotor && (QD_MotorStep == 0))
  184. {
  185. if(X_DRV)AxisDecStop(X_AXIS);
  186. }
  187. if(QD_QIAN_LIMIT_IN && (QD_MotorStep == 0) && !QD_bBackMotor &&(QD_AutoStep == 0))
  188. {
  189. if(X_DRV)AxisEgmStop(X_AXIS);
  190. }
  191. }
  192. }
  193. void QueDuan_AlarmProtect(void)
  194. {
  195. cRealPos = GetPos(X_AXIS);
  196. if(!bRunning)
  197. {
  198. ;
  199. //
  200. #if 0
  201. if(QD_BACK_LIMIT_IN_UP)
  202. {
  203. if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
  204. {
  205. QD_bBackMotor = 0;
  206. AxisDecStop(X_AXIS);
  207. QD_JD_VAVLE = 0;
  208. QD_SetAlarmCode(QD_BACK_ALARM);
  209. }
  210. }
  211. #endif
  212. }
  213. else
  214. {
  215. if((cRealPos > QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH > 3000)
  216. && (cGoLimitEn != 0))
  217. {
  218. AxisEgmStop(X_AXIS);
  219. QD_JD_VAVLE = 0;
  220. QD_SetAlarmCode(QD_BACK_ALARM);
  221. }
  222. }
  223. }
  224. void QueDuan_AutoAction(void)
  225. {
  226. //台面电机定时关掉
  227. if(bRunning)
  228. {
  229. if(dwTickCount >= QD_TBDelay)
  230. QD_TABLE_VAVLE = 0;
  231. switch(QD_AutoStep)
  232. {
  233. case 1:
  234. if(dwTickCount >= QD_AutoDelay)
  235. {
  236. QD_AutoStep = 2;
  237. if(QD_MotorStep == 0)
  238. {
  239. QD_MotorStep = 61; //前点定位
  240. }
  241. cGoLimitEn = 0;
  242. }
  243. break;
  244. case 2:
  245. if(QD_MotorStep == 0)
  246. {
  247. QD_MotorStep = 30;
  248. QD_AutoStep = 3;
  249. cGoLimitEn = 1;
  250. }
  251. break;
  252. case 3:
  253. if(QD_MotorStep == 0)
  254. {
  255. if(QD_SAFE_IN)
  256. {
  257. bStop = 1;
  258. }
  259. else
  260. {
  261. if(QD_XiaQieStep == 0)
  262. QD_XiaQieStep = 1;
  263. QD_AutoStep = 4;
  264. }
  265. }
  266. break;
  267. case 4:
  268. // if((QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI) || (QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI))
  269. // {
  270. // 闭口
  271. if((QD_XiaQieStep == 0) || ((QD_XiaQieStep == 6) && QD_KB_MODE)|| ((QD_XiaQieStep == 13) && (QD_KB_MODE == 0)))// && !QD_SHANG_MU_LIMIT_IN)
  272. {
  273. if(QD_MotorStep == 0)
  274. {
  275. cGoLimitEn=0;
  276. QD_MotorStep = 40; //切完后退
  277. }
  278. QD_AutoStep = 5;
  279. }
  280. /*
  281. // }
  282. // else
  283. // {
  284. if(((QD_XiaQieStep == 0) || (QD_XiaQieStep == 13)) && !QD_SHANG_MU_LIMIT_IN && !QD_XIA_MU_LIMIT_IN)
  285. {
  286. if(QD_MotorStep == 0)
  287. {
  288. QD_MotorStep = 40; //切完后退
  289. QD_AutoStep = 5;
  290. }
  291. }
  292. }
  293. */
  294. break;
  295. case 5:
  296. if(QD_MotorStep == 0)
  297. {
  298. cZipCnt++;
  299. QD_PARAM_NOW_CNT++;
  300. cTableCnt++;
  301. AddToTal(QD_TOTAL_ADDR);
  302. AddToTal(CT_WORKTOTAL_ADDR);
  303. CalProSP(QD_PROSPEED_ADDR);
  304. if(cTableCnt >= QD_PARAM_TABLE_NUM)
  305. {
  306. cTableCnt = 0;
  307. QD_TABLE_VAVLE = 1;
  308. QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME;
  309. }
  310. if(/*(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) ||*/ SingOneFlg)
  311. {
  312. /*
  313. if((QD_PARAM_SET_TOTAL == 0) && !SingOneFlg)
  314. {
  315. QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
  316. QD_AutoStep = 1;
  317. }
  318. else
  319. */
  320. {
  321. bRunning = 0;
  322. QD_AutoStep = 0;
  323. SingOneFlg = 0;
  324. }
  325. // if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
  326. }
  327. else
  328. {
  329. QD_AutoStep = 1;
  330. if((QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU) && (QD_PARAM_ZHA_SHU > 0))
  331. {
  332. QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME;
  333. QD_PARAM_NOW_CNT = 0;
  334. if(QD_PARAM_ZS_STOP_TIME == 0)
  335. {
  336. bRunning = 0;
  337. QD_AutoStep = 0;
  338. SingOneFlg = 0;
  339. QD_SetAlarmCode(QD_TOTAL_ALARM);
  340. }
  341. }
  342. else
  343. QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
  344. }
  345. }
  346. break;
  347. }
  348. }
  349. }
  350. void QueDuan_StepCheckStart(void)
  351. {
  352. // 启动
  353. if((START_IN_UP) || bStart || QD_bSingle)
  354. {
  355. bStart = 0;
  356. if(!bRunning && (QD_AutoStep == 0))
  357. {
  358. if(QD_XIA_MU_LIMIT_IN && !QD_PARAM_XM_ENABLE)QD_SetAlarmCode(QD_XM_DAOWEI);
  359. // else if(GetAlarmCode(QD_ALARM_ADDR) != 0);
  360. //else if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
  361. // else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM);
  362. else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM);
  363. else
  364. {
  365. bRunning = 1;
  366. QD_AutoStep = 1;
  367. if(QD_bSingle)
  368. SingOneFlg= 1;
  369. cZipCnt = 0;
  370. cTuiFangKuaiCnt = 0;
  371. QD_BL_VAVLE = 0; //并链关
  372. QD_DGLG_VAVLE = 0; //顶过链杆关
  373. SetAlarmCode(QD_ALARM_ADDR,0);
  374. }
  375. }
  376. QD_bSingle = 0;
  377. }
  378. //停止
  379. if(STOP_IN_UP || bStop)
  380. {
  381. bStop = 0;
  382. if(bRunning)
  383. {
  384. QD_AutoDelay = dwTickCount;
  385. QD_MotorDelay = dwTickCount;
  386. QD_XiaQieDelay = dwTickCount;
  387. QD_KaDaiDelay = dwTickCount;
  388. QD_CSDelay = dwTickCount;
  389. QD_TBDelay = dwTickCount;
  390. QD_TFKDelay = dwTickCount;
  391. QD_TLDelay = dwTickCount;
  392. dwTickCount = QD_TBDelay;
  393. SingOneFlg = 0;
  394. QD_JD_VAVLE = 0;
  395. QD_SM_VAVLE = 0;
  396. QD_XM_VAVLE = 0;
  397. QD_YD_VAVLE = 0;
  398. QD_TFK_VAVLE= 0;
  399. QD_TL_VAVLE = 0;
  400. QD_HL_VAVLE = 0;
  401. QD_CS_OUT = 0;
  402. QD_XiaQieStep = 0;
  403. QD_MotorStep = 0;
  404. QD_TuiLianStep = 0;
  405. //QD_SZ_OUT = 1;
  406. QD_GZ_VAVLE = 0;
  407. QD_TABLE_VAVLE = 0;
  408. QD_DGLG_VAVLE = 0; //顶过链杆关
  409. AxisDecStop(X_AXIS);
  410. QD_BinLianStep = 0;
  411. QD_BL_VAVLE = 0;
  412. user_datas[121] = 0;
  413. user_datas[122] = 0;
  414. SetAlarmCode(QD_ALARM_ADDR,0);
  415. }
  416. else
  417. {
  418. QD_AutoDelay = dwTickCount;
  419. QD_MotorDelay = dwTickCount;
  420. QD_XiaQieDelay = dwTickCount;
  421. QD_KaDaiDelay = dwTickCount;
  422. QD_CSDelay = dwTickCount;
  423. QD_TBDelay = dwTickCount;
  424. QD_TFKDelay = dwTickCount;
  425. QD_TLDelay = dwTickCount;
  426. dwTickCount = QD_TBDelay;
  427. SingOneFlg = 0;
  428. QD_JD_VAVLE = 0;
  429. QD_SM_VAVLE = 0;
  430. QD_XM_VAVLE = 0;
  431. QD_YD_VAVLE = 0;
  432. QD_TFK_VAVLE= 0;
  433. QD_YX_VAVLE = 0;
  434. QD_HL_VAVLE = 0;
  435. QD_TL_VAVLE = 0;
  436. QD_DGLG_VAVLE = 0; //顶过链杆关
  437. QD_CS_OUT = 0;
  438. QD_XiaQieStep = 0;
  439. QD_MotorStep = 0;
  440. QD_TuiLianStep = 0;
  441. QD_SZ_OUT = 1;
  442. QD_GZ_VAVLE = 0;
  443. QD_TABLE_VAVLE = 0;
  444. AxisDecStop(X_AXIS);
  445. QD_BinLianStep = 0;
  446. QD_BL_VAVLE = 0;
  447. SetAlarmCode(QD_ALARM_ADDR,0);
  448. }
  449. bRunning = 0;
  450. QD_XiaQieStep = 0;
  451. QD_AutoStep = 0;
  452. QD_MotorStep = 0;
  453. QD_TuiLianStep = 0;
  454. }
  455. if(bAlarmStop)
  456. {
  457. bAlarmStop = 0;
  458. QD_XiaQieStep = 0;
  459. QD_AutoStep = 0;
  460. QD_MotorStep = 0;
  461. QD_TuiLianStep = 0;
  462. QD_XiaQieStep = 0;
  463. QD_MotorStep = 0;
  464. QD_TuiLianStep = 0;
  465. QD_AutoDelay = dwTickCount;
  466. QD_MotorDelay = dwTickCount;
  467. QD_XiaQieDelay = dwTickCount;
  468. QD_KaDaiDelay = dwTickCount;
  469. QD_CSDelay = dwTickCount;
  470. QD_TBDelay = dwTickCount;
  471. QD_TFKDelay = dwTickCount;
  472. QD_TLDelay = dwTickCount;
  473. SingOneFlg = 0;
  474. bRunning = 0;
  475. AxisDecStop(X_AXIS);
  476. dwTickCount = QD_TBDelay;
  477. QD_TABLE_VAVLE = 0;
  478. QD_JD_VAVLE=0;
  479. QD_GZ_VAVLE=0;
  480. }
  481. }
  482. //记忆长度模式误差检测
  483. void QueDuan_CheckLength(long zip_length)
  484. {
  485. static long start_dist;
  486. switch(QD_CheckLengthStep)
  487. {
  488. case 0:break;
  489. case 1:
  490. start_dist = cRealPos;
  491. dwSaveLength = 0;
  492. QD_CheckLengthStep = 2;
  493. break;
  494. case 2:
  495. if(QD_GUO_LIAN_IN_DW){
  496. dwSaveLength = cRealPos - start_dist;
  497. // user_datas[127] = cRealPos;
  498. }
  499. break;
  500. }
  501. }
  502. #if !QD_KB_MODE //开口
  503. //开口切专用
  504. //30步开始后拉开始,分解4种工作模式
  505. //40步开始用切断后拉动作
  506. //60步开始为前方向,开闭口一样
  507. void QueDuan_Motor_KK(void)
  508. {
  509. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  510. unsigned short ch;
  511. user_datas[121]= QD_MotorStep;
  512. user_datas[122]= length_buff;
  513. user_datas[123] = cRealPos;
  514. user_datas[124] = GetCurSpeed(X_AXIS);
  515. user_datas[125] = QD_AutoStep;
  516. user_datas[126] = QD_XiaQieStep;
  517. // user_datas[127] = QD_XiaQieStep;
  518. QueDuan_CheckLength(length_buff);
  519. switch(QD_MotorStep)
  520. {
  521. case 30:
  522. switch(QD_PARAM_BACK_MODE) //开口分四种模式
  523. {
  524. case 0: //单数控模式
  525. QD_MotorStep = 310; //每种模式留20步
  526. QD_DGLG_VAVLE = 1; //顶过链杆关
  527. break;
  528. case 1://单感应模式
  529. QD_MotorStep = 330; //每种模式留20步
  530. break;
  531. case 2: //先感应后数控模式+检测
  532. QD_MotorStep = 350; //每种模式留20步
  533. break;
  534. default: //数控模式+过链检测长度
  535. QD_MotorStep = 370; //每种模式留20步
  536. break;
  537. }
  538. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  539. break;
  540. //310步到315步为数控模式
  541. case 310:
  542. QD_MotorStep = 311;
  543. QD_JZ_DIR = QD_YDIR_P;
  544. if(QD_PARAM_BL_ENABLE)
  545. QD_BinLianStep = 1; //并链起动
  546. break;
  547. case 311:
  548. if(dwTickCount >= QD_MotorDelay)
  549. {
  550. length_buffer = &QD_PARAM_OFFSET_LENGTH;
  551. //李永庆代码
  552. SetDir(X_AXIS, QD_DIR_N);
  553. //两段速度移动距离 拉链长度+慢速长度停止
  554. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  555. AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
  556. back_buff = cRealPos;
  557. gou_zhen_buff = cRealPos;
  558. save_buff = cRealPos;
  559. SetDir(X_AXIS,QD_DIR_P);
  560. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  561. QD_MotorStep = 312;
  562. }
  563. break;
  564. case 312:
  565. //勾针提前输出 ,争取时间推方块
  566. if (!QD_GZ_VAVLE && (cRealPos >= (QD_PARAM_ZIPPER_LENGTH- 230)))
  567. QD_GZ_VAVLE = 1;
  568. if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
  569. {
  570. QD_MotorStep = 313;
  571. }
  572. else if(cRealPos >= (QD_PARAM_ZIPPER_LENGTH + (*length_buffer) + QD_PARAM_ERROR_LENGTH))
  573. {
  574. QD_SetAlarmCode(QD_GZ_ALARM);
  575. }
  576. break;
  577. case 313:
  578. if(!QD_GZ_VAVLE && ((cRealPos) > (QD_PARAM_ZIPPER_LENGTH - 230)))
  579. QD_GZ_VAVLE = 1;
  580. if(!X_DRV)
  581. {
  582. AxisEgmStop(X_AXIS);
  583. QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  584. QD_MotorStep = 314;
  585. QD_BL_VAVLE = 0; //停止时并链一定要打开
  586. if((QD_PARAM_BACK_MODE == 2) && !QD_DGLG_VAVLE) //模式2,先检测长度后数控
  587. {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
  588. if(cZipCnt > 1) //长度检测
  589. {
  590. if(QD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  591. {
  592. if(((dwSaveLength + QD_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + QD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
  593. {
  594. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);//拉链变长,对比警告
  595. }
  596. else if((dwSaveLength + QD_PARAM_MOTOR_DELAY_LENGTH+ QD_PARAM_ERROR_LENGTH) < length_buff)
  597. {
  598. QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM); ////拉链变短
  599. }
  600. QD_CheckLengthStep = 0;
  601. }
  602. }
  603. }
  604. }
  605. break;
  606. case 314:
  607. if(!X_DRV && (dwTickCount >= QD_MotorDelay)) //数控到停止
  608. {
  609. QD_MotorStep = 0;
  610. QD_TFK_VAVLE = 1; //推方块输出
  611. }
  612. break;
  613. //330步到349步单感应模式
  614. case 330:
  615. back_buff = cRealPos;
  616. gou_zhen_buff = cRealPos;
  617. QD_MotorStep = 331;
  618. QD_JZ_DIR = QD_YDIR_P;
  619. user_datas[127] = 0;
  620. break;
  621. case 331:
  622. if(dwTickCount >= QD_MotorDelay)
  623. {
  624. QD_MotorStep = 332;
  625. if(cZipCnt < 2)
  626. {
  627. if(QD_PARAM_BL_ENABLE)
  628. QD_BinLianStep = 10; //并链起动
  629. //第一条都是过链感应,后拉速度减半//原来QD_PARAM_CHECK_BACK_HSPEED/2
  630. // X轴 运行速度 启动速度 加速度 减速度
  631. AxisContinueMoveAcc(X_AXIS,9000,QD_DIR_P,QD_PARAM_START_SPEED,8,13);
  632. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  633. // AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
  634. }
  635. else
  636. {
  637. if(QD_PARAM_BL_ENABLE)
  638. QD_BinLianStep = 1; //并链起动
  639. //因为每条都是过链感应,所以直接运行检测模式后拉速度
  640. // X轴 运行速度 启动速度 加速度 减速度
  641. AxisContinueMoveAcc(X_AXIS,QD_PARAM_CHECK_BACK_HSPEED,QD_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  642. }
  643. }
  644. break;
  645. case 332:
  646. if(cZipCnt > 1) //第二条开始数控降速
  647. {
  648. if((cRealPos + QD_PARAM_BACK_LOW_SPEED_LENGTH + 600)>= length_buff)
  649. {
  650. CancelPmoveState(X_AXIS); //长度模式去掉
  651. AxisChangeSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  652. user_datas[127] = cRealPos;
  653. QD_MotorStep = 334; //到检测定位
  654. }
  655. if(QD_GUO_LIAN_IN_DW) //重新到链上
  656. {
  657. CancelPmoveState(X_AXIS);
  658. AxisChangeSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  659. gou_zhen_buff = cRealPos;
  660. QD_MotorStep = 335; //到检测定位
  661. }
  662. //
  663. // if((cRealPos >= (QD_PARAM_BACK_LOW_SPEED_LENGTH + 60)) && QD_GUO_LIAN_IN)
  664. // {
  665. // }
  666. }
  667. else //第一条工作
  668. {
  669. if(QD_GUO_LIAN_IN_UP)
  670. {
  671. checkdelay_buff = cRealPos;
  672. MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  673. QD_MotorDelay = dwTickCount + 0;//QD_PARAM_DELAY_XM;
  674. QD_MotorStep = 333;
  675. }
  676. else if((cRealPos >= QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
  677. {
  678. // QD_SetAlarmCode(QD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
  679. }
  680. }
  681. break;
  682. case 333:
  683. if(dwTickCount >= QD_MotorDelay)
  684. {
  685. QD_MotorStep = 334;
  686. }
  687. break;
  688. case 334:
  689. if(QD_GUO_LIAN_IN_DW) //下降沿,定位长度
  690. {
  691. //滤波有待调试
  692. // if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && (QD_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
  693. // {
  694. if(QD_GUO_LIAN_IN_DW)
  695. {
  696. gou_zhen_buff = cRealPos;
  697. QD_MotorStep = 335;
  698. }
  699. // }
  700. }
  701. break;
  702. case 335:
  703. if(QD_GUO_LIAN_IN_DW)
  704. {
  705. gou_zhen_buff = cRealPos;
  706. }
  707. //在空们都把延时清零
  708. if(QD_GUO_LIAN_IN)
  709. {
  710. gou_zhen_buff = cRealPos;
  711. }
  712. //定位停止
  713. if(((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) && !QD_GUO_LIAN_IN)
  714. {
  715. AxisEgmStop(X_AXIS);
  716. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  717. QD_MotorStep = 336;
  718. QD_GZ_VAVLE = 1;
  719. }
  720. break;
  721. case 336:
  722. if(!X_DRV)
  723. {
  724. QD_GZ_VAVLE = 1;
  725. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  726. // QD_XM_VAVLE = 1;
  727. QD_MotorStep = 337;
  728. }
  729. break;
  730. case 337:
  731. if(1)
  732. {
  733. QD_MotorStep = 338;
  734. QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  735. }
  736. // else if(dwTickCount >= QD_MotorDelay) QD_SetAlarmCode(QD_XM_DAOWEI);
  737. break;
  738. case 338:
  739. if((dwTickCount >= QD_MotorDelay))
  740. {
  741. QD_TFK_VAVLE = 1; //推方块输出
  742. QD_MotorStep = 339;
  743. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  744. }
  745. break;
  746. case 339:
  747. if(cZipCnt == 1)
  748. {
  749. length_buff = cRealPos - save_buff;
  750. SetData32bits(QD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
  751. }
  752. else if(cZipCnt > 1) //长度检测
  753. {
  754. if(QD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  755. {
  756. if(cRealPos >= length_buff) //拉链变长,对比警告
  757. {
  758. if((cRealPos - save_buff) > (length_buff+QD_PARAM_ERROR_LENGTH))
  759. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  760. }
  761. else //拉链变短
  762. {
  763. if((cRealPos - save_buff + QD_PARAM_ERROR_LENGTH) < (length_buff))
  764. QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
  765. }
  766. }
  767. }
  768. QD_MotorStep = 0;
  769. break;
  770. //350步到369步单感应模式
  771. case 350:
  772. back_buff = cRealPos;
  773. gou_zhen_buff = cRealPos;
  774. QD_MotorStep = 351;
  775. QD_JZ_DIR = QD_YDIR_P;
  776. break;
  777. case 351:
  778. if(dwTickCount >= QD_MotorDelay)
  779. {
  780. QD_MotorStep = 352;
  781. //第一,二条都是过链感应,测量长度
  782. if(cZipCnt < 2)
  783. {
  784. if(QD_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
  785. QD_BinLianStep = 10; //并链起动
  786. QD_DGLG_VAVLE = 0; //顶过链杆关
  787. // X轴 运行速度 启动速度 加速度 减速度
  788. AxisContinueMoveAcc(X_AXIS,9000,QD_DIR_P,QD_PARAM_START_SPEED,8,12);
  789. }
  790. else
  791. {
  792. if(QD_PARAM_BL_ENABLE)
  793. QD_BinLianStep = 1; //并链起动
  794. QD_DGLG_VAVLE = 1; //顶过链杆关
  795. QD_CheckLengthStep = 1; //长度检测,第3条才有对比
  796. //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
  797. QD_MotorStep = 311;
  798. }
  799. }
  800. break;
  801. case 352:
  802. //前两条都按最低速度工作
  803. if(QD_GUO_LIAN_IN_UP)
  804. {
  805. checkdelay_buff = cRealPos;
  806. MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  807. QD_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波
  808. QD_MotorStep = 353;
  809. }
  810. else if((cRealPos >= QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
  811. {
  812. // QD_SetAlarmCode(QD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
  813. }
  814. break;
  815. case 353:
  816. if(dwTickCount >= QD_MotorDelay)
  817. {
  818. QD_MotorStep = 354;
  819. }
  820. break;
  821. case 354:
  822. if(QD_GUO_LIAN_IN_DW) //下降沿,定位长度
  823. {
  824. //滤波有待调试
  825. // if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && (QD_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
  826. // {
  827. if(QD_GUO_LIAN_IN_DW)
  828. {
  829. gou_zhen_buff = cRealPos;
  830. QD_MotorStep = 355;
  831. }
  832. // }
  833. }
  834. break;
  835. case 355:
  836. if(QD_GUO_LIAN_IN_DW)
  837. {
  838. gou_zhen_buff = cRealPos;
  839. }
  840. //在空们都把延时清零
  841. if(QD_GUO_LIAN_IN)
  842. {
  843. gou_zhen_buff = cRealPos;
  844. }
  845. //定位停止
  846. if(((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) && !QD_GUO_LIAN_IN)
  847. {
  848. AxisEgmStop(X_AXIS);
  849. QD_MotorStep = 356;
  850. QD_GZ_VAVLE = 1;
  851. }
  852. break;
  853. case 356:
  854. if(!X_DRV)
  855. {
  856. QD_GZ_VAVLE = 1;
  857. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  858. // QD_XM_VAVLE = 1;
  859. QD_MotorStep = 357;
  860. }
  861. break;
  862. case 357:
  863. if(1)
  864. {
  865. QD_MotorStep = 358;
  866. QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  867. }
  868. break;
  869. case 358:
  870. if((dwTickCount >= QD_MotorDelay))
  871. {
  872. QD_TFK_VAVLE = 1; //推方块输出
  873. QD_MotorStep = 359;
  874. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  875. }
  876. break;
  877. case 359:
  878. if(cZipCnt == 1)
  879. {
  880. length_buff = cRealPos - save_buff;
  881. //测量出来长度
  882. SetData32bits(QD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
  883. }
  884. QD_MotorStep = 0;
  885. break;
  886. //370步到389步为数控模式
  887. case 370:
  888. QD_MotorStep = 371;
  889. QD_JZ_DIR = QD_YDIR_P;
  890. if(QD_PARAM_BL_ENABLE)
  891. QD_BinLianStep = 1; //并链起动
  892. QD_CheckLengthStep = 1; //长度检测开始
  893. break;
  894. case 371:
  895. if(dwTickCount >= QD_MotorDelay)
  896. {
  897. back_buff = cRealPos;
  898. gou_zhen_buff = cRealPos;
  899. save_buff = cRealPos;
  900. //李永庆代码
  901. SetDir(X_AXIS, QD_DIR_N);
  902. //两段速度移动距离 拉链长度+慢速长度停止
  903. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  904. AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
  905. SetDir(X_AXIS,QD_DIR_P);
  906. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  907. QD_MotorStep = 372;
  908. }
  909. break;
  910. case 372:
  911. //勾针提前输出 ,争取时间推方块
  912. if (!QD_GZ_VAVLE && (cRealPos >= (QD_PARAM_ZIPPER_LENGTH - 230)))
  913. QD_GZ_VAVLE = 1;
  914. if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
  915. {
  916. QD_MotorStep = 373;
  917. }
  918. break;
  919. case 373:
  920. if(!QD_GZ_VAVLE && ((cRealPos) > (QD_PARAM_ZIPPER_LENGTH - 230)))
  921. QD_GZ_VAVLE = 1;
  922. if(!X_DRV)
  923. {
  924. AxisEgmStop(X_AXIS);
  925. QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  926. QD_MotorStep = 374;
  927. QD_BL_VAVLE = 0; //停止时并链一定要打开
  928. //对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
  929. if(cZipCnt > 1) //长度检测
  930. {
  931. if((QD_PARAM_ERROR_LENGTH != 0) && length_buff) //长度误差值不能为0
  932. {
  933. if((dwSaveLength > (length_buff + QD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
  934. {
  935. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);//拉链变长,对比警告
  936. }
  937. //上升沿的长度
  938. else if((dwSaveLength + QD_PARAM_ERROR_LENGTH) < length_buff)
  939. {
  940. QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM); ////拉链变短
  941. }
  942. QD_CheckLengthStep = 0;
  943. }
  944. }
  945. else if(cZipCnt == 1) //长度检测
  946. {
  947. if(dwSaveLength)
  948. length_buff = dwSaveLength;
  949. }
  950. }
  951. break;
  952. case 374:
  953. if(!X_DRV && (dwTickCount >= QD_MotorDelay)) //数控到停止
  954. {
  955. QD_MotorStep = 0;
  956. QD_TFK_VAVLE = 1; //推方块输出
  957. }
  958. break;
  959. //切完延时后拉带松夹子
  960. case 40:
  961. if(QD_PARAM_SJZ_LENGTH == 0)
  962. {
  963. QD_JD_VAVLE = 0;
  964. }
  965. QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
  966. SetDir(X_AXIS, QD_DIR_P);
  967. QD_JZ_DIR = QD_YDIR_P;
  968. SetDir(X_AXIS, QD_DIR_N);
  969. QD_MotorStep = 41;
  970. break;
  971. case 41:
  972. if((dwTickCount >= QD_MotorDelay))
  973. {
  974. jz_buff = cRealPos;
  975. if(QD_JD_VAVLE)
  976. //两段速度移动距离
  977. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  978. AxisMoveTwoPos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,QD_PARAM_SJZ_LENGTH,5000,QD_PARAM_BACK_LENGTH,QD_DIR_P);
  979. else
  980. //夹子已经张开
  981. AxisMovePosAccDec(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH),QD_PARAM_START_SPEED,10,10);
  982. // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  983. QD_MotorStep = 42;
  984. }
  985. break;
  986. case 42:
  987. if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  988. {
  989. QD_JD_VAVLE = 0;
  990. QD_MotorStep = 43;
  991. }
  992. if(!X_DRV)
  993. {
  994. QD_JD_VAVLE = 0;
  995. QD_MotorStep = 43;
  996. }
  997. break;
  998. case 43: // 切断完成后拉电机动作
  999. if(!X_DRV)
  1000. {
  1001. QD_MotorStep = 0;
  1002. QD_MotorDelay = dwTickCount;
  1003. }
  1004. break;
  1005. case 61: // 前点定位数控模式
  1006. if(QD_SZ_OUT)
  1007. {
  1008. QD_SZ_OUT = 0;
  1009. QD_MotorDelay = dwTickCount + 150;
  1010. SetPos(X_AXIS, 0);
  1011. }
  1012. else
  1013. QD_MotorDelay = dwTickCount;
  1014. QD_BL_VAVLE = 0;//并链也要打开
  1015. QD_JZ_DIR = QD_YDIR_N;
  1016. if(!QD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
  1017. {
  1018. if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
  1019. {
  1020. QD_TuiLianStep = 1;
  1021. QD_MotorStep = 62;
  1022. }
  1023. }
  1024. else
  1025. QD_MotorStep = 62;
  1026. break;
  1027. case 62:
  1028. if(dwTickCount >= QD_MotorDelay)
  1029. {
  1030. if(QD_QIAN_LIMIT_IN)
  1031. {
  1032. SetPos(X_AXIS, 0);//在前点,直接置零点
  1033. QD_JZ_DIR = QD_YDIR_P;
  1034. //前点亮的情况下先退出
  1035. AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,1000);
  1036. QD_MotorDelay = dwTickCount + 300;
  1037. }
  1038. QD_MotorStep = 63;
  1039. QD_JD_VAVLE = 0;
  1040. }
  1041. break;
  1042. case 63:
  1043. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))// && !QD_SHANG_MU_LIMIT_IN)
  1044. {
  1045. SetDir(X_AXIS, QD_DIR_N);
  1046. QD_JZ_DIR = QD_YDIR_N;
  1047. SetDir(X_AXIS, QD_DIR_P);
  1048. go_buff = cRealPos;
  1049. QD_YD_VAVLE = 1;
  1050. QD_HL_VAVLE = 1;
  1051. QD_YX_VAVLE = 1;
  1052. //李永庆代码,当位置在慢速之外,走数控到慢速点
  1053. if(cZipCnt > 0)
  1054. {
  1055. if(cRealPos>(QD_PARAM_GO_LOW_SPEED_LENGTH))
  1056. {
  1057. // AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1058. // SetStartSpeed(X_AXIS,QD_PARAM_START_SPEED);
  1059. // SetAccTime(X_AXIS,QD_PARAM_ACC);
  1060. // SetDecTime(X_AXIS,QD_PARAM_DCC);
  1061. //两段速度移动距离
  1062. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  1063. // AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH+ 100,QD_DIR_N);
  1064. //跑三段速度
  1065. AxisMoveThreePosNoStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos -QD_PARAM_GO_LOW_SPEED_LENGTH-300,
  1066. QD_PARAM_GO_HIGH_SPEED*2/3,350,
  1067. QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_DIR_N) ;
  1068. }
  1069. else
  1070. {
  1071. // X轴 运行速度 启动速度 加速度 减速度
  1072. AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
  1073. // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1074. }
  1075. }
  1076. else
  1077. {
  1078. // X轴 运行速度 启动速度 加速度 减速度
  1079. AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
  1080. // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
  1081. }
  1082. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1083. QD_MotorStep =64;
  1084. }
  1085. break;
  1086. case 64:
  1087. if(cZipCnt > 1)
  1088. {
  1089. //李永庆代码
  1090. if(((cRealPos) < (QD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QD_QIAN_DEC_IN))
  1091. {
  1092. user_datas[126]= GetCurSpeed(X_AXIS);
  1093. // MoveChangSpeedDec(X_AXIS,QD_PARAM_GO_HIGH_SPEED*2/3,6,8);
  1094. // AxisChangeSpeed(X_AXIS,40);
  1095. QD_MotorStep =65;
  1096. }
  1097. if(QD_QIAN_LIMIT_IN) //前点限位
  1098. {
  1099. AxisEgmStop(X_AXIS);
  1100. QD_MotorStep = 66;
  1101. }
  1102. }
  1103. else
  1104. {
  1105. if(QD_QIAN_LIMIT_IN) //前点限位
  1106. {
  1107. AxisEgmStop(X_AXIS);
  1108. QD_MotorStep = 66;
  1109. }
  1110. }
  1111. break;
  1112. case 65:
  1113. if(QD_QIAN_LIMIT_IN)
  1114. {
  1115. AxisEgmStop(X_AXIS);
  1116. QD_MotorStep = 66;
  1117. }
  1118. else if(dwTickCount >= QD_MotorDelay)
  1119. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1120. break;
  1121. case 66:
  1122. if(!X_DRV)
  1123. {
  1124. SetPos(X_AXIS, 0);
  1125. QD_MotorDelay = dwTickCount;
  1126. QD_MotorStep = 67;
  1127. }
  1128. break;
  1129. case 67: //等推链完成后,
  1130. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  1131. {
  1132. if(bRunning)
  1133. {
  1134. QD_JD_VAVLE = 1;
  1135. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1136. }
  1137. QD_MotorStep = 68;
  1138. }
  1139. break;
  1140. case 68:
  1141. if(dwTickCount >= QD_MotorDelay)
  1142. {
  1143. QD_YD_VAVLE = 0;
  1144. QD_HL_VAVLE = 0;
  1145. QD_YX_VAVLE = 0;
  1146. QD_TL_VAVLE = 0;
  1147. QD_MotorStep = 0;
  1148. QD_MotorDelay = dwTickCount;
  1149. }
  1150. break;
  1151. }
  1152. }
  1153. #endif
  1154. void QueDuan_BingLian(void)
  1155. {
  1156. static long bl_pos_buff,HL_delay;
  1157. switch(QD_BinLianStep)
  1158. {
  1159. case 0:break;
  1160. case 1:
  1161. bl_pos_buff = cRealPos;
  1162. QD_BinLianStep = 2;
  1163. break;
  1164. case 2:
  1165. if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
  1166. {
  1167. QD_BL_VAVLE = 1;
  1168. QD_BinLianStep = 3;
  1169. }
  1170. break;
  1171. case 3://有过链检测
  1172. if(QD_GUO_LIAN_IN_DW || ((cRealPos - bl_pos_buff) >= (QD_PARAM_ZIPPER_LENGTH - QD_PARAM_HL_DELAY_BACK)))
  1173. {
  1174. QD_BL_VAVLE = 0;
  1175. QD_BinLianStep = 0;
  1176. }
  1177. break;
  1178. case 10:
  1179. bl_pos_buff = cRealPos;
  1180. QD_BinLianStep = 11;
  1181. break;
  1182. case 11:
  1183. if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
  1184. {
  1185. QD_BL_VAVLE = 1;
  1186. QD_BinLianStep = 12;
  1187. }
  1188. break;
  1189. case 12://有过链检测
  1190. if(QD_GUO_LIAN_IN_DW)
  1191. {
  1192. QD_BL_VAVLE = 0;
  1193. QD_BinLianStep = 0;
  1194. }
  1195. break;
  1196. default:;
  1197. }
  1198. }
  1199. #if QD_KB_MODE==1 //闭口
  1200. //作闭口专用程序
  1201. //不带过链感应长度输入电机长度 闭口有勾针到位
  1202. void QueDuan_Motor_NoGL(void)
  1203. {
  1204. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  1205. long pulse_buff;
  1206. unsigned short ch,kk;
  1207. user_datas[124]= cRealPos;
  1208. user_datas[125]= bRunning;
  1209. // user_datas[123] = length_buff - (*length_buffer);
  1210. // user_datas[127] = cRealPos;
  1211. // user_datas[126] = go_buff - cRealPos;
  1212. user_datas[122] = QD_AutoStep;
  1213. user_datas[121] = QD_MotorStep;
  1214. if((QD_MotorStep >= 101) && (QD_MotorStep <= 103))
  1215. {
  1216. if(QD_QIAN_LIMIT_IN_DW)QD_HL_VAVLE = 0;
  1217. }
  1218. switch(QD_MotorStep)
  1219. {
  1220. case 30:
  1221. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1222. length_buffer = &QD_PARAM_OFFSET_LENGTH;
  1223. if(QD_PARAM_BL_ENABLE) //
  1224. QD_BinLianStep = 1;
  1225. QD_JZ_DIR = QD_YDIR_P; //电机方向
  1226. if(QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) //双开带过链感应
  1227. {
  1228. if(QD_PARAM_DEC_MODE == QD_BACK_NOMAL_DEC_MODE)//测长数控
  1229. QD_MotorStep = 101;
  1230. else
  1231. QD_MotorStep = 31;
  1232. }
  1233. else //闭口走长度
  1234. QD_MotorStep = 31;
  1235. break;
  1236. case 31:
  1237. if(dwTickCount >= QD_MotorDelay)
  1238. {
  1239. back_buff = cRealPos;
  1240. gou_zhen_buff = cRealPos;
  1241. save_buff = cRealPos;
  1242. length_buffer = &QD_PARAM_OFFSET_LENGTH;
  1243. //李永庆代码
  1244. SetDir(X_AXIS, QD_DIR_N);
  1245. //两段速度移动距离
  1246. // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
  1247. AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH-200,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH + (*length_buffer),QD_DIR_P);
  1248. //AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_BACK_LOW_SPEED,4,QD_PARAM_DCC+8);
  1249. SetDir(X_AXIS,QD_DIR_P);
  1250. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1251. QD_MotorStep = 32;
  1252. }
  1253. break;
  1254. case 32:
  1255. //勾针提前输出
  1256. if (!QD_GZ_VAVLE && ((cRealPos + QD_PARAM_GOUZHEN_LENGTH + 200) >= (QD_PARAM_ZIPPER_LENGTH )))
  1257. QD_GZ_VAVLE = 1;
  1258. if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
  1259. {
  1260. QD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  1261. QD_MotorStep = 33;
  1262. }
  1263. else if(cRealPos >= (QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//QD_PARAM_ERROR_LENGTH))
  1264. {
  1265. QD_SetAlarmCode(QD_GZ_ALARM);
  1266. }
  1267. break;
  1268. case 33:
  1269. if(!QD_GZ_VAVLE && (cRealPos + QD_PARAM_GOUZHEN_LENGTH + 200) > (QD_PARAM_ZIPPER_LENGTH ))
  1270. {
  1271. QD_GZ_VAVLE = 1;
  1272. QD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  1273. }
  1274. //提前12MM取消数控模式,进入连续运动
  1275. if((cRealPos + 100 + 200) > (QD_PARAM_ZIPPER_LENGTH ))
  1276. {
  1277. CancelPmoveState(X_AXIS);
  1278. SetStartSpeed(X_AXIS,1500);
  1279. AxisChangeSpeed(X_AXIS,1500);
  1280. }
  1281. if(QD_GOUZHEN_IN)
  1282. {
  1283. AxisEgmStop(X_AXIS);
  1284. QD_MotorDelay = dwTickCount + 10;
  1285. QD_YD_VAVLE = 1;
  1286. QD_MotorStep = 34;
  1287. QD_BL_VAVLE = 0; //停止时并链一定要打开
  1288. }
  1289. else if(((cRealPos + 200) >= (QD_PARAM_ZIPPER_LENGTH + (*length_buffer) + QD_PARAM_ERROR_LENGTH)))// && dwTickCount >= QD_MotorDelay)
  1290. {
  1291. AxisEgmStop(X_AXIS);
  1292. if(dwTickCount >= QD_MotorDelay)
  1293. QD_SetAlarmCode(QD_GZ_ALARM);
  1294. }
  1295. break;
  1296. case 34:
  1297. if(!X_DRV && (dwTickCount >= QD_MotorDelay))
  1298. {
  1299. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1300. QD_YD_VAVLE = 1;
  1301. QD_MotorStep = 35;
  1302. }
  1303. break;
  1304. case 35:
  1305. if(cZipCnt == 0)
  1306. {
  1307. ch = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-20-QD_PARAM_ERROR_LENGTH;
  1308. kk = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+20+QD_PARAM_ERROR_LENGTH;
  1309. }
  1310. else
  1311. {
  1312. ch = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-QD_PARAM_ERROR_LENGTH;
  1313. kk = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+QD_PARAM_ERROR_LENGTH;
  1314. }user_datas[128] = ch;
  1315. user_datas[127] = kk;
  1316. if(((cRealPos) < (ch)) && QD_PARAM_ERROR_LENGTH)
  1317. {
  1318. SetAlarmCode(QD_ALARM_ADDR,QD_LENGTH_LONG_ALARM);
  1319. if(dwTickCount >= QD_MotorDelay)
  1320. bAlarmStop = 1;
  1321. }
  1322. else if((cRealPos > kk) && QD_PARAM_ERROR_LENGTH)//(QD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
  1323. {
  1324. SetAlarmCode(QD_ALARM_ADDR,QD_LENGTH_LONG_ALARM);
  1325. if(dwTickCount >= QD_MotorDelay)
  1326. bAlarmStop = 1;
  1327. }
  1328. else
  1329. {
  1330. SetDir(X_AXIS, QD_DIR_N);
  1331. QD_JZ_DIR = QD_YDIR_N;
  1332. SetDir(X_AXIS, QD_DIR_P);
  1333. AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,-QD_PARAM_FZ_LENGTH,3000,QD_PARAM_ACC,QD_PARAM_DCC);
  1334. SetDir(X_AXIS, QD_DIR_P);
  1335. QD_MotorStep = 0;
  1336. }
  1337. break;
  1338. case 101:
  1339. if(dwTickCount >= QD_MotorDelay)
  1340. {
  1341. back_buff = cRealPos;
  1342. gou_zhen_buff = cRealPos;
  1343. save_buff = cRealPos;
  1344. if(cZipCnt <= 2)
  1345. {
  1346. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1347. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1348. QD_MotorStep = 102;
  1349. }
  1350. else
  1351. {
  1352. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1353. QD_MotorStep = 102;
  1354. }
  1355. }
  1356. break;
  1357. case 102:
  1358. if(cZipCnt <= 2)
  1359. {
  1360. //拉链上升沿,就是到空位
  1361. if(QD_GUO_LIAN_IN_UP)
  1362. {
  1363. QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
  1364. if(X_DRV)
  1365. MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED); //降速
  1366. QD_MotorStep = 103;
  1367. }
  1368. }
  1369. else
  1370. {
  1371. //1为双开
  1372. if((QD_SK_MODE) && (((cRealPos + QD_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH))))
  1373. {
  1374. QD_YX_VAVLE = 1;
  1375. QD_HL_VAVLE = 1;
  1376. }
  1377. if(((cRealPos - gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
  1378. {
  1379. QD_GZ_VAVLE = 1;
  1380. QD_YX_VAVLE = 1;
  1381. }
  1382. if((cRealPos - back_buff) > (length_buff - QD_PARAM_BACK_LOW_SPEED_LENGTH-PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC))))
  1383. {
  1384. if(X_DRV)
  1385. {
  1386. MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1387. }
  1388. QD_MotorStep = 103;
  1389. }
  1390. }
  1391. break;
  1392. case 103:
  1393. if(cZipCnt <= 2)
  1394. {//双开暂不用,先保留
  1395. #if QD_SK_MODE
  1396. if((QD_SK_MODE) && ((dwTickCount + QD_PARAM_GZ_DELAY/2) >= QD_MotorDelay))
  1397. {
  1398. QD_YX_VAVLE = 1;
  1399. QD_HL_VAVLE = 1;
  1400. }
  1401. #endif
  1402. if(dwTickCount >= QD_MotorDelay)
  1403. {
  1404. QD_GZ_VAVLE = 1;
  1405. QD_YX_VAVLE = 1;
  1406. #if QD_SK_MODE //双开暂不用,先保留
  1407. if(QD_SK_MODE)
  1408. QD_MotorStep = 154;
  1409. else
  1410. #endif
  1411. QD_MotorStep = 160;
  1412. }
  1413. }
  1414. else
  1415. {
  1416. #if QD_SK_MODE //双开暂不用,先保留
  1417. if((QD_SK_MODE) && (((cRealPos + QD_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH))))
  1418. {
  1419. QD_YX_VAVLE = 1;
  1420. QD_HL_VAVLE = 1;
  1421. }
  1422. #endif
  1423. if(((cRealPos - gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH)))
  1424. {
  1425. QD_GZ_VAVLE = 1;
  1426. QD_YX_VAVLE = 1;
  1427. #if QD_SK_MODE //双开暂不用,先保留
  1428. if(QD_SK_MODE)
  1429. QD_MotorStep = 154;
  1430. else
  1431. #endif
  1432. QD_MotorStep = 160;
  1433. }
  1434. if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + length_buff)) && QD_GZ_VAVLE)
  1435. {
  1436. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1437. }
  1438. }
  1439. break;
  1440. case 154:
  1441. #if QD_SK_MODE //双开暂不用,先保留
  1442. if(QD_GZ_UP_IN)
  1443. {
  1444. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_CHECK_GZ;
  1445. QD_MotorStep = 104;
  1446. }
  1447. #endif
  1448. break;
  1449. case 160:
  1450. if(QD_GOUZHEN_IN)
  1451. {
  1452. AxisEgmStop(X_AXIS);
  1453. QD_YD_VAVLE = 1;
  1454. QD_MotorStep = 105;
  1455. }
  1456. else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + length_buff)) && QD_GZ_VAVLE && (cZipCnt > 2))
  1457. {
  1458. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1459. }
  1460. break;
  1461. case 104:
  1462. #if QD_SK_MODE //双开暂不用,先保留
  1463. if(dwTickCount >= QD_MotorDelay)
  1464. {
  1465. //勾针离开就是到位
  1466. if(!QD_GOUZHEN_IN && QD_GZ_UP_IN)
  1467. {
  1468. AxisEgmStop(X_AXIS);
  1469. QD_MotorStep = 105;
  1470. }
  1471. }
  1472. #endif
  1473. break;
  1474. case 105:
  1475. if(!X_DRV)
  1476. {
  1477. QD_MotorStep = 0;
  1478. QD_HL_VAVLE = 1;
  1479. QD_YD_VAVLE = 1;
  1480. if(cZipCnt == 1)
  1481. {
  1482. go_length_buff = cRealPos - back_buff;
  1483. }
  1484. else if(cZipCnt == 2)
  1485. {
  1486. length_buff = cRealPos - back_buff;
  1487. }
  1488. else if(cZipCnt > 2)
  1489. {
  1490. if(((cRealPos - save_buff) < (length_buff - QD_PARAM_ERROR_LENGTH- (*length_buffer))))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1491. else if(((cRealPos - save_buff) > (QD_PARAM_ERROR_LENGTH + length_buff - (*length_buffer))))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1492. else
  1493. {
  1494. }
  1495. }
  1496. AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH,1,QD_PARAM_ACC,QD_PARAM_DCC);
  1497. }
  1498. break;
  1499. case 106:
  1500. if(!X_DRV)
  1501. {
  1502. QD_SetAlarmCode(QD_GZ_ALARM);
  1503. }
  1504. else
  1505. {
  1506. if(QD_GOUZHEN_IN)
  1507. {
  1508. AxisEgmStop(X_AXIS);
  1509. QD_YD_VAVLE = 1;
  1510. QD_MotorStep = 0;
  1511. }
  1512. }
  1513. break;
  1514. case 40:
  1515. QD_JD_VAVLE = 0;
  1516. SetDir(X_AXIS, QD_DIR_P);
  1517. QD_JZ_DIR = QD_YDIR_P;
  1518. SetDir(X_AXIS, QD_DIR_N);
  1519. QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
  1520. QD_MotorStep = 41;
  1521. break;
  1522. case 41:
  1523. if((dwTickCount >= QD_MotorDelay))
  1524. {
  1525. //夹子已经张开
  1526. AxisMovePosAccDec(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH),QD_PARAM_START_SPEED,10,10);
  1527. // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  1528. QD_MotorStep = 42;
  1529. }
  1530. break;
  1531. case 42:
  1532. // if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  1533. // {
  1534. // QD_JD_VAVLE = 0;
  1535. // QD_MotorStep = 43;
  1536. // }
  1537. // else
  1538. if(!X_DRV)
  1539. {
  1540. QD_JD_VAVLE = 0;
  1541. QD_MotorStep = 43;
  1542. }
  1543. break;
  1544. case 43: // 切断完成后拉电机动作
  1545. if(!X_DRV)
  1546. {
  1547. QD_MotorStep = 0;
  1548. QD_MotorDelay = dwTickCount;
  1549. }
  1550. break;
  1551. case 61: // 前点定位数控模式
  1552. if(QD_SZ_OUT)
  1553. {
  1554. QD_SZ_OUT = 0;
  1555. QD_MotorDelay = dwTickCount + 150;
  1556. SetPos(X_AXIS, 0);
  1557. }
  1558. else
  1559. QD_MotorDelay = dwTickCount;
  1560. QD_BL_VAVLE = 0;//并链也要打开
  1561. QD_JZ_DIR = QD_YDIR_N;
  1562. if(!QD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
  1563. {
  1564. if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
  1565. {
  1566. QD_TuiLianStep = 1;
  1567. QD_MotorStep = 62;
  1568. }
  1569. }
  1570. else
  1571. QD_MotorStep = 62;
  1572. break;
  1573. case 62:
  1574. if(dwTickCount >= QD_MotorDelay)
  1575. {
  1576. if(QD_QIAN_LIMIT_IN)
  1577. {
  1578. SetPos(X_AXIS, 0);//在前点,直接置零点
  1579. QD_JZ_DIR = QD_YDIR_P;
  1580. //前点亮的情况下先退出
  1581. AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,1000);
  1582. QD_MotorDelay = dwTickCount + 300;
  1583. }
  1584. QD_MotorStep = 63;
  1585. QD_JD_VAVLE = 0;
  1586. }
  1587. break;
  1588. case 63:
  1589. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))// && !QD_SHANG_MU_LIMIT_IN)
  1590. {
  1591. SetDir(X_AXIS, QD_DIR_N);
  1592. QD_JZ_DIR = QD_YDIR_N;
  1593. SetDir(X_AXIS, QD_DIR_P);
  1594. go_buff = cRealPos;
  1595. QD_YD_VAVLE = 1;
  1596. QD_HL_VAVLE = 1;
  1597. QD_YX_VAVLE = 1;
  1598. //李永庆代码,当位置在慢速之外,走数控到慢速点
  1599. if(cZipCnt > 0)
  1600. {
  1601. if(cRealPos>(QD_PARAM_GO_LOW_SPEED_LENGTH))
  1602. {
  1603. // AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1604. // SetStartSpeed(X_AXIS,QD_PARAM_START_SPEED);
  1605. // SetAccTime(X_AXIS,QD_PARAM_ACC);
  1606. // SetDecTime(X_AXIS,QD_PARAM_DCC);
  1607. //两段速度移动距离
  1608. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  1609. // AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH+ 100,QD_DIR_N);
  1610. //跑三段速度
  1611. AxisMoveThreePosNoStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos -QD_PARAM_GO_LOW_SPEED_LENGTH-300,
  1612. QD_PARAM_GO_HIGH_SPEED*2/3,350,
  1613. QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_DIR_N) ;
  1614. }
  1615. else
  1616. {
  1617. // X轴 运行速度 启动速度 加速度 减速度
  1618. AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
  1619. // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1620. }
  1621. }
  1622. else
  1623. {
  1624. // X轴 运行速度 启动速度 加速度 减速度
  1625. AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
  1626. // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
  1627. }
  1628. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1629. QD_MotorStep =64;
  1630. }
  1631. break;
  1632. case 64:
  1633. if(cZipCnt > 1)
  1634. {
  1635. //李永庆代码
  1636. if(((cRealPos) < (QD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QD_QIAN_DEC_IN))
  1637. {
  1638. user_datas[126]= GetCurSpeed(X_AXIS);
  1639. // MoveChangSpeedDec(X_AXIS,QD_PARAM_GO_HIGH_SPEED*2/3,6,8);
  1640. // AxisChangeSpeed(X_AXIS,40);
  1641. QD_MotorStep =65;
  1642. }
  1643. if(QD_QIAN_LIMIT_IN) //前点限位
  1644. {
  1645. AxisEgmStop(X_AXIS);
  1646. QD_MotorStep = 66;
  1647. }
  1648. }
  1649. else
  1650. {
  1651. if(QD_QIAN_LIMIT_IN) //前点限位
  1652. {
  1653. AxisEgmStop(X_AXIS);
  1654. QD_MotorStep = 66;
  1655. }
  1656. }
  1657. break;
  1658. case 65:
  1659. if(QD_QIAN_LIMIT_IN)
  1660. {
  1661. AxisEgmStop(X_AXIS);
  1662. QD_MotorStep = 66;
  1663. }
  1664. else if(dwTickCount >= QD_MotorDelay)
  1665. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1666. break;
  1667. case 66:
  1668. if(!X_DRV)
  1669. {
  1670. SetPos(X_AXIS, 0);
  1671. QD_MotorDelay = dwTickCount;
  1672. QD_MotorStep = 67;
  1673. }
  1674. break;
  1675. case 67: //等推链完成后,
  1676. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  1677. {
  1678. if(bRunning)
  1679. {
  1680. QD_JD_VAVLE = 1;
  1681. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1682. }
  1683. QD_MotorStep = 68;
  1684. }
  1685. break;
  1686. case 68:
  1687. if(dwTickCount >= QD_MotorDelay)
  1688. {
  1689. QD_YD_VAVLE = 0;
  1690. QD_HL_VAVLE = 0;
  1691. QD_YX_VAVLE = 0;
  1692. QD_TL_VAVLE = 0;
  1693. QD_MotorStep = 0;
  1694. QD_MotorDelay = dwTickCount;
  1695. }
  1696. break;
  1697. }
  1698. }
  1699. #endif
  1700. //电机动作
  1701. void QueDuan_Motor(void)
  1702. {
  1703. if(QD_KB_MODE) //闭口
  1704. {
  1705. #if QD_KB_MODE //闭口
  1706. QueDuan_Motor_NoGL();
  1707. #endif
  1708. }
  1709. else //开口
  1710. {
  1711. #if !QD_KB_MODE //开口
  1712. QueDuan_Motor_KK(); //
  1713. #endif
  1714. }
  1715. // switch(QD_MACHINE_TYPE)
  1716. // {
  1717. // case QD_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
  1718. // case QD_NO_GL_TUIFANGKUAI: QueDuan_Motor_NoGL();break;
  1719. // case QD_CS_TUIFANGKUAI:break;
  1720. // default:;
  1721. // }
  1722. }
  1723. //超声方式下切,开口专用
  1724. void QueDuan_XiaQue_KK(void)
  1725. {
  1726. switch(QD_XiaQieStep)
  1727. {
  1728. case 0:
  1729. break;
  1730. case 1:
  1731. /*
  1732. if(bRunning)
  1733. {
  1734. QD_XiaQieStep = 6;
  1735. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1736. if(QD_SAFE_IN)
  1737. {
  1738. bStop = 1;
  1739. QD_XM_VAVLE = 0;
  1740. }
  1741. }
  1742. else
  1743. */
  1744. QD_XiaQieStep = 2;
  1745. break;
  1746. case 2:
  1747. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1748. QD_XiaQieStep = 3;
  1749. break;
  1750. case 3:
  1751. if(1)
  1752. {
  1753. QD_XiaQieDelay = dwTickCount + 0;//QD_PARAM_GZ_DELAY;
  1754. QD_XiaQieStep = 4;
  1755. }
  1756. else if(dwTickCount >= QD_XiaQieDelay)
  1757. {
  1758. QD_SetAlarmCode(QD_XM_DAOWEI);
  1759. }
  1760. break;
  1761. case 4:
  1762. if(QD_GZ_VAVLE) //勾针已经有输出就不需要延时
  1763. {
  1764. QD_XiaQieDelay = dwTickCount + 0;
  1765. }
  1766. else
  1767. QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  1768. QD_GZ_VAVLE = 1;
  1769. cTuiFangKuaiCnt=0;
  1770. QD_XiaQieStep = 5;
  1771. break;
  1772. case 5:
  1773. if(dwTickCount >= QD_XiaQieDelay)
  1774. {
  1775. QD_TFK_VAVLE = 1;
  1776. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1777. QD_XiaQieStep = 6;
  1778. }
  1779. break;
  1780. case 6:
  1781. if(1)
  1782. {
  1783. QD_XiaQieStep = 7;
  1784. QD_XiaQieDelay = dwTickCount + 1000;
  1785. }
  1786. else if(dwTickCount >= QD_XiaQieDelay)
  1787. {
  1788. QD_SetAlarmCode(QD_XM_DAOWEI);
  1789. }
  1790. break;
  1791. case 7:
  1792. if(QD_GOUZHEN_IN)
  1793. {
  1794. cTuiFangKuaiCnt = 0;
  1795. QD_YD_VAVLE = 1;
  1796. if(!bRunning)
  1797. QD_XiaQieDelay = dwTickCount + 200;
  1798. else
  1799. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  1800. if(!QD_QIAN_LIMIT_IN)
  1801. QD_XiaQieStep = 8;
  1802. else
  1803. QD_SetAlarmCode(QD_QIAN_LIMIT_ALARM);
  1804. }
  1805. else if((dwTickCount >= QD_XiaQieDelay))
  1806. {
  1807. if(cTuiFangKuaiCnt < QD_PARAM_TFK_NUMBER)
  1808. {
  1809. QD_TFK_VAVLE = 0;
  1810. cTuiFangKuaiCnt++;
  1811. QD_XiaQieDelay = dwTickCount + 500;
  1812. QD_XiaQieStep = 100;
  1813. }
  1814. else
  1815. QD_SetAlarmCode(QD_GZ_ALARM);
  1816. }
  1817. break;
  1818. case 100:
  1819. if((dwTickCount >= QD_XiaQieDelay))
  1820. {
  1821. QD_XiaQieStep = 5;
  1822. }
  1823. break;
  1824. case 8://上下模同时输出
  1825. if(dwTickCount >= QD_XiaQieDelay)
  1826. {
  1827. QD_SM_VAVLE = 1;
  1828. if(QD_PARAM_XM_ENABLE == 0) //配置下模动
  1829. QD_XM_VAVLE = 1;
  1830. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1831. QD_XiaQieStep = 9;
  1832. }
  1833. break;
  1834. case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
  1835. if(QD_SHANG_MU_LIMIT_IN && (QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  1836. {
  1837. if(QD_PARAM_CS_MODE) //无超声配置
  1838. {
  1839. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
  1840. QD_XiaQieStep = 12;
  1841. }
  1842. else
  1843. {
  1844. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
  1845. QD_XiaQieStep = 10;
  1846. }
  1847. }
  1848. else if(dwTickCount >= QD_XiaQieDelay)
  1849. {
  1850. if(!QD_SHANG_MU_LIMIT_IN)QD_SetAlarmCode(QD_SM_DAOWEI);
  1851. else QD_SetAlarmCode(QD_XM_DAOWEI);
  1852. }
  1853. break;
  1854. case 10:
  1855. if(dwTickCount >= QD_XiaQieDelay)
  1856. {
  1857. QD_CS_OUT = 1;
  1858. //
  1859. QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
  1860. QD_XiaQieStep = 11;
  1861. }
  1862. break;
  1863. case 11:
  1864. if(dwTickCount >= QD_XiaQieDelay)
  1865. {
  1866. QD_CS_OUT = 0;
  1867. QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
  1868. QD_XiaQieStep = 12;
  1869. }
  1870. break;
  1871. case 12:
  1872. if(dwTickCount >= QD_XiaQieDelay)
  1873. {
  1874. QD_SM_VAVLE = 0;
  1875. if(QD_PARAM_XM_ENABLE == 0) //配置下模动
  1876. QD_XM_VAVLE = 0;
  1877. QD_TFK_VAVLE = 0;
  1878. QD_GZ_VAVLE = 0;
  1879. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1880. QD_XiaQieStep = 13;
  1881. }//
  1882. break;
  1883. case 13:
  1884. if(!QD_SHANG_MU_LIMIT_IN)
  1885. {
  1886. //启动推链(送链)
  1887. if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)
  1888. QD_TuiLianStep = 1;
  1889. }
  1890. if(!QD_SHANG_MU_LIMIT_IN && (!QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE))
  1891. {
  1892. QD_XiaQieStep = 0;
  1893. }
  1894. else if(dwTickCount >= QD_XiaQieDelay)
  1895. {
  1896. QD_SetAlarmCode(QD_SM_YUANWEI);
  1897. }
  1898. break;
  1899. }
  1900. }
  1901. void QueDuan_TuiLianAction(void)
  1902. {
  1903. if(QD_PARAM_XM_ENABLE == 0)
  1904. {
  1905. QD_TuiLianStep = 0;
  1906. }
  1907. else
  1908. {
  1909. switch(QD_TuiLianStep)
  1910. {
  1911. case 1:
  1912. QD_TuiLianStep = 2;
  1913. break;
  1914. case 2:
  1915. QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
  1916. QD_TuiLianStep = 3;
  1917. break;
  1918. case 3:
  1919. if(!QD_SM_VAVLE && !QD_SHANG_MU_LIMIT_IN)//dwTickCount >= QD_TLDelay)
  1920. {
  1921. QD_TL_VAVLE = 1;
  1922. if(!bRunning)QD_TFK_VAVLE = 0;
  1923. QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
  1924. QD_TuiLianStep = 4;
  1925. }
  1926. break;
  1927. case 4:
  1928. if(dwTickCount >= QD_TLDelay)
  1929. {
  1930. QD_TuiLianStep = 0;
  1931. }
  1932. break;
  1933. case 10:
  1934. QD_TuiLianStep = 11;
  1935. break;
  1936. case 11:
  1937. if(!Y_DRV)
  1938. {
  1939. {
  1940. QD_TuiLianStep = 0;
  1941. }
  1942. }
  1943. break;
  1944. }
  1945. }
  1946. }
  1947. //闭口专用
  1948. void QueDuan_XiaQue_NO_GL(void)
  1949. {
  1950. switch(QD_XiaQieStep)
  1951. {
  1952. case 0:
  1953. break;
  1954. case 1:
  1955. if(!bRunning)
  1956. {
  1957. if((QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) && QD_SK_MODE)
  1958. {
  1959. //跳到双开
  1960. // QD_YD_VAVLE = 1;
  1961. QD_HL_VAVLE = 1; //护链
  1962. QD_YX_VAVLE = 1; //压带
  1963. QD_GZ_VAVLE = 1; //勾针
  1964. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  1965. QD_XiaQieStep = 100;
  1966. }
  1967. else
  1968. {
  1969. // QD_GZ_VAVLE = 1; //勾针
  1970. // QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  1971. // QD_XiaQieStep = 100;
  1972. QD_YD_VAVLE = 1;
  1973. QD_XiaQieStep = 2;
  1974. QD_XiaQieDelay = dwTickCount + 30;
  1975. }
  1976. }
  1977. else
  1978. {
  1979. QD_YD_VAVLE = 1;
  1980. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  1981. QD_XiaQieStep = 2;
  1982. }
  1983. break;
  1984. case 2:
  1985. if(dwTickCount >= QD_XiaQieDelay)
  1986. {
  1987. QD_XiaQieStep = 3;
  1988. QD_XiaQieDelay = dwTickCount;
  1989. }
  1990. break;
  1991. case 3:
  1992. if(dwTickCount >= QD_XiaQieDelay)
  1993. {
  1994. if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
  1995. {
  1996. QD_SM_VAVLE = 1;
  1997. QD_XM_VAVLE = 1;
  1998. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  1999. QD_XiaQieStep = 4;
  2000. }
  2001. }
  2002. break;
  2003. case 4://永兴为下模固定
  2004. if(QD_SHANG_MU_LIMIT_IN && (QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE))
  2005. {
  2006. QD_GZ_VAVLE = 0;
  2007. if(!QD_PARAM_CS_MODE) //气切
  2008. {
  2009. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
  2010. QD_XiaQieStep = 5;
  2011. }
  2012. else
  2013. {
  2014. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
  2015. QD_XiaQieStep = 10;
  2016. } //
  2017. }
  2018. else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
  2019. break;
  2020. case 5:
  2021. if(dwTickCount >= QD_XiaQieDelay)
  2022. {
  2023. QD_SM_VAVLE = 0;
  2024. QD_XM_VAVLE = 0;
  2025. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2026. QD_XiaQieStep = 6;
  2027. }
  2028. break;
  2029. case 6:
  2030. if(!QD_SHANG_MU_LIMIT_IN && (!QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE)) //下模不动就不用判断
  2031. {
  2032. if(QD_TuiLianStep == 0)
  2033. QD_TuiLianStep = 1;
  2034. if(!bRunning)
  2035. QD_JD_VAVLE = 0;
  2036. QD_XiaQieStep = 0;
  2037. }
  2038. else if(dwTickCount >= QD_XiaQieDelay)
  2039. {
  2040. QD_SetAlarmCode(QD_SM_YUANWEI);
  2041. }
  2042. break;
  2043. //10~11步为超声
  2044. case 10:
  2045. if(dwTickCount >= QD_XiaQieDelay)
  2046. {
  2047. if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
  2048. QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
  2049. QD_XiaQieStep = 11;
  2050. }
  2051. break;
  2052. case 11:
  2053. if(dwTickCount >= QD_XiaQieDelay)
  2054. {
  2055. QD_CS_OUT = 0;
  2056. QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
  2057. QD_XiaQieStep = 5;
  2058. }
  2059. break;
  2060. case 100:
  2061. if(dwTickCount >= QD_XiaQieDelay)
  2062. {
  2063. //这是双开程序,暂时不考虑
  2064. #if 1
  2065. if(QD_GOUZHEN_IN)
  2066. {
  2067. QD_YD_VAVLE = 1;
  2068. QD_XiaQieStep = 3;
  2069. }
  2070. #endif
  2071. }
  2072. break;
  2073. }
  2074. }
  2075. //切断动作
  2076. void QueDuan_XiaQue(void)
  2077. {
  2078. if(QD_KB_MODE) //闭口
  2079. {
  2080. QueDuan_XiaQue_NO_GL(); //
  2081. }
  2082. else //开口
  2083. {
  2084. QueDuan_XiaQue_KK();
  2085. }
  2086. #if 0
  2087. switch(QD_MACHINE_TYPE)
  2088. {
  2089. case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
  2090. case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
  2091. case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
  2092. default:;
  2093. }
  2094. #endif
  2095. }
  2096. #endif