JLChuantou_HeLian.c 78 KB

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