XSQueDuanJi.c 98 KB

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