JHSKQueDuanJi.c 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477
  1. #include "global.h"
  2. #if JIN_HONG_MACHINE ==1
  3. void SK_QueDuan_AlarmProtect(void);
  4. void SK_QueDuan_ManualAction(void);
  5. void SK_QueDuan_AutoAction(void);
  6. void SK_QueDuan_StepCheckStart(void);
  7. void SK_QueDuan_XiaQue(void);
  8. void SK_QueDuan_BingLian(void);
  9. void SK_QueDuan_Motor(void);
  10. void SK_QueDuan_YuanDianAction(void);
  11. void SK_QueDuan_ExtiActionX31(void);
  12. void SK_StopCode(void);
  13. void SK_Motor_SZ(unsigned char En);
  14. short *SK_length_buffer;
  15. short *SK_GYlength_buffer;
  16. void SK_QueDuan_ExtiActionX31(void)
  17. {
  18. SK_NcCheckLianFlg = 1;
  19. }
  20. void SK_QD_SetAlarmCode(unsigned alarm_code)
  21. {
  22. SetAlarmCode(SKQD_ALARM_ADDR,alarm_code);
  23. bAlarmStop = 1;
  24. }
  25. void SK_StopCode(void)
  26. {
  27. switch(SKQD_StopStep)
  28. {
  29. case 1:
  30. SKQD_StopStep=2;
  31. if(X_DRV)
  32. {
  33. AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS) * 2/3);
  34. AxisDecStop(X_AXIS);
  35. }
  36. break;
  37. case 2:
  38. if(!X_DRV || (dwXRealPos < 10))
  39. {
  40. SKQD_StopCodeDelay=dwTickCount+350;
  41. SKQD_StopStep = 3;
  42. }
  43. break;
  44. case 3:
  45. if(dwTickCount >= SKQD_StopCodeDelay)
  46. {
  47. // if(!cSTOPONE)
  48. {
  49. SKQD_StopStep=0;
  50. }
  51. // else
  52. // {
  53. // QD_SetAlarmCode(QD_PARAM_ANQUANMEN_ALARM);
  54. // BKQD_StopStep=0;
  55. // cSTOPONE=0;
  56. // }
  57. SK_Motor_SZ(SKQD_MOTOR_DIS); //电机松轴
  58. }
  59. break;
  60. }
  61. }
  62. //电机松轴
  63. void SK_Motor_SZ(unsigned char En)
  64. {
  65. if(En) //使能
  66. {
  67. if(SKQD_PARAM_MOTOR_SELECT)
  68. SKQD_SZ_OUT = 1; //伺服电机
  69. else
  70. SKQD_SZ_OUT = 0; //步进电机
  71. }
  72. else //松轴
  73. {
  74. if(SKQD_PARAM_MOTOR_SELECT)
  75. SKQD_SZ_OUT = 0; //伺服电机
  76. else
  77. SKQD_SZ_OUT = 1; //步进电机
  78. }
  79. }
  80. void SK_QueDuan_InitAction(void)
  81. {
  82. float length_buff,pulse_buff;
  83. length_buff = SKQD_PARAM_CYCLE_LENGTH;
  84. pulse_buff = SKQD_PARAM_CYCLE_PULSE;
  85. XGearRatio = pulse_buff/length_buff;
  86. SK_Motor_SZ(SKQD_MOTOR_DIS); //电机松轴
  87. SetAlarmCode(SKQD_ALARM_ADDR,0);
  88. SetDirReverse(X_AXIS, 0);
  89. axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,0);
  90. }
  91. void SK_QueDuan_Action(void)
  92. {
  93. user_datas[123] = 11;
  94. SK_QueDuan_AlarmProtect();
  95. SK_StopCode();
  96. SK_QueDuan_Motor();
  97. SK_QueDuan_XiaQue();
  98. SK_QueDuan_BingLian();
  99. SK_QueDuan_ManualAction();
  100. SK_QueDuan_AutoAction();
  101. SK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
  102. }
  103. //手动动作
  104. void SK_QueDuan_ManualAction(void)
  105. {
  106. if(bRunning == 0)
  107. {
  108. //下切
  109. if(SKQD_bXiaQie)
  110. {
  111. SKQD_bXiaQie = 0;
  112. if(SKQD_XiaQieStep == 0)
  113. {
  114. SKQD_XiaQieStep = 1;
  115. }
  116. }
  117. if(SKQD_bQianDianDW)
  118. {
  119. SKQD_bQianDianDW = 0;
  120. if(SKQD_MotorStep == 0 && !SKQD_XIAMO_IN &&!SKQD_SHANGMO_IN)
  121. {
  122. SKQD_MotorStep = 61;
  123. SK_cZipCnt = 0;
  124. SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
  125. SKQD_MotorDelay = dwTickCount + 150;
  126. }
  127. }
  128. if(SKQD_bSM)
  129. {
  130. SKQD_bSM = 0;
  131. if(SKQD_YAGOUZHEN_IN && !SKQD_SHANGMO_VAVLE)
  132. {
  133. SKQD_SHANGMO_VAVLE = 1;
  134. }
  135. else if (SKQD_SHANGMO_VAVLE)
  136. {
  137. SKQD_SHANGMO_VAVLE = 0;
  138. }
  139. }
  140. if(SKQD_bXM)
  141. {
  142. SKQD_bXM = 0;
  143. SKQD_XIAMO_VAVLE = ~SKQD_XIAMO_VAVLE;
  144. }
  145. if(SKQD_bBinLian)//合链
  146. {
  147. SKQD_bBinLian = 0;
  148. SKQD_BL_VAVLE = ~SKQD_BL_VAVLE;
  149. }
  150. if(SKQD_bGZ)
  151. {
  152. SKQD_bGZ = 0;
  153. if(SKQD_SHANGMO_ROIGIN_IN && SKQD_GZ_VAVLE)
  154. SKQD_GZ_VAVLE =0;
  155. else if (!SKQD_GZ_VAVLE)
  156. SKQD_GZ_VAVLE=1;
  157. }
  158. if(SKQD_bDGZ )
  159. {
  160. SKQD_bDGZ = 0;
  161. SKQD_DGZ_VAVLE = ~SKQD_DGZ_VAVLE;
  162. }
  163. if(SKQD_bChaoSheng)
  164. {
  165. SKQD_bChaoSheng = 0;
  166. SKQD_CSB_VAVLE = 1;
  167. SKQD_CSDelay = dwTickCount + SKQD_PARAM_CS_TIME + 5;
  168. }
  169. if(SKQD_XiaQieStep == 0)
  170. {
  171. if(dwTickCount >= SKQD_CSDelay)
  172. SKQD_CSB_VAVLE = 0;
  173. }
  174. if(SKQD_bTABLE)
  175. {
  176. SKQD_bTABLE = 0;
  177. SK_cTableCnt = 0;
  178. SKQD_TABLE_VAVLE = ~SKQD_TABLE_VAVLE;
  179. }
  180. if(SKQD_bJIAZI)
  181. {
  182. SKQD_bJIAZI = 0;
  183. SKQD_JIAZI_VAVLE = ~SKQD_JIAZI_VAVLE;
  184. }
  185. if(SKQD_bYADAI)
  186. {
  187. SKQD_bYADAI = 0;
  188. SKQD_YADAI_VAVLE = ~SKQD_YADAI_VAVLE;
  189. }
  190. //电机控制
  191. if(SKQD_bGoMotor && !SKQD_QIAN_LIMIT_IN)
  192. {
  193. SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
  194. SKQD_STOPINDelay = dwTickCount;
  195. if(!X_DRV)
  196. {
  197. // X轴 运行速度 启动速度 加速度 减速度
  198. AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_N,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,10,12);
  199. }
  200. }
  201. if(SKQD_bBackMotor) //后退限位已经取消
  202. {
  203. SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
  204. SKQD_STOPINDelay = dwTickCount;
  205. if(!X_DRV)
  206. // X轴 运行速度 启动速度 加速度 减速度
  207. AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_P,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,10,12);
  208. }
  209. if(!SKQD_bGoMotor && !SKQD_bBackMotor && (SKQD_MotorStep == 0) && (dwTickCount >= SKQD_STOPINDelay))
  210. {
  211. if(X_DRV) AxisEgmStop(X_AXIS);
  212. }
  213. if(SKQD_QIAN_LIMIT_IN && (SKQD_MotorStep == 0) && !SKQD_bBackMotor &&(SKQD_AutoStep == 0))
  214. {
  215. if(X_DRV)AxisEgmStop(X_AXIS);
  216. }
  217. }
  218. }
  219. void SK_QueDuan_AlarmProtect(void)
  220. {
  221. dwXRealPos = GetPos(X_AXIS);
  222. if(!bRunning)
  223. {
  224. ;
  225. }
  226. else
  227. {
  228. if(SKQD_PARAM_RUN_LENGTH < 5000)
  229. SKQD_PARAM_RUN_LENGTH= 5000;
  230. if((dwXRealPos > SKQD_PARAM_RUN_LENGTH) && (SK_NcGoLimitEn != 0)) //第一条手动时不保护
  231. {
  232. //AxisDecStop(X_AXIS); //AxisEgmStop(X_AXIS);
  233. SK_NcGoLimitEn = 0;
  234. bStop = 1;
  235. SKQD_StopStep = 1;
  236. SKQD_JIAZI_VAVLE = 0;
  237. SetAlarmCode(SKQD_ALARM_ADDR,SKQD_BACK_ALARM);
  238. }
  239. }
  240. }
  241. void SK_QueDuan_AutoAction(void)
  242. {
  243. if(bRunning)
  244. {//台面电机定时关掉
  245. if(dwTickCount >= SKQD_TBDelay)
  246. SKQD_TABLE_VAVLE = 0;
  247. switch(SKQD_AutoStep)
  248. {
  249. case 1:
  250. if(dwTickCount >= SKQD_AutoDelay)
  251. {
  252. if(SKQD_MotorStep == 0)
  253. {
  254. SKQD_AutoStep = 2;
  255. SKQD_MotorDelay = dwTickCount;
  256. SKQD_MotorStep = 61; //前点定位
  257. }
  258. SK_NcGoLimitEn = 0;
  259. }
  260. break;
  261. case 2:
  262. if(SKQD_MotorStep == 0)
  263. {
  264. SKQD_MotorStep = 30; //夹链后拉
  265. SKQD_AutoStep = 3;
  266. SK_NcGoLimitEn = 1;
  267. }
  268. break;
  269. case 3: //后面两步为延时反转步
  270. if((SKQD_MotorStep == 0) )//|| (SKQD_MotorStep == 392) || (SKQD_MotorStep == 393))
  271. {
  272. if(SKQD_SAFE_IN)
  273. {
  274. bStop = 1;
  275. }
  276. else
  277. {
  278. if(SKQD_XiaQieStep == 0)
  279. SKQD_XiaQieStep = 1;
  280. SKQD_AutoStep = 4;
  281. }
  282. }
  283. break;
  284. case 4:
  285. if((SKQD_XiaQieStep == 0) || (SKQD_XiaQieStep == 13))// && !QD_SHANG_MU_LIMIT_IN)
  286. {
  287. if(SKQD_MotorStep == 0)
  288. {
  289. SKQD_MotorStep = 40; //切完后退
  290. }
  291. SKQD_AutoStep = 5;
  292. }
  293. break;
  294. case 5:
  295. if(SKQD_MotorStep == 0)
  296. {
  297. SK_cZipCnt++;
  298. SKQD_PARAM_NOW_CNT++;
  299. SK_cTableCnt++;
  300. AddToTal(SKQD_TOTAL_ADDR);
  301. AddToTal(CT_WORKTOTAL_ADDR);
  302. CalProSP(SKQD_PROSPEED_ADDR);
  303. if(SK_cTableCnt >= SKQD_PARAM_TABLE_NUM)
  304. {
  305. SK_cTableCnt = 0;
  306. SKQD_TABLE_VAVLE = 1;
  307. SKQD_TBDelay = dwTickCount + SKQD_PARAM_TB_TIME;
  308. }
  309. if(SK_SingOneFlg)
  310. {
  311. bRunning = 0;
  312. SKQD_AutoStep = 0;
  313. SK_SingOneFlg = 0;
  314. }
  315. else
  316. {
  317. SKQD_AutoStep = 1;
  318. if((SKQD_PARAM_NOW_CNT >= SKQD_PARAM_ZHA_SHU) && (SKQD_PARAM_ZHA_SHU > 0))
  319. {
  320. SK_cTableCnt = 0;
  321. SKQD_TABLE_VAVLE = 1;
  322. SKQD_TBDelay = dwTickCount + SKQD_PARAM_TB_TIME;
  323. SKQD_AutoDelay = dwTickCount + SKQD_PARAM_ZS_STOP_TIME;
  324. SKQD_PARAM_NOW_CNT = 0;
  325. if(SKQD_PARAM_ZS_STOP_TIME == 0)
  326. {
  327. bRunning = 0;
  328. SKQD_AutoStep = 0;
  329. SK_SingOneFlg = 0;
  330. SK_QD_SetAlarmCode(SKQD_TOTAL_ALARM);
  331. SKQD_TABLE_VAVLE = 0;
  332. }
  333. }
  334. else
  335. SKQD_AutoDelay = dwTickCount + SKQD_PARAM_CYCLE_DELAY;
  336. }
  337. }
  338. break;
  339. }
  340. }
  341. }
  342. //合链
  343. void SK_QueDuan_BingLian(void)
  344. {
  345. static long bl_pos_buff;
  346. switch(SKQD_BinLianStep)
  347. {
  348. case 0:break;
  349. case 1:
  350. bl_pos_buff = dwXRealPos;
  351. SKQD_BinLianStep = 2;
  352. break;
  353. case 2:
  354. if((dwXRealPos - bl_pos_buff) >= SKQD_PARAM_DELAY_HL_LENGTH)
  355. {
  356. SKQD_BL_VAVLE = 1;
  357. SKQD_BinLianStep = 3;
  358. }
  359. break;
  360. case 3://有过链检测
  361. if((SKQD_GZ_VAVLE && (SKQD_PARAM_HL_DELAY_BACK == 0)) || ((dwXRealPos - bl_pos_buff) >= (SKQD_PARAM_ZIPPER_LENGTH - SKQD_PARAM_HL_DELAY_BACK)))
  362. {
  363. SKQD_BL_VAVLE = 0;
  364. SKQD_BinLianStep = 0;
  365. }
  366. break;
  367. case 10:
  368. bl_pos_buff = dwXRealPos;
  369. SKQD_BinLianStep = 11;
  370. break;
  371. case 11:
  372. if((dwXRealPos - bl_pos_buff) >= SKQD_PARAM_DELAY_HL_LENGTH)
  373. {
  374. SKQD_BL_VAVLE = 1;
  375. SKQD_BinLianStep = 12;
  376. }
  377. break;
  378. case 12://有过链检测
  379. if(SKQD_GUOLIAN_IN_DW)
  380. {
  381. SKQD_BinLianStep = 13;
  382. SKQD_BLDelay = dwTickCount + SKQD_PARAM_BL_DELAY_BACK;
  383. }
  384. break;
  385. case 13:
  386. if(dwTickCount >= SKQD_BLDelay )
  387. {
  388. SKQD_BL_VAVLE = 0;
  389. SKQD_BinLianStep = 0;
  390. }
  391. break;
  392. default:;
  393. }
  394. }
  395. void SK_QueDuan_StepCheckStart(void)
  396. {
  397. // 启动
  398. if((SKQD_START_IN_UP) || bStart || SKQD_bSingle)
  399. {
  400. bStart = 0;
  401. if(!bRunning && (SKQD_AutoStep == 0))
  402. {
  403. if(!SKQD_XIAMO_ROIGIN_IN) SK_QD_SetAlarmCode(SKQD_XM_DAOWEI);
  404. else if(!SKQD_SHANGMO_ROIGIN_IN) SK_QD_SetAlarmCode(SKQD_SM_ALARM);
  405. else
  406. {
  407. bRunning = 1;
  408. SKQD_AutoStep = 1;
  409. SK_SingOneFlg= 0;
  410. if(SKQD_bSingle)
  411. SK_SingOneFlg= 1;
  412. SK_cZipCnt = 0;
  413. SK_cTuiFangKuaiCnt = 0;
  414. SetAlarmCode(SKQD_ALARM_ADDR,0);
  415. SK_Motor_SZ(SKQD_MOTOR_EN); //电机锁轴
  416. SKQD_AutoDelay = dwTickCount + 150;
  417. SK_NcGoLimitEn = 0;
  418. SKQD_BL_VAVLE=0;
  419. SKQD_GZ_VAVLE =0;
  420. SKQD_DGZ_VAVLE =0;
  421. }
  422. }
  423. SKQD_bSingle = 0;
  424. }
  425. //停止
  426. if((SKQD_STOP_IN_UP && (dwTickCount >= SKQD_STOPINDelay)) || bStop)
  427. {
  428. bStop = 0;
  429. SKQD_STOPINDelay = dwTickCount + 100;
  430. if(bRunning)
  431. {
  432. SKQD_AutoDelay = dwTickCount;
  433. SKQD_MotorDelay = dwTickCount;
  434. SKQD_XiaQieDelay = dwTickCount;
  435. SK_SingOneFlg = 0;
  436. SKQD_BinLianStep = 0;
  437. if((SKQD_StopStep == 0) && X_DRV)
  438. SKQD_StopStep = 1;
  439. // AxisDecStop(X_AXIS);
  440. SetAlarmCode(SKQD_ALARM_ADDR,0);
  441. SKQD_SHANGMO_VAVLE =0;
  442. SKQD_XIAMO_VAVLE =0;
  443. SKQD_CSB_VAVLE =0;
  444. SKQD_TABLE_VAVLE=0;
  445. SKQD_BL_VAVLE=0;
  446. }
  447. else
  448. {
  449. SKQD_AutoDelay = dwTickCount;
  450. SKQD_MotorDelay = dwTickCount;
  451. SKQD_XiaQieDelay = dwTickCount;
  452. SK_SingOneFlg = 0;
  453. SKQD_BinLianStep = 0;
  454. SKQD_XiaQieStep = 0;
  455. SKQD_MotorStep = 0;
  456. SKQD_DGUOLIAN_VAVLE=0;
  457. SKQD_BL_VAVLE=0;
  458. SKQD_DGZ_VAVLE =0;
  459. SKQD_YADAI_VAVLE =0;
  460. SKQD_SHANGMO_VAVLE =0;
  461. if(SKQD_SHANGMO_ROIGIN_IN)
  462. SKQD_GZ_VAVLE =0;
  463. SKQD_XIAMO_VAVLE =0;
  464. SKQD_JIAZI_VAVLE =0;
  465. SKQD_CSB_VAVLE =0;
  466. SKQD_TABLE_VAVLE = 0;
  467. if((SKQD_StopStep == 0))
  468. {
  469. AxisEgmStop(X_AXIS);
  470. SK_Motor_SZ(SKQD_MOTOR_DIS); //电机松轴
  471. }
  472. SetAlarmCode(SKQD_ALARM_ADDR,0);
  473. }
  474. bRunning = 0;
  475. SKQD_XiaQieStep = 0;
  476. SKQD_AutoStep = 0;
  477. SKQD_MotorStep = 0;
  478. }
  479. if(bAlarmStop)
  480. {
  481. bAlarmStop = 0;
  482. SKQD_XiaQieStep = 0;
  483. SKQD_AutoStep = 0;
  484. SKQD_MotorStep = 0;
  485. SKQD_XiaQieStep = 0;
  486. SKQD_MotorStep = 0;
  487. SKQD_BinLianStep = 0;
  488. SKQD_AutoDelay = dwTickCount;
  489. SKQD_MotorDelay = dwTickCount;
  490. SKQD_XiaQieDelay = dwTickCount;
  491. SKQD_KaDaiDelay = dwTickCount;
  492. SK_SingOneFlg = 0;
  493. bRunning = 0;
  494. if(X_DRV) //电机没有停止的话要减速停止
  495. SKQD_StopStep=1;
  496. // AxisEgmStop(X_AXIS);
  497. }
  498. }
  499. //记忆长度模式误差检测
  500. void SK_QueDuan_CheckLength(long zip_length)
  501. {
  502. static long start_dist;
  503. switch(SKQD_CheckLengthStep)
  504. {
  505. case 0:break;
  506. case 1:
  507. start_dist = dwXRealPos;
  508. SK_NdwSaveLength = 0;
  509. SKQD_CheckLengthStep = 2;
  510. break;
  511. case 2:
  512. if(SKQD_GUOLIAN_IN_DW){
  513. SK_NdwSaveLength = dwXRealPos - start_dist;
  514. }
  515. break;
  516. }
  517. }
  518. #if 1//!QD_KB_MODE //开口
  519. //开口切专用
  520. //30步开始后拉开始,分解4种工作模式
  521. //40步开始用切断后拉动作
  522. //60步开始为前方向,开闭口一样
  523. void SK_QueDuan_Motor(void)
  524. {
  525. static long length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff,bhgz_length_buff;
  526. static unsigned char cChangeSpeed;
  527. long pulse_buff;
  528. unsigned short ch,kk;
  529. user_datas[121] = dwXRealPos ;
  530. user_datas[122] = SKQD_AutoStep;
  531. user_datas[123] = SKQD_MotorStep;
  532. user_datas[124] = SKQD_StopStep ;
  533. user_datas[125] = SKQD_XiamuStep;//bhgz_length_buff;
  534. user_datas[126] = go_buff - dwXRealPos;
  535. switch(SKQD_MotorStep)
  536. {
  537. case 30:
  538. cChangeSpeed = 0;
  539. switch(SKQD_PARAM_BACK_MODE) //三种模式
  540. {
  541. case 0: //单数控模式
  542. SKQD_MotorStep = 310; //每种模式留20步
  543. break;
  544. case 1://单感应模式
  545. SKQD_MotorStep = 330; //每种模式留20步
  546. break;
  547. case 2: //先感应后数控模式+检测
  548. SKQD_MotorStep = 350; //每种模式留20步
  549. break;
  550. }
  551. back_buff = 0;
  552. gou_zhen_buff = 0;
  553. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_DELAY_BACK;
  554. break;
  555. //310步到315步为数控模式
  556. case 310:
  557. SKQD_MotorStep = 311;
  558. if(SKQD_PARAM_BL_ENABLE)
  559. SKQD_BinLianStep = 1; //并链起动
  560. SKQD_DGUOLIAN_VAVLE=1; //顶过链杆
  561. break;
  562. case 311:
  563. if(dwTickCount >= SKQD_MotorDelay)
  564. {
  565. SK_length_buffer = &SKQD_PARAM_OFFSET_LENGTH;
  566. SK_DCC_TIME_BL=SKQD_PARAM_DCC + SKQD_PARAM_GO_HIGH_SPEED/500;
  567. AxisMovePosAccDecNotStop(X_AXIS,SKQD_PARAM_BACK_SPEED,SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer), SKQD_PARAM_START_SPEED,SKQD_PARAM_BACK_LOW_SPEED,
  568. SKQD_PARAM_ACC,SK_DCC_TIME_BL,(SKQD_PARAM_BACK_LOW_SPEED_LENGTH));
  569. SKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  570. SKQD_MotorStep = 312;
  571. }
  572. break;
  573. case 312:
  574. if(SKQD_GUOLIAN_IN_DW)
  575. {
  576. bhgz_length_buff = dwXRealPos;
  577. }
  578. //顶过链提前输出
  579. if (!SKQD_DGUOLIAN_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH + 350) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  580. {
  581. SKQD_DGUOLIAN_VAVLE=0;
  582. }
  583. //下模提前输出
  584. if (!SKQD_DGUOLIAN_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH + 100) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  585. {
  586. SKQD_DGUOLIAN_VAVLE=0;
  587. }
  588. //勾针提前输出
  589. if (!SKQD_GZ_VAVLE && ((dwXRealPos + SKQD_PARAM_XIAMO_LENTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  590. {
  591. SKQD_XIAMO_VAVLE=1;
  592. SKQD_DGUOLIAN_VAVLE=0;
  593. }
  594. if (!SKQD_GZ_VAVLE && ((dwXRealPos +SKQD_PARAM_GOUZHEN_LENGTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  595. {
  596. SKQD_GZ_VAVLE = 1;
  597. }
  598. if((dwXRealPos) >= (SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) - SKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
  599. {
  600. SKQD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
  601. SKQD_MotorStep = 313;
  602. }//下面条件为无效代码
  603. else if((dwXRealPos >= (SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) + SKQD_PARAM_ERROR_LENGTH)) && SKQD_PARAM_ERROR_LENGTH)
  604. {
  605. SK_QD_SetAlarmCode(SKQD_GZ_ALARM);
  606. }
  607. break;
  608. case 313:
  609. if(SKQD_GUOLIAN_IN_DW)
  610. {
  611. bhgz_length_buff = dwXRealPos;
  612. }
  613. //顶过链提前关
  614. if (!SKQD_DGUOLIAN_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH + 350) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  615. {
  616. SKQD_DGUOLIAN_VAVLE=0; //顶
  617. }
  618. //下模提前输出
  619. if (!SKQD_GZ_VAVLE && ((dwXRealPos + SKQD_PARAM_XIAMO_LENTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  620. {
  621. SKQD_XIAMO_VAVLE=1;
  622. SKQD_DGUOLIAN_VAVLE=0;
  623. }
  624. //勾针提前输出
  625. if (!SKQD_GZ_VAVLE && ((dwXRealPos + SKQD_PARAM_GOUZHEN_LENGTH) >= (SKQD_PARAM_ZIPPER_LENGTH )))
  626. {
  627. SKQD_GZ_VAVLE = 1;
  628. SKQD_XIAMO_VAVLE=1;
  629. SKQD_MotorStep = 501;
  630. }
  631. if(SKQD_GZ_VAVLE)
  632. {
  633. SKQD_MotorStep = 501;
  634. }
  635. break;
  636. case 501:
  637. if(SKQD_GOUZHEN_IN) //勾针到位信号
  638. {
  639. // AxisEgmStop(X_AXIS);
  640. SKQD_YADAI_VAVLE = 1;
  641. SKQD_DGZ_VAVLE = 1;
  642. SKQD_BL_VAVLE = 0;
  643. if((((dwXRealPos-bhgz_length_buff)< (SKQD_PARAM_KWGZBJ_LENTH + SKQD_PARAM_KWGZBJ_ERROR_LENTH)) && ((dwXRealPos-bhgz_length_buff) > (SKQD_PARAM_KWGZBJ_LENTH - SKQD_PARAM_KWGZBJ_ERROR_LENTH))) | !SKQD_PARAM_KWGZBJ_LENTH)
  644. {
  645. if(SKQD_YAGOUZHEN_IN)
  646. {
  647. SKQD_MotorStep = 502;
  648. bhgz_length_buff = dwXRealPos + 30;
  649. }
  650. else if(!SKQD_YAGOUZHEN_IN && !X_DRV)
  651. {
  652. AxisEgmStop(X_AXIS);
  653. SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM);
  654. }
  655. }
  656. else
  657. {
  658. AxisEgmStop(X_AXIS);
  659. SK_QD_SetAlarmCode(SKQD_PARAM_KWGZ_ALARM);
  660. }
  661. }
  662. else if((dwXRealPos >= (SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) + SKQD_PARAM_ERROR_LENGTH)) && SKQD_PARAM_ERROR_LENGTH)
  663. {
  664. AxisEgmStop(X_AXIS);
  665. if(dwTickCount >= SKQD_MotorDelay)
  666. SK_QD_SetAlarmCode(SKQD_GZ_ALARM);
  667. }
  668. break;
  669. case 502:
  670. if(dwXRealPos >= bhgz_length_buff) //??
  671. {
  672. AxisEgmStop(X_AXIS);
  673. SKQD_YADAI_VAVLE=1;
  674. SKQD_MotorStep = 314;
  675. }
  676. break;
  677. case 314:
  678. if(!X_DRV)
  679. {
  680. SKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
  681. user_datas[127] = dwXRealPos;
  682. SKQD_BL_VAVLE=0;
  683. SKQD_MotorStep = 315;
  684. }
  685. break;
  686. case 315:
  687. if(SK_cZipCnt < 2) //第一条把误差到正负9MM
  688. {
  689. ch = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)-200;
  690. kk = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)+200;
  691. }
  692. else
  693. {
  694. if(SKQD_PARAM_BACK_MODE == 2)
  695. {
  696. ch = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) - 30 - SKQD_PARAM_ERROR_LENGTH;
  697. kk = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer) - 30 + SKQD_PARAM_ERROR_LENGTH;
  698. }
  699. else
  700. {
  701. ch = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)-SKQD_PARAM_ERROR_LENGTH;
  702. kk = SKQD_PARAM_ZIPPER_LENGTH + (*SK_length_buffer)+SKQD_PARAM_ERROR_LENGTH;
  703. }
  704. }
  705. if(((dwXRealPos) < (ch)))
  706. {
  707. SetAlarmCode(SKQD_ALARM_ADDR,SKQD_LENGTH_SHORT_ALARM);
  708. if(dwTickCount >= SKQD_MotorDelay)
  709. bAlarmStop = 1;
  710. }
  711. else if((dwXRealPos > kk))//(QD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
  712. {
  713. SetAlarmCode(SKQD_ALARM_ADDR,SKQD_LENGTH_LONG_ALARM);
  714. if(dwTickCount >= SKQD_MotorDelay)
  715. bAlarmStop = 1;
  716. }
  717. else
  718. {
  719. SKQD_MotorStep = 0;//390; //延时反转步
  720. }
  721. break;
  722. //330步到349步单感应模式
  723. case 330:
  724. SKQD_MotorStep = 331;
  725. break;
  726. case 331:
  727. if(dwTickCount >= SKQD_MotorDelay)
  728. {
  729. SKQD_MotorStep = 332;
  730. if(SKQD_PARAM_BL_ENABLE)
  731. SKQD_BinLianStep = 10; //并链起动
  732. //因为每条都是过链感应,所以直接运行检测模式后拉速度
  733. // X轴 运行速度 启动速度 加速度 减速度
  734. AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_CHECK_BACK_HSPEED,SKQD_DIR_P,2000,2000,SKQD_PARAM_ACC,SKQD_PARAM_DCC);
  735. }
  736. break;
  737. case 332:
  738. if(SKQD_GUOLIAN_IN_UP) //重新到链上
  739. {
  740. AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS)/2);
  741. if(GetCurSpeed(X_AXIS) > (SKQD_PARAM_BACK_LOW_SPEED))
  742. AxisContinueMoveChangeSpeed(X_AXIS,GetCurSpeed(X_AXIS),SKQD_PARAM_BACK_LOW_SPEED,25,15);
  743. gou_zhen_buff = dwXRealPos;
  744. back_buff = dwXRealPos;
  745. SKQD_MotorStep = 333; //到检测定位
  746. user_datas[127] = dwXRealPos;
  747. SKQD_MotorDelay = dwTickCount + 3;
  748. }
  749. if(SKQD_GUOLIAN_IN_DW)
  750. {
  751. bhgz_length_buff = dwXRealPos;
  752. }
  753. break;
  754. case 333:
  755. if(SKQD_GUOLIAN_IN_DW)
  756. {
  757. bhgz_length_buff = dwXRealPos;
  758. }
  759. if(dwTickCount > SKQD_MotorDelay)
  760. {
  761. if(!SKQD_GUOLIAN_IN)
  762. {
  763. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_GOUZHEN_DELAY;
  764. SKQD_XMDelay = dwTickCount + SKQD_PARAM_XIAMO_DELAY;
  765. AxisContinueMoveChangeSpeed(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED,SKQD_PARAM_BACK_LOW_SPEED/2,25,15);
  766. back_buff = dwXRealPos;
  767. SKQD_MotorStep = 334;
  768. }
  769. }
  770. else
  771. { //滤波时间内信号灭掉就重新检测
  772. if(!SKQD_GUOLIAN_IN)
  773. {
  774. SKQD_MotorStep = 332;
  775. }
  776. }
  777. break;
  778. case 334:
  779. if(SKQD_GUOLIAN_IN_DW)
  780. {
  781. bhgz_length_buff = dwXRealPos;
  782. }
  783. if(dwTickCount >= SKQD_XMDelay)
  784. {
  785. SKQD_XIAMO_VAVLE=1;
  786. }
  787. if(dwTickCount >= SKQD_MotorDelay)
  788. {
  789. SKQD_XIAMO_VAVLE=1;
  790. SKQD_GZ_VAVLE=1;
  791. SKQD_MotorDelay = dwTickCount + 350;
  792. SKQD_MotorStep = 335;
  793. }
  794. break;
  795. case 335:
  796. //在空们都把延时清零
  797. if(SKQD_GUOLIAN_IN)
  798. {
  799. gou_zhen_buff = dwXRealPos;
  800. }
  801. if(dwXRealPos > (back_buff + SKQD_PARAM_LLGC_LENTH))
  802. {
  803. SK_QD_SetAlarmCode(SKQD_GUOCHANG_ALARM);
  804. }
  805. if(SKQD_GOUZHEN_IN)
  806. {
  807. SKQD_YADAI_VAVLE=1;
  808. SKQD_DGZ_VAVLE=1;
  809. SKQD_BL_VAVLE=0;
  810. if((((dwXRealPos-bhgz_length_buff)< (SKQD_PARAM_KWGZBJ_LENTH + SKQD_PARAM_KWGZBJ_ERROR_LENTH)) && ((dwXRealPos-bhgz_length_buff) > (SKQD_PARAM_KWGZBJ_LENTH - SKQD_PARAM_KWGZBJ_ERROR_LENTH))) | !SKQD_PARAM_KWGZBJ_LENTH)
  811. {
  812. if(SKQD_YAGOUZHEN_IN)
  813. {
  814. SKQD_MotorStep = 336;
  815. bhgz_length_buff = dwXRealPos + 30;
  816. }
  817. else if(dwTickCount >= SKQD_MotorDelay)
  818. {
  819. AxisEgmStop(X_AXIS);
  820. SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM);
  821. }
  822. }
  823. else
  824. {
  825. AxisEgmStop(X_AXIS);
  826. SK_QD_SetAlarmCode(SKQD_PARAM_KWGZ_ALARM);
  827. }
  828. }
  829. break;
  830. case 336:
  831. if(dwXRealPos >= bhgz_length_buff)
  832. AxisEgmStop(X_AXIS);
  833. if(!X_DRV)
  834. {
  835. SKQD_BL_VAVLE=0;
  836. SKQD_MotorStep = 337;
  837. }
  838. break;
  839. case 337:
  840. if(SK_cZipCnt == 1)
  841. {
  842. length_buff = dwXRealPos;
  843. SetData32bits(SKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff-30); //测量记录长度
  844. }
  845. else if(SK_cZipCnt > 1) //长度检测
  846. {
  847. if(SKQD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
  848. {
  849. if(dwXRealPos >= length_buff) //拉链变长,对比警告
  850. {
  851. if((dwXRealPos) > (length_buff+SKQD_PARAM_ERROR_LENGTH))
  852. SK_QD_SetAlarmCode(SKQD_LENGTH_LONG_ALARM);
  853. }
  854. else //拉链变短
  855. {
  856. if((dwXRealPos + SKQD_PARAM_ERROR_LENGTH) < (length_buff))
  857. SK_QD_SetAlarmCode(SKQD_LENGTH_SHORT_ALARM);
  858. }
  859. }
  860. }
  861. SKQD_MotorStep = 338;
  862. break;
  863. case 338:
  864. SKQD_MotorStep = 0;//390; //延时反转步
  865. break;
  866. //350步到369步先感应后数控模式
  867. case 350:
  868. back_buff = dwXRealPos;
  869. gou_zhen_buff = dwXRealPos;
  870. SKQD_MotorStep = 351;
  871. break;
  872. case 351:
  873. if(dwTickCount >= SKQD_MotorDelay)
  874. {
  875. SKQD_MotorStep = 352;
  876. //第一,二条都是过链感应,测量长度
  877. if(SK_cZipCnt < 2)
  878. {
  879. if(SKQD_PARAM_BL_ENABLE)
  880. SKQD_BinLianStep = 10; //并链起动
  881. // X轴 运行速度 启动速度 加速度 减速度
  882. AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_CHECK_BACK_HSPEED /2,SKQD_DIR_P,SKQD_PARAM_START_SPEED,2000,SKQD_PARAM_ACC,SKQD_PARAM_DCC);
  883. }
  884. else
  885. {
  886. if(SKQD_PARAM_BL_ENABLE)
  887. SKQD_BinLianStep = 1; //并链起动
  888. SKQD_CheckLengthStep = 1; //长度检测,第3条才有对比
  889. //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
  890. SKQD_MotorStep = 310;
  891. }
  892. }
  893. break;
  894. case 352:
  895. //前两条都按最低速度工作
  896. if(SKQD_GUOLIAN_IN_UP) //重新到链上
  897. {
  898. AxisContinueMoveChangeSpeed(X_AXIS,SKQD_PARAM_CHECK_BACK_HSPEED/2,SKQD_PARAM_CHECK_BACK_HSPEED/4,25,15);
  899. gou_zhen_buff = dwXRealPos;
  900. back_buff = dwXRealPos;
  901. SKQD_MotorStep = 353; //到检测定位
  902. SKQD_MotorDelay = dwTickCount + 8;
  903. }
  904. if(SKQD_GUOLIAN_IN_DW)
  905. {
  906. bhgz_length_buff = dwXRealPos;
  907. }
  908. break;
  909. case 353:
  910. if(SKQD_GUOLIAN_IN_DW)
  911. {
  912. bhgz_length_buff = dwXRealPos;
  913. }
  914. //此步为前两条运行
  915. if(dwTickCount > SKQD_MotorDelay)
  916. {
  917. if(SKQD_GUOLIAN_IN_DW)
  918. {
  919. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_GOUZHEN_DELAY;
  920. AxisContinueMoveChangeSpeed(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED,SKQD_PARAM_BACK_LOW_SPEED/2,25,15);
  921. back_buff = dwXRealPos;
  922. SKQD_MotorStep = 354;
  923. }
  924. }
  925. else
  926. {
  927. if(!SKQD_GUOLIAN_IN)
  928. {
  929. SKQD_MotorStep = 352;
  930. }
  931. }
  932. break;
  933. case 354:
  934. if(SKQD_GUOLIAN_IN_DW)
  935. {
  936. bhgz_length_buff = dwXRealPos;
  937. }
  938. if(dwTickCount >= SKQD_XMDelay)
  939. {
  940. SKQD_XIAMO_VAVLE=1;
  941. // SKQD_MotorDelay = dwTickCount + 50;
  942. }
  943. if(dwTickCount >= SKQD_MotorDelay)
  944. {
  945. SKQD_XIAMO_VAVLE=1;
  946. SKQD_GZ_VAVLE=1;
  947. SKQD_MotorDelay = dwTickCount + 350;
  948. SKQD_MotorStep = 355;
  949. }
  950. break;
  951. case 355:
  952. if(dwXRealPos > back_buff + SKQD_PARAM_LLGC_LENTH )
  953. {
  954. SK_QD_SetAlarmCode(SKQD_GUOCHANG_ALARM);
  955. }
  956. //在空们都把延时清零
  957. if(SKQD_GOUZHEN_IN)
  958. {
  959. SKQD_BL_VAVLE=0;
  960. if((((dwXRealPos-bhgz_length_buff)< (SKQD_PARAM_KWGZBJ_LENTH + SKQD_PARAM_KWGZBJ_ERROR_LENTH)) && ((dwXRealPos-bhgz_length_buff) > (SKQD_PARAM_KWGZBJ_LENTH - SKQD_PARAM_KWGZBJ_ERROR_LENTH))) | !SKQD_PARAM_KWGZBJ_LENTH)
  961. {
  962. if(SKQD_YAGOUZHEN_IN)
  963. {
  964. SKQD_MotorStep = 356;
  965. bhgz_length_buff = dwXRealPos + 30;
  966. }
  967. else if(dwTickCount >= SKQD_MotorDelay)
  968. {
  969. AxisEgmStop(X_AXIS);
  970. SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM);
  971. }
  972. }
  973. else
  974. {
  975. AxisEgmStop(X_AXIS);
  976. SK_QD_SetAlarmCode(SKQD_PARAM_KWGZ_ALARM);
  977. }
  978. }
  979. break;
  980. case 356:
  981. if(dwXRealPos >= bhgz_length_buff)
  982. {
  983. AxisEgmStop(X_AXIS);
  984. }
  985. if(!X_DRV)
  986. {
  987. SKQD_YADAI_VAVLE=1;
  988. SKQD_DGZ_VAVLE=1;
  989. SKQD_BL_VAVLE=0;
  990. if(SK_cZipCnt == 1)
  991. {
  992. length_buff = dwXRealPos ;
  993. SetData32bits(SKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
  994. }
  995. SKQD_MotorStep = 357;
  996. }
  997. break;
  998. case 357:
  999. SKQD_MotorStep = 0;//390; //延时反转步
  1000. break;
  1001. //此两步为到位后反转步
  1002. case 390:
  1003. if(SKQD_YAGOUZHEN_IN && SKQD_GOUZHEN_IN)
  1004. {
  1005. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_YD_FZ_DELAY;
  1006. SKQD_MotorStep = 391;
  1007. }
  1008. break;
  1009. case 391:
  1010. if((dwTickCount >= SKQD_MotorDelay) || SKQD_SHANGMO_IN)
  1011. {
  1012. SKQD_DGZ_VAVLE=1;
  1013. SKQD_MotorStep = 392;
  1014. AxisMovePosAccDec(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED*2,-SKQD_PARAM_FZ_LENGTH,2000,1500,SKQD_PARAM_ACC,SKQD_PARAM_DCC,00);
  1015. }
  1016. break;
  1017. case 392:
  1018. if(!X_DRV)//dwTickCount >= SKQD_MotorDelay)
  1019. {
  1020. SKQD_MotorStep = 0;
  1021. }
  1022. break;
  1023. case 393:
  1024. if(dwTickCount >= SKQD_MotorDelay)
  1025. {
  1026. AxisMovePosAccDec(X_AXIS,SKQD_PARAM_BACK_LOW_SPEED*3/2,-SKQD_PARAM_FZ_LENGTH,1000,1000,SKQD_PARAM_ACC,SKQD_PARAM_DCC,00);
  1027. SKQD_MotorStep = 0;
  1028. }
  1029. break;
  1030. case 40:
  1031. if(SKQD_PARAM_SJZ_LENGTH == 0)
  1032. {
  1033. SKQD_JIAZI_VAVLE = 0;
  1034. }
  1035. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_CUT_BACK_DELAY;
  1036. SetDir(X_AXIS, SKQD_DIR_N);
  1037. SKQD_MotorStep = 41;
  1038. jz_buff = dwXRealPos;
  1039. break;
  1040. case 41:
  1041. if(dwTickCount >= SKQD_MotorDelay)
  1042. {
  1043. //夹子已经张开
  1044. AxisMovePosAccDec(X_AXIS,SKQD_PARAM_CUT_BACK_SPEED,(SKQD_PARAM_SJZ_LENGTH+SKQD_PARAM_BACK_LENGTH),SKQD_PARAM_START_SPEED,SKQD_PARAM_START_SPEED,10,10,0);
  1045. // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
  1046. SKQD_MotorStep = 42;
  1047. }
  1048. break;
  1049. case 42:
  1050. if(((SKQD_PARAM_SJZ_LENGTH) <= (dwXRealPos - jz_buff)))
  1051. {
  1052. SKQD_JIAZI_VAVLE = 0;
  1053. }
  1054. if(!X_DRV)
  1055. {
  1056. SKQD_JIAZI_VAVLE = 0;
  1057. SKQD_MotorStep = 43;
  1058. }
  1059. break;
  1060. case 43: // 切断完成后拉电机动作
  1061. if(!X_DRV)
  1062. {
  1063. SKQD_MotorStep = 0;
  1064. SKQD_MotorDelay = dwTickCount;
  1065. }
  1066. break;
  1067. case 61: // 前点定位数控模式
  1068. SKQD_BL_VAVLE = 0;
  1069. if(dwTickCount >= SKQD_MotorDelay)
  1070. {
  1071. SKQD_MotorStep = 62;
  1072. }
  1073. break;
  1074. case 62:
  1075. if(dwTickCount >= SKQD_MotorDelay)
  1076. {
  1077. if(SKQD_QIAN_LIMIT_IN)
  1078. {
  1079. //前点亮的情况下先后退离开信号后再前进定位 ,10公分
  1080. AxisMovePosAccDec(X_AXIS,3000,1000,2000,2000,10,10,30);
  1081. SKQD_MotorDelay = dwTickCount + 300;
  1082. }
  1083. SKQD_MotorStep = 63;
  1084. SKQD_JIAZI_VAVLE = 0;
  1085. }
  1086. break;
  1087. case 63:
  1088. if(!X_DRV && !SKQD_QIAN_LIMIT_IN && (dwTickCount >= SKQD_MotorDelay) &&
  1089. ((dwXRealPos > 4000) || (!SKQD_SHANGMO_IN && !SKQD_XIAMO_IN && !SKQD_YAGOUZHEN_IN)))// && !QD_SHANG_MU_LIMIT_IN)
  1090. {
  1091. go_buff = dwXRealPos;
  1092. SKQD_YADAI_VAVLE = 1;
  1093. SKQD_DGZ_VAVLE = 0;
  1094. if(SK_cZipCnt > 0)
  1095. {
  1096. if(dwXRealPos>(SKQD_PARAM_GO_LOW_SPEED_LENGTH))
  1097. { //
  1098. axis_set_parameter( X_AXIS,AXIS_ACCDEC_MODE,1);
  1099. SK_DCC_TIME_BL = SKQD_PARAM_DCC + SKQD_PARAM_GO_HIGH_SPEED/500;
  1100. AxisMovePosAccDecNotStop(X_AXIS,SKQD_PARAM_GO_HIGH_SPEED,-dwXRealPos,
  1101. SKQD_PARAM_START_SPEED,SKQD_PARAM_GO_LOW_SPEED,SKQD_PARAM_ACC,SK_DCC_TIME_BL,
  1102. SKQD_PARAM_GO_LOW_SPEED_LENGTH);
  1103. }
  1104. else
  1105. {
  1106. // X轴 运行速度 启动速度 加速度 减速度
  1107. AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_N,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,15,15);
  1108. }
  1109. }
  1110. else
  1111. {
  1112. // X轴 运行速度 启动速度 加速度 减速度
  1113. AxisContinueMoveAcc(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,SKQD_DIR_N,SKQD_PARAM_GO_LOW_SPEED/3,SKQD_PARAM_GO_LOW_SPEED,15,15);
  1114. // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
  1115. }
  1116. SKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
  1117. SKQD_MotorStep =64;
  1118. }
  1119. break;
  1120. case 64:
  1121. if(SK_cZipCnt > 0)
  1122. {
  1123. if(SKQD_QIAN_LIMIT_IN) //前点限位
  1124. {
  1125. if(SKQD_PARAM_GO_DW_LENGTH)
  1126. {
  1127. SetPos(X_AXIS, SKQD_PARAM_GO_DW_LENGTH);
  1128. AxisMovePosAccDec(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,-SKQD_PARAM_GO_DW_LENGTH,1200,1000,5,5,00);
  1129. }
  1130. else
  1131. AxisEgmStop(X_AXIS);
  1132. SKQD_MotorStep = 66;
  1133. }
  1134. }
  1135. else
  1136. {
  1137. if(SKQD_QIAN_LIMIT_IN) //前点限位
  1138. {
  1139. if(SKQD_PARAM_GO_DW_LENGTH)
  1140. {
  1141. SetPos(X_AXIS, SKQD_PARAM_GO_DW_LENGTH);
  1142. AxisMovePosAccDec(X_AXIS,SKQD_PARAM_GO_LOW_SPEED,-SKQD_PARAM_GO_DW_LENGTH,1200,1000,5,5,00);
  1143. }
  1144. else
  1145. AxisEgmStop(X_AXIS);
  1146. SKQD_MotorStep = 66;
  1147. }
  1148. }
  1149. // if(dwTickCount >= SKQD_MotorDelay)
  1150. // SK_QD_SetAlarmCode(SKQD_NO_ZIPPER_ALARM);
  1151. break;
  1152. case 66:
  1153. if(!X_DRV || (dwXRealPos <= 0))
  1154. {
  1155. axis_set_parameter( X_AXIS,AXIS_ACCDEC_MODE,0);
  1156. SetPos(X_AXIS, 0);
  1157. SKQD_MotorDelay = dwTickCount;
  1158. SKQD_MotorStep = 67;
  1159. }
  1160. break;
  1161. case 67:
  1162. if(dwTickCount >= SKQD_MotorDelay)
  1163. {
  1164. if(bRunning)
  1165. {
  1166. SKQD_JIAZI_VAVLE = 1;
  1167. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_DELAY_BACK*3/5;
  1168. }
  1169. SKQD_MotorStep = 68;
  1170. }
  1171. break;
  1172. case 68:
  1173. if(dwTickCount >= SKQD_MotorDelay)
  1174. {
  1175. SKQD_YADAI_VAVLE = 0;
  1176. SKQD_MotorStep = 69;
  1177. SKQD_MotorDelay = dwTickCount + SKQD_PARAM_DELAY_BACK*2/5;
  1178. }
  1179. break;
  1180. case 69:
  1181. if(dwTickCount >= SKQD_MotorDelay)
  1182. {
  1183. SKQD_MotorStep = 0;
  1184. SKQD_MotorDelay = dwTickCount;
  1185. }
  1186. break;
  1187. }
  1188. }
  1189. #endif
  1190. //超声方式下切,开口专用
  1191. void SK_QueDuan_XiaQue(void)
  1192. {
  1193. switch(SKQD_XiaQieStep)
  1194. {
  1195. case 0:
  1196. break;
  1197. case 1:
  1198. if(bRunning)
  1199. {
  1200. SKQD_XiaQieStep = 5;
  1201. SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1202. if(SKQD_SAFE_IN)
  1203. {
  1204. bStop = 1;
  1205. SKQD_XIAMO_VAVLE = 0;
  1206. }
  1207. }
  1208. else
  1209. SKQD_XiaQieStep = 2;
  1210. break;
  1211. case 2:
  1212. SKQD_XIAMO_VAVLE=1;
  1213. SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1214. SKQD_XiaQieStep = 3;
  1215. break;
  1216. case 3:
  1217. if(SKQD_XIAMO_IN)
  1218. {
  1219. SKQD_XiaQieDelay = dwTickCount + 0;
  1220. SKQD_XiaQieStep = 4;
  1221. }
  1222. else if(dwTickCount >= SKQD_XiaQieDelay)
  1223. {
  1224. SK_QD_SetAlarmCode(SKQD_XM_DAOWEI);
  1225. }
  1226. break;
  1227. case 4:
  1228. SKQD_XiaQieDelay = dwTickCount + 3000;
  1229. SKQD_GZ_VAVLE = 1;
  1230. SK_cTuiFangKuaiCnt=0;
  1231. SKQD_XiaQieStep = 5;
  1232. break;
  1233. case 5:
  1234. if(SKQD_GOUZHEN_IN || bRunning)
  1235. {
  1236. SKQD_DGZ_VAVLE=1;
  1237. SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1238. SKQD_XiaQieStep = 6;
  1239. }
  1240. else if(dwTickCount >= SKQD_XiaQieDelay)
  1241. {
  1242. SK_QD_SetAlarmCode(SKQD_GZ_ALARM);
  1243. }
  1244. break;
  1245. case 6:
  1246. if(SKQD_YAGOUZHEN_IN)
  1247. {
  1248. SKQD_XiaQieStep = 7;
  1249. SKQD_XiaQieDelay = dwTickCount + 1000;
  1250. }
  1251. else if(dwTickCount >= SKQD_XiaQieDelay)
  1252. {
  1253. SK_QD_SetAlarmCode(SKQD_YAGOUZHEN_ALARM); //压勾针到位
  1254. }
  1255. break;
  1256. case 7:
  1257. if(SKQD_GOUZHEN_IN || bRunning)
  1258. {
  1259. if(!bRunning)
  1260. SKQD_XiaQieDelay = dwTickCount + 200;
  1261. else
  1262. {
  1263. SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_CUT_DELAY;
  1264. }
  1265. if(!SKQD_QIAN_LIMIT_IN)
  1266. SKQD_XiaQieStep = 8;
  1267. else
  1268. SK_QD_SetAlarmCode(SKQD_QIAN_LIMIT_ALARM);
  1269. }
  1270. break;
  1271. case 8://上下模同时输出
  1272. if(dwTickCount >= SKQD_XiaQieDelay)
  1273. {
  1274. SKQD_YADAI_VAVLE = 1;//压带
  1275. SKQD_DGZ_VAVLE = 1;
  1276. SKQD_SHANGMO_VAVLE = 1;
  1277. SKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
  1278. SKQD_XiaQieStep = 9;
  1279. if(bRunning)
  1280. SKQD_MotorStep = 390;
  1281. }
  1282. break;
  1283. case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
  1284. if(SKQD_SHANGMO_IN && SKQD_XIAMO_IN )
  1285. {
  1286. SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_DELAY_CS; //
  1287. SKQD_XiaQieStep = 10;
  1288. }
  1289. else if(dwTickCount >= SKQD_XiaQieDelay)
  1290. {
  1291. if(!SKQD_SHANGMO_IN) SK_QD_SetAlarmCode(SKQD_SM_DAOWEI);
  1292. else SK_QD_SetAlarmCode(SKQD_XM_DAOWEI);
  1293. }
  1294. break;
  1295. case 10:
  1296. if(dwTickCount >= SKQD_XiaQieDelay)
  1297. {
  1298. SKQD_CSB_VAVLE = 1;
  1299. //
  1300. SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_CS_TIME; //
  1301. SKQD_XiaQieStep = 11;
  1302. }
  1303. break;
  1304. case 11:
  1305. if(dwTickCount >= SKQD_XiaQieDelay)
  1306. {
  1307. SKQD_CSB_VAVLE = 0;
  1308. SKQD_XiaQieDelay = dwTickCount + SKQD_PARAM_CS_COLD_TIME; //
  1309. SKQD_XiaQieStep = 12;
  1310. SKQD_DGZ_VAVLE = 0;
  1311. }
  1312. break;
  1313. case 12:
  1314. if(dwTickCount >= SKQD_XiaQieDelay)
  1315. {
  1316. SKQD_SHANGMO_VAVLE = 0;
  1317. SKQD_XIAMO_VAVLE = 0;
  1318. SKQD_ErrorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1319. SKQD_XiaQieStep = 13;
  1320. }//
  1321. break;
  1322. case 13:
  1323. if((!SKQD_SHANGMO_IN))
  1324. {
  1325. SKQD_GZ_VAVLE = 0;
  1326. SKQD_XiaQieDelay = dwTickCount + 7;//SKQD_PARAM_TDGZ_DELAY ;
  1327. SKQD_XiaQieStep = 14;
  1328. SKQD_ErrorDelay = dwTickCount + VAVLE_ALARM_TIME;
  1329. }
  1330. else if((dwTickCount >= SKQD_ErrorDelay) && !SKQD_SHANGMO_VAVLE)
  1331. {
  1332. SK_QD_SetAlarmCode(SKQD_SM_YUANWEI);
  1333. }
  1334. break;
  1335. case 14:
  1336. if(dwTickCount >= SKQD_XiaQieDelay)
  1337. {
  1338. if(SKQD_SHANGMO_ROIGIN_IN && !SKQD_XIAMO_IN && !SKQD_YAGOUZHEN_IN)
  1339. {
  1340. SKQD_DGZ_VAVLE = 0;
  1341. SKQD_XiaQieStep = 0;
  1342. }
  1343. else if(dwTickCount >= SKQD_ErrorDelay)
  1344. {
  1345. SK_QD_SetAlarmCode(SKQD_XYAGOUZHEN_ALARM);
  1346. }
  1347. }
  1348. break;
  1349. }
  1350. }
  1351. #endif