GLChuantou_HeLian.c 109 KB

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