YWXChuantou_HeLian_New.c 118 KB

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