JHQueDuanJi.c 113 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825
  1. #include "global.h"
  2. #if JIN_HONG_MACHINE
  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_TuiFangKuai(void);
  12. void QueDuan_ExtiActionX31(void);
  13. void QueDuan_BingLian(void);
  14. static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
  15. static long save_limit_pos,cRealPos;
  16. unsigned char cCheckLianFlg = 0;
  17. unsigned char cCheckLianFlgEN = 0;
  18. unsigned char cGoLimitEn = 0;
  19. short *length_buffer;
  20. static long dwSaveLength;
  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. save_limit_pos = QD_SAVE_POS;
  34. axis_x->speed_unit = 500;
  35. SetAccTime(X_AXIS,10);
  36. SetDecTime(X_AXIS,10);
  37. length_buff = QD_PARAM_CYCLE_LENGTH;
  38. pulse_buff = QD_PARAM_CYCLE_PULSE;
  39. XGearRatio = pulse_buff/length_buff;
  40. axis_y->speed_unit = 300;
  41. SetAccTime(Y_AXIS,3);
  42. SetDecTime(Y_AXIS,3);
  43. length_buff = QD_PARAM_TL_CYCLE_LENGTH;
  44. pulse_buff = QD_PARAM_TL_CYCLE_PULSE;
  45. YGearRatio = pulse_buff/length_buff;
  46. QD_SZ_OUT = 1;
  47. }
  48. void QueDuan_Action(void)
  49. {
  50. QueDuan_AlarmProtect();
  51. QueDuan_TuiFangKuai();
  52. QueDuan_Motor();
  53. QueDuan_XiaQue();
  54. QueDuan_ManualAction();
  55. QueDuan_YuanDianAction();
  56. QueDuan_TuiLianAction();
  57. QueDuan_BingLian();
  58. QueDuan_AutoAction();
  59. QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
  60. }
  61. long testFlg = 0;
  62. //手动动作
  63. void QueDuan_ManualAction(void)
  64. {
  65. if(bRunning == 0)
  66. {
  67. if(QD_bCalSin || testFlg)
  68. {
  69. QD_bCalSin = 0;
  70. testFlg = 0;
  71. // CalculateSModelLine(FreqTab_X,MAX_SPEED,MAX_FREQ,MIN_FREQ,FLEXIBLE);
  72. }
  73. if(QD_bClearTotal) //切断计数清零
  74. {
  75. QD_bClearTotal = 0;
  76. ClrcToTal(QD_TOTAL_ADDR);
  77. }
  78. if(QD_bClearNowTotal)
  79. {
  80. QD_bClearNowTotal = 0;
  81. QD_PARAM_NOW_CNT = 0;
  82. }
  83. if(QD_bXiaQie)
  84. {
  85. QD_bXiaQie = 0;
  86. if(QD_XiaQieStep == 0)QD_XiaQieStep = 1;
  87. }
  88. if(QD_bQianDianDW)
  89. {
  90. QD_bQianDianDW = 0;
  91. if(QD_MotorStep == 0)
  92. {
  93. QD_MotorStep = 61;
  94. cZipCnt = 0;
  95. }
  96. }
  97. if(QD_bTL)
  98. {
  99. if(QD_PARAM_TL_MODE)
  100. {
  101. if(!Y_DRV)AxisMovePos(Y_AXIS,QD_PARAM_TL_SPEED,QD_PARAM_TL_LENGTH);
  102. }
  103. else
  104. {
  105. QD_bTL = 0;
  106. QD_TL_VAVLE = ~QD_TL_VAVLE;
  107. }
  108. }
  109. if(!Y_DRV)QD_bTL = 0;
  110. if(QD_bYD)
  111. {
  112. QD_bYD = 0;
  113. QD_YD_VAVLE = ~QD_YD_VAVLE;
  114. }
  115. if(QD_bGZ)
  116. {
  117. QD_bGZ = 0;
  118. QD_GZ_VAVLE = ~QD_GZ_VAVLE;
  119. }
  120. if(QD_bJD)
  121. {
  122. QD_bJD = 0;
  123. QD_JD_VAVEL = ~QD_JD_VAVEL;
  124. }
  125. if(QD_bXM)
  126. {
  127. QD_bXM = 0;
  128. QD_XM_VAVLE = ~QD_XM_VAVLE;
  129. }
  130. if(QD_bSM)
  131. {
  132. QD_bSM = 0;
  133. QD_SM_VAVLE = ~QD_SM_VAVLE;
  134. }
  135. if(QD_bTFK)
  136. {
  137. QD_bTFK = 0;
  138. QD_TFK_VAVEL = ~QD_TFK_VAVEL;
  139. }
  140. if(QD_bTB)
  141. {
  142. QD_bTB = 0;
  143. QD_TABLE_VAVLE = ~QD_TABLE_VAVLE;
  144. }
  145. if(QD_bYBD)
  146. {
  147. QD_bYBD = 0;
  148. QD_YBD_VAVLE = ~QD_YBD_VAVLE;
  149. }
  150. if(QD_bTestCS)
  151. {
  152. QD_bTestCS = 0;
  153. QD_CS_OUT = 1;
  154. QD_CSDelay = dwTickCount + QD_PARAM_CS_TIME;
  155. }
  156. if(QD_bBL)
  157. {
  158. QD_bBL = 0;
  159. QD_BL_VAVLE = ~QD_BL_VAVLE;
  160. }
  161. if(QD_XiaQieStep == 0)
  162. {
  163. if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0;
  164. }
  165. if(QD_bYuanDianDW)
  166. {
  167. QD_bYuanDianDW = 0;
  168. if(QD_YuanDianStep == 0)QD_YuanDianStep = 1;
  169. }
  170. //电机控制
  171. if(QD_bGoMotor && !QD_QIAN_LIMIT_IN)
  172. {
  173. QD_SZ_OUT = 0;
  174. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_N;
  175. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,QD_DIR_N,5,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  176. }
  177. if(QD_bBackMotor && !QD_BACK_LIMIT_IN)
  178. {
  179. QD_SZ_OUT = 0;
  180. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  181. if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,5,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  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_YuanDianAction(void)
  194. {
  195. switch(QD_YuanDianStep)
  196. {
  197. case 0:break;
  198. case 1:
  199. if(QD_MotorStep == 0)QD_MotorStep = 61;
  200. QD_YuanDianStep = 2;
  201. break;
  202. case 2:
  203. if(QD_MotorStep == 0)
  204. {
  205. QD_MotorStep = 30;
  206. QD_YuanDianStep = 3;
  207. QD_JD_VAVEL = 1;
  208. }
  209. break;
  210. case 3:
  211. if(QD_MotorStep == 0)
  212. {
  213. QD_MotorStep = 0;
  214. QD_YuanDianStep = 0;
  215. }
  216. break;
  217. }
  218. }
  219. void QueDuan_AlarmProtect(void)
  220. {
  221. cRealPos = GetPos(X_AXIS);
  222. if(QD_PARAM_BACK_ALARM_MODE)
  223. { //感应后限模式
  224. if(!bRunning)
  225. {
  226. if(QD_BACK_LIMIT_IN_UP)
  227. {
  228. if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
  229. {
  230. QD_bBackMotor = 0;
  231. AxisDecStop(X_AXIS);
  232. QD_JD_VAVEL = 0;
  233. QD_SetAlarmCode(QD_BACK_ALARM);
  234. }
  235. }
  236. }
  237. else
  238. {
  239. if(QD_BACK_LIMIT_IN_UP && (QD_MotorStep < 61))
  240. {
  241. AxisDecStop(X_AXIS);
  242. QD_JD_VAVEL = 0;
  243. QD_SetAlarmCode(QD_BACK_ALARM);
  244. }
  245. }
  246. }
  247. else
  248. {
  249. if(QD_QIAN_LIMIT_IN_UP) //数控后限模式
  250. {
  251. save_limit_pos = cRealPos;
  252. SetData32bits(200,save_limit_pos);
  253. }
  254. if(QD_PARAM_MAX_BACK_LENGTH < (cRealPos - save_limit_pos))
  255. {
  256. if(!bRunning)
  257. {
  258. if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
  259. {
  260. QD_bBackMotor = 0;
  261. AxisDecStop(X_AXIS);
  262. QD_JD_VAVEL = 0;
  263. QD_SetAlarmCode(QD_BACK_ALARM);
  264. }
  265. }
  266. else
  267. {
  268. AxisDecStop(X_AXIS);
  269. QD_JD_VAVEL = 0;
  270. QD_SetAlarmCode(QD_BACK_ALARM);
  271. }
  272. }
  273. }
  274. // if(!QD_KADAI_IN)QD_KaDaiDelay = dwTickCount + 3000;
  275. /* if(bRunning)
  276. {
  277. if(dwTickCount >= QD_KaDaiDelay)QD_SetAlarmCode(QD_KA_DAI_ALARM);
  278. }*/
  279. }
  280. void QueDuan_AutoAction(void)
  281. {
  282. if(bRunning)
  283. {
  284. if(dwTickCount >= QD_TBDelay)QD_TABLE_VAVLE = 0;
  285. switch(QD_AutoStep)
  286. {
  287. case 1:
  288. if(dwTickCount >= QD_AutoDelay)
  289. {
  290. QD_AutoStep = 2;
  291. if(QD_MotorStep == 0)
  292. {
  293. QD_MotorStep = 61; //前点定位
  294. // else QD_MotorStep = 1;
  295. }
  296. }
  297. break;
  298. case 2:
  299. if(QD_MotorStep == 0)
  300. {
  301. if(QD_PARAM_DC_MODE == 0)
  302. QD_MotorStep = 20; //后退到位
  303. else
  304. QD_MotorStep = 30;
  305. QD_AutoStep = 3;
  306. }
  307. break;
  308. case 3:
  309. if(QD_MotorStep == 0)
  310. {
  311. if(QD_XiaQieStep == 0)QD_XiaQieStep = 1;
  312. QD_AutoStep = 4;
  313. }
  314. break;
  315. case 4:
  316. if(QD_MACHINE_TYPE == QD_QQ_TUIFANGKUAI)
  317. {
  318. if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 4)) && !QD_SHANG_MU_LIMIT_IN)
  319. {
  320. if(QD_MotorStep == 0)
  321. {
  322. QD_MotorStep = 40; //切完后退
  323. QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
  324. }
  325. QD_AutoStep = 5;
  326. }
  327. }
  328. else if(QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI)
  329. {
  330. if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 5)) && !QD_SHANG_MU_LIMIT_IN)
  331. {
  332. if(QD_MotorStep == 0)
  333. {
  334. QD_MotorStep = 40; //切完后退
  335. QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
  336. }
  337. QD_AutoStep = 5;
  338. }
  339. }
  340. else
  341. {
  342. if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 13)) && !QD_SHANG_MU_LIMIT_IN && !QD_XIA_MU_LIMIT_IN)
  343. {
  344. if(QD_MotorStep == 0)
  345. {
  346. QD_MotorStep = 40; //切完后退
  347. // QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
  348. }
  349. QD_AutoStep = 5;
  350. }
  351. }
  352. break;
  353. case 5:
  354. if(QD_MotorStep == 0)
  355. {
  356. cZipCnt++;
  357. QD_PARAM_NOW_CNT++;
  358. cTableCnt++;
  359. AddToTal(QD_TOTAL_ADDR);
  360. CalProSP(QD_PROSPEED_ADDR);
  361. if(cTableCnt >= QD_PARAM_TABLE_NUM)
  362. {
  363. cTableCnt = 0;
  364. QD_TABLE_VAVLE = 1;
  365. QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME;
  366. }
  367. if((GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) || SingOneFlg)
  368. {
  369. bRunning = 0;
  370. QD_AutoStep = 0;
  371. SingOneFlg = 0;
  372. if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
  373. }
  374. else
  375. {
  376. QD_AutoStep = 1;
  377. if(QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU)
  378. {
  379. QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME + 50;
  380. QD_PARAM_NOW_CNT = 0;
  381. }
  382. else
  383. QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
  384. }
  385. }
  386. break;
  387. }
  388. }
  389. }
  390. void QueDuan_StepCheckStart(void)
  391. {
  392. // 启动
  393. if((START_IN_UP) || bStart || QD_bSingle)
  394. {
  395. bStart = 0;
  396. if(!bRunning && (QD_AutoStep == 0))
  397. {
  398. if(!QD_SHANG_MU_ORIGIN_IN)QD_SetAlarmCode(QD_SM_YUANWEI);
  399. else if(QD_XIA_MU_LIMIT_IN)QD_SetAlarmCode(QD_XM_DAOWEI);
  400. else if(GetAlarmCode(QD_ALARM_ADDR) != 0);
  401. else if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
  402. else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM);
  403. else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM);
  404. else
  405. {
  406. bRunning = 1;
  407. QD_AutoStep = 1;
  408. if(QD_bSingle) SingOneFlg= 1;
  409. cZipCnt = 0;
  410. cTuiFangKuaiCnt = 0;
  411. if(QD_PARAM_TL_MODE)
  412. {
  413. if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
  414. }
  415. }
  416. }
  417. QD_bSingle = 0;
  418. }
  419. //停止
  420. if(STOP_IN_UP || bStop)
  421. {
  422. bStop = 0;
  423. user_datas[127] = 0;
  424. /* if(bRunning)
  425. {
  426. if(SingOneFlg)
  427. {
  428. bRunning = 0;
  429. QD_XiaQieStep = 0;
  430. QD_AutoStep = 0;
  431. QD_MotorStep = 0;
  432. QD_TuiLianStep = 0;
  433. QD_TuiFangKuaiStep = 0;
  434. QD_YuanDianStep = 0;
  435. QD_BinLianStep = 0;
  436. SingOneFlg = 0;
  437. QD_JD_VAVEL = 0;
  438. QD_SM_VAVLE = 0;
  439. QD_XM_VAVLE = 0;
  440. QD_YD_VAVLE = 0;
  441. QD_XHG_VAVLE = 0;
  442. // QD_CS_OUT = 0;
  443. QD_TL_VAVLE = 0;
  444. QD_SZ_OUT = 1;
  445. QD_GZ_VAVLE = 0;
  446. QD_YBD_VAVLE = 0;
  447. QD_TFK_VAVEL = 0;
  448. QD_TABLE_VAVLE = 0;
  449. QD_BL_VAVLE = 0;
  450. QD_AutoDelay = dwTickCount;
  451. QD_MotorDelay = dwTickCount;
  452. QD_XiaQieDelay = dwTickCount;
  453. QD_KaDaiDelay = dwTickCount;
  454. QD_CSDelay = dwTickCount;
  455. QD_TBDelay = dwTickCount;
  456. QD_TFKDelay = dwTickCount;
  457. QD_TLDelay = dwTickCount;
  458. QD_CheckDelay = dwTickCount;
  459. AxisDecStop(X_AXIS);
  460. if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
  461. }
  462. else
  463. {
  464. SingOneFlg = 1;
  465. }
  466. }
  467. else
  468. {
  469. bRunning = 0;
  470. QD_XiaQieStep = 0;
  471. QD_AutoStep = 0;
  472. QD_MotorStep = 0;
  473. QD_TuiLianStep = 0;
  474. QD_TuiFangKuaiStep = 0;
  475. QD_YuanDianStep = 0;
  476. QD_AutoDelay = dwTickCount;
  477. QD_MotorDelay = dwTickCount;
  478. QD_XiaQieDelay = dwTickCount;
  479. QD_KaDaiDelay = dwTickCount;
  480. QD_CSDelay = dwTickCount;
  481. QD_TBDelay = dwTickCount;
  482. QD_TFKDelay = dwTickCount;
  483. QD_TLDelay = dwTickCount;
  484. QD_CheckDelay = dwTickCount;
  485. SingOneFlg = 0;
  486. QD_JD_VAVEL = 0;
  487. QD_SM_VAVLE = 0;
  488. QD_XM_VAVLE = 0;
  489. QD_YD_VAVLE = 0;
  490. QD_TFK_VAVEL= 0;
  491. QD_TL_VAVLE = 0;
  492. QD_YBD_VAVLE = 0;
  493. //QD_CS_OUT = 0;
  494. QD_XiaQieStep = 0;
  495. QD_MotorStep = 0;
  496. QD_TuiLianStep = 0;
  497. QD_TuiFangKuaiStep = 0;
  498. QD_SZ_OUT = 1;
  499. QD_GZ_VAVLE = 0;
  500. QD_TABLE_VAVLE = 0;
  501. QD_XHG_VAVLE = 0;
  502. AxisDecStop(X_AXIS);
  503. QD_YuanDianStep = 0;
  504. QD_BinLianStep = 0;
  505. QD_BL_VAVLE = 0;
  506. if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
  507. }*/
  508. if(bRunning)
  509. {
  510. bRunning = 0;
  511. QD_XiaQieStep = 0;
  512. QD_AutoStep = 0;
  513. QD_MotorStep = 0;
  514. QD_TuiLianStep = 0;
  515. QD_TuiFangKuaiStep = 0;
  516. QD_YuanDianStep = 0;
  517. QD_AutoDelay = dwTickCount;
  518. QD_MotorDelay = dwTickCount;
  519. QD_XiaQieDelay = dwTickCount;
  520. QD_KaDaiDelay = dwTickCount;
  521. QD_CSDelay = dwTickCount;
  522. QD_TBDelay = dwTickCount;
  523. QD_TFKDelay = dwTickCount;
  524. QD_TLDelay = dwTickCount;
  525. QD_CheckDelay = dwTickCount;
  526. SingOneFlg = 0;
  527. QD_JD_VAVEL = 0;
  528. QD_SM_VAVLE = 0;
  529. QD_XM_VAVLE = 0;
  530. QD_YD_VAVLE = 0;
  531. QD_TFK_VAVEL= 0;
  532. QD_TL_VAVLE = 0;
  533. QD_YBD_VAVLE = 0;
  534. QD_CS_OUT = 0;
  535. QD_XiaQieStep = 0;
  536. QD_MotorStep = 0;
  537. QD_TuiLianStep = 0;
  538. QD_TuiFangKuaiStep = 0;
  539. //QD_SZ_OUT = 1;
  540. QD_GZ_VAVLE = 0;
  541. QD_TABLE_VAVLE = 0;
  542. QD_XHG_VAVLE = 0;
  543. AxisDecStop(X_AXIS);
  544. QD_YuanDianStep = 0;
  545. QD_BinLianStep = 0;
  546. QD_BL_VAVLE = 0;
  547. user_datas[121] = 0;
  548. user_datas[122] = 0;
  549. if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
  550. }
  551. else
  552. {
  553. bRunning = 0;
  554. QD_XiaQieStep = 0;
  555. QD_AutoStep = 0;
  556. QD_MotorStep = 0;
  557. QD_TuiLianStep = 0;
  558. QD_TuiFangKuaiStep = 0;
  559. QD_YuanDianStep = 0;
  560. QD_AutoDelay = dwTickCount;
  561. QD_MotorDelay = dwTickCount;
  562. QD_XiaQieDelay = dwTickCount;
  563. QD_KaDaiDelay = dwTickCount;
  564. QD_CSDelay = dwTickCount;
  565. QD_TBDelay = dwTickCount;
  566. QD_TFKDelay = dwTickCount;
  567. QD_TLDelay = dwTickCount;
  568. QD_CheckDelay = dwTickCount;
  569. SingOneFlg = 0;
  570. QD_JD_VAVEL = 0;
  571. QD_SM_VAVLE = 0;
  572. QD_XM_VAVLE = 0;
  573. QD_YD_VAVLE = 0;
  574. QD_TFK_VAVEL= 0;
  575. QD_TL_VAVLE = 0;
  576. QD_YBD_VAVLE = 0;
  577. QD_CS_OUT = 0;
  578. QD_XiaQieStep = 0;
  579. QD_MotorStep = 0;
  580. QD_TuiLianStep = 0;
  581. QD_TuiFangKuaiStep = 0;
  582. QD_SZ_OUT = 1;
  583. QD_GZ_VAVLE = 0;
  584. QD_TABLE_VAVLE = 0;
  585. QD_XHG_VAVLE = 0;
  586. AxisDecStop(X_AXIS);
  587. QD_YuanDianStep = 0;
  588. QD_BinLianStep = 0;
  589. QD_BL_VAVLE = 0;
  590. user_datas[121] = 0;
  591. user_datas[122] = 0;
  592. if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
  593. }
  594. }
  595. if(bAlarmStop)
  596. {
  597. bAlarmStop = 0;
  598. QD_XiaQieStep = 0;
  599. QD_AutoStep = 0;
  600. QD_MotorStep = 0;
  601. QD_TuiLianStep = 0;
  602. QD_TuiFangKuaiStep = 0;
  603. QD_YuanDianStep = 0;
  604. QD_XiaQieStep = 0;
  605. QD_MotorStep = 0;
  606. QD_TuiLianStep = 0;
  607. QD_TuiFangKuaiStep = 0;
  608. QD_AutoDelay = dwTickCount;
  609. QD_MotorDelay = dwTickCount;
  610. QD_XiaQieDelay = dwTickCount;
  611. QD_KaDaiDelay = dwTickCount;
  612. QD_CSDelay = dwTickCount;
  613. QD_TBDelay = dwTickCount;
  614. QD_TFKDelay = dwTickCount;
  615. QD_TLDelay = dwTickCount;
  616. QD_CheckDelay = dwTickCount;
  617. SingOneFlg = 0;
  618. bRunning = 0;
  619. AxisDecStop(X_AXIS);
  620. QD_TABLE_VAVLE = 0;
  621. }
  622. }
  623. void QueDuan_CheckLength(void)
  624. {
  625. static long start_dist;
  626. switch(QD_CheckLengthStep)
  627. {
  628. case 0:break;
  629. case 1:
  630. start_dist = cRealPos;
  631. QD_CheckLengthStep = 2;
  632. break;
  633. case 2:
  634. if(QD_GUO_LIAN_IN_DW)
  635. {
  636. dwSaveLength = cRealPos - start_dist;
  637. QD_CheckLengthStep = 0;
  638. }
  639. break;
  640. }
  641. }
  642. void QueDuan_Motor_CS(void)
  643. {
  644. static long save_buff,length_buff,length_buff2,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  645. long dec_pulse;
  646. user_datas[124]= PosToPulse(X_AXIS,(QD_PARAM_ZIPPER_LENGTH)/3);
  647. user_datas[125]= cRealPos;
  648. user_datas[123] = MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DEC_SPEED);
  649. user_datas[127] = length_buff2;
  650. user_datas[126] = QD_MotorStep;
  651. // user_datas[121] = QD_XiaQieStep;
  652. QueDuan_CheckLength();
  653. switch(QD_MotorStep)
  654. {
  655. case 0:
  656. break;
  657. case 1: // 前点定位数控模式
  658. if(QD_SZ_OUT)
  659. {
  660. QD_SZ_OUT = 0;
  661. QD_MotorDelay = dwTickCount + 50;
  662. }
  663. QD_YD_VAVLE = 1;
  664. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  665. if((QD_TuiLianStep == 0) && !QD_TL_VAVLE && !QD_PARAM_TL_MODE)QD_TuiLianStep = 1;
  666. QD_MotorStep = 2;
  667. break;
  668. case 2:
  669. if(dwTickCount >= QD_MotorDelay)
  670. {
  671. if(QD_QIAN_LIMIT_IN || QD_QIAN_DEC_IN)
  672. {
  673. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  674. // MV_Set_Acc_CPU(X_AXIS, 10);
  675. // AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,-QD_PARAM_ON_BACK_LENGTH);
  676. QD_MotorDelay = dwTickCount + 1000;
  677. }
  678. QD_MotorStep = 3;
  679. QD_JD_VAVEL = 0;
  680. }
  681. break;
  682. case 3:
  683. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
  684. {
  685. if(cZipCnt == 0)
  686. {
  687. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  688. AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED/2,QD_DIR_P); //第一条走低速
  689. }
  690. else
  691. {
  692. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  693. AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,(length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH +QD_PARAM_SJZ_LENGTH),QD_PARAM_GO_LOW_SPEED,0xFFFFFF,QD_DIR_P);//第二条开始走两段速
  694. }
  695. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  696. QD_MotorStep = 4;
  697. }
  698. break;
  699. case 4:
  700. if(QD_QIAN_LIMIT_IN)
  701. {
  702. AxisEgmStop(X_AXIS);
  703. QD_MotorStep = 5;
  704. }
  705. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  706. else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
  707. break;
  708. case 5:
  709. if(!X_DRV)
  710. {
  711. QD_MotorDelay = dwTickCount;
  712. QD_MotorStep = 6;
  713. }
  714. break;
  715. case 6:
  716. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0))
  717. {
  718. if(bRunning)
  719. {
  720. QD_JD_VAVEL = 1;
  721. }
  722. QD_MotorStep = 7;
  723. QD_MotorDelay = dwTickCount + 100;
  724. }
  725. break;
  726. case 7:
  727. if(dwTickCount >= QD_MotorDelay)
  728. {
  729. QD_YBD_VAVLE = 0;
  730. QD_TL_VAVLE = 0;
  731. QD_MotorStep = 0;
  732. }
  733. break;
  734. case 20:// 后退使用电机定长
  735. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  736. QD_MotorStep = 21;
  737. break;
  738. case 21:
  739. if(dwTickCount >= QD_MotorDelay)
  740. {
  741. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  742. AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-QD_PARAM_ZIPPER_LENGTH);
  743. QD_MotorStep = 22;
  744. }
  745. break;
  746. case 22:
  747. if(!X_DRV)
  748. {
  749. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_FZ;
  750. QD_MotorStep = 23;
  751. }
  752. break;
  753. case 23:
  754. if(dwTickCount >= QD_MotorDelay)
  755. {
  756. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
  757. AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
  758. QD_MotorStep = 24;
  759. }
  760. break;
  761. case 24:
  762. if(!X_DRV)
  763. {
  764. QD_MotorStep = 0;
  765. QD_MotorDelay = dwTickCount;
  766. }
  767. break;
  768. case 30:
  769. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  770. QD_MotorStep = 31;
  771. if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
  772. break;
  773. case 31: // 后退使用钩针定长
  774. if(dwTickCount >= QD_MotorDelay)
  775. {
  776. save_buff = cRealPos;
  777. back_buff = cRealPos;
  778. if(QD_PARAM_DEC_MODE == 0)
  779. {
  780. if(QD_PARAM_BACK_MODE)
  781. {
  782. if(cZipCnt < 3)
  783. {
  784. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  785. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  786. QD_MotorStep = 32;
  787. }
  788. else
  789. {
  790. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  791. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  792. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  793. QD_MotorStep = 32;
  794. }
  795. }
  796. else
  797. {
  798. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  799. if(cZipCnt < 3)
  800. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  801. else
  802. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_GYHIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  803. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  804. QD_MotorStep = 32;
  805. }
  806. }
  807. else if(QD_PARAM_DEC_MODE == 1)
  808. {
  809. if(cZipCnt < 3)
  810. {
  811. // AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
  812. MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  813. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  814. QD_MotorStep = 32;
  815. }
  816. else
  817. {
  818. gouzhen_buff = cRealPos;
  819. MV_Set_Acc_CPU(X_AXIS, 10);
  820. // AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
  821. length_buffer = &QD_PARAM_LENGTH_OFFSET;
  822. dec_pulse = PosToPulse(X_AXIS,length_buff/4);
  823. if(MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DEC_SPEED) > dec_pulse)
  824. {
  825. AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_SPEED,-(length_buff+(*length_buffer)),QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,15);
  826. MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,15)));
  827. }
  828. else
  829. {
  830. AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_SPEED,-(length_buff+(*length_buffer)),QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  831. MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DEC_SPEED)));
  832. }
  833. QD_MotorDelay = dwTickCount;
  834. QD_CheckLengthStep = 1;
  835. QD_MotorStep = 34;
  836. }
  837. }
  838. else
  839. {
  840. gouzhen_buff = cRealPos;
  841. MV_Set_Acc_CPU(X_AXIS, 10);
  842. length_buffer = &QD_PARAM_LENGTH_OFFSET;
  843. dec_pulse = PosToPulse(X_AXIS,(QD_PARAM_ZIPPER_LENGTH-QD_PARAM_INPUT_LENGTH_OFFSET)/4);
  844. if(MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DEC_SPEED) > dec_pulse)
  845. {
  846. AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_SPEED,-(QD_PARAM_ZIPPER_LENGTH-QD_PARAM_INPUT_LENGTH_OFFSET),QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,15);
  847. MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,15)));
  848. }
  849. else
  850. {
  851. AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_SPEED,-(QD_PARAM_ZIPPER_LENGTH-QD_PARAM_INPUT_LENGTH_OFFSET),QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  852. MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DEC_SPEED)));
  853. }
  854. QD_MotorDelay = dwTickCount;
  855. QD_MotorStep = 34;
  856. }
  857. }
  858. break;
  859. case 32:
  860. if(QD_PARAM_DEC_MODE)
  861. {
  862. if(cZipCnt < 3)
  863. {
  864. if(QD_GUO_LIAN_IN_UP)
  865. {
  866. checkdelay_buff = cRealPos;
  867. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_FIRST_BACK_LOWSPEED);
  868. QD_MotorStep = 33;
  869. QD_MotorDelay =dwTickCount + QD_PARAM_DELAY_XM;
  870. }
  871. else if(dwTickCount >= QD_MotorDelay)
  872. {
  873. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  874. }
  875. }
  876. else
  877. {
  878. QD_MotorDelay = dwTickCount;
  879. QD_MotorStep = 34;
  880. }
  881. }
  882. else
  883. {
  884. if(QD_PARAM_BACK_MODE)
  885. {
  886. if(cZipCnt < 3)
  887. {
  888. if(QD_GUO_LIAN_IN_UP)
  889. {
  890. checkdelay_buff = cRealPos;
  891. QD_MotorDelay = dwTickCount;
  892. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  893. QD_MotorStep = 33;
  894. }
  895. else if(dwTickCount >= QD_MotorDelay)
  896. {
  897. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  898. }
  899. }
  900. else
  901. {
  902. 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_DEC_SPEED))))))
  903. {
  904. checkdelay_buff = cRealPos;
  905. QD_MotorDelay = dwTickCount;
  906. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  907. QD_MotorStep = 33;
  908. }
  909. else if(dwTickCount >= QD_MotorDelay)
  910. {
  911. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  912. }
  913. }
  914. }
  915. else
  916. {
  917. if(QD_GUO_LIAN_IN_UP)
  918. {
  919. checkdelay_buff = cRealPos;
  920. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GYLOW_SPEED);
  921. QD_MotorDelay = dwTickCount;
  922. QD_MotorStep = 33;
  923. }
  924. else if(dwTickCount >= QD_MotorDelay)
  925. {
  926. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  927. }
  928. }
  929. }
  930. break;
  931. case 33:
  932. if((cZipCnt < 3) || (QD_PARAM_DEC_MODE == 0))
  933. {
  934. if(dwTickCount >= QD_MotorDelay)
  935. {
  936. QD_XM_VAVLE = 1;
  937. QD_MotorStep = 34;
  938. }
  939. }
  940. else
  941. {
  942. if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH))
  943. {
  944. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  945. QD_MotorStep = 34;
  946. }
  947. }
  948. break;
  949. case 34:
  950. if(((cZipCnt < 3) || (QD_PARAM_DEC_MODE == 0)) && (QD_PARAM_DEC_MODE != 2))
  951. {
  952. 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)))
  953. {
  954. if(!QD_GUO_LIAN_IN)
  955. {
  956. gou_zhen_buff = cRealPos;
  957. QD_MotorStep = 35;
  958. }
  959. }
  960. }
  961. else
  962. {
  963. if(QD_PARAM_DEC_MODE == 2)
  964. {
  965. if(QD_PARAM_LT_ENABLE == 0)
  966. {
  967. if((cRealPos - gouzhen_buff) >= (QD_PARAM_ZIPPER_LENGTH - (QD_PARAM_DELAY_XM_LENGTH)))
  968. {
  969. QD_XM_VAVLE = 1;
  970. }
  971. if((cRealPos - gouzhen_buff) >= (QD_PARAM_ZIPPER_LENGTH - QD_PARAM_GOUZHEN_LENGTH))
  972. {
  973. QD_XM_VAVLE = 1;
  974. QD_GZ_VAVLE = 1;
  975. QD_MotorStep = 36;
  976. }
  977. }
  978. else
  979. {
  980. if((cRealPos - gouzhen_buff) >= (QD_PARAM_ZIPPER_LENGTH - (QD_PARAM_DELAY_XM_LENGTH)))
  981. {
  982. QD_XM_VAVLE = 1;
  983. QD_MotorStep = 36;
  984. }
  985. }
  986. }
  987. else
  988. {
  989. if(QD_PARAM_LT_ENABLE == 0)
  990. {
  991. if((cRealPos - gouzhen_buff) >= (length_buff - (QD_PARAM_DELAY_XM_LENGTH)))
  992. {
  993. QD_XM_VAVLE = 1;
  994. user_datas[125] = (cRealPos - gouzhen_buff);
  995. }
  996. if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
  997. {
  998. user_datas[124] = (cRealPos - gouzhen_buff);
  999. QD_XM_VAVLE = 1;
  1000. QD_GZ_VAVLE = 1;
  1001. QD_MotorStep = 36;
  1002. }
  1003. }
  1004. else
  1005. {
  1006. if((cRealPos - gouzhen_buff) >= (length_buff - (QD_PARAM_DELAY_XM_LENGTH)))
  1007. {
  1008. QD_XM_VAVLE = 1;
  1009. QD_MotorStep = 36;
  1010. }
  1011. }
  1012. }
  1013. }
  1014. user_datas[121] = gouzhen_buff;
  1015. user_datas[126] = QD_PARAM_DELAY_XM_LENGTH;
  1016. break;
  1017. case 35:
  1018. if(QD_GUO_LIAN_IN_DW)
  1019. {
  1020. gou_zhen_buff = cRealPos;
  1021. }
  1022. if(QD_GUO_LIAN_IN_UP)
  1023. {
  1024. gou_zhen_buff = cRealPos;
  1025. }
  1026. if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
  1027. {
  1028. AxisEgmStop(X_AXIS);
  1029. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1030. QD_MotorStep = 36;
  1031. }
  1032. break;
  1033. case 36:
  1034. if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
  1035. {
  1036. if(QD_PARAM_BACK_MODE)
  1037. {
  1038. if(cZipCnt < 3)
  1039. {
  1040. QD_GZ_VAVLE = 1;
  1041. }
  1042. else
  1043. {
  1044. QD_GZ_VAVLE = 1;
  1045. }
  1046. }
  1047. else
  1048. {
  1049. QD_GZ_VAVLE = 1;
  1050. }
  1051. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1052. QD_MotorStep = 37;
  1053. }
  1054. break;
  1055. case 37:
  1056. if(QD_XIA_MU_LIMIT_IN)
  1057. {
  1058. QD_MotorStep = 38;
  1059. QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  1060. }
  1061. else if(dwTickCount >= QD_MotorDelay) QD_SetAlarmCode(QD_XM_DAOWEI);
  1062. break;
  1063. case 38:
  1064. if(dwTickCount >= QD_MotorDelay)
  1065. {
  1066. QD_TFK_VAVEL = 1;
  1067. QD_MotorStep = 39;
  1068. }
  1069. break;
  1070. case 39:
  1071. if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
  1072. {
  1073. if(cZipCnt == 1)
  1074. {
  1075. length_buff = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH;
  1076. QD_MotorStep = 0;
  1077. }
  1078. else if(cZipCnt == 2)
  1079. {
  1080. length_buff2 = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH;
  1081. QD_MotorStep = 0;
  1082. }
  1083. else if((cZipCnt > 3) && (QD_PARAM_DEC_MODE == 1))
  1084. {
  1085. length_buffer = &QD_PARAM_OFFSET_LENGTH;
  1086. if((dwSaveLength - (*length_buffer)+ QD_PARAM_ERROR_LENGTH) < length_buff)
  1087. {
  1088. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1089. QD_CheckLengthStep = 0;
  1090. }
  1091. else if((dwSaveLength - (*length_buffer)-QD_PARAM_ERROR_LENGTH) > length_buff)
  1092. {
  1093. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1094. QD_CheckLengthStep = 0;
  1095. }
  1096. else
  1097. QD_CheckLengthStep = 0;
  1098. }
  1099. if(cZipCnt == 0)
  1100. {
  1101. go_length_buff = cRealPos - save_buff;
  1102. QD_MotorStep = 0;
  1103. }
  1104. else
  1105. {
  1106. if(QD_PARAM_DEC_MODE == 0)
  1107. {
  1108. QD_MotorStep = 0;
  1109. }
  1110. else
  1111. {
  1112. QD_MotorStep = 0;
  1113. }
  1114. }
  1115. }
  1116. break;
  1117. case 40:
  1118. dwTickCount + QD_PARAM_CUT_BACK_DELAY;
  1119. QD_MotorStep = 41;
  1120. break;
  1121. case 41:
  1122. if(dwTickCount >= QD_MotorDelay)
  1123. {
  1124. jz_buff = cRealPos;
  1125. if(QD_PARAM_SJZ_LENGTH == 0)
  1126. {
  1127. QD_JD_VAVEL = 0;
  1128. }
  1129. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
  1130. QD_MotorStep = 45;
  1131. }
  1132. break;
  1133. case 45: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
  1134. {
  1135. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  1136. QD_MotorStep = 43;
  1137. }
  1138. break;
  1139. case 43:
  1140. // 切断完成后拉电机动作
  1141. if(dwTickCount >= QD_MotorDelay)
  1142. {
  1143. if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  1144. {
  1145. user_datas[126] = cRealPos - jz_buff;
  1146. QD_JD_VAVEL = 0;
  1147. QD_MotorStep = 44;
  1148. }
  1149. else if(!X_DRV)
  1150. {
  1151. QD_JD_VAVEL = 0;
  1152. QD_MotorStep = 44;
  1153. }
  1154. }
  1155. break;
  1156. case 44: // 切断完成后拉电机动作
  1157. if(!X_DRV)
  1158. {
  1159. QD_MotorStep = 0;
  1160. QD_MotorDelay = dwTickCount;
  1161. }
  1162. break;
  1163. case 61: // 前点定位数控模式
  1164. if(QD_SZ_OUT)
  1165. {
  1166. QD_SZ_OUT = 0;
  1167. QD_MotorDelay = dwTickCount + 50;
  1168. }
  1169. QD_YD_VAVLE = 1;
  1170. if(QD_PARAM_TL_MODE)
  1171. {
  1172. }
  1173. else
  1174. {
  1175. if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1;
  1176. }
  1177. QD_MotorStep = 62;
  1178. break;
  1179. case 62:
  1180. if(dwTickCount >= QD_MotorDelay)
  1181. {
  1182. if(QD_QIAN_LIMIT_IN)
  1183. {
  1184. MV_Set_Acc_CPU(X_AXIS, 10);
  1185. AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,QD_PARAM_ON_BACK_LENGTH);
  1186. QD_MotorDelay = dwTickCount + 1000;
  1187. }
  1188. QD_MotorStep = 63;
  1189. QD_JD_VAVEL = 0;
  1190. }
  1191. break;
  1192. case 63:
  1193. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
  1194. {
  1195. go_buff = cRealPos;
  1196. if(cZipCnt > 1)
  1197. {
  1198. MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  1199. }
  1200. else
  1201. {
  1202. MoveAction_Const_Stop_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC_SPEED,QD_PARAM_DEC_SPEED);
  1203. }
  1204. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1205. QD_MotorStep = 64;
  1206. }
  1207. break;
  1208. case 64:
  1209. if(QD_PARAM_GO_MODE)
  1210. {
  1211. if(cZipCnt > 0)
  1212. {
  1213. if(((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || (QD_QIAN_DEC_IN_UP))
  1214. {
  1215. MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  1216. QD_MotorStep =65;
  1217. }
  1218. }
  1219. else
  1220. {
  1221. if(QD_QIAN_DEC_IN_UP)
  1222. {
  1223. MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  1224. QD_MotorStep =65;
  1225. }
  1226. }
  1227. }
  1228. else
  1229. {
  1230. QD_MotorStep =65;
  1231. }
  1232. break;
  1233. case 65:
  1234. if(QD_QIAN_LIMIT_IN_UP)
  1235. {
  1236. if(QD_PARAM_DAO_MODE)
  1237. {
  1238. dandao_buff = cRealPos;
  1239. QD_MotorStep = 70;
  1240. }
  1241. else
  1242. {
  1243. AxisEgmStop(X_AXIS);
  1244. QD_MotorStep = 66;
  1245. }
  1246. }
  1247. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1248. else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
  1249. break;
  1250. case 70:
  1251. if((dandao_buff - cRealPos) >= QD_PARAM_DANDAO_MODE_LENGTH)
  1252. {
  1253. AxisEgmStop(X_AXIS);
  1254. QD_MotorStep = 66;
  1255. }
  1256. break;
  1257. case 66:
  1258. if(!X_DRV)
  1259. {
  1260. QD_MotorDelay = dwTickCount;
  1261. QD_MotorStep = 67;
  1262. }
  1263. break;
  1264. case 67:
  1265. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  1266. {
  1267. if(bRunning)
  1268. {
  1269. QD_JD_VAVEL = 1;
  1270. }
  1271. QD_MotorStep = 68;
  1272. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1273. }
  1274. break;
  1275. case 68:
  1276. if(dwTickCount >= QD_MotorDelay)
  1277. {
  1278. QD_YD_VAVLE = 0;
  1279. QD_MotorStep = 0;
  1280. }
  1281. break;
  1282. }
  1283. }
  1284. //推方块动作
  1285. void QueDuan_TuiFangKuai(void)
  1286. {
  1287. }
  1288. void QueDuan_BingLian(void)
  1289. {
  1290. static long bl_pos_buff;
  1291. switch(QD_BinLianStep)
  1292. {
  1293. case 0:break;
  1294. case 1:
  1295. bl_pos_buff = cRealPos;
  1296. QD_BinLianStep = 2;
  1297. break;
  1298. case 2:
  1299. if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
  1300. {
  1301. QD_BL_VAVLE = 1;
  1302. QD_BinLianStep = 3;
  1303. }
  1304. break;
  1305. case 3:
  1306. if(QD_SM_VAVLE)QD_BL_VAVLE = 0;
  1307. break;
  1308. default:;
  1309. }
  1310. }
  1311. void QueDuan_Motor_QD(void)
  1312. {
  1313. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  1314. user_datas[124]= QD_MotorStep;
  1315. // user_datas[125]= go_length_buff;
  1316. // user_datas[123] = length_buff;
  1317. user_datas[127] = cRealPos;
  1318. user_datas[126] = go_buff - cRealPos;
  1319. user_datas[121] = QD_PARAM_GOUZHEN_LENGTH;
  1320. if(QD_GUO_LIAN_IN_DW)user_datas[122]++;
  1321. switch(QD_MotorStep)
  1322. {
  1323. case 0:
  1324. break;
  1325. case 1: // 前点定位数控模式
  1326. if(QD_SZ_OUT)
  1327. {
  1328. QD_SZ_OUT = 0;
  1329. QD_MotorDelay = dwTickCount + 50;
  1330. }
  1331. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  1332. if((QD_TuiLianStep == 0) && !QD_TL_VAVLE && !QD_PARAM_TL_MODE)QD_TuiLianStep = 1;
  1333. QD_MotorStep = 2;
  1334. break;
  1335. case 2:
  1336. if(dwTickCount >= QD_MotorDelay)
  1337. {
  1338. if(QD_QIAN_LIMIT_IN)
  1339. {
  1340. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
  1341. MV_Set_Acc_CPU(X_AXIS, 10);
  1342. AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_ON_BACK_LENGTH);
  1343. QD_MotorDelay = dwTickCount + 1000;
  1344. }
  1345. QD_MotorStep = 3;
  1346. QD_JD_VAVEL = 0;
  1347. }
  1348. break;
  1349. case 3:
  1350. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
  1351. {
  1352. if(cZipCnt == 0)
  1353. {
  1354. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  1355. AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); //第一条走低速
  1356. }
  1357. else
  1358. {
  1359. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  1360. AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,(length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH +QD_PARAM_SJZ_LENGTH),QD_PARAM_GO_LOW_SPEED,0xFFFFFF,QD_DIR_P);//第二条开始走两段速
  1361. }
  1362. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1363. QD_MotorStep = 4;
  1364. }
  1365. break;
  1366. case 4:
  1367. if(QD_QIAN_LIMIT_IN_UP)
  1368. {
  1369. AxisEgmStop(X_AXIS);
  1370. QD_MotorStep = 5;
  1371. }
  1372. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1373. else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
  1374. break;
  1375. case 5:
  1376. if(!X_DRV)
  1377. {
  1378. QD_MotorDelay = dwTickCount;
  1379. QD_MotorStep = 6;
  1380. }
  1381. break;
  1382. case 6:
  1383. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0))
  1384. {
  1385. if(bRunning)
  1386. {
  1387. QD_JD_VAVEL = 1;
  1388. }
  1389. QD_MotorStep = 7;
  1390. QD_MotorDelay = dwTickCount + 100;
  1391. }
  1392. break;
  1393. case 7:
  1394. if(dwTickCount >= QD_MotorDelay)
  1395. {
  1396. QD_YBD_VAVLE = 0;
  1397. QD_TL_VAVLE = 0;
  1398. QD_MotorStep = 0;
  1399. }
  1400. break;
  1401. case 20:// 后退使用电机定长
  1402. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1403. QD_MotorStep = 21;
  1404. break;
  1405. case 21:
  1406. if(dwTickCount >= QD_MotorDelay)
  1407. {
  1408. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
  1409. AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-QD_PARAM_ZIPPER_LENGTH);
  1410. QD_MotorStep = 22;
  1411. }
  1412. break;
  1413. case 22:
  1414. if(!X_DRV)
  1415. {
  1416. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_FZ;
  1417. QD_MotorStep = 23;
  1418. }
  1419. break;
  1420. case 23:
  1421. if(dwTickCount >= QD_MotorDelay)
  1422. {
  1423. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
  1424. AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
  1425. QD_MotorStep = 24;
  1426. }
  1427. break;
  1428. case 24:
  1429. if(!X_DRV)
  1430. {
  1431. QD_MotorStep = 0;
  1432. QD_MotorDelay = dwTickCount;
  1433. }
  1434. break;
  1435. case 30:
  1436. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1437. QD_MotorStep = 31;
  1438. if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
  1439. break;
  1440. case 31: // 后退使用钩针定长
  1441. if(dwTickCount >= QD_MotorDelay)
  1442. {
  1443. save_buff = cRealPos;
  1444. back_buff = cRealPos;
  1445. SetAccTime(X_AXIS,5);
  1446. SetDecTime(X_AXIS,5);
  1447. if(QD_PARAM_DEC_MODE == 0)
  1448. {
  1449. if(QD_PARAM_BACK_MODE)
  1450. {
  1451. if(cZipCnt < 2)
  1452. {
  1453. AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
  1454. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1455. QD_MotorStep = 32;
  1456. }
  1457. else
  1458. {
  1459. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  1460. AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
  1461. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1462. QD_MotorStep = 32;
  1463. }
  1464. }
  1465. else
  1466. {
  1467. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  1468. AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
  1469. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1470. QD_MotorStep = 32;
  1471. }
  1472. }
  1473. else
  1474. {
  1475. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  1476. if(cZipCnt < 2)
  1477. {
  1478. QD_XHG_VAVLE = 0;
  1479. AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
  1480. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1481. QD_MotorStep = 32;
  1482. }
  1483. else
  1484. {
  1485. gouzhen_buff = cRealPos;
  1486. QD_XHG_VAVLE = 1;
  1487. //AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,(length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH),QD_PARAM_GO_LOW_SPEED,QD_PARAM_Back_LOW_SPEED_LENGTH,QD_DIR_N);
  1488. MV_Set_Acc_CPU(X_AXIS, 10);
  1489. AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
  1490. MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)));
  1491. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1492. QD_MotorStep = 33;
  1493. }
  1494. // AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_N);
  1495. }
  1496. }
  1497. break;
  1498. case 32:
  1499. if(QD_PARAM_DEC_MODE)
  1500. {
  1501. if(cZipCnt < 2)
  1502. {
  1503. if(QD_GUO_LIAN_IN_UP)
  1504. {
  1505. checkdelay_buff = cRealPos;
  1506. QD_MotorDelay = dwTickCount;
  1507. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1508. QD_MotorStep = 33;
  1509. }
  1510. else if(dwTickCount >= QD_MotorDelay)
  1511. {
  1512. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1513. }
  1514. }
  1515. else
  1516. {
  1517. QD_MotorStep = 36;
  1518. }
  1519. }
  1520. else
  1521. {
  1522. if(QD_PARAM_BACK_MODE)
  1523. {
  1524. if(cZipCnt < 2)
  1525. {
  1526. if(QD_GUO_LIAN_IN_UP)
  1527. {
  1528. checkdelay_buff = cRealPos;
  1529. QD_MotorDelay = dwTickCount;
  1530. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1531. QD_MotorStep = 33;
  1532. }
  1533. else if(dwTickCount >= QD_MotorDelay)
  1534. {
  1535. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1536. }
  1537. }
  1538. else
  1539. {
  1540. 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,10)))))
  1541. {
  1542. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1543. }
  1544. if(QD_GUO_LIAN_IN_UP)
  1545. {
  1546. checkdelay_buff = cRealPos;
  1547. QD_MotorDelay = dwTickCount;
  1548. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1549. QD_MotorStep = 33;
  1550. }
  1551. else if(dwTickCount >= QD_MotorDelay)
  1552. {
  1553. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1554. }
  1555. }
  1556. }
  1557. else
  1558. {
  1559. if(QD_GUO_LIAN_IN_UP)
  1560. {
  1561. checkdelay_buff = cRealPos;
  1562. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1563. QD_MotorDelay = dwTickCount;
  1564. QD_MotorStep = 33;
  1565. }
  1566. else if(dwTickCount >= QD_MotorDelay)
  1567. {
  1568. QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1569. }
  1570. }
  1571. }
  1572. break;
  1573. case 33:
  1574. if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0))
  1575. {
  1576. 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)))
  1577. {
  1578. if(QD_PARAM_GOUZHEN_LENGTH != 0)QD_GZ_VAVLE = 1;
  1579. QD_MotorStep = 34;
  1580. }
  1581. }
  1582. else
  1583. {
  1584. if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH))
  1585. {
  1586. if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1587. QD_MotorStep = 34;
  1588. }
  1589. }
  1590. break;
  1591. case 34:
  1592. if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0))
  1593. {
  1594. if(QD_GUO_LIAN_IN_DW)
  1595. {
  1596. gou_zhen_buff = cRealPos;
  1597. QD_MotorStep = 35;
  1598. }
  1599. }
  1600. else
  1601. {
  1602. if(QD_PARAM_GOUZHEN_LENGTH != 0)
  1603. {
  1604. if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
  1605. {
  1606. if(QD_PARAM_GOUZHEN_LENGTH != 0)QD_GZ_VAVLE = 1;
  1607. QD_MotorStep = 36;
  1608. }
  1609. }
  1610. else
  1611. {
  1612. QD_MotorStep = 36;
  1613. }
  1614. }
  1615. break;
  1616. case 35:
  1617. if(QD_GUO_LIAN_IN_DW)
  1618. {
  1619. gou_zhen_buff = cRealPos;
  1620. }
  1621. if(QD_GUO_LIAN_IN_UP)
  1622. {
  1623. gou_zhen_buff = cRealPos;
  1624. }
  1625. if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
  1626. {
  1627. AxisEgmStop(X_AXIS);
  1628. QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1629. QD_MotorStep = 36;
  1630. }
  1631. break;
  1632. case 36:
  1633. if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
  1634. {
  1635. if(QD_PARAM_GOUZHEN_LENGTH == 0)QD_GZ_VAVLE = 1;
  1636. if(QD_PARAM_DEC_MODE == 0)QD_GZ_VAVLE = 1;
  1637. if(!QD_PARAM_TL_MODE)QD_YBD_VAVLE = 1;
  1638. QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  1639. QD_MotorStep = 37;
  1640. }
  1641. break;
  1642. case 37:
  1643. if(dwTickCount >= QD_MotorDelay)
  1644. {
  1645. QD_TFK_VAVEL = 1;
  1646. QD_MotorDelay = dwTickCount + 1000;
  1647. QD_MotorStep = 38;
  1648. }
  1649. break;
  1650. case 38:
  1651. if(QD_GOUZHEN_IN && !X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
  1652. {
  1653. if(QD_PARAM_TL_MODE)QD_YBD_VAVLE = 1;
  1654. if(cZipCnt == 1)
  1655. {
  1656. length_buff = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH;
  1657. }
  1658. if(cZipCnt == 0)
  1659. {
  1660. go_length_buff = cRealPos - save_buff;
  1661. }
  1662. cTuiFangKuaiCnt = 0;
  1663. QD_MotorStep = 0;
  1664. }
  1665. else if(dwTickCount >= QD_MotorDelay)
  1666. {
  1667. if(cTuiFangKuaiCnt == 0)
  1668. {
  1669. QD_MotorStep = 100;
  1670. QD_TFK_VAVEL = 0;
  1671. cTuiFangKuaiCnt++;
  1672. QD_MotorDelay = dwTickCount + 1000;
  1673. }
  1674. else
  1675. QD_SetAlarmCode(QD_GZ_ALARM);
  1676. }
  1677. break;
  1678. case 100:
  1679. if(dwTickCount >= QD_MotorDelay)
  1680. {
  1681. QD_MotorStep = 37;
  1682. }
  1683. break;
  1684. case 40:
  1685. if(dwTickCount >= QD_MotorDelay)
  1686. {
  1687. jz_buff = cRealPos;
  1688. if(QD_PARAM_SJZ_LENGTH == 0)
  1689. {
  1690. QD_JD_VAVEL = 0;
  1691. }
  1692. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
  1693. QD_MotorStep = 45;
  1694. }
  1695. break;
  1696. case 45: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
  1697. {
  1698. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  1699. QD_MotorStep = 43;
  1700. }
  1701. break;
  1702. case 41:
  1703. if(!X_DRV)
  1704. {
  1705. QD_JD_VAVEL = 0;
  1706. QD_MotorDelay = dwTickCount + 20;
  1707. QD_MotorStep = 42;
  1708. }
  1709. break;
  1710. case 42:
  1711. if(dwTickCount >= QD_MotorDelay)
  1712. {
  1713. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  1714. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH));
  1715. QD_MotorStep = 44;
  1716. }
  1717. break;
  1718. case 43:
  1719. // 切断完成后拉电机动作
  1720. if(dwTickCount >= QD_MotorDelay)
  1721. {
  1722. if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  1723. {
  1724. user_datas[126] = cRealPos - jz_buff;
  1725. QD_JD_VAVEL = 0;
  1726. QD_MotorStep = 44;
  1727. }
  1728. else if(!X_DRV)
  1729. {
  1730. QD_JD_VAVEL = 0;
  1731. QD_MotorStep = 44;
  1732. }
  1733. }
  1734. break;
  1735. case 44: // 切断完成后拉电机动作
  1736. if(!X_DRV)
  1737. {
  1738. QD_MotorStep = 0;
  1739. QD_MotorDelay = dwTickCount;
  1740. }
  1741. break;
  1742. case 61: // 前点定位数控模式
  1743. if(QD_SZ_OUT)
  1744. {
  1745. QD_SZ_OUT = 0;
  1746. QD_MotorDelay = dwTickCount + 50;
  1747. }
  1748. QD_YD_VAVLE = 1;
  1749. if(QD_PARAM_TL_MODE)
  1750. {
  1751. // if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
  1752. }
  1753. else
  1754. {
  1755. if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1;
  1756. }
  1757. QD_MotorStep = 62;
  1758. break;
  1759. case 62:
  1760. if(dwTickCount >= QD_MotorDelay)
  1761. {
  1762. if(QD_QIAN_LIMIT_IN)
  1763. {
  1764. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  1765. MV_Set_Acc_CPU(X_AXIS, 10);
  1766. AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH);
  1767. QD_MotorDelay = dwTickCount + 1000;
  1768. }
  1769. QD_MotorStep = 63;
  1770. QD_JD_VAVEL = 0;
  1771. }
  1772. break;
  1773. case 63:
  1774. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
  1775. {
  1776. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_N;
  1777. go_buff = cRealPos;
  1778. if(cZipCnt > 0)
  1779. {
  1780. MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);//
  1781. }
  1782. else
  1783. {
  1784. MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED);
  1785. }
  1786. // MoveAction_Const_Stop(X_AXIS, QD_DIR_P,QD_PARAM_GO_HIGH_SPEED);//
  1787. // AxisContinueMove(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_DIR_P); //第一条走低速
  1788. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1789. QD_MotorStep =64;
  1790. }
  1791. break;
  1792. case 64:
  1793. if(QD_PARAM_GO_MODE)
  1794. {
  1795. if(cZipCnt > 0)
  1796. {
  1797. if(((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,30))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
  1798. {
  1799. MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  1800. QD_MotorStep =65;
  1801. }
  1802. }
  1803. else
  1804. {
  1805. // if(QD_QIAN_DEC_IN)
  1806. {
  1807. // if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  1808. QD_MotorStep =65;
  1809. }
  1810. }
  1811. }
  1812. else
  1813. {
  1814. // if(QD_QIAN_DEC_IN)
  1815. {
  1816. // if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  1817. QD_MotorStep =65;
  1818. }
  1819. }
  1820. break;
  1821. case 65:
  1822. if(QD_QIAN_LIMIT_IN_UP)
  1823. {
  1824. if(QD_PARAM_DAO_MODE)
  1825. {
  1826. dandao_buff = cRealPos;
  1827. QD_MotorStep = 70;
  1828. }
  1829. else
  1830. {
  1831. AxisEgmStop(X_AXIS);
  1832. QD_MotorStep = 66;
  1833. }
  1834. }
  1835. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  1836. else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
  1837. break;
  1838. case 70:
  1839. if((dandao_buff - cRealPos) >= QD_PARAM_DANDAO_MODE_LENGTH)
  1840. {
  1841. AxisEgmStop(X_AXIS);
  1842. QD_MotorStep = 66;
  1843. }
  1844. break;
  1845. case 66:
  1846. if(!X_DRV)
  1847. {
  1848. QD_MotorDelay = dwTickCount;
  1849. QD_MotorStep = 67;
  1850. }
  1851. break;
  1852. case 67:
  1853. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  1854. {
  1855. if(bRunning)
  1856. {
  1857. QD_JD_VAVEL = 1;
  1858. }
  1859. QD_MotorStep = 68;
  1860. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1861. }
  1862. break;
  1863. case 68:
  1864. if(dwTickCount >= QD_MotorDelay)
  1865. {
  1866. QD_YBD_VAVLE = 0;
  1867. QD_TL_VAVLE = 0;
  1868. QD_MotorStep = 0;
  1869. }
  1870. break;
  1871. }
  1872. }
  1873. //不带过链感应长度输入电机长度
  1874. void QueDuan_Motor_NoGL(void)
  1875. {
  1876. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  1877. user_datas[124]= QD_MotorStep;
  1878. // user_datas[125]= go_length_buff;
  1879. // user_datas[123] = length_buff;
  1880. user_datas[127] = cRealPos;
  1881. // user_datas[126] = go_buff - cRealPos;
  1882. // user_datas[121] = QD_PARAM_GOUZHEN_LENGTH;
  1883. if(QD_GUO_LIAN_IN_DW)user_datas[122]++;
  1884. switch(QD_MotorStep)
  1885. {
  1886. case 30:
  1887. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  1888. if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
  1889. if(QD_PARAM_LENGTH_MODE == 0)
  1890. QD_MotorStep = 101;
  1891. else
  1892. QD_MotorStep = 31;
  1893. break;
  1894. case 31:
  1895. if(dwTickCount >= QD_MotorDelay)
  1896. {
  1897. back_buff = cRealPos;
  1898. gou_zhen_buff = cRealPos;
  1899. save_buff = cRealPos;
  1900. // AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
  1901. MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
  1902. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1903. QD_MotorStep = 33;
  1904. }
  1905. break;
  1906. case 32:
  1907. if(((cRealPos - gou_zhen_buff) > ((QD_PARAM_ZIPPER_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
  1908. {
  1909. if(user_datas[127] == 0)
  1910. user_datas[127] = cRealPos - gou_zhen_buff;
  1911. save_buff = cRealPos;
  1912. QD_GZ_VAVLE = 1;
  1913. }
  1914. if((cRealPos - back_buff) > ((QD_PARAM_ZIPPER_LENGTH -QD_PARAM_Back_LOW_SPEED_LENGTH)))//(QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,5)))))
  1915. {
  1916. if(X_DRV)
  1917. {
  1918. MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  1919. }
  1920. QD_MotorStep = 33;
  1921. }
  1922. else if(dwTickCount >= QD_MotorDelay)
  1923. {
  1924. QD_SetAlarmCode(QD_GZ_ALARM);
  1925. }
  1926. break;
  1927. case 33:
  1928. if(((cRealPos - gou_zhen_buff) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
  1929. {
  1930. QD_GZ_VAVLE = 1;
  1931. if(user_datas[127] == 0)
  1932. user_datas[127] = cRealPos - gou_zhen_buff;
  1933. }
  1934. if(QD_GOUZHEN_IN)
  1935. {
  1936. AxisEgmStop(X_AXIS);
  1937. QD_YD_VAVLE = 1;
  1938. //user_datas[126] = cRealPos - save_buff;
  1939. QD_MotorDelay = dwTickCount + 3000;
  1940. QD_MotorStep = 34;
  1941. }
  1942. else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH)) && QD_GZ_VAVLE)
  1943. {
  1944. // user_datas[126] = cRealPos - save_buff;
  1945. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  1946. }
  1947. else if(dwTickCount >= QD_MotorDelay)
  1948. {
  1949. QD_SetAlarmCode(QD_GZ_ALARM);
  1950. }
  1951. break;
  1952. case 34:
  1953. if(!X_DRV && (dwTickCount >= QD_MotorDelay))
  1954. {
  1955. // AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
  1956. QD_MotorStep = 35;
  1957. }
  1958. break;
  1959. case 35:
  1960. if(!X_DRV)
  1961. {
  1962. QD_MotorStep = 36;
  1963. }
  1964. break;
  1965. case 36:
  1966. QD_MotorStep = 0;
  1967. break;
  1968. case 101:
  1969. if(dwTickCount >= QD_MotorDelay)
  1970. {
  1971. back_buff = cRealPos;
  1972. gou_zhen_buff = cRealPos;
  1973. save_buff = cRealPos;
  1974. if(cZipCnt < 2)
  1975. {
  1976. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1977. AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
  1978. QD_MotorStep = 102;
  1979. }
  1980. else
  1981. {
  1982. MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,((length_buff - QD_PARAM_TC_LENGTH) - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
  1983. QD_MotorStep = 102;
  1984. }
  1985. }
  1986. break;
  1987. case 102:
  1988. if(cZipCnt < 2)
  1989. {
  1990. if(QD_GUO_LIAN_IN_UP)
  1991. {
  1992. QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
  1993. QD_MotorStep = 103;
  1994. }
  1995. }
  1996. else
  1997. {
  1998. if(((cRealPos - gou_zhen_buff) > ((length_buff - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
  1999. {
  2000. save_buff = cRealPos;
  2001. QD_GZ_VAVLE = 1;
  2002. }
  2003. if((cRealPos - back_buff) > ((length_buff - QD_PARAM_TC_LENGTH) - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)))))
  2004. {
  2005. if(X_DRV)
  2006. {
  2007. MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
  2008. }
  2009. QD_MotorStep = 103;
  2010. }
  2011. }
  2012. break;
  2013. case 103:
  2014. if(cZipCnt < 2)
  2015. {
  2016. if(dwTickCount >= QD_MotorDelay)
  2017. {
  2018. QD_GZ_VAVLE = 1;
  2019. QD_MotorStep = 104;
  2020. }
  2021. }
  2022. else
  2023. {
  2024. if(((cRealPos - gou_zhen_buff) > ((length_buff - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
  2025. {
  2026. QD_GZ_VAVLE = 1;
  2027. }
  2028. if(QD_GOUZHEN_IN)
  2029. {
  2030. QD_YD_VAVLE = 1;
  2031. QD_MotorDelay = dwTickCount + 5;
  2032. QD_MotorStep = 105;
  2033. }
  2034. else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH)) && QD_GZ_VAVLE)
  2035. {
  2036. QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
  2037. }
  2038. }
  2039. break;
  2040. case 104:
  2041. if(cZipCnt < 2)
  2042. {
  2043. if(QD_GOUZHEN_IN)
  2044. {
  2045. AxisEgmStop(X_AXIS);
  2046. QD_YD_VAVLE = 1;
  2047. QD_MotorStep = 105;
  2048. }
  2049. }
  2050. else
  2051. {
  2052. }
  2053. break;
  2054. case 105:
  2055. if(!X_DRV)
  2056. {
  2057. if(cZipCnt == 0)
  2058. {
  2059. go_length_buff = cRealPos - back_buff;
  2060. }
  2061. else if(cZipCnt == 1)
  2062. {
  2063. length_buff = cRealPos - back_buff;
  2064. SetData32bits(1,length_buff);
  2065. }
  2066. AxisMovePos(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH);
  2067. QD_MotorStep = 106;
  2068. }
  2069. break;
  2070. case 106:
  2071. if(!X_DRV)
  2072. {
  2073. QD_MotorStep = 0;
  2074. }
  2075. break;
  2076. case 40:
  2077. if(dwTickCount >= QD_MotorDelay)
  2078. {
  2079. jz_buff = cRealPos;
  2080. /* if(1)//(QD_PARAM_SJZ_LENGTH <= 200)
  2081. {
  2082. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH));
  2083. QD_MotorStep = 41;
  2084. }*/
  2085. /* else
  2086. {
  2087. QD_JD_VAVEL = 0;
  2088. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  2089. QD_MotorStep = 43;
  2090. }*/
  2091. if(QD_PARAM_SJZ_LENGTH == 0)
  2092. {
  2093. QD_JD_VAVEL = 0;
  2094. }
  2095. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
  2096. QD_MotorStep = 45;
  2097. }
  2098. break;
  2099. case 45: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
  2100. {
  2101. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  2102. QD_MotorStep = 43;
  2103. }
  2104. break;
  2105. case 41:
  2106. if(!X_DRV)
  2107. {
  2108. QD_JD_VAVEL = 0;
  2109. QD_MotorDelay = dwTickCount + 20;
  2110. QD_MotorStep = 42;
  2111. }
  2112. break;
  2113. case 42:
  2114. if(dwTickCount >= QD_MotorDelay)
  2115. {
  2116. if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
  2117. AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH));
  2118. QD_MotorStep = 44;
  2119. }
  2120. break;
  2121. case 43:
  2122. // 切断完成后拉电机动作
  2123. if(dwTickCount >= QD_MotorDelay)
  2124. {
  2125. if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  2126. {
  2127. user_datas[126] = cRealPos - jz_buff;
  2128. QD_JD_VAVEL = 0;
  2129. QD_MotorStep = 44;
  2130. }
  2131. else if(!X_DRV)
  2132. {
  2133. QD_JD_VAVEL = 0;
  2134. QD_MotorStep = 44;
  2135. }
  2136. }
  2137. break;
  2138. case 44: // 切断完成后拉电机动作
  2139. if(!X_DRV)
  2140. {
  2141. QD_MotorStep = 0;
  2142. QD_MotorDelay = dwTickCount;
  2143. }
  2144. break;
  2145. case 61: // 前点定位数控模式
  2146. if(QD_SZ_OUT)
  2147. {
  2148. QD_SZ_OUT = 0;
  2149. QD_MotorDelay = dwTickCount + 50;
  2150. }
  2151. if(!QD_TL_VAVLE)
  2152. {
  2153. if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
  2154. {
  2155. QD_TuiLianStep = 1;
  2156. QD_MotorStep = 62;
  2157. }
  2158. }
  2159. else
  2160. QD_MotorStep = 62;
  2161. break;
  2162. case 62:
  2163. if(dwTickCount >= QD_MotorDelay)
  2164. {
  2165. if(QD_QIAN_LIMIT_IN)
  2166. {
  2167. AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH);
  2168. QD_MotorDelay = dwTickCount + 1000;
  2169. }
  2170. QD_MotorStep = 63;
  2171. QD_JD_VAVEL = 0;
  2172. }
  2173. break;
  2174. case 63:
  2175. if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay) && !QD_SHANG_MU_LIMIT_IN)
  2176. {
  2177. go_buff = cRealPos;
  2178. if(cZipCnt > 0)
  2179. {
  2180. MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);//
  2181. }
  2182. else
  2183. {
  2184. if(QD_PARAM_LENGTH_MODE == 0)
  2185. MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED);
  2186. else
  2187. MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED);
  2188. }
  2189. QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  2190. QD_MotorStep =64;
  2191. }
  2192. break;
  2193. case 64:
  2194. if(QD_PARAM_LENGTH_MODE == 0)
  2195. {
  2196. if(((go_buff - cRealPos) > ((go_length_buff - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,30))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
  2197. {
  2198. MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  2199. QD_MotorStep =65;
  2200. }
  2201. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  2202. }
  2203. else
  2204. {
  2205. if(((go_buff - cRealPos) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,30))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
  2206. {
  2207. MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
  2208. QD_MotorStep =65;
  2209. }
  2210. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  2211. }
  2212. break;
  2213. case 65:
  2214. if(QD_QIAN_LIMIT_IN_UP)
  2215. {
  2216. AxisEgmStop(X_AXIS);
  2217. QD_MotorStep = 66;
  2218. }
  2219. else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
  2220. else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
  2221. break;
  2222. case 66:
  2223. if(!X_DRV)
  2224. {
  2225. QD_MotorDelay = dwTickCount;
  2226. QD_MotorStep = 67;
  2227. }
  2228. break;
  2229. case 67:
  2230. if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  2231. {
  2232. if(bRunning)
  2233. {
  2234. QD_JD_VAVEL = 1;
  2235. }
  2236. QD_MotorStep = 68;
  2237. QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
  2238. }
  2239. break;
  2240. case 68:
  2241. if(dwTickCount >= QD_MotorDelay)
  2242. {
  2243. QD_YD_VAVLE = 0;
  2244. QD_TL_VAVLE = 0;
  2245. QD_MotorStep = 0;
  2246. }
  2247. break;
  2248. }
  2249. }
  2250. //电机动作
  2251. void QueDuan_Motor(void) //
  2252. {
  2253. switch(QD_MACHINE_TYPE)
  2254. {
  2255. case QD_CS_TUIFANGKUAI:
  2256. {
  2257. QueDuan_Motor_CS();
  2258. }break;
  2259. case QD_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
  2260. case QD_QQ_TUIFANGKUAI: QueDuan_Motor_QD();break;
  2261. case QD_NO_GL_TUIFANGKUAI:QueDuan_Motor_NoGL();break;
  2262. default:;
  2263. }
  2264. }
  2265. //超声方式下切
  2266. void QueDuan_XiaQue_CS(void)
  2267. {
  2268. switch(QD_XiaQieStep)
  2269. {
  2270. case 0:
  2271. break;
  2272. case 1:
  2273. if(bRunning)
  2274. {
  2275. QD_XiaQieStep = 6;
  2276. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2277. }
  2278. else
  2279. QD_XiaQieStep = 2;
  2280. break;
  2281. case 2:
  2282. QD_XM_VAVLE = 1;
  2283. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2284. QD_XiaQieStep = 3;
  2285. break;
  2286. case 3:
  2287. if(QD_XIA_MU_LIMIT_IN)
  2288. {
  2289. QD_XiaQieDelay = dwTickCount + QD_PARAM_GZ_DELAY;
  2290. QD_XiaQieStep = 4;
  2291. }
  2292. else if(dwTickCount >= QD_XiaQieDelay)
  2293. {
  2294. QD_SetAlarmCode(QD_XM_DAOWEI);
  2295. }
  2296. break;
  2297. case 4:
  2298. QD_GZ_VAVLE = 1;
  2299. QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
  2300. QD_XiaQieStep = 5;
  2301. break;
  2302. case 5:
  2303. QD_TFK_VAVEL = 1;
  2304. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2305. QD_XiaQieStep = 6;
  2306. break;
  2307. case 6:
  2308. if(QD_XIA_MU_LIMIT_IN)
  2309. {
  2310. QD_XiaQieStep = 7;
  2311. QD_XiaQieDelay = dwTickCount + 1000;
  2312. }
  2313. else if(dwTickCount >= QD_XiaQieDelay)
  2314. {
  2315. QD_SetAlarmCode(QD_XM_DAOWEI);
  2316. }
  2317. break;
  2318. case 7:
  2319. if(QD_GOUZHEN_IN)
  2320. {
  2321. QD_YD_VAVLE = 1;
  2322. cTuiFangKuaiCnt = 0;
  2323. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  2324. QD_XiaQieStep = 8;
  2325. }
  2326. else if((dwTickCount >= QD_XiaQieDelay))
  2327. {
  2328. if(cTuiFangKuaiCnt == 0)
  2329. {
  2330. QD_TFK_VAVEL = 0;
  2331. cTuiFangKuaiCnt++;
  2332. QD_XiaQieDelay = dwTickCount + 1000;
  2333. QD_XiaQieStep = 100;
  2334. }
  2335. else
  2336. QD_SetAlarmCode(QD_GZ_ALARM);
  2337. }
  2338. break;
  2339. case 100:
  2340. if((dwTickCount >= QD_XiaQieDelay))
  2341. {
  2342. QD_XiaQieStep = 5;
  2343. }
  2344. break;
  2345. case 8:
  2346. if(dwTickCount >= QD_XiaQieDelay)
  2347. {
  2348. QD_SM_VAVLE = 1;
  2349. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2350. QD_XiaQieStep = 9;
  2351. }
  2352. break;
  2353. case 9:
  2354. if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  2355. {
  2356. if(QD_MACHINE_TYPE == QD_NO_CS_TUIFANGKUAI)
  2357. {
  2358. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
  2359. QD_XiaQieStep = 12;
  2360. }
  2361. else
  2362. {
  2363. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
  2364. QD_XiaQieStep = 10;
  2365. }
  2366. }
  2367. else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
  2368. break;
  2369. case 10:
  2370. if(dwTickCount >= QD_XiaQieDelay)
  2371. {
  2372. if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
  2373. QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
  2374. QD_XiaQieStep = 11;
  2375. }
  2376. break;
  2377. case 11:
  2378. if(dwTickCount >= QD_XiaQieDelay)
  2379. {
  2380. QD_CS_OUT = 0;
  2381. QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
  2382. QD_XiaQieStep = 12;
  2383. }
  2384. break;
  2385. case 12:
  2386. if(dwTickCount >= QD_XiaQieDelay)
  2387. {
  2388. QD_SM_VAVLE = 0;
  2389. QD_XM_VAVLE = 0;
  2390. QD_TFK_VAVEL = 0;
  2391. QD_GZ_VAVLE = 0;
  2392. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2393. QD_XiaQieStep = 13;
  2394. }//
  2395. break;
  2396. case 13:
  2397. if(QD_SHANG_MU_ORIGIN_IN && !QD_XIA_MU_LIMIT_IN)
  2398. {
  2399. QD_XiaQieStep = 0;
  2400. }
  2401. else if(dwTickCount >= QD_XiaQieDelay)
  2402. {
  2403. QD_SetAlarmCode(QD_SM_YUANWEI);
  2404. }
  2405. break;
  2406. }
  2407. }
  2408. void QueDuan_TuiLianNormal(void)
  2409. {
  2410. switch(QD_TuiLianStep)
  2411. {
  2412. case 0:
  2413. break;
  2414. case 1:
  2415. QD_TuiLianStep = 2;
  2416. break;
  2417. case 2:
  2418. QD_YBD_VAVLE = 1;
  2419. QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
  2420. QD_TuiLianStep = 3;
  2421. break;
  2422. case 3:
  2423. if(dwTickCount >= QD_TLDelay)
  2424. {
  2425. if(QD_PARAM_TL_MODE)
  2426. {
  2427. QD_TuiLianStep = 10;
  2428. }
  2429. else
  2430. {
  2431. QD_TL_VAVLE = 1;
  2432. if(!bRunning)QD_TFK_VAVEL = 0;
  2433. QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
  2434. QD_TuiLianStep = 4;
  2435. }
  2436. }
  2437. break;
  2438. case 4:
  2439. if(dwTickCount >= QD_TLDelay)
  2440. {
  2441. // QD_TL_VAVLE = 0;
  2442. QD_TuiLianStep = 0;
  2443. }
  2444. break;
  2445. case 10:
  2446. if(bRunning && QD_PARAM_TL_MODE)AxisMovePos(Y_AXIS,QD_PARAM_TL_SPEED,QD_PARAM_TL_LENGTH);
  2447. QD_TuiLianStep = 11;
  2448. break;
  2449. case 11:
  2450. if(!Y_DRV)
  2451. {
  2452. {
  2453. QD_TuiLianStep = 0;
  2454. }
  2455. }
  2456. break;
  2457. }
  2458. }
  2459. void QueDuan_TuiLianNoGL(void)
  2460. {
  2461. switch(QD_TuiLianStep)
  2462. {
  2463. case 0:
  2464. break;
  2465. case 1:
  2466. QD_TuiLianStep = 2;
  2467. break;
  2468. case 2:
  2469. if(!QD_YD_VAVLE)QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
  2470. QD_YD_VAVLE = 1;
  2471. QD_TuiLianStep = 3;
  2472. break;
  2473. case 3:
  2474. if(dwTickCount >= QD_TLDelay)
  2475. {
  2476. QD_TL_VAVLE = 1;
  2477. QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
  2478. QD_TuiLianStep = 4;
  2479. }
  2480. break;
  2481. case 4:
  2482. if(dwTickCount >= QD_TLDelay)
  2483. {
  2484. QD_TuiLianStep = 0;
  2485. }
  2486. break;
  2487. }
  2488. }
  2489. void QueDuan_TuiLianAction(void)
  2490. {
  2491. switch(QD_MACHINE_TYPE)
  2492. {
  2493. case QD_NO_GL_TUIFANGKUAI: QueDuan_TuiLianNoGL();break;
  2494. default:QueDuan_TuiLianNormal();
  2495. }
  2496. }
  2497. //气动推方块方式下切
  2498. void QueDuan_XiaQue_QD(void)
  2499. {
  2500. switch(QD_XiaQieStep)
  2501. {
  2502. case 0:
  2503. break;
  2504. case 1:
  2505. if(!bRunning)
  2506. {
  2507. QD_XiaQieDelay = dwTickCount + 50;
  2508. QD_GZ_VAVLE = 1;
  2509. QD_XiaQieStep = 20;
  2510. }
  2511. else
  2512. {
  2513. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  2514. QD_XiaQieStep = 2;
  2515. }
  2516. break;
  2517. case 20:
  2518. if(dwTickCount >= QD_XiaQieDelay)
  2519. {
  2520. QD_XiaQieDelay = dwTickCount + 1000;
  2521. QD_YBD_VAVLE = 1;
  2522. QD_TFK_VAVEL = 1;
  2523. QD_XiaQieStep = 21;
  2524. }
  2525. break;
  2526. case 21:
  2527. if(QD_GOUZHEN_IN)
  2528. {
  2529. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  2530. cTuiFangKuaiCnt = 0;
  2531. QD_XiaQieStep = 2;
  2532. }
  2533. else if(dwTickCount >= QD_XiaQieDelay)
  2534. {
  2535. QD_SetAlarmCode(QD_GZ_ALARM);
  2536. }
  2537. break;
  2538. case 22:
  2539. if(dwTickCount >= QD_XiaQieDelay)
  2540. {
  2541. QD_XiaQieStep = 20;
  2542. }
  2543. break;
  2544. case 2:
  2545. if(dwTickCount >= QD_XiaQieDelay)
  2546. {
  2547. QD_SM_VAVLE = 1;
  2548. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2549. QD_XiaQieStep = 3;
  2550. }
  2551. break;
  2552. case 3:
  2553. if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
  2554. {
  2555. QD_XiaQieStep = 4;
  2556. QD_XiaQieDelay = dwTickCount + 100;
  2557. }
  2558. else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
  2559. break;
  2560. case 4:
  2561. if(dwTickCount >= QD_XiaQieDelay)
  2562. {
  2563. QD_SM_VAVLE = 0;
  2564. if(bRunning)QD_TFK_VAVEL = 0;
  2565. QD_GZ_VAVLE = 0;
  2566. if(!QD_PARAM_TL_MODE)
  2567. {
  2568. if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
  2569. }
  2570. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2571. QD_XiaQieStep = 5;
  2572. }
  2573. break;
  2574. case 5:
  2575. if(QD_SHANG_MU_ORIGIN_IN && (QD_TuiLianStep == 0))
  2576. {
  2577. if(QD_PARAM_TL_MODE)
  2578. {
  2579. if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
  2580. }
  2581. QD_XiaQieStep = 0;
  2582. QD_XiaQieDelay = dwTickCount + QD_PARAM_TL_DELAY;
  2583. }
  2584. else if(dwTickCount >= QD_XiaQieDelay)
  2585. {
  2586. QD_SetAlarmCode(QD_SM_YUANWEI);
  2587. }
  2588. break;
  2589. }
  2590. }
  2591. void QueDuan_XiaQue_NO_GL(void)
  2592. {
  2593. switch(QD_XiaQieStep)
  2594. {
  2595. case 0:
  2596. break;
  2597. case 1:
  2598. QD_YD_VAVLE = 1;
  2599. QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
  2600. QD_XiaQieStep = 2;
  2601. break;
  2602. case 2:
  2603. if(dwTickCount >= QD_XiaQieDelay)
  2604. {
  2605. QD_XiaQieStep = 3;
  2606. }
  2607. break;
  2608. case 3:
  2609. if(dwTickCount >= QD_XiaQieDelay)
  2610. {
  2611. if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
  2612. {
  2613. QD_SM_VAVLE = 1;
  2614. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2615. QD_XiaQieStep = 4;
  2616. }
  2617. }
  2618. break;
  2619. case 4:
  2620. if(QD_SHANG_MU_LIMIT_IN)
  2621. {
  2622. QD_XiaQieStep = 5;
  2623. QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
  2624. }
  2625. else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
  2626. break;
  2627. case 5:
  2628. if(dwTickCount >= QD_XiaQieDelay)
  2629. {
  2630. QD_GZ_VAVLE = 0;
  2631. QD_SM_VAVLE = 0;
  2632. QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2633. QD_XiaQieStep = 6;
  2634. }
  2635. break;
  2636. case 6:
  2637. if(QD_SHANG_MU_ORIGIN_IN && !QD_SHANG_MU_LIMIT_IN)
  2638. {
  2639. if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
  2640. if(!bRunning)QD_JD_VAVEL = 0;
  2641. QD_XiaQieStep = 0;
  2642. }
  2643. else if(dwTickCount >= QD_XiaQieDelay)
  2644. {
  2645. QD_SetAlarmCode(QD_SM_YUANWEI);
  2646. }
  2647. break;
  2648. }
  2649. }
  2650. //切断动作
  2651. void QueDuan_XiaQue(void)
  2652. {
  2653. switch(QD_MACHINE_TYPE)
  2654. {
  2655. case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
  2656. case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
  2657. case QD_QQ_TUIFANGKUAI:QueDuan_XiaQue_QD();break;
  2658. case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
  2659. default:;
  2660. }
  2661. }
  2662. #endif