XDChuantou_HeLian.c 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914
  1. #include "global.h"
  2. #if XI_DONG_MACHINE == 1
  3. void GL_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag);
  4. void GL_CTHL_ManualAction(void);
  5. void GL_CTHL_AutoStepAction(void);
  6. void GL_CTHL_TableAction(void);
  7. void GL_CTHL_TD_Motor(void);
  8. void GL_CTHL_CL_Motor(void);
  9. void GL_CTHL_CheckStart(void);
  10. void GL_CTHL_TLiao_Step(void); //推料(推拉头)
  11. void GL_CTHL_AlarmProtect(void);
  12. void GL_CTHL_ZLT_Step(void);
  13. void GL_CTHL_ZhenDongAction(void);
  14. void GL_CTHL_bFKCXTDDWStep(void);
  15. void GL_CTHL_bCXCRStep(void);
  16. void GL_CTHL_bCLFirstStep(void);
  17. void GL_CTHL_HeMo(void);
  18. void ExtiAcitionX02_CTHL(void)
  19. {
  20. if(bCheckEN_FLG)
  21. {
  22. bCheckEN_FLG = 0;
  23. GL_CTHL_CheckInX02PosBuff = GetPos(X_AXIS);
  24. }
  25. }
  26. //故障报警
  27. void GL_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag)
  28. {
  29. SetAlarmCode(GL_CTHL_ALARM_ADDR,alarm_code);
  30. // bAlarmStop = 0;
  31. // if(cStopFlag)
  32. if(!cWULATOUCnt)
  33. {
  34. bAlarmStop = 1;
  35. }
  36. else
  37. {
  38. cWULATOUCnt=0;
  39. }
  40. }
  41. //初始化动作
  42. void GL_CTHL_InitAction(void)
  43. {
  44. float buff_pulse,buff_dist;
  45. buff_pulse = GL_CTHL_PARAM_CYCLE_PULSE;
  46. buff_dist = GL_CTHL_PARAM_CYCLE_LENGTH;
  47. XGearRatio = buff_pulse/buff_dist;
  48. buff_pulse = GL_CTHL_PARAM_YCYCLE_PULSE;
  49. buff_dist = GL_CTHL_PARAM_YCYCLE_LENGTH;
  50. YGearRatio = buff_pulse/buff_dist;
  51. GL_CTHL_bZDP= 1;
  52. bYFirstDingWeiFlg = 1;
  53. user_datas[121] = 0;
  54. user_datas[122] = 0;
  55. user_datas[123] = 0;
  56. SetEnReverse(X_AXIS, 0);
  57. if(GL_CTHL_PARAM_Y_ENSelect == 1)
  58. SetEnReverse(Y_AXIS, 0);
  59. else
  60. SetEnReverse(Y_AXIS, 1);
  61. SetEnReverse(Z_AXIS, 0);
  62. SetDirReverse(X_AXIS, 0);
  63. SetDirReverse(Y_AXIS, 0);
  64. SetDirReverse(Z_AXIS, 0);
  65. SetEn(X_AXIS, MOTOR_DISEN);
  66. SetEn(Y_AXIS, MOTOR_DISEN);
  67. SetEn(Z_AXIS, MOTOR_DISEN);
  68. SetAlarmCode(GL_CTHL_ALARM_ADDR,0); //警告要清除
  69. GL_CTHL_bSFBBAOJIN_Delay = dwTickCount + 2000;
  70. GL_CTHL_X_EN_FLG=0;
  71. GL_CTHL_Y_EN_FLG=0;
  72. }
  73. void GL_CTHL_Action(void)
  74. {
  75. // user_datas[121] = GL_CTHL_ZhuangLiaoStep;
  76. // user_datas[122] =GL_CTHL_bXCBackOK;
  77. // user_datas[123] = GL_CTHL_X_CXPosBuff;
  78. dwXRealPos = GetPos(X_AXIS);
  79. dwYRealPos = GetPos(Y_AXIS);
  80. dwZRealPos = GetPos(Z_AXIS);
  81. user_datas[124] = dwXRealPos;
  82. user_datas[125] = GL_CTHL_RunStepSave;//dwYRealPos;
  83. user_datas[126] = dwYRealPos;//GL_CTHL_CL_MotorStep;
  84. user_datas[127] = GetEn(X_AXIS);//GL_CTHL_TD_MotorStep;
  85. user_datas[128] = GL_CTHL_TD_MotorStep;//GL_CTHL_AutoStep;
  86. GL_CTHL_ZhenDongAction();
  87. GL_CTHL_AlarmProtect();
  88. GL_CTHL_CheckStart();
  89. GL_CTHL_ZLT_Step();
  90. GL_CTHL_TLiao_Step();
  91. GL_CTHL_TD_Motor();
  92. GL_CTHL_CL_Motor();
  93. GL_CTHL_bFKCXTDDWStep();
  94. GL_CTHL_bCXCRStep();
  95. GL_CTHL_bCLFirstStep();
  96. GL_CTHL_HeMo();
  97. GL_CTHL_ManualAction();
  98. GL_CTHL_AutoStepAction();
  99. }
  100. void GL_CTHL_AlarmProtect(void)
  101. {
  102. }
  103. //自动动作
  104. void GL_CTHL_AutoStepAction(void)
  105. {
  106. if(bRunning && !bAlarmStop)
  107. {
  108. switch(GL_CTHL_AutoStep)
  109. {
  110. case 1:
  111. if(dwTickCount >= GL_CTHL_AutoDelay)
  112. {
  113. if(!GL_CTHL_XKSC_Limit_IN)
  114. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  115. GL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
  116. GL_CTHL_FKGD_VAVLE = 0; //方块固定关
  117. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  118. GL_CTHL_CXSX_VAVLE = 1; //插销上下
  119. else
  120. GL_CTHL_CXSX_VAVLE = 0; //插销顶出
  121. // GL_CTHL_XKDW_VAVLE = 1;
  122. GL_CTHL_AutoStep = 2;
  123. if(GL_CTHL_HLJJ_VAVLE)
  124. bCL_EN_FLG = 1;
  125. if(GL_CTHL_ZhuangLiaoStep == 0)
  126. {
  127. GL_CTHL_ZhuangLiaoStep = 1;
  128. GL_CTHL_TryCnt = 0;
  129. }
  130. }
  131. break;
  132. case 2:
  133. if((!GL_CTHL_XKTD_Origin_IN && GL_CTHL_XKTD_VAVLE) ||
  134. (!GL_CTHL_XKTD_VAVLE&& GL_CTHL_XKTD_Origin_IN)) //斜口推带原位离开
  135. {
  136. GL_CTHL_AutoStep = 3;
  137. if(GL_CTHL_cZipCnt== 0)
  138. {
  139. GL_CTHL_AutoDelay = dwTickCount + 180;
  140. }
  141. else
  142. GL_CTHL_AutoDelay = dwTickCount;
  143. }
  144. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  145. break;
  146. case 3://斜口定位
  147. if(dwTickCount >= GL_CTHL_AutoDelay)
  148. {
  149. //调试模式
  150. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  151. {
  152. GL_CTHL_bTiaoShiStep = 0;
  153. GL_CTHL_AutoStep = 4;
  154. GL_CTHL_XKDW_VAVLE = 1;
  155. if(GL_CTHL_cZipCnt== 0)
  156. GL_CTHL_AutoDelay = dwTickCount + 80;
  157. else
  158. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_XKDW_TD_DELAY;
  159. }
  160. }
  161. break;
  162. case 4:
  163. if(dwTickCount >= GL_CTHL_AutoDelay)
  164. {
  165. //调试模式
  166. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  167. {
  168. GL_CTHL_bTiaoShiStep = 0;
  169. if(!GL_CTHL_XKSC_Limit_IN)
  170. {
  171. // AxisContinueMoveAcc(X_AXIS,1000,DIR_P,800,600,10,10);//拖带电机
  172. SetPos(X_AXIS, 0); //启动位置设为0点
  173. dwXRealPos = 0;
  174. //AxisMovePosAccDecNotStop(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,250,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_XKDW_Speed,10,10,0);
  175. AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,DIR_P,GL_CTHL_PARAM_XKDW_Speed/2,GL_CTHL_PARAM_XKDW_Speed/2,10,10);//拖带电机
  176. GL_CTHL_bDinweiOK = 0;
  177. }
  178. GL_CTHL_AutoStep = 5;
  179. GL_CTHL_XSavePosBuff = dwXRealPos;
  180. }
  181. }
  182. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  183. break;
  184. case 5:
  185. if((dwXRealPos >= GL_CTHL_PARAM_WLCDSHEZHI_LENTH) && GL_CTHL_PARAM_WLCDSHEZHI_LENTH)
  186. {
  187. GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
  188. //无拉链自动停机
  189. }
  190. if(dwXRealPos > GL_CTHL_LianLengthAutoCheck+2000 && GL_CTHL_LianLengthAutoCheck && GL_CTHL_cZipCnt>0)
  191. {
  192. GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
  193. //无拉链自动停机
  194. }
  195. if(dwXRealPos>= 190)
  196. GL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸关
  197. if((dwXRealPos >= 280) && bCL_EN_FLG)
  198. GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
  199. if(GL_CTHL_XKSC_Limit_IN) //方块上止到位
  200. {
  201. if(bCL_EN_FLG)
  202. GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
  203. //AxisEgmStop(X_AXIS);
  204. GL_CTHL_GDXM_VAVLE = 1; //固定斜码
  205. GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸关
  206. GL_CTHL_bDinweiOK = 1;
  207. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  208. {
  209. if(((GL_CTHL_bTiaoShiMode) && (!GL_CTHL_bTiaoShiStep)))
  210. {
  211. AxisEgmStop(X_AXIS);
  212. }
  213. else if(GL_CTHL_PARAM_SCDW_LENTH==0)
  214. {
  215. AxisEgmStop(X_AXIS);
  216. }
  217. else
  218. {
  219. AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_SCDW_LENTH,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_XKDW_Speed,6,2,0); //
  220. }
  221. }
  222. else ////尼龙不用多走
  223. {
  224. AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,-25,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_XKDW_Speed,6,2,0);
  225. }
  226. //调试模式
  227. // if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  228. {
  229. GL_CTHL_bTiaoShiStep = 0;
  230. GL_CTHL_AutoStep = 6;
  231. //GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
  232. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  233. GL_CTHL_bLTCHECK_Delay = dwTickCount + 20;
  234. //电机穿入可以启动
  235. bCL_OK_FLG = 1; //不用穿合链的话认为已经完成
  236. if(bCL_EN_FLG)
  237. {
  238. bCL_OK_FLG = 0;
  239. GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
  240. GL_CTHL_CL_MotorStep = 1;
  241. GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HLJJ_CL_DELAY;
  242. }
  243. }
  244. }
  245. else if(dwXRealPos >= (GL_CTHL_XSavePosBuff + 850)) //750
  246. {
  247. AxisEgmStop(X_AXIS);
  248. GL_CTHL_SetAlarmCode(GL_CTHL_FKCXDW_ALARM,bRunning); //方块插销定位异常警告
  249. }
  250. break;
  251. case 6:
  252. // if(GL_CTHL_XKTD_Origin_IN) //斜口推带回到原位
  253. // {
  254. if(bZhuangLiaoOkFlg && (GL_CTHL_ZhuangLiaoStep == 0))
  255. {
  256. if(dwTickCount >= GL_CTHL_bLTCHECK_Delay)
  257. {
  258. //单一标志
  259. if(bSingOneFlg)
  260. {
  261. //次数到停止
  262. if(bSingOneCnt==0)
  263. {
  264. GL_CTHL_AutoStep = 0;
  265. bRunning = 0;
  266. }
  267. }
  268. if(!bSingOneFlg || (bSingOneFlg && bSingOneCnt))
  269. {
  270. //调试模式
  271. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  272. {
  273. GL_CTHL_bTiaoShiStep = 0;
  274. if(!GL_CTHL_LTou_Check)
  275. {
  276. // GL_CTHL_CTXMSS_VAVLE = 1; //穿头下模上升
  277. if(!GL_CTHL_CTXMSS_VAVLE)
  278. GL_CTHL_HeMoStep = 1; //下模的上升和下降电磁阀要配合
  279. GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
  280. GL_CTHL_AutoStep = 7;
  281. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  282. GL_CTHL_CXSX_VAVLE = 1; //插销上下
  283. //单一标准有效,次数减去1
  284. if(bSingOneFlg)
  285. {
  286. if(bSingOneCnt>0)
  287. bSingOneCnt--;
  288. }
  289. }
  290. else
  291. {
  292. cWULATOUCnt=1;
  293. GL_CTHL_SetAlarmCode(GL_CTHL_ZLT_ALARM,bRunning); // 没有拉头
  294. }
  295. }
  296. }
  297. }
  298. }
  299. // }
  300. // else if(dwTickCount >= GL_CTHL_AutoDelay)
  301. // {
  302. // GL_CTHL_SetAlarmCode(GL_CTHL_XKTD_Origin_ALARM,bRunning); //斜口推带回到异常
  303. // }
  304. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  305. break;
  306. case 7:
  307. if(!GL_CTHL_CTM_Origin_IN)
  308. {
  309. GL_CTHL_JLTou_VAVLE = 0; //接拉头
  310. }
  311. if(GL_CTHL_CTM_Limit_IN)
  312. {
  313. GL_CTHL_JLTou_VAVLE = 0;
  314. GL_CTHL_AutoStep = 8;
  315. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_DXK_DELAY;
  316. if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1)) //尼龙的顶斜口不能输出
  317. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  318. }
  319. else if(dwTickCount >= GL_CTHL_AutoDelay)
  320. {
  321. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Limit_ALARM,bRunning); //穿头下模上升异常
  322. }
  323. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  324. break;
  325. case 8:
  326. if(dwTickCount >= GL_CTHL_AutoDelay) //延时顶斜口
  327. {
  328. if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0) && (GL_CTHL_PARAM_QianMaSelect == 0))
  329. GL_CTHL_DXK_VAVLE = 1; //延时顶斜口
  330. GL_CTHL_AutoStep = 9;
  331. if(GL_CTHL_cZipCnt==0)
  332. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_DXK_XKDW_Off_DELAY+50;
  333. else
  334. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_DXK_XKDW_Off_DELAY;
  335. }
  336. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  337. break;
  338. case 9:
  339. if((dwTickCount >= GL_CTHL_AutoDelay)) //顶斜口延时退斜口上止定位
  340. {
  341. //调试模式
  342. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  343. {
  344. GL_CTHL_bTiaoShiStep = 0;
  345. GL_CTHL_XKDW_VAVLE = 0; //方块钩针
  346. GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸关
  347. GL_CTHL_AutoStep = 10;
  348. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_XK_CR_DELAY;
  349. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1)
  350. GL_CTHL_CXSX_VAVLE = 0; //插销顶出退
  351. }
  352. }
  353. break;
  354. case 10:
  355. if((dwTickCount >= GL_CTHL_AutoDelay) && !X_DRV && (bCL_OK_FLG))
  356. {
  357. //调试模式
  358. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  359. {
  360. GL_CTHL_bTiaoShiStep = 0;
  361. GL_CTHL_TD_MotorStep = 10; //启动拖带穿入
  362. GL_CTHL_AutoStep = 11;
  363. GL_CTHL_bXCBackOK = 0;
  364. GL_CTHL_AutoDelay = dwTickCount + 60;
  365. }
  366. }
  367. break;
  368. case 11:
  369. if((GL_CTHL_TD_MotorStep == 0) && bCL_OK_FLG) //穿入定位完成
  370. {
  371. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  372. GL_CTHL_CXSX_VAVLE = 1; //插销上下
  373. else
  374. GL_CTHL_CXSX_VAVLE = 0; //插销顶出
  375. /* //测试拖带定位
  376. GL_CTHL_AutoStep = 1;
  377. GL_CTHL_AutoDelay = dwTickCount + 1000;
  378. if(GL_CTHL_cZipCnt<3)
  379. GL_CTHL_cZipCnt++;
  380. break; */
  381. // if(START_IN_UP)
  382. // {
  383. //调试模式
  384. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  385. {
  386. GL_CTHL_bTiaoShiStep = 0;
  387. GL_CTHL_XKDW_VAVLE = 0; //方块钩针
  388. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  389. // if(GL_CTHL_PARAM_CR_MODE==0)
  390. GL_CTHL_CXSCDW_VAVLE = 1; //Y21 插销上止定位电磁阀
  391. if((GL_CTHL_CL_MotorStep == 0) && (GL_CTHL_SF_Origin_IN))
  392. {
  393. GL_CTHL_CXQJD_VAVLE = 1;
  394. //Y轴启动插销
  395. GL_CTHL_CL_MotorStep = 20; //插销定位
  396. GL_CTHL_BB_VAVLE=1;
  397. }
  398. GL_CTHL_AutoStep = 12;
  399. }
  400. }
  401. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  402. break;
  403. case 12:
  404. if(!GL_CTHL_bXCBackOK && (GL_CTHL_CL_MotorStep == 0) &&
  405. (GL_CTHL_SF_Origin_IN ))
  406. {
  407. GL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
  408. GL_CTHL_CL_MotorStep = 20; //插销定位
  409. GL_CTHL_BB_VAVLE=1;
  410. }
  411. if(!GL_CTHL_XKTD_Origin_IN)//) //插销前夹带回到原位
  412. {
  413. GL_CTHL_AutoStep = 14;
  414. GL_CTHL_AutoDelay = dwTickCount + 0;
  415. }
  416. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  417. break;
  418. case 14:
  419. if(dwTickCount >= GL_CTHL_AutoDelay)
  420. {
  421. GL_CTHL_AutoStep = 15;
  422. GL_CTHL_FKGD_VAVLE = 1; //方块固定
  423. // if(GL_CTHL_PARAM_CR_MODE==0)
  424. // GL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
  425. GL_CTHL_XKDW_VAVLE = 1; //方块勾针输出
  426. }
  427. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  428. break;
  429. case 15:
  430. if(!GL_CTHL_bXCBackOK && (GL_CTHL_CL_MotorStep == 0) &&
  431. (GL_CTHL_SF_Origin_IN ))
  432. {
  433. GL_CTHL_CXQJD_VAVLE = 1;
  434. GL_CTHL_CL_MotorStep = 20; //插销定位
  435. GL_CTHL_BB_VAVLE=1;
  436. }
  437. if((GL_CTHL_CL_MotorStep == 0) && GL_CTHL_bXCBackOK) //插销定位完成
  438. {
  439. //调试模式
  440. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  441. {
  442. GL_CTHL_bTiaoShiStep = 0;
  443. GL_CTHL_AutoStep = 16;
  444. GL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
  445. GL_CTHL_AutoDelay = dwTickCount + 2; //延时插销下移
  446. GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
  447. GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
  448. GL_CTHL_FKJD_VAVLE = 0;
  449. }
  450. }
  451. break;
  452. case 16:
  453. if(dwTickCount >= GL_CTHL_AutoDelay)
  454. {
  455. GL_CTHL_AutoStep = 17;
  456. GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
  457. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  458. GL_CTHL_CXSX_VAVLE = 0; //插销上下
  459. else
  460. GL_CTHL_CXSX_VAVLE = 1; //插销顶出
  461. // GL_CTHL_CXSX_VAVLE = 0; //Y06 插销下移电磁阀
  462. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
  463. }
  464. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  465. break;
  466. case 17:
  467. if(GL_CTHL_CXXY_Limit_IN)
  468. {
  469. //调试模式
  470. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  471. {
  472. GL_CTHL_bTiaoShiStep = 0;
  473. //GL_CTHL_XKDW_VAVLE = 1; //方块勾针输出
  474. GL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
  475. GL_CTHL_AutoStep = 18;
  476. if(GL_CTHL_LENTH>0 )
  477. {
  478. if(!GL_CTHL_bReStart)
  479. GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH;
  480. // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH,800,600,6,8,0);
  481. else
  482. GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH/3;
  483. // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH/3,800,600,6,8,0);
  484. }
  485. else
  486. {
  487. if(!GL_CTHL_bReStart)
  488. GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH + 300;
  489. // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH-300,800,600,6,8,0);
  490. else
  491. GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH/3+ 300;
  492. // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH/3-300,800,600,6,8,0);
  493. }
  494. user_datas[123] = GL_CTHL_LENCountBuff;//
  495. AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_LENCountBuff,800,600,6,8,0);
  496. GL_CTHL_bReStart = 0;
  497. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_CXCR_DELAY;
  498. cXcxcrCnt = 0;
  499. }
  500. }
  501. else if(dwTickCount >= GL_CTHL_AutoDelay)
  502. {
  503. GL_CTHL_SetAlarmCode(GL_CTHL_CXGL_Limit_ALARM,bRunning); //插销下移异常
  504. }
  505. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  506. break;
  507. case 18:
  508. // if(START_IN_UP)
  509. {
  510. if(dwTickCount >= GL_CTHL_AutoDelay)
  511. {
  512. GL_CTHL_AutoStep = 19;
  513. GL_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
  514. GL_CTHL_AutoDelay = dwTickCount + 500; //插销穿入到位异常时间
  515. GL_CTHL_CL_MotorStep = 50; //合链电机回原点
  516. }
  517. }
  518. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  519. break;
  520. case 19:
  521. if(GL_CTHL_CX_Limit_IN || (!GL_CTHL_CXDWZ_VAVLE && GL_CTHL_bTiaoShiMode))
  522. {
  523. //调试模式
  524. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  525. {
  526. GL_CTHL_bTiaoShiStep = 0;
  527. bZhuangLiaoOkFlg = 0;
  528. GL_CTHL_AutoStep = 20;
  529. GL_CTHL_BB_VAVLE=0;
  530. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_DELAY/2;//延时一次穿入
  531. }
  532. GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
  533. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1)
  534. GL_CTHL_CXSX_VAVLE = 0; //插销顶出
  535. }
  536. else if((dwTickCount >= GL_CTHL_AutoDelay) && GL_CTHL_CXDWZ_VAVLE)
  537. {
  538. cXcxcrCnt++;
  539. if(cXcxcrCnt >= 3)
  540. GL_CTHL_SetAlarmCode(GL_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
  541. else
  542. {
  543. GL_CTHL_CXHJD_VAVLE=0;
  544. GL_CTHL_AutoStep = 190;
  545. GL_CTHL_AutoDelay = dwTickCount + 100;
  546. }
  547. }
  548. break;
  549. case 190:
  550. if(dwTickCount >= GL_CTHL_AutoDelay)
  551. {
  552. GL_CTHL_AutoStep = 191;
  553. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)
  554. GL_CTHL_AutoDelay = dwTickCount + 100;
  555. }
  556. break;
  557. case 191:
  558. if(dwTickCount >= GL_CTHL_AutoDelay)
  559. {
  560. GL_CTHL_CXQJD_VAVLE = 1;
  561. GL_CTHL_CL_MotorStep = 20; //插销定位
  562. GL_CTHL_bXCBackOK=0;
  563. GL_CTHL_AutoStep = 192;
  564. }
  565. break;
  566. case 192:
  567. if((GL_CTHL_CL_MotorStep == 0) && GL_CTHL_bXCBackOK)
  568. {
  569. GL_CTHL_AutoStep = 18;
  570. GL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
  571. GL_CTHL_CXHJD_VAVLE=1;
  572. GL_CTHL_AutoDelay = dwTickCount + 100;
  573. }
  574. break;
  575. case 20:
  576. if( GL_CTHL_FKGD_VAVLE)//方块固定退
  577. {
  578. if(dwTickCount >= GL_CTHL_AutoDelay)
  579. {
  580. GL_CTHL_FKGD_VAVLE = 0;
  581. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_DELAY/2;//延时一次穿入
  582. }
  583. }
  584. else
  585. {
  586. if(dwTickCount >= GL_CTHL_AutoDelay)
  587. {
  588. GL_CTHL_AutoStep = 21;
  589. GL_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
  590. GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带打开
  591. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  592. }
  593. }
  594. break;
  595. case 21:
  596. if(!GL_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
  597. {
  598. // GL_CTHL_LENCountBuff
  599. // AxisMovePosAccDec(X_AXIS,5000,GL_CTHL_PARAM_TDFZ_LENTH*4/5,1500,800,6,6,0);
  600. GL_CTHL_AutoStep = 22;
  601. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_Timer/2; //一次穿入时间
  602. }
  603. else if(dwTickCount >= GL_CTHL_AutoDelay)
  604. {
  605. GL_CTHL_SetAlarmCode(GL_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
  606. }
  607. break;
  608. case 22:
  609. if(dwTickCount >= GL_CTHL_AutoDelay)
  610. {
  611. GL_CTHL_AutoStep = 23;
  612. GL_CTHL_LENCountBuff = GL_CTHL_LENCountBuff * 2/5;
  613. // if(GL_CTHL_LENCountBuff > 150)
  614. AxisMovePosAccDec(X_AXIS,3500,GL_CTHL_LENCountBuff,800,800,6,6,0);
  615. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_Timer/2; //一次穿入时间
  616. }
  617. break;
  618. case 23:
  619. if(dwTickCount >= GL_CTHL_AutoDelay)
  620. {
  621. //调试模式
  622. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  623. {
  624. GL_CTHL_bTiaoShiStep = 0;
  625. GL_CTHL_AutoStep = 24;
  626. GL_CTHL_MGuo_VAVLE = 0; //码勾退
  627. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_MGOff_XiaMo_DELAY;
  628. }
  629. }
  630. break;
  631. case 24:
  632. if(dwTickCount >= GL_CTHL_AutoDelay)
  633. {
  634. GL_CTHL_AutoStep = 25;
  635. GL_CTHL_HeMoStep = 10; //下模的上升和下降电磁阀要配合
  636. GL_CTHL_CTXMSS_VAVLE = 0; //穿头下模退
  637. GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  638. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
  639. GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸输出
  640. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  641. GL_CTHL_FKGD_VAVLE = 0; //方块固定关
  642. GL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
  643. }
  644. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  645. break;
  646. case 25:
  647. if(!GL_CTHL_CTM_Limit_IN)
  648. {
  649. GL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
  650. GL_CTHL_AutoStep = 26;
  651. GL_CTHL_AutoDelay = dwTickCount + 3; //一次穿入延时返回
  652. }
  653. else if(dwTickCount >= GL_CTHL_AutoDelay)
  654. {
  655. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning);//穿头下模下降异常
  656. }
  657. break;
  658. case 26:
  659. if(dwTickCount >= GL_CTHL_AutoDelay)
  660. {
  661. GL_CTHL_AutoStep = 27;
  662. // GL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
  663. GL_CTHL_AutoDelay = dwTickCount + 0;
  664. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
  665. GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸输出
  666. //退下出错警告
  667. GL_CTHL_AutoDelay1 = dwTickCount + 25;
  668. GL_CTHL_AutoStep1 = 1;
  669. }
  670. break;
  671. case 27:
  672. if(dwTickCount >= GL_CTHL_AutoDelay)
  673. {
  674. //调试模式
  675. if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
  676. {
  677. GL_CTHL_bTiaoShiStep = 0;
  678. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  679. GL_CTHL_FKGD_VAVLE = 0; //方块固定关
  680. GL_CTHL_AutoStep = 2;
  681. bCL_EN_FLG = 1;
  682. // cXcxcrCnt=0;
  683. AddToTal(GL_CTHL_TOTAL_ADDR);
  684. AddToTal(GL_CTHL_WORK_TOTAL_ADDR);
  685. AddToTal(GL_CTHL_CUR_TOTAL_ADDR);
  686. CalProSP(GL_CTHL_SPEED_ADDR);
  687. if(GL_CTHL_cZipCnt<3)
  688. GL_CTHL_cZipCnt++;
  689. }
  690. }
  691. break;
  692. }
  693. GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
  694. }
  695. //退下模后启动送拉头
  696. switch(GL_CTHL_AutoStep1)
  697. {
  698. case 1:
  699. if(cStopMode==1)
  700. {
  701. cStopMode=2;
  702. bStop=1;
  703. }
  704. if(GL_CTHL_First_CT_VAVLE)
  705. {
  706. if(dwTickCount >= GL_CTHL_AutoDelay1)
  707. {
  708. GL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
  709. GL_CTHL_AutoDelay1 = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  710. }
  711. }
  712. else
  713. {
  714. if(GL_CTHL_CTM_Origin_IN && GL_CTHL_First_CT_Origin_IN)
  715. {
  716. GL_CTHL_ZhuangLiaoStep = 1;
  717. GL_CTHL_TryCnt = 0;
  718. GL_CTHL_AutoStep1 = 0;
  719. GL_CTHL_MGuo_VAVLE = 0;
  720. GL_CTHL_JLTou_VAVLE = 0;
  721. if(!bRunning) //在调机状态下先判断有没有料
  722. {
  723. GL_CTHL_MGuo_VAVLE = 1;
  724. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 100;
  725. bZhuangLiaoOkFlg = 0;
  726. }
  727. }
  728. else if(dwTickCount >= GL_CTHL_AutoDelay1)
  729. {
  730. //穿头模和一次穿入回位异常
  731. if(!GL_CTHL_CTM_Origin_IN)
  732. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning);
  733. else if(!GL_CTHL_First_CT_Origin_IN)
  734. GL_CTHL_SetAlarmCode(GL_CTHL_First_CT_Origin_ALARM,bRunning);
  735. }
  736. }
  737. break;
  738. }
  739. }
  740. void GL_CTHL_CheckStart(void)
  741. {
  742. /*
  743. if(cWULATOUCnt) // 无拉头警告后按
  744. {
  745. if(GL_CTHL_START_IN_UP)
  746. {
  747. if(!bRunning)
  748. {
  749. if(GL_CTHL_SafeDoor_IN)
  750. {
  751. bRunning=1;
  752. GL_CTHL_TryCnt=0;
  753. cWULATOUCnt=0;
  754. GL_CTHL_ZhuangLiaoStep = 1;
  755. GL_CTHL_AutoStep=6;
  756. bTuiLaTouOkFlg = 1;
  757. bZhuangLiaoOkFlg= 0;
  758. GL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
  759. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
  760. }
  761. else
  762. {
  763. GL_CTHL_SetAlarmCode(GL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
  764. }
  765. }
  766. }
  767. }
  768. */
  769. //启动 自动启动 单一自动
  770. if(GL_CTHL_START_IN_UP || bStart || GL_CTHL_bOnceStart)
  771. {
  772. //单一启动
  773. if(GL_CTHL_bOnceStart)
  774. {
  775. GL_CTHL_bOnceStart=0;
  776. bSingOneFlg=1;//一次标志
  777. bSingOneCnt=1;//走完一条
  778. }
  779. else
  780. {
  781. bSingOneFlg=0;
  782. bSingOneCnt=0;
  783. }
  784. if(!bRunning)
  785. {
  786. if(GL_CTHL_SafeDoor_IN)
  787. {
  788. GL_CTHL_CXDW_Stop = 0;
  789. cStopMode=0;
  790. bRunning = 1;
  791. cWULATOUCnt=0;
  792. GL_CTHL_CL_MotorStep = 40;
  793. bZhuangLiaoOkFlg= 0;
  794. GL_CTHL_SongDai_Step=1;
  795. GL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
  796. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 180;
  797. GL_CTHL_LianLengthCheck = 0;
  798. GL_CTHL_LianLengthAutoCheck = 0;
  799. GL_CTHL_cZipCnt = 0;
  800. bTuiLaTouOkFlg = 1;
  801. bCL_EN_FLG = 0;
  802. cStopInCnt = 0;
  803. GL_CTHL_CTXMXJ_VAVLE = 0;
  804. GL_CTHL_bReStart = 0;
  805. //装料启动一次,保证下模已在原位(下面)
  806. if((GL_CTHL_ZhuangLiaoStep == 0) && !GL_CTHL_CTXMSS_VAVLE && GL_CTHL_CTM_Origin_IN)
  807. {
  808. GL_CTHL_ZhuangLiaoStep = 1;
  809. GL_CTHL_TryCnt = 0;
  810. }
  811. //已经定位好,并且保持在原位
  812. if(GL_CTHL_bDinweiOK && GL_CTHL_XKSC_Limit_IN && GL_CTHL_XKDW_VAVLE
  813. && GetEn(X_AXIS) && (GL_CTHL_RunStepSave != 19))
  814. {
  815. SetPos(X_AXIS, 0);
  816. GL_CTHL_GDXM_VAVLE = 1;
  817. GL_CTHL_AutoStep = 5;
  818. GL_CTHL_XSavePosBuff = 0;
  819. } //穿插销不到位停止
  820. else if(((GL_CTHL_RunStepSave == 19) || (GL_CTHL_RunStepSave == 190) || (GL_CTHL_RunStepSave == 191))
  821. && GL_CTHL_CXHJD_VAVLE && GL_CTHL_CXHDW_VAVLE
  822. && GL_CTHL_CTXMSS_VAVLE && GL_CTHL_CXDWZ_VAVLE)
  823. {
  824. if(GL_CTHL_CX_Limit_IN)
  825. {
  826. GL_CTHL_AutoStep = 19;
  827. }
  828. else
  829. {
  830. GL_CTHL_AutoStep = 16;
  831. GL_CTHL_bReStart = 1;
  832. GL_CTHL_AutoDelay = dwTickCount + 100;
  833. GL_CTHL_CXHJD_VAVLE = 0;
  834. GL_CTHL_CXHDW_VAVLE = 0;
  835. }
  836. }
  837. else
  838. {
  839. GL_CTHL_AutoStep = 1;
  840. GL_CTHL_AutoDelay = dwTickCount + 180;
  841. }
  842. GL_CTHL_cZipCnt = 0;
  843. SetEn(X_AXIS, MOTOR_EN);
  844. SetEn(Y_AXIS, MOTOR_EN);
  845. SetAlarmCode(GL_CTHL_ALARM_ADDR,0);
  846. }
  847. else
  848. {
  849. GL_CTHL_SetAlarmCode(GL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
  850. }
  851. }
  852. bStart = 0;
  853. }
  854. if(bStop)
  855. {
  856. bStop=0;
  857. bSingOneFlg=1;
  858. bSingOneCnt=0;
  859. }
  860. //停止
  861. if(GL_CTHL_STOP_IN_UP)
  862. {
  863. if(cStopMode < 2)
  864. cStopMode++;
  865. if(bRunning)
  866. {
  867. GL_CTHL_CXDW_Stop = 0;
  868. cStopMode=0;
  869. cXcxcrCnt=0;
  870. cWULATOUCnt=0;
  871. if(GL_CTHL_XKSC_Limit_IN)
  872. AxisEgmStop(X_AXIS);
  873. else
  874. AxisDecStop(X_AXIS);
  875. AxisEgmStop(Y_AXIS);
  876. GL_CTHL_AutoStep = 0;
  877. GL_CTHL_CL_MotorStep =0;
  878. GL_CTHL_SongDai_Step=0;
  879. GL_CTHL_HLJJ_VAVLE = 0;
  880. GL_CTHL_bCLFirst_Step=0;
  881. if(!GL_CTHL_bDinweiOK)
  882. GL_CTHL_XKDW_VAVLE =0;
  883. SetAlarmCode(GL_CTHL_ALARM_ADDR,0);
  884. bRunning=0;
  885. }
  886. else if(!bRunning)
  887. {
  888. bRunning=0;
  889. cXcxcrCnt=0;
  890. cStopMode=0;
  891. cWULATOUCnt=0;
  892. AxisEgmStop(X_AXIS);
  893. AxisEgmStop(Y_AXIS);
  894. SetEn(X_AXIS, MOTOR_DISEN);
  895. SetEn(Y_AXIS, MOTOR_DISEN);
  896. cStopMode=0;
  897. GL_CTHL_bDinweiOK = 0;
  898. if(GetAlarm(X_AXIS)==MOTOR_ALARM || GetAlarm(Y_AXIS)==MOTOR_ALARM )
  899. {
  900. SetClr(X_AXIS,ALARM_CLR);
  901. GL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 200;
  902. }
  903. GL_CTHL_TLiao_VAVLE=0;
  904. if(!GL_CTHL_HSLiao_VAVLE || !GL_CTHL_MGuo_VAVLE)
  905. GL_CTHL_JLTou_VAVLE =0;
  906. GL_CTHL_HSLiao_VAVLE =0;
  907. GL_CTHL_XKTD_VAVLE =0;
  908. GL_CTHL_XKDW_VAVLE =0;
  909. GL_CTHL_DXK_VAVLE =0;
  910. GL_CTHL_GDXM_VAVLE = 0;
  911. GL_CTHL_CXSX_VAVLE =0;
  912. GL_CTHL_First_CT_VAVLE =0;
  913. GL_CTHL_FKGD_VAVLE =0;
  914. GL_CTHL_CXQJD_VAVLE =0;
  915. GL_CTHL_CXDWZ_VAVLE =0;
  916. GL_CTHL_CXHJD_VAVLE =0;
  917. GL_CTHL_CXHDW_VAVLE =0;
  918. GL_CTHL_FKJD_VAVLE =0;
  919. GL_CTHL_HLJJ_VAVLE =0;
  920. GL_CTHL_BB_VAVLE=0;
  921. //GL_CTHL_CXHT_VAVLE = 0;
  922. GL_CTHL_CXSCDW_VAVLE =0;
  923. if((GL_CTHL_CTXMSS_VAVLE) || (GL_CTHL_CTM_Origin_IN && !GL_CTHL_CTXMSS_VAVLE))
  924. GL_CTHL_MGuo_VAVLE =0;
  925. if(GL_CTHL_CTXMSS_VAVLE || !GL_CTHL_CTM_Origin_IN)
  926. {
  927. GL_CTHL_HeMoStep = 10;
  928. }
  929. else if(!GL_CTHL_CTXMSS_VAVLE && !GL_CTHL_CTM_Limit_IN)
  930. GL_CTHL_CTXMXJ_VAVLE = 1;
  931. GL_CTHL_CTXMSS_VAVLE =0;
  932. GL_CTHL_AutoStep = 0;
  933. GL_CTHL_ZhuangLiaoStep=0;
  934. GL_CTHL_TLiaoStep=0;
  935. GL_CTHL_TD_MotorStep=0;
  936. GL_CTHL_JiaLianStep =0;
  937. // GL_CTHL_ZhenDongStep =0;
  938. GL_CTHL_SongLiaoStep =0;
  939. GL_CTHL_CL_MotorStep =0;
  940. GL_CTHL_AutoStep1 =0;
  941. GL_CTHL_bFKCXTDDW_Step=0;
  942. GL_CTHL_bCXCR_Step=0;
  943. GL_CTHL_bCLFirst_Step=0;
  944. GL_CTHL_RunStepSave = 0;
  945. GL_CTHL_SongDai_Step=0;
  946. SetAlarmCode(GL_CTHL_ALARM_ADDR,0);
  947. SetPos(X_AXIS, 0);
  948. // if(cStopInCnt < 3)
  949. // cStopInCnt++;
  950. // if(bStop)
  951. // cStopInCnt = 0;
  952. GL_CTHL_TLiaoStep = 0;
  953. GL_CTHL_AutoStep = 0;
  954. GL_CTHL_CXDW_Stop = 0;
  955. //穿合链电机是往零点方向时可以停止
  956. // if((GetDir(Y_AXIS) == DIR_N) && GL_CTHL_SF_Origin_IN)
  957. // AxisEgmStop(Y_AXIS);
  958. // if(GL_CTHL_SF_ALR_IN || GL_CTHL_Y_SF_ALR_IN)
  959. // {
  960. // //SetEn(Z_AXIS, MOTOR_EN); //清伺服警告
  961. // GL_CTHL_ALARMCLR_VAVLE=1;
  962. // GL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 200;
  963. // }
  964. /* if(cStopInCnt > 1)
  965. {
  966. GL_CTHL_CL_MotorStep = 0;
  967. AxisEgmStop(Y_AXIS);
  968. GL_CTHL_ZhuangLiaoStep = 0;
  969. }
  970. else
  971. {
  972. GL_CTHL_TD_MotorStep = 0;
  973. SetEn(X_AXIS, MOTOR_DISEN);
  974. SetEn(Y_AXIS, MOTOR_DISEN);
  975. GL_CTHL_bFKCXTDDW_Step = 0;
  976. GL_CTHL_bCXCR_Step = 0;
  977. GL_CTHL_bCLFirst_Step = 0;
  978. }*/
  979. }
  980. bStop=0;
  981. }
  982. if(bAlarmStop)
  983. {
  984. bRunning = 0;
  985. bAlarmStop=0;
  986. cStopMode=0;
  987. cXcxcrCnt=0;
  988. if(GetAlarmCode(GL_CTHL_ALARM_ADDR) == GL_CTHL_SF_ALR_ALARM)
  989. GL_CTHL_X_EN_FLG=0;
  990. if(GetAlarmCode(GL_CTHL_ALARM_ADDR) == GL_CTHL_Y_SF_ALR_ALARM)
  991. GL_CTHL_Y_EN_FLG=0;
  992. AxisDecStop(X_AXIS);
  993. AxisEgmStop(Y_AXIS);
  994. if(GL_CTHL_CXSC_Limit_IN)
  995. {
  996. AxisEgmStop(X_AXIS);
  997. }
  998. GL_CTHL_AutoStep = 0;
  999. GL_CTHL_CL_MotorStep =0;
  1000. GL_CTHL_bCLFirst_Step=0;
  1001. GL_CTHL_SongLiaoStep =0;
  1002. GL_CTHL_ZhuangLiaoStep=0;
  1003. GL_CTHL_SongDai_Step=0;
  1004. }
  1005. }
  1006. //拖带电机控制动作 X轴
  1007. void GL_CTHL_TD_Motor(void) //
  1008. {
  1009. #if 1
  1010. switch(GL_CTHL_TD_MotorStep)
  1011. {
  1012. //1步开始,纯定位, 没有穿入
  1013. case 1:
  1014. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1015. if(dwTickCount >= GL_CTHL_TD_MotorDelay) //给锁轴时间
  1016. {
  1017. GL_CTHL_bTest = 0;
  1018. bCheckEN_FLG = 1;
  1019. GL_CTHL_CheckInX02PosBuff= 0;
  1020. GL_CTHL_TD_MotorStep = 2;
  1021. SetPos(X_AXIS, 0); //启动位置设为0点
  1022. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0) //尼龙
  1023. AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,DIR_P,800,600,15,15);
  1024. else
  1025. AxisContinueMoveAcc(X_AXIS,4000,DIR_P,800,600,15,15);
  1026. }
  1027. break;
  1028. case 2://检测到过链
  1029. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1030. if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)//200) //穿入2CM后退
  1031. {
  1032. GL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
  1033. GL_CTHL_GDXM_VAVLE = 0;
  1034. if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1))//尼龙
  1035. GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸输出
  1036. }
  1037. if((dwXRealPos >= GL_CTHL_PARAM_WLCDSHEZHI_LENTH) && GL_CTHL_PARAM_WLCDSHEZHI_LENTH)
  1038. {
  1039. GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  1040. }
  1041. if((dwXRealPos > (GL_CTHL_LianLengthAutoCheck+2000)) && GL_CTHL_LianLengthAutoCheck && GL_CTHL_cZipCnt>1)
  1042. {
  1043. GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
  1044. //无拉链自动停机
  1045. }
  1046. if(GL_CTHL_FK_Check)
  1047. {
  1048. // user_datas[122] = dwXRealPos;
  1049. GL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
  1050. if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1)) //尼龙
  1051. GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸输出
  1052. GL_CTHL_GDXM_VAVLE = 0;
  1053. GL_CTHL_XSavePosBuff = dwXRealPos;
  1054. GL_CTHL_TD_MotorStep = 3;
  1055. // user_datas[123] = dwXRealPos - GL_CTHL_CheckInX02PosBuff;
  1056. if((dwXRealPos >= GL_CTHL_CheckInX02PosBuff) && GL_CTHL_CheckInX02PosBuff)
  1057. AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,GL_CTHL_PARAM_FKDW_Length - (dwXRealPos- GL_CTHL_CheckInX02PosBuff),
  1058. GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed/2,10,50,100);
  1059. else
  1060. AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,GL_CTHL_PARAM_FKDW_Length,
  1061. GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed/2,10,50,100);
  1062. }
  1063. if(GL_CTHL_CXSC_Limit_IN_UP)
  1064. {
  1065. GL_CTHL_X_CXPosBuff = dwXRealPos;
  1066. // if(GL_CTHL_PARAM_CR_MODE==0)
  1067. // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1068. }
  1069. break;
  1070. case 3:
  1071. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1072. if(GL_CTHL_CXSC_Limit_IN_UP && !GL_CTHL_bTest)
  1073. {
  1074. GL_CTHL_bTest = 1;
  1075. GL_CTHL_X_CXPosBuff = dwXRealPos;
  1076. user_datas[123] = GL_CTHL_X_CXPosBuff;
  1077. }
  1078. if(!X_DRV || (dwXRealPos >= (GL_CTHL_XSavePosBuff + GL_CTHL_PARAM_FKDW_Length)))
  1079. {
  1080. AxisEgmStop(X_AXIS);
  1081. GL_CTHL_TD_MotorStep =4 ;
  1082. GL_CTHL_LianLengthAutoCheckOLD = GL_CTHL_LianLengthAutoCheck;
  1083. GL_CTHL_LianLengthAutoCheck = dwXRealPos;
  1084. }
  1085. break;
  1086. case 4:
  1087. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1088. if(GL_CTHL_PARAM_XCX_LENTH) //0的话不判断位置
  1089. {
  1090. // if(GL_CTHL_PARAM_CR_MODE==0)
  1091. // {
  1092. if ((dwXRealPos - GL_CTHL_X_CXPosBuff) > (GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_XCXWC_LENTH))
  1093. {
  1094. user_datas[121] = 1;
  1095. GL_CTHL_TD_MotorStep = 0;
  1096. GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1097. }
  1098. else if((dwXRealPos - GL_CTHL_X_CXPosBuff) < (GL_CTHL_PARAM_XCX_LENTH - GL_CTHL_PARAM_XCXWC_LENTH))
  1099. {
  1100. user_datas[121] = 2;
  1101. GL_CTHL_TD_MotorStep = 0;
  1102. GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1103. }
  1104. else if(GL_CTHL_X_CXPosBuff == 0)
  1105. {
  1106. user_datas[121] = 3;
  1107. GL_CTHL_TD_MotorStep = 0;
  1108. GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1109. }
  1110. else
  1111. {
  1112. GL_CTHL_TD_MotorStep = 0;
  1113. }
  1114. // }
  1115. // else
  1116. // {
  1117. // if(GL_CTHL_X_CXPosBuff == 0)
  1118. // {
  1119. // user_datas[121] = 3;
  1120. // GL_CTHL_TD_MotorStep = 0;
  1121. // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1122. // }
  1123. // else
  1124. // {
  1125. // GL_CTHL_TD_MotorStep = 0;
  1126. // }
  1127. // }
  1128. }
  1129. else
  1130. {
  1131. GL_CTHL_TD_MotorStep = 0;
  1132. }
  1133. break;
  1134. //穿拉头定位
  1135. case 10:
  1136. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1137. if(dwTickCount >= GL_CTHL_TD_MotorDelay)
  1138. {
  1139. GL_CTHL_TD_MotorStep = 11;
  1140. SetPos(X_AXIS, 0); //启动位置设为0点
  1141. dwXRealPos = 0;
  1142. AxisContinueMoveAcc(X_AXIS,4000,DIR_P,800,1200,18,5);
  1143. GL_CTHL_CheckInX02PosBuff= 0;
  1144. bCheckEN_FLG = 1;
  1145. GL_CTHL_X_CXPosBuff = 0;
  1146. GL_CTHL_bTest = 0;
  1147. GL_CTHL_X_FKCheckPos = 0;
  1148. user_datas[121] = 0;
  1149. }
  1150. break;
  1151. case 11:
  1152. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1153. if(dwXRealPos > 150) //穿入2CM后退
  1154. {
  1155. if((GL_CTHL_cZipCnt < 2) || (GL_CTHL_LianLengthCheck < 350))
  1156. {
  1157. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  1158. AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,DIR_P,3000,600,10,10);
  1159. else
  1160. AxisContinueMoveAcc(X_AXIS,6000,DIR_P,3000,600,10,10);
  1161. }
  1162. else ////两段速度移动距离
  1163. {
  1164. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  1165. AxisMovePosAccDecNotStop(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed + GL_CTHL_PARAM_TD_RunSpeed/3,GL_CTHL_LianLengthCheck-350,3000,8500,10,20,0);
  1166. else
  1167. AxisMovePosAccDecNotStop(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed + GL_CTHL_PARAM_TD_RunSpeed/3,GL_CTHL_LianLengthCheck-450,3000,7000,10,20,0);
  1168. }
  1169. GL_CTHL_TD_MotorStep = 12;
  1170. }
  1171. break;
  1172. case 12:
  1173. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1174. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT)
  1175. {
  1176. if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)
  1177. {
  1178. GL_CTHL_CheckInX02PosBuff= 0;
  1179. GL_CTHL_GDXM_VAVLE = 0;
  1180. GL_CTHL_TD_MotorStep = 13;
  1181. }
  1182. }
  1183. else
  1184. {
  1185. if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)
  1186. {
  1187. GL_CTHL_CheckInX02PosBuff= 0;
  1188. GL_CTHL_GDXM_VAVLE = 0;
  1189. GL_CTHL_TD_MotorStep = 13;
  1190. }
  1191. }
  1192. break;
  1193. case 13://检测到过链
  1194. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1195. if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)//400)
  1196. {
  1197. GL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
  1198. if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1)) //尼龙
  1199. GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸输出
  1200. }
  1201. if((dwXRealPos >= GL_CTHL_PARAM_WLCDSHEZHI_LENTH) && GL_CTHL_PARAM_WLCDSHEZHI_LENTH)
  1202. {
  1203. GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
  1204. // AxisDecStop(X_AXIS);
  1205. GL_CTHL_TD_MotorStep = 0;
  1206. user_datas[121] = 10;
  1207. AxisMovePosAccDec(X_AXIS,2000,600,
  1208. GL_CTHL_PARAM_FKDW_Speed,1000,10,50,20);
  1209. }
  1210. if((dwXRealPos > (GL_CTHL_LianLengthAutoCheck+7000)) && GL_CTHL_LianLengthAutoCheck && GL_CTHL_cZipCnt>0)
  1211. {
  1212. GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
  1213. AxisDecStop(X_AXIS);
  1214. GL_CTHL_TD_MotorStep = 0;
  1215. user_datas[121] = 11;
  1216. AxisMovePosAccDec(X_AXIS,2000,600,
  1217. GL_CTHL_PARAM_FKDW_Speed,1000,10,50,20);
  1218. break;
  1219. //无拉链自动停机
  1220. }
  1221. if(GL_CTHL_FK_Check)
  1222. {
  1223. user_datas[122] = GetCurSpeed(X_AXIS);//dwXRealPos;
  1224. GL_CTHL_LianLengthCheckReal=dwXRealPos;
  1225. if(GL_CTHL_cZipCnt == 1)
  1226. GL_CTHL_LianLengthCheck = dwXRealPos;
  1227. //break;
  1228. GL_CTHL_X_FKCheckPos = dwXRealPos + GL_CTHL_PARAM_FKDW_Length;
  1229. GL_CTHL_TD_MotorStep = 14;
  1230. // if(GetCurSpeed(X_AXIS) <= 10000)
  1231. // user_datas[122] = GL_CTHL_PARAM_FKDW_Length - (dwXRealPos- GL_CTHL_CheckInX02PosBuff);
  1232. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  1233. AxisMovePosAccDec(X_AXIS,8500,GL_CTHL_PARAM_FKDW_Length,
  1234. GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed,10,50,20);
  1235. else //尼龙
  1236. AxisMovePosAccDec(X_AXIS,8500,GL_CTHL_PARAM_FKDW_Length,
  1237. GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed,10,50,20);
  1238. // else
  1239. // AxisMovePosAccDec(X_AXIS,8000,GL_CTHL_PARAM_FKDW_Length-20,
  1240. // GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed,10,35,30);
  1241. //GL_CTHL_TD_MotorStep = 0;
  1242. }
  1243. //方块还没有感应之前感应到插销的话,肯定错位
  1244. if(GL_CTHL_CXSC_Limit_IN_UP)
  1245. {
  1246. user_datas[121] = 4;
  1247. GL_CTHL_X_CXPosBuff = dwXRealPos;
  1248. // if(GL_CTHL_PARAM_CR_MODE==0)
  1249. // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1250. }
  1251. break;
  1252. case 14:
  1253. GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
  1254. if((dwXRealPos+350 >= GL_CTHL_X_FKCheckPos) && bRunning)
  1255. {
  1256. GL_CTHL_FKJD_VAVLE = 1;
  1257. }
  1258. if(GL_CTHL_CXSC_Limit_IN_UP && !GL_CTHL_bTest)
  1259. {
  1260. GL_CTHL_bTest = 1;
  1261. GL_CTHL_X_CXPosBuff = dwXRealPos;
  1262. user_datas[123] = GL_CTHL_X_CXPosBuff;
  1263. user_datas[121] = 128;
  1264. }
  1265. if((!X_DRV ) || (dwXRealPos >= (GL_CTHL_X_FKCheckPos)))
  1266. {
  1267. // user_datas[123] = dwXRealPos-GL_CTHL_CheckInX02PosBuff;
  1268. AxisEgmStop(X_AXIS);
  1269. GL_CTHL_TD_MotorStep = 15;
  1270. GL_CTHL_LianLengthAutoCheckOLD = GL_CTHL_LianLengthAutoCheck;
  1271. GL_CTHL_LianLengthAutoCheck = dwXRealPos;
  1272. }
  1273. break;
  1274. case 15:
  1275. // if(GL_CTHL_PARAM_CR_MODE==0)
  1276. // {
  1277. if(((dwXRealPos - GL_CTHL_X_CXPosBuff) > (GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_XCXWC_LENTH)) && GL_CTHL_X_CXPosBuff)
  1278. {
  1279. user_datas[121] += 5;
  1280. GL_CTHL_TD_MotorStep = 0;
  1281. GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1282. }
  1283. else if(((dwXRealPos - GL_CTHL_X_CXPosBuff) < (GL_CTHL_PARAM_XCX_LENTH - GL_CTHL_PARAM_XCXWC_LENTH)) && GL_CTHL_X_CXPosBuff)
  1284. {
  1285. user_datas[121] += 6;
  1286. GL_CTHL_TD_MotorStep = 0;
  1287. GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1288. }
  1289. else if(GL_CTHL_X_CXPosBuff == 0)
  1290. {
  1291. user_datas[121] += 7;
  1292. GL_CTHL_TD_MotorStep = 0;
  1293. GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1294. }
  1295. else
  1296. {
  1297. GL_CTHL_TD_MotorStep = 0;
  1298. }
  1299. // }
  1300. // else
  1301. // {
  1302. // if(GL_CTHL_X_CXPosBuff == 0)
  1303. // {
  1304. // user_datas[121] += 7;
  1305. // GL_CTHL_TD_MotorStep = 0;
  1306. // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
  1307. // }
  1308. // else
  1309. // {
  1310. // GL_CTHL_TD_MotorStep = 0;
  1311. // }
  1312. // }
  1313. break;
  1314. }
  1315. #endif
  1316. }
  1317. //穿入电机动作,Y轴
  1318. void GL_CTHL_CL_Motor(void) //
  1319. {
  1320. #if 1
  1321. //1步开始, 穿链长度开始
  1322. //20步开始 插销定位开始
  1323. //40步,回原点为
  1324. switch(GL_CTHL_CL_MotorStep)
  1325. {
  1326. //穿入长度位置
  1327. case 1:
  1328. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1329. {
  1330. // if(GL_CTHL_PARAM_CR_MODE != 0) //电机穿入
  1331. // {
  1332. /*
  1333. //穿入长度要根据检测长度减动一次穿入的3CM,反转的2CM
  1334. if((GL_CTHL_LianLengthAutoCheck < (GL_CTHL_PARAM_CL_Length + 700)) && (GL_CTHL_LianLengthAutoCheck>700))
  1335. {
  1336. GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-700;
  1337. // if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
  1338. // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
  1339. if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
  1340. GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
  1341. AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,150);
  1342. }
  1343. else if(GL_CTHL_LianLengthAutoCheck>700)
  1344. {
  1345. GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-GL_CTHL_PARAM_CL_Length;
  1346. //if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
  1347. // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
  1348. if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
  1349. GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
  1350. AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,100);
  1351. }
  1352. */
  1353. // (公分节判断)
  1354. if((GL_CTHL_LianLengthAutoCheck < (GL_CTHL_LianLengthAutoCheckOLD)) &&
  1355. (GL_CTHL_LianLengthAutoCheck < GL_CTHL_PARAM_GFJ_Length)) //
  1356. {
  1357. GL_CTHL_cZipCnt = 0;
  1358. GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-900;
  1359. // if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
  1360. // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
  1361. if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
  1362. GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
  1363. //正常穿入
  1364. if(GL_CTHL_PARAM_GFJ_WorkMode == 0)
  1365. {
  1366. AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,150);
  1367. }
  1368. //停止
  1369. else if(GL_CTHL_PARAM_GFJ_WorkMode == 1)
  1370. {
  1371. GL_CTHL_CL_MotorStep = 0;
  1372. GL_CTHL_HLJJ_VAVLE = 0;
  1373. bCL_OK_FLG = 1;
  1374. bSingOneFlg= 1;
  1375. bSingOneCnt=0;
  1376. break;
  1377. }
  1378. else if(GL_CTHL_PARAM_GFJ_WorkMode == 2)
  1379. {
  1380. GL_CTHL_CL_MotorStep = 0;
  1381. GL_CTHL_HLJJ_VAVLE = 0;
  1382. bCL_OK_FLG = 1;
  1383. break;
  1384. }
  1385. }
  1386. //穿入长度要根据检测长度减动一次穿入的3CM,反转的2CM
  1387. else if(GL_CTHL_LianLengthAutoCheck>700)
  1388. {
  1389. GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-GL_CTHL_PARAM_CL_Length-200;
  1390. //if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
  1391. // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
  1392. if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
  1393. GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
  1394. else if(GL_CTHL_Y_CL_Length < 100)
  1395. GL_CTHL_Y_CL_Length = 100;
  1396. AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,100);
  1397. }
  1398. GL_CTHL_CL_MotorStep = 2;
  1399. // }
  1400. // else //气缸穿入
  1401. // {
  1402. // GL_CTHL_CL_MotorStep = 10;
  1403. // GL_CTHL_HL_VAVLE = 1;
  1404. //
  1405. // GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_CLT_Time;
  1406. //
  1407. // if(((GL_CTHL_LianLengthAutoCheckOLD > (GL_CTHL_LianLengthAutoCheck + 1200)) &&
  1408. // GL_CTHL_LianLengthAutoCheck) && (GL_CTHL_cZipCnt > 1))
  1409. // {
  1410. // GL_CTHL_CL_MotorStep = 0;
  1411. // bCL_OK_FLG = 1;
  1412. // GL_CTHL_HLJJ_VAVLE = 0;
  1413. // GL_CTHL_HL_VAVLE = 0;
  1414. // }
  1415. //
  1416. // }
  1417. }
  1418. break;
  1419. case 2:
  1420. if((dwYRealPos + 120) > GL_CTHL_Y_CL_Length)
  1421. GL_CTHL_HLJJ_VAVLE = 0;
  1422. if(!Y_DRV || dwYRealPos >= GL_CTHL_Y_CL_Length)
  1423. {
  1424. AxisEgmStop(Y_AXIS);
  1425. GL_CTHL_HLJJ_VAVLE = 0;
  1426. GL_CTHL_CL_MotorStep = 3;
  1427. bCL_OK_FLG = 1;
  1428. GL_CTHL_CL_MotorDelay = dwTickCount + 20; //延时数控回零点
  1429. }
  1430. break;
  1431. case 3:
  1432. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1433. {
  1434. GL_CTHL_CL_MotorStep = 50;
  1435. }
  1436. break;
  1437. //气缸穿入
  1438. case 10:
  1439. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1440. {
  1441. GL_CTHL_CL_MotorStep = 11;
  1442. bCL_OK_FLG = 1;
  1443. GL_CTHL_HLJJ_VAVLE = 0;
  1444. GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HL_BACK_Time; //合链返回时间到后才能重新前夹链
  1445. }
  1446. break;
  1447. case 11:
  1448. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1449. {
  1450. GL_CTHL_CL_MotorStep = 0;
  1451. }
  1452. break;
  1453. //夹带插销到穿入位置
  1454. case 20: //此处最好算好定位长度相减
  1455. // if(cXcxcrCnt > 0 || GL_CTHL_LianLengthCheck - GL_CTHL_LianLengthCheckReal > 350)
  1456. // {
  1457. // GL_CTHL_LENTH = GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_CXDW_Length - (dwXRealPos - GL_CTHL_X_CXPosBuff) + 45;
  1458. // }
  1459. // else
  1460. // {
  1461. // GL_CTHL_LENTH = GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_CXDW_Length - (dwXRealPos - GL_CTHL_X_CXPosBuff);
  1462. // }
  1463. GL_CTHL_LENTH = GL_CTHL_PARAM_CXDW_Length;
  1464. user_datas[121] = GL_CTHL_LENTH;
  1465. user_datas[122] = GL_CTHL_X_CXPosBuff;
  1466. if((GL_CTHL_LENTH > 0) )
  1467. {
  1468. GL_CTHL_CL_MotorStep = 21;
  1469. }
  1470. else
  1471. {
  1472. GL_CTHL_CL_MotorStep = 30;
  1473. }
  1474. GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_CXJZ_HT_DELAY;
  1475. break;
  1476. case 21:
  1477. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1478. {
  1479. // if(GL_CTHL_PARAM_CR_MODE!= 0)
  1480. // {
  1481. GL_CTHL_Y_CL_PosBuff = dwYRealPos;
  1482. AxisMovePosAccDec(Y_AXIS,8000,GL_CTHL_LENTH,800,500,6,6,20);
  1483. // }
  1484. // else
  1485. // {
  1486. // //GL_CTHL_CXHT_VAVLE = 1;
  1487. // GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_XXHT_Time;
  1488. // }
  1489. GL_CTHL_CL_MotorStep = 22;
  1490. }
  1491. break;
  1492. case 22:
  1493. // if(GL_CTHL_PARAM_CR_MODE!= 0)
  1494. // {
  1495. if((dwYRealPos > GL_CTHL_Y_CL_PosBuff+GL_CTHL_LENTH-GL_CTHL_PARAM_CXDW_Length) && !GL_CTHL_CXDW_Stop)
  1496. GL_CTHL_CXSCDW_VAVLE = 1; //Y21 插销上止定位电磁阀
  1497. if(!Y_DRV /*|| (dwYRealPos >= GL_CTHL_PARAM_CXDW_Length)*/) //插销定位已经结束
  1498. {
  1499. AxisEgmStop(Y_AXIS);
  1500. GL_CTHL_YsaveCXDWPosBuff = 0;
  1501. if(GL_CTHL_CXDW_Stop)
  1502. {
  1503. GL_CTHL_CL_MotorStep = 23;
  1504. GL_CTHL_CL_MotorDelay = dwTickCount + 30;
  1505. }
  1506. else
  1507. {
  1508. GL_CTHL_CL_MotorStep = 0;
  1509. GL_CTHL_bXCBackOK = 1;
  1510. GL_CTHL_CXQJD_VAVLE = 0;//YYQ
  1511. //GL_CTHL_SongDai_VAVLE = 0; //松带
  1512. }
  1513. }
  1514. // }
  1515. // else if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1516. // {
  1517. // GL_CTHL_CL_MotorStep = 23;
  1518. // GL_CTHL_CL_MotorDelay = dwTickCount + 10;
  1519. // GL_CTHL_CXQJD_VAVLE = 0;
  1520. //
  1521. // GL_CTHL_bXCBackOK = 1;
  1522. // }
  1523. break;
  1524. case 23:
  1525. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1526. {
  1527. //GL_CTHL_CXHT_VAVLE = 0;
  1528. GL_CTHL_CL_MotorStep = 0;
  1529. if(GL_CTHL_CXDW_Stop&& !bRunning)
  1530. SetEn(Y_AXIS, MOTOR_DISEN);
  1531. GL_CTHL_CXDW_Stop = 0;
  1532. }
  1533. break;
  1534. case 30:
  1535. GL_CTHL_YsaveCXDWPosBuff = 0;
  1536. GL_CTHL_CL_MotorStep = 0;
  1537. GL_CTHL_bXCBackOK = 1;
  1538. GL_CTHL_CXQJD_VAVLE = 0;//YYQ
  1539. break;
  1540. //回原点开始
  1541. case 40:
  1542. // if(GL_CTHL_PARAM_CR_MODE == 0)
  1543. // {
  1544. // GL_CTHL_CL_MotorStep = 0;
  1545. // GL_CTHL_CXQJD_VAVLE = 0;
  1546. // //GL_CTHL_CXHT_VAVLE = 0;
  1547. // GL_CTHL_HL_VAVLE = 0;
  1548. // break;
  1549. // }
  1550. // else
  1551. // {
  1552. //要先离开
  1553. if(GL_CTHL_SF_Origin_IN && (GetEn(Y_AXIS) == MOTOR_DISEN))
  1554. {
  1555. GL_CTHL_CL_MotorStep = 41;
  1556. SetDir(Y_AXIS, DIR_P);
  1557. }
  1558. else
  1559. {
  1560. SetDir(Y_AXIS, DIR_N);
  1561. GL_CTHL_CL_MotorStep = 46;
  1562. }
  1563. if(GetEn(Y_AXIS) == MOTOR_DISEN)
  1564. {
  1565. SetEn(Y_AXIS, MOTOR_EN);
  1566. GL_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
  1567. }
  1568. else //已经锁轴
  1569. GL_CTHL_CL_MotorDelay = dwTickCount + 5;
  1570. // }
  1571. break;
  1572. case 41:
  1573. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1574. {
  1575. GL_CTHL_CL_MotorStep = 42;
  1576. AxisContinueMoveAcc(Y_AXIS,5000,DIR_P,1000,800,15,15);
  1577. }
  1578. break;
  1579. case 42:
  1580. if(!GL_CTHL_SF_Origin_IN)
  1581. {
  1582. GL_CTHL_CL_MotorStep = 43;
  1583. GL_CTHL_YSavePosBuff = dwYRealPos;
  1584. }
  1585. break;
  1586. case 43:
  1587. //离开原点5CM停止
  1588. if((dwYRealPos - GL_CTHL_YSavePosBuff) >= 800)
  1589. {
  1590. AxisEgmStop(Y_AXIS);
  1591. GL_CTHL_CL_MotorStep = 46; //留空几步备用
  1592. GL_CTHL_CL_MotorDelay = dwTickCount + 50;
  1593. }
  1594. break;
  1595. case 46:
  1596. if(dwTickCount >= GL_CTHL_CL_MotorDelay)
  1597. {
  1598. GL_CTHL_CL_MotorStep = 47; //检测回到原位
  1599. if(!GL_CTHL_SF_Origin_IN)
  1600. AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,800,15,10);
  1601. }
  1602. break;
  1603. case 47:
  1604. if(GL_CTHL_SF_Origin_IN)
  1605. {
  1606. GL_CTHL_CL_MotorStep = 0;
  1607. AxisEgmStop(Y_AXIS);
  1608. SetPos(Y_AXIS, 0);
  1609. }
  1610. break;
  1611. //数控回原位 (条件为自动工作,SON一直没有松开)
  1612. case 50:
  1613. // if(GL_CTHL_PARAM_CR_MODE == 0)
  1614. // {
  1615. // GL_CTHL_CL_MotorStep = 0;
  1616. // GL_CTHL_HLJJ_VAVLE = 0;
  1617. // GL_CTHL_HL_VAVLE = 0;
  1618. // break;
  1619. // }
  1620. // else
  1621. // {
  1622. if(dwYRealPos > 150)
  1623. { //回零速度
  1624. SetDir(Y_AXIS, DIR_N);
  1625. AxisMovePosAccDecNotStop(Y_AXIS,GL_CTHL_PARAM_CL_Back_O_Speed,-dwYRealPos + 150,5000,2000,25,25,50);
  1626. }
  1627. else
  1628. AxisContinueMoveAcc(Y_AXIS,1000,DIR_N,1000,1000,15,15);
  1629. GL_CTHL_CL_MotorStep = 51;
  1630. // }
  1631. break;
  1632. case 51:
  1633. if(GL_CTHL_SF_Origin_IN)
  1634. {
  1635. GL_CTHL_CL_MotorStep = 0;
  1636. AxisEgmStop(Y_AXIS);
  1637. SetPos(Y_AXIS, 0);
  1638. }
  1639. else
  1640. {
  1641. if(dwYRealPos < -65)
  1642. {
  1643. GL_CTHL_CL_MotorStep = 0;
  1644. AxisEgmStop(Y_AXIS);
  1645. SetPos(Y_AXIS, 0);
  1646. GL_CTHL_SetAlarmCode(GL_CTHL_YAxis_Origin_ALARM,0);
  1647. }
  1648. }
  1649. break;
  1650. }
  1651. #endif
  1652. }
  1653. void GL_CTHL_HeMo(void)
  1654. {
  1655. switch(GL_CTHL_HeMoStep)
  1656. {
  1657. case 1:
  1658. GL_CTHL_HeMoStep = 2;
  1659. GL_CTHL_CTXMXJ_VAVLE = 1;
  1660. //GL_CTHL_JLTou_VAVLE = 0; //接拉头关
  1661. GL_CTHL_HeMo_Time = dwTickCount + 10;
  1662. //GL_CTHL_TimeBuff=dwTickCount;
  1663. // GL_CTHL_HeMoStep = 4;
  1664. // GL_CTHL_CTXMSS_VAVLE = 1;
  1665. // GL_CTHL_HeMo_Time = dwTickCount + 1800;
  1666. GL_CTHL_CXSX_VAVLE=1;
  1667. break;
  1668. case 2:
  1669. if(dwTickCount >= GL_CTHL_HeMo_Time)
  1670. {
  1671. GL_CTHL_HeMoStep = 3;
  1672. GL_CTHL_CTXMSS_VAVLE = 1;
  1673. GL_CTHL_HeMo_Time = dwTickCount + 25;
  1674. }
  1675. break;
  1676. case 3:
  1677. if(dwTickCount >= GL_CTHL_HeMo_Time)
  1678. {
  1679. GL_CTHL_HeMoStep = 4;
  1680. GL_CTHL_CTXMXJ_VAVLE = 0;
  1681. GL_CTHL_HeMo_Time = dwTickCount + 1800;
  1682. }
  1683. break;
  1684. case 4:
  1685. if(!GL_CTHL_CTM_Origin_IN)
  1686. GL_CTHL_JLTou_VAVLE = 0; //接拉头
  1687. if(GL_CTHL_CTM_Limit_IN)
  1688. {
  1689. GL_CTHL_JLTou_VAVLE = 0; //接拉头
  1690. GL_CTHL_HeMoStep = 0;
  1691. //user_datas[127]=dwTickCount-GL_CTHL_TimeBuff;
  1692. }
  1693. else if((dwTickCount >= GL_CTHL_HeMo_Time)&& bRunning)
  1694. {
  1695. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Limit_ALARM,bRunning); //穿头下模上升异常
  1696. }
  1697. break;
  1698. case 10:
  1699. GL_CTHL_HeMoStep = 11;
  1700. GL_CTHL_CTXMXJ_VAVLE = 1;
  1701. GL_CTHL_CTXMSS_VAVLE = 0;
  1702. GL_CTHL_HeMo_Time = dwTickCount + 200;
  1703. //GL_CTHL_TimeBuff=dwTickCount;
  1704. break;
  1705. case 11:
  1706. if(dwTickCount >= GL_CTHL_HeMo_Time)
  1707. {
  1708. //GL_CTHL_HeMoStep = 0;
  1709. GL_CTHL_CTXMXJ_VAVLE = 0;
  1710. }
  1711. if(GL_CTHL_CTM_Origin_IN)
  1712. {
  1713. GL_CTHL_HeMoStep = 0;
  1714. GL_CTHL_CTXMXJ_VAVLE = 0;
  1715. //user_datas[127]=dwTickCount-GL_CTHL_TimeBuff;
  1716. }
  1717. break;
  1718. }
  1719. }
  1720. //装拉头动作
  1721. void GL_CTHL_ZLT_Step(void)
  1722. {
  1723. switch(GL_CTHL_ZhuangLiaoStep)
  1724. {
  1725. case 1:
  1726. if(bZhuangLiaoOkFlg)
  1727. {
  1728. GL_CTHL_ZhuangLiaoStep = 0;
  1729. }
  1730. else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
  1731. {
  1732. if(((GL_CTHL_MGuo_VAVLE && GL_CTHL_LTou_Check) || (!GL_CTHL_MGuo_VAVLE)) && !GL_CTHL_JLiao_Limit_IN )//说明没有拉头
  1733. {
  1734. //穿头模和一次穿入必须在原位,接料不能有输出
  1735. if(GL_CTHL_CTM_Origin_IN && !GL_CTHL_CTXMSS_VAVLE)
  1736. {
  1737. GL_CTHL_First_CT_VAVLE = 0;
  1738. GL_CTHL_JLTou_VAVLE = 0;
  1739. GL_CTHL_MGuo_VAVLE = 0;
  1740. if(GL_CTHL_TLiaoStep == 0)
  1741. {
  1742. GL_CTHL_TLiaoStep = 1;
  1743. GL_CTHL_ZhuangLiaoStep = 2;
  1744. }
  1745. }
  1746. else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay + 500) //警告横送拉必须保证穿头模和一次穿入在原位,接料不能有输出
  1747. {
  1748. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning);
  1749. }
  1750. }
  1751. else //已经有拉头直接跳到结束
  1752. {
  1753. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 40;
  1754. GL_CTHL_ZhuangLiaoStep = 9;
  1755. }
  1756. }
  1757. break;
  1758. case 2:
  1759. if(GL_CTHL_TLiaoStep == 0) //推料已经完成
  1760. {
  1761. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1762. GL_CTHL_JLTou_VAVLE = 0;
  1763. GL_CTHL_MGuo_VAVLE = 0;
  1764. if(!GL_CTHL_JLiao_Limit_IN && GL_CTHL_First_CT_Origin_IN)
  1765. {
  1766. GL_CTHL_ZhuangLiaoStep = 3;
  1767. GL_CTHL_HSLiao_VAVLE = 1;
  1768. }
  1769. }
  1770. break;
  1771. case 3:
  1772. //横送到位
  1773. if(GL_CTHL_HSLiao_Limit_IN && !GL_CTHL_HSLiao_Origin_IN)
  1774. {
  1775. GL_CTHL_ZhuangLiaoStep = 4;
  1776. // GL_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
  1777. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 2;
  1778. }
  1779. else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
  1780. {
  1781. GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Limit_ALARM,bRunning);
  1782. }
  1783. break;
  1784. case 4:
  1785. if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
  1786. {
  1787. GL_CTHL_ZhuangLiaoStep = 5;
  1788. GL_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
  1789. GL_CTHL_CTXMSS_VAVLE = 0; //Y20 穿头下模上升电磁阀
  1790. GL_CTHL_CTXMXJ_VAVLE = 0; //Y21 穿头下模下降电磁阀
  1791. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1792. }
  1793. break;
  1794. case 5:
  1795. if(GL_CTHL_JLiao_Limit_IN)
  1796. {
  1797. GL_CTHL_ZhuangLiaoStep = 6;
  1798. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_PARAM_MaGou_DELAY;
  1799. }
  1800. else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay) //接拉头(接料)到们信号异常
  1801. {
  1802. GL_CTHL_SetAlarmCode(GL_CTHL_JLiao_Limit_ALARM,bRunning);
  1803. }
  1804. break;
  1805. case 6:
  1806. if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay) //延时码勾
  1807. {
  1808. GL_CTHL_MGuo_VAVLE = 1; //码勾输出
  1809. GL_CTHL_ZhuangLiaoStep = 7;
  1810. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_PARAM_HSLiaoOff_DELAY;
  1811. bTuiLaTouOkFlg = 0; //认为拉头没法带出
  1812. }
  1813. break;
  1814. case 7:
  1815. if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
  1816. {
  1817. GL_CTHL_HSLiao_VAVLE = 0;
  1818. GL_CTHL_ZhuangLiaoStep = 8;
  1819. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1820. }
  1821. break;
  1822. case 8:
  1823. if(!GL_CTHL_HSLiao_Limit_IN) //
  1824. {
  1825. GL_CTHL_ZhuangLiaoStep = 9;
  1826. GL_CTHL_TLiaoStep = 1; //推拉头
  1827. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_PARAM_CheckLT_DELAY; //也是给下模能上升的时间
  1828. }
  1829. else if (GL_CTHL_LTou_Check) //时间内信号这说明没有拉头
  1830. {
  1831. //重送3次
  1832. GL_CTHL_TryCnt++;
  1833. GL_CTHL_JLTou_VAVLE = 0; //接拉头关
  1834. GL_CTHL_MGuo_VAVLE = 0; //码勾打开
  1835. if(GL_CTHL_TryCnt >= 3)
  1836. {
  1837. GL_CTHL_TryCnt = 0;
  1838. bZhuangLiaoOkFlg = 0;
  1839. GL_CTHL_ZhuangLiaoStep = 0;
  1840. GL_CTHL_SetAlarmCode(GL_CTHL_ZLT_ALARM,bRunning);
  1841. cWULATOUCnt=1;
  1842. }
  1843. else
  1844. {
  1845. GL_CTHL_ZhuangLiaoStep = 20; //重新送3次
  1846. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1847. }
  1848. }
  1849. else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
  1850. {
  1851. GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Limit_ALARM,bRunning);
  1852. if(bRunning)
  1853. {
  1854. GL_CTHL_ZhuangLiaoStep = 0 ;
  1855. }
  1856. }
  1857. break;
  1858. case 9:
  1859. if(GL_CTHL_LTou_Check) //时间内信号这说明没有拉头
  1860. {
  1861. GL_CTHL_TryCnt++;
  1862. GL_CTHL_JLTou_VAVLE = 0; //接拉头关
  1863. GL_CTHL_MGuo_VAVLE = 0; //码勾打开
  1864. if(GL_CTHL_TryCnt >= 3)
  1865. {
  1866. GL_CTHL_TryCnt=0;
  1867. bZhuangLiaoOkFlg = 0;
  1868. GL_CTHL_ZhuangLiaoStep = 0;
  1869. GL_CTHL_SetAlarmCode(GL_CTHL_ZLT_ALARM,bRunning);
  1870. cWULATOUCnt=1;
  1871. }
  1872. else
  1873. {
  1874. GL_CTHL_ZhuangLiaoStep = 20; //重新送3次
  1875. GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1876. }
  1877. }
  1878. else if((dwTickCount >= GL_CTHL_ZhuangLiaoDelay) || GL_CTHL_HSLiao_Origin_IN)
  1879. {
  1880. bZhuangLiaoOkFlg = 1;
  1881. GL_CTHL_ZhuangLiaoStep = 0;
  1882. }
  1883. break;
  1884. //装拉头不成攻重新送拉头
  1885. case 20:
  1886. if(GL_CTHL_HSLiao_Origin_IN)
  1887. {
  1888. GL_CTHL_JLTou_VAVLE = 0; //接拉头关
  1889. GL_CTHL_MGuo_VAVLE = 0; //码勾打开
  1890. GL_CTHL_ZhuangLiaoStep = 1;
  1891. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 10;
  1892. }
  1893. else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
  1894. {
  1895. GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Origin_ALARM,bRunning);
  1896. }
  1897. break;
  1898. }
  1899. }
  1900. void GL_CTHL_TLiao_Step(void)
  1901. {
  1902. switch(GL_CTHL_TLiaoStep)
  1903. {
  1904. case 1:
  1905. if(bTuiLaTouOkFlg)
  1906. {
  1907. GL_CTHL_TLiaoStep = 0;
  1908. }
  1909. else
  1910. {
  1911. GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1912. GL_CTHL_TLiaoStep = 2;
  1913. }
  1914. break;
  1915. case 2: //横送料在原位
  1916. if(GL_CTHL_HSLiao_Origin_IN && !GL_CTHL_HSLiao_Limit_IN && !GL_CTHL_HSLiao_VAVLE)
  1917. {
  1918. GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_PARAM_HSLYDTL_DELAY;
  1919. GL_CTHL_TLiaoStep = 21;
  1920. }
  1921. else if(dwTickCount >= GL_CTHL_TLiao_Delay)
  1922. GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Origin_ALARM,1);
  1923. break;
  1924. case 21: //横送料在原位
  1925. if((dwTickCount >= GL_CTHL_TLiao_Delay) && GL_CTHL_HSLiao_Origin_IN && !GL_CTHL_HSLiao_Limit_IN && !GL_CTHL_HSLiao_VAVLE)
  1926. {
  1927. GL_CTHL_TLiao_VAVLE = 1; //推料(推拉头)输出
  1928. GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1929. GL_CTHL_TLiaoStep = 3;
  1930. }
  1931. else if(dwTickCount >= GL_CTHL_TLiao_Delay)
  1932. GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Origin_ALARM,1);
  1933. break;
  1934. case 3: //推拉头到位
  1935. if(GL_CTHL_TLiao_Limit_IN)
  1936. {
  1937. GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_PARAM_TLiao_BACKDELAY;
  1938. GL_CTHL_TLiaoStep = 4;
  1939. }
  1940. else if(dwTickCount >= GL_CTHL_TLiao_Delay)
  1941. GL_CTHL_SetAlarmCode(GL_CTHL_TLiao_Limit_ALARM,1);
  1942. break;
  1943. case 4:
  1944. if(dwTickCount >= GL_CTHL_TLiao_Delay)
  1945. {
  1946. GL_CTHL_TLiao_VAVLE = 0;
  1947. GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  1948. GL_CTHL_TLiaoStep = 5;
  1949. }
  1950. break;
  1951. case 5:
  1952. if(!GL_CTHL_TLiao_Limit_IN)
  1953. {
  1954. GL_CTHL_TLiaoStep = 0;
  1955. GL_CTHL_TLiao_Delay = dwTickCount;
  1956. bTuiLaTouOkFlg = 1;
  1957. }
  1958. else if(dwTickCount >= GL_CTHL_TLiao_Delay)
  1959. GL_CTHL_SetAlarmCode(GL_CTHL_TLiao_Limit_ALARM,0);
  1960. break;
  1961. }
  1962. }
  1963. //振动盘控制
  1964. void GL_CTHL_ZhenDongAction(void)
  1965. {
  1966. #if 1
  1967. // if(bRunning)
  1968. // {
  1969. if(!GL_CTHL_PARAM_ZDP_AUTO)
  1970. {
  1971. if(GL_CTHL_ZhenDongPian_OUT == 1)
  1972. {
  1973. if(GL_CTHL_ZDP_IN)
  1974. {
  1975. if(dwTickCount >= GL_CTHL_ZDP_Delay)
  1976. {
  1977. GL_CTHL_ZhenDongPian_OUT = 0;
  1978. GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Stop_TIME;//GL_CTHL_PARAM_ZDP_Stop_TIME + 50;
  1979. }
  1980. }
  1981. else
  1982. {
  1983. GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Start_TIME;//GL_CTHL_PARAM_ZDP_Start_TIME;
  1984. }
  1985. }
  1986. else
  1987. {
  1988. if(!GL_CTHL_ZDP_IN)
  1989. {
  1990. if(dwTickCount >= GL_CTHL_ZDP_Delay)
  1991. {
  1992. GL_CTHL_ZhenDongPian_OUT = 1;
  1993. GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Start_TIME;//GL_CTHL_PARAM_ZDP_Start_TIME
  1994. }
  1995. }
  1996. else
  1997. GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Stop_TIME;//GL_CTHL_PARAM_ZDP_Stop_TIME+ 50;
  1998. }
  1999. }
  2000. else if (GL_CTHL_PARAM_ZDP_AUTO ==1 )
  2001. {
  2002. GL_CTHL_ZhenDongPian_OUT=0;
  2003. GL_CTHL_ZDP_Delay = dwTickCount + 0;
  2004. }
  2005. else if(GL_CTHL_PARAM_ZDP_AUTO == 2)
  2006. {
  2007. GL_CTHL_ZhenDongPian_OUT=1;
  2008. GL_CTHL_ZDP_Delay = dwTickCount + 0;
  2009. }
  2010. //GL_CTHL_CuiQi_VAVLE = ~GL_CTHL_ZhenDongPian_OUT;
  2011. #endif
  2012. }
  2013. void GL_CTHL_bFKCXTDDWStep(void)
  2014. {
  2015. switch(GL_CTHL_bFKCXTDDW_Step)
  2016. {
  2017. case 1:
  2018. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  2019. GL_CTHL_FKGD_VAVLE = 0; //方块固定关
  2020. GL_CTHL_bFKCXTDDW_Step = 2;
  2021. break;
  2022. case 2:
  2023. if(!GL_CTHL_XKTD_Origin_IN) //斜口推带原位离开
  2024. {
  2025. GL_CTHL_bFKCXTDDW_Step = 3;
  2026. GL_CTHL_bFKCXTDDW_Delay = dwTickCount + 20;
  2027. }
  2028. break;
  2029. case 3://斜口定位
  2030. if(dwTickCount >= GL_CTHL_bFKCXTDDW_Delay)
  2031. {
  2032. GL_CTHL_XKDW_VAVLE = 1;
  2033. GL_CTHL_bFKCXTDDW_Step = 4;
  2034. GL_CTHL_bFKCXTDDW_Delay = dwTickCount + GL_CTHL_PARAM_XKDW_TD_DELAY;
  2035. }
  2036. break;
  2037. case 4:
  2038. if(dwTickCount >= GL_CTHL_bFKCXTDDW_Delay)
  2039. {
  2040. AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,DIR_P,GL_CTHL_PARAM_XKDW_Speed/2,GL_CTHL_PARAM_XKDW_Speed/2,10,10);//拖带电机
  2041. GL_CTHL_bFKCXTDDW_Step = 5;
  2042. GL_CTHL_XSavePosBuff = dwXRealPos;
  2043. SetPos(X_AXIS, 0); //启动位置设为0点
  2044. dwXRealPos = 0;
  2045. }
  2046. break;
  2047. case 5:
  2048. if(GL_CTHL_XKSC_Limit_IN) //方块到位
  2049. {
  2050. AxisEgmStop(X_AXIS);
  2051. GL_CTHL_bFKCXTDDW_Step = 6;
  2052. GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
  2053. GL_CTHL_bFKCXTDDW_Delay = dwTickCount + 300;
  2054. }
  2055. else if(dwXRealPos >= (GL_CTHL_XSavePosBuff + 800))
  2056. {
  2057. GL_CTHL_SetAlarmCode(GL_CTHL_FKCXDW_ALARM,bRunning);//方块插销定位异常警告
  2058. }
  2059. break;
  2060. case 6:
  2061. if(dwTickCount >= GL_CTHL_bFKCXTDDW_Delay)
  2062. {
  2063. GL_CTHL_GDXM_VAVLE=1;
  2064. GL_CTHL_bFKCXTDDW_Step = 0;
  2065. }
  2066. break;
  2067. }
  2068. }
  2069. //插销穿入动作
  2070. void GL_CTHL_bCXCRStep(void)
  2071. {
  2072. switch(GL_CTHL_bCXCR_Step)
  2073. {
  2074. case 11:
  2075. if(!GL_CTHL_CXDW_Stop)
  2076. GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
  2077. GL_CTHL_FKGD_VAVLE = 0; //方块固定关
  2078. GL_CTHL_bCXCR_Step = 12;
  2079. break;
  2080. case 12:
  2081. if(!GL_CTHL_XKTD_Origin_IN || GL_CTHL_CXDW_Stop) //斜口推带原位离开
  2082. {
  2083. GL_CTHL_bCXCR_Step = 13;
  2084. GL_CTHL_bCXCR_Delay = dwTickCount + 65;
  2085. }
  2086. break;
  2087. case 13:
  2088. // if(GL_CTHL_PARAM_CR_MODE == 1)
  2089. // {
  2090. if((GL_CTHL_CL_MotorStep == 0) && (GL_CTHL_SF_Origin_IN) && (dwTickCount >= GL_CTHL_bCXCR_Delay)) //插销前夹带回到原位
  2091. {
  2092. GL_CTHL_bCXCR_Step = 14;
  2093. if(!GL_CTHL_CXDW_Stop)
  2094. GL_CTHL_FKGD_VAVLE = 1; //方块固定关
  2095. GL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
  2096. //GL_CTHL_SongDai_VAVLE = 1; //松带
  2097. GL_CTHL_bCXCR_Delay = dwTickCount + 0;
  2098. }
  2099. // }//气缸穿入
  2100. // else
  2101. // {
  2102. // GL_CTHL_bCXCR_Step = 14;
  2103. // if(!GL_CTHL_CXDW_Stop)
  2104. // GL_CTHL_FKGD_VAVLE = 1; //方块固定关
  2105. // GL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
  2106. // //GL_CTHL_SongDai_VAVLE = 1; //松带
  2107. // GL_CTHL_bCXCR_Delay = dwTickCount + 0;
  2108. // }
  2109. // break;
  2110. case 14:
  2111. if(dwTickCount >= GL_CTHL_bCXCR_Delay)
  2112. {
  2113. GL_CTHL_bCXCR_Step = 15;
  2114. if(!GL_CTHL_CXDW_Stop)
  2115. GL_CTHL_FKGD_VAVLE = 1; //方块固定
  2116. //Y轴启动插销
  2117. GL_CTHL_CL_MotorStep = 20; //插销定位
  2118. GL_CTHL_BB_VAVLE=1;
  2119. }
  2120. break;
  2121. case 15:
  2122. if(GL_CTHL_CL_MotorStep == 0) //插销定位完成
  2123. {
  2124. if(!GL_CTHL_CXDW_Stop)
  2125. {
  2126. GL_CTHL_bCXCR_Step = 16;
  2127. GL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
  2128. GL_CTHL_bCXCR_Delay = dwTickCount + 10; //延时插销下移
  2129. }
  2130. else
  2131. {
  2132. GL_CTHL_bCXCR_Step = 0;
  2133. }
  2134. GL_CTHL_CXDW_Stop = 0;
  2135. }
  2136. break;
  2137. case 16:
  2138. if(dwTickCount >= GL_CTHL_bCXCR_Delay)
  2139. {
  2140. GL_CTHL_bCXCR_Step = 17;
  2141. if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  2142. GL_CTHL_CXSX_VAVLE = 0; //插销上下
  2143. else
  2144. GL_CTHL_CXSX_VAVLE = 1; //插销顶出
  2145. GL_CTHL_bCXCR_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
  2146. }
  2147. break;
  2148. case 17:
  2149. if(GL_CTHL_CXXY_Limit_IN)
  2150. {
  2151. // if(GL_CTHL_START_IN_UP)
  2152. GL_CTHL_bCXCR_Step = 18;
  2153. if( cXcxcrCnt==0 && !X_DRV) //拖带电机反转
  2154. {
  2155. // SetDir(X_AXIS, DIR_N);
  2156. AxisMovePosAccDec(X_AXIS,10000,-GL_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
  2157. }
  2158. GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
  2159. GL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
  2160. GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
  2161. GL_CTHL_bCXCR_Delay = dwTickCount + GL_CTHL_PARAM_CXCR_DELAY;
  2162. }
  2163. else if(dwTickCount >= GL_CTHL_bCXCR_Delay)
  2164. {
  2165. GL_CTHL_SetAlarmCode(GL_CTHL_CXGL_Limit_ALARM,bRunning);//插销下移异常
  2166. }
  2167. break;
  2168. case 18:
  2169. // if(START_IN_UP)
  2170. {
  2171. if(dwTickCount >= GL_CTHL_bCXCR_Delay)
  2172. {
  2173. GL_CTHL_bCXCR_Step = 19;
  2174. GL_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
  2175. GL_CTHL_bCXCR_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME +1000; //插销穿入到位异常时间
  2176. //if(GL_CTHL_PARAM_CR_MODE == 1)
  2177. GL_CTHL_CL_MotorStep = 50; //合链电机回原点
  2178. }
  2179. }
  2180. break;
  2181. case 19:
  2182. // if( cXcxcrCnt > 1)
  2183. {
  2184. // GL_CTHL_SetAlarmCode(GL_CTHL_CX_Limit_ALARM,bRunning); //插销穿入到位异常
  2185. }
  2186. if( GL_CTHL_CX_Limit_IN )
  2187. {
  2188. cXcxcrCnt=0;
  2189. bZhuangLiaoOkFlg = 0;
  2190. GL_CTHL_bCXCR_Step = 0;
  2191. GL_CTHL_BB_VAVLE=0;
  2192. // GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
  2193. }
  2194. else if (dwTickCount >= GL_CTHL_bCXCR_Delay)
  2195. {
  2196. GL_CTHL_SetAlarmCode(GL_CTHL_CX_Limit_ALARM,bRunning); //插销穿入到
  2197. GL_CTHL_bCXCR_Step = 0;
  2198. /*
  2199. cXcxcrCnt++;
  2200. GL_CTHL_CXHJD_VAVLE=0;
  2201. GL_CTHL_CXHDW_VAVLE=0;
  2202. GL_CTHL_CXDWZ_VAVLE = 0;
  2203. GL_CTHL_CXSX_VAVLE=1;
  2204. GL_CTHL_bCXCR_Step = 11;
  2205. */
  2206. }
  2207. break;
  2208. }
  2209. }
  2210. void GL_CTHL_bCLFirstStep(void)
  2211. {
  2212. switch(GL_CTHL_bCLFirst_Step)
  2213. {
  2214. case 19:
  2215. GL_CTHL_JLTou_VAVLE = 0; //接拉头
  2216. bZhuangLiaoOkFlg = 0;
  2217. GL_CTHL_bCLFirst_Step = 20;
  2218. GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
  2219. GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
  2220. break;
  2221. case 20:
  2222. if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
  2223. {
  2224. GL_CTHL_bCLFirst_Step = 21;
  2225. GL_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
  2226. GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  2227. }
  2228. break;
  2229. case 21:
  2230. if(!GL_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
  2231. {
  2232. GL_CTHL_bCLFirst_Step = 22;
  2233. GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_PARAM_First_CL_Timer; //一次穿入时间
  2234. }
  2235. else if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
  2236. {
  2237. GL_CTHL_SetAlarmCode(GL_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
  2238. }
  2239. break;
  2240. case 22:
  2241. if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
  2242. {
  2243. GL_CTHL_bCLFirst_Step = 23;
  2244. GL_CTHL_MGuo_VAVLE = 0; //码勾退
  2245. GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_PARAM_MGOff_XiaMo_DELAY;
  2246. GL_CTHL_FKGD_VAVLE = 0; //方块固定退
  2247. GL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
  2248. // if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
  2249. // GL_CTHL_CXSX_VAVLE = 1; //插销上下
  2250. // else
  2251. // GL_CTHL_CXSX_VAVLE = 0; //插销顶出
  2252. }
  2253. break;
  2254. case 23:
  2255. if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
  2256. {
  2257. GL_CTHL_bCLFirst_Step = 24;
  2258. GL_CTHL_CTXMSS_VAVLE = 0; //穿头下模下降
  2259. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
  2260. GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  2261. }
  2262. break;
  2263. case 24:
  2264. if(!GL_CTHL_CTM_Limit_IN)
  2265. {
  2266. GL_CTHL_bCLFirst_Step= 25;
  2267. GL_CTHL_bCLFirst_Delay = dwTickCount + 25; //一次穿入延时返回
  2268. }
  2269. else if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
  2270. {
  2271. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning); //穿头下模下降异常
  2272. }
  2273. break;
  2274. case 25:
  2275. if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
  2276. {
  2277. GL_CTHL_bCLFirst_Step= 0;
  2278. GL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
  2279. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
  2280. //退下出错警告
  2281. GL_CTHL_AutoDelay1 = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
  2282. GL_CTHL_AutoStep1 = 1;
  2283. bTuiLaTouOkFlg = 1;
  2284. }
  2285. break;
  2286. }
  2287. }
  2288. //手动动作
  2289. void GL_CTHL_ManualAction(void)
  2290. {
  2291. if(bRunning) // 运行灯输出
  2292. {
  2293. GL_CTHL_Run_State=1;
  2294. GL_CTHL_Stop_State=0;
  2295. }
  2296. else
  2297. {
  2298. GL_CTHL_Stop_State=1;
  2299. GL_CTHL_Run_State=0;
  2300. }
  2301. if(GetEn(X_AXIS)==MOTOR_EN)
  2302. GL_CTHL_X_EN_FLG=1;
  2303. if(GetEn(Y_AXIS)==MOTOR_EN)
  2304. GL_CTHL_Y_EN_FLG=1;
  2305. if(dwTickCount>GL_CTHL_bSFBBAOJIN_Delay)
  2306. {
  2307. if((GetAlarm(X_AXIS)==MOTOR_ALARM) && GL_CTHL_X_EN_FLG) // 伺服报警
  2308. {
  2309. GL_CTHL_SetAlarmCode(GL_CTHL_SF_ALR_ALARM,0);
  2310. }
  2311. if((GetAlarm(Y_AXIS)==MOTOR_ALARM) && GL_CTHL_Y_EN_FLG) // 伺服报警
  2312. {
  2313. GL_CTHL_SetAlarmCode(GL_CTHL_Y_SF_ALR_ALARM,0);
  2314. }
  2315. SetClr(X_AXIS,ALARM_NOCLR);
  2316. }
  2317. if((dwYRealPos > (GL_CTHL_PARAM_Y_MAX_LENTH+20)) && Y_DRV && (GetDir(Y_AXIS)==DIR_P))
  2318. {
  2319. AxisEgmStop(Y_AXIS);
  2320. // if(GL_CTHL_PARAM_CR_MODE != 0)
  2321. // {
  2322. GL_CTHL_SetAlarmCode(GL_CTHL_YAxis_Limit_ALARM,0);
  2323. // }
  2324. }
  2325. if(bRunning == 0)
  2326. {
  2327. if(bClearTotal) //切断计数清零
  2328. {
  2329. bClearTotal = 0;
  2330. ClrcToTal(QDCT_TOTAL_ADDR);
  2331. }
  2332. if(GL_CTHL_bTLiao ) //手动推料(推拉头)
  2333. {
  2334. GL_CTHL_bTLiao = 0;
  2335. if(GL_CTHL_TLiao_VAVLE)
  2336. GL_CTHL_TLiao_VAVLE = 0;//GL_CTHL_TLiao_VAVLE;
  2337. else if(!GL_CTHL_HSLiao_VAVLE && GL_CTHL_HSLiao_Origin_IN)
  2338. {
  2339. GL_CTHL_TLiao_VAVLE = 1;
  2340. }
  2341. else//条件警告
  2342. {
  2343. GL_CTHL_SetAlarmCode(GL_CTHL_HENSONGLIAO_ALARM,0); // 横送料不能输出
  2344. }
  2345. }
  2346. if(GL_CTHL_bHSL) //手动横送料
  2347. {
  2348. GL_CTHL_bHSL= 0;
  2349. if(!GL_CTHL_First_CT_VAVLE)
  2350. {
  2351. if(GL_CTHL_HSLiao_VAVLE)
  2352. {
  2353. GL_CTHL_HSLiao_VAVLE = 0;//~GL_CTHL_HSLiao_VAVLE;
  2354. }
  2355. else if(!GL_CTHL_TLiao_VAVLE && !GL_CTHL_TLiao_Limit_IN && GL_CTHL_CTM_Origin_IN && !GL_CTHL_JLiao_Limit_IN &&
  2356. !GL_CTHL_JLTou_VAVLE && !GL_CTHL_CTXMSS_VAVLE && !GL_CTHL_CXDWZ_VAVLE && (!GL_CTHL_bMG || (GL_CTHL_bMG && GL_CTHL_LTou_Check)))
  2357. {
  2358. GL_CTHL_HSLiao_VAVLE = 1;
  2359. }
  2360. else //条件警告 最后一个括号条件为已经有拉头
  2361. {
  2362. if(GL_CTHL_TLiao_Limit_IN)
  2363. GL_CTHL_SetAlarmCode(GL_CTHL_TLiao_Limit_ALARM,0);
  2364. else if(!GL_CTHL_CTM_Origin_IN)
  2365. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,0);
  2366. else if(GL_CTHL_JLiao_Limit_IN)
  2367. GL_CTHL_SetAlarmCode(GL_CTHL_JLiao_Limit_ALARM,0);
  2368. }
  2369. }
  2370. }
  2371. if(GL_CTHL_bJLT) //接拉头
  2372. {
  2373. GL_CTHL_bJLT = 0;
  2374. if(GL_CTHL_JLTou_VAVLE)
  2375. GL_CTHL_JLTou_VAVLE = 0;
  2376. else if(!GL_CTHL_First_CT_VAVLE && !GL_CTHL_CTXMSS_VAVLE && GL_CTHL_CTM_Origin_IN && GL_CTHL_First_CT_Origin_IN)
  2377. {
  2378. GL_CTHL_MGuo_VAVLE = 0;
  2379. GL_CTHL_JLTou_VAVLE = 1;
  2380. GL_CTHL_CTXMXJ_VAVLE = 0;
  2381. }
  2382. else//条件警告
  2383. {
  2384. if(!GL_CTHL_CTM_Origin_IN)
  2385. GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,0);
  2386. else if(!GL_CTHL_First_CT_Origin_IN)
  2387. GL_CTHL_SetAlarmCode(GL_CTHL_First_CT_Origin_ALARM,0);
  2388. }
  2389. }
  2390. if(GL_CTHL_bMG) //码勾
  2391. {
  2392. GL_CTHL_bMG = 0;
  2393. GL_CTHL_MGuo_VAVLE = !GL_CTHL_MGuo_VAVLE;
  2394. }
  2395. if(GL_CTHL_bFKJD) //方块夹带
  2396. {
  2397. GL_CTHL_bFKJD = 0;
  2398. GL_CTHL_FKJD_VAVLE = !GL_CTHL_FKJD_VAVLE;
  2399. }
  2400. if(GL_CTHL_bXKTD) //斜口推带
  2401. {
  2402. GL_CTHL_bXKTD = 0;
  2403. if(GL_CTHL_XKTD_VAVLE)
  2404. GL_CTHL_XKTD_VAVLE = 0;
  2405. else if(((!GL_CTHL_DXK_VAVLE && (!GL_CTHL_XKSC_Limit_IN || !GL_CTHL_CTXMSS_VAVLE)) || (GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1)) || GL_CTHL_PARAM_QianMaSelect)
  2406. GL_CTHL_XKTD_VAVLE = 1;
  2407. else//条件警告
  2408. {
  2409. GL_CTHL_SetAlarmCode(GL_CTHL_DXKCTXM_Origin_ALARM,0);
  2410. }
  2411. }
  2412. if(GL_CTHL_bXKDW) //斜口定位
  2413. {
  2414. GL_CTHL_bXKDW = 0;
  2415. GL_CTHL_XKDW_VAVLE = ~GL_CTHL_XKDW_VAVLE;
  2416. }
  2417. if(GL_CTHL_bCTXM) //穿头下模
  2418. {
  2419. GL_CTHL_bCTXM = 0;
  2420. if(GL_CTHL_CTXMSS_VAVLE)
  2421. {
  2422. GL_CTHL_HeMoStep = 10;
  2423. // GL_CTHL_JLTou_VAVLE = 0;
  2424. // GL_CTHL_CTXMXJ_VAVLE = 0;
  2425. GL_CTHL_CTXMSS_VAVLE = 0;
  2426. }
  2427. else if(!GL_CTHL_HSLiao_VAVLE && GL_CTHL_HSLiao_Origin_IN && (!GL_CTHL_XKSC_Limit_IN || !GL_CTHL_XKTD_VAVLE))
  2428. {
  2429. // GL_CTHL_MGuo_VAVLE = 1;
  2430. GL_CTHL_HeMoStep = 1;
  2431. // GL_CTHL_CTXMSS_VAVLE = 1;
  2432. // GL_CTHL_CTXMXJ_VAVLE = 1;
  2433. // GL_CTHL_XMXJ_Time = dwTickCount + 450;
  2434. }
  2435. }
  2436. if(GL_CTHL_bDXK) //顶斜口
  2437. {
  2438. GL_CTHL_bDXK = 0;
  2439. if(GL_CTHL_DXK_VAVLE)
  2440. {
  2441. GL_CTHL_DXK_VAVLE = 0;
  2442. }
  2443. else if(!GL_CTHL_XKTD_VAVLE)
  2444. {
  2445. GL_CTHL_DXK_VAVLE = 1;
  2446. GL_CTHL_GDXM_VAVLE = 1;
  2447. }
  2448. else //条件警告
  2449. {
  2450. GL_CTHL_SetAlarmCode(GL_CTHL_XKTD_ALARM,0);
  2451. }
  2452. }
  2453. if(GL_CTHL_bXKGD) //固定斜码电磁阀
  2454. {
  2455. GL_CTHL_bXKGD = 0;
  2456. GL_CTHL_GDXM_VAVLE = ~GL_CTHL_GDXM_VAVLE;
  2457. }
  2458. if(GL_CTHL_bFKGD) //方块固定
  2459. {
  2460. GL_CTHL_bFKGD = 0;
  2461. GL_CTHL_FKGD_VAVLE = ~GL_CTHL_FKGD_VAVLE;
  2462. }
  2463. if(GL_CTHL_bCXQJD) //插销前夹带
  2464. {
  2465. GL_CTHL_bCXQJD = 0;
  2466. GL_CTHL_CXQJD_VAVLE = ~GL_CTHL_CXQJD_VAVLE;
  2467. }
  2468. if(GL_CTHL_bCXSY) //插销下移电磁阀
  2469. {
  2470. GL_CTHL_bCXSY = 0;
  2471. GL_CTHL_CXSX_VAVLE = !GL_CTHL_CXSX_VAVLE;
  2472. }
  2473. //
  2474. if(GL_CTHL_bCXHT)
  2475. {
  2476. GL_CTHL_bCXHT = 0;
  2477. //GL_CTHL_CXHT_VAVLE = ~GL_CTHL_CXHT_VAVLE;
  2478. if(GL_CTHL_CL_MotorStep == 0)
  2479. GL_CTHL_CL_MotorStep = 20;
  2480. SetEn(Y_AXIS, MOTOR_EN);
  2481. GL_CTHL_CXDW_Stop = 1;
  2482. }
  2483. if(GL_CTHL_bBB)
  2484. {
  2485. GL_CTHL_bBB = 0;
  2486. GL_CTHL_BB_VAVLE = ~GL_CTHL_BB_VAVLE;
  2487. }
  2488. if(GL_CTHL_bCXDWZ) //Y14 插销定位针电磁阀
  2489. {
  2490. GL_CTHL_bCXDWZ = 0;
  2491. if(GL_CTHL_CXDWZ_VAVLE)
  2492. GL_CTHL_CXDWZ_VAVLE = 0;
  2493. else if(GL_CTHL_HSLiao_Origin_IN)
  2494. {
  2495. GL_CTHL_CXDWZ_VAVLE = 1;
  2496. }
  2497. else //条件警告
  2498. {
  2499. GL_CTHL_SetAlarmCode(GL_CTHL_HENSONGLIAO_ALARM,0);
  2500. }
  2501. }
  2502. if(GL_CTHL_bCXHJD) //Y15 插销后夹带电磁阀
  2503. {
  2504. GL_CTHL_bCXHJD = 0;
  2505. GL_CTHL_CXHJD_VAVLE =~GL_CTHL_CXHJD_VAVLE;
  2506. }
  2507. if(GL_CTHL_bCXHDW) //Y16 插销后定位电磁阀
  2508. {
  2509. GL_CTHL_bCXHDW = 0;
  2510. if(GL_CTHL_CXHDW_VAVLE)
  2511. GL_CTHL_CXHDW_VAVLE = 0;
  2512. else if(!GL_CTHL_CXQJD_VAVLE)
  2513. GL_CTHL_CXHDW_VAVLE = 1;
  2514. else//条件警告
  2515. {
  2516. GL_CTHL_SetAlarmCode(GL_CTHL_CXQJD_ALARM,0);
  2517. }
  2518. }
  2519. if(GL_CTHL_bFirst_CT) //Y20 一次穿头电磁阀
  2520. {
  2521. GL_CTHL_bFirst_CT = 0;
  2522. GL_CTHL_First_CT_VAVLE = ~GL_CTHL_First_CT_VAVLE;
  2523. }
  2524. if(GL_CTHL_bHLJJ) //Y21 合链夹具电磁阀
  2525. {
  2526. GL_CTHL_bHLJJ = 0;
  2527. GL_CTHL_HLJJ_VAVLE = ~GL_CTHL_HLJJ_VAVLE;
  2528. }
  2529. if(GL_CTHL_bHL)
  2530. {
  2531. GL_CTHL_bHL = 0;
  2532. }
  2533. if(GL_CTHL_bCXSCDW) //Y23 插销上止定位电磁阀
  2534. {
  2535. GL_CTHL_bCXSCDW = 0;
  2536. GL_CTHL_CXSCDW_VAVLE = ~GL_CTHL_CXSCDW_VAVLE;
  2537. }
  2538. //自动装料
  2539. if(GL_CTHL_bAutoZhuangLiao)
  2540. {
  2541. GL_CTHL_bAutoZhuangLiao = 0;
  2542. if(GL_CTHL_ZhuangLiaoStep == 0)
  2543. {
  2544. bTuiLaTouOkFlg = 1;
  2545. bZhuangLiaoOkFlg = 0;
  2546. GL_CTHL_ZhuangLiaoStep = 1;
  2547. GL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
  2548. GL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
  2549. }
  2550. }
  2551. //测试电机
  2552. if(GL_CTHL_bCLMotor_N)
  2553. {
  2554. SetEn(Y_AXIS, MOTOR_EN);
  2555. if(!GL_CTHL_SF_Origin_IN)
  2556. {
  2557. if(!Y_DRV)
  2558. // Y轴 运行速度 启动速度 加速度 减速度
  2559. AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,1000,15,15);
  2560. }
  2561. else
  2562. {
  2563. GL_CTHL_bCLMotor_N = 0;
  2564. }
  2565. }
  2566. if(GL_CTHL_bCLMotor_P) //后退限位已经取消
  2567. {
  2568. SetEn(Y_AXIS, MOTOR_EN);
  2569. if(!Y_DRV)
  2570. // Y轴 运行速度 启动速度 加速度 减速度
  2571. AxisContinueMoveAcc(Y_AXIS,2000,DIR_P,1000,1000,15,15);
  2572. }
  2573. if(!GL_CTHL_bCLMotor_P && !GL_CTHL_bCLMotor_N && (GL_CTHL_TD_MotorStep == 0) && (GL_CTHL_bFKCXTDDW_Step==0)&& (GL_CTHL_CL_MotorStep == 0))
  2574. {
  2575. AxisEgmStop(Y_AXIS);//AxisDecStop(Y_AXIS);
  2576. }
  2577. /* if(GL_CTHL_bCLMotor_N)
  2578. {
  2579. GL_CTHL_bCLMotor_N=0;
  2580. SetEn(Y_AXIS, MOTOR_EN);
  2581. if(!Y_DRV)
  2582. // Y轴 运行速度 启动速度 加速度 减速度
  2583. AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,-GL_CTHL_PARAM_CL_Length,2000,2000,50,50,50);
  2584. }
  2585. if(GL_CTHL_bCLMotor_P) //后退限位已经取消
  2586. {
  2587. GL_CTHL_bCLMotor_P=0;
  2588. SetEn(Y_AXIS, MOTOR_EN);
  2589. if(!Y_DRV)
  2590. // Y轴 运行速度 启动速度 加速度 减速度
  2591. AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_PARAM_CL_Length,2000,2000,50,50,50);
  2592. }
  2593. */
  2594. //合链电机返回原点
  2595. if(GL_CTHL_bCLMotor_O)
  2596. {
  2597. GL_CTHL_bCLMotor_O = 0;
  2598. if(GL_CTHL_CL_MotorStep == 0)
  2599. GL_CTHL_CL_MotorStep = 40;
  2600. }
  2601. //拖带方块定位 ,因这步为前拖带定位, 很多电磁阀要关掉
  2602. if(GL_CTHL_bFKTDDW)
  2603. {
  2604. GL_CTHL_bFKTDDW = 0;
  2605. if(GL_CTHL_TD_MotorStep == 0)
  2606. {
  2607. GL_CTHL_XKDW_VAVLE = 0; //斜口定位
  2608. GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
  2609. //GL_CTHL_CXSX_VAVLE = 1; //插销下移
  2610. GL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
  2611. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位
  2612. GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针
  2613. GL_CTHL_bHLJJ = 0; //合链夹具
  2614. GL_CTHL_FKJD_VAVLE = 0; //方块夹带
  2615. if((GetEn(X_AXIS) == MOTOR_DISEN))
  2616. {
  2617. SetEn(X_AXIS, MOTOR_EN);
  2618. GL_CTHL_TD_MotorDelay = dwTickCount + 200;
  2619. }
  2620. else
  2621. GL_CTHL_TD_MotorDelay = dwTickCount + 50;
  2622. GL_CTHL_TD_MotorStep = 1;
  2623. GL_CTHL_cZipCnt = 0;
  2624. }
  2625. }
  2626. //拖带方块插销定位(斜口推带,斜口定位,顶斜口)
  2627. if(GL_CTHL_bFKCXTDDW)
  2628. {
  2629. GL_CTHL_bFKCXTDDW = 0;
  2630. if((GL_CTHL_bFKCXTDDW_Step == 0) && (GL_CTHL_CL_MotorStep == 0) &&
  2631. !GL_CTHL_CTXMSS_VAVLE)
  2632. {
  2633. GL_CTHL_bFKCXTDDW_Step = 1;
  2634. SetEn(X_AXIS, MOTOR_EN);
  2635. GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
  2636. //GL_CTHL_CXSX_VAVLE = 1; //插销上下
  2637. GL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
  2638. GL_CTHL_CXHDW_VAVLE = 0; //插销后定位
  2639. GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针
  2640. GL_CTHL_HLJJ_VAVLE = 0; //合链夹具
  2641. }
  2642. }
  2643. //插销穿入(包含电机前定位,插销下移,后夹,后定位)
  2644. if(GL_CTHL_bCXCR)
  2645. {
  2646. GL_CTHL_bCXCR = 0;
  2647. //拉头模在上面到们并且码勾输出,判断有拉头
  2648. if(GL_CTHL_CTXMSS_VAVLE && GL_CTHL_MGuo_VAVLE && !GL_CTHL_CXQJD_VAVLE &&
  2649. GL_CTHL_CTM_Limit_IN && !GL_CTHL_LTou_Check)
  2650. {
  2651. if(GL_CTHL_CL_MotorStep == 0)
  2652. {
  2653. GL_CTHL_bCXCR_Step = 11;
  2654. GL_CTHL_CXSX_VAVLE = 1; //Y06 插销下移电磁阀关
  2655. GL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
  2656. GL_CTHL_CXHDW_VAVLE = 0;
  2657. // if(GL_CTHL_PARAM_CR_MODE==0)
  2658. // GL_CTHL_CXSCDW_VAVLE = 1;
  2659. // if(GL_CTHL_PARAM_CR_MODE == 1)
  2660. // {
  2661. SetEn(Y_AXIS, MOTOR_EN);
  2662. if(!GL_CTHL_SF_Origin_IN)
  2663. GL_CTHL_CL_MotorStep = 40;
  2664. // }
  2665. }
  2666. }
  2667. else //警告不能自动穿插销
  2668. {
  2669. GL_CTHL_SetAlarmCode(GL_CTHL_WFZIDONGCX_ALARM,0);
  2670. }
  2671. }
  2672. //电机合链动作
  2673. if(GL_CTHL_bMotorHL)
  2674. {
  2675. GL_CTHL_bMotorHL = 0;
  2676. // if(GL_CTHL_PARAM_CR_MODE == 1)
  2677. // {
  2678. if(GL_CTHL_SF_Origin_IN)
  2679. {
  2680. if((GL_CTHL_CL_MotorStep == 0) && !GL_CTHL_CTXMSS_VAVLE && (!GL_CTHL_CTM_Limit_IN))
  2681. {
  2682. bCL_OK_FLG = 0;
  2683. GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
  2684. GL_CTHL_CL_MotorStep = 1;
  2685. GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HLJJ_CL_DELAY + 130;
  2686. if((GetEn(Y_AXIS) == MOTOR_DISEN))
  2687. {
  2688. SetEn(Y_AXIS, MOTOR_EN);
  2689. GL_CTHL_CL_MotorDelay = dwTickCount + 250;
  2690. }
  2691. if((GL_CTHL_LianLengthAutoCheck ==0) || (GL_CTHL_PARAM_CL_Length == 0))
  2692. {
  2693. GL_CTHL_LianLengthAutoCheck = 1000;
  2694. GL_CTHL_PARAM_CL_Length = 1000;
  2695. }
  2696. }
  2697. // }
  2698. else
  2699. {
  2700. GL_CTHL_bCLMotor_O = 1;
  2701. }
  2702. }
  2703. else
  2704. {
  2705. GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
  2706. GL_CTHL_CL_MotorStep = 1;
  2707. GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HLJJ_CL_DELAY;
  2708. }
  2709. }
  2710. //一次穿链动作
  2711. if(GL_CTHL_bCL_First)
  2712. {
  2713. GL_CTHL_bCL_First = 0;
  2714. //拉头模在上面到们并且码勾输出,判断有拉头
  2715. if(GL_CTHL_CTXMSS_VAVLE && GL_CTHL_MGuo_VAVLE && !GL_CTHL_CXQJD_VAVLE &&
  2716. GL_CTHL_CTM_Limit_IN && !GL_CTHL_LTou_Check && (GL_CTHL_CL_MotorStep == 0))
  2717. {
  2718. GL_CTHL_bCLFirst_Step = 19;
  2719. GL_CTHL_CXHJD_VAVLE = 1; //插销后夹带
  2720. GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
  2721. GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
  2722. }
  2723. }
  2724. }
  2725. }
  2726. #endif