YXMXC_NiLong_StepJi.c 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161
  1. #include "global.h"
  2. #if FJ_YING_XING_MACHINE == 1
  3. void MXC_NiLongXiuCiJiCheckStart(void);
  4. void MXC_ShaChe_Output(void);
  5. void MXC_NiLongXiuCiJi_Motor(void);//电机
  6. void MXC_NiLongXiuCiJi_XiaC(void);
  7. void MXC_Start_FenZ(void);
  8. void MXC_NiLongXiuCiJi_FenZhengProc(void);
  9. void MXC_ChuiQiProc(void);
  10. void MXC_JiaoDao(void);
  11. void MXC_ManualAction(void);
  12. void MXC_AutoAction(void);
  13. void MXC_NiLongXiuCiJi_GouZhenProc(void);
  14. void DianDanLenghtCheck(void);
  15. long MultLengthOffset(unsigned long zip_length);
  16. unsigned short DingDanCheckOk(void);
  17. unsigned char cLFengTimer, cRFengTimer, cGuZhangStop = 0;
  18. unsigned long cShaCheTime, cLaLianLine, cGouZhenTime;
  19. unsigned char cChuiQiStep = 0, cGouZhenResetOK;
  20. unsigned short cBudaiCheckDelay = 0;
  21. unsigned char bHandWork, bPulseTatol_EN, bFirst, cInt1_OK, cStopFlag, cOneTimes, cKey_Time;
  22. long cSetEncode, cTotal, cDinWeiTime, cAddSetPulseNum, cEncodePulse, cWorkPulseNum;
  23. unsigned long cZipperLength[2];
  24. unsigned char cCheckLengthOk = 0, cDaoJu_Flag = 0;
  25. unsigned char STOP_IN_FLAG, STOP_IN_FLAG_OLD, STOP_FILTER;
  26. unsigned char MXC_SingOneFlag = 0;
  27. unsigned char MXC_KD_Flag = 0, KD_GO_ON_FLAG = 0;
  28. long MXC_KD_pos = 0, save_pos_buff = 0;
  29. long zipper_length_buff;
  30. short *len_buf;
  31. short *offset_len;
  32. //故障报警
  33. void MXC_SetAlarmCode(unsigned alarm_code)
  34. {
  35. SetAlarmCode(MXC_ALARM_ADDR, alarm_code);
  36. MXC_bAlarmStop = 1;
  37. }
  38. //高速输入X31/X17外部色标信号中断
  39. void MXC_ExtiActionX31(void)
  40. {
  41. if (cSeBiaoEn && !cSeBiaoOk)
  42. {
  43. cSeBiaoOk = 1;
  44. cSeBiaoEn = 0;
  45. if (X_DRV)
  46. //SetRemainLength(X_AXIS, MXC_PARAM_SEBIAO_DW_LENGTH,MXC_PARAM_SB_OFFSET_SPEED);
  47. AxisMovePosAccDec(X_AXIS, MXC_PARAM_SB_OFFSET_SPEED, MXC_PARAM_SEBIAO_DW_LENGTH,
  48. MXC_PARAM_START_SPEED, MXC_PARAM_START_SPEED,
  49. 10, 10, 80);
  50. }
  51. // DISPLAY_DATA2++;
  52. }
  53. //检测订单数据内是否还有可以加工的数据,返回订单序号
  54. unsigned short DingDanCheckOk(void)
  55. {
  56. unsigned short ch, i;
  57. for (ch = 0; ch < (MXC_DingDanNum); ch++)
  58. {
  59. i = MXC_DingDan_NowNum;//当前订单号
  60. // 订单完成数量 //订单量 // 拉链长度
  61. if ((GetData32bits(MXC_DingDanAddr + i * 6 + 2) < GetData32bits(MXC_DingDanAddr + i * 6 + 4)) && (GetData32bits(MXC_DingDanAddr + i * 6) != 0))
  62. {
  63. //设置拉链长度
  64. SetData32bits(15, GetData32bits(MXC_DingDanAddr + i * 6));
  65. //累计条数
  66. SetData32bits(76, GetData32bits(MXC_DingDanAddr + i * 6 + 2)); //当前一般为0
  67. //设置加工条数
  68. SetData32bits(22, GetData32bits(MXC_DingDanAddr + i * 6 + 4));
  69. MXC_SET_REVISE_ZIPPER_LENGTH = user_datas[i + MXC_DingDanOffsetAddr];
  70. return ch;//进入设置则退出该函数
  71. }
  72. MXC_DingDan_NowNum++;
  73. if (MXC_DingDan_NowNum >= MXC_DingDanNum)
  74. MXC_DingDan_NowNum = 0;
  75. }
  76. return ch; //如ch = MXC_DingDanNum)无订单加工
  77. }
  78. //num订单序号设置订单数据植物入生产表
  79. void SetDingDanData(void)
  80. {
  81. unsigned short ch, i;
  82. i = MXC_DingDan_NowNum; //当前
  83. for (ch = 0; ch < MXC_DingDanNum; ch++)
  84. {
  85. // 订单完成数量 //订单量
  86. if ((GetData32bits(MXC_DingDanAddr + i * 6 + 2) >= GetData32bits(MXC_DingDanAddr + i * 6 + 4)) || (GetData32bits(MXC_DingDanAddr + i * 6) == 0))
  87. { //勾针并且长度小于勾针最小长度
  88. if ((MXC_DC_MODE != 0) || (MXC_ScanMa_LENGTH >= MXC_GouzhenMin_Length)) //伺服或色标可以直接输入
  89. {
  90. //设置拉链长度
  91. SetData32bits((MXC_DingDanAddr + i * 6), MXC_ScanMa_LENGTH);
  92. //设置累计条数
  93. SetData32bits(MXC_DingDanAddr + i * 6 + 2, 0);
  94. //设置加工条数
  95. SetData32bits(MXC_DingDanAddr + i * 6 + 4, MXC_ScanMa_Production);
  96. }
  97. break;
  98. }
  99. else
  100. {
  101. i++;
  102. if (i >= MXC_DingDanNum)
  103. i = 0;
  104. }
  105. }
  106. }
  107. long MultLengthOffset(unsigned long zip_length)
  108. {
  109. if (zip_length <= user_datas[MXC_MultLengthOffsetAddr])
  110. len_buf = &user_datas[MXC_MultOffsetAddr];
  111. else if (zip_length <= user_datas[MXC_MultLengthOffsetAddr + 1])
  112. len_buf = &user_datas[MXC_MultOffsetAddr + 1];
  113. else if (zip_length <= user_datas[MXC_MultLengthOffsetAddr + 2])
  114. len_buf = &user_datas[MXC_MultOffsetAddr + 2];
  115. else if (zip_length <= user_datas[MXC_MultLengthOffsetAddr + 3])
  116. len_buf = &user_datas[MXC_MultOffsetAddr + 3];
  117. else
  118. len_buf = &user_datas[MXC_MultOffsetAddr + 4];
  119. return (*len_buf);
  120. }
  121. //订单完成条数增加
  122. void DingDanTotalAdd(void)
  123. {
  124. //把当前产量赋值到当前订单组
  125. SetData32bits(MXC_DingDanAddr + MXC_DingDan_NowNum * 6 + 2, GetData32bits(76));
  126. }
  127. void DianDanLenghtCheck(void)
  128. {
  129. unsigned int i = 0, ch = 0;
  130. //长度不能小于勾针长度
  131. ch = 0;
  132. if (MXC_DingDanSet130)
  133. {
  134. MXC_DingDanSet130 = 0;
  135. i = 0;
  136. ch = 1;
  137. }
  138. //长度不能小于勾针长度
  139. if (MXC_DingDanSet136)
  140. {
  141. MXC_DingDanSet136 = 0;
  142. i = 1;
  143. ch = 1;
  144. }
  145. //长度不能小于勾针长度
  146. if (MXC_DingDanSet142)
  147. {
  148. MXC_DingDanSet142 = 0;
  149. i = 2;
  150. ch = 1;
  151. }
  152. //长度不能小于勾针长度
  153. if (MXC_DingDanSet148)
  154. {
  155. MXC_DingDanSet148 = 0;
  156. i = 3;
  157. ch = 1;
  158. }
  159. if (MXC_DingDanSet154)
  160. {
  161. MXC_DingDanSet154 = 0;
  162. i = 4;
  163. ch = 1;
  164. }
  165. if ((MXC_DC_MODE == 0) && ch) //在勾针定寸模式下不能勾针最小尺寸
  166. {
  167. if (GetData32bits(MXC_DingDanAddr + i * 6) < MXC_GouzhenMin_Length)
  168. {
  169. SetData32bits(MXC_DingDanAddr + i * 6, MXC_GouzhenMin_Length);
  170. }
  171. }
  172. }
  173. //上电订单检测
  174. void IntitDingDan(void)
  175. {
  176. if (MXC_DingDan_NowNum >= MXC_DingDanNum)
  177. MXC_DingDan_NowNum = 0;
  178. }
  179. void MXC_ExtiActionX20(void)
  180. {
  181. }
  182. void MXC_InitAction(void)
  183. {
  184. float length_buff, pulse_buff;
  185. //CalFreqTab_X_Free(25);
  186. length_buff = MXC_PARAM_DAILUN_LENGTH;
  187. pulse_buff = 2000;
  188. XGearRatio = pulse_buff / length_buff;
  189. if (MXC_USE_GZ_SERVO)
  190. MXC_StartFirst = 1; //上电第一次要重新定位
  191. MXC_Gouzhencurrent_L = 0; //上电当前位置要清零
  192. length_buff = MXC_PARAM_GouZhenLun_LENGTH; // 勾针电机一圈周长;
  193. pulse_buff = 2000; // 勾针电机细分
  194. YGearRatio = pulse_buff / length_buff;
  195. MXC_ProSpeed = 0; //生产速度
  196. MXC_XC_SongZhou = MXC_XC_SERVER_DISEN;
  197. MXC_TuoDaiSongZhou = MXC_SERVER_DISEN;
  198. //
  199. if (MXC_PARAM_XIAZHI_EN == 0)
  200. MXC_XIA_ZHI_ENABLE = 0; //0不带下止,带下止时强关掉
  201. if (MXC_XIA_ZHI_ENABLE)
  202. MXC_XiaZhi_MOTOR = 1;
  203. else
  204. MXC_XiaZhi_MOTOR = 0;
  205. SetAlarmCode(MXC_ALARM_ADDR, 0); //警告清零
  206. //Y轴方向实际输出电平设置
  207. SetDirReverse(Y_AXIS, 1); //方向输出的实际电平取反
  208. //订单初始华
  209. //IntitDingDan();
  210. STOP_IN_FLAG = MXC_STOP_IN;
  211. STOP_IN_FLAG_OLD = STOP_IN_FLAG;
  212. }
  213. void MXC_NiLongXiuCiJiAction(void)
  214. {
  215. MXC_NiLongXiuCiJiCheckStart(); //启动
  216. MXC_NiLongXiuCiJi_FenZhengProc(); //左右分针
  217. MXC_NiLongXiuCiJi_XiaC(); //下冲
  218. MXC_ChuiQiProc();
  219. MXC_NiLongXiuCiJi_Motor(); //拖带控制
  220. MXC_JiaoDao();
  221. MXC_ManualAction();
  222. MXC_AutoAction();
  223. MXC_NiLongXiuCiJi_GouZhenProc(); //勾针数控动作
  224. //订单植入
  225. /* if(MXC_Scan_Ma)
  226. {
  227. MXC_Scan_Ma = 0;
  228. SetDingDanData();
  229. }
  230. */
  231. }
  232. void MXC_ManualAction(void)
  233. {
  234. long i;
  235. static unsigned char save_flg = 0;
  236. //清总产量
  237. if (MXC_bClear) //清总产量
  238. {
  239. MXC_bClear = 0;
  240. ClrcToTal(MXC_TOTAL_ADDR);
  241. // MXC_bSaveWorkData = 1;
  242. save_flg = 1;
  243. }
  244. if (save_flg)
  245. {
  246. if (!MXC_bSaveWorkData)
  247. {
  248. ClrcToTal(MXC_TOTAL_ADDR);
  249. if (MXC_DingDanWorkMode)
  250. {
  251. DingDanTotalAdd();
  252. }
  253. save_flg = 0;
  254. }
  255. }
  256. // //当长度改变时,生产总量自动清零
  257. // if (MXC_bChangeLength)
  258. // {
  259. // MXC_bChangeLength = 0;
  260. // MXC_bClear = 1;
  261. // }
  262. //加5
  263. if (MXC_bAddLength)
  264. {
  265. MXC_bAddLength = 0;
  266. i = MXC_SET_REVISE_ZIPPER_LENGTH;
  267. i += 5;
  268. SetData32bits(MXC_ZIPPER_LENGTH_ADDR, i);
  269. }
  270. //减5
  271. if (MXC_bDecLength)
  272. {
  273. MXC_bDecLength = 0;
  274. i = MXC_SET_REVISE_ZIPPER_LENGTH;
  275. i -= 5;
  276. SetData32bits(MXC_ZIPPER_LENGTH_ADDR, i);
  277. }
  278. //工作方式选择(数控定寸和勾针定寸) 
  279. if (MXC_bSetDCMode)
  280. {
  281. MXC_bSetDCMode = 0;
  282. if (!MXC_bRunning)
  283. {
  284. MXC_DC_MODE++;
  285. if (MXC_DC_MODE > 2)
  286. MXC_DC_MODE = 0;
  287. if (MXC_DC_MODE != 0)
  288. {
  289. MXC_GouZhen_VAVLE = 1;
  290. MXC_XIA_ZHI_ENABLE = 0;
  291. MXC_XiaZhi_MOTOR = 0;
  292. }
  293. }
  294. }
  295. //订单组拉链长度改变
  296. if((MXC_DingDanWorkMode == 1) && MXC_Length_Change_flag && (MXC_cMotorStep == 0))
  297. {
  298. MXC_Length_Change_flag = 0;
  299. DingDanCheckOk();
  300. }
  301. //勾针方式选择(活动勾针和固定勾针) 
  302. if (MXC_bChangeGouZhenMode)
  303. {
  304. MXC_bChangeGouZhenMode = 0;
  305. if (!MXC_bRunning)
  306. {
  307. // MXC_GOU_ZHEN_MODE++;
  308. // if(MXC_GOU_ZHEN_MODE > 1)MXC_GOU_ZHEN_MODE = 0;
  309. }
  310. }
  311. //下止工作选择) 
  312. if (MXC_bChangeXiaZhiMode)
  313. {
  314. MXC_bChangeXiaZhiMode = 0;
  315. if (!MXC_bRunning)
  316. {
  317. MXC_XIA_ZHI_ENABLE++;
  318. if (MXC_XIA_ZHI_ENABLE > 2)
  319. MXC_XIA_ZHI_ENABLE = 0;
  320. if (MXC_XIA_ZHI_ENABLE)
  321. MXC_XiaZhi_MOTOR = 1;
  322. else
  323. MXC_XiaZhi_MOTOR = 0;
  324. }
  325. }
  326. //顶刀保护
  327. if(MXC_bDingDao_Baohu)
  328. {
  329. MXC_bDingDao_Baohu = 0;
  330. MXC_DingDao_BaoHu_VAVLE = 1;
  331. MXC_cDDBHDelay = dwTickCount + MXC_DDBH_Time;
  332. }
  333. if (MXC_bJiaoDao)
  334. {
  335. MXC_cJiaoDaoStep = 1;
  336. MXC_bJiaoDao = 0;
  337. }
  338. if (MXC_bChuiQi)
  339. {
  340. MXC_bChuiQi = 0;
  341. if (MXC_cChuiQiStep == 0)
  342. MXC_cChuiQiStep = 1;
  343. }
  344. if ((MXC_bRunning) == 0) ////手动
  345. {
  346. if(MXC_bDJTD_P)//电机拖带
  347. {
  348. if(!X_DRV)
  349. {
  350. MXC_TuoDaiSongZhou= MXC_SERVER_EN;
  351. AxisContinueMoveAcc(X_AXIS, MXC_PARAM_LOW_SPEED, MXC_DIR_P, MXC_PARAM_START_SPEED,
  352. MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  353. }
  354. }
  355. if(MXC_bDJTD_N)//电机拖带
  356. {
  357. if(!X_DRV)
  358. {
  359. MXC_TuoDaiSongZhou= MXC_SERVER_EN;
  360. AxisContinueMoveAcc(X_AXIS, MXC_PARAM_LOW_SPEED, MXC_DIR_N, MXC_PARAM_START_SPEED,
  361. MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  362. }
  363. }
  364. if(X_DRV && !MXC_bDJTD_P && !MXC_bDJTD_N && !MXC_bRunning && (MXC_cMotorStep == 0))
  365. {
  366. AxisEgmStop(X_AXIS);
  367. }
  368. if (MXC_ManXiaChong_UP || MXC_bXiaChong)
  369. {
  370. MXC_bXiaChong = 0;
  371. if (MXC_cXiaChongStep == 0)
  372. {
  373. MXC_cXiaChongStep = 1;
  374. MXC_DingDanJianGe_State = 0;
  375. }
  376. }
  377. if (MXC_cXiaChongStep == 0)
  378. {
  379. if (MXC_bLeftFenZhen)
  380. {
  381. MXC_bLeftFenZhen = 0;
  382. MXC_LeftFenZhen_VAVLE = ~MXC_LeftFenZhen_VAVLE;
  383. }
  384. if (MXC_bRightFenZhen)
  385. {
  386. MXC_bRightFenZhen = 0;
  387. MXC_RightFenZhen_VAVLE = ~MXC_RightFenZhen_VAVLE;
  388. }
  389. //点动下冲
  390. if ((MXC_bDotXiaChong))
  391. {
  392. MXC_bDotXiaChong = 0;
  393. if (MXC_LeftFenZhen_IN && MXC_RighttFenZhen_IN)
  394. {
  395. if (MXC_XiaChongMotorMode == 0)//交流电机,直接下冲
  396. {
  397. if (MXC_cXiaChongStep == 0)
  398. MXC_cXiaChongStep = 20;
  399. }
  400. else
  401. {
  402. if (MXC_cXiaChongStep == 0)
  403. MXC_cXiaChongStep = 40;
  404. }
  405. }
  406. else
  407. {
  408. MXC_SetAlarmCode(MXC_XIA_CHONG_ALARM); //下冲条件不满足
  409. }
  410. }
  411. if (MXC_bGouZhen)
  412. {
  413. MXC_bGouZhen = 0;
  414. if ((MXC_GOU_ZHEN_MODE == 0)) //普通勾针(活动)过链
  415. {
  416. //MXC_cGouZhenTime = dwTickCount + 300;
  417. MXC_GouZhen_VAVLE = ~MXC_GouZhen_VAVLE;
  418. }
  419. }
  420. }
  421. if (MXC_bXiaZhi)
  422. {
  423. MXC_bXiaZhi = 0;
  424. if (MXC_XiaZhi_VAVLE)
  425. {
  426. MXC_XiaZhi_VAVLE = 0;
  427. MXC_ChaoSheng = 0;
  428. }
  429. else
  430. {
  431. if (MXC_XIA_ZHI_ENABLE) //下止选择
  432. {
  433. //下止输出
  434. MXC_cXiaZhiDelay = dwTickCount + MXC_PARAM_XIAZHI_TIME;
  435. MXC_XiaZhi_VAVLE = 1;
  436. }
  437. }
  438. }
  439. if (MXC_DC_MODE != 0) //伺服定寸,目前没有钩针 暂时不用
  440. {
  441. // MXC_GuDingGouZhen = 1;
  442. // MXC_GouZhen_VAVLE = 1;
  443. }
  444. // else if ((MXC_GOU_ZHEN_MODE == 0) && !Y_DRV && (MXC_cGouZhenDWStep == 0)) //普通勾针(活动)过链在勾针定电机动作情况下不能关
  445. // {
  446. // if (dwTickCount >= MXC_cGouZhenTime)
  447. // MXC_GouZhen_VAVLE = 0;
  448. // }
  449. if (MXC_bChuDai)
  450. {
  451. MXC_ChuDai_VAVLE = 1;
  452. }
  453. else
  454. {
  455. MXC_ChuDai_VAVLE = 0;
  456. }
  457. // if (MXC_bTestMotor)
  458. // {
  459. // MXC_GouZhen_VAVLE = 1;
  460. // MXC_cGouZhenTime = dwTickCount + 300;
  461. // if (!X_DRV)
  462. // {
  463. // MXC_TuoDaiSongZhou = MXC_SERVER_EN;
  464. // //AxisContinueMoveAcc(X_AXIS,10,MXC_DIR_P,MXC_PARAM_START_SPEED,MXC_PARAM_START_SPEED,MXC_PARAM_ACC_SPEED,MXC_PARAM_DEC_SPEED);
  465. // }
  466. // }
  467. // else if (MXC_cMotorStep == 0)
  468. // {
  469. // //if(X_DRV)AxisDecStop(X_AXIS);
  470. // }
  471. }
  472. //下止下冲电磁铁
  473. if ((MXC_XiaZhi_VAVLE != 0) && (dwTickCount >= MXC_cXiaZhiDelay))
  474. {
  475. MXC_XiaZhi_VAVLE = 0;
  476. }
  477. }
  478. void MXC_AutoAction(void)
  479. {
  480. unsigned char DingDan_Flag;
  481. unsigned short ch;
  482. DISPLAY_DATA0 = MXC_cAutoStep;
  483. DISPLAY_DATA1 = MXC_cMotorStep;
  484. DISPLAY_DATA2 = KD_GO_ON_FLAG;
  485. if((DISPLAY_DATA3 <= GetCurSpeed(X_AXIS)) && MXC_bRunning == 1)
  486. DISPLAY_DATA3 = GetCurSpeed(X_AXIS);
  487. DISPLAY_DATA4 = MXC_cXiaChongStep;//MXC_cXiaChongStep;
  488. DISPLAY_DATA6 = dwRealPos;
  489. if (MXC_bRunning)
  490. {
  491. if ((!MXC_Zipper_IN))
  492. MXC_ChuDai_VAVLE = 0;
  493. else
  494. MXC_ChuDai_VAVLE = 1;
  495. if ((MXC_DC_MODE == 0) && (MXC_GOU_ZHEN_MODE == 0))
  496. {
  497. if (MXC_GouZhen_IN_UP)
  498. MXC_cGouZhenTime = 1;
  499. }
  500. else
  501. MXC_cGouZhenTime = 1;
  502. switch (MXC_cAutoStep)
  503. {
  504. case 0:
  505. break;
  506. case 1:
  507. if (dwTickCount >= MXC_cAutoDelay)
  508. {
  509. if (MXC_TuoDaiSongZhou == MXC_SERVER_DISEN)
  510. {
  511. MXC_TuoDaiSongZhou = MXC_SERVER_EN;
  512. MXC_cAutoDelay = dwTickCount + 700; //先锁轴
  513. }
  514. else
  515. MXC_cAutoDelay = dwTickCount;
  516. //要判断勾针是否已定位好
  517. if (MXC_cGouZhenDWStep == 0 || MXC_DC_MODE != 0)
  518. {
  519. MXC_cAutoStep = 2;
  520. }
  521. }
  522. break;
  523. case 2:
  524. //左右分针要退到位,过链到位要离开
  525. if (!MXC_GouZhen_IN && MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_LeftFenZhen_IN && !MXC_RighttFenZhen_IN && (dwTickCount >= MXC_cAutoDelay))// && MXC_DDBH_Origin_IN
  526. {
  527. //要判断勾针是否已定位好
  528. if (MXC_cGouZhenDWStep == 0 || MXC_DC_MODE != 0)
  529. {
  530. MXC_cAutoStep = 3;
  531. MXC_cMotorStep = 1; //启动拖带
  532. }
  533. }
  534. break;
  535. case 3:
  536. //拖带已经完成
  537. if (MXC_cMotorStep == 0)
  538. {
  539. if (SingOneFlg)
  540. {
  541. dwZipCnt = 0;
  542. SingOneFlg = 0;
  543. MXC_cAutoStep = 0;
  544. MXC_bRunning = 0;
  545. }
  546. else
  547. {
  548. MXC_cAutoStep = 4;
  549. }
  550. }
  551. break;
  552. case 4:
  553. MXC_cAutoStep = 5;
  554. break;
  555. case 5:
  556. //左右分针都已完成
  557. if ((MXC_cLeftFenZhenStep == 0) && (MXC_cRightFenZhenStep == 0) && (MXC_cXiaChongStep == 0) && (!MXC_TIAOSHI_MODE || MXC_START_IN_UP))
  558. {
  559. if (MXC_SET_XIACHONG_DISEN == 0)
  560. {
  561. MXC_cXiaChongStep = 1; //下冲电机启动
  562. MXC_cAutoStep = 6;
  563. }
  564. else
  565. {
  566. MXC_cAutoDelay = dwTickCount + MXC_PARAM_DELAY_XC;
  567. MXC_cAutoStep = 106;
  568. }
  569. }
  570. break;
  571. case 106:
  572. if (dwTickCount >= MXC_cAutoDelay)
  573. {
  574. MXC_GouZhen_VAVLE = 1;
  575. MXC_cAutoStep = 6;
  576. }
  577. break;
  578. case 6: //下冲已完成
  579. if (((MXC_cXiaChongStep == 0) || (MXC_cXiaChongStep >= 5)) )//&& !MXC_XiaZhi_VAVLE
  580. {
  581. dwZipCnt++;
  582. AddToTal(MXC_TOTAL_ADDR); //计数增加和保存
  583. //条件满足的情况下对应产量也加1
  584. if(MXC_DingDanWorkMode)
  585. DingDanTotalAdd();
  586. // MXC_DingDanJianGe = 0; //回到原来工作模式
  587. CalProSP(MXC_PROSPEED_ADDR);
  588. MXC_cAutoStep = 7;
  589. }
  590. break;
  591. case 7:
  592. if (MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_LeftFenZhen_IN && !MXC_RighttFenZhen_IN)
  593. {
  594. if (GetTotal(MXC_TOTAL_ADDR) >= MXC_SET_TOTAL)
  595. {
  596. if (MXC_DingDanWorkMode && MXC_USE_GZ_SERVO)//连续订单模式
  597. {
  598. MXC_bSaveWorkData = 1;//存盘数据到屏幕
  599. MXC_cAutoStep = 20;
  600. }
  601. else
  602. {
  603. MXC_cAutoStep = 0;
  604. MXC_bRunning = 0;
  605. MXC_SingOneFlag = 1;
  606. MXC_SetAlarmCode(MXC_TOTAL_ALARM);
  607. }
  608. }
  609. else
  610. MXC_cAutoStep = 8;
  611. }
  612. break;
  613. case 8:
  614. MXC_cAutoDelay = dwTickCount + MXC_PARAM_MOTOR_DELAY;
  615. if (MXC_SingOneFlag)
  616. {
  617. dwZipCnt = 0;
  618. MXC_SingOneFlag = 0;
  619. MXC_cAutoStep = 0;
  620. MXC_bRunning = 0;
  621. }
  622. else
  623. MXC_cAutoStep = 1;
  624. break;
  625. case 20:
  626. if (!MXC_bSaveWorkData)//未进行存盘
  627. {
  628. //订单组自动赋值
  629. DingDan_Flag = DingDanCheckOk();
  630. //订单接收标志位为0,表示当前订单的数量设定做了修改,需要继续加工
  631. if(DingDan_Flag == 0)
  632. MXC_cAutoStep = 1;
  633. //订单接收标志位不为0且不等于5,则有其他订单待做,打上公分节
  634. else if (DingDan_Flag != (MXC_DingDanNum))
  635. {
  636. MXC_cAutoStep = 21;
  637. MXC_cAutoDelay = dwTickCount + 20;
  638. if (MXC_DC_MODE == 0) //勾针定寸情况下才要重新的定位勾针
  639. {
  640. //长度不一样先定位勾针
  641. if (MXC_SET_ZIPPER_LENGTH > MXC_Gouzhencurrent_L)
  642. ch = MXC_SET_ZIPPER_LENGTH - MXC_Gouzhencurrent_L;
  643. else
  644. ch = MXC_Gouzhencurrent_L - MXC_SET_ZIPPER_LENGTH;
  645. if (ch > 2)
  646. MXC_cGouZhenDWStep = 1;
  647. }
  648. }
  649. else
  650. MXC_SetAlarmCode(MXC_TOTAL_ALARM);
  651. DingDan_Flag = 0;
  652. }
  653. break;
  654. case 21:
  655. if (dwTickCount >= MXC_cAutoDelay)
  656. {
  657. if (MXC_DingDanJianGe_Length) //间隔距离为0时直接返回
  658. {
  659. MXC_DingDanJianGe_State = 1;
  660. MXC_cMotorStep = 100;
  661. MXC_cAutoStep = 22;
  662. }
  663. else
  664. MXC_cAutoStep = 8;
  665. }
  666. break;
  667. case 22:
  668. if (MXC_cMotorStep == 0)
  669. {
  670. MXC_cXiaChongStep = 1;
  671. MXC_cAutoStep = 23;
  672. }
  673. break;
  674. case 23:
  675. if (MXC_cXiaChongStep == 0)
  676. {
  677. if (MXC_DC_MODE != 0)
  678. MXC_cAutoStep = 1;
  679. else
  680. MXC_cAutoStep = 30;
  681. }
  682. break;
  683. case 30:
  684. if (MXC_PARAM_GZ_RESET_MODE == 0)//勾针复位方式 0为延时1为数控
  685. MXC_cMotorStep = 200;
  686. MXC_cAutoStep = 31;
  687. break;
  688. case 31:
  689. if (MXC_cMotorStep == 0)
  690. {
  691. MXC_cAutoStep = 1;
  692. }
  693. break;
  694. }
  695. }
  696. }
  697. // 检测是否踏了脚踏开关
  698. void MXC_NiLongXiuCiJiCheckStart(void)
  699. {
  700. unsigned short ch;
  701. // 停止键 不能在工作,手动,停止过程中
  702. if ((MXC_bRunning == 0) && (MXC_START_IN_UP || MXC_bStart || MXC_bNext))
  703. {
  704. MXC_bStart = 0;
  705. if (!MXC_LeftFenZhen_Origin_IN)
  706. MXC_SetAlarmCode(MXC_START_LFZ_ORIGIN_ALARM); //没拉链
  707. else if (!MXC_RightFenZhen_Origin_IN)
  708. MXC_SetAlarmCode(MXC_START_RFZ_ORIGIN_ALARM);
  709. else if (!MXC_Zipper_IN)
  710. MXC_SetAlarmCode(MXC_START_NO_ZIPPER_ALARM);
  711. else if ((MXC_PARAM_SEBIAO_DW_LENGTH > MXC_SET_ZIPPER_LENGTH) && (MXC_DC_MODE == 2))
  712. MXC_SetAlarmCode(MXC_SEBIAO_ZIPPER_LENGTH_ALARM);
  713. else if (MXC_KaDai_IN)
  714. MXC_SetAlarmCode(MXC_KA_DAI_ALARM);
  715. else
  716. {
  717. /* if(GetTotal(MXC_TOTAL_ADDR) >= MXC_SET_TOTAL)
  718. {
  719. //调入下一组数据,全部都没有的话警告停止
  720. if(DingDanCheckOk() >= (MXC_DingDanNum))
  721. {
  722. MXC_SetAlarmCode(MXC_TOTAL_ALARM);
  723. return;
  724. }
  725. }*/
  726. if (MXC_bNext)
  727. {
  728. SingOneFlg = 1;
  729. MXC_bNext = 0;
  730. }
  731. MXC_bRunning = 1;
  732. cGouZhenTime = 1;
  733. cCheckLengthOk = 0;
  734. cZipperLength[0] = 0;
  735. cZipperLength[1] = 0;
  736. zipper_length_buff = 0;
  737. dwZipCnt = 0;
  738. //DISPLAY_DATA4=0;
  739. /*
  740. if((MXC_DingDanJianGe_State == 1) && MXC_DingDanWorkMode && MXC_USE_GZ_SERVO) //间隔链还没有打完情况下先打间隔链
  741. MXC_cAutoStep = 20;
  742. else
  743. */
  744. MXC_cAutoStep = 1;
  745. //第一次上电或长度不一样时启动必须先定位勾针
  746. //长度不一样先定位勾针
  747. //MXC_StartFirst = 1;
  748. offset_len = &MXC_SET_REVISE_ZIPPER_LENGTH;
  749. if ((MXC_SET_ZIPPER_LENGTH + (*offset_len)) > MXC_Gouzhencurrent_L)
  750. ch = MXC_SET_ZIPPER_LENGTH + MXC_SET_REVISE_ZIPPER_LENGTH - MXC_Gouzhencurrent_L;
  751. else
  752. ch = MXC_Gouzhencurrent_L - (MXC_SET_ZIPPER_LENGTH + (*offset_len));
  753. // 数控模式下不用走动勾针
  754. if ((MXC_StartFirst || (ch > 1)) && (MXC_DC_MODE == 0) && MXC_USE_GZ_SERVO)
  755. {
  756. MXC_cGouZhenDWStep = 1;
  757. //MXC_StartFirst = 1;
  758. }
  759. }
  760. }
  761. //卡带感应
  762. if (MXC_KaDai_IN && (dwTickCount >= MXC_cKaDaiDelay))
  763. {
  764. if (MXC_DC_MODE == 1)
  765. {
  766. if (X_DRV && MXC_bRunning && (MXC_cMotorStep == 20))
  767. {
  768. MXC_KD_Flag = 1;
  769. KD_GO_ON_FLAG = 1;
  770. }
  771. }
  772. MXC_SetAlarmCode(MXC_KA_DAI_ALARM);
  773. MXC_cKaDaiDelay = dwTickCount + 2200;
  774. }
  775. if (MXC_KD_Flag)
  776. {
  777. if (!X_DRV)
  778. {
  779. MXC_KD_pos = dwRealPos;
  780. MXC_KD_Flag = 0;
  781. }
  782. }
  783. if (MXC_KaDai_IN_UP)
  784. {
  785. if (MXC_cChuiQiStep == 0)
  786. MXC_cChuiQiStep = 1;
  787. }
  788. //停止
  789. STOP_IN_FLAG_OLD = STOP_IN_FLAG;
  790. if (MXC_STOP_IN)
  791. {
  792. if (STOP_FILTER < 50)
  793. {
  794. STOP_FILTER++;
  795. }
  796. else
  797. STOP_IN_FLAG = 1;
  798. }
  799. else if (STOP_FILTER > 25)
  800. {
  801. STOP_FILTER--;
  802. }
  803. else
  804. STOP_IN_FLAG = 0;
  805. if (MXC_bStop)
  806. {
  807. MXC_bStop = 0;
  808. if (MXC_bRunning)
  809. MXC_SingOneFlag = 1;
  810. }
  811. if (((STOP_IN_FLAG && !STOP_IN_FLAG_OLD)))
  812. {
  813. MXC_bStop = 0;
  814. if (MXC_cGouZhenDWStep && STOP_IN_FLAG && (MXC_cXiaChongStep == 0))
  815. {
  816. AxisDecStop(Y_AXIS);
  817. MXC_cGouZhenDWStep = 0;
  818. }
  819. if (MXC_bRunning)
  820. {
  821. if (MXC_cXiaChongStep == 0)
  822. {
  823. if (MXC_cChuiQiStep == 0)
  824. MXC_cChuiQiStep = 1;
  825. if (!MXC_XiaChong_MOTOR)
  826. MXC_XC_SongZhou = MXC_XC_SERVER_EN;
  827. }
  828. MXC_bRunning = 0;
  829. cStopFlag = 0;
  830. MXC_cAutoStep = 0;
  831. MXC_cMotorStep = 0;
  832. MXC_cDCPStep = 0;
  833. AxisDecStop(X_AXIS);
  834. //DISPLAY_DATA4++;
  835. MXC_cJiaoDaoStep = 0;
  836. SingOneFlg = 0;
  837. MXC_SingOneFlag = 0;
  838. MXC_KD_Flag = 0;
  839. KD_GO_ON_FLAG = 0;
  840. }
  841. else
  842. {
  843. DISPLAY_DATA3 = 0;
  844. MXC_bRunning = 0;
  845. SetPos(X_AXIS, 0);
  846. MXC_TuoDaiSongZhou = MXC_SERVER_DISEN;
  847. cDW_data_Num = 0;
  848. cStopFlag = 0;
  849. MXC_cAutoStep = 0;
  850. MXC_cMotorStep = 0;
  851. MXC_cXiaChongStep = 0;
  852. MXC_cLeftFenZhenStep = 0;
  853. MXC_cRightFenZhenStep = 0;
  854. MXC_cJiaoDaoStep = 0;
  855. MXC_cDCPStep = 0;
  856. MXC_DingDao_BaoHu_VAVLE = 0;
  857. MXC_XiaZhi_VAVLE = 0;
  858. MXC_LeftFenZhen_VAVLE = 0;
  859. MXC_RightFenZhen_VAVLE = 0;
  860. MXC_XiaChong_MOTOR = 0;
  861. MXC_ChaoSheng = 0;
  862. MXC_JiaoDao_OUT = 0;
  863. MXC_ChuDai_VAVLE = 0;
  864. MXC_GuDingGouZhen = 0;
  865. SingOneFlg = 0;
  866. MXC_SingOneFlag = 0;
  867. MXC_KD_Flag = 0;
  868. KD_GO_ON_FLAG = 0;
  869. if (MXC_XiaChongMotorMode)
  870. MXC_XC_SongZhou = MXC_XC_SERVER_EN;
  871. else
  872. MXC_XC_ShaChe = MXC_SC_DISEN;
  873. if ((MXC_cChuiQiStep == 0) && (MXC_cXiaChongStep == 0))
  874. MXC_cChuiQiStep = 1;
  875. AxisDecStop(X_AXIS);
  876. //DISPLAY_DATA7++;
  877. SetAlarmCode(MXC_ALARM_ADDR, MXC_NO_ALARM);
  878. }
  879. }
  880. // if (!MXC_bRunning && (MXC_cMotorStep == 0) && (MXC_cXiaChongStep == 0))
  881. // {
  882. // if (!X_DRV)
  883. // MXC_TuoDaiSongZhou = MXC_SERVER_DISEN;
  884. // }
  885. if (MXC_bAlarmStop)
  886. {
  887. MXC_bAlarmStop = 0;
  888. MXC_bRunning = 0;
  889. MXC_cAutoStep = 0;
  890. MXC_cMotorStep = 0;
  891. MXC_cDCPStep = 0;
  892. MXC_SingOneFlag = 0;
  893. AxisDecStop(X_AXIS);
  894. if ((GetAlarmCode(MXC_ALARM_ADDR) == MXC_XIA_CHONG_ALARM) || (GetAlarmCode(MXC_ALARM_ADDR) == MXC_XC_ALARM) || (GetAlarmCode(MXC_ALARM_ADDR) == MXC_FEN_ZHEN_ALARM))
  895. {
  896. MXC_cXiaChongStep = 0;
  897. MXC_XiaChong_MOTOR = 0;
  898. }
  899. }
  900. }
  901. void MXC_JiaoDao(void)
  902. {
  903. if (MXC_cJiaoDaoStep == 1)
  904. {
  905. MXC_cChuiQiDelay = dwTickCount + 500;
  906. MXC_JiaoDao_OUT = 1;
  907. MXC_cJiaoDaoStep = 2;
  908. }
  909. else if ((MXC_cJiaoDaoStep == 2) && (dwTickCount >= MXC_cChuiQiDelay))
  910. {
  911. MXC_JiaoDao_OUT = 0;
  912. MXC_cJiaoDaoStep = 0;
  913. }
  914. }
  915. void MXC_ChuiQiProc(void)
  916. {
  917. //吹气
  918. if (MXC_XiaChong_IN_UP)
  919. {
  920. if (MXC_cChuiQiStep == 0)
  921. MXC_cChuiQiStep = 1;
  922. if(!MXC_DingDao_BaoHu_VAVLE && MXC_DDBH_Origin_IN )//
  923. {
  924. MXC_DingDao_BaoHu_VAVLE = 1;
  925. MXC_cDDBHDelay = dwTickCount + MXC_DDBH_Time;
  926. }
  927. }
  928. if(MXC_DingDao_BaoHu_VAVLE && dwTickCount > MXC_cDDBHDelay)
  929. {
  930. MXC_DingDao_BaoHu_VAVLE = 0;
  931. }
  932. #if 0
  933. switch (MXC_cDCPStep)
  934. {
  935. case 0:
  936. break;
  937. case 1:
  938. MXC_cDCPStep = 2;
  939. MXC_cDaoJuCheckDelay = dwTickCount + 3500;
  940. break;
  941. case 2:
  942. if (MXC_DingChuPian_IN_DW)
  943. {
  944. MXC_cDCPStep = 0;
  945. }
  946. else if ((dwTickCount >= MXC_cDaoJuCheckDelay) && (MXC_DAO_JU_ALARM_EN == 0))
  947. MXC_SetAlarmCode(MXC_DAO_JU_ALARM);
  948. break;
  949. }
  950. #endif
  951. switch (MXC_cChuiQiStep)
  952. {
  953. case 1:
  954. MXC_cChuiQiStep = 2;
  955. if (MXC_bRunning)
  956. MXC_cChuiQiDelay = dwTickCount + MXC_PARAM_DELAY_CHUIQI_TIME;
  957. break;
  958. case 2:
  959. if (dwTickCount >= MXC_cChuiQiDelay)
  960. {
  961. MXC_cChuiQiDelay = dwTickCount + MXC_PARAM_CHUIQI_TIME;
  962. MXC_ChuiQi_VAVLE = 1; //
  963. MXC_cChuiQiStep = 3;
  964. }
  965. break;
  966. case 3:
  967. if (dwTickCount >= MXC_cChuiQiDelay)
  968. {
  969. MXC_ChuiQi_VAVLE = 0; //
  970. MXC_cChuiQiStep = 0;
  971. }
  972. break;
  973. }
  974. }
  975. void MXC_ShaChe_Output(void)
  976. {
  977. //启动吹气
  978. cShaCheTime = dwTickCount + (unsigned long)120;
  979. if (MXC_XiaChongMotorMode == 0)
  980. MXC_XC_SongZhou = MXC_XC_SERVER_DISEN;
  981. }
  982. void MXC_Output_XiaCi(void) //下止输出
  983. {
  984. if (MXC_XIA_ZHI_ENABLE) //下止选择
  985. {
  986. //下止输出
  987. MXC_cXiaZhiDelay = dwTickCount + MXC_PARAM_XIAZHI_TIME;
  988. MXC_XiaZhi_VAVLE = 1;
  989. }
  990. }
  991. unsigned char ComPareLength(void)//前后拉链对比
  992. {
  993. if ((cZipperLength[0] != 0) && (cZipperLength[1] != 0))
  994. {
  995. if (cZipperLength[0] > cZipperLength[1])
  996. {
  997. if ((cZipperLength[0] - cZipperLength[1]) > 50)
  998. {
  999. return 0;
  1000. }
  1001. else
  1002. return 1;
  1003. }
  1004. else
  1005. {
  1006. if ((cZipperLength[1] - cZipperLength[0]) > 50)
  1007. {
  1008. return 0;
  1009. }
  1010. else
  1011. return 1;
  1012. }
  1013. }
  1014. else
  1015. return 0;
  1016. }
  1017. void MXC_NiLongXiuCiJi_Motor(void)
  1018. {
  1019. static long save_buff, gou_zhen_buff;
  1020. static unsigned long zipper_length;
  1021. short *revise_buff;
  1022. if (MXC_bRunning)//检测拉链,由于拉链有间隙,故需要延迟检测
  1023. {
  1024. if (MXC_Zipper_IN)
  1025. {
  1026. MXC_cBudaiCheckDelay = dwTickCount + MXC_PARAM_MOTOR_ALARM_TIME;
  1027. }
  1028. else if (dwTickCount >= MXC_cBudaiCheckDelay) //没布带了
  1029. {
  1030. MXC_SetAlarmCode(MXC_NO_ZIPPER_ALARM); //没拉链
  1031. }
  1032. }
  1033. dwRealPos = GetPos(X_AXIS);
  1034. //当前位置脉冲
  1035. dwRealPosY = GetPos(Y_AXIS);
  1036. DISPLAY_DATA6 = zipper_length;
  1037. // DISPLAY_DATA7 = zipper_length_buff;
  1038. switch (MXC_cMotorStep)
  1039. {
  1040. case 0:
  1041. break;
  1042. //
  1043. case 1:
  1044. //
  1045. if (MXC_LeftFenZhen_Origin_IN && (!MXC_LeftFenZhen_IN) && MXC_RightFenZhen_Origin_IN && (!MXC_RighttFenZhen_IN))
  1046. {
  1047. SetPos(X_AXIS, 0);
  1048. //save_buff = dwRealPos;
  1049. //DISPLAY_DATA2= save_buff;
  1050. revise_buff = &user_datas[17];
  1051. //save_pos_buff = dwRealPos;
  1052. if (MXC_DC_MODE == 0) //钩针定寸(暂时无钩针)
  1053. {
  1054. if (MXC_DEC_MODE) //减速方式:1数控模式 0感应方式
  1055. {
  1056. if (MXC_PARAM_AUTO_CHECK_MODE) //1为自动测长0为手动输入长度
  1057. {
  1058. if (cCheckLengthOk)
  1059. {
  1060. AxisMovePosAccDecNotStop(X_AXIS, MXC_PARAM_SET_SPEED, zipper_length - MXC_PARAM_LOWSPEED_LENGTH,
  1061. MXC_PARAM_START_SPEED, MXC_PARAM_LOW_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1062. }
  1063. else
  1064. {
  1065. if (cCheckLengthOk == 0)
  1066. {
  1067. cZipperLength[0] = cZipperLength[1];
  1068. cZipperLength[1] = zipper_length_buff;
  1069. if (ComPareLength())//返回1,前后拉链没有明显变化
  1070. {
  1071. cCheckLengthOk = 1;
  1072. }
  1073. }
  1074. if (cCheckLengthOk)
  1075. {
  1076. zipper_length = cZipperLength[1];
  1077. AxisMovePosAccDecNotStop(X_AXIS, MXC_PARAM_SET_SPEED, zipper_length - MXC_PARAM_LOWSPEED_LENGTH,
  1078. MXC_PARAM_START_SPEED, MXC_PARAM_LOW_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1079. }
  1080. else
  1081. {
  1082. AxisContinueMoveAcc(X_AXIS, MXC_PARAM_FIRST_SPEED, MXC_DIR_P, MXC_PARAM_START_SPEED,
  1083. MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  1084. }
  1085. }
  1086. }
  1087. else
  1088. {
  1089. if (dwZipCnt == 0)
  1090. AxisContinueMoveAcc(X_AXIS, MXC_PARAM_FIRST_SPEED, MXC_DIR_P, MXC_PARAM_START_SPEED, MXC_PARAM_START_SPEED,
  1091. MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  1092. else
  1093. {
  1094. zipper_length = MXC_SET_ZIPPER_LENGTH + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH;
  1095. //输入长度过大
  1096. if (zipper_length > zipper_length_buff && dwZipCnt > 1)
  1097. zipper_length = zipper_length_buff;
  1098. AxisMovePosAccDecNotStop(X_AXIS, MXC_PARAM_SET_SPEED, zipper_length - MXC_PARAM_LOWSPEED_LENGTH,
  1099. MXC_PARAM_START_SPEED, MXC_PARAM_LOW_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1100. }
  1101. }
  1102. MXC_cMotorStep = 3;
  1103. }
  1104. else // 感应方式
  1105. {
  1106. AxisContinueMove(X_AXIS, MXC_PARAM_SET_SPEED, MXC_DIR_P);
  1107. MXC_cMotorStep = 2;
  1108. }
  1109. }
  1110. else if (MXC_DC_MODE == 1 && (!MXC_TIAOSHI_MODE || MXC_START_IN_UP)) //电机定寸
  1111. {
  1112. // if (KD_GO_ON_FLAG)
  1113. // {
  1114. // if(bGongFen_Stop == 1)
  1115. // {
  1116. // if (MXC_KD_pos > (MXC_DingDanJianGe_Length + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH))//警告停止时走链已超过,按正常重新走链
  1117. // zipper_length = MXC_DingDanJianGe_Length + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH;
  1118. // else//警告停止时还未超出,走剩下的拉链
  1119. // zipper_length = MXC_DingDanJianGe_Length + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH - MXC_KD_pos;
  1120. // MXC_cAutoStep = 22;
  1121. // }
  1122. // else
  1123. // {
  1124. // if (MXC_KD_pos > (MXC_SET_ZIPPER_LENGTH + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH))//警告停止时走链已超过,按正常重新走链
  1125. // zipper_length = MXC_SET_ZIPPER_LENGTH + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH;
  1126. // else//警告停止时还未超出,走剩下的拉链
  1127. // zipper_length = MXC_SET_ZIPPER_LENGTH + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH - MXC_KD_pos;
  1128. // }
  1129. // KD_GO_ON_FLAG = 0;
  1130. // }
  1131. // else
  1132. zipper_length = MXC_SET_ZIPPER_LENGTH + (*revise_buff) + MXC_PARAM_DAOKOU_LENGTH;
  1133. MXC_cMotorStep = 20;
  1134. MXC_GouZhen_VAVLE = 1; //定位(活动勾针)电磁阀
  1135. MXC_GuDingGouZhen = 1; //定位(固定勾针)电磁阀
  1136. AxisMovePosAccDec(X_AXIS, MXC_PARAM_SET_SPEED, zipper_length, MXC_PARAM_START_SPEED,
  1137. MXC_PARAM_SHIFU_LOW_SPEED, MXC_PARAM_ACC_SPEED,( MXC_PARAM_DEC_SPEED + MXC_PARAM_SET_SPEED/200) ,
  1138. MXC_PARAM_SHIFU_LOWSPEED_LENGTH);
  1139. }
  1140. else if(MXC_DC_MODE == 2)//色标定寸
  1141. {
  1142. zipper_length = MXC_SET_ZIPPER_LENGTH + (*revise_buff);
  1143. if ((dwZipCnt == 0) || SingOneFlg)
  1144. AxisContinueMoveAcc(X_AXIS, MXC_PARAM_SB_LOW_SPEED, MXC_DIR_P, MXC_PARAM_START_SPEED,
  1145. MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  1146. else
  1147. AxisContinueMoveAcc(X_AXIS, MXC_PARAM_SB_HIGH_SPEED, MXC_DIR_P, MXC_PARAM_START_SPEED,
  1148. MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  1149. cSeBiaoOk = 0;
  1150. cSeBiaoEn = 0;
  1151. MXC_cMotorStep = 50;
  1152. }
  1153. MXC_cGouZhenTime = dwTickCount + MXC_PARAM_GZ_DELAY;
  1154. MXC_cMotorDelay = dwTickCount + MXC_MOTOR_ALALRM_TIME;
  1155. }
  1156. break;
  1157. // step2-5 活动勾针定寸
  1158. case 2:
  1159. if ((dwTickCount >= MXC_cGouZhenTime) && (MXC_PARAM_GZ_RESET_MODE == 0))
  1160. MXC_GouZhen_VAVLE = 0;
  1161. if (MXC_DEC_MODE == 0) // 感应模式
  1162. {
  1163. if (MXC_Dec_IN_DW)
  1164. {
  1165. AxisChangeSpeed(X_AXIS, MXC_PARAM_LOW_SPEED);
  1166. MXC_cGouZhenTime = dwTickCount + MXC_PARAM_GZ_DELAY;
  1167. MXC_cMotorStep = 3;
  1168. }
  1169. if (MXC_GouZhen_IN)
  1170. {
  1171. MXC_cMotorStep = 5;
  1172. AxisEgmStop(X_AXIS);
  1173. }
  1174. }
  1175. if (dwTickCount >= MXC_cMotorDelay)
  1176. MXC_SetAlarmCode(MXC_LONG_TIME_NO_ZIPPER_ALARM);
  1177. break;
  1178. case 3:
  1179. if ((dwTickCount >= MXC_cGouZhenTime) && (MXC_PARAM_GZ_RESET_MODE == 0))
  1180. MXC_GouZhen_VAVLE = 0;
  1181. if (MXC_DEC_MODE) // 数控方式
  1182. {
  1183. if (MXC_PARAM_AUTO_CHECK_MODE)
  1184. {
  1185. if (cCheckLengthOk)
  1186. {
  1187. if ((dwRealPos >= (zipper_length - MXC_PARAM_GZ_LENGTH)) && MXC_PARAM_GZ_RESET_MODE)
  1188. MXC_GouZhen_VAVLE = 0;
  1189. }
  1190. else
  1191. {
  1192. if (dwTickCount >= MXC_cGouZhenTime)
  1193. MXC_GouZhen_VAVLE = 0;
  1194. }
  1195. }
  1196. else
  1197. {
  1198. if ((dwRealPos >= (zipper_length - MXC_PARAM_GZ_LENGTH)) && MXC_PARAM_GZ_RESET_MODE)
  1199. MXC_GouZhen_VAVLE = 0;
  1200. if ((dwZipCnt == 0) && (dwTickCount >= MXC_cGouZhenTime) && (MXC_PARAM_GZ_RESET_MODE == 1))
  1201. MXC_GouZhen_VAVLE = 0;
  1202. }
  1203. if (MXC_GouZhen_IN)
  1204. {
  1205. MXC_GouZhen_VAVLE = 0;
  1206. MXC_cMotorStep = 4;
  1207. //AxisEgmStop(X_AXIS);
  1208. //再走一点拉紧
  1209. AxisMovePosAccDec(X_AXIS, MXC_PARAM_LOW_SPEED, 6, MXC_PARAM_LOW_SPEED, MXC_PARAM_LOW_SPEED,
  1210. MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1211. }
  1212. }
  1213. else // 感应方式
  1214. {
  1215. MXC_cMotorStep = 4;
  1216. }
  1217. if (dwTickCount >= MXC_cMotorDelay)
  1218. MXC_SetAlarmCode(MXC_LONG_TIME_NO_ZIPPER_ALARM);
  1219. break;
  1220. case 4:
  1221. if ((dwTickCount >= MXC_cGouZhenTime) && (MXC_PARAM_GZ_RESET_MODE == 0))
  1222. MXC_GouZhen_VAVLE = 0;
  1223. if (MXC_DEC_MODE) // 数控方式
  1224. {
  1225. if (!X_DRV)
  1226. {
  1227. MXC_cMotorStep = 0;
  1228. zipper_length_buff = dwRealPos;
  1229. }
  1230. }
  1231. else // 感应方式
  1232. {
  1233. if (MXC_GouZhen_IN)
  1234. {
  1235. MXC_cMotorStep = 5;
  1236. AxisEgmStop(X_AXIS);
  1237. }
  1238. }
  1239. if (dwTickCount >= MXC_cMotorDelay)
  1240. MXC_SetAlarmCode(MXC_LONG_TIME_NO_ZIPPER_ALARM);
  1241. break;
  1242. case 5:
  1243. if (MXC_DEC_MODE) // 数控方式
  1244. {
  1245. }
  1246. else // 感应方式
  1247. {
  1248. if (!X_DRV)
  1249. {
  1250. MXC_cMotorStep = 0;
  1251. }
  1252. }
  1253. if (dwTickCount >= MXC_cMotorDelay)
  1254. MXC_SetAlarmCode(MXC_LONG_TIME_NO_ZIPPER_ALARM);
  1255. break;
  1256. /*
  1257. case 11://以下为固定勾针方式
  1258. if(MXC_XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针
  1259. {
  1260. if(dwTickCount >= MXC_cAutoDelay)MXC_GuDingGouZhen = 0;
  1261. if(!MXC_GuoLian_IN)
  1262. {
  1263. AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED);
  1264. MXC_cMotorStep = 12;
  1265. MXC_cAutoDelay = dwTickCount + (unsigned long)1500; //延时检测
  1266. }
  1267. }
  1268. else
  1269. {
  1270. if(MXC_GuoLianCheckMode)
  1271. {
  1272. if(!MXC_GuoLian_IN)
  1273. {
  1274. AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED);
  1275. MXC_cMotorStep = 12;
  1276. MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[12]; //延时检测
  1277. }
  1278. }
  1279. else
  1280. {
  1281. if(MXC_GuoLian_IN)
  1282. {
  1283. AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED);
  1284. MXC_cMotorStep = 12;
  1285. MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[12]; //延时检测
  1286. }
  1287. }
  1288. }
  1289. break;
  1290. case 12:
  1291. if(dwTickCount >= MXC_cAutoDelay)
  1292. {
  1293. if(MXC_GuDingGouZhen)
  1294. {
  1295. MXC_GuDingGouZhen = 0;
  1296. MXC_cAutoDelay = dwTickCount + (unsigned long)1500; //延时检测
  1297. }
  1298. else if(!MXC_GuDingGouZhen)
  1299. {
  1300. // MXC_SetAlarmCode(MXC_GU_DING_GOUZHEN_ALARM);
  1301. }
  1302. }
  1303. if(MXC_XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针
  1304. {
  1305. if(MXC_GuoLian_IN)
  1306. {
  1307. MXC_GuDingGouZhen = 0;
  1308. MXC_cMotorStep = 13;
  1309. MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机
  1310. }
  1311. }
  1312. else
  1313. {
  1314. if(MXC_GuoLianCheckMode)
  1315. {
  1316. if(MXC_GuoLian_IN_UP)
  1317. {
  1318. MXC_GuDingGouZhen = 0;
  1319. MXC_cMotorStep = 13;
  1320. MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机
  1321. }
  1322. }
  1323. else
  1324. {
  1325. if(MXC_GuoLian_IN_DW)
  1326. {
  1327. MXC_GuDingGouZhen = 0;
  1328. MXC_cMotorStep = 13;
  1329. MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机
  1330. }
  1331. }
  1332. }
  1333. break;
  1334. case 13:
  1335. if((dwTickCount >= MXC_cAutoDelay))
  1336. {
  1337. if(MXC_XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针
  1338. {
  1339. AxisEgmStop(X_AXIS);
  1340. if(MXC_GuoLian_IN)
  1341. {
  1342. MXC_cMotorStep = 0;
  1343. MXC_LIHE_VAVLE = 0;
  1344. }
  1345. }
  1346. else
  1347. {
  1348. if(MXC_GuoLianCheckMode)
  1349. {
  1350. if(MXC_GuoLian_IN)
  1351. {
  1352. MXC_cMotorStep = 0;
  1353. AxisEgmStop(X_AXIS);
  1354. MXC_LIHE_VAVLE = 0;
  1355. }
  1356. }
  1357. else
  1358. {
  1359. if(!MXC_GuoLian_IN)
  1360. {
  1361. MXC_cMotorStep = 0;
  1362. AxisEgmStop(X_AXIS);
  1363. MXC_LIHE_VAVLE = 0;
  1364. }
  1365. }
  1366. }
  1367. }
  1368. break;
  1369. */
  1370. //伺服定寸
  1371. case 20:
  1372. if (!X_DRV)
  1373. {
  1374. user_datas[270+cDW_data_Num] = dwRealPos;
  1375. cDW_data_Num++;
  1376. if(cDW_data_Num >= 30)cDW_data_Num = 0;
  1377. MXC_cMotorStep = 0;
  1378. }
  1379. else if (dwTickCount >= MXC_cMotorDelay)
  1380. MXC_SetAlarmCode(MXC_LONG_TIME_NO_ZIPPER_ALARM);
  1381. break;
  1382. case 50:
  1383. if (dwZipCnt == 0)
  1384. {
  1385. cSeBiaoOk = 0;
  1386. cSeBiaoEn = 1;
  1387. MXC_cMotorStep = 51;
  1388. }
  1389. else
  1390. {
  1391. if ((dwRealPos + MXC_PARAM_SEBIAO_LOWSPEED_LENGTH) >= (zipper_length - MXC_PARAM_SEBIAO_DW_LENGTH))//抵达色标慢速长度
  1392. // AxisChangeSpeed(X_AXIS, MXC_PARAM_LOW_SPEED);//修改减速方式
  1393. AxisContinueMoveChangeSpeed(X_AXIS, MXC_PARAM_LOW_SPEED, MXC_PARAM_LOW_SPEED,
  1394. MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED);
  1395. if ((dwRealPos + MXC_PARAM_SEBIAO_TQ_LENGTH) >= (zipper_length - MXC_PARAM_SEBIAO_DW_LENGTH))
  1396. {
  1397. cSeBiaoOk = 0;//开启色标中断
  1398. cSeBiaoEn = 1;//色标中断使能
  1399. MXC_cMotorStep = 51;
  1400. }
  1401. else if (dwRealPos > (zipper_length + MXC_ERROR_LENGTH))//
  1402. MXC_SetAlarmCode(MXC_NO_SEBIAO_ALARM);
  1403. }
  1404. break;
  1405. case 51:
  1406. if (dwZipCnt != 0)
  1407. {
  1408. if (dwRealPos >= (zipper_length - MXC_PARAM_SEBIAO_LOWSPEED_LENGTH))
  1409. AxisChangeSpeed(X_AXIS, MXC_PARAM_LOW_SPEED);
  1410. if (dwRealPos > (zipper_length + MXC_ERROR_LENGTH))//电机所跑距离超出容错范围
  1411. MXC_SetAlarmCode(MXC_NO_SEBIAO_ALARM);
  1412. }
  1413. if (!X_DRV)
  1414. {
  1415. if (dwZipCnt != 0)
  1416. {
  1417. if (dwRealPos < (zipper_length - MXC_ERROR_LENGTH))//电机停止位置小于容错范围
  1418. MXC_SetAlarmCode(MXC_NO_SEBIAO_ALARM);
  1419. }
  1420. MXC_cMotorStep = 0;
  1421. }
  1422. else if (dwTickCount >= MXC_cMotorDelay)
  1423. MXC_SetAlarmCode(MXC_NO_SEBIAO_ALARM);
  1424. break;
  1425. case 100:
  1426. bGongFen_Stop = 1;
  1427. SetPos(X_AXIS, 0);
  1428. //算出间隔脉冲
  1429. zipper_length = MXC_DingDanJianGe_Length + MXC_PARAM_DAOKOU_LENGTH;
  1430. DISPLAY_DATA5 = zipper_length;
  1431. AxisMovePosAccDec(X_AXIS,MXC_PARAM_SET_SPEED/2,
  1432. zipper_length,
  1433. MXC_PARAM_START_SPEED,
  1434. MXC_PARAM_START_SPEED,
  1435. MXC_PARAM_ACC_SPEED,
  1436. MXC_PARAM_DEC_SPEED,
  1437. 0);
  1438. MXC_cMotorStep = 101;
  1439. break;
  1440. case 101:
  1441. if(!X_DRV)
  1442. {
  1443. bGongFen_Stop = 0;
  1444. MXC_cMotorStep = 0;
  1445. }
  1446. break;
  1447. /*
  1448. case 200:
  1449. //先把拉链
  1450. zipper_length = MXC_SET_ZIPPER_LENGTH;
  1451. //把速度降下来
  1452. AxisMovePosAccDec(X_AXIS,MXC_PARAM_SET_SPEED/2,zipper_length,MXC_PARAM_START_SPEED/2,MXC_PARAM_ACC_SPEED,MXC_PARAM_DEC_SPEED);
  1453. MXC_cMotorStep = 201;
  1454. break;
  1455. case 201:
  1456. if(!X_DRV)
  1457. {
  1458. MXC_cMotorStep = 0;
  1459. }
  1460. break; */
  1461. }
  1462. }
  1463. //下冲
  1464. void MXC_NiLongXiuCiJi_XiaC(void)
  1465. {
  1466. static unsigned char xia_zhi_flg = 0;
  1467. static unsigned long delay_gz_back;
  1468. static unsigned char gz_back_flg = 0;
  1469. //屏幕选择带不带下止功能
  1470. if (MXC_PARAM_XIAZHI_EN == 0)
  1471. MXC_XIA_ZHI_ENABLE = 0;
  1472. if ((MXC_XIA_ZHI_ENABLE == 2) && MXC_bRunning)
  1473. {
  1474. if ((dwTickCount >= delay_gz_back) && gz_back_flg)
  1475. {
  1476. MXC_GouZhen_VAVLE = 1;
  1477. gz_back_flg = 0;
  1478. MXC_cGouZhenTime = dwTickCount + 300;
  1479. }
  1480. }
  1481. switch (MXC_cXiaChongStep)
  1482. {
  1483. case 0:
  1484. return;
  1485. break;
  1486. case 1:
  1487. {
  1488. MXC_DingDanJianGe_State = 0;//走间隔
  1489. if ((MXC_XIA_ZHI_ENABLE == 2) && MXC_bRunning)
  1490. {
  1491. MXC_cXiaChongStep = 7;
  1492. delay_gz_back = dwTickCount + MXC_PARAM_DELAY_GOUZHEN_BACK;
  1493. gz_back_flg = 1;
  1494. xia_zhi_flg = 0;
  1495. MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_DELAY_XC;
  1496. }
  1497. else
  1498. {
  1499. gz_back_flg = 0;
  1500. MXC_cRightFenZhenStep = 1;//右分针动作
  1501. if (MXC_cDCPStep == 0)//做顶出片检测
  1502. MXC_cDCPStep = 1;
  1503. MXC_cLeftFenZhenStep = 0;
  1504. cRFengTimer = 0;
  1505. cLFengTimer = 0;
  1506. MXC_cXiaChongStep = 2;
  1507. }
  1508. }
  1509. break;
  1510. case 2:
  1511. if ((MXC_cRightFenZhenStep == 0) && (MXC_cLeftFenZhenStep == 0))
  1512. {
  1513. if (MXC_XiaChongMotorMode)//0为交流1为步进/伺服
  1514. MXC_XC_SongZhou = MXC_XC_SERVER_EN;
  1515. else
  1516. MXC_XC_ShaChe = MXC_SC_DISEN;
  1517. MXC_XC_SongZhou = MXC_XC_SERVER_DISEN; //刹车打开
  1518. if (MXC_bRunning)
  1519. {
  1520. MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_DELAY_XC;
  1521. }
  1522. MXC_cXiaChongStep = 3;
  1523. }
  1524. break;
  1525. case 3:
  1526. if (dwTickCount >= MXC_cXiaChongDelay)
  1527. {
  1528. MXC_cXiaChongStep = 4;
  1529. MXC_XiaChong_MOTOR = 1; //下冲电机
  1530. if (MXC_bRunning)
  1531. {
  1532. MXC_Output_XiaCi(); //下止输出
  1533. xia_zhi_flg = 1;
  1534. }
  1535. MXC_cXiaChongDelay = dwTickCount + (unsigned long)ERRORTIME; //下冲最长时间
  1536. // if(MXC_XiaChongMotorMode == 1)
  1537. // {
  1538. // AxisMoveTwoPos(Y_AXIS,MXC_XiaChongSpeed,2000,MXC_XiaChongLowSpeed,9999999,0);
  1539. // }
  1540. }
  1541. break;
  1542. case 4: //碰到右大微动,延时停
  1543. if (MXC_XiaChong_IN_UP)//下冲回原位
  1544. {
  1545. MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_XC_DELAY;
  1546. MXC_cXiaChongStep = 5;
  1547. MXC_LeftFenZhen_VAVLE = 0; //退左分针
  1548. MXC_RightFenZhen_VAVLE = 0; //退右分针
  1549. MXC_GouZhen_VAVLE = 1;
  1550. MXC_cGouZhenTime = dwTickCount + 300;
  1551. }
  1552. else if (dwTickCount >= MXC_cXiaChongDelay) //自动停机
  1553. {
  1554. MXC_cXiaChongStep = 0;
  1555. // MXC_ShaChe_Output();////刹车
  1556. MXC_XiaChong_MOTOR = 0; // //下冲电机
  1557. MXC_SetAlarmCode(MXC_XC_ALARM);
  1558. MXC_LeftFenZhen_VAVLE = 0; //退左分针
  1559. MXC_RightFenZhen_VAVLE = 0; //退右分针
  1560. // AxisEgmStop(Y_AXIS);
  1561. }
  1562. break;
  1563. case 5:
  1564. if (dwTickCount >= MXC_cXiaChongDelay)
  1565. {
  1566. // AxisEgmStop(Y_AXIS);
  1567. MXC_XiaChong_MOTOR = 0; //延时刹车
  1568. if (MXC_PARAM_SC_MODE)//1为长时间刹车
  1569. {
  1570. MXC_cXiaChongStep = 0;
  1571. }
  1572. else
  1573. {
  1574. MXC_cXiaChongStep = 6;
  1575. }
  1576. // MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_SC_DELAY;
  1577. }
  1578. break;
  1579. case 6:
  1580. // if((dwTickCount >= MXC_cXiaChongDelay))
  1581. {
  1582. MXC_cXiaChongStep = 7;
  1583. MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_SC_DELAY;
  1584. // MXC_ShaChe_Output();
  1585. }
  1586. break;
  1587. case 7:
  1588. if ((dwTickCount >= MXC_cXiaChongDelay) && !MXC_XiaZhi_VAVLE)
  1589. {
  1590. if (MXC_XIA_ZHI_ENABLE == 2)
  1591. {
  1592. MXC_cXiaChongStep = 8;
  1593. MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_XIAZHI_TIME;
  1594. }
  1595. else
  1596. {
  1597. MXC_cXiaChongStep = 0;
  1598. MXC_cXiaChongDelay = dwTickCount;
  1599. }
  1600. if (MXC_bRunning && !xia_zhi_flg)
  1601. {
  1602. MXC_Output_XiaCi(); //下止输出
  1603. }
  1604. MXC_XC_SongZhou = MXC_XC_SERVER_EN;
  1605. }
  1606. break;
  1607. case 8:
  1608. if (dwTickCount >= MXC_cXiaChongDelay)
  1609. {
  1610. MXC_cXiaChongStep = 0;
  1611. }
  1612. break;
  1613. case 20: // 点动普通下冲动作
  1614. MXC_XC_SongZhou = MXC_XC_SERVER_DISEN;
  1615. MXC_cXiaChongDelay = dwTickCount + 50;
  1616. MXC_cXiaChongStep = 21;
  1617. break;
  1618. case 21:
  1619. if ((dwTickCount >= MXC_cXiaChongDelay))
  1620. {
  1621. MXC_XiaChong_MOTOR = 1;
  1622. // MXC_cXiaChongDelay = dwTickCount + 50;
  1623. MXC_cXiaChongStep = 22;
  1624. }
  1625. break;
  1626. case 22:
  1627. if (MXC_XiaChong_IN_UP)
  1628. {
  1629. MXC_XiaChong_MOTOR = 0;
  1630. MXC_XC_SongZhou = MXC_XC_SERVER_DISEN;
  1631. if (MXC_XiaChongMotorMode)
  1632. MXC_cXiaChongStep = 0;
  1633. else
  1634. {
  1635. MXC_cXiaChongDelay = dwTickCount + 150;
  1636. MXC_cXiaChongStep = 23;
  1637. }
  1638. }
  1639. break;
  1640. case 23:
  1641. if ((dwTickCount >= MXC_cXiaChongDelay))
  1642. {
  1643. MXC_XC_SongZhou = MXC_XC_SERVER_EN;
  1644. MXC_cXiaChongStep = 0;
  1645. }
  1646. break;
  1647. case 40: // 点动电机下冲动作
  1648. MXC_XC_SongZhou = MXC_XC_SERVER_DISEN;
  1649. MXC_cXiaChongDelay = dwTickCount + 50;
  1650. MXC_cXiaChongStep = 41;
  1651. break;
  1652. case 41:
  1653. if (!Y_DRV)
  1654. AxisMovePos(Y_AXIS, 20, 10);
  1655. MXC_cXiaChongStep = 42;
  1656. break;
  1657. case 42:
  1658. if (!Y_DRV)
  1659. {
  1660. MXC_cXiaChongStep = 0;
  1661. }
  1662. break;
  1663. }
  1664. }
  1665. //分针
  1666. void MXC_NiLongXiuCiJi_FenZhengProc(void)
  1667. {
  1668. if (MXC_FenZSelect == 0)
  1669. {
  1670. MXC_cLeftFenZhenStep = 0;
  1671. MXC_cRightFenZhenStep = 0;
  1672. }
  1673. //右分针
  1674. switch (MXC_cRightFenZhenStep)
  1675. {
  1676. case 0:
  1677. break;
  1678. case 1:
  1679. MXC_cFenZhenRightDelay = MXC_PARAM_R_FZ_DELAY + dwTickCount;
  1680. MXC_cRightFenZhenStep = 2;
  1681. break;
  1682. case 2:
  1683. if (dwTickCount >= MXC_cFenZhenRightDelay)
  1684. {
  1685. MXC_cRightFenZhenStep = 3;
  1686. MXC_RightFenZhen_VAVLE = 1; //右分针电磁阀
  1687. MXC_cFenZhenRightDelay = dwTickCount + FenZhengErrorTime;
  1688. }
  1689. break;
  1690. case 3: //碰到右大微动,延时停
  1691. if (!MXC_RightFenZhen_Origin_IN) //右分针原点离开
  1692. {
  1693. MXC_cFenZhenRightDelay = dwTickCount + FenZhengErrorTime;
  1694. MXC_cRightFenZhenStep = 4;
  1695. } //右分针不下去
  1696. else if (dwTickCount >= MXC_cFenZhenRightDelay)
  1697. {
  1698. MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM);
  1699. MXC_cRightFenZhenStep = 0;
  1700. MXC_RightFenZhen_VAVLE = 0;
  1701. }
  1702. break;
  1703. case 4:
  1704. if (MXC_RighttFenZhen_IN) //插针到位
  1705. {
  1706. MXC_cRightFenZhenStep = 0;
  1707. MXC_cLeftFenZhenStep = 1; //左分针延时启动
  1708. }
  1709. else if (dwTickCount >= MXC_cFenZhenRightDelay)
  1710. {
  1711. MXC_RightFenZhen_VAVLE = 0; //右分针
  1712. cRFengTimer++;
  1713. //当右分针分不到位时,左分针也要重新分针
  1714. MXC_LeftFenZhen_VAVLE = 0;
  1715. MXC_cRightFenZhenStep = 0;
  1716. if (cRFengTimer < 4)//times 次数
  1717. {
  1718. MXC_cRightFenZhenStep = 5;
  1719. MXC_cFenZhenRightDelay = dwTickCount + FenZhengErrorTime;
  1720. }
  1721. else
  1722. {
  1723. MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM);
  1724. MXC_cRightFenZhenStep = 0;
  1725. MXC_RightFenZhen_VAVLE = 0;
  1726. }
  1727. }
  1728. break;
  1729. //5-6重新下右分针
  1730. case 5:
  1731. if (MXC_RightFenZhen_Origin_IN) //退到位
  1732. {
  1733. MXC_cRightFenZhenStep = 6;
  1734. }
  1735. else if (dwTickCount >= MXC_cFenZhenRightDelay)
  1736. {
  1737. MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM);
  1738. MXC_RightFenZhen_VAVLE = 0;
  1739. MXC_cRightFenZhenStep = 0;
  1740. }
  1741. break;
  1742. case 6:
  1743. {
  1744. MXC_cRightFenZhenStep = 1;
  1745. }
  1746. break;
  1747. }
  1748. //左分针
  1749. switch (MXC_cLeftFenZhenStep)
  1750. {
  1751. case 0:
  1752. break;
  1753. case 1:
  1754. MXC_cFenZhenLeftDelay = MXC_PARAM_L_FZ_DELAY + dwTickCount;
  1755. MXC_cLeftFenZhenStep = 2;
  1756. break;
  1757. case 2:
  1758. if (dwTickCount >= MXC_cFenZhenLeftDelay)
  1759. {
  1760. MXC_cLeftFenZhenStep = 3;
  1761. MXC_LeftFenZhen_VAVLE = 1; //左分针电磁阀
  1762. MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime;
  1763. }
  1764. break;
  1765. case 3: //离开左分针原点
  1766. if (!MXC_LeftFenZhen_Origin_IN) //左分针原点离开
  1767. {
  1768. MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime;
  1769. MXC_cLeftFenZhenStep = 4;
  1770. } //左分针不下去
  1771. else if (dwTickCount >= MXC_cFenZhenLeftDelay)
  1772. {
  1773. MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM);
  1774. MXC_cLeftFenZhenStep = 0;
  1775. MXC_LeftFenZhen_VAVLE = 0;
  1776. }
  1777. break;
  1778. case 4:
  1779. if (MXC_LeftFenZhen_IN) //插针到位
  1780. MXC_cLeftFenZhenStep = 0;
  1781. else if (dwTickCount >= MXC_cFenZhenLeftDelay)
  1782. {
  1783. MXC_LeftFenZhen_VAVLE = 0; //左分针
  1784. cLFengTimer++;
  1785. if (cLFengTimer < 6)
  1786. {
  1787. MXC_cLeftFenZhenStep = 5;
  1788. MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime;
  1789. if ((cLFengTimer % 2) == 0)
  1790. {
  1791. MXC_RightFenZhen_VAVLE = 0;
  1792. MXC_cRightFenZhenStep = 0;
  1793. }
  1794. }
  1795. else
  1796. {
  1797. MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM);
  1798. MXC_cLeftFenZhenStep = 0;
  1799. MXC_LeftFenZhen_VAVLE = 0;
  1800. }
  1801. }
  1802. break;
  1803. //5-6重新下左分针
  1804. case 5:
  1805. if (MXC_LeftFenZhen_Origin_IN) //退到位
  1806. {
  1807. MXC_cLeftFenZhenStep = 6;
  1808. }
  1809. else if (dwTickCount >= MXC_cFenZhenLeftDelay)
  1810. {
  1811. MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM);
  1812. MXC_cLeftFenZhenStep = 0;
  1813. MXC_LeftFenZhen_VAVLE = 0;
  1814. }
  1815. break;
  1816. case 6:
  1817. if ((cLFengTimer % 2) == 0) //左边插两次都插不到,就退右边再同时插
  1818. {
  1819. MXC_cRightFenZhenStep = 1;
  1820. cRFengTimer = 0;
  1821. MXC_cLeftFenZhenStep = 0;
  1822. }
  1823. else
  1824. {
  1825. MXC_cLeftFenZhenStep = 1;
  1826. }
  1827. break;
  1828. }
  1829. }
  1830. //勾针复位定位动作
  1831. void MXC_NiLongXiuCiJi_GouZhenProc(void)
  1832. {
  1833. static unsigned char kk;
  1834. static unsigned long last_set_length;
  1835. long ch;
  1836. //当前勾针位置为脉冲位置加偏移量
  1837. MXC_Gouzhencurrent_L = dwRealPosY;
  1838. //DISPLAY_DATA7 = dwRealPosY;
  1839. if (!MXC_bRunning) //在手动状态下才点动勾针
  1840. {
  1841. if ((MXC_cXiaChongStep == 0) && (MXC_cGouZhenDWStep == 0))
  1842. {
  1843. //输入变化自动定位
  1844. if (last_set_length != MXC_SET_ZIPPER_LENGTH)
  1845. {
  1846. last_set_length = MXC_SET_ZIPPER_LENGTH;
  1847. if (MXC_USE_GZ_SERVO)
  1848. MXC_cGouZhenDWStep = 1;
  1849. //MXC_StartFirst=1;
  1850. kk = 0;
  1851. }
  1852. //勾针定位
  1853. if (MXC_GouZhenlocation)
  1854. {
  1855. MXC_GouZhenlocation = 0;
  1856. MXC_cGouZhenDWStep = 1;
  1857. MXC_StartFirst = 1;
  1858. kk = 0;
  1859. }
  1860. if (MXC_ShaChe)
  1861. {
  1862. MXC_ShaChe = 0;
  1863. if (!Y_DRV)
  1864. {
  1865. MXC_GouzhenShaChe = !MXC_GouzhenShaChe; //刹车取反
  1866. }
  1867. }
  1868. if (MXC_GouZhenforward && !MXC_GouZhenforward_IN && !Y_DRV) //勾针前移 限位开关不能输入
  1869. {
  1870. if (!MXC_GouzhenShaChe || !MXC_GouZhen_VAVLE)
  1871. MXC_cGouZhenMotorDelay = dwTickCount + 150;
  1872. MXC_GouzhenShaChe = 1; //刹车松开
  1873. //MXC_GouzhenMotor_DR = MXC_GZ_DIR_P;
  1874. MXC_GouZhen_VAVLE = 1;
  1875. MXC_cGouZhenTime = dwTickCount + 400;
  1876. kk = 0;
  1877. //先松开刹车延时动电机
  1878. if (dwTickCount >= MXC_cGouZhenMotorDelay)
  1879. {
  1880. if (!Y_DRV)
  1881. {
  1882. AxisContinueMoveAcc(Y_AXIS, MXC_GouzhenSpeed_Hand_SPEED, MXC_GZ_DIR_N, MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1883. }
  1884. }
  1885. }
  1886. if (MXC_GouZhenforward_IN)
  1887. {
  1888. MXC_GouZhenforward = 0;
  1889. }
  1890. if (MXC_GouZhenback && !MXC_GouZhenback_IN && !Y_DRV) //勾针后移 限位开关不能输入
  1891. {
  1892. if (!MXC_GouzhenShaChe || !MXC_GouZhen_VAVLE)
  1893. MXC_cGouZhenMotorDelay = dwTickCount + 150;
  1894. MXC_GouzhenShaChe = 1; //刹车松开
  1895. //MXC_GouzhenMotor_DR = MXC_GZ_DIR_N;
  1896. MXC_GouZhen_VAVLE = 1;
  1897. MXC_cGouZhenTime = dwTickCount + 400;
  1898. kk = 0;
  1899. //先松开刹车延时动电机
  1900. if (dwTickCount >= MXC_cGouZhenMotorDelay)
  1901. {
  1902. if (!Y_DRV)
  1903. {
  1904. AxisContinueMoveAcc(Y_AXIS, MXC_GouzhenSpeed_Hand_SPEED, MXC_GZ_DIR_P, MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1905. }
  1906. }
  1907. }
  1908. if (MXC_GouZhenback_IN || ((dwRealPosY >= GetData32bits(MXC_N_LIMIT_LENGTH_ADDR)) && !MXC_StartFirst))
  1909. {
  1910. MXC_GouZhenback = 0;
  1911. }
  1912. if ((!MXC_GouZhenforward && !MXC_GouZhenback) && (kk == 0))
  1913. {
  1914. if (Y_DRV)
  1915. {
  1916. if (MXC_GouzhenShaChe)
  1917. {
  1918. kk = 1;
  1919. MXC_cGouZhenMotorDelay = dwTickCount + 450;
  1920. }
  1921. }
  1922. AxisEgmStop(Y_AXIS); //立即停
  1923. MXC_GouZhenback = 0;
  1924. MXC_GouZhenforward = 0;
  1925. }
  1926. //电机停止后延时刹车
  1927. if (kk && (dwTickCount >= MXC_cGouZhenMotorDelay))
  1928. {
  1929. kk = 0;
  1930. MXC_GouzhenShaChe = 0; //刹车
  1931. }
  1932. }
  1933. }
  1934. switch (MXC_cGouZhenDWStep)
  1935. {
  1936. case 1:
  1937. MXC_cGouZhenMotorDelay = dwTickCount + 160;
  1938. MXC_GouZhen_VAVLE = 1;
  1939. MXC_GouzhenShaChe = 1; //刹车松开
  1940. MXC_cGouZhenDWStep = 2;
  1941. break;
  1942. case 2: //先回前点
  1943. if (dwTickCount >= MXC_cGouZhenMotorDelay)
  1944. {
  1945. if (!MXC_GouZhenforward_IN)
  1946. {
  1947. if ((!MXC_StartFirst))
  1948. {
  1949. offset_len = &MXC_SET_REVISE_ZIPPER_LENGTH;
  1950. ch = (MXC_SET_ZIPPER_LENGTH + MultLengthOffset(MXC_SET_ZIPPER_LENGTH) + (*offset_len) - MXC_GouzhenMin_Length); //算出脉冲
  1951. if (ch < 0)
  1952. {
  1953. MXC_SetAlarmCode(MXC_GOUZHEN_MIN_LENGTH_ALARM);
  1954. MXC_cGouZhenDWStep = 0;
  1955. }
  1956. else
  1957. {
  1958. ch = ch - MXC_Gouzhencurrent_L;
  1959. //DISPLAY_DATA1=ch;
  1960. //DISPLAY_DATA2=MXC_Gouzhencurrent_L;
  1961. // if(ch < 0)
  1962. // MXC_GouzhenMotor_DR = MXC_GZ_DIR_P;
  1963. // else
  1964. // MXC_GouzhenMotor_DR = MXC_GZ_DIR_N;
  1965. //
  1966. // SetDir(Y_AXIS,MXC_GouzhenMotor_DR);
  1967. AxisMovePos(Y_AXIS, MXC_GouzhenSpeed_Auto_SPEED, ch);
  1968. MXC_cGouZhenDWStep = 7;
  1969. }
  1970. }
  1971. else //等于0时就是第一次, 走手动速度
  1972. {
  1973. //MXC_GouzhenMotor_DR = MXC_GZ_DIR_P;
  1974. if (!Y_DRV)
  1975. AxisContinueMoveAcc(Y_AXIS, MXC_GouzhenSpeed_Hand_SPEED, MXC_GZ_DIR_N, MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0);
  1976. MXC_cGouZhenDWStep = 3;
  1977. }
  1978. }
  1979. else //已在原点直接后移
  1980. {
  1981. MXC_cGouZhenDWStep = 4;
  1982. MXC_GouzhenMotor_DR = MXC_GZ_DIR_N; //变为后移方向
  1983. }
  1984. }
  1985. break;
  1986. case 3:
  1987. if (MXC_GouZhenforward_IN) //感应前点 延时后移
  1988. {
  1989. MXC_cGouZhenDWStep = 4;
  1990. AxisEgmStop(Y_AXIS);
  1991. MXC_cGouZhenMotorDelay = dwTickCount + 50;
  1992. }
  1993. break;
  1994. case 4:
  1995. if (dwTickCount >= MXC_cGouZhenMotorDelay)
  1996. {
  1997. //MXC_GouzhenMotor_DR = MXC_GZ_DIR_N; //变为后移方向
  1998. ch = 5;
  1999. AxisContinueMoveAcc(Y_AXIS, ch, MXC_GZ_DIR_P, MXC_PARAM_START_SPEED, MXC_PARAM_ACC_SPEED, MXC_PARAM_DEC_SPEED, 0); //匀速离开零点位置
  2000. MXC_cGouZhenDWStep = 5;
  2001. }
  2002. break;
  2003. case 5:
  2004. if (!MXC_GouZhenforward_IN)
  2005. {
  2006. MXC_cGouZhenDWStep = 6;
  2007. AxisDecStop(Y_AXIS);
  2008. }
  2009. break;
  2010. case 6:
  2011. if (!Y_DRV)
  2012. {
  2013. SetPos(Y_AXIS, 0); //回到原点位置清零
  2014. //MXC_GouzhenMotor_DR = MXC_GZ_DIR_N; //变为后移方向
  2015. offset_len = &MXC_SET_REVISE_ZIPPER_LENGTH;
  2016. if ((MXC_SET_ZIPPER_LENGTH + (*offset_len) + MultLengthOffset(MXC_SET_ZIPPER_LENGTH)) >= MXC_GouzhenMin_Length)
  2017. {
  2018. ch = (MXC_SET_ZIPPER_LENGTH + (*offset_len) + MultLengthOffset(MXC_SET_ZIPPER_LENGTH) - MXC_GouzhenMin_Length); //算出脉冲
  2019. //SetDir(Y_AXIS,MXC_GouzhenMotor_DR);
  2020. AxisMovePos(Y_AXIS, MXC_GouzhenSpeed_Auto_SPEED, ch);
  2021. MXC_cGouZhenDWStep = 7;
  2022. }
  2023. else
  2024. {
  2025. MXC_SetAlarmCode(MXC_GOUZHEN_MIN_LENGTH_ALARM);
  2026. MXC_cGouZhenDWStep = 0;
  2027. }
  2028. }
  2029. break;
  2030. case 7:
  2031. if (!Y_DRV)
  2032. {
  2033. MXC_cGouZhenDWStep = 8;
  2034. MXC_cGouZhenMotorDelay = dwTickCount + 420;
  2035. }
  2036. else if ((MXC_GouzhenMotor_DR == MXC_GZ_DIR_N) && (MXC_GouZhenback_IN || ((dwRealPosY >= GetData32bits(MXC_N_LIMIT_LENGTH_ADDR)) && !MXC_StartFirst)))
  2037. {
  2038. AxisEgmStop(Y_AXIS); //立即停
  2039. MXC_cGouZhenDWStep = 8;
  2040. MXC_SetAlarmCode(MXC_GOUZHEN_MORE_ALARM);
  2041. MXC_cGouZhenMotorDelay = dwTickCount + 420;
  2042. }
  2043. break;
  2044. case 8:
  2045. if (dwTickCount >= MXC_cGouZhenMotorDelay)
  2046. {
  2047. MXC_GouzhenShaChe = 0; //刹车
  2048. MXC_cGouZhenDWStep = 0;
  2049. MXC_StartFirst = 0;
  2050. }
  2051. break;
  2052. }
  2053. }
  2054. #endif