1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866 |
- #include "global.h"
- #if JING_LONG_MACHINE == 1
- void JL_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag);
- void JL_CTHL_ManualAction(void);
- void JL_CTHL_AutoStepAction(void);
- void JL_CTHL_TableAction(void);
- void JL_CTHL_TD_Motor(void);
- void JL_CTHL_CL_Motor(void);
- void JL_CTHL_CheckStart(void);
- void JL_CTHL_TLiao_Step(void); //推料(推拉头)
- void JL_CTHL_AlarmProtect(void);
- void JL_CTHL_ZLT_Step(void);
- void JL_CTHL_ZhenDongAction(void);
- void JL_CTHL_bFKCXTDDWStep(void);
- void JL_CTHL_bCXCRStep(void);
- void JL_CTHL_bCLFirstStep(void);
- //故障报警
- void JL_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag)
- {
- SetAlarmCode(JL_CTHL_ALARM_ADDR,alarm_code);
- // bAlarmStop = 0;
- // if(cStopFlag)
- if(!cWULATOUCnt && !cXiaoChaCNT && !cCHULIANBAOJIN)
- {
- bAlarmStop = 1;
- }
- else
- {
- cWULATOUCnt=0;
- }
-
-
-
- }
- //初始化动作
- void JL_CTHL_InitAction(void)
- {
- float buff_pulse,buff_dist;
-
- buff_pulse = JL_CTHL_PARAM_CYCLE_PULSE;
- buff_dist = JL_CTHL_PARAM_CYCLE_LENGTH;
-
- XGearRatio = buff_pulse/buff_dist;
-
- buff_pulse = 2000;//JL_CTHL_PARAM_CYCLE_PULSE;
- buff_dist = 750;//JL_CTHL_PARAM_CYCLE_LENGTH;
- YGearRatio = buff_pulse/buff_dist;
-
-
-
- bYFirstDingWeiFlg = 1;
- user_datas[121] = 0;
- user_datas[122] = 0;
- user_datas[123] = 0;
-
- SetEnReverse(X_AXIS, 1);
- SetEnReverse(Y_AXIS, 1);
- SetEnReverse(Z_AXIS, 1);
-
- SetDirReverse(X_AXIS, 0);
- SetDirReverse(Y_AXIS, 0);
- SetDirReverse(Z_AXIS, 0);
-
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- SetEn(Z_AXIS, MOTOR_DISEN);
-
- SetAlarmCode(JL_CTHL_ALARM_ADDR,0);
- // QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- }
- void JL_CTHL_Action(void)
- {
-
- // user_datas[122] =axis_x->cur_speed;
- // user_datas[123] = JL_CTHL_bCXCR_Step;
- dwXRealPos = GetPos(X_AXIS);
- dwYRealPos = GetPos(Y_AXIS);
- dwZRealPos = GetPos(Z_AXIS);
- user_datas[121] = JL_CTHL_PARAM_DXKFZ_LENTH;//JL_CTHL_LianLengSave;
- // user_datas[122] =
- // user_datas[123] =
- // user_datas[124] = //dwXRealPos;
- // user_datas[125] = //dwYRealPos;
-
- // user_datas[126] = //JL_CTHL_CL_MotorStep;
- // user_datas[127] = //JL_CTHL_TD_MotorStep;
- // user_datas[128] = //JL_CTHL_AutoStep;
-
- JL_CTHL_ZhenDongAction();
- JL_CTHL_AlarmProtect();
- JL_CTHL_CheckStart();
- JL_CTHL_ZLT_Step();
- JL_CTHL_TLiao_Step();
-
- JL_CTHL_TD_Motor();
- JL_CTHL_CL_Motor();
- JL_CTHL_bFKCXTDDWStep();
- JL_CTHL_bCXCRStep();
- JL_CTHL_bCLFirstStep();
- JL_CTHL_ManualAction();
-
- JL_CTHL_AutoStepAction();
- }
- void JL_CTHL_AlarmProtect(void)
- {
-
-
-
- }
- //自动动作
- void JL_CTHL_AutoStepAction(void)
- {
-
-
-
- if(bRunning)
- {
- switch(JL_CTHL_AutoStep)
- {
- case 1:
-
- /* JL_CTHL_AutoStep = 10; //测试拖带定位
- JL_CTHL_AutoDelay = dwTickCount + 1000;
- break; */
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
- JL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- JL_CTHL_FKGD_VAVLE = 0; //方块固定关
- // JL_CTHL_XKDW_VAVLE = 1;
- JL_CTHL_AutoStep = 2;
- // JL_CTHL_AutoDelay = dwTickCount + 10;
- if(JL_CTHL_ZhuangLiaoStep == 0)
- {
- JL_CTHL_ZhuangLiaoStep = 1;
- JL_CTHL_TryCnt = 0;
- }
- }
-
- break;
- case 2:
- if(!JL_CTHL_XKTD_Origin_IN)// && (dwTickCount >= JL_CTHL_AutoDelay)) //斜口推带原位离开
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 3;
- JL_CTHL_XKDW_VAVLE = 1;
- JL_CTHL_AutoDelay = dwTickCount + 20;
- }
- }
- break;
- case 3://斜口定位
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- JL_CTHL_AutoStep = 4;
- // JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_XKDW_TD_DELAY;
- }
- break;
- case 4:
- if(!cBanAuTo)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- AxisMovePosAccDecNotStop(X_AXIS,1600,1500,600,1000,5,20,00);
- JL_CTHL_AutoStep = 5;
- cDJzzcd=0;
- JL_CTHL_XSavePosBuff = dwXRealPos;
- // SetPos(X_AXIS, 0); //启动位置设为0点
- if(cZipCnt < 1)
- JL_CTHL_AutoDelay = dwTickCount +350;
- else
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_FKJD_DELAY;
- }
- }
- else
- {
- JL_CTHL_AutoStep = 5;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_FKJD_DELAY;
- JL_CTHL_XSavePosBuff = dwXRealPos;
- }
-
- break;
- case 5:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- JL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
- }
- if(bCL_EN_FLG && (dwXRealPos >= 230) && JL_CTHL_XKSC_Limit_IN)
- {
- JL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- }
-
- if(JL_CTHL_XKSC_Limit_IN) //方块上止到位
- {
- if(!JL_CTHL_PARAM_GYZZ_LENGTH)
- AxisEgmStop(X_AXIS);
- else
- {
- if(!cDJzzcd)
- {
- AxisMovePosAccDec(X_AXIS,1000,JL_CTHL_PARAM_GYZZ_LENGTH,800,600,10,20,0);
- cDJzzcd=1;
- }
-
- }
-
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_QDXK_VAVLE = 1;
- JL_CTHL_FKJD_VAVLE=0;
-
- JL_CTHL_AutoStep = 6;
- //
-
- JL_CTHL_bLTCHECK_Delay = dwTickCount + 20;
- //电机穿入可以启动
- bCL_OK_FLG = 1; //不用穿合链的话认为已经完成
- if(bCL_EN_FLG)
- {
- bCL_OK_FLG = 0;
- JL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- JL_CTHL_CL_MotorStep = 1;
- JL_CTHL_CL_MotorDelay = dwTickCount + JL_CTHL_PARAM_HLJJ_CL_DELAY;
-
- JL_CTHL_AutoDelay = dwTickCount + 50 + JL_CTHL_PARAM_HLJJ_CL_DELAY;
- }
- else
- {
- JL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- }
- else if(dwXRealPos >= (JL_CTHL_XSavePosBuff + 3000))
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_FKCXDW_ALARM,bRunning); //方块插销定位异常警告
-
- }
- break;
- case 6:
- if((dwYRealPos > 1000) || JL_CTHL_CL_MotorStep==0)
- {
- JL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- }
-
- if(JL_CTHL_XKTD_Origin_IN) //斜口推带回到原位
- {
- if(bZhuangLiaoOkFlg && (JL_CTHL_ZhuangLiaoStep == 0))
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- if(dwTickCount >= JL_CTHL_bLTCHECK_Delay)
- {
- if(bSingOneFlg)
- {
- JL_CTHL_AutoStep = 0;
- bRunning = 0;
- }
- else
- {
- if(!JL_CTHL_LTou_Check)
- {
- if(JL_CTHL_PARAM_DXKFZ_LENTH && !X_DRV && JL_CTHL_HSLiao_Origin_IN) //拖带电机反转
- {
- user_datas[122] =dwXRealPos;
- AxisMovePosAccDec(X_AXIS,8000,-JL_CTHL_PARAM_DXKFZ_LENTH,800,600,6,6,0);
- JL_CTHL_AutoStep = 7;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- JL_CTHL_CTXM_VAVLE = 1; //穿头下模上升
- if(!JL_CTHL_PARAM_NLSL_MODE)
- JL_CTHL_FKJD_VAVLE= 0; //方块夹带气缸关
-
- }
- else if(dwTickCount >= (JL_CTHL_AutoDelay+3000))
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_HSLiao_Origin_ALARM,bRunning); // 没有拉头
- }
- if(JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 1;
-
-
-
- }
- else
- {
- cWULATOUCnt=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_ZLT_ALARM,bRunning); // 没有拉头
- }
- }
- }
- }
- }
- }
- else if((dwTickCount >= JL_CTHL_AutoDelay) && !JL_CTHL_XKTD_VAVLE && !cBanAuTo)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_XKTD_Origin_ALARM,bRunning); //斜口推带回到异常
- }
- break;
- case 7:
-
- if(!JL_CTHL_CTM_Origin_IN)
- {
- JL_CTHL_JLTou_VAVLE = 0; //接拉头
- }
- if(JL_CTHL_CTM_Limit_IN)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- if(JL_CTHL_PARAM_NLSL_MODE)
- {
-
- JL_CTHL_XKTD_VAVLE=1;
- }
- JL_CTHL_JLTou_VAVLE = 0;
- JL_CTHL_AutoStep = 8;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_DXKYS_DELAY;
- }
-
- }
- else if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CTM_Limit_ALARM,bRunning); //穿头下模上升异常
- }
- break;
-
- case 8:
-
- if(!X_DRV) //延时顶斜口
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- if((dwTickCount >= JL_CTHL_AutoDelay) || (JL_CTHL_PARAM_NLSL_MODE))
- {
- if(!JL_CTHL_PARAM_NLSL_MODE)
- JL_CTHL_DXK_VAVLE=1;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_DXK_XKDW_Off_DELAY;
- JL_CTHL_AutoStep = 9;
- }
- }
-
- }
- break;
- case 9:
- if((dwTickCount >= JL_CTHL_AutoDelay) && (bCL_OK_FLG)) //顶斜口延时退斜口上止定位
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- // AxisMovePosAccDec(X_AXIS,2000,-150,1200,1200,3,6,0); //反转1.5CM
- JL_CTHL_XKDW_VAVLE = 0; //斜口上止定位关
- JL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸关
- JL_CTHL_AutoStep = 10;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_XK_CR_DELAY;
- }
- }
- break;
- case 10:
- if(!cBanAuTo)
- {
- if((dwTickCount >= JL_CTHL_AutoDelay) && !X_DRV)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_TD_MotorStep = 10; //启动拖带穿入
- JL_CTHL_AutoStep = 11;
- }
-
- }
- }
- else
- {
- JL_CTHL_AutoStep = 801;
- JL_CTHL_AutoDelay = dwTickCount + 1000;
- }
- break;
- case 801:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
-
- bRunning=0;
- cBanAuTo=0;
- JL_CTHL_QDXK_VAVLE=0;
- JL_CTHL_XKTD_VAVLE = 0;
- JL_CTHL_DXK_VAVLE=0;
- JL_CTHL_AutoStep = 0;
-
- }
- break;
- case 11:
-
- if(JL_CTHL_TD_MotorStep == 0) //穿入定位完成
- {
- /* //测试拖带定位
- JL_CTHL_AutoStep = 1;
- JL_CTHL_AutoDelay = dwTickCount + 1000;
- if(cZipCnt<3)
- cZipCnt++;
- break; */
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
-
- JL_CTHL_XKDW_VAVLE = 0; //斜口上止定位关
- JL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- JL_CTHL_CXSCDW_VAVLE = 1; //Y21 插销上止定位电磁阀
- cXcxcrCnt = 0;
- if(JL_CTHL_CL_MotorStep == 0)
- {
- JL_CTHL_CXQJD_VAVLE = 1;
- }
- JL_CTHL_AutoStep = 12;
- JL_CTHL_AutoDelay = dwTickCount;
- }
-
- }
- break;
- case 12:
- if(JL_CTHL_CL_MotorStep == 0) //插销前夹带回到原位
- {
- if(JL_CTHL_SF_Origin_IN)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 14;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_XCQJD_XCDW_DELAY;
- if(cXcxcrCnt != 1)
- {
- JL_CTHL_CXQJD_VAVLE = 1;
- }
- }
- }
- else if(!JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep=50;
-
- }
-
- }
- break;
- case 14:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_XKDW_VAVLE = 1; //斜口定位
- JL_CTHL_AutoStep = 15;
- JL_CTHL_FKGD_VAVLE = 1; //方块固定
- //Y轴启动插销
- if(cXcxcrCnt != 1)
- {
- JL_CTHL_CL_MotorStep = 20; //插销定位
- }
- }
- }
- break;
- case 15:
- if(JL_CTHL_CL_MotorStep == 0) //插销定位完成
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 16;
- JL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- JL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- JL_CTHL_AutoDelay = dwTickCount + 10; //延时插销下移
- }
- }
- break;
- case 16:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 17;
- if(JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 0;
- else
- JL_CTHL_CXJL_VAVLE = 1; //Y06 插销下移电磁阀
- JL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
- }
- }
- break;
- case 17:
- if(JL_CTHL_PARAM_CXJL_MODE)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- if(JL_CTHL_CXJL_Limit_IN)
- {
- JL_CTHL_AutoStep = 18;
- if( cXcxcrCnt==0 && !X_DRV && !cCXCONE) //拖带电机反转
- {
- AxisMovePosAccDec(X_AXIS,8000,-JL_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- JL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- JL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- JL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_SCDWOff_CXDW_DELAY;
- }
-
- }
- else if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CXJL_Limit_ALARM,bRunning); //插销下移异常
-
- }
- }
- else
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 18;
- if( cXcxcrCnt==0 && !X_DRV && !cCXCONE) //拖带电机反转
- {
- AxisMovePosAccDec(X_AXIS,8000,-JL_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- JL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- JL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
-
- JL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_SCDWOff_CXDW_DELAY;
- }
- }
- break;
- case 18:
- // if(START_IN_UP)
- {
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 19;
- cBAOHUCNT=0;
- JL_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
- JL_CTHL_AutoDelay = dwTickCount + 500; //插销穿入到位异常时间
- JL_CTHL_CL_MotorStep = 50; //合链电机回原点
- }
- }
- }
- break;
- case 19:
-
- if(JL_CTHL_CX_Limit_IN && (cXcxcrCnt<4))
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- cXcxcrCnt=0;
- cXiaoChaCNT=0;
- user_datas[100]=0;
- bZhuangLiaoOkFlg = 0;
- JL_CTHL_CXJL_VAVLE=0;
- JL_CTHL_AutoStep = 901;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_FKGD_DELAY; //退方块固定时间
- JL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- }
-
- }
- else if ((dwTickCount >= JL_CTHL_AutoDelay) && (cXcxcrCnt<3) )
- {
- cXcxcrCnt++;
- JL_CTHL_CXHJD_VAVLE=0;
- JL_CTHL_CXHDW_VAVLE=0;
- if(!JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE=0;
- else
- JL_CTHL_CXJL_VAVLE=1;
- if(cXcxcrCnt<3)
- {
- JL_CTHL_CXSCDW_VAVLE=1;
- JL_CTHL_AutoStep = 12;
- JL_CTHL_AutoDelay = dwTickCount + 120;
- }
- }
- else if((dwTickCount >= (JL_CTHL_AutoDelay +3000)) && !JL_CTHL_CX_Limit_IN )
- {
- cXiaoChaCNT=1;
- if(!JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE=0;
- else
- JL_CTHL_CXJL_VAVLE=1;
- JL_CTHL_CXHJD_VAVLE =0;
-
- cBAOHUCNT=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- }
-
- if( cXcxcrCnt > 2)
- {
- cXiaoChaCNT=1;
-
- JL_CTHL_CXJL_VAVLE=0;
- JL_CTHL_CXHJD_VAVLE =0;
- cBAOHUCNT=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- if(JL_CTHL_START_IN_UP)
- {
-
- JL_CTHL_SetAlarmCode(0,bRunning);
- JL_CTHL_CXSCDW_VAVLE=1;
- JL_CTHL_AutoStep = 12;
- JL_CTHL_CXHJD_VAVLE=0;
- cXiaoChaCNT=0;
- cBAOHUCNT=0;
- cXcxcrCnt=0;
- JL_CTHL_CXHDW_VAVLE=0;
- if(!JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE=0;
- else
- JL_CTHL_CXJL_VAVLE=1;
-
-
- }
- }
-
- break;
-
- case 901:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_FKGD_VAVLE = 0; //方块固定退
- JL_CTHL_AutoStep = 20;
- if(!cBAOHUCNT)
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
- else
- {
- JL_CTHL_AutoDelay = dwTickCount + 1000;//手动插销保护时间
- cBAOHUCNT=0;
- }
- }
-
- }
- break;
- case 20:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 21;
- JL_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- break;
- case 21:
- if(!JL_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 22;
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_First_CL_Timer; //一次穿入时间
- }
- }
- else if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
- }
- break;
- case 22:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 23;
- JL_CTHL_MGuo_VAVLE = 0; //码勾退
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_PARAM_MGOff_XiaMo_DELAY;
- JL_CTHL_FKGD_VAVLE = 0; //方块固定退
- JL_CTHL_FKJD_VAVLE=0;
- JL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- JL_CTHL_CXJL_VAVLE = 0; //Y06 插销下移电磁阀关
- }
- }
- break;
- case 23:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 24;
- JL_CTHL_CTXM_VAVLE = 0; //穿头下模下降
- JL_CTHL_AutoDelay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- break;
- case 24:
- if(!JL_CTHL_CTM_Limit_IN)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 25;
- JL_CTHL_AutoDelay = dwTickCount + 20; //一次穿入延时返回
- }
- }
- else if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CTM_Origin_ALARM,bRunning);//穿头下模下降异常
- }
- break;
- case 25:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- JL_CTHL_AutoStep = 26;
- JL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- JL_CTHL_AutoDelay = dwTickCount + 5;
- JL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- //退下出错警告
- JL_CTHL_AutoDelay1 = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- JL_CTHL_AutoStep1 = 1;
- }
- }
- break;
-
-
- case 26:
- if(dwTickCount >= JL_CTHL_AutoDelay)
- {
- if(!JL_CTHL_bDanBu || JL_CTHL_START_IN_UP)
- {
- if(!cCXCONE)
- {
- JL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
- JL_CTHL_FKGD_VAVLE = 0; //方块固定关
- JL_CTHL_AutoStep = 2;
- bCL_EN_FLG = 1;
- cXcxcrCnt=0;
- AddToTal(JL_CTHL_TOTAL_ADDR);
-
- CalProSP(JL_CTHL_SPEED_ADDR);
- if(cZipCnt<3)
- cZipCnt++;
- }
- else
- {
- bRunning=0;
- cCXCONE=0;
- JL_CTHL_AutoStep = 0;
-
- }
- }
-
- }
- break;
-
- }
- }
- //退下模后启动送拉头
- switch(JL_CTHL_AutoStep1)
- {
- case 1:
- if(cStopMode==1)
- {
- bCL_EN_FLG=1;
- cStopMode=2;
- bStop=1;
- }
- if(JL_CTHL_CTM_Origin_IN && JL_CTHL_First_CT_Origin_IN)
- {
- JL_CTHL_ZhuangLiaoStep = 1;
- JL_CTHL_TryCnt = 0;
- JL_CTHL_AutoStep1 = 0;
- JL_CTHL_MGuo_VAVLE = 0;
- JL_CTHL_JLTou_VAVLE = 0;
- }
- else if(dwTickCount >= JL_CTHL_AutoDelay1)
- {
- //穿头模和一次穿入回位异常
- if(!JL_CTHL_CTM_Origin_IN)
- JL_CTHL_SetAlarmCode(JL_CTHL_CTM_Origin_ALARM,bRunning);
- else if(!JL_CTHL_First_CT_Origin_IN)
- JL_CTHL_SetAlarmCode(JL_CTHL_First_CT_Origin_ALARM,bRunning);
- }
- break;
-
- }
-
- }
- void JL_CTHL_CheckStart(void)
- {
- //监控
- if(cBanAuTo)
- {
- JL_CTHL_PARAM_XCRU=1;
- }
- else
- {
- JL_CTHL_PARAM_XCRU=0;
- }
- //监控
- if(cCXCONE)
- {
- JL_CTHL_PARAM_CXCR=1;
- }
- else
- {
- JL_CTHL_PARAM_CXCR=0;
- }
-
- if(cXCXQXQD)
- {
- if(JL_CTHL_START_IN_UP || bStart)
- {
- bStart=0;
- if(!bRunning)
- {
- if(JL_CTHL_SafeDoor_IN )
- {
- bRunning=1;
- cXCXQXQD =0;
- JL_CTHL_TD_MotorStep = 0;
- JL_CTHL_AutoStep=11;
- }
- else
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
- }
- }
-
-
- }
- if(cWULATOUCnt) // 无拉头警告后按
- {
- if(JL_CTHL_START_IN_UP || bStart)
- {
- bStart=0;
- if(!bRunning)
- {
- if(JL_CTHL_SafeDoor_IN)
- {
- bRunning=1;
- JL_CTHL_TryCnt=0;
- cWULATOUCnt=0;
- JL_CTHL_ZhuangLiaoStep = 1;
- JL_CTHL_AutoStep=6;
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg= 0;
- JL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- }
- else
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
- }
- }
- }
- if(!JL_CTHL_SafeDoor_IN && bRunning && !cBanAuTo && !cCXCONE)
- {
- bStop=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
-
- //启动 自动启动 单一自动
- if((JL_CTHL_START_IN_UP || bStart ) && !cWULATOUCnt && !cXCXQXQD)
- {
- if(cCHULIANBAOJIN) //无链停机启动
- {
- cCHULIANBAOJIN=0;
- SetEn(X_AXIS, MOTOR_EN);
- // dwXRealPos=0;
- JL_CTHL_TD_MotorStep=9;
-
-
- if(GetAlarm(Y_AXIS)==0 || GetAlarm(X_AXIS)==0)
- {
- SetClr(Y_AXIS, MOTOR_NOALARM);
- SetClr(X_AXIS, MOTOR_NOALARM);
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- JL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- cZipCnt=0;
- JL_CTHL_TD_MotorDelay = dwTickCount + 500;
- JL_CTHL_AutoDelay = dwTickCount + 150;
- if(GetAlarmCode(JL_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(JL_CTHL_ALARM_ADDR,0);
-
- }
-
- if(!bRunning)
- {
- if(JL_CTHL_SafeDoor_IN)
- {
- cStopMode=0;
- bRunning = 1;
- cWULATOUCnt=0;
- cHeLian=0;
- SetEn(X_AXIS, MOTOR_EN);
- SetEn(Y_AXIS, MOTOR_EN);
- JL_CTHL_CL_MotorStep = 40;
- JL_CTHL_AutoStep = 1;
- bTuiLaTouOkFlg = 1;
- JL_CTHL_PARAM_ZDP_AUTO= 0;
- bZhuangLiaoOkFlg= 0;
- JL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- // bCL_EN_FLG = 0;
- cZipCnt = 0;
- cQDXK_DXK=0;
- JL_CTHL_LianLengthCheck = 0;
- cStopInCnt = 0;
- }
- else
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
- }
- bStart = 0;
- }
-
- //停止
- if(JL_CTHL_STOP_IN_UP || bStop)
- {
-
- if(cStopMode < 2)
- cStopMode++;
- if(bRunning && cStopMode==2)
- {
- cBanAuTo=0;
- cCXCONE=0;
- bRunning=0;
- cStopMode=0;
- cXcxcrCnt=0;
- cXCXQXQD=0;
- cCHULIANBAOJIN=0;
- cWULATOUCnt=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- JL_CTHL_AutoStep = 0;
- JL_CTHL_CL_MotorStep =0;
- JL_CTHL_bCLFirst_Step=0;
- JL_CTHL_ZhuangLiaoStep=0;
- // JL_CTHL_XKTD_VAVLE = 0;
- cQDXK_DXK=0;
- // JL_CTHL_XKDW_VAVLE =0;
- if(JL_CTHL_SF_ALR_IN )
- {
- JL_CTHL_SF_ALR_CLR=1;
- JL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarm(Y_AXIS)==0 || GetAlarm(X_AXIS)==0)
- {
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- SetClr(Y_AXIS, MOTOR_NOALARM);
- SetClr(X_AXIS, MOTOR_NOALARM);
- JL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarmCode(JL_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(JL_CTHL_ALARM_ADDR,0);
-
- }
- else if(!bRunning)
- {
- cBanAuTo=0;
- cCXCONE=0;
- bRunning=0;
- cXcxcrCnt=0;
- cStopMode=0;
- cCHULIANBAOJIN=0;
- cXCXQXQD=0;
- cWULATOUCnt=0;
- bCL_EN_FLG=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- cStopMode=0;
- cQDXK_DXK=0;
- if(JL_CTHL_SF_ALR_IN )
- {
- JL_CTHL_SF_ALR_CLR=1;
- JL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarm(Y_AXIS)==0 || GetAlarm(X_AXIS)==0)
- {
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- SetClr(Y_AXIS, MOTOR_NOALARM);
- SetClr(X_AXIS, MOTOR_NOALARM);
- JL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- JL_CTHL_TLiao_VAVLE=0;
- JL_CTHL_HSLiao_VAVLE =0;
- JL_CTHL_JLTou_VAVLE =0;
- JL_CTHL_XKTD_VAVLE =0;
- JL_CTHL_XKDW_VAVLE =0;
- JL_CTHL_DXK_VAVLE =0;
- JL_CTHL_CXJL_VAVLE =0;
- JL_CTHL_CTXM_VAVLE =0;
- JL_CTHL_First_CT_VAVLE =0;
- JL_CTHL_FKGD_VAVLE =0;
- JL_CTHL_CXQJD_VAVLE =0;
- JL_CTHL_CXDWZ_VAVLE =0;
- JL_CTHL_CXHJD_VAVLE =0;
- JL_CTHL_CXHDW_VAVLE =0;
- JL_CTHL_FKJD_VAVLE =0;
- JL_CTHL_HLJJ_VAVLE =0;
- JL_CTHL_CXSCDW_VAVLE =0;
- JL_CTHL_MGuo_VAVLE =0;
- JL_CTHL_QDXK_VAVLE=0;
-
- JL_CTHL_AutoStep = 0;
- JL_CTHL_ZhuangLiaoStep=0;
- JL_CTHL_TLiaoStep=0;
- JL_CTHL_TD_MotorStep=0;
- JL_CTHL_JiaLianStep =0;
- JL_CTHL_SongLiaoStep =0;
- JL_CTHL_CL_MotorStep =0;
- JL_CTHL_AutoStep1 =0;
- JL_CTHL_bFKCXTDDW_Step=0;
- JL_CTHL_bCXCR_Step=0;
- JL_CTHL_bCLFirst_Step=0;
- if(GetAlarmCode(JL_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(JL_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
-
- JL_CTHL_TLiaoStep = 0;
- JL_CTHL_AutoStep = 0;
-
- //穿合链电机是往零点方向时可以停止
- if(GetDir(Y_AXIS) == DIR_N)
- AxisEgmStop(Y_AXIS);
-
- }
- bStop=0;
- }
-
- if(bAlarmStop)
- {
- bRunning = 0;
- bAlarmStop=0;
- cStopMode=0;
- cXcxcrCnt=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- JL_CTHL_AutoStep = 0;
- cQDXK_DXK=0;
- JL_CTHL_CL_MotorStep =0;
- JL_CTHL_bCLFirst_Step=0;
- JL_CTHL_SongLiaoStep =0;
- JL_CTHL_ZhuangLiaoStep=0;
- // JL_CTHL_XKTD_VAVLE = 0;
- // JL_CTHL_XKDW_VAVLE =0;
-
- }
- }
- //拖带电机控制动作 X轴
- void JL_CTHL_TD_Motor(void) //
- {
- #if 1
- switch(JL_CTHL_TD_MotorStep)
- {
- //1步开始,纯定位, 没有穿入
- case 1:
- if(dwTickCount >= JL_CTHL_TD_MotorDelay) //给锁轴时间
- {
- bCheckEN_FLG = 1;
- JL_CTHL_CheckInX02PosBuff= 0;
- JL_CTHL_TD_MotorStep = 2;
- SetPos(X_AXIS, 0); //启动位置设为0点
- AxisContinueMoveAcc(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,DIR_P,800,600,15,15);
- JL_CTHL_X_CXPosBuff=0;
- }
- break;
- case 2://检测到过链
- if(dwXRealPos > 400) //穿入2CM后退
- {
- if(JL_CTHL_PARAM_NLSL_MODE)
- {
- JL_CTHL_XKTD_VAVLE=0;
- }
- JL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- JL_CTHL_QDXK_VAVLE = 0;
- }
- if(dwXRealPos >= JL_CTHL_PARAM_WLCDSHEZHI_LENTH)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- }
- if(JL_CTHL_FK_Check)
- {
- JL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- JL_CTHL_QDXK_VAVLE = 0;
- JL_CTHL_XSavePosBuff = dwXRealPos;
- JL_CTHL_TD_MotorStep = 3;
- // user_datas[123] = dwXRealPos - JL_CTHL_CheckInX02PosBuff;
- if((dwXRealPos >= JL_CTHL_CheckInX02PosBuff) && JL_CTHL_CheckInX02PosBuff)
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_FKDW_Length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,250,40);
- else
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_FKDW_Length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,250,40);
- }
- break;
- case 3:
- if(JL_CTHL_CXSC_Limit_IN_DW)
- {
- JL_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
-
- if(!X_DRV || (dwXRealPos >= (JL_CTHL_XSavePosBuff + JL_CTHL_PARAM_FKDW_Length)))
- {
- AxisEgmStop(X_AXIS);
- JL_CTHL_TD_MotorStep =4 ;
- JL_CTHL_LianLengthAutoCheck = dwXRealPos;
- }
- break;
- case 4:
- if(JL_CTHL_PARAM_XCX_LENTH) //0的话不判断位置
- {
-
- if ((dwXRealPos - JL_CTHL_X_CXPosBuff) > (JL_CTHL_PARAM_XCX_LENTH + JL_CTHL_PARAM_XCXWC_LENTH))
- {
- // user_datas[121] = 1;
- JL_CTHL_TD_MotorStep = 0;
- JL_CTHL_SetAlarmCode(JL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
-
- else if(JL_CTHL_X_CXPosBuff == 0)
- {
- // user_datas[121] = 3;
- JL_CTHL_TD_MotorStep = 0;
- JL_CTHL_SetAlarmCode(JL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else
- {
- JL_CTHL_TD_MotorStep = 0;
- JL_CTHL_X_CXPosBuff=dwXRealPos;
-
- }
-
- }
- else
- {
- JL_CTHL_TD_MotorStep = 0;
- // JL_CTHL_X_CXPosBuff=dwXRealPos;
- }
- break;
-
- case 9:
- if(dwTickCount >= JL_CTHL_TD_MotorDelay)
- {
- JL_CTHL_TD_MotorStep = 10;
- JL_CTHL_TD_MotorDelay=dwTickCount+500;
- SetEn(X_AXIS, MOTOR_EN);
-
- }
- break;
-
- case 10:
- if(dwTickCount >= JL_CTHL_TD_MotorDelay)
- {
-
- JL_CTHL_TD_MotorStep = 11;
- SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
- AxisContinueMoveAcc(X_AXIS,JL_CTHL_PARAM_TDCR_LowSpeed,DIR_P,1200,1200,15,15);
- JL_CTHL_CheckInX02PosBuff= 0;
- JL_CTHL_X_CXPosBuff=0;
- bCheckEN_FLG = 1;
- }
- break;
- case 11:
- if(dwXRealPos > 350) //穿入2CM后退
- {
- if(JL_CTHL_PARAM_NLSL_MODE)
- {
- JL_CTHL_XKTD_VAVLE=0;
- }
- JL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- JL_CTHL_QDXK_VAVLE =0;
- }
- if(dwXRealPos > JL_CTHL_PARAM_TDCR_LowSpeedLength) //穿入2CM后退
- {
-
- JL_CTHL_CheckInX02PosBuff= 0;
- JL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- JL_CTHL_QDXK_VAVLE = 0;
- if(JL_CTHL_PARAM_NLSL_MODE)
- {
- JL_CTHL_XKTD_VAVLE=0;
- }
- JL_CTHL_TD_MotorStep = 12;
- if((cZipCnt < 2) || (JL_CTHL_LianLengthCheck < JL_CTHL_PARAM_TDCR_LowSpeedLength))
- AxisContinueMoveAcc(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,DIR_P,3000,600,10,10);
- else ////两段速度移动距离
- {
-
- AxisMovePosAccDecNotStop(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed ,JL_CTHL_LianLengthCheck-(JL_CTHL_PARAM_TDCR_LowSpeedLength),1500,7000,30,300,250);
-
- }
- }
-
- if(JL_CTHL_FK_Check) //在这里检测到说明速度还没有起来
- {
- // JL_CTHL_SongDai_VAVLE=1;
- JL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- JL_CTHL_QDXK_VAVLE = 0;
- if(JL_CTHL_PARAM_NLSL_MODE)
- {
- JL_CTHL_XKTD_VAVLE=0;
- }
- JL_CTHL_TD_MotorDelay= dwTickCount + JL_CTHL_PARAM_FKJDSECONG_DEALY;
- JL_CTHL_LianLengthReal = dwXRealPos;
-
- JL_CTHL_XSavePosBuff = dwXRealPos;
- JL_CTHL_TD_MotorStep = 13;
- // user_datas[122] = JL_CTHL_PARAM_FKDW_Length - (dwXRealPos- JL_CTHL_CheckInX02PosBuff);
-
- if((dwXRealPos >= JL_CTHL_CheckInX02PosBuff) && JL_CTHL_CheckInX02PosBuff)
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_FKDW_Length - (dwXRealPos- JL_CTHL_CheckInX02PosBuff),
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,250,40);
- else
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_FKDW_Length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,250,40);
- //JL_CTHL_TD_MotorStep = 0;
- }
- else if(JL_CTHL_CXSC_Limit_IN_UP)
- {
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed * 2/3,JL_CTHL_PARAM_FKDW_Length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,250,50);
-
- }
- else if(JL_CTHL_CXSC_Limit_IN_DW)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_DK_ERROR_ALARM,bRunning);
- }
- break;
- case 12://检测到过链
-
- if(cZipCnt<2)
- {
- if(dwXRealPos >= JL_CTHL_PARAM_WLCDSHEZHI_LENTH)
- {
- if(bRunning)
- {
- cCHULIANBAOJIN=1;
- SetEn(X_AXIS, MOTOR_DISEN);
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0); //启动位置设为0点
- // dwXRealPos=0;
- }
- JL_CTHL_SetAlarmCode(JL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- }
- }
- else
- {
- if(dwXRealPos >= JL_CTHL_LianLengthAutoCheckERROR + JL_CTHL_PARAM_WUCD_LENTH)
- {
- if(bRunning)
- {
- cCHULIANBAOJIN=1;
- SetEn(X_AXIS, MOTOR_DISEN);
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0); //启动位置设为0点
- // dwXRealPos=0;
- }
- JL_CTHL_SetAlarmCode(JL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- }
-
- }
- if(JL_CTHL_FK_Check)
- {
-
- JL_CTHL_TD_MotorDelay= dwTickCount + JL_CTHL_PARAM_FKJDSECONG_DEALY;
- JL_CTHL_LianLengthReal = dwXRealPos;
- //if(cZipCnt == 1)
- // user_datas[122] = dwXRealPos;
- // user_datas[121] = dwXRealPos;
- if((cZipCnt == 1) || dwXRealPos < (JL_CTHL_LianLengthCheck*0.85) || dwXRealPos>(JL_CTHL_LianLengthCheck*1.3))
- JL_CTHL_LianLengthCheck = dwXRealPos;
-
- JL_CTHL_LianLengthCheckOLD=JL_CTHL_LianLengthNEWCheck;
- JL_CTHL_LianLengthNEWCheck = dwXRealPos;
- //break;
- JL_CTHL_XSavePosBuff = dwXRealPos;
- JL_CTHL_TD_MotorStep = 13;
- // user_datas[122] = JL_CTHL_PARAM_FKDW_Length - (dwXRealPos- JL_CTHL_CheckInX02PosBuff);
- if(cZipCnt > 1 )
- {
- if((dwXRealPos >= JL_CTHL_CheckInX02PosBuff) && JL_CTHL_CheckInX02PosBuff)
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_FKDW_Length - (dwXRealPos- JL_CTHL_CheckInX02PosBuff),
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,300,50);
- else
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_FKDW_Length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,300,50);
- }
- else
- {
-
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed*2/3,JL_CTHL_PARAM_first_length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,30,300,50);
- }
- //JL_CTHL_TD_MotorStep = 0;
- }
- else if(JL_CTHL_CXSC_Limit_IN_UP)
- {
- AxisMovePosAccDec(X_AXIS,JL_CTHL_PARAM_TD_RunSpeed * 2/3,JL_CTHL_PARAM_FKDW_Length,
- JL_CTHL_PARAM_FKDW_Speed,JL_CTHL_PARAM_FKDW_Speed,10,150,50);
-
- }
- else if(JL_CTHL_CXSC_Limit_IN_DW)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_DK_ERROR_ALARM,bRunning);
- }
-
- break;
- case 13:
-
- if(dwTickCount >= JL_CTHL_TD_MotorDelay)
- {
- JL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
- }
- if(JL_CTHL_CXSC_Limit_IN_DW)
- {
- JL_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
- if((!X_DRV ))// || (dwXRealPos >= (JL_CTHL_XSavePosBuff + JL_CTHL_PARAM_FKDW_Length)))
- {
- // user_datas[123] = dwXRealPos-JL_CTHL_CheckInX02PosBuff;
-
- AxisEgmStop(X_AXIS);
- JL_CTHL_TD_MotorStep = 14;
- /* if(cZipCnt>2)
- {
- if(((JL_CTHL_LianLengthNEWCheck+JL_CTHL_LianLengthCheckOLD)*0.5) < (JL_CTHL_LianLengthCheck*0.95))
- {
- cZipCnt=0;
- cHeLian=1;
- }
- }*/
- if(cZipCnt==1)
- JL_CTHL_LianLengthAutoCheckERROR = dwXRealPos;
-
- if(cZipCnt==1)
- JL_CTHL_LianLengSave=dwXRealPos;
-
- JL_CTHL_LianLengthAutoCheck = dwXRealPos;
- // user_datas[122] = dwXRealPos-JL_CTHL_X_CXPosBuff;
- }
- break;
- case 14:
-
- if(JL_CTHL_PARAM_XCX_LENTH) //0的话不判断位置
- {
-
- if ((dwXRealPos - JL_CTHL_X_CXPosBuff) > (JL_CTHL_PARAM_XCX_LENTH + JL_CTHL_PARAM_XCXWC_LENTH))
- {
- // user_datas[121] = 1;
- JL_CTHL_TD_MotorStep = 0;
- cXCXQXQD=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
- else if((dwXRealPos - JL_CTHL_X_CXPosBuff) < (JL_CTHL_PARAM_XCX_LENTH - JL_CTHL_PARAM_XCXWC_LENTH))
- {
- // user_datas[121] = 2;
- JL_CTHL_TD_MotorStep = 0;
- cXCXQXQD=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else if(JL_CTHL_X_CXPosBuff == 0)
- {
- // user_datas[121] = 3;
- JL_CTHL_TD_MotorStep = 0;
- cXCXQXQD=1;
- JL_CTHL_SetAlarmCode(JL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else
- {
-
- JL_CTHL_TD_MotorStep = 15;
- }
-
- }
- else
- {
-
- JL_CTHL_TD_MotorStep = 15;
- }
- break;
- case 15:
- // if(JL_CTHL_START_IN_UP)
- JL_CTHL_TD_MotorStep = 0;
-
- break;
- }
- #endif
- }
- //穿入电机动作,Y轴
- void JL_CTHL_CL_Motor(void) //
- {
- #if 0
- //1步开始, 穿链长度开始
- //20步开始 插销定位开始
- //40步,回原点为
- switch(JL_CTHL_CL_MotorStep)
- {
- //穿入长度位置
- case 1:
-
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- // SetDir(Y_AXIS, DIR_P);
- if(JL_CTHL_PARAM_CL_Length >= JL_CTHL_PARAM_CL_MAX_Length)
- JL_CTHL_PARAM_CL_Length = JL_CTHL_PARAM_CL_MAX_Length;
- //穿入长度要根据检测长度减动一次穿入的1CM,反转的2CM
- if((JL_CTHL_LianLengthAutoCheck < (JL_CTHL_PARAM_CL_Length + 500 )) && bRunning)
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_CL_Speed,(JL_CTHL_LianLengthAutoCheck-500),800,600,6,6,50);
- else
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_CL_Speed,(JL_CTHL_PARAM_CL_Length-100),800,600,6,6,50);
- JL_CTHL_CL_MotorStep = 2;
- }
- break;
- case 2:
- if((dwYRealPos + 120) > JL_CTHL_PARAM_CL_Length)
- JL_CTHL_HLJJ_VAVLE = 0;
- if(!Y_DRV || dwYRealPos >= JL_CTHL_PARAM_CL_Length)
- {
- JL_CTHL_HLJJ_VAVLE = 0;
- JL_CTHL_CL_MotorStep = 3;
- bCL_OK_FLG = 1;
- JL_CTHL_CL_MotorDelay = dwTickCount + 40; //延时数控回零点
- }
- break;
- case 3:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- JL_CTHL_CL_MotorStep = 50;
- }
- break;
- //夹带插销到穿入位置
- case 20: //此处最好算好定位长度相减
- if(cXcxcrCnt > 0)
- {
- JL_CTHL_LENTH = JL_CTHL_PARAM_CXDW_Length + 30;
- JL_CTHL_CL_MotorStep = 21;
- }
- else
- {
- JL_CTHL_LENTH = JL_CTHL_PARAM_CXDW_Length ;
- JL_CTHL_CL_MotorStep = 21;
- }
- break;
- case 21:
- SetDir(Y_AXIS, DIR_P);
- AxisMovePosAccDec(Y_AXIS,8000,JL_CTHL_LENTH,800,500,6,6,50);
- JL_CTHL_CL_MotorStep = 22;
- break;
- case 22:
- if(!Y_DRV || (dwYRealPos >= JL_CTHL_LENTH)) //插销定位已经结束
- {
- AxisEgmStop(Y_AXIS);
- JL_CTHL_YsaveCXDWPosBuff = 0;
- JL_CTHL_CL_MotorStep = 0;
- }
- break;
- //回原点开始
- case 40:
- //要先离开
- if(JL_CTHL_SF_Origin_IN && (GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- JL_CTHL_CL_MotorStep = 41;
- SetDir(Y_AXIS, DIR_P);
- }
- else
- {
- SetDir(Y_AXIS, DIR_N);
- JL_CTHL_CL_MotorStep = 46;
-
- }
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- JL_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- else //已经锁轴
- JL_CTHL_CL_MotorDelay = dwTickCount + 5;
- break;
- case 41:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- JL_CTHL_CL_MotorStep = 42;
- AxisContinueMoveAcc(Y_AXIS,5000,DIR_P,1000,800,15,15);
- }
- break;
- case 42:
- if(!JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep = 43;
- JL_CTHL_YSavePosBuff = dwYRealPos;
- }
- break;
- case 43:
- //离开原点5CM停止
- if((dwYRealPos - JL_CTHL_YSavePosBuff) >= 800)
- {
- AxisEgmStop(Y_AXIS);
- JL_CTHL_CL_MotorStep = 46; //留空几步备用
- JL_CTHL_CL_MotorDelay = dwTickCount + 50;
- }
- break;
- case 46:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- JL_CTHL_CL_MotorStep = 47; //检测回到原位
- if(!JL_CTHL_SF_Origin_IN)
- AxisContinueMoveAcc(Y_AXIS,1500,DIR_N,1000,800,15,10);
- }
- break;
- case 47:
- if(JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- break;
- //数控回原位 (条件为自动工作,SON一直没有松开)
- case 50:
- if(dwYRealPos > 150)
- { //回零速度
- SetDir(Y_AXIS, DIR_N);
- AxisMovePosAccDecNotStop(Y_AXIS,JL_CTHL_PARAM_CL_Back_O_Speed,-dwYRealPos + 150,5000,2000,10,50,50);
-
-
- }
- else
- AxisContinueMoveAcc(Y_AXIS,1000,DIR_N,1000,1000,15,15);
- JL_CTHL_CL_MotorStep = 51;
- break;
- case 51:
- if(JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- break;
-
- }
- #endif
-
- #if 1
- //1步开始, 穿链长度开始
- //20步开始 插销定位开始
- //40步,回原点为
- switch(JL_CTHL_CL_MotorStep)
- {
- //穿入长度位置
- case 1:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- { if(JL_CTHL_SF_Origin_IN)
- {
- if(!JL_CTHL_PARAM_AUTO_MODE)
- {
- //穿入长度要根据检测长度减动一次穿入的1CM,反转的2CM
- if(JL_CTHL_LianLengthAutoCheck <= 700)
- {
- JL_CTHL_Y_CL_Length=JL_CTHL_LianLengthAutoCheck-200;
- if(JL_CTHL_Y_CL_Length<10)
- JL_CTHL_Y_CL_Length=200;
- if(JL_CTHL_Y_CL_Length >= JL_CTHL_PARAM_CL_MAX_Length)
- JL_CTHL_Y_CL_Length = JL_CTHL_PARAM_CL_MAX_Length-40;
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_CL_Speed,JL_CTHL_Y_CL_Length,800,600,6,6,50);
- }
- else if(JL_CTHL_LianLengthAutoCheck>700)
- {
-
- user_datas[123] =JL_CTHL_LianLengthAutoCheck;
- if(cZipCnt>1)
- JL_CTHL_Y_CL_Length=JL_CTHL_LianLengSave-JL_CTHL_PARAM_HLTSY_LENTH-300;
- else
- {
- if(cZipCnt<1)
- JL_CTHL_Y_CL_Length=JL_CTHL_LianLengthAutoCheck-JL_CTHL_PARAM_HLTSY_LENTH-100;
- else
- JL_CTHL_Y_CL_Length=JL_CTHL_LianLengthAutoCheck-JL_CTHL_PARAM_HLTSY_LENTH-300;
- }
-
- if(JL_CTHL_Y_CL_Length<200)
- JL_CTHL_Y_CL_Length=200;
- if(JL_CTHL_Y_CL_Length >= JL_CTHL_PARAM_CL_MAX_Length)
- JL_CTHL_Y_CL_Length = JL_CTHL_PARAM_CL_MAX_Length-40;
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_CL_Speed,JL_CTHL_Y_CL_Length,800,600,6,6,50);
-
- }
-
- }
-
- else
- {
- if(JL_CTHL_PARAM_CL_Length >= JL_CTHL_PARAM_CL_MAX_Length)
- JL_CTHL_PARAM_CL_Length = JL_CTHL_PARAM_CL_MAX_Length;
- //穿入长度要根据检测长度减动一次穿入的1CM,反转的2CM
- if((JL_CTHL_LianLengthAutoCheck < (JL_CTHL_PARAM_CL_Length + 500 )) && bRunning)
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_CL_Speed,(JL_CTHL_LianLengthAutoCheck-500),800,600,6,6,50);
- else
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_CL_Speed,(JL_CTHL_PARAM_CL_Length-100),800,600,6,6,50);
-
- }
- JL_CTHL_CL_MotorStep = 2;
- }
- }
- break;
- case 2:
- if(JL_CTHL_PARAM_AUTO_MODE)
- {
- if((dwYRealPos + 120) > JL_CTHL_PARAM_CL_Length)
- JL_CTHL_HLJJ_VAVLE = 0;
- if(!Y_DRV || dwYRealPos >= JL_CTHL_PARAM_CL_Length)
- {
- JL_CTHL_HLJJ_VAVLE = 0;
- JL_CTHL_CL_MotorStep = 3;
- bCL_OK_FLG = 1;
- JL_CTHL_CL_MotorDelay = dwTickCount + 30; //延时数控回零点
- }
- }
- else
- {
- if((dwYRealPos + 120) > JL_CTHL_Y_CL_Length)
- JL_CTHL_HLJJ_VAVLE = 0;
- if(!Y_DRV || dwYRealPos >= JL_CTHL_Y_CL_Length)
- {
- JL_CTHL_HLJJ_VAVLE = 0;
- JL_CTHL_CL_MotorStep = 3;
- bCL_OK_FLG = 1;
- JL_CTHL_CL_MotorDelay = dwTickCount + 30; //延时数控回零点
- }
-
- }
- break;
- case 3:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- JL_CTHL_CL_MotorStep = 50;
- }
- break;
- //夹带插销到穿入位置
- case 20: //此处最好算好定位长度相减
- if(cXcxcrCnt > 0)
- {
- if(cXcxcrCnt==1)
- JL_CTHL_LENTH = JL_CTHL_PARAM_CXDW_Length+JL_CTHL_PARAM_TDFZ_LENTH + 50;
- if(cXcxcrCnt>1)
- JL_CTHL_LENTH = JL_CTHL_PARAM_CXDW_Length +JL_CTHL_PARAM_TDFZ_LENTH + 120;
- JL_CTHL_CL_MotorStep = 21;
- }
- else
- {
- JL_CTHL_LENTH = JL_CTHL_PARAM_CXDW_Length ;
- JL_CTHL_CL_MotorStep = 21;
- }
- break;
- case 21:
- if(JL_CTHL_SF_Origin_IN)
- {
- SetDir(Y_AXIS, DIR_P);
- JL_CTHL_Y_CL_PosBuff = dwYRealPos;
- AxisMovePosAccDec(Y_AXIS,JL_CTHL_PARAM_XCLC_SPEED,JL_CTHL_LENTH,800,500,6,6,50);
- JL_CTHL_CL_MotorStep = 22;
- }
- break;
- case 22:
- if(dwYRealPos >= JL_CTHL_Y_CL_PosBuff+JL_CTHL_LENTH-JL_CTHL_PARAM_CXDW_Length) //插销定位已经结束
- {
- JL_CTHL_CXSCDW_VAVLE = 1;
- }
-
- if(!Y_DRV || (dwYRealPos >= JL_CTHL_Y_CL_PosBuff+JL_CTHL_LENTH)) //插销定位已经结束
- {
- AxisEgmStop(Y_AXIS);
- JL_CTHL_YsaveCXDWPosBuff = 0;
- JL_CTHL_CL_MotorStep = 0;
- }
-
- break;
- case 30:
- JL_CTHL_YsaveCXDWPosBuff = 0;
- JL_CTHL_CL_MotorStep = 0;
- break;
- //回原点开始
- case 40:
- //要先离开
- if(JL_CTHL_SF_Origin_IN && (GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- JL_CTHL_CL_MotorStep = 41;
- SetDir(Y_AXIS, DIR_P);
- }
- else
- {
- SetDir(Y_AXIS, DIR_N);
- JL_CTHL_CL_MotorStep = 46;
-
- }
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- JL_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- else //已经锁轴
- JL_CTHL_CL_MotorDelay = dwTickCount + 5;
- break;
- case 41:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- JL_CTHL_CL_MotorStep = 42;
- AxisContinueMoveAcc(Y_AXIS,5000,DIR_P,1000,800,15,15);
- }
- break;
- case 42:
- if(!JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep = 43;
- JL_CTHL_YSavePosBuff = dwYRealPos;
- }
- break;
- case 43:
- //离开原点5CM停止
- if((dwYRealPos - JL_CTHL_YSavePosBuff) >= 800)
- {
- AxisEgmStop(Y_AXIS);
- JL_CTHL_CL_MotorStep = 46; //留空几步备用
- JL_CTHL_CL_MotorDelay = dwTickCount + 50;
- }
- break;
- case 46:
- if(dwTickCount >= JL_CTHL_CL_MotorDelay)
- {
- JL_CTHL_CL_MotorStep = 47; //检测回到原位
- if(!JL_CTHL_SF_Origin_IN)
- AxisContinueMoveAcc(Y_AXIS,1500,DIR_N,1000,800,15,10);
- }
- break;
- case 47:
- if(JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- break;
- //数控回原位 (条件为自动工作,SON一直没有松开)
- case 50:
- if(dwYRealPos > 151)
- { //回零速度
- SetDir(Y_AXIS, DIR_N);
- AxisMovePosAccDecNotStop(Y_AXIS,JL_CTHL_PARAM_CL_Back_O_Speed,-dwYRealPos + 150,5000,2500,30,200,00);
- }
- else
- AxisContinueMoveAcc(Y_AXIS,1000,DIR_N,1000,1000,15,15);
- JL_CTHL_CL_MotorStep = 51;
- break;
- case 51:
- if(JL_CTHL_SF_Origin_IN)
- {
- JL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- break;
-
- }
- #endif
- }
- //装拉头动作
- void JL_CTHL_ZLT_Step(void)
- {
-
- switch(JL_CTHL_ZhuangLiaoStep)
- {
- case 1:
-
- if(bZhuangLiaoOkFlg)
- {
- JL_CTHL_ZhuangLiaoStep = 0;
- }
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
-
- if(((JL_CTHL_MGuo_VAVLE && JL_CTHL_LTou_Check) || (!JL_CTHL_MGuo_VAVLE)) && !JL_CTHL_JLiao_Limit_IN )//说明没有拉头
- {
- //穿头模和一次穿入必须在原位,接料不能有输出
- if(JL_CTHL_CTM_Origin_IN && !JL_CTHL_CTXM_VAVLE)
- {
- JL_CTHL_First_CT_VAVLE = 0;
- JL_CTHL_JLTou_VAVLE = 0;
- JL_CTHL_MGuo_VAVLE = 0;
- if(JL_CTHL_TLiaoStep == 0)
- {
- JL_CTHL_TLiaoStep = 1;
- JL_CTHL_ZhuangLiaoStep = 2;
- }
- }
-
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay + 500) //警告横送拉必须保证穿头模和一次穿入在原位,接料不能有输出
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CTM_Origin_ALARM,bRunning);
-
- }
- }
- else //已经有拉头直接跳到结束
- {
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 40;
- JL_CTHL_ZhuangLiaoStep = 9;
- }
- }
- break;
- case 2:
- if(JL_CTHL_TLiaoStep == 0) //推料已经完成
- {
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- JL_CTHL_JLTou_VAVLE = 0;
- JL_CTHL_MGuo_VAVLE = 0;
- if(!JL_CTHL_JLiao_Limit_IN && JL_CTHL_First_CT_Origin_IN)
- {
- JL_CTHL_ZhuangLiaoStep = 3;
- JL_CTHL_HSLiao_VAVLE = 1;
- }
- }
- break;
- case 3:
- //横送到位
- if(JL_CTHL_HSLiao_Limit_IN && !JL_CTHL_HSLiao_Origin_IN)
- {
- JL_CTHL_ZhuangLiaoStep = 4;
- // JL_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 5;
- }
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_HSLiao_Limit_ALARM,bRunning);
- }
- break;
- case 4:
- if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
- JL_CTHL_ZhuangLiaoStep = 5;
- JL_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- }
- break;
- case 5:
- if(JL_CTHL_JLiao_Limit_IN)
- {
- JL_CTHL_ZhuangLiaoStep = 6;
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + JL_CTHL_PARAM_MaGou_DELAY;
- }
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay) //接拉头(接料)到们信号异常
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_JLiao_Limit_ALARM,bRunning);
- }
- break;
- case 6:
- if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay) //延时码勾
- {
- JL_CTHL_MGuo_VAVLE = 1; //码勾输出
- JL_CTHL_ZhuangLiaoStep = 7;
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + JL_CTHL_PARAM_HSLiaoOff_DELAY;
- bTuiLaTouOkFlg = 0; //认为拉头没法带出
- }
- break;
- case 7:
- if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
- JL_CTHL_HSLiao_VAVLE = 0;
- JL_CTHL_ZhuangLiaoStep = 8;
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- }
- break;
- case 8:
- if(!JL_CTHL_HSLiao_Limit_IN) //
- {
- JL_CTHL_ZhuangLiaoStep = 9;
- JL_CTHL_TLiaoStep = 1; //推拉头
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + JL_CTHL_PARAM_CheckLT_DELAY; //也是给下模能上升的时间
- }
- else if (JL_CTHL_LTou_Check) //时间内信号这说明没有拉头
- {
- //重送3次
- JL_CTHL_TryCnt++;
- JL_CTHL_JLTou_VAVLE = 0; //接拉头关
- JL_CTHL_MGuo_VAVLE = 0; //码勾打开
- if(JL_CTHL_TryCnt >= 3)
- {
- JL_CTHL_TryCnt = 0;
- bZhuangLiaoOkFlg = 0;
- JL_CTHL_ZhuangLiaoStep = 0;
- JL_CTHL_SetAlarmCode(JL_CTHL_ZLT_ALARM,bRunning);
- cWULATOUCnt=1;
- }
- else
- {
- JL_CTHL_ZhuangLiaoStep = 20; //重新送3次
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- }
- }
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_HSLiao_Limit_ALARM,bRunning);
- if(bRunning)
- {
- JL_CTHL_ZhuangLiaoStep = 0 ;
- }
- }
- break;
- case 9:
- if(JL_CTHL_LTou_Check) //时间内信号这说明没有拉头
- {
- JL_CTHL_TryCnt++;
- JL_CTHL_JLTou_VAVLE = 0; //接拉头关
- JL_CTHL_MGuo_VAVLE = 0; //码勾打开
- if(JL_CTHL_TryCnt >= 3)
- {
- JL_CTHL_TryCnt=0;
- bZhuangLiaoOkFlg = 0;
- JL_CTHL_ZhuangLiaoStep = 0;
- JL_CTHL_SetAlarmCode(JL_CTHL_ZLT_ALARM,bRunning);
- cWULATOUCnt=1;
- }
- else
- {
- JL_CTHL_ZhuangLiaoStep = 20; //重新送3次
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- }
- }
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
- bZhuangLiaoOkFlg = 1;
- JL_CTHL_ZhuangLiaoStep = 0;
- }
- break;
- //装拉头不成攻重新送拉头
- case 20:
- if(JL_CTHL_HSLiao_Origin_IN)
- {
- JL_CTHL_JLTou_VAVLE = 0; //接拉头关
- JL_CTHL_MGuo_VAVLE = 0; //码勾打开
- JL_CTHL_ZhuangLiaoStep = 1;
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 10;
- }
- else if(dwTickCount >= JL_CTHL_ZhuangLiaoDelay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_HSLiao_Origin_ALARM,bRunning);
- }
- break;
- }
- }
- void JL_CTHL_TLiao_Step(void)
- {
- switch(JL_CTHL_TLiaoStep)
- {
- case 1:
- if(bTuiLaTouOkFlg)
- {
- JL_CTHL_TLiaoStep = 0;
- }
- else
- {
- JL_CTHL_TLiao_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- JL_CTHL_TLiaoStep = 2;
- }
- break;
- case 2: //横送料在原位
- if(JL_CTHL_HSLiao_Origin_IN && !JL_CTHL_HSLiao_Limit_IN && !JL_CTHL_HSLiao_VAVLE)
- {
- JL_CTHL_TLiao_VAVLE = 1; //推料(推拉头)输出
- JL_CTHL_TLiao_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- JL_CTHL_TLiaoStep = 3;
- }
- else if(dwTickCount >= JL_CTHL_TLiao_Delay)
- JL_CTHL_SetAlarmCode(JL_CTHL_HSLiao_Origin_ALARM,1);
- break;
- case 3: //推拉头到位
- if(!JL_CTHL_TLiao_Limit_IN)
- {
- JL_CTHL_TLiao_Delay = dwTickCount + JL_CTHL_PARAM_TLiao_BACKDELAY;
- JL_CTHL_TLiaoStep = 4;
- }
- else if(dwTickCount >= JL_CTHL_TLiao_Delay)
- JL_CTHL_SetAlarmCode(JL_CTHL_TLiao_Limit_ALARM,1);
- break;
- case 4:
- if(dwTickCount >= JL_CTHL_TLiao_Delay)
- {
- JL_CTHL_TLiao_VAVLE = 0;
- JL_CTHL_TLiao_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- JL_CTHL_TLiaoStep = 5;
- }
- break;
- case 5:
- if(JL_CTHL_TLiao_Limit_IN)
- {
- JL_CTHL_TLiaoStep = 0;
- JL_CTHL_TLiao_Delay = dwTickCount;
- bTuiLaTouOkFlg = 1;
- }
- else if(dwTickCount >= JL_CTHL_TLiao_Delay)
- JL_CTHL_SetAlarmCode(JL_CTHL_TLiao_Limit_ALARM,0);
- break;
- }
-
- }
- //振动盘控制
- void JL_CTHL_ZhenDongAction(void)
- {
-
- #if 0
- if((JL_CTHL_bDLP || bRunning) && JL_CTHL_ZhenDongPian_OUT && JL_CTHL_PARAM_DALIAOPIAN)
- {
- if(CT_DLP_Time >= dwTickCount)
- {
- CT_ZDP_Delay = dwTickCount + CT_PARAM_DLP_TIME + 40;
- CT_DaLaPian_VAVLE = ~CT_DaLaPian_VAVLE;
- }
- }
- else
- CT_DaLaPian_VAVLE = 0;
- #endif
-
- #if 1
-
- // if(bRunning)
- // {
- switch(JL_CTHL_PARAM_ZDP_AUTO)
- {
- case 0:
- if(JL_CTHL_ZhenDongPian_OUT == 0)
- {
- if(!JL_CTHL_ZDP_IN)
- {
- if(dwTickCount >= JL_CTHL_ZDP_Delay)
- {
- JL_CTHL_ZhenDongPian_OUT = 1;
- JL_CTHL_ZDP_Delay = dwTickCount + JL_CTHL_PARAM_ZDP_Stop_TIME;//JL_CTHL_PARAM_ZDP_Stop_TIME + 50;
- }
- }
- else
- {
- JL_CTHL_ZDP_Delay = dwTickCount + JL_CTHL_PARAM_ZDP_Start_TIME;//JL_CTHL_PARAM_ZDP_Start_TIME;
- }
- }
- else
- {
- if(JL_CTHL_ZDP_IN)
- {
- if(dwTickCount >= JL_CTHL_ZDP_Delay)
- {
- JL_CTHL_ZhenDongPian_OUT = 0;
- JL_CTHL_ZDP_Delay = dwTickCount + JL_CTHL_PARAM_ZDP_Start_TIME;//JL_CTHL_PARAM_ZDP_Start_TIME
- }
- }
- else
- JL_CTHL_ZDP_Delay = dwTickCount + JL_CTHL_PARAM_ZDP_Stop_TIME;//JL_CTHL_PARAM_ZDP_Stop_TIME+ 50;
- }
- break;
- case 1:
- JL_CTHL_ZhenDongPian_OUT=0;
- JL_CTHL_ZDP_Delay = dwTickCount;
- break;
- case 2:
- JL_CTHL_ZhenDongPian_OUT=1;
- JL_CTHL_ZDP_Delay = dwTickCount;
- break;
- }
- if(JL_CTHL_ZhenDongPian_OUT)
- {
- if(JL_CTHL_PARAM_LaPian_EN)
- {
- if(dwTickCount >= JL_CTHL_DLP_Delay)
- {
-
- JL_CTHL_DaLaPian_OUT = !JL_CTHL_DaLaPian_OUT;
-
- if(JL_CTHL_DaLaPian_OUT)
- JL_CTHL_DLP_Delay = dwTickCount + JL_CTHL_PARAM_DaLaPian;
- else
- JL_CTHL_DLP_Delay = dwTickCount + JL_CTHL_PARAM_DaLaPian+50;
- }
- }
- else
- JL_CTHL_DaLaPian_OUT = 0;
- }
- else
- JL_CTHL_DaLaPian_OUT = 0;
- #endif
- }
- void JL_CTHL_bFKCXTDDWStep(void)
- {
- switch(JL_CTHL_bFKCXTDDW_Step)
- {
- case 1:
- JL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
- JL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- JL_CTHL_FKGD_VAVLE = 0; //方块固定关
- JL_CTHL_bFKCXTDDW_Step = 2;
-
- break;
- case 2:
- if(!JL_CTHL_XKTD_Origin_IN) //斜口推带原位离开
- {
- JL_CTHL_bFKCXTDDW_Step = 3;
- JL_CTHL_bFKCXTDDW_Delay = dwTickCount + 20;
- }
- break;
- case 3://斜口定位
- if(dwTickCount >= JL_CTHL_bFKCXTDDW_Delay)
- {
- JL_CTHL_XKDW_VAVLE = 1;
- JL_CTHL_bFKCXTDDW_Step = 4;
- // JL_CTHL_bFKCXTDDW_Delay = dwTickCount + JL_CTHL_PARAM_XKDW_TD_DELAY;
- }
- break;
- case 4:
- if(dwTickCount >= JL_CTHL_bFKCXTDDW_Delay)
- {
- AxisContinueMoveAcc(X_AXIS,1200,DIR_P,800,600,10,10);//拖带电机
- JL_CTHL_bFKCXTDDW_Step = 5;
- JL_CTHL_XSavePosBuff = dwXRealPos;
- SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
- }
- break;
- case 5:
- if(JL_CTHL_XKSC_Limit_IN) //方块到位
- {
- AxisEgmStop(X_AXIS);
- JL_CTHL_QDXK_VAVLE=1;
- JL_CTHL_bFKCXTDDW_Step = 6;
- JL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- JL_CTHL_bFKCXTDDW_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
-
- }
- else if(dwXRealPos >= (JL_CTHL_XSavePosBuff + 800))
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_FKCXDW_ALARM,bRunning);//方块插销定位异常警告
-
- }
- break;
- case 6:
- if(JL_CTHL_PARAM_TDFZ_LENTH && !X_DRV) //拖带电机反转
- AxisMovePosAccDec(X_AXIS,8000,-JL_CTHL_PARAM_DXKFZ_LENTH,800,600,6,6,0);
- if(JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 1;
- JL_CTHL_bFKCXTDDW_Step = 0;
- break;
-
- }
- }
- //插销穿入动作
- void JL_CTHL_bCXCRStep(void)
- {
- switch(JL_CTHL_bCXCR_Step)
- {
- case 11:
- JL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- JL_CTHL_FKGD_VAVLE = 0; //方块固定关
- JL_CTHL_CXSCDW_VAVLE=1;
- JL_CTHL_bCXCR_Step = 12;
-
- break;
- case 12:
- if(!JL_CTHL_XKTD_Origin_IN) //斜口推带原位离开
- {
- JL_CTHL_bCXCR_Step = 13;
- // JL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- JL_CTHL_bCXCR_Delay = dwTickCount + 20;
- }
- break;
- case 13:
- if((JL_CTHL_CL_MotorStep == 0) && (JL_CTHL_SF_Origin_IN) && (dwTickCount >= JL_CTHL_bCXCR_Delay)) //插销前夹带回到原位
- {
- JL_CTHL_bCXCR_Step = 14;
- // JL_CTHL_FKGD_VAVLE = 1; //方块固定开
- JL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- JL_CTHL_bCXCR_Delay = dwTickCount + JL_CTHL_PARAM_XCQJD_XCDW_DELAY+100;
- }
- break;
- case 14:
- if(dwTickCount >= JL_CTHL_bCXCR_Delay)
- {
- JL_CTHL_bCXCR_Step = 15;
- JL_CTHL_FKGD_VAVLE = 1; //方块固定
- //Y轴启动插销
- JL_CTHL_CL_MotorStep = 20; //插销定位
- }
- break;
- case 15:
- if(JL_CTHL_CL_MotorStep == 0) //插销定位完成
- {
- JL_CTHL_bCXCR_Step = 16;
- JL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- JL_CTHL_bCXCR_Delay = dwTickCount + 10; //延时插销下移
- }
- break;
- case 16:
- if(dwTickCount >= JL_CTHL_bCXCR_Delay)
- {
- JL_CTHL_bCXCR_Step = 17;
- if(JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 0;
- else
- JL_CTHL_CXJL_VAVLE = 1; //Y06 插销下移电磁阀
- if(JL_CTHL_PARAM_NLSL_MODE == 0)
- JL_CTHL_bCXCR_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
- else
- JL_CTHL_bCXCR_Delay = dwTickCount + 80; //插销下移异常时间
- }
- break;
- case 17:
- if((JL_CTHL_CXJL_Limit_IN) || JL_CTHL_PARAM_NLSL_MODE)
- {
-
- if(JL_CTHL_CXJL_Limit_IN || (dwTickCount >= JL_CTHL_bCXCR_Delay))
- {
- JL_CTHL_bCXCR_Step = 18;
- if( cXcxcrCnt==0 && !X_DRV) //拖带电机反转
- {
- AxisMovePosAccDec(X_AXIS,10000,-JL_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- JL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- JL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- JL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- JL_CTHL_bCXCR_Delay = dwTickCount + JL_CTHL_PARAM_SCDWOff_CXDW_DELAY;
-
- }
- }
- else if(dwTickCount >= JL_CTHL_bCXCR_Delay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CXJL_Limit_ALARM,bRunning);//插销下移异常
-
- }
- break;
- case 18:
- // if(START_IN_UP)
- {
- if(dwTickCount >= JL_CTHL_bCXCR_Delay)
- {
- JL_CTHL_bCXCR_Step = 19;
-
- JL_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
- JL_CTHL_bCXCR_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME +1000; //插销穿入到位异常时间
- JL_CTHL_CL_MotorStep = 50; //合链电机回原点
- }
- }
- break;
- case 19:
- if( cXcxcrCnt > 1)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CX_Limit_ALARM,bRunning); //插销穿入到位异常
- }
-
- if( JL_CTHL_CX_Limit_IN && cXcxcrCnt<2 )
- {
- cXcxcrCnt=0;
- bZhuangLiaoOkFlg = 0;
- JL_CTHL_bCXCR_Step = 0;
- JL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
-
- }
- else if (dwTickCount >= JL_CTHL_bCXCR_Delay)
- {
- cXcxcrCnt++;
-
- JL_CTHL_CXHJD_VAVLE=0;
- JL_CTHL_CXHDW_VAVLE=0;
- JL_CTHL_CXDWZ_VAVLE = 0;
- if(JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 0;
- else
- JL_CTHL_CXJL_VAVLE = 1; //Y06 插销下移电磁阀
- JL_CTHL_bCXCR_Step = 11;
- }
-
- break;
- }
- }
- void JL_CTHL_bCLFirstStep(void)
- {
- switch(JL_CTHL_bCLFirst_Step)
- {
- case 19:
- JL_CTHL_JLTou_VAVLE = 0; //接拉头
- bZhuangLiaoOkFlg = 0;
- JL_CTHL_bCLFirst_Step = 20;
- JL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- JL_CTHL_CXJL_VAVLE = 0; //Y06 插销下移电磁阀关
- JL_CTHL_bCLFirst_Delay = dwTickCount + JL_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
- break;
- case 20:
- if(dwTickCount >= JL_CTHL_bCLFirst_Delay)
- {
- JL_CTHL_bCLFirst_Step = 21;
- JL_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
- JL_CTHL_bCLFirst_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 21:
- if(!JL_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
- {
- JL_CTHL_bCLFirst_Step = 22;
- JL_CTHL_bCLFirst_Delay = dwTickCount + JL_CTHL_PARAM_First_CL_Timer; //一次穿入时间
- }
- else if(dwTickCount >= JL_CTHL_bCLFirst_Delay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
- }
- break;
- case 22:
- if(dwTickCount >= JL_CTHL_bCLFirst_Delay)
- {
- JL_CTHL_bCLFirst_Step = 23;
- JL_CTHL_MGuo_VAVLE = 0; //码勾退
- JL_CTHL_bCLFirst_Delay = dwTickCount + JL_CTHL_PARAM_MGOff_XiaMo_DELAY;
- JL_CTHL_FKGD_VAVLE = 0; //方块固定退
- JL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- JL_CTHL_CXJL_VAVLE = 0; //Y06 插销下移电磁阀关
- }
- break;
- case 23:
- if(dwTickCount >= JL_CTHL_bCLFirst_Delay)
- {
- JL_CTHL_bCLFirst_Step = 24;
- JL_CTHL_CTXM_VAVLE = 0; //穿头下模下降
- JL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- JL_CTHL_bCLFirst_Delay = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 24:
- if(!JL_CTHL_CTM_Limit_IN)
- {
- JL_CTHL_bCLFirst_Step= 25;
- JL_CTHL_bCLFirst_Delay = dwTickCount + 25; //一次穿入延时返回
- }
- else if(dwTickCount >= JL_CTHL_bCLFirst_Delay)
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CTM_Origin_ALARM,bRunning); //穿头下模下降异常
- }
- break;
- case 25:
- if(dwTickCount >= JL_CTHL_bCLFirst_Delay)
- {
-
- JL_CTHL_bCLFirst_Step= 0;
- JL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- JL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
-
-
- //退下出错警告
- JL_CTHL_AutoDelay1 = dwTickCount + JL_CTHL_VAVLE_ERROR_TIME;
- JL_CTHL_AutoStep1 = 1;
- bTuiLaTouOkFlg = 1;
- }
- break;
- }
- }
- //手动动作
- void JL_CTHL_ManualAction(void)
- {
- if(bRunning) // 运行灯输出
- {
- JL_CTHL_Run_State=1;
- JL_CTHL_Stop_State=0;
- }
- else
- {
- JL_CTHL_Stop_State=1;
- JL_CTHL_Run_State=0;
- }
-
-
- if(dwTickCount >= JL_CTHL_bSFBBAOJIN_Delay)
- {
- JL_CTHL_SF_ALR_CLR=0;
- SetClr(Y_AXIS,MOTOR_ALARM);
- SetClr(X_AXIS,MOTOR_ALARM);
- }
-
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(QDCT_TOTAL_ADDR);
- }
- if(JL_CTHL_bTLiao ) //手动推料(推拉头)
- {
- JL_CTHL_bTLiao = 0;
- if(JL_CTHL_TLiao_VAVLE)
- JL_CTHL_TLiao_VAVLE = 0;//JL_CTHL_TLiao_VAVLE;
- else if(!JL_CTHL_HSLiao_VAVLE && JL_CTHL_HSLiao_Origin_IN)
- {
- JL_CTHL_TLiao_VAVLE = 1;
- }
- else//条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_HENSONGLIAO_ALARM,0); // 横送料不能输出
- }
-
- }
-
- if(JL_CTHL_bHSL) //手动横送料
- {
- JL_CTHL_bHSL= 0;
- if(!JL_CTHL_First_CT_VAVLE)
- {
- if(JL_CTHL_HSLiao_VAVLE)
- {
- JL_CTHL_HSLiao_VAVLE = 0;//~JL_CTHL_HSLiao_VAVLE;
- }
- else if(!JL_CTHL_TLiao_VAVLE && JL_CTHL_TLiao_Limit_IN && JL_CTHL_CTM_Origin_IN && !JL_CTHL_JLiao_Limit_IN &&
- !JL_CTHL_JLTou_VAVLE && !JL_CTHL_CTXM_VAVLE && !JL_CTHL_CXDWZ_VAVLE && (!JL_CTHL_bMG || (JL_CTHL_bMG && JL_CTHL_LTou_Check)))
- {
- JL_CTHL_HSLiao_VAVLE = 1;
- }
- else //条件警告 最后一个括号条件为已经有拉头
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_YCCT_ALARM,0);
- }
- }
- }
- if(JL_CTHL_bJLT) //接拉头
- {
- JL_CTHL_bJLT = 0;
- if(JL_CTHL_JLTou_VAVLE)
- JL_CTHL_JLTou_VAVLE = 0;
- else if(!JL_CTHL_First_CT_VAVLE && !JL_CTHL_CTXM_VAVLE && JL_CTHL_CTM_Origin_IN && JL_CTHL_First_CT_Origin_IN)
- {
- JL_CTHL_MGuo_VAVLE = 0;
- JL_CTHL_JLTou_VAVLE = 1;
- }
- else//条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_YCXM_Origin_ALARM,0);
- }
- }
- if(JL_CTHL_bMG) //码勾
- {
- JL_CTHL_bMG = 0;
- JL_CTHL_MGuo_VAVLE = !JL_CTHL_MGuo_VAVLE;
- }
- if(JL_CTHL_bFKJD) //方块夹带
- {
- JL_CTHL_bFKJD = 0;
- JL_CTHL_FKJD_VAVLE = !JL_CTHL_FKJD_VAVLE;
- }
- if(JL_CTHL_bXKTD) //斜口推带
- {
- JL_CTHL_bXKTD = 0;
- if(JL_CTHL_XKTD_VAVLE)
- JL_CTHL_XKTD_VAVLE = 0;
- else if(!JL_CTHL_DXK_VAVLE && (!JL_CTHL_XKSC_Limit_IN || !JL_CTHL_CTXM_VAVLE|| JL_CTHL_PARAM_NLSL_MODE))
- JL_CTHL_XKTD_VAVLE = 1;
- else//条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_DXKCTXM_Origin_ALARM,0);
- }
- }
- if(JL_CTHL_bXKDW) //斜口定位
- {
- JL_CTHL_bXKDW = 0;
- JL_CTHL_XKDW_VAVLE = ~JL_CTHL_XKDW_VAVLE;
- }
- if(JL_CTHL_bCTXM) //穿头下模
- {
- JL_CTHL_bCTXM = 0;
- if(JL_CTHL_CTXM_VAVLE )
- {
- if(!JL_CTHL_CXJL_VAVLE)
- {
- JL_CTHL_CTXM_VAVLE = 0;
- JL_CTHL_JLTou_VAVLE = 0;
- }
- else
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_TXC_Limit_ALARM,0);
- }
- }
- else if(!JL_CTHL_HSLiao_VAVLE && JL_CTHL_HSLiao_Origin_IN && (!JL_CTHL_XKSC_Limit_IN || !JL_CTHL_XKTD_VAVLE))
- {
- if(JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 1;
- JL_CTHL_MGuo_VAVLE = 1;
- JL_CTHL_CTXM_VAVLE = 1;
- }
- }
- if(JL_CTHL_bQianDXK) //前顶斜口
- {
- JL_CTHL_bQianDXK = 0;
- if(JL_CTHL_QDXK_VAVLE)
- JL_CTHL_QDXK_VAVLE = 0;
- else if(!JL_CTHL_XKTD_VAVLE)
- JL_CTHL_QDXK_VAVLE = 1;
- else //条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_XKTD_ALARM,0);
- }
- }
-
- if(JL_CTHL_bDXK) //顶斜口
- {
- JL_CTHL_bDXK = 0;
- if(!JL_CTHL_PARAM_NLSL_MODE)
- {
- if(JL_CTHL_DXK_VAVLE)
- JL_CTHL_DXK_VAVLE = 0;
- else if(!JL_CTHL_XKTD_VAVLE)
- {
- if(!JL_CTHL_PARAM_NLSL_MODE)
- JL_CTHL_DXK_VAVLE = 1;
- }
- else //条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_XKTD_ALARM,0);
- }
- }
- else
- {
- if(JL_CTHL_XKTD_VAVLE)
- JL_CTHL_XKTD_VAVLE = 0;
- else if(!JL_CTHL_DXK_VAVLE )
- {
- if(!JL_CTHL_XKSC_Limit_IN || !JL_CTHL_CTXM_VAVLE || JL_CTHL_PARAM_NLSL_MODE)
- JL_CTHL_XKTD_VAVLE = 1;
- else
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_YCXM_Origin_ALARM,0);
- }
- }
- else//条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_DXKCTXM_Origin_ALARM,0);
- }
-
- }
- }
-
- if(JL_CTHL_bQianDXK_DXK)
- {
- JL_CTHL_bQianDXK_DXK = 0;
- if(!JL_CTHL_XKTD_VAVLE && JL_CTHL_AutoStep==0)
- {
- cQDXK_DXK=1;
- JL_CTHL_AutoStep = 8;
- SetEn(X_AXIS, MOTOR_EN);
- JL_CTHL_AutoDelay = dwTickCount + 50;
- bRunning=1;
- }
-
- }
- //斜码插入
- if(JL_CTHL_bBanZiDong)
- {
- JL_CTHL_bBanZiDong=0;
- cBanAuTo=1;
- // JL_CTHL_PARAM_BanAuto_MODE=1;
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- JL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- JL_CTHL_ZhuangLiaoStep = 1;
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg= 0;
- bCL_EN_FLG=0;
- JL_CTHL_AutoStep = 1;
- bRunning=1;
- }
- //小插插入
- if(JL_CTHL_CXC)//穿小插
- {
- JL_CTHL_CXC=0;
- cCXCONE=1;
- cBanAuTo=0;
- // JL_CTHL_PARAM_BanAuto_MODE=0;
- JL_CTHL_AutoStep = 11;
- bRunning=1;
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- JL_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- }
-
- if(JL_CTHL_bFKGD) //方块固定
- {
- JL_CTHL_bFKGD = 0;
- JL_CTHL_FKGD_VAVLE = ~JL_CTHL_FKGD_VAVLE;
- }
- if(JL_CTHL_bCXQJD) //插销前夹带
- {
- JL_CTHL_bCXQJD = 0;
- JL_CTHL_CXQJD_VAVLE = ~JL_CTHL_CXQJD_VAVLE;
- }
- if(JL_CTHL_bCXSY) //插销下移电磁阀
- {
- JL_CTHL_bCXSY = 0;
- JL_CTHL_CXJL_VAVLE = !JL_CTHL_CXJL_VAVLE;
- }
- if(JL_CTHL_bCXDWZ) //Y14 插销定位针电磁阀
- {
- JL_CTHL_bCXDWZ = 0;
- if(JL_CTHL_CXDWZ_VAVLE)
- JL_CTHL_CXDWZ_VAVLE = 0;
- else if(JL_CTHL_HSLiao_Origin_IN)
- {
- JL_CTHL_CXDWZ_VAVLE = 1;
- }
- else //条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_HENSONGLIAO_ALARM,0);
- }
-
- }
- if(JL_CTHL_bCXHJD) //Y15 插销后夹带电磁阀
- {
- JL_CTHL_bCXHJD = 0;
- JL_CTHL_CXHJD_VAVLE =~JL_CTHL_CXHJD_VAVLE;
- }
- if(JL_CTHL_bCXHDW) //Y16 插销后定位电磁阀
- {
- JL_CTHL_bCXHDW = 0;
- if(JL_CTHL_CXHDW_VAVLE)
- JL_CTHL_CXHDW_VAVLE = 0;
- else if(!JL_CTHL_CXQJD_VAVLE)
- JL_CTHL_CXHDW_VAVLE = 1;
- else//条件警告
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_CXQJD_ALARM,0);
- }
- }
- if(JL_CTHL_bFirst_CT) //Y20 一次穿头电磁阀
- {
- JL_CTHL_bFirst_CT = 0;
- if( !JL_CTHL_First_CT_VAVLE )
- {
- if(!JL_CTHL_CXJL_VAVLE)
- JL_CTHL_First_CT_VAVLE=1;
- else
- JL_CTHL_SetAlarmCode(JL_CTHL_TXC_Limit_ALARM,0);
-
- }
- else if(JL_CTHL_First_CT_VAVLE)
- {
- JL_CTHL_First_CT_VAVLE=0;
- }
-
-
- }
- if(JL_CTHL_bHLJJ) //Y21 合链夹具电磁阀
- {
- JL_CTHL_bHLJJ = 0;
- JL_CTHL_HLJJ_VAVLE = ~JL_CTHL_HLJJ_VAVLE;
- }
- if(JL_CTHL_bCXSCDW) //Y23 插销上止定位电磁阀
- {
- JL_CTHL_bCXSCDW = 0;
- JL_CTHL_CXSCDW_VAVLE = ~JL_CTHL_CXSCDW_VAVLE;
- }
- //自动装料
- if(JL_CTHL_bAutoZhuangLiao)
- {
- JL_CTHL_bAutoZhuangLiao = 0;
- if(JL_CTHL_ZhuangLiaoStep == 0)
- {
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg = 0;
- JL_CTHL_ZhuangLiaoStep = 1;
- JL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- JL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- }
- }
- //测试电机
- if(JL_CTHL_bCLMotor_N)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!JL_CTHL_SF_Origin_IN)
- {
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,1000,15,15);
- }
- else
- {
- JL_CTHL_bCLMotor_N = 0;
- }
-
- }
-
- if(JL_CTHL_bCLMotor_P) //后退限位已经取消
- {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_P,1000,1000,15,15);
- }
-
- if(!JL_CTHL_bCLMotor_P && !JL_CTHL_bCLMotor_N && (JL_CTHL_CL_MotorStep == 0))
- {
- AxisEgmStop(Y_AXIS);//AxisDecStop(Y_AXIS);
- }
-
-
- if(JL_CTHL_bTDMotor_P) //后退限位已经取消
- {
- SetEn(X_AXIS, MOTOR_EN);
- if(!X_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,2000,DIR_N,1000,1000,15,15);
- }
- if(JL_CTHL_bTDMotor_N) //后退限位已经取消
- {
- SetEn(X_AXIS, MOTOR_EN);
- if(!X_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,2000,DIR_P,1000,1000,15,15);
- }
-
-
- if(!JL_CTHL_bTDMotor_P && !JL_CTHL_bTDMotor_N && (JL_CTHL_TD_MotorStep == 0))
- {
- AxisEgmStop(X_AXIS);//AxisDecStop(Y_AXIS);
- }
- //合链电机返回原点
- if(JL_CTHL_bCLMotor_O)
- {
- JL_CTHL_bCLMotor_O = 0;
- if(JL_CTHL_CL_MotorStep == 0)
- JL_CTHL_CL_MotorStep = 40;
- }
- //拖带方块定位 ,因这步为前拖带定位, 很多电磁阀要关掉
- if(JL_CTHL_bFKTDDW)
- {
- JL_CTHL_bFKTDDW = 0;
- if(JL_CTHL_TD_MotorStep == 0)
- {
- JL_CTHL_XKDW_VAVLE = 0; //斜口定位
- JL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- if(!JL_CTHL_PARAM_CXJL_MODE)
- JL_CTHL_CXJL_VAVLE = 0; //插销下移
-
- JL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- JL_CTHL_CXHDW_VAVLE = 0; //插销后定位
- JL_CTHL_CXDWZ_VAVLE = 0; //插销定位针
- JL_CTHL_bHLJJ = 0; //合链夹具
- JL_CTHL_FKJD_VAVLE = 0; //方块夹带
- if((GetEn(X_AXIS) == MOTOR_DISEN))
- {
- SetEn(X_AXIS, MOTOR_EN);
- JL_CTHL_TD_MotorDelay = dwTickCount + 200;
- }
- else
- JL_CTHL_TD_MotorDelay = dwTickCount + 50;
- JL_CTHL_TD_MotorStep = 1;
- }
- }
- //拖带方块插销定位(斜口推带,斜口定位,顶斜口)
- if(JL_CTHL_bFKCXTDDW)
- {
- JL_CTHL_bFKCXTDDW = 0;
- if((JL_CTHL_bFKCXTDDW_Step == 0) && (JL_CTHL_CL_MotorStep == 0) &&
- !JL_CTHL_CTXM_VAVLE)
- {
- JL_CTHL_bFKCXTDDW_Step = 1;
- SetEn(X_AXIS, MOTOR_EN);
- JL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- JL_CTHL_CXJL_VAVLE = 0; //插销下移
- JL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- JL_CTHL_CXHDW_VAVLE = 0; //插销后定位
- JL_CTHL_CXDWZ_VAVLE = 0; //插销定位针
- JL_CTHL_HLJJ_VAVLE = 0; //合链夹具
- }
- }
- //插销穿入(包含电机前定位,插销下移,后夹,后定位)
- if(JL_CTHL_bCXCR)
- {
- JL_CTHL_bCXCR = 0;
- //拉头模在上面到们并且码勾输出,判断有拉头
- if(JL_CTHL_CTXM_VAVLE && JL_CTHL_MGuo_VAVLE && !JL_CTHL_CXQJD_VAVLE &&
- JL_CTHL_CTM_Limit_IN && !JL_CTHL_LTou_Check)
- {
- if(JL_CTHL_CL_MotorStep == 0)
- {
- JL_CTHL_bCXCR_Step = 11;
- SetEn(Y_AXIS, MOTOR_EN);
- if(!JL_CTHL_SF_Origin_IN)
- JL_CTHL_CL_MotorStep = 40;
- }
- }
- else //警告不能自动穿插销
- {
- JL_CTHL_SetAlarmCode(JL_CTHL_WFZIDONGCX_ALARM,0);
- }
- }
- //电机合链动作
- if(JL_CTHL_bMotorHL)
- {
- JL_CTHL_bMotorHL = 0;
- if(JL_CTHL_SF_Origin_IN)
- {
- if((JL_CTHL_CL_MotorStep == 0) && !JL_CTHL_CTXM_VAVLE && (!JL_CTHL_CTM_Limit_IN))
- {
- bCL_OK_FLG = 0;
- JL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- JL_CTHL_CL_MotorStep = 1;
- JL_CTHL_CL_MotorDelay = dwTickCount + JL_CTHL_PARAM_HLJJ_CL_DELAY + 130;
- if((GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- SetEn(Y_AXIS, MOTOR_EN);
- JL_CTHL_CL_MotorDelay = dwTickCount + 250;
- }
- }
- }
- else
- {
- JL_CTHL_bCLMotor_O =1;
-
- }
- }
- //一次穿链动作
- if(JL_CTHL_bCL_First)
- {
- JL_CTHL_bCL_First = 0;
- //拉头模在上面到们并且码勾输出,判断有拉头
- if(JL_CTHL_CTXM_VAVLE && JL_CTHL_MGuo_VAVLE && !JL_CTHL_CXQJD_VAVLE &&
- JL_CTHL_CTM_Limit_IN && !JL_CTHL_LTou_Check && (JL_CTHL_CL_MotorStep == 0))
- {
- JL_CTHL_bCLFirst_Step = 19;
- JL_CTHL_CXHJD_VAVLE = 1; //插销后夹带
- JL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- JL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- }
- }
- }
- }
- #endif
|