GLQueduan_newstr_CSNew.c 134 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178
  1. #include "global.h"
  2. #if (CHANG_SHENG_GEI_LI_MACHINE==1)
  3. void QueDuan_AlarmProtect(void);
  4. void QueDuan_ManualAction(void);
  5. void QueDuan_AutoAction(void);
  6. void QueDuan_StepCheckStart(void);
  7. void QueDuan_XiaQue(void);
  8. void QueDuan_SecondXiaQue(void);
  9. void QueDuan_Motor(void);
  10. void QueDuan_YuanDianAction(void);
  11. void QueDuan_TuiLianAction(void);
  12. void QueDuan_ExtiActionX31(void);
  13. void QueDuan_BingLian(void);
  14. void QDN_TuiDaiAction(void);
  15. static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
  16. static long save_limit_pos,cRealPos;
  17. static long dwSaveLength;
  18. unsigned char cCheckLianFlg = 0;
  19. unsigned char cCheckLianFlgEN = 0;
  20. unsigned char cGoLimitEn = 0;
  21. unsigned char NQDJGNUNMBER = 0;
  22. short *length_buffer;
  23. void QueDuan_ExtiActionX31(void)
  24. {
  25. cCheckLianFlg = 1;
  26. }
  27. void QDN_SetAlarmCode(unsigned alarm_code)
  28. {
  29. SetAlarmCode(QDN_ALARM_ADDR,alarm_code);
  30. bAlarmStop = 1;
  31. }
  32. //电机松轴
  33. void Motor_SZ(unsigned char En)
  34. {
  35. if(En) //使能
  36. {
  37. if(QDN_PARAM_MOTOR_SELECT)
  38. QDN_SZ_OUT = 1; //伺服电机
  39. else
  40. QDN_SZ_OUT = 0; //步进电机
  41. }
  42. else //松轴
  43. {
  44. if(QDN_PARAM_MOTOR_SELECT)
  45. QDN_SZ_OUT = 0; //伺服电机
  46. else
  47. QDN_SZ_OUT = 1; //步进电机
  48. }
  49. }
  50. void QueDuan_NewStr_InitAction(void)
  51. {
  52. float length_buff,pulse_buff;
  53. length_buff = QDN_PARAM_CYCLE_LENGTH;
  54. pulse_buff = QDN_PARAM_CYCLE_PULSE;
  55. XGearRatio = pulse_buff/length_buff;
  56. if(QDN_PARAM_KAIBEE_SELECT > 1)
  57. QDN_PARAM_KAIBEE_SELECT = 1;
  58. Motor_SZ(QDN_MOTOR_DIS); //电机松轴
  59. QDCT_SetAlarmCode(QDN_NO_ALARM);
  60. }
  61. void QueDuan_NewStr_Action(void)
  62. {
  63. InputPinConfig();
  64. QueDuan_AlarmProtect();
  65. QueDuan_Motor();
  66. QueDuan_XiaQue();
  67. QueDuan_ManualAction();
  68. QueDuan_TuiLianAction();
  69. QueDuan_BingLian();
  70. QueDuan_SecondXiaQue();
  71. QueDuan_AutoAction();
  72. QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
  73. OutputPinConfig();
  74. }
  75. //手动动作
  76. void QueDuan_ManualAction(void)
  77. {
  78. if(bRunning == 0)
  79. {
  80. cGoLimitEn = 0;
  81. if(QDN_bClearTotal) //切断计数清零
  82. {
  83. QDN_bClearTotal = 0;
  84. ClrcToTal(QDN_TOTAL_ADDR);
  85. }
  86. if(QDN_bClearNowTotal)
  87. {
  88. QDN_bClearNowTotal = 0;
  89. QDN_PARAM_NOW_CNT = 0;
  90. }
  91. if(QDN_PARAM_KAIBEE_SELECT)
  92. {
  93. if(!QDN_GOUZHEN_HOU_IN && !QDN_GOUZHEN_HOU_IN)
  94. QDN_GZDW_OUT=1;
  95. }
  96. else
  97. {
  98. QDN_GZDW_OUT=0;
  99. }
  100. if(QDN_bXiaQie || QDN_MAN_QIEDUAN_IN_UP)
  101. {
  102. QDN_bXiaQie = 0;
  103. if((QDN_XiaQieStep == 0) && !QDN_TL_VAVLE)
  104. {
  105. if(!QDN_PARAM_KAIBEE_SELECT)
  106. QDN_XiaQieStep = 1;
  107. else
  108. QDN_XiaQieStep = 1;
  109. }
  110. }
  111. //前点定位
  112. if(QDN_bQianDianDW)
  113. {
  114. QDN_bQianDianDW = 0;
  115. if(QDN_MotorStep == 0)
  116. {
  117. QDN_MotorStep = 61;
  118. cZipCnt = 0;
  119. Motor_SZ(QDN_MOTOR_EN); //电机锁轴
  120. QDN_MotorDelay = dwTickCount + 150;
  121. }
  122. }
  123. if(QDN_bTL)
  124. {
  125. QDN_bTL = 0;
  126. if(QDN_TL_VAVLE)
  127. {
  128. QDN_TL_VAVLE = 0;
  129. }
  130. else if(!QDN_GZ_VAVLE && !QDN_SM_VAVLE)
  131. {
  132. QDN_TL_VAVLE = ~QDN_TL_VAVLE;
  133. }
  134. }
  135. if(QDN_bYD)
  136. {
  137. QDN_bYD = 0;
  138. QDN_YD_VAVLE = ~QDN_YD_VAVLE;
  139. }
  140. if(QDN_bGZ || QDN_MAN_GOUZHEN_IN_UP)
  141. {
  142. QDN_bGZ = 0;
  143. QDN_GZ_VAVLE = ~QDN_GZ_VAVLE;
  144. }
  145. if(QDN_bJD)
  146. {
  147. QDN_bJD = 0;
  148. QDN_JD_VAVLE = ~QDN_JD_VAVLE;
  149. }
  150. if(QDN_bXM)
  151. {
  152. QDN_bXM = 0;
  153. if(QDN_XM_KAIKOU_VAVLE || QDN_XM_VAVLE)
  154. {
  155. QDN_XM_VAVLE = 0;
  156. QDN_XM_KAIKOU_VAVLE = 0;
  157. }
  158. else
  159. {
  160. if(QDN_PARAM_KAIBEE_SELECT) //闭口
  161. {
  162. QDN_XM_VAVLE = 1;
  163. }
  164. else
  165. {
  166. QDN_XM_KAIKOU_VAVLE = 1;
  167. }
  168. }
  169. }
  170. if(QDN_bSM)
  171. {
  172. QDN_bSM = 0;
  173. if(QDN_SM_VAVLE)
  174. QDN_SM_VAVLE = 0;
  175. else if(!QDN_TL_VAVLE)
  176. QDN_SM_VAVLE = 1;
  177. }
  178. //推方块
  179. if(QDN_bTFK || QDN_MAN_TUIDAI_IN_UP)
  180. {
  181. QDN_bTFK = 0;
  182. QDN_TFK_VAVLE = ~QDN_TFK_VAVLE;
  183. }
  184. //台面电机
  185. if(QDN_bTB)
  186. {
  187. QDN_bTB = 0;
  188. QDN_TABLE_VAVLE = ~QDN_TABLE_VAVLE;
  189. }
  190. // if(QDN_bYBD)
  191. // / {
  192. // QDN_bYBD = 0;
  193. // QDN_YBD_VAVLE = ~QDN_YBD_VAVLE;
  194. // }
  195. if(QDN_bTestCS)
  196. {
  197. QDN_bTestCS = 0;
  198. QDN_CS_OUT = 1;
  199. QDN_CSDelay = dwTickCount + QDN_PARAM_CS_TIME;
  200. }
  201. if(QDN_bBL)//合链
  202. {
  203. QDN_bBL = 0;
  204. QDN_BL_VAVLE = ~QDN_BL_VAVLE;
  205. }
  206. if(QDN_bHL) //护链,双开用
  207. {
  208. QDN_bHL = 0;
  209. // QDN_HL_VAVLE = ~QDN_HL_VAVLE;
  210. }
  211. if(QDN_bYX)
  212. {
  213. QDN_bYX = 0;
  214. // QDN_YX_VAVLE = ~QDN_YX_VAVLE;
  215. }
  216. if(QDN_XiaQieStep == 0)
  217. {
  218. if(dwTickCount >= QDN_CSDelay) QDN_CS_OUT = 0;
  219. }
  220. //电机控制
  221. if(QDN_bGoMotor && !QDN_QIAN_LIMIT_IN)
  222. {
  223. Motor_SZ(QDN_MOTOR_EN); //电机锁轴
  224. if(!X_DRV)
  225. {
  226. // X轴 运行速度 启动速度 加速度 减速度
  227. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,10,12);
  228. }
  229. }
  230. if(QDN_bBackMotor) //后退限位已经取消
  231. {
  232. Motor_SZ(QDN_MOTOR_EN); //电机锁轴
  233. if(!X_DRV)
  234. // X轴 运行速度 启动速度 加速度 减速度
  235. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_P,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,10,12);
  236. }
  237. if(!QDN_bGoMotor && !QDN_bBackMotor && (QDN_MotorStep == 0))
  238. {
  239. if(X_DRV)AxisEgmStop(X_AXIS);
  240. }
  241. if(QDN_QIAN_LIMIT_IN && (QDN_MotorStep == 0) && !QDN_bBackMotor &&(QDN_AutoStep == 0))
  242. {
  243. if(X_DRV)AxisEgmStop(X_AXIS);
  244. }
  245. }
  246. }
  247. void QueDuan_AlarmProtect(void)
  248. {
  249. cRealPos = GetPos(X_AXIS);
  250. if(!bRunning)
  251. {
  252. if(QDN_BACK_LIMIT_IN)
  253. {
  254. if((QDN_MotorStep != 0) || X_DRV && QDN_bBackMotor) //到后限不能再后退但可以点前进
  255. {
  256. QDN_bBackMotor = 0;
  257. AxisDecStop(X_AXIS);
  258. QDN_JD_VAVLE = 0;
  259. QDN_SetAlarmCode(QDN_BACK_ALARM);
  260. }
  261. }
  262. }
  263. else
  264. {
  265. //软件限位
  266. if(QDN_PARAM_RUN_LENGTH < 5000)
  267. QDN_PARAM_RUN_LENGTH= 5000;
  268. if((cRealPos > QDN_PARAM_RUN_LENGTH) && (cGoLimitEn != 0)) //第一条手动时不保护
  269. {
  270. AxisEgmStop(X_AXIS);
  271. QDN_JD_VAVLE = 0;
  272. QDN_SetAlarmCode(QDN_BACK_ALARM);
  273. }
  274. //硬件限位
  275. if(QDN_BACK_LIMIT_IN && GetDir(X_AXIS)==QDN_DIR_P)
  276. {
  277. if(X_DRV)
  278. {
  279. AxisEgmStop(X_AXIS);
  280. QDCT_JD_OUT = 0;
  281. QDCT_SetAlarmCode(QDN_BACK_ALARM);
  282. }
  283. }
  284. }
  285. }
  286. void QueDuan_AutoAction(void)
  287. {
  288. if(bRunning)
  289. {//台面电机定时关掉
  290. if(dwTickCount >= QDN_TBDelay)
  291. QDN_TABLE_VAVLE = 0;
  292. switch(QDN_AutoStep)
  293. {
  294. case 1:
  295. if(dwTickCount >= QDN_AutoDelay)
  296. {
  297. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  298. {
  299. QDN_AutoStep = 2;
  300. if(QDN_MotorStep == 0)
  301. {
  302. QDN_MotorStep = 61; //前点定位
  303. }
  304. cGoLimitEn = 0;
  305. }
  306. }
  307. break;
  308. case 2:
  309. if(QDN_MotorStep == 0)
  310. {
  311. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  312. {
  313. QDN_MotorStep = 30;
  314. QDN_AutoStep = 3;
  315. cGoLimitEn = 1;
  316. }
  317. }
  318. break;
  319. case 3: //后面两步为延时反转步
  320. if((QDN_MotorStep == 0) || (QDN_MotorStep == 390) || (QDN_MotorStep == 391))
  321. {
  322. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  323. {
  324. if(QDN_SAFE_IN)
  325. {
  326. bStop = 1;
  327. }
  328. else
  329. {
  330. if(QDN_XiaQieStep == 0)
  331. QDN_XiaQieStep = 1;
  332. QDN_AutoStep = 4;
  333. }
  334. }
  335. }
  336. break;
  337. case 4:
  338. // 闭口
  339. if((QDN_XiaQieStep == 0) || ((QDN_XiaQieStep == 6) && (QDN_PARAM_KAIBEE_SELECT == 1))|| ((QDN_XiaQieStep == 13) && (QDN_PARAM_KAIBEE_SELECT == 0)))// && !QDN_SHANG_MU_LIMIT_IN)
  340. {
  341. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  342. {
  343. if(QDN_MotorStep == 0)
  344. {
  345. QDN_MotorStep = 40; //切完后退
  346. QDN_AutoStep = 5;
  347. }
  348. }
  349. }
  350. break;
  351. case 5:
  352. if(QDN_MotorStep == 0)
  353. {
  354. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  355. {
  356. if(QDN_PARAM_SecondDAO_LENGTH && QDN_PARAM_KAIBEE_SELECT && QDN_PARAM_BKGZ_NUMBER )
  357. {
  358. QDN_SecondXiaQueStep = 1;
  359. QDN_AutoStep=0;
  360. }
  361. else
  362. {
  363. if(NQDJGNUNMBER==0)
  364. QDN_AutoStep = 6;
  365. else if(NQDJGNUNMBER==1)
  366. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  367. else if(NQDJGNUNMBER==2)
  368. QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM);
  369. }
  370. }
  371. }
  372. break;
  373. case 6:
  374. if(QDN_MotorStep == 0)
  375. {
  376. cZipCnt++;
  377. QDN_PARAM_NOW_CNT++;
  378. cTableCnt++;
  379. AddToTal(QDN_TOTAL_ADDR);
  380. AddToTal(CT_WORKTOTAL_ADDR);
  381. CalProSP(QDN_PROSPEED_ADDR);
  382. if(cTableCnt >= QDN_PARAM_TABLE_NUM)
  383. {
  384. cTableCnt = 0;
  385. QDN_TABLE_VAVLE = 1;
  386. QDN_TBDelay = dwTickCount + QDN_PARAM_TB_TIME;
  387. }
  388. if(/*(GetTotal(QDN_TOTAL_ADDR) >= QDN_PARAM_SET_TOTAL) ||*/ SingOneFlg)
  389. {
  390. /*
  391. if((QDN_PARAM_SET_TOTAL == 0) && !SingOneFlg)
  392. {
  393. QDN_AutoDelay = dwTickCount + QDN_PARAM_CYCLE_DELAY;
  394. QDN_AutoStep = 1;
  395. }
  396. else
  397. */
  398. {
  399. bRunning = 0;
  400. QDN_AutoStep = 0;
  401. SingOneFlg = 0;
  402. }
  403. // if(GetTotal(QDN_TOTAL_ADDR) >= QDN_PARAM_SET_TOTAL) QDN_SetAlarmCode(QDN_TOTAL_ALARM);
  404. }
  405. else
  406. {
  407. QDN_AutoStep = 1;
  408. if((QDN_PARAM_NOW_CNT >= QDN_PARAM_ZHA_SHU) && (QDN_PARAM_ZHA_SHU > 0))
  409. {
  410. QDN_AutoDelay = dwTickCount + QDN_PARAM_ZS_STOP_TIME;
  411. QDN_PARAM_NOW_CNT = 0;
  412. if(QDN_PARAM_ZS_STOP_TIME == 0)
  413. {
  414. bRunning = 0;
  415. QDN_AutoStep = 0;
  416. SingOneFlg = 0;
  417. QDN_SetAlarmCode(QDN_TOTAL_ALARM);
  418. }
  419. }
  420. else
  421. QDN_AutoDelay = dwTickCount + QDN_PARAM_CYCLE_DELAY;
  422. }
  423. }
  424. break;
  425. }
  426. }
  427. }
  428. void QueDuan_StepCheckStart(void)
  429. {
  430. // 启动
  431. if((QDN_START_IN_UP) || bStart || QDN_bSingle)
  432. {
  433. bStart = 0;
  434. if(!bRunning && (QDN_AutoStep == 0))
  435. {
  436. if((QDN_XIA_MU_LIMIT_IN | QDN_KAIKUO_XIAMO_LIMIT_IN) && !QDN_PARAM_XM_ENABLE)QDN_SetAlarmCode(QDN_XM_DAOWEI);
  437. // else if(GetAlarmCode(QDN_ALARM_ADDR) != 0);
  438. //else if(GetTotal(QDN_TOTAL_ADDR) >= QDN_PARAM_SET_TOTAL) QDN_SetAlarmCode(QDN_TOTAL_ALARM);
  439. else if(QDN_ANQUANMEN_LIMIT_IN)QDN_SetAlarmCode(QDN_PARAM_ANQUANMEN_ALARM);
  440. else if(QDN_SM_VAVLE)QDN_SetAlarmCode(QDN_SM_ALARM);
  441. else if(QDN_GOUZHEN_QIAN_IN || QDN_GOUZHEN_HOU_IN)QDN_SetAlarmCode(QDN_GZ_ALARM);
  442. else
  443. {
  444. bRunning = 1;
  445. QDN_AutoStep = 1;
  446. if(QDN_bSingle)
  447. SingOneFlg= 1;
  448. cZipCnt = 0;
  449. cTuiFangKuaiCnt = 0;
  450. NQDJGNUNMBER = 0;
  451. QDN_BL_VAVLE = 0; //并链关
  452. QDN_DGLG_VAVLE = 0; //顶过链杆关
  453. SetAlarmCode(QDN_ALARM_ADDR,0);
  454. Motor_SZ(QDN_MOTOR_EN); //电机锁轴
  455. QDN_AutoDelay = dwTickCount + 150;
  456. if(QDN_PARAM_KAIBEE_SELECT)
  457. QDN_GZDW_OUT=1;
  458. else
  459. QDN_GZDW_OUT=0;
  460. }
  461. }
  462. QDN_bSingle = 0;
  463. }
  464. //停止
  465. if(QDN_STOP_IN_UP || bStop)
  466. {
  467. bStop = 0;
  468. if(bRunning)
  469. {
  470. QDN_AutoDelay = dwTickCount;
  471. QDN_MotorDelay = dwTickCount;
  472. QDN_XiaQieDelay = dwTickCount;
  473. QDN_KaDaiDelay = dwTickCount;
  474. QDN_CSDelay = dwTickCount;
  475. QDN_TBDelay = dwTickCount;
  476. QDN_TFKDelay = dwTickCount;
  477. QDN_TLDelay = dwTickCount;
  478. dwTickCount = QDN_TBDelay;
  479. NQDJGNUNMBER = 0;
  480. SingOneFlg = 0;
  481. QDN_JD_VAVLE = 0;
  482. QDN_SM_VAVLE = 0;
  483. QDN_XM_VAVLE = 0;
  484. QDN_XM_KAIKOU_VAVLE=0;
  485. QDN_YD_VAVLE = 0;
  486. QDN_TFK_VAVLE= 0;
  487. QDN_TL_VAVLE = 0;
  488. // QDN_HL_VAVLE = 0;
  489. QDN_CS_OUT = 0;
  490. QDN_XiaQieStep = 0;
  491. QDN_MotorStep = 0;
  492. QDN_TuiLianStep = 0;
  493. QDN_GZ_VAVLE = 0;
  494. QDN_TABLE_VAVLE = 0;
  495. QDN_DGLG_VAVLE = 0; //顶过链杆关
  496. AxisDecStop(X_AXIS);
  497. QDN_BinLianStep = 0;
  498. QDN_BL_VAVLE = 0;
  499. user_datas[121] = 0;
  500. user_datas[122] = 0;
  501. SetAlarmCode(QDN_ALARM_ADDR,0);
  502. }
  503. else
  504. {
  505. QDN_AutoDelay = dwTickCount;
  506. QDN_MotorDelay = dwTickCount;
  507. QDN_XiaQieDelay = dwTickCount;
  508. QDN_KaDaiDelay = dwTickCount;
  509. QDN_CSDelay = dwTickCount;
  510. QDN_TBDelay = dwTickCount;
  511. QDN_TFKDelay = dwTickCount;
  512. QDN_TLDelay = dwTickCount;
  513. dwTickCount = QDN_TBDelay;
  514. NQDJGNUNMBER = 0;
  515. SingOneFlg = 0;
  516. QDN_JD_VAVLE = 0;
  517. QDN_SM_VAVLE = 0;
  518. QDN_XM_VAVLE = 0;
  519. QDN_XM_KAIKOU_VAVLE = 0;
  520. QDN_YD_VAVLE = 0;
  521. QDN_TFK_VAVLE= 0;
  522. // QDN_YX_VAVLE = 0;
  523. // QDN_HL_VAVLE = 0;
  524. QDN_TL_VAVLE = 0;
  525. QDN_DGLG_VAVLE = 0; //顶过链杆关
  526. QDN_GZ_VAVLE = 0;
  527. QDN_CS_OUT = 0;
  528. QDN_XiaQieStep = 0;
  529. QDN_MotorStep = 0;
  530. QDN_TuiLianStep = 0;
  531. QDN_TABLE_VAVLE = 0;
  532. AxisEgmStop(X_AXIS);
  533. Motor_SZ(QDN_MOTOR_DIS); //电机松轴
  534. QDN_BinLianStep = 0;
  535. QDN_BL_VAVLE = 0;
  536. SetAlarmCode(QDN_ALARM_ADDR,0);
  537. }
  538. bRunning = 0;
  539. QDN_XiaQieStep = 0;
  540. QDN_AutoStep = 0;
  541. QDN_MotorStep = 0;
  542. QDN_TuiLianStep = 0;
  543. cTuiFangKuaiCnt=0;
  544. }
  545. if(bAlarmStop)
  546. {
  547. bAlarmStop = 0;
  548. QDN_XiaQieStep = 0;
  549. QDN_AutoStep = 0;
  550. QDN_MotorStep = 0;
  551. QDN_TuiLianStep = 0;
  552. NQDJGNUNMBER = 0;
  553. QDN_XiaQieStep = 0;
  554. QDN_MotorStep = 0;
  555. QDN_TuiLianStep = 0;
  556. QDN_AutoDelay = dwTickCount;
  557. QDN_MotorDelay = dwTickCount;
  558. QDN_XiaQieDelay = dwTickCount;
  559. QDN_KaDaiDelay = dwTickCount;
  560. QDN_CSDelay = dwTickCount;
  561. QDN_TBDelay = dwTickCount;
  562. QDN_TFKDelay = dwTickCount;
  563. QDN_TLDelay = dwTickCount;
  564. SingOneFlg = 0;
  565. bRunning = 0;
  566. AxisDecStop(X_AXIS);
  567. dwTickCount = QDN_TBDelay;
  568. QDN_TABLE_VAVLE = 0;
  569. QDN_JD_VAVLE=0;
  570. QDN_GZ_VAVLE=0;
  571. cTuiFangKuaiCnt=0;
  572. }
  573. }
  574. //记忆长度模式误差检测
  575. void QueDuan_CheckLength(long zip_length)
  576. {
  577. static long start_dist;
  578. switch(QDN_CheckLengthStep)
  579. {
  580. case 0:break;
  581. case 1:
  582. start_dist = cRealPos;
  583. dwSaveLength = 0;
  584. QDN_CheckLengthStep = 2;
  585. break;
  586. case 2:
  587. if(QDN_GUO_LIAN_IN_DW){
  588. dwSaveLength = cRealPos - start_dist;
  589. // user_datas[127] = cRealPos;
  590. }
  591. break;
  592. }
  593. }
  594. #if 1//!QDN_KB_MODE //开口
  595. //开口切专用
  596. //30步开始后拉开始,分解4种工作模式
  597. //40步开始用切断后拉动作
  598. //60步开始为前方向,开闭口一样
  599. void QueDuan_Motor_KK(void)
  600. {
  601. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  602. unsigned short ch;
  603. user_datas[121] = QDN_AutoStep;
  604. user_datas[122] = QDN_MotorStep;
  605. user_datas[123] = cRealPos;
  606. user_datas[124] = length_buff;
  607. user_datas[125] = GetCurSpeed(X_AXIS);
  608. user_datas[126] = QDN_XiaQieStep;
  609. user_datas[127] = QDN_XiaQieStep;
  610. QueDuan_CheckLength(length_buff);
  611. switch(QDN_MotorStep)
  612. {
  613. case 30:
  614. switch(QDN_PARAM_BACK_MODE) //开口分四种模式
  615. {
  616. case 0: //单数控模式
  617. QDN_MotorStep = 310; //每种模式留20步
  618. QDN_DGLG_VAVLE = 1; //顶过链杆关
  619. break;
  620. case 1://单感应模式
  621. QDN_MotorStep = 330; //每种模式留20步
  622. break;
  623. case 2: //先感应后数控模式+检测
  624. QDN_MotorStep = 350; //每种模式留20步
  625. break;
  626. default: //数控模式+过链检测长度
  627. QDN_MotorStep = 370; //每种模式留20步
  628. break;
  629. }
  630. QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
  631. break;
  632. //310步到315步为数控模式
  633. case 310:
  634. QDN_MotorStep = 311;
  635. // QDN_JZ_DIR = QDN_YDIR_P;
  636. if(QDN_PARAM_BL_ENABLE)
  637. QDN_BinLianStep = 1; //并链起动
  638. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  639. break;
  640. case 311:
  641. if(dwTickCount >= QDN_MotorDelay)
  642. {
  643. //李永庆代码
  644. //SetDir(X_AXIS, QDN_DIR_N);
  645. //两段速度移动距离 拉链长度+慢速长度停止
  646. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  647. AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH -(*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
  648. QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P,
  649. QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  650. back_buff = cRealPos;
  651. gou_zhen_buff = cRealPos;
  652. save_buff = cRealPos;
  653. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  654. QDN_MotorStep = 312;
  655. }
  656. break;
  657. case 312:
  658. //勾针提前输出 ,争取时间推方块
  659. if (!QDN_GZ_VAVLE && (cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer)- QDN_PARAM_GOUZHEN_LENGTH)))
  660. {
  661. QDN_GZ_VAVLE = 1;
  662. //QDN_XM_KAIKOU_VAVLE=1;
  663. }
  664. if((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
  665. {
  666. QDN_MotorStep = 313;
  667. }
  668. else if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer) + QDN_PARAM_ERROR_LENGTH))
  669. {
  670. AxisEgmStop(X_AXIS);
  671. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  672. }
  673. break;
  674. case 313:
  675. if(!QDN_GZ_VAVLE && ((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer) - QDN_PARAM_GOUZHEN_LENGTH)))
  676. {
  677. QDN_GZ_VAVLE = 1;
  678. //QDN_XM_KAIKOU_VAVLE=1;
  679. }
  680. if(!X_DRV)
  681. {
  682. //AxisEgmStop(X_AXIS);
  683. QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
  684. QDN_MotorStep = 314;
  685. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  686. if((QDN_PARAM_BACK_MODE == 2) && !QDN_DGLG_VAVLE) //模式2,先检测长度后数控
  687. {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里对比长度
  688. if(cZipCnt > 1) //长度检测
  689. {
  690. if(QDN_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  691. {
  692. if(((dwSaveLength + QDN_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + QDN_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
  693. {
  694. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);//拉链变长,对比警告
  695. }
  696. else if((dwSaveLength + QDN_PARAM_MOTOR_DELAY_LENGTH+ QDN_PARAM_ERROR_LENGTH) < length_buff)
  697. {
  698. QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM); ////拉链变短
  699. }
  700. QDN_CheckLengthStep = 0;
  701. }
  702. }
  703. }
  704. }
  705. if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - (*length_buffer) + QDN_PARAM_ERROR_LENGTH))
  706. {
  707. AxisEgmStop(X_AXIS);
  708. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  709. }
  710. break;
  711. case 314:
  712. if(!X_DRV && (dwTickCount >= QDN_MotorDelay)) //数控到停止
  713. {
  714. QDN_MotorStep = 315;
  715. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  716. QDN_TFK_VAVLE = 1; //推方块输出
  717. }
  718. break;
  719. case 315:
  720. if(QDN_GOUZHEN_QIAN_IN)
  721. {
  722. QDN_MotorStep = 0;
  723. }
  724. else if(dwTickCount >= QDN_MotorDelay)
  725. {
  726. QDN_SetAlarmCode(QDN_GZ_ALARM);
  727. }
  728. break;
  729. //330步到349步单感应模式
  730. case 330:
  731. back_buff = cRealPos;
  732. gou_zhen_buff = cRealPos;
  733. QDN_MotorStep = 331;
  734. // QDN_JZ_DIR = QDN_YDIR_P;
  735. save_buff = cRealPos;
  736. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  737. //user_datas[127] = 0;
  738. break;
  739. case 331:
  740. if(dwTickCount >= QDN_MotorDelay)
  741. {
  742. if(cZipCnt < 2)
  743. {
  744. if(QDN_PARAM_BL_ENABLE)
  745. QDN_BinLianStep = 10; //并链起动
  746. //第一条都是过链感应,后拉速度减半//原来QDN_PARAM_CHECK_BACK_HSPEED/2
  747. // X轴 运行速度 启动速度 加速度 减速度
  748. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,13);
  749. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  750. // AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P);
  751. QDN_MotorStep = 332;
  752. }
  753. else
  754. {
  755. if(QDN_PARAM_BL_ENABLE)
  756. QDN_BinLianStep = 1; //并链起动
  757. //因为每条都是过链感应,所以直接运行检测模式后拉速度
  758. // X轴 运行速度 启动速度 加速度 减速度
  759. //AxisContinueMoveAcc(X_AXIS,QDN_PARAM_CHECK_BACK_HSPEED,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  760. if(length_buff>QDN_PARAM_BACK_LOW_SPEED_LENGTH)
  761. AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,length_buff-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
  762. QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  763. else
  764. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,13);
  765. QDN_MotorStep = 334;
  766. }
  767. }
  768. break;
  769. case 332:
  770. //第一二条工作
  771. {
  772. if(QDN_GUO_LIAN_IN_UP)
  773. {
  774. checkdelay_buff = cRealPos;
  775. AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
  776. QDN_MotorDelay = dwTickCount + 0;//QDN_PARAM_DELAY_XM;
  777. QDN_MotorStep = 333;
  778. }
  779. // else if((cRealPos >= QDN_PARAM_RUN_LENGTH) && (QDN_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
  780. // {
  781. // QDN_SetAlarmCode(QDN_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
  782. // }
  783. }
  784. break;
  785. case 333:
  786. if(dwTickCount >= QDN_MotorDelay)
  787. {
  788. QDN_MotorStep = 334;
  789. }
  790. break;
  791. case 334:
  792. if(QDN_GUO_LIAN_IN_DW && ((cRealPos-save_buff)> (length_buff-QDN_PARAM_BACK_LOW_SPEED_LENGTH) || (cZipCnt < 2))) //下降沿,定位长度
  793. {
  794. //滤波有待调试
  795. // if((((cRealPos - checkdelay_buff) >= QDN_PARAM_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QDN_PARAM_NO_LT_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE == 0)))
  796. // {
  797. if(QDN_GUO_LIAN_IN_DW)
  798. {
  799. gou_zhen_buff = cRealPos;
  800. QDN_MotorStep = 335;
  801. }
  802. // }
  803. }
  804. break;
  805. case 335:
  806. if(QDN_GUO_LIAN_IN_DW)
  807. {
  808. gou_zhen_buff = cRealPos;
  809. }
  810. //在空们都把延时清零
  811. if(QDN_GUO_LIAN_IN)
  812. {
  813. gou_zhen_buff = cRealPos;
  814. }
  815. if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH/4) && !QDN_GUO_LIAN_IN)
  816. {
  817. QDN_GZ_VAVLE = 1;
  818. //QDN_XM_KAIKOU_VAVLE=1;
  819. //QDN_MotorStep = 336;
  820. }
  821. //定位停止
  822. if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH) && !QDN_GUO_LIAN_IN)
  823. {
  824. AxisEgmStop(X_AXIS);
  825. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  826. QDN_MotorStep = 336;
  827. QDN_GZ_VAVLE = 1;
  828. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  829. }
  830. break;
  831. case 336:
  832. if(!X_DRV)
  833. {
  834. QDN_GZ_VAVLE = 1;
  835. QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
  836. // QDN_XM_VAVLE = 1;
  837. QDN_MotorStep = 337;
  838. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  839. }
  840. break;
  841. case 337:
  842. if(dwTickCount >= QDN_MotorDelay)
  843. {
  844. QDN_TFK_VAVLE = 1; //推方块输出
  845. QDN_MotorStep = 338;
  846. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  847. }
  848. break;
  849. case 338:
  850. if(QDN_GOUZHEN_QIAN_IN)
  851. {
  852. QDN_MotorStep = 339;
  853. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  854. }
  855. else if(dwTickCount >= QDN_MotorDelay)
  856. {
  857. QDN_SetAlarmCode(QDN_GZ_ALARM);
  858. }
  859. break;
  860. case 339:
  861. if(cZipCnt == 1)
  862. {
  863. length_buff = cRealPos - save_buff;
  864. //需要补偿推方块增加的距离
  865. SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff + (*length_buffer));
  866. }
  867. else if(cZipCnt > 1) //长度检测
  868. {
  869. if(QDN_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  870. {
  871. if(cRealPos >= length_buff) //拉链变长,对比警告
  872. {
  873. if((cRealPos - save_buff) > (length_buff+QDN_PARAM_ERROR_LENGTH))
  874. NQDJGNUNMBER=1;
  875. }
  876. else //拉链变短
  877. {
  878. if((cRealPos - save_buff + QDN_PARAM_ERROR_LENGTH) < (length_buff))
  879. NQDJGNUNMBER=2;
  880. }
  881. }
  882. }
  883. QDN_MotorStep = 0;
  884. break;
  885. //350步到369步单感应模式
  886. case 350:
  887. back_buff = cRealPos;
  888. gou_zhen_buff = cRealPos;
  889. save_buff = cRealPos;
  890. QDN_MotorStep = 351;
  891. // QDN_JZ_DIR = QDN_YDIR_P;
  892. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  893. break;
  894. case 351:
  895. if(dwTickCount >= QDN_MotorDelay)
  896. {
  897. QDN_MotorStep = 352;
  898. //第一,二条都是过链感应,测量长度
  899. if(cZipCnt < 2)
  900. {
  901. if(QDN_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
  902. QDN_BinLianStep = 10; //并链起动
  903. QDN_DGLG_VAVLE = 0; //顶过链杆关
  904. // X轴 运行速度 启动速度 加速度 减速度
  905. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,8,12);
  906. }
  907. else
  908. {
  909. if(QDN_PARAM_BL_ENABLE)
  910. QDN_BinLianStep = 1; //并链起动
  911. QDN_DGLG_VAVLE = 1; //顶过链杆关
  912. QDN_CheckLengthStep = 1; //长度检测,第3条才有对比
  913. //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
  914. QDN_MotorStep = 311;
  915. }
  916. }
  917. break;
  918. case 352:
  919. //前两条都按最低速度工作
  920. if(QDN_GUO_LIAN_IN_UP)
  921. {
  922. checkdelay_buff = cRealPos;
  923. AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
  924. QDN_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波
  925. QDN_MotorStep = 353;
  926. }
  927. else if((cRealPos >= QDN_PARAM_RUN_LENGTH) && (QDN_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
  928. {
  929. // QDN_SetAlarmCode(QDN_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
  930. }
  931. break;
  932. case 353:
  933. if(dwTickCount >= QDN_MotorDelay)
  934. {
  935. QDN_MotorStep = 354;
  936. }
  937. break;
  938. case 354:
  939. if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
  940. {
  941. //滤波有待调试
  942. // if((((cRealPos - checkdelay_buff) >= QDN_PARAM_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QDN_PARAM_NO_LT_DELAY_CHECK) && (QDN_PARAM_LT_ENABLE == 0)))
  943. // {
  944. if(QDN_GUO_LIAN_IN_DW)
  945. {
  946. gou_zhen_buff = cRealPos;
  947. QDN_MotorStep = 355;
  948. }
  949. // }
  950. }
  951. break;
  952. case 355:
  953. if(QDN_GUO_LIAN_IN_DW)
  954. {
  955. gou_zhen_buff = cRealPos;
  956. }
  957. //在空们都把延时清零
  958. if(QDN_GUO_LIAN_IN)
  959. {
  960. gou_zhen_buff = cRealPos;
  961. }
  962. if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH/4) && !QDN_GUO_LIAN_IN)
  963. {
  964. QDN_GZ_VAVLE = 1;
  965. //QDN_XM_KAIKOU_VAVLE=1;
  966. }
  967. //定位停止
  968. if(((cRealPos - gou_zhen_buff) >= QDN_PARAM_MOTOR_DELAY_LENGTH) && !QDN_GUO_LIAN_IN)
  969. {
  970. AxisEgmStop(X_AXIS);
  971. QDN_MotorStep = 356;
  972. QDN_GZ_VAVLE = 1;
  973. }
  974. break;
  975. case 356:
  976. if(!X_DRV)
  977. {
  978. QDN_GZ_VAVLE = 1;
  979. QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
  980. // QDN_XM_VAVLE = 1;
  981. QDN_MotorStep = 357;
  982. }
  983. break;
  984. case 357:
  985. if(dwTickCount >= QDN_MotorDelay)
  986. {
  987. QDN_TFK_VAVLE = 1; //推方块输出
  988. QDN_MotorStep = 358;
  989. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  990. }
  991. break;
  992. case 358:
  993. if(QDN_GOUZHEN_QIAN_IN)
  994. {
  995. QDN_MotorStep = 359;
  996. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  997. }
  998. else if(dwTickCount >= QDN_MotorDelay)
  999. {
  1000. QDN_SetAlarmCode(QDN_GZ_ALARM);
  1001. }
  1002. break;
  1003. case 359:
  1004. if(cZipCnt == 1)
  1005. {
  1006. length_buff = cRealPos - save_buff;
  1007. //测量出来长度,补偿推方块的距离
  1008. SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff + (*length_buffer));
  1009. }
  1010. QDN_MotorStep = 0;
  1011. break;
  1012. //370步到389步为数控模式
  1013. case 370:
  1014. QDN_MotorStep = 371;
  1015. // QDN_JZ_DIR = QDN_YDIR_P;
  1016. if(QDN_PARAM_BL_ENABLE)
  1017. QDN_BinLianStep = 1; //并链起动
  1018. QDN_CheckLengthStep = 1; //长度检测开始
  1019. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  1020. break;
  1021. case 371:
  1022. if(dwTickCount >= QDN_MotorDelay)
  1023. {
  1024. back_buff = cRealPos;
  1025. gou_zhen_buff = cRealPos;
  1026. save_buff = cRealPos;
  1027. //李永庆代码
  1028. //SetDir(X_AXIS, QDN_DIR_N);
  1029. //两段速度移动距离 拉链长度+慢速长度停止
  1030. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  1031. AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH -(*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
  1032. QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P,
  1033. QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1034. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1035. QDN_MotorStep = 372;
  1036. }
  1037. break;
  1038. case 372:
  1039. //勾针提前输出 ,争取时间推方块
  1040. if (!QDN_GZ_VAVLE && (cRealPos >= (QDN_PARAM_ZIPPER_LENGTH- (*length_buffer) - QDN_PARAM_GOUZHEN_LENGTH)))
  1041. {
  1042. QDN_GZ_VAVLE = 1;
  1043. //QDN_XM_KAIKOU_VAVLE=1;
  1044. }
  1045. if((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH- (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
  1046. {
  1047. QDN_MotorStep = 373;
  1048. }
  1049. break;
  1050. case 373:
  1051. if(!QDN_GZ_VAVLE && ((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH- (*length_buffer) - QDN_PARAM_GOUZHEN_LENGTH)))
  1052. {
  1053. QDN_GZ_VAVLE = 1;
  1054. //QDN_XM_KAIKOU_VAVLE=1;
  1055. }
  1056. if(!X_DRV)
  1057. {
  1058. AxisEgmStop(X_AXIS);
  1059. QDN_MotorDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
  1060. QDN_MotorStep = 374;
  1061. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1062. //对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
  1063. if(cZipCnt > 1) //长度检测
  1064. {
  1065. if((QDN_PARAM_ERROR_LENGTH != 0) && length_buff) //长度误差值不能为0
  1066. {
  1067. if((dwSaveLength > (length_buff + QDN_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
  1068. {
  1069. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);//拉链变长,对比警告
  1070. }
  1071. //上升沿的长度
  1072. else if((dwSaveLength + QDN_PARAM_ERROR_LENGTH) < length_buff)
  1073. {
  1074. QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM); ////拉链变短
  1075. }
  1076. QDN_CheckLengthStep = 0;
  1077. }
  1078. }
  1079. else if(cZipCnt == 1) //长度检测
  1080. {
  1081. if(dwSaveLength)
  1082. length_buff = dwSaveLength;
  1083. }
  1084. }
  1085. break;
  1086. case 374:
  1087. if(!X_DRV && (dwTickCount >= QDN_MotorDelay)) //数控到停止
  1088. {
  1089. QDN_MotorStep = 315;
  1090. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1091. QDN_TFK_VAVLE = 1; //推方块输出
  1092. }
  1093. break;
  1094. case 375:
  1095. if(QDN_GOUZHEN_QIAN_IN)
  1096. {
  1097. QDN_MotorStep = 0;
  1098. }
  1099. else if(dwTickCount >= QDN_MotorDelay)
  1100. {
  1101. QDN_SetAlarmCode(QDN_GZ_ALARM);
  1102. }
  1103. break;
  1104. //切完延时后拉带松夹子
  1105. case 40:
  1106. if(QDN_PARAM_SJZ_LENGTH == 0)
  1107. {
  1108. QDN_JD_VAVLE = 0;
  1109. }
  1110. QDN_MotorDelay = dwTickCount + QDN_PARAM_CUT_BACK_DELAY;
  1111. SetDir(X_AXIS, QDN_DIR_P);
  1112. // QDN_JZ_DIR = QDN_YDIR_P;
  1113. SetDir(X_AXIS, QDN_DIR_N);
  1114. QDN_MotorStep = 41;
  1115. break;
  1116. case 41:
  1117. if((dwTickCount >= QDN_MotorDelay))
  1118. {
  1119. jz_buff = cRealPos;
  1120. if(QDN_JD_VAVLE)
  1121. //两段速度移动距离
  1122. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  1123. AxisMoveTwoPos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,QDN_PARAM_SJZ_LENGTH,5000,
  1124. QDN_PARAM_BACK_LENGTH,QDN_DIR_P,QDN_PARAM_START_SPEED,
  1125. QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1126. else
  1127. //夹子已经张开
  1128. AxisMovePosAccDec(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH),
  1129. QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,10,0);
  1130. // AxisMovePos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH));
  1131. QDN_MotorStep = 42;
  1132. }
  1133. break;
  1134. case 42:
  1135. if(((QDN_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  1136. {
  1137. QDN_JD_VAVLE = 0;
  1138. QDN_MotorStep = 43;
  1139. }
  1140. if(!X_DRV)
  1141. {
  1142. QDN_JD_VAVLE = 0;
  1143. QDN_MotorStep = 43;
  1144. }
  1145. break;
  1146. case 43: // 切断完成后拉电机动作
  1147. if(!X_DRV)
  1148. {
  1149. QDN_MotorStep = 0;
  1150. QDN_MotorDelay = dwTickCount;
  1151. }
  1152. break;
  1153. case 61: // 前点定位数控模式
  1154. QDN_BL_VAVLE = 0;//并链也要打开
  1155. if(dwTickCount >= QDN_MotorDelay)
  1156. {
  1157. // QDN_JZ_DIR = QDN_YDIR_N;
  1158. if(!QDN_TL_VAVLE && cZipCnt) //没送链情况下主动送链
  1159. {
  1160. if(!QDN_SHANG_MU_LIMIT_IN && (QDN_TuiLianStep == 0))
  1161. {
  1162. QDN_TuiLianStep = 1;
  1163. QDN_MotorStep = 62;
  1164. }
  1165. }
  1166. else
  1167. QDN_MotorStep = 62;
  1168. }
  1169. break;
  1170. case 62:
  1171. if(dwTickCount >= QDN_MotorDelay)
  1172. {
  1173. if(QDN_QIAN_LIMIT_IN)
  1174. {
  1175. SetPos(X_AXIS, 0);//在前点,直接置零点
  1176. // QDN_JZ_DIR = QDN_YDIR_P;
  1177. //前点亮的情况下先退出
  1178. AxisMovePos(X_AXIS,QDN_PARAM_GO_LOW_SPEED,1000);
  1179. QDN_MotorDelay = dwTickCount + 300;
  1180. }
  1181. QDN_MotorStep = 63;
  1182. QDN_JD_VAVLE = 0;
  1183. }
  1184. break;
  1185. case 63:
  1186. if(!X_DRV && !QDN_QIAN_LIMIT_IN && (dwTickCount >= QDN_MotorDelay))// && !QDN_SHANG_MU_LIMIT_IN)
  1187. {
  1188. SetDir(X_AXIS, QDN_DIR_N);
  1189. // QDN_JZ_DIR = QDN_YDIR_N;
  1190. //SetDir(X_AXIS, QDN_DIR_P);
  1191. go_buff = cRealPos;
  1192. //QDN_YD_VAVLE = 1; //开口不用压带
  1193. // QDN_HL_VAVLE = 1;
  1194. // QDN_YX_VAVLE = 1;
  1195. //李永庆代码,当位置在慢速之外,走数控到慢速点
  1196. if(cZipCnt > 0)
  1197. {
  1198. if(cRealPos>(QDN_PARAM_GO_LOW_SPEED_LENGTH))
  1199. {
  1200. // AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1201. // SetStartSpeed(X_AXIS,QDN_PARAM_START_SPEED);
  1202. // SetAccTime(X_AXIS,QDN_PARAM_ACC);
  1203. // SetDecTime(X_AXIS,QDN_PARAM_DCC);
  1204. //两段速度移动距离
  1205. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  1206. // AxisMoveTwoPos(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH+ 100,QDN_DIR_N);
  1207. //跑三段速度
  1208. // AxisMoveThreePosNoStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH-300-150,
  1209. // QDN_PARAM_GO_HIGH_SPEED*2/3,350,
  1210. // QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH+150,QDN_DIR_N) ;
  1211. AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,-(cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH),
  1212. QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  1213. }
  1214. else
  1215. {
  1216. // X轴 运行速度 启动速度 加速度 减速度
  1217. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
  1218. // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1219. }
  1220. }
  1221. else
  1222. {
  1223. // X轴 运行速度 启动速度 加速度 减速度
  1224. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
  1225. // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_FIRST_GO_HIGHSPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);//
  1226. }
  1227. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1228. QDN_MotorStep =64;
  1229. }
  1230. break;
  1231. case 64:
  1232. if(cZipCnt > 1)
  1233. {
  1234. //李永庆代码
  1235. if(((cRealPos) < (QDN_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QDN_QIAN_DEC_IN))
  1236. {
  1237. //user_datas[126]= GetCurSpeed(X_AXIS);
  1238. // MoveChangSpeedDec(X_AXIS,QDN_PARAM_GO_HIGH_SPEED*2/3,6,8);
  1239. // AxisChangeSpeed(X_AXIS,40);
  1240. QDN_MotorStep =65;
  1241. }
  1242. if(QDN_QIAN_LIMIT_IN)
  1243. {
  1244. back_buff=cRealPos;
  1245. QDN_MotorStep = 301;
  1246. }
  1247. }
  1248. else
  1249. { if(QDN_QIAN_LIMIT_IN)
  1250. {
  1251. back_buff=cRealPos;
  1252. QDN_MotorStep = 301;
  1253. }
  1254. }
  1255. break;
  1256. case 301:
  1257. if(QDN_QIAN_LIMIT_IN && back_buff-cRealPos >= QDN_PARAM_KKQIANDIAN_LENGTH ) //前点限位
  1258. {
  1259. AxisEgmStop(X_AXIS);
  1260. QDN_MotorStep = 66;
  1261. }
  1262. break;
  1263. case 65:
  1264. if(QDN_QIAN_LIMIT_IN)
  1265. {
  1266. back_buff=cRealPos;
  1267. QDN_MotorStep = 301;
  1268. }
  1269. else if(dwTickCount >= QDN_MotorDelay)
  1270. QDN_SetAlarmCode(QDN_NO_ZIPPER_ALARM);
  1271. break;
  1272. case 66:
  1273. if(!X_DRV)
  1274. {
  1275. SetPos(X_AXIS, 0);
  1276. QDN_MotorDelay = dwTickCount;
  1277. QDN_MotorStep = 67;
  1278. }
  1279. break;
  1280. case 67: //等推链完成后,
  1281. if((dwTickCount >= QDN_MotorDelay) && (QDN_TuiLianStep == 0) && ((QDN_PARAM_TIAOSHI_MODE && QDN_bTS) || (QDN_PARAM_TIAOSHI_MODE == 0)) )
  1282. {
  1283. if(bRunning)
  1284. {
  1285. QDN_JD_VAVLE = 1;
  1286. QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
  1287. }
  1288. QDN_MotorStep = 68;
  1289. }
  1290. break;
  1291. case 68:
  1292. if(dwTickCount >= QDN_MotorDelay)
  1293. {
  1294. QDN_YD_VAVLE = 0;
  1295. QDN_TFK_VAVLE = 0;
  1296. // QDN_HL_VAVLE = 0;
  1297. // QDN_YX_VAVLE = 0;
  1298. QDN_TL_VAVLE = 0;
  1299. QDN_MotorStep = 0;
  1300. QDN_MotorDelay = dwTickCount;
  1301. }
  1302. break;
  1303. }
  1304. }
  1305. #endif
  1306. void QueDuan_BingLian(void)
  1307. {
  1308. static long bl_pos_buff,HL_delay;
  1309. switch(QDN_BinLianStep)
  1310. {
  1311. case 0:break;
  1312. case 1:
  1313. bl_pos_buff = cRealPos;
  1314. QDN_BinLianStep = 2;
  1315. break;
  1316. case 2:
  1317. if((cRealPos - bl_pos_buff) >= QDN_PARAM_DELAY_HL_LENGTH)
  1318. {
  1319. QDN_BL_VAVLE = 1;
  1320. QDN_BinLianStep = 3;
  1321. }
  1322. break;
  1323. case 3://有过链检测
  1324. if((cRealPos - bl_pos_buff) >= (QDN_PARAM_ZIPPER_LENGTH - QDN_PARAM_HL_DELAY_BACK))
  1325. {
  1326. QDN_BL_VAVLE = 0;
  1327. QDN_BinLianStep = 0;
  1328. }
  1329. break;
  1330. case 10:
  1331. bl_pos_buff = cRealPos;
  1332. QDN_BinLianStep = 11;
  1333. break;
  1334. case 11:
  1335. if((cRealPos - bl_pos_buff) >= QDN_PARAM_DELAY_HL_LENGTH)
  1336. {
  1337. QDN_BL_VAVLE = 1;
  1338. QDN_BinLianStep = 12;
  1339. }
  1340. break;
  1341. case 12://有过链检测
  1342. if(QDN_GUO_LIAN_IN_DW)
  1343. {
  1344. QDN_BinLianStep = 13;
  1345. QDN_BingLianDelay = dwTickCount + 50;
  1346. }
  1347. break;
  1348. case 13:
  1349. if(QDN_GUO_LIAN_IN)
  1350. QDN_BinLianStep = 12;
  1351. if(dwTickCount>=QDN_BingLianDelay)
  1352. {
  1353. if(!QDN_GUO_LIAN_IN)
  1354. {
  1355. QDN_BL_VAVLE = 0;
  1356. QDN_BinLianStep = 0;
  1357. }
  1358. else
  1359. {
  1360. QDN_BinLianStep = 12;
  1361. }
  1362. }
  1363. break;
  1364. default:;
  1365. }
  1366. }
  1367. #if 1 //闭口
  1368. //作闭口专用程序,也有四种模式
  1369. //不带过链感应长度输入电机长度 闭口有勾针到位
  1370. void QueDuan_Motor_NoGL(void)
  1371. {
  1372. static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
  1373. long pulse_buff;
  1374. unsigned short ch,kk;
  1375. user_datas[121] = QDN_AutoStep;
  1376. user_datas[122] = QDN_MotorStep;
  1377. user_datas[123] = cRealPos;
  1378. user_datas[124] = length_buff;
  1379. user_datas[125] = GetCurSpeed(X_AXIS);
  1380. user_datas[126] = QDN_XiaQieStep;
  1381. user_datas[127] = QDN_XiaQieStep;
  1382. switch(QDN_MotorStep)
  1383. {
  1384. case 30:
  1385. switch(QDN_PARAM_BACK_MODE) //开口分四种模式
  1386. {
  1387. case 0: //单数控模式
  1388. QDN_MotorStep = 310; //每种模式留20步
  1389. QDN_DGLG_VAVLE = 1; //顶过链杆关
  1390. break;
  1391. case 1://单感应模式
  1392. QDN_MotorStep = 330; //每种模式留20步
  1393. break;
  1394. case 2: //先感应后数控模式+检测
  1395. QDN_MotorStep = 350; //每种模式留20步
  1396. break;
  1397. default: //数控模式+过链检测长度
  1398. QDN_MotorStep = 370; //每种模式留20步
  1399. break;
  1400. }
  1401. QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
  1402. break;
  1403. //310步到315步为数控模式
  1404. case 310:
  1405. QDN_MotorStep = 311;
  1406. // QDN_JZ_DIR = QDN_YDIR_P;
  1407. if(QDN_PARAM_BL_ENABLE)
  1408. QDN_BinLianStep = 1; //并链起动
  1409. break;
  1410. case 311:
  1411. if(dwTickCount >= QDN_MotorDelay)
  1412. {
  1413. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  1414. AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
  1415. QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  1416. back_buff = cRealPos;
  1417. gou_zhen_buff = cRealPos;
  1418. save_buff = cRealPos;
  1419. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1420. QDN_MotorStep = 312;
  1421. }
  1422. break;
  1423. case 312:
  1424. //勾针提前输出
  1425. if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH) >= (QDN_PARAM_ZIPPER_LENGTH )))
  1426. {
  1427. QDN_GZ_VAVLE = 1;
  1428. }
  1429. if((cRealPos) >= (QDN_PARAM_ZIPPER_LENGTH - QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
  1430. {
  1431. QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  1432. QDN_MotorStep = 313;
  1433. }//下面条件为无效代码
  1434. else if((cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)
  1435. {
  1436. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  1437. }
  1438. break;
  1439. case 313:
  1440. if(!QDN_GZ_VAVLE && (cRealPos + QDN_PARAM_GOUZHEN_LENGTH) > (QDN_PARAM_ZIPPER_LENGTH ))
  1441. {
  1442. QDN_GZ_VAVLE = 1;
  1443. }
  1444. //提前12MM取消数控模式,进入连续运动
  1445. // if((cRealPos + 100) > (QDN_PARAM_ZIPPER_LENGTH ))
  1446. // {
  1447. // //CancelPmoveState(X_AXIS);
  1448. // SetStartSpeed(X_AXIS,1500);
  1449. // AxisChangeSpeed(X_AXIS,1500);
  1450. // }
  1451. if(QDN_GOUZHEN_HOU_IN)
  1452. {
  1453. AxisEgmStop(X_AXIS);
  1454. QDN_MotorDelay = dwTickCount + 0;
  1455. QDN_YD_VAVLE = 1;
  1456. QDN_MotorStep = 314;
  1457. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1458. }
  1459. else if((cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)
  1460. {
  1461. AxisEgmStop(X_AXIS);
  1462. if(dwTickCount >= QDN_MotorDelay)
  1463. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  1464. }
  1465. // else if((cRealPos >= QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)))// && dwTickCount >= QDN_MotorDelay)
  1466. // {
  1467. // }
  1468. break;
  1469. case 314:
  1470. if(!X_DRV && (dwTickCount >= QDN_MotorDelay))
  1471. {
  1472. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1473. QDN_YD_VAVLE = 1;//压带
  1474. QDN_MotorStep = 315;
  1475. }
  1476. break;
  1477. case 315:
  1478. if(cZipCnt == 0) //第一条把误差到正负9MM
  1479. {
  1480. ch = QDN_PARAM_ZIPPER_LENGTH -90;
  1481. kk = QDN_PARAM_ZIPPER_LENGTH +90;
  1482. }
  1483. else
  1484. {
  1485. ch = QDN_PARAM_ZIPPER_LENGTH -70;
  1486. kk = QDN_PARAM_ZIPPER_LENGTH +70;
  1487. }
  1488. if(((cRealPos) < (ch)))
  1489. {
  1490. SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
  1491. if(dwTickCount >= QDN_MotorDelay)
  1492. bAlarmStop = 1;
  1493. }
  1494. else if((cRealPos > kk))//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
  1495. {
  1496. SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
  1497. if(dwTickCount >= QDN_MotorDelay)
  1498. bAlarmStop = 1;
  1499. }
  1500. else
  1501. {
  1502. QDN_MotorStep = 390; //延时反转步
  1503. }
  1504. break;
  1505. //330步到349步单感应模式
  1506. case 330:
  1507. back_buff = cRealPos;
  1508. gou_zhen_buff = cRealPos;
  1509. save_buff=cRealPos;
  1510. QDN_MotorStep = 331;
  1511. break;
  1512. case 331:
  1513. if(dwTickCount >= QDN_MotorDelay)
  1514. {
  1515. if(cZipCnt < 2)
  1516. {
  1517. if(QDN_PARAM_BL_ENABLE)
  1518. QDN_BinLianStep = 10; //并链起动
  1519. //第一条都是过链感应,后拉速度减半//原来QDN_PARAM_CHECK_BACK_HSPEED/2
  1520. // X轴 运行速度 启动速度 加速度 减速度
  1521. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,13);
  1522. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  1523. // AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)-QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_DIR_P);
  1524. QDN_MotorDelay = dwTickCount + 20;
  1525. QDN_MotorStep = 332;
  1526. }
  1527. else
  1528. {
  1529. if(QDN_PARAM_BL_ENABLE)
  1530. QDN_BinLianStep = 1; //并链起动
  1531. //因为每条都是过链感应,所以直接运行检测模式后拉速度
  1532. // X轴 运行速度 启动速度 加速度 减速度
  1533. //AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1534. if(length_buff>QDN_PARAM_BACK_LOW_SPEED_LENGTH)
  1535. AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,length_buff-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
  1536. QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  1537. else
  1538. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,13);
  1539. QDN_MotorStep = 334;
  1540. }
  1541. }
  1542. break;
  1543. case 332:
  1544. if(QDN_GUO_LIAN_IN_UP)
  1545. {
  1546. checkdelay_buff = cRealPos;
  1547. AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
  1548. QDN_MotorDelay = dwTickCount + 20;
  1549. }
  1550. if(QDN_GUO_LIAN_IN && dwTickCount >= QDN_MotorDelay)
  1551. {
  1552. QDN_MotorDelay = dwTickCount + QDN_PARAM_FEEL_GZ_DELAY;//QDN_PARAM_DELAY_XM;
  1553. QDN_MotorStep = 333;
  1554. }
  1555. else if(!QDN_GUO_LIAN_IN)
  1556. {
  1557. QDN_MotorDelay = dwTickCount + 20;
  1558. }
  1559. break;
  1560. case 333: //此步为前两条运行
  1561. if(!QDN_PARAM_BKGZ_NUMBER) //有钩针模式
  1562. {
  1563. if(dwTickCount >= QDN_MotorDelay)
  1564. {
  1565. QDN_MotorStep = 334;
  1566. QDN_GZ_VAVLE = 1;
  1567. }
  1568. if(QDN_GUO_LIAN_IN_DW)
  1569. {
  1570. gou_zhen_buff = cRealPos;
  1571. QDN_MotorStep = 335;
  1572. QDN_GZ_VAVLE = 1;
  1573. }
  1574. }
  1575. else // 无钩针模式
  1576. {
  1577. if(QDN_GUO_LIAN_IN_DW)
  1578. {
  1579. gou_zhen_buff = cRealPos;
  1580. QDN_MotorStep = 335;
  1581. }
  1582. }
  1583. break;
  1584. case 334:
  1585. if(!QDN_PARAM_BKGZ_NUMBER) // 有钩针模式
  1586. {
  1587. if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
  1588. {
  1589. gou_zhen_buff = cRealPos;
  1590. QDN_MotorStep = 335;
  1591. QDN_GZ_VAVLE = 1;
  1592. }
  1593. if(cZipCnt > 1) //第三条开始要长度误差
  1594. {
  1595. if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
  1596. {
  1597. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  1598. //user_datas[128] = 1;
  1599. }
  1600. }
  1601. }
  1602. else // 无钩针模式
  1603. {
  1604. if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
  1605. {
  1606. gou_zhen_buff = cRealPos;
  1607. QDN_MotorStep = 335;
  1608. }
  1609. if(cZipCnt > 1) //第三条开始要长度误差
  1610. {
  1611. if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
  1612. {
  1613. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  1614. //user_datas[128] = 1;
  1615. }
  1616. }
  1617. }
  1618. break;
  1619. case 335:
  1620. if(!QDN_PARAM_BKGZ_NUMBER) //有钩针模式
  1621. {
  1622. if(QDN_GUO_LIAN_IN_DW)
  1623. {
  1624. gou_zhen_buff = cRealPos;
  1625. }
  1626. //在空们都把延时清零
  1627. if(QDN_GUO_LIAN_IN)
  1628. {
  1629. gou_zhen_buff = cRealPos;
  1630. }
  1631. //距离到停
  1632. // if(cRealPos -gou_zhen_buff > QDN_PARAM_BKGY_LENGTH )
  1633. // {
  1634. // AxisEgmStop(X_AXIS);
  1635. // QDN_MotorDelay = dwTickCount + 10;
  1636. // QDN_YD_VAVLE = 1;
  1637. // QDN_MotorStep = 336;
  1638. // QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1639. // }
  1640. //感应到停
  1641. if(QDN_GOUZHEN_HOU_IN)
  1642. {
  1643. AxisEgmStop(X_AXIS);
  1644. QDN_MotorDelay = dwTickCount + 10;
  1645. QDN_YD_VAVLE = 1;
  1646. QDN_MotorStep = 336;
  1647. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1648. }
  1649. else
  1650. {
  1651. if(cZipCnt > 1) //2 条后才有长度误差
  1652. {
  1653. if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
  1654. {
  1655. AxisEgmStop(X_AXIS);
  1656. //user_datas[128] = 2;
  1657. if(dwTickCount >= QDN_MotorDelay)
  1658. QDN_SetAlarmCode(QDN_GZ_ALARM);
  1659. }
  1660. }
  1661. }
  1662. }
  1663. else
  1664. {
  1665. if(QDN_GUO_LIAN_IN_DW)
  1666. {
  1667. gou_zhen_buff = cRealPos;
  1668. }
  1669. //在空们都把延时清零
  1670. if(QDN_GUO_LIAN_IN)
  1671. {
  1672. gou_zhen_buff = cRealPos;
  1673. }
  1674. if(cRealPos -gou_zhen_buff > QDN_PARAM_BKGY_LENGTH )
  1675. {
  1676. AxisEgmStop(X_AXIS);
  1677. QDN_MotorDelay = dwTickCount + 10;
  1678. QDN_YD_VAVLE = 1;
  1679. QDN_MotorStep = 336;
  1680. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1681. }
  1682. else
  1683. {
  1684. if(cZipCnt > 1) //2 条后才有长度误差
  1685. {
  1686. if(cRealPos >= (length_buff + QDN_PARAM_ERROR_LENGTH))
  1687. {
  1688. AxisEgmStop(X_AXIS);
  1689. //user_datas[128] = 2;
  1690. if(dwTickCount >= QDN_MotorDelay)
  1691. QDN_SetAlarmCode(QDN_GZ_ALARM);
  1692. }
  1693. }
  1694. }
  1695. }
  1696. break;
  1697. case 336:
  1698. if(cZipCnt > 1) //长度检测
  1699. {
  1700. ch = QDN_PARAM_ZIPPER_LENGTH;
  1701. //user_datas[127] = ch;
  1702. if(((cRealPos + QDN_PARAM_ERROR_LENGTH) < (ch)) && QDN_PARAM_ERROR_LENGTH)
  1703. {
  1704. NQDJGNUNMBER =1;
  1705. //user_datas[128] = 3;
  1706. if(dwTickCount >= QDN_MotorDelay)
  1707. bAlarmStop = 1;
  1708. }
  1709. else if((cRealPos > (ch + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
  1710. {
  1711. //user_datas[128] = 4;
  1712. NQDJGNUNMBER = 2;
  1713. if(dwTickCount >= QDN_MotorDelay)
  1714. bAlarmStop = 1;
  1715. }
  1716. else
  1717. {
  1718. QDN_MotorStep = 337;
  1719. }
  1720. }
  1721. else
  1722. {
  1723. if(cZipCnt == 1)
  1724. {
  1725. length_buff = cRealPos - save_buff;
  1726. SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
  1727. }
  1728. QDN_MotorStep = 337;
  1729. }
  1730. break;
  1731. case 337:
  1732. QDN_MotorStep = 390;
  1733. // SetDir(X_AXIS, QDN_DIR_N);
  1734. // if(dwTickCount >= QDN_MotorDelay)
  1735. // {
  1736. // AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1737. // QDN_MotorStep = 0;
  1738. // }
  1739. break;
  1740. //350步到369步单感应模式
  1741. case 350:
  1742. back_buff = cRealPos;
  1743. gou_zhen_buff = cRealPos;
  1744. save_buff=cRealPos;
  1745. QDN_MotorStep = 351;
  1746. break;
  1747. case 351:
  1748. if(dwTickCount >= QDN_MotorDelay)
  1749. {
  1750. QDN_MotorStep = 352;
  1751. //第一,二条都是过链感应,测量长度
  1752. if(cZipCnt < 2)
  1753. {
  1754. if(QDN_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
  1755. QDN_BinLianStep = 10; //并链起动
  1756. QDN_DGLG_VAVLE = 0; //顶过链杆关
  1757. // X轴 运行速度 启动速度 加速度 减速度
  1758. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_BACK_LOW_SPEED*2,QDN_DIR_P,QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,8,12);
  1759. QDN_MotorDelay = dwTickCount + 20;
  1760. }
  1761. else
  1762. {
  1763. if(QDN_PARAM_BL_ENABLE)
  1764. QDN_BinLianStep = 1; //并链起动
  1765. QDN_DGLG_VAVLE = 1; //顶过链杆关
  1766. QDN_CheckLengthStep = 1; //长度检测,第3条才有对比
  1767. //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
  1768. QDN_MotorStep = 311;
  1769. }
  1770. }
  1771. break;
  1772. case 352:
  1773. //前两条都按最低速度工作
  1774. if(QDN_GUO_LIAN_IN_UP)
  1775. {
  1776. checkdelay_buff = cRealPos;
  1777. AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
  1778. QDN_MotorDelay = dwTickCount + 20;
  1779. }
  1780. if(QDN_GUO_LIAN_IN && dwTickCount >= QDN_MotorDelay)
  1781. {
  1782. QDN_MotorDelay = dwTickCount + QDN_PARAM_FEEL_GZ_DELAY;//QDN_PARAM_DELAY_XM;
  1783. QDN_MotorStep = 353;
  1784. }
  1785. else if(!QDN_GUO_LIAN_IN)
  1786. {
  1787. QDN_MotorDelay = dwTickCount + 20;
  1788. }
  1789. break;
  1790. case 353:
  1791. //此步为前两条运行
  1792. if(dwTickCount >= QDN_MotorDelay)
  1793. {
  1794. QDN_MotorStep = 354;
  1795. QDN_GZ_VAVLE = 1;
  1796. }
  1797. if(QDN_GUO_LIAN_IN_DW)
  1798. {
  1799. gou_zhen_buff = cRealPos;
  1800. QDN_MotorStep = 355;
  1801. QDN_GZ_VAVLE = 1;
  1802. }
  1803. break;
  1804. case 354:
  1805. if(QDN_GUO_LIAN_IN_DW) //下降沿,定位长度
  1806. {
  1807. if(QDN_GUO_LIAN_IN_DW)
  1808. {
  1809. gou_zhen_buff = cRealPos;
  1810. QDN_MotorStep = 355;
  1811. QDN_GZ_VAVLE = 1;
  1812. }
  1813. }
  1814. break;
  1815. case 355:
  1816. //在空们都把延时清零
  1817. if(QDN_GOUZHEN_HOU_IN)
  1818. {
  1819. AxisEgmStop(X_AXIS);
  1820. QDN_MotorDelay = dwTickCount + 10;
  1821. QDN_YD_VAVLE = 1;
  1822. QDN_MotorStep = 356;
  1823. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1824. }
  1825. break;
  1826. case 356:
  1827. if(cZipCnt == 1)
  1828. {
  1829. length_buff = cRealPos - save_buff;
  1830. SetData32bits(QDN_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
  1831. }
  1832. QDN_MotorStep = 357;
  1833. break;
  1834. case 357:
  1835. QDN_MotorStep = 390; //延时反转步
  1836. // SetDir(X_AXIS, QDN_DIR_N);
  1837. // AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1838. // QDN_MotorStep = 0;
  1839. break;
  1840. //370步到389步为数控模式
  1841. case 370:
  1842. QDN_MotorStep = 371;
  1843. // QDN_JZ_DIR = QDN_YDIR_P;
  1844. if(QDN_PARAM_BL_ENABLE)
  1845. QDN_BinLianStep = 1; //并链起动
  1846. QDN_CheckLengthStep = 1; //长度检测开始
  1847. break;
  1848. case 371:
  1849. if(dwTickCount >= QDN_MotorDelay)
  1850. {
  1851. back_buff = cRealPos;
  1852. gou_zhen_buff = cRealPos;
  1853. save_buff = cRealPos;
  1854. //李永庆代码
  1855. SetDir(X_AXIS, QDN_DIR_P);
  1856. \
  1857. AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH,
  1858. QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  1859. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1860. QDN_MotorStep = 372;
  1861. }
  1862. break;
  1863. case 372:
  1864. //勾针提前输出
  1865. if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH) >= (QDN_PARAM_ZIPPER_LENGTH )))
  1866. QDN_GZ_VAVLE = 1;
  1867. if((cRealPos + QDN_PARAM_BACK_LOW_SPEED_LENGTH + 20) > (QDN_PARAM_ZIPPER_LENGTH + (*length_buffer))) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
  1868. {
  1869. QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  1870. QDN_MotorStep = 373;
  1871. }
  1872. else if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + (*length_buffer)))//QDN_PARAM_ERROR_LENGTH))
  1873. {
  1874. QDN_SetAlarmCode(QDN_GZ_ALARM);
  1875. }
  1876. break;
  1877. case 373:
  1878. //勾针提前输出
  1879. if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH) >= (QDN_PARAM_ZIPPER_LENGTH )))
  1880. QDN_GZ_VAVLE = 1;
  1881. //提前12MM取消数控模式,进入连续运动
  1882. // if((cRealPos + 100) > (QDN_PARAM_ZIPPER_LENGTH ))
  1883. // {
  1884. // //CancelPmoveState(X_AXIS);
  1885. // SetStartSpeed(X_AXIS,1500);
  1886. // AxisChangeSpeed(X_AXIS,1500);
  1887. // }
  1888. if(QDN_GOUZHEN_HOU_IN)
  1889. {
  1890. AxisEgmStop(X_AXIS);
  1891. QDN_MotorDelay = dwTickCount + 0;
  1892. QDN_YD_VAVLE = 1;
  1893. QDN_MotorStep = 374;
  1894. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  1895. }
  1896. else if((cRealPos >= (QDN_PARAM_ZIPPER_LENGTH + QDN_PARAM_ERROR_LENGTH)) && QDN_PARAM_ERROR_LENGTH)
  1897. {
  1898. AxisEgmStop(X_AXIS);
  1899. if(dwTickCount >= QDN_MotorDelay)
  1900. QDN_SetAlarmCode(QDN_GZ_ALARM);
  1901. }
  1902. break;
  1903. case 374:
  1904. if(!X_DRV)
  1905. {
  1906. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1907. QDN_YD_VAVLE = 1;
  1908. QDN_MotorStep = 375;
  1909. }
  1910. break;
  1911. case 375:
  1912. if(cZipCnt == 0) //第一条把误差到正负9MM
  1913. {
  1914. ch = QDN_PARAM_ZIPPER_LENGTH - 90;
  1915. kk = QDN_PARAM_ZIPPER_LENGTH + 90;
  1916. }
  1917. else
  1918. {
  1919. ch = QDN_PARAM_ZIPPER_LENGTH;
  1920. kk = QDN_PARAM_ZIPPER_LENGTH;
  1921. }
  1922. if(((cRealPos + QDN_PARAM_ERROR_LENGTH) < (ch)))
  1923. {
  1924. SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
  1925. if(dwTickCount >= QDN_MotorDelay)
  1926. bAlarmStop = 1;
  1927. }
  1928. else if((cRealPos > (kk + QDN_PARAM_ERROR_LENGTH)))//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
  1929. {
  1930. SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
  1931. if(dwTickCount >= QDN_MotorDelay)
  1932. bAlarmStop = 1;
  1933. }
  1934. else
  1935. {
  1936. // SetDir(X_AXIS, QDN_DIR_N);
  1937. // AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
  1938. QDN_MotorStep = 390; //延时反转步
  1939. }
  1940. break;
  1941. //此两步为到位后反转步
  1942. case 390:
  1943. //SetDir(X_AXIS, QDN_DIR_N);
  1944. QDN_YD_VAVLE=1;//先压带后延时反转
  1945. QDN_MotorDelay = dwTickCount + QDN_PARAM_YD_FZ_DELAY;
  1946. QDN_MotorStep = 391;
  1947. break;
  1948. case 391:
  1949. if(dwTickCount >= QDN_MotorDelay)
  1950. {
  1951. //SetDir(X_AXIS, QDN_DIR_N);
  1952. AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,3000,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  1953. QDN_MotorStep = 392;
  1954. }
  1955. break;
  1956. case 392:
  1957. if(!X_DRV)
  1958. {
  1959. QDN_MotorStep = 0;
  1960. }
  1961. break;
  1962. #if 0 //下面为老的数控模式
  1963. case 30:
  1964. QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
  1965. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  1966. if(QDN_PARAM_BL_ENABLE) //
  1967. QDN_BinLianStep = 1;
  1968. if(QDN_MACHINE_TYPE == QDN_CS_TUIFANGKUAI) //双开带过链感应
  1969. {
  1970. if(QDN_PARAM_DEC_MODE == QDN_BACK_NOMAL_DEC_MODE)//测长数控
  1971. QDN_MotorStep = 101;
  1972. else
  1973. QDN_MotorStep = 31;
  1974. }
  1975. else //闭口走长度
  1976. QDN_MotorStep = 31;
  1977. break;
  1978. case 31:
  1979. if(dwTickCount >= QDN_MotorDelay)
  1980. {
  1981. back_buff = cRealPos;
  1982. gou_zhen_buff = cRealPos;
  1983. save_buff = cRealPos;
  1984. length_buffer = &QDN_PARAM_OFFSET_LENGTH;
  1985. //李永庆代码
  1986. SetDir(X_AXIS, QDN_DIR_N);
  1987. //两段速度移动距离
  1988. // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
  1989. AxisMoveTwoPos(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH-200,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_BACK_LOW_SPEED_LENGTH + (*length_buffer),QDN_DIR_P);
  1990. //AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_BACK_SPEED,QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH,QDN_PARAM_START_SPEED,QDN_PARAM_BACK_LOW_SPEED,4,QDN_PARAM_DCC+8);
  1991. SetDir(X_AXIS,QDN_DIR_P);
  1992. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1993. QDN_MotorStep = 32;
  1994. }
  1995. break;
  1996. case 32:
  1997. //勾针提前输出
  1998. if (!QDN_GZ_VAVLE && ((cRealPos + QDN_PARAM_GOUZHEN_LENGTH + 200) >= (QDN_PARAM_ZIPPER_LENGTH )))
  1999. QDN_GZ_VAVLE = 1;
  2000. if((cRealPos) > (QDN_PARAM_ZIPPER_LENGTH-QDN_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QDN_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC)))))
  2001. {
  2002. QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  2003. QDN_MotorStep = 33;
  2004. }
  2005. else if(cRealPos >= (QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//QDN_PARAM_ERROR_LENGTH))
  2006. {
  2007. QDN_SetAlarmCode(QDN_GZ_ALARM);
  2008. }
  2009. break;
  2010. case 33:
  2011. if(!QDN_GZ_VAVLE && (cRealPos + QDN_PARAM_GOUZHEN_LENGTH + 200) > (QDN_PARAM_ZIPPER_LENGTH ))
  2012. {
  2013. QDN_GZ_VAVLE = 1;
  2014. QDN_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  2015. }
  2016. //提前12MM取消数控模式,进入连续运动
  2017. // if((cRealPos + 180 + 200) > (QDN_PARAM_ZIPPER_LENGTH ))
  2018. // {
  2019. // CancelPmoveState(X_AXIS);
  2020. // SetStartSpeed(X_AXIS,1500);
  2021. // AxisChangeSpeed(X_AXIS,1500);
  2022. // }
  2023. if(QDN_GOUZHEN_HOU_IN)
  2024. {
  2025. AxisEgmStop(X_AXIS);
  2026. QDN_MotorDelay = dwTickCount + 10;
  2027. QDN_YD_VAVLE = 1;
  2028. QDN_MotorStep = 34;
  2029. QDN_BL_VAVLE = 0; //停止时并链一定要打开
  2030. }
  2031. else if((cRealPos >= QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))// && dwTickCount >= QDN_MotorDelay)
  2032. {
  2033. AxisEgmStop(X_AXIS);
  2034. if(dwTickCount >= QDN_MotorDelay)
  2035. QDN_SetAlarmCode(QDN_GZ_ALARM);
  2036. }
  2037. break;
  2038. case 34:
  2039. if(!X_DRV && (dwTickCount >= QDN_MotorDelay))
  2040. {
  2041. QDN_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  2042. QDN_YD_VAVLE = 1;
  2043. QDN_MotorStep = 35;
  2044. }
  2045. break;
  2046. case 35:
  2047. if(cZipCnt == 0)
  2048. {
  2049. ch = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-90;
  2050. kk = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+90;
  2051. }
  2052. else
  2053. {
  2054. ch = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-70;
  2055. kk = QDN_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+70;
  2056. }user_datas[128] = ch;
  2057. user_datas[127] = kk;
  2058. if(((cRealPos) < (ch)))
  2059. {
  2060. SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
  2061. if(dwTickCount >= QDN_MotorDelay)
  2062. bAlarmStop = 1;
  2063. }
  2064. else if((cRealPos > kk))//(QDN_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
  2065. {
  2066. SetAlarmCode(QDN_ALARM_ADDR,QDN_LENGTH_LONG_ALARM);
  2067. if(dwTickCount >= QDN_MotorDelay)
  2068. bAlarmStop = 1;
  2069. }
  2070. else
  2071. {
  2072. SetDir(X_AXIS, QDN_DIR_N);
  2073. SetDir(X_AXIS, QDN_DIR_P);
  2074. AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,-QDN_PARAM_FZ_LENGTH,3000,QDN_PARAM_ACC,QDN_PARAM_DCC);
  2075. SetDir(X_AXIS, QDN_DIR_P);
  2076. QDN_MotorStep = 0;
  2077. }
  2078. break;
  2079. case 101:
  2080. if(dwTickCount >= QDN_MotorDelay)
  2081. {
  2082. back_buff = cRealPos;
  2083. gou_zhen_buff = cRealPos;
  2084. save_buff = cRealPos;
  2085. if(cZipCnt <= 2)
  2086. {
  2087. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  2088. MoveAction_Const_AccDec(X_AXIS,QDN_DIR_P,QDN_PARAM_FIRST_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  2089. QDN_MotorStep = 102;
  2090. }
  2091. else
  2092. {
  2093. MoveAction_Const_AccDec(X_AXIS,QDN_DIR_P,QDN_PARAM_BACK_SPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  2094. QDN_MotorStep = 102;
  2095. }
  2096. }
  2097. break;
  2098. case 102:
  2099. if(cZipCnt <= 2)
  2100. {
  2101. //拉链上升沿,就是到空位
  2102. if(QDN_GUO_LIAN_IN_UP)
  2103. {
  2104. QDN_MotorDelay = dwTickCount + QDN_PARAM_GZ_DELAY;
  2105. if(X_DRV)
  2106. AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED); //降速
  2107. QDN_MotorStep = 103;
  2108. }
  2109. }
  2110. else
  2111. {
  2112. //1为双开
  2113. if((QDN_SK_MODE) && (((cRealPos + QDN_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH))))
  2114. {
  2115. // QDN_HL_VAVLE = 1;
  2116. }
  2117. if(((cRealPos - gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH)) && !QDN_GZ_VAVLE)
  2118. {
  2119. QDN_GZ_VAVLE = 1;
  2120. }
  2121. if((cRealPos - back_buff) > (length_buff - QDN_PARAM_BACK_LOW_SPEED_LENGTH-PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDN_PARAM_BACK_SPEED,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_DCC))))
  2122. {
  2123. if(X_DRV)
  2124. {
  2125. AxisChangeSpeed(X_AXIS,QDN_PARAM_BACK_LOW_SPEED);
  2126. }
  2127. QDN_MotorStep = 103;
  2128. }
  2129. }
  2130. break;
  2131. case 103:
  2132. if(cZipCnt <= 2)
  2133. {//双开暂不用,先保留
  2134. #if QDN_SK_MODE
  2135. if((QDN_SK_MODE) && ((dwTickCount + QDN_PARAM_GZ_DELAY/2) >= QDN_MotorDelay))
  2136. {
  2137. QDN_YX_VAVLE = 1;
  2138. QDN_HL_VAVLE = 1;
  2139. }
  2140. #endif
  2141. if(dwTickCount >= QDN_MotorDelay)
  2142. {
  2143. QDN_GZ_VAVLE = 1;
  2144. // QDN_YX_VAVLE = 1;
  2145. #if QDN_SK_MODE //双开暂不用,先保留
  2146. if(QDN_SK_MODE)
  2147. QDN_MotorStep = 154;
  2148. else
  2149. #endif
  2150. QDN_MotorStep = 160;
  2151. }
  2152. }
  2153. else
  2154. {
  2155. #if QDN_SK_MODE //双开暂不用,先保留
  2156. if((QDN_SK_MODE) && (((cRealPos + QDN_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH))))
  2157. {
  2158. QDN_YX_VAVLE = 1;
  2159. QDN_HL_VAVLE = 1;
  2160. }
  2161. #endif
  2162. if(((cRealPos - gou_zhen_buff) > (length_buff - QDN_PARAM_GOUZHEN_LENGTH)))
  2163. {
  2164. QDN_GZ_VAVLE = 1;
  2165. #if QDN_SK_MODE //双开暂不用,先保留
  2166. if(QDN_SK_MODE)
  2167. QDN_MotorStep = 154;
  2168. else
  2169. #endif
  2170. QDN_MotorStep = 160;
  2171. }
  2172. if(((cRealPos - save_buff) >= (QDN_PARAM_ERROR_LENGTH + length_buff)) && QDN_GZ_VAVLE)
  2173. {
  2174. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  2175. }
  2176. }
  2177. break;
  2178. case 154:
  2179. #if QDN_SK_MODE //双开暂不用,先保留
  2180. if(QDN_GZ_UP_IN)
  2181. {
  2182. QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_CHECK_GZ;
  2183. QDN_MotorStep = 104;
  2184. }
  2185. #endif
  2186. break;
  2187. case 160:
  2188. if(QDN_GOUZHEN_HOU_IN)
  2189. {
  2190. AxisEgmStop(X_AXIS);
  2191. QDN_YD_VAVLE = 1;
  2192. QDN_MotorStep = 105;
  2193. }
  2194. else if(((cRealPos - save_buff) >= (QDN_PARAM_ERROR_LENGTH + length_buff)) && QDN_GZ_VAVLE && (cZipCnt > 2))
  2195. {
  2196. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  2197. }
  2198. break;
  2199. case 104:
  2200. #if QDN_SK_MODE //双开暂不用,先保留
  2201. if(dwTickCount >= QDN_MotorDelay)
  2202. {
  2203. //勾针离开就是到位
  2204. if(!QDN_GOUZHEN_HOU_IN && QDN_GZ_UP_IN)
  2205. {
  2206. AxisEgmStop(X_AXIS);
  2207. QDN_MotorStep = 105;
  2208. }
  2209. }
  2210. #endif
  2211. break;
  2212. case 105:
  2213. if(!X_DRV)
  2214. {
  2215. QDN_MotorStep = 0;
  2216. // QDN_HL_VAVLE = 1;
  2217. QDN_YD_VAVLE = 1;
  2218. if(cZipCnt == 1)
  2219. {
  2220. go_length_buff = cRealPos - back_buff;
  2221. }
  2222. else if(cZipCnt == 2)
  2223. {
  2224. length_buff = cRealPos - back_buff;
  2225. }
  2226. else if(cZipCnt > 2)
  2227. {
  2228. if(((cRealPos - save_buff) < (length_buff - QDN_PARAM_ERROR_LENGTH- (*length_buffer))))QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  2229. else if(((cRealPos - save_buff) > (QDN_PARAM_ERROR_LENGTH + length_buff - (*length_buffer))))QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  2230. else
  2231. {
  2232. }
  2233. }
  2234. AxisMovePosAccDec(X_AXIS,QDN_PARAM_BACK_LOW_SPEED,QDN_PARAM_FZ_LENGTH,1,QDN_PARAM_ACC,QDN_PARAM_DCC);
  2235. }
  2236. break;
  2237. case 106:
  2238. if(!X_DRV)
  2239. {
  2240. QDN_SetAlarmCode(QDN_GZ_ALARM);
  2241. }
  2242. else
  2243. {
  2244. if(QDN_GOUZHEN_HOU_IN)
  2245. {
  2246. AxisEgmStop(X_AXIS);
  2247. QDN_YD_VAVLE = 1;
  2248. QDN_MotorStep = 0;
  2249. }
  2250. }
  2251. break;
  2252. #endif
  2253. case 40:
  2254. if(!QDN_SecondXiaQueStep)
  2255. {
  2256. if(QDN_PARAM_SJZ_LENGTH == 0)
  2257. {
  2258. QDN_MotorDelay = dwTickCount + QDN_PARAM_CUT_BACK_DELAY;
  2259. QDN_JD_VAVLE = 0;
  2260. }
  2261. else
  2262. QDN_MotorDelay = dwTickCount + 3;
  2263. }
  2264. else
  2265. {
  2266. if(QDN_PARAM_Secondleave_LENGTH == 0)
  2267. {
  2268. QDN_MotorDelay = dwTickCount + 20;
  2269. QDN_JD_VAVLE = 0;
  2270. }
  2271. else
  2272. QDN_MotorDelay = dwTickCount + 3;
  2273. }
  2274. SetDir(X_AXIS, QDN_DIR_N);
  2275. QDN_MotorStep = 41;
  2276. jz_buff = cRealPos;
  2277. break;
  2278. case 41:
  2279. if(!QDN_SecondXiaQueStep)
  2280. {
  2281. if((dwTickCount >= QDN_MotorDelay))
  2282. {
  2283. //夹子已经张开
  2284. AxisMovePosAccDec(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH),
  2285. QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,10,0);
  2286. // AxisMovePos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH));
  2287. QDN_MotorStep = 42;
  2288. }
  2289. }
  2290. else
  2291. {
  2292. if((dwTickCount >= QDN_MotorDelay))
  2293. {
  2294. AxisMovePosAccDec(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_Secondleave_LENGTH+QDN_PARAM_BACK_LENGTH),
  2295. QDN_PARAM_START_SPEED,QDN_PARAM_START_SPEED,10,10,0);
  2296. // AxisMovePos(X_AXIS,QDN_PARAM_CUT_BACK_SPEED,(QDN_PARAM_SJZ_LENGTH+QDN_PARAM_BACK_LENGTH));
  2297. QDN_MotorStep = 42;
  2298. }
  2299. }
  2300. break;
  2301. case 42:
  2302. if(!QDN_SecondXiaQueStep)
  2303. {
  2304. if(((QDN_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
  2305. {
  2306. QDN_JD_VAVLE = 0;
  2307. }
  2308. }
  2309. else
  2310. {
  2311. if(((QDN_PARAM_Secondleave_LENGTH) <= (cRealPos - jz_buff)))
  2312. {
  2313. QDN_JD_VAVLE = 0;
  2314. }
  2315. }
  2316. if(!X_DRV)
  2317. {
  2318. QDN_JD_VAVLE = 0;
  2319. QDN_MotorStep = 43;
  2320. }
  2321. break;
  2322. case 43: // 切断完成后拉电机动作
  2323. if(!X_DRV)
  2324. {
  2325. QDN_MotorStep = 0;
  2326. QDN_MotorDelay = dwTickCount;
  2327. }
  2328. break;
  2329. case 61: // 前点定位数控模式
  2330. QDN_BL_VAVLE = 0;//并链也要打开
  2331. if(dwTickCount >= QDN_MotorDelay)
  2332. {
  2333. // QDN_JZ_DIR = QDN_YDIR_N;
  2334. if(!QDN_TL_VAVLE && cZipCnt) //没送链情况下主动送链
  2335. {
  2336. if(!QDN_SHANG_MU_LIMIT_IN && (QDN_TuiLianStep == 0))
  2337. {
  2338. QDN_TuiLianStep = 1;
  2339. QDN_MotorStep = 62;
  2340. }
  2341. }
  2342. else
  2343. QDN_MotorStep = 62;
  2344. }
  2345. break;
  2346. case 62:
  2347. if(dwTickCount >= QDN_MotorDelay)
  2348. {
  2349. if(QDN_QIAN_LIMIT_IN)
  2350. {
  2351. SetPos(X_AXIS, 0);//在前点,直接置零点
  2352. //前点亮的情况下先退出
  2353. AxisMovePos(X_AXIS,QDN_PARAM_GO_LOW_SPEED,1000);
  2354. QDN_MotorDelay = dwTickCount + 300;
  2355. }
  2356. QDN_MotorStep = 63;
  2357. QDN_JD_VAVLE = 0;
  2358. }
  2359. break;
  2360. case 63:
  2361. if(!X_DRV && !QDN_QIAN_LIMIT_IN && (dwTickCount >= QDN_MotorDelay))// && !QDN_SHANG_MU_LIMIT_IN)
  2362. {
  2363. //SetDir(X_AXIS, QDN_DIR_N);
  2364. go_buff = cRealPos;
  2365. QDN_YD_VAVLE = 1;
  2366. // QDN_HL_VAVLE = 1;
  2367. // QDN_YX_VAVLE = 1;
  2368. //李永庆代码,当位置在慢速之外,走数控到慢速点
  2369. if(cZipCnt > 0)
  2370. {
  2371. if(cRealPos>(QDN_PARAM_GO_LOW_SPEED_LENGTH))
  2372. {
  2373. // AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  2374. // SetStartSpeed(X_AXIS,QDN_PARAM_START_SPEED);
  2375. // SetAccTime(X_AXIS,QDN_PARAM_ACC);
  2376. // SetDecTime(X_AXIS,QDN_PARAM_DCC);
  2377. //两段速度移动距离
  2378. // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
  2379. // AxisMoveTwoPos(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos-QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH+ 100,QDN_DIR_N);
  2380. //跑三段速度
  2381. // AxisMoveThreePosNoStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH-300,
  2382. // QDN_PARAM_GO_HIGH_SPEED*2/3,350,
  2383. // QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_DIR_N) ;
  2384. AxisMovePosAccDecNotStop(X_AXIS,QDN_PARAM_GO_HIGH_SPEED,-(cRealPos -QDN_PARAM_GO_LOW_SPEED_LENGTH),
  2385. QDN_PARAM_START_SPEED,QDN_PARAM_GO_LOW_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  2386. }
  2387. else
  2388. {
  2389. // X轴 运行速度 启动速度 加速度 减速度
  2390. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
  2391. // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED_LENGTH,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);
  2392. }
  2393. }
  2394. else
  2395. {
  2396. // X轴 运行速度 启动速度 加速度 减速度
  2397. AxisContinueMoveAcc(X_AXIS,QDN_PARAM_GO_LOW_SPEED,QDN_DIR_N,QDN_PARAM_GO_LOW_SPEED/3,QDN_PARAM_GO_LOW_SPEED/3,15,15);
  2398. // MoveAction_Const_AccDec(X_AXIS, QDN_DIR_N,QDN_PARAM_FIRST_GO_HIGHSPEED,QDN_PARAM_START_SPEED,QDN_PARAM_ACC,QDN_PARAM_DCC);//
  2399. }
  2400. QDN_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  2401. QDN_MotorStep =64;
  2402. }
  2403. break;
  2404. case 64:
  2405. if(cZipCnt > 1)
  2406. {
  2407. //李永庆代码
  2408. if(((cRealPos) < (QDN_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QDN_QIAN_DEC_IN))
  2409. {
  2410. //user_datas[126]= GetCurSpeed(X_AXIS);
  2411. // MoveChangSpeedDec(X_AXIS,QDN_PARAM_GO_HIGH_SPEED*2/3,6,8);
  2412. // AxisChangeSpeed(X_AXIS,40);
  2413. QDN_MotorStep =65;
  2414. }
  2415. if(QDN_QIAN_LIMIT_IN) //前点限位
  2416. {
  2417. SetPos(X_AXIS, QDN_PARAM_BKQIANDIAN_LENGTH);
  2418. //AxisEgmStop(X_AXIS);
  2419. QDN_MotorStep = 66;
  2420. }
  2421. }
  2422. else
  2423. {
  2424. if(QDN_QIAN_LIMIT_IN) //前点限位
  2425. {
  2426. //AxisEgmStop(X_AXIS);
  2427. SetPos(X_AXIS, QDN_PARAM_BKQIANDIAN_LENGTH);
  2428. QDN_MotorStep = 66;
  2429. }
  2430. }
  2431. break;
  2432. case 65:
  2433. if(QDN_QIAN_LIMIT_IN)
  2434. {
  2435. //AxisEgmStop(X_AXIS);
  2436. SetPos(X_AXIS, QDN_PARAM_BKQIANDIAN_LENGTH);
  2437. QDN_MotorStep = 66;
  2438. }
  2439. else if(dwTickCount >= QDN_MotorDelay)
  2440. QDN_SetAlarmCode(QDN_NO_ZIPPER_ALARM);
  2441. break;
  2442. case 66:
  2443. if(!X_DRV || cRealPos<=0)
  2444. {
  2445. AxisEgmStop(X_AXIS);
  2446. SetPos(X_AXIS, 0);
  2447. QDN_MotorDelay = dwTickCount + 15;
  2448. QDN_MotorStep = 67;
  2449. }
  2450. break;
  2451. case 67: //等推链完成后,
  2452. if((dwTickCount >= QDN_MotorDelay) && (QDN_TuiLianStep == 0) && ((QDN_PARAM_TIAOSHI_MODE && QDN_bTS) || (QDN_PARAM_TIAOSHI_MODE == 0)) )
  2453. {
  2454. if(bRunning)
  2455. {
  2456. QDN_JD_VAVLE = 1;
  2457. QDN_MotorDelay = dwTickCount + QDN_PARAM_DELAY_BACK;
  2458. }
  2459. QDN_MotorStep = 68;
  2460. }
  2461. break;
  2462. case 68:
  2463. if(dwTickCount >= QDN_MotorDelay)
  2464. {
  2465. QDN_YD_VAVLE = 0;
  2466. // QDN_HL_VAVLE = 0;
  2467. // QDN_YX_VAVLE = 0;
  2468. QDN_TL_VAVLE = 0;
  2469. QDN_MotorStep = 0;
  2470. QDN_MotorDelay = dwTickCount;
  2471. }
  2472. break;
  2473. }
  2474. }
  2475. #endif
  2476. //电机动作
  2477. void QueDuan_Motor(void)
  2478. {
  2479. if(QDN_PARAM_KAIBEE_SELECT) //闭口
  2480. {
  2481. QueDuan_Motor_NoGL();
  2482. }
  2483. else //开口
  2484. {
  2485. //开口
  2486. QueDuan_Motor_KK(); //
  2487. }
  2488. // switch(QDN_MACHINE_TYPE)
  2489. // {
  2490. // case QDN_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
  2491. // case QDN_NO_GL_TUIFANGKUAI: QueDuan_Motor_NoGL();break;
  2492. // case QDN_CS_TUIFANGKUAI:break;
  2493. // default:;
  2494. // }
  2495. }
  2496. //超声方式下切,开口专用
  2497. void QueDuan_XiaQue_KK(void)
  2498. {
  2499. switch(QDN_XiaQieStep)
  2500. {
  2501. case 0:
  2502. break;
  2503. case 1:
  2504. /*
  2505. if(bRunning)
  2506. {
  2507. QDN_XiaQieStep = 6;
  2508. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2509. if(QDN_SAFE_IN)
  2510. {
  2511. bStop = 1;
  2512. QDN_XM_VAVLE = 0;
  2513. }
  2514. }
  2515. else
  2516. */
  2517. QDN_XiaQieStep = 2;
  2518. break;
  2519. case 2:
  2520. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2521. QDN_XiaQieStep = 3;
  2522. break;
  2523. case 3:
  2524. if(1)
  2525. {
  2526. QDN_XiaQieDelay = dwTickCount + 0;//QDN_PARAM_GZ_DELAY;
  2527. QDN_XiaQieStep = 4;
  2528. }
  2529. else if(dwTickCount >= QDN_XiaQieDelay)
  2530. {
  2531. QDN_SetAlarmCode(QDN_XM_DAOWEI);
  2532. }
  2533. break;
  2534. case 4:
  2535. if(QDN_GZ_VAVLE) //勾针已经有输出就不需要延时
  2536. {
  2537. QDN_XiaQieDelay = dwTickCount + 0;
  2538. }
  2539. else
  2540. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_TFK_DELAY;
  2541. QDN_GZ_VAVLE = 1;
  2542. cTuiFangKuaiCnt=0;
  2543. QDN_XiaQieStep = 5;
  2544. break;
  2545. case 5:
  2546. if(dwTickCount >= QDN_XiaQieDelay)
  2547. {
  2548. QDN_TFK_VAVLE = 1;
  2549. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2550. QDN_XiaQieStep = 6;
  2551. }
  2552. break;
  2553. case 6:
  2554. if(1)
  2555. {
  2556. QDN_XiaQieStep = 7;
  2557. QDN_XiaQieDelay = dwTickCount + 1000;
  2558. }
  2559. else if(dwTickCount >= QDN_XiaQieDelay)
  2560. {
  2561. QDN_SetAlarmCode(QDN_GZ_ALARM);
  2562. QDN_TFK_VAVLE=0;
  2563. QDN_GZ_VAVLE=0;
  2564. }
  2565. break;
  2566. case 7:
  2567. if(QDN_GOUZHEN_QIAN_IN /*| !bRunning*/ )
  2568. {
  2569. cTuiFangKuaiCnt = 0;
  2570. //QDN_YD_VAVLE = 1;
  2571. if(!bRunning)
  2572. QDN_XiaQieDelay = dwTickCount + 200;
  2573. else
  2574. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
  2575. if(!QDN_QIAN_LIMIT_IN)
  2576. {
  2577. QDN_XiaQieStep = 8;
  2578. }
  2579. else
  2580. {
  2581. QDN_SetAlarmCode(QDN_QIAN_LIMIT_ALARM);
  2582. QDN_TFK_VAVLE=0;
  2583. QDN_GZ_VAVLE=0;
  2584. }
  2585. }
  2586. else if((dwTickCount >= QDN_XiaQieDelay))
  2587. {
  2588. if(cTuiFangKuaiCnt < QDN_PARAM_TFK_NUMBER)
  2589. {
  2590. QDN_TFK_VAVLE = 0;
  2591. cTuiFangKuaiCnt++;
  2592. QDN_XiaQieDelay = dwTickCount + 500;
  2593. QDN_XiaQieStep = 100;
  2594. }
  2595. else
  2596. {
  2597. QDN_SetAlarmCode(QDN_GZ_ALARM);
  2598. QDN_TFK_VAVLE=0;
  2599. QDN_GZ_VAVLE=0;
  2600. }
  2601. }
  2602. break;
  2603. case 100:
  2604. if((dwTickCount >= QDN_XiaQieDelay))
  2605. {
  2606. QDN_XiaQieStep = 5;
  2607. }
  2608. break;
  2609. case 8://上下模同时输出
  2610. if(dwTickCount >= QDN_XiaQieDelay)
  2611. {
  2612. QDN_SM_VAVLE = 1;
  2613. if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
  2614. QDN_XM_KAIKOU_VAVLE=1;
  2615. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2616. QDN_XiaQieStep = 9;
  2617. }
  2618. break;
  2619. case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
  2620. if(QDN_SHANG_MU_LIMIT_IN && (QDN_KAIKUO_XIAMO_LIMIT_IN || QDN_PARAM_XM_ENABLE) && ((QDN_bTiaoShiMode && QDN_bTiaoShiStep) || (QDN_bTiaoShiMode == 0)) )
  2621. {
  2622. if(!QDN_PARAM_CS_MODE) //无超声配置
  2623. {
  2624. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAYBACK_SM; //
  2625. QDN_XiaQieStep = 12;
  2626. }
  2627. else
  2628. {
  2629. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAY_CS; //
  2630. QDN_XiaQieStep = 10;
  2631. }
  2632. }
  2633. else if(dwTickCount >= QDN_XiaQieDelay)
  2634. {
  2635. if(!QDN_SHANG_MU_LIMIT_IN)QDN_SetAlarmCode(QDN_SM_DAOWEI);
  2636. else QDN_SetAlarmCode(QDN_XM_DAOWEI);
  2637. }
  2638. break;
  2639. case 10:
  2640. if(dwTickCount >= QDN_XiaQieDelay)
  2641. {
  2642. QDN_CS_OUT = 1;
  2643. //
  2644. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_TIME; //
  2645. QDN_XiaQieStep = 11;
  2646. }
  2647. break;
  2648. case 11:
  2649. if(dwTickCount >= QDN_XiaQieDelay)
  2650. {
  2651. QDN_CS_OUT = 0;
  2652. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_COLD_TIME; //
  2653. QDN_XiaQieStep = 12;
  2654. }
  2655. break;
  2656. case 12:
  2657. if(dwTickCount >= QDN_XiaQieDelay)
  2658. {
  2659. QDN_SM_VAVLE = 0;
  2660. if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
  2661. QDN_XM_KAIKOU_VAVLE=0;
  2662. if(!QDN_PARAM_TFK_SELECT) //切断后推方块退
  2663. QDN_TFK_VAVLE = 0;
  2664. QDN_GZ_VAVLE = 0;
  2665. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  2666. QDN_XiaQieStep = 13;
  2667. }//
  2668. break;
  2669. case 13:
  2670. if(!QDN_SHANG_MU_LIMIT_IN)
  2671. {
  2672. //启动推链(送链)
  2673. if((QDN_TuiLianStep == 0) && !QDN_TL_VAVLE)
  2674. QDN_TuiLianStep = 1;
  2675. }
  2676. if(!QDN_SHANG_MU_LIMIT_IN && (!QDN_KAIKUO_XIAMO_LIMIT_IN || QDN_PARAM_XM_ENABLE))
  2677. {
  2678. QDN_XiaQieStep = 0;
  2679. }
  2680. else if(dwTickCount >= QDN_XiaQieDelay)
  2681. {
  2682. QDN_SetAlarmCode(QDN_SM_YUANWEI);
  2683. }
  2684. break;
  2685. }
  2686. }
  2687. void QueDuan_TuiLianAction(void)
  2688. {
  2689. if(QDN_PARAM_XM_ENABLE == 0)
  2690. {
  2691. QDN_TuiLianStep = 0;
  2692. }
  2693. else
  2694. {
  2695. switch(QDN_TuiLianStep)
  2696. {
  2697. case 1:
  2698. QDN_TuiLianStep = 2;
  2699. break;
  2700. case 2:
  2701. QDN_TLDelay = dwTickCount + QDN_PARAM_YD_DELAY;
  2702. QDN_TuiLianStep = 3;
  2703. break;
  2704. case 3:
  2705. if(!QDN_SM_VAVLE && !QDN_SHANG_MU_LIMIT_IN)//dwTickCount >= QDN_TLDelay)
  2706. {
  2707. QDN_TL_VAVLE = 1;
  2708. if(!bRunning)QDN_TFK_VAVLE = 0;
  2709. QDN_TLDelay = dwTickCount + QDN_PARAM_TL_DELAY;
  2710. QDN_TuiLianStep = 4;
  2711. }
  2712. break;
  2713. case 4:
  2714. if(dwTickCount >= QDN_TLDelay)
  2715. {
  2716. QDN_TuiLianStep = 0;
  2717. }
  2718. break;
  2719. case 10:
  2720. QDN_TuiLianStep = 11;
  2721. break;
  2722. case 11:
  2723. if(!Y_DRV)
  2724. {
  2725. {
  2726. QDN_TuiLianStep = 0;
  2727. }
  2728. }
  2729. break;
  2730. }
  2731. }
  2732. }
  2733. //闭口专用
  2734. void QueDuan_XiaQue_NO_GL(void)
  2735. {
  2736. switch(QDN_XiaQieStep)
  2737. {
  2738. case 0:
  2739. break;
  2740. case 1:
  2741. if(!bRunning)
  2742. {
  2743. if(/*(QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) && */QDN_SK_MODE)
  2744. {
  2745. //跳到双开
  2746. // QDN_YD_VAVLE = 1;
  2747. QDN_GZ_VAVLE = 1; //勾针
  2748. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
  2749. QDN_XiaQieStep = 100;
  2750. }
  2751. else
  2752. {
  2753. // QDN_GZ_VAVLE = 1; //勾针
  2754. // QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
  2755. // QDN_XiaQieStep = 100;
  2756. QDN_YD_VAVLE = 1;
  2757. QDN_XiaQieStep = 2;
  2758. QDN_XiaQieDelay = dwTickCount + 30;
  2759. }
  2760. }
  2761. else
  2762. {
  2763. QDN_YD_VAVLE = 1;
  2764. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CUT_DELAY;
  2765. QDN_XiaQieStep = 2;
  2766. }
  2767. break;
  2768. case 2:
  2769. if(dwTickCount >= QDN_XiaQieDelay)
  2770. {
  2771. QDN_XiaQieStep = 3;
  2772. QDN_XiaQieDelay = dwTickCount;
  2773. }
  2774. break;
  2775. case 3:
  2776. if(dwTickCount >= QDN_XiaQieDelay)
  2777. {
  2778. if((QDN_PARAM_TIAOSHI_MODE && QDN_bTS) || (QDN_PARAM_TIAOSHI_MODE == 0))
  2779. {
  2780. QDN_SM_VAVLE = 1;
  2781. if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
  2782. QDN_XM_VAVLE = 1;
  2783. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2784. QDN_XiaQieStep = 4;
  2785. }
  2786. }
  2787. break;
  2788. case 4:
  2789. if(QDN_SHANG_MU_LIMIT_IN && (QDN_XIA_MU_LIMIT_IN || QDN_PARAM_XM_ENABLE))
  2790. {
  2791. QDN_GZ_VAVLE = 0;
  2792. if(!QDN_PARAM_CS_MODE) //气切
  2793. {
  2794. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAYBACK_SM; //
  2795. QDN_XiaQieStep = 5;
  2796. }
  2797. else
  2798. {
  2799. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_DELAY_CS; //
  2800. QDN_XiaQieStep = 10;
  2801. } //
  2802. }
  2803. else if(dwTickCount >= QDN_XiaQieDelay)
  2804. {
  2805. if(!QDN_SHANG_MU_LIMIT_IN)
  2806. QDN_SetAlarmCode(QDN_SM_DAOWEI);
  2807. else
  2808. QDN_SetAlarmCode(QDN_XM_DAOWEI);
  2809. }
  2810. break;
  2811. case 5:
  2812. if(dwTickCount >= QDN_XiaQieDelay)
  2813. {
  2814. QDN_SM_VAVLE = 0;
  2815. if(QDN_PARAM_XM_ENABLE == 0) //配置下模动
  2816. QDN_XM_VAVLE = 0;
  2817. QDN_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
  2818. QDN_XiaQieStep = 6;
  2819. }
  2820. break;
  2821. case 6:
  2822. if(!QDN_SHANG_MU_LIMIT_IN && (!QDN_XIA_MU_LIMIT_IN || QDN_PARAM_XM_ENABLE)) //下模不动就不用判断
  2823. {
  2824. if(QDN_TuiLianStep == 0)
  2825. QDN_TuiLianStep = 1;
  2826. if(!bRunning)
  2827. QDN_JD_VAVLE = 0;
  2828. QDN_XiaQieStep = 0;
  2829. }
  2830. else if(dwTickCount >= QDN_XiaQieDelay)
  2831. {
  2832. QDN_SetAlarmCode(QDN_SM_YUANWEI);
  2833. }
  2834. break;
  2835. //10~11步为超声
  2836. case 10:
  2837. if(dwTickCount >= QDN_XiaQieDelay)
  2838. {
  2839. if(QDN_PARAM_CS_ENABLE)QDN_CS_OUT = 1;
  2840. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_TIME; //
  2841. QDN_XiaQieStep = 11;
  2842. }
  2843. break;
  2844. case 11:
  2845. if(dwTickCount >= QDN_XiaQieDelay)
  2846. {
  2847. QDN_CS_OUT = 0;
  2848. QDN_XiaQieDelay = dwTickCount + QDN_PARAM_CS_COLD_TIME; //
  2849. QDN_XiaQieStep = 5;
  2850. }
  2851. break;
  2852. case 100:
  2853. if(dwTickCount >= QDN_XiaQieDelay)
  2854. {
  2855. //这是双开程序,暂时不考虑
  2856. #if 1
  2857. if(QDN_GOUZHEN_HOU_IN)
  2858. {
  2859. QDN_YD_VAVLE = 1;
  2860. QDN_XiaQieStep = 3;
  2861. }
  2862. #endif
  2863. }
  2864. break;
  2865. }
  2866. }
  2867. //第二刀下切步骤
  2868. void QueDuan_SecondXiaQue(void)
  2869. {
  2870. switch(QDN_SecondXiaQueStep)
  2871. {
  2872. case 1:
  2873. if(dwTickCount >= QDN_SecondXQDelay)
  2874. {
  2875. QDN_SecondXiaQueStep = 2;
  2876. if(QDN_MotorStep == 0)
  2877. {
  2878. QDN_MotorStep = 61; //前点定位
  2879. }
  2880. }
  2881. break;
  2882. case 2:
  2883. if(QDN_MotorStep == 0)
  2884. {
  2885. QDN_SecondXiaQueStep = 3;
  2886. QDN_SecondXQDelay = dwTickCount + 20;
  2887. }
  2888. break;
  2889. case 3:
  2890. if(dwTickCount >= QDN_SecondXQDelay)
  2891. {
  2892. AxisMovePosAccDec(X_AXIS,1000,QDN_PARAM_SecondDAO_LENGTH,1000,1000,QDN_PARAM_ACC,QDN_PARAM_DCC,0);
  2893. QDN_SecondXiaQueStep = 4;
  2894. }
  2895. break;
  2896. case 4:
  2897. if(!X_DRV)
  2898. {
  2899. QDN_XiaQieStep=1;
  2900. QDN_SecondXiaQueStep = 5;
  2901. }
  2902. break;
  2903. case 5:
  2904. if((QDN_XiaQieStep == 0) || ((QDN_XiaQieStep == 6) && (QDN_PARAM_KAIBEE_SELECT == 1)))
  2905. {
  2906. if(QDN_MotorStep == 0)
  2907. {
  2908. QDN_MotorStep = 40; //切完后退
  2909. }
  2910. QDN_SecondXiaQueStep = 6;
  2911. }
  2912. break;
  2913. case 6:
  2914. if(QDN_MotorStep == 0)
  2915. {
  2916. QDN_SecondXiaQueStep = 0;
  2917. if(NQDJGNUNMBER==0)
  2918. QDN_AutoStep = 6;
  2919. else if(NQDJGNUNMBER==1)
  2920. QDN_SetAlarmCode(QDN_LENGTH_LONG_ALARM);
  2921. else if(NQDJGNUNMBER==2)
  2922. QDN_SetAlarmCode(QDN_LENGTH_SHORT_ALARM);
  2923. }
  2924. break;
  2925. }
  2926. }
  2927. //切断动作
  2928. void QueDuan_XiaQue(void)
  2929. {
  2930. if(QDN_PARAM_KAIBEE_SELECT)//QDN_KB_MODE) //闭口
  2931. {
  2932. QueDuan_XiaQue_NO_GL(); //
  2933. }
  2934. else //开口
  2935. {
  2936. QueDuan_XiaQue_KK();
  2937. }
  2938. #if 0
  2939. switch(QDN_MACHINE_TYPE)
  2940. {
  2941. case QDN_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
  2942. case QDN_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
  2943. case QDN_CS_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
  2944. default:;
  2945. }
  2946. #endif
  2947. }
  2948. #endif