1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914 |
- #include "global.h"
- #if XI_DONG_MACHINE == 1
- void GL_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag);
- void GL_CTHL_ManualAction(void);
- void GL_CTHL_AutoStepAction(void);
- void GL_CTHL_TableAction(void);
- void GL_CTHL_TD_Motor(void);
- void GL_CTHL_CL_Motor(void);
- void GL_CTHL_CheckStart(void);
- void GL_CTHL_TLiao_Step(void); //推料(推拉头)
- void GL_CTHL_AlarmProtect(void);
- void GL_CTHL_ZLT_Step(void);
- void GL_CTHL_ZhenDongAction(void);
- void GL_CTHL_bFKCXTDDWStep(void);
- void GL_CTHL_bCXCRStep(void);
- void GL_CTHL_bCLFirstStep(void);
- void GL_CTHL_HeMo(void);
- void ExtiAcitionX02_CTHL(void)
- {
- if(bCheckEN_FLG)
- {
- bCheckEN_FLG = 0;
- GL_CTHL_CheckInX02PosBuff = GetPos(X_AXIS);
- }
- }
- //故障报警
- void GL_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag)
- {
- SetAlarmCode(GL_CTHL_ALARM_ADDR,alarm_code);
- // bAlarmStop = 0;
- // if(cStopFlag)
- if(!cWULATOUCnt)
- {
- bAlarmStop = 1;
- }
- else
- {
- cWULATOUCnt=0;
- }
- }
- //初始化动作
- void GL_CTHL_InitAction(void)
- {
- float buff_pulse,buff_dist;
-
- buff_pulse = GL_CTHL_PARAM_CYCLE_PULSE;
- buff_dist = GL_CTHL_PARAM_CYCLE_LENGTH;
-
- XGearRatio = buff_pulse/buff_dist;
-
- buff_pulse = GL_CTHL_PARAM_YCYCLE_PULSE;
- buff_dist = GL_CTHL_PARAM_YCYCLE_LENGTH;
- YGearRatio = buff_pulse/buff_dist;
-
- GL_CTHL_bZDP= 1;
-
- bYFirstDingWeiFlg = 1;
- user_datas[121] = 0;
- user_datas[122] = 0;
- user_datas[123] = 0;
-
- SetEnReverse(X_AXIS, 0);
-
- if(GL_CTHL_PARAM_Y_ENSelect == 1)
- SetEnReverse(Y_AXIS, 0);
- else
- SetEnReverse(Y_AXIS, 1);
-
- SetEnReverse(Z_AXIS, 0);
-
- 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(GL_CTHL_ALARM_ADDR,0); //警告要清除
- GL_CTHL_bSFBBAOJIN_Delay = dwTickCount + 2000;
-
- GL_CTHL_X_EN_FLG=0;
- GL_CTHL_Y_EN_FLG=0;
- }
- void GL_CTHL_Action(void)
- {
- // user_datas[121] = GL_CTHL_ZhuangLiaoStep;
- // user_datas[122] =GL_CTHL_bXCBackOK;
- // user_datas[123] = GL_CTHL_X_CXPosBuff;
- dwXRealPos = GetPos(X_AXIS);
- dwYRealPos = GetPos(Y_AXIS);
- dwZRealPos = GetPos(Z_AXIS);
- user_datas[124] = dwXRealPos;
- user_datas[125] = GL_CTHL_RunStepSave;//dwYRealPos;
-
- user_datas[126] = dwYRealPos;//GL_CTHL_CL_MotorStep;
- user_datas[127] = GetEn(X_AXIS);//GL_CTHL_TD_MotorStep;
- user_datas[128] = GL_CTHL_TD_MotorStep;//GL_CTHL_AutoStep;
-
- GL_CTHL_ZhenDongAction();
- GL_CTHL_AlarmProtect();
- GL_CTHL_CheckStart();
- GL_CTHL_ZLT_Step();
- GL_CTHL_TLiao_Step();
- GL_CTHL_TD_Motor();
- GL_CTHL_CL_Motor();
- GL_CTHL_bFKCXTDDWStep();
- GL_CTHL_bCXCRStep();
- GL_CTHL_bCLFirstStep();
- GL_CTHL_HeMo();
- GL_CTHL_ManualAction();
- GL_CTHL_AutoStepAction();
-
-
- }
- void GL_CTHL_AlarmProtect(void)
- {
-
-
- }
- //自动动作
- void GL_CTHL_AutoStepAction(void)
- {
- if(bRunning && !bAlarmStop)
- {
- switch(GL_CTHL_AutoStep)
- {
- case 1:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- if(!GL_CTHL_XKSC_Limit_IN)
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- GL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
- GL_CTHL_FKGD_VAVLE = 0; //方块固定关
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- GL_CTHL_CXSX_VAVLE = 1; //插销上下
- else
- GL_CTHL_CXSX_VAVLE = 0; //插销顶出
- // GL_CTHL_XKDW_VAVLE = 1;
- GL_CTHL_AutoStep = 2;
- if(GL_CTHL_HLJJ_VAVLE)
- bCL_EN_FLG = 1;
- if(GL_CTHL_ZhuangLiaoStep == 0)
- {
- GL_CTHL_ZhuangLiaoStep = 1;
- GL_CTHL_TryCnt = 0;
- }
- }
- break;
- case 2:
- if((!GL_CTHL_XKTD_Origin_IN && GL_CTHL_XKTD_VAVLE) ||
- (!GL_CTHL_XKTD_VAVLE&& GL_CTHL_XKTD_Origin_IN)) //斜口推带原位离开
- {
- GL_CTHL_AutoStep = 3;
- if(GL_CTHL_cZipCnt== 0)
- {
- GL_CTHL_AutoDelay = dwTickCount + 180;
- }
- else
- GL_CTHL_AutoDelay = dwTickCount;
-
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 3://斜口定位
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- GL_CTHL_AutoStep = 4;
- GL_CTHL_XKDW_VAVLE = 1;
- if(GL_CTHL_cZipCnt== 0)
- GL_CTHL_AutoDelay = dwTickCount + 80;
- else
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_XKDW_TD_DELAY;
- }
- }
- break;
- case 4:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- if(!GL_CTHL_XKSC_Limit_IN)
- {
- // AxisContinueMoveAcc(X_AXIS,1000,DIR_P,800,600,10,10);//拖带电机
- SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
-
- //AxisMovePosAccDecNotStop(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,250,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_XKDW_Speed,10,10,0);
- AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,DIR_P,GL_CTHL_PARAM_XKDW_Speed/2,GL_CTHL_PARAM_XKDW_Speed/2,10,10);//拖带电机
- GL_CTHL_bDinweiOK = 0;
- }
-
- GL_CTHL_AutoStep = 5;
- GL_CTHL_XSavePosBuff = dwXRealPos;
- }
-
-
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 5:
- if((dwXRealPos >= GL_CTHL_PARAM_WLCDSHEZHI_LENTH) && GL_CTHL_PARAM_WLCDSHEZHI_LENTH)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
- //无拉链自动停机
- }
- if(dwXRealPos > GL_CTHL_LianLengthAutoCheck+2000 && GL_CTHL_LianLengthAutoCheck && GL_CTHL_cZipCnt>0)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
- //无拉链自动停机
- }
- if(dwXRealPos>= 190)
- GL_CTHL_FKJD_VAVLE = 1; //方块夹带气缸关
- if((dwXRealPos >= 280) && bCL_EN_FLG)
- GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- if(GL_CTHL_XKSC_Limit_IN) //方块上止到位
- {
- if(bCL_EN_FLG)
- GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- //AxisEgmStop(X_AXIS);
- GL_CTHL_GDXM_VAVLE = 1; //固定斜码
- GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸关
- GL_CTHL_bDinweiOK = 1;
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- {
- if(((GL_CTHL_bTiaoShiMode) && (!GL_CTHL_bTiaoShiStep)))
- {
- AxisEgmStop(X_AXIS);
- }
- else if(GL_CTHL_PARAM_SCDW_LENTH==0)
- {
- AxisEgmStop(X_AXIS);
- }
- else
- {
- AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_SCDW_LENTH,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_XKDW_Speed,6,2,0); //
- }
- }
- else ////尼龙不用多走
- {
- AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,-25,GL_CTHL_PARAM_XKDW_Speed,GL_CTHL_PARAM_XKDW_Speed,6,2,0);
- }
- //调试模式
- // if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
-
- GL_CTHL_AutoStep = 6;
- //GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_bLTCHECK_Delay = dwTickCount + 20;
- //电机穿入可以启动
- bCL_OK_FLG = 1; //不用穿合链的话认为已经完成
- if(bCL_EN_FLG)
- {
- bCL_OK_FLG = 0;
- GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
-
- GL_CTHL_CL_MotorStep = 1;
- GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HLJJ_CL_DELAY;
- }
- }
- }
- else if(dwXRealPos >= (GL_CTHL_XSavePosBuff + 850)) //750
- {
- AxisEgmStop(X_AXIS);
- GL_CTHL_SetAlarmCode(GL_CTHL_FKCXDW_ALARM,bRunning); //方块插销定位异常警告
-
- }
-
- break;
- case 6:
- // if(GL_CTHL_XKTD_Origin_IN) //斜口推带回到原位
- // {
-
- if(bZhuangLiaoOkFlg && (GL_CTHL_ZhuangLiaoStep == 0))
- {
- if(dwTickCount >= GL_CTHL_bLTCHECK_Delay)
- {
- //单一标志
- if(bSingOneFlg)
- {
- //次数到停止
- if(bSingOneCnt==0)
- {
- GL_CTHL_AutoStep = 0;
- bRunning = 0;
- }
- }
- if(!bSingOneFlg || (bSingOneFlg && bSingOneCnt))
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- if(!GL_CTHL_LTou_Check)
- {
- // GL_CTHL_CTXMSS_VAVLE = 1; //穿头下模上升
- if(!GL_CTHL_CTXMSS_VAVLE)
- GL_CTHL_HeMoStep = 1; //下模的上升和下降电磁阀要配合
- GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- GL_CTHL_AutoStep = 7;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_CXSX_VAVLE = 1; //插销上下
-
- //单一标准有效,次数减去1
- if(bSingOneFlg)
- {
- if(bSingOneCnt>0)
- bSingOneCnt--;
- }
- }
- else
- {
- cWULATOUCnt=1;
- GL_CTHL_SetAlarmCode(GL_CTHL_ZLT_ALARM,bRunning); // 没有拉头
- }
- }
- }
- }
- }
- // }
- // else if(dwTickCount >= GL_CTHL_AutoDelay)
- // {
- // GL_CTHL_SetAlarmCode(GL_CTHL_XKTD_Origin_ALARM,bRunning); //斜口推带回到异常
- // }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 7:
- if(!GL_CTHL_CTM_Origin_IN)
- {
- GL_CTHL_JLTou_VAVLE = 0; //接拉头
- }
- if(GL_CTHL_CTM_Limit_IN)
- {
- GL_CTHL_JLTou_VAVLE = 0;
- GL_CTHL_AutoStep = 8;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_DXK_DELAY;
-
- if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1)) //尼龙的顶斜口不能输出
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- }
- else if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Limit_ALARM,bRunning); //穿头下模上升异常
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 8:
- if(dwTickCount >= GL_CTHL_AutoDelay) //延时顶斜口
- {
- if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0) && (GL_CTHL_PARAM_QianMaSelect == 0))
- GL_CTHL_DXK_VAVLE = 1; //延时顶斜口
-
- GL_CTHL_AutoStep = 9;
- if(GL_CTHL_cZipCnt==0)
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_DXK_XKDW_Off_DELAY+50;
- else
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_DXK_XKDW_Off_DELAY;
-
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
-
- case 9:
- if((dwTickCount >= GL_CTHL_AutoDelay)) //顶斜口延时退斜口上止定位
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
-
- GL_CTHL_XKDW_VAVLE = 0; //方块钩针
- GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸关
- GL_CTHL_AutoStep = 10;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_XK_CR_DELAY;
-
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1)
- GL_CTHL_CXSX_VAVLE = 0; //插销顶出退
- }
- }
- break;
- case 10:
- if((dwTickCount >= GL_CTHL_AutoDelay) && !X_DRV && (bCL_OK_FLG))
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- GL_CTHL_TD_MotorStep = 10; //启动拖带穿入
- GL_CTHL_AutoStep = 11;
- GL_CTHL_bXCBackOK = 0;
- GL_CTHL_AutoDelay = dwTickCount + 60;
- }
- }
- break;
- case 11:
-
- if((GL_CTHL_TD_MotorStep == 0) && bCL_OK_FLG) //穿入定位完成
- {
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- GL_CTHL_CXSX_VAVLE = 1; //插销上下
- else
- GL_CTHL_CXSX_VAVLE = 0; //插销顶出
- /* //测试拖带定位
- GL_CTHL_AutoStep = 1;
- GL_CTHL_AutoDelay = dwTickCount + 1000;
- if(GL_CTHL_cZipCnt<3)
- GL_CTHL_cZipCnt++;
- break; */
-
- // if(START_IN_UP)
- // {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- GL_CTHL_XKDW_VAVLE = 0; //方块钩针
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
-
- // if(GL_CTHL_PARAM_CR_MODE==0)
- GL_CTHL_CXSCDW_VAVLE = 1; //Y21 插销上止定位电磁阀
-
- if((GL_CTHL_CL_MotorStep == 0) && (GL_CTHL_SF_Origin_IN))
- {
- GL_CTHL_CXQJD_VAVLE = 1;
-
- //Y轴启动插销
- GL_CTHL_CL_MotorStep = 20; //插销定位
- GL_CTHL_BB_VAVLE=1;
-
- }
- GL_CTHL_AutoStep = 12;
- }
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 12:
- if(!GL_CTHL_bXCBackOK && (GL_CTHL_CL_MotorStep == 0) &&
- (GL_CTHL_SF_Origin_IN ))
- {
- GL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- GL_CTHL_CL_MotorStep = 20; //插销定位
- GL_CTHL_BB_VAVLE=1;
- }
- if(!GL_CTHL_XKTD_Origin_IN)//) //插销前夹带回到原位
- {
- GL_CTHL_AutoStep = 14;
-
- GL_CTHL_AutoDelay = dwTickCount + 0;
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 14:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 15;
- GL_CTHL_FKGD_VAVLE = 1; //方块固定
- // if(GL_CTHL_PARAM_CR_MODE==0)
- // GL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- GL_CTHL_XKDW_VAVLE = 1; //方块勾针输出
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 15:
- if(!GL_CTHL_bXCBackOK && (GL_CTHL_CL_MotorStep == 0) &&
- (GL_CTHL_SF_Origin_IN ))
- {
- GL_CTHL_CXQJD_VAVLE = 1;
- GL_CTHL_CL_MotorStep = 20; //插销定位
- GL_CTHL_BB_VAVLE=1;
- }
- if((GL_CTHL_CL_MotorStep == 0) && GL_CTHL_bXCBackOK) //插销定位完成
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- GL_CTHL_AutoStep = 16;
- GL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- GL_CTHL_AutoDelay = dwTickCount + 2; //延时插销下移
-
- GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- GL_CTHL_FKJD_VAVLE = 0;
- }
- }
- break;
- case 16:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 17;
- GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- GL_CTHL_CXSX_VAVLE = 0; //插销上下
- else
- GL_CTHL_CXSX_VAVLE = 1; //插销顶出
- // GL_CTHL_CXSX_VAVLE = 0; //Y06 插销下移电磁阀
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 17:
- if(GL_CTHL_CXXY_Limit_IN)
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- //GL_CTHL_XKDW_VAVLE = 1; //方块勾针输出
- GL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- GL_CTHL_AutoStep = 18;
- if(GL_CTHL_LENTH>0 )
- {
- if(!GL_CTHL_bReStart)
- GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH;
- // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH,800,600,6,8,0);
- else
- GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH/3;
- // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH/3,800,600,6,8,0);
- }
- else
- {
- if(!GL_CTHL_bReStart)
- GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH + 300;
- // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH-300,800,600,6,8,0);
- else
- GL_CTHL_LENCountBuff = GL_CTHL_PARAM_TDFZ_LENTH/3+ 300;
- // AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_PARAM_TDFZ_LENTH/3-300,800,600,6,8,0);
- }
- user_datas[123] = GL_CTHL_LENCountBuff;//
- AxisMovePosAccDec(X_AXIS,6000,-GL_CTHL_LENCountBuff,800,600,6,8,0);
- GL_CTHL_bReStart = 0;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_CXCR_DELAY;
- cXcxcrCnt = 0;
- }
- }
- else if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CXGL_Limit_ALARM,bRunning); //插销下移异常
-
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 18:
- // if(START_IN_UP)
- {
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 19;
-
- GL_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
- GL_CTHL_AutoDelay = dwTickCount + 500; //插销穿入到位异常时间
-
- GL_CTHL_CL_MotorStep = 50; //合链电机回原点
- }
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 19:
-
-
- if(GL_CTHL_CX_Limit_IN || (!GL_CTHL_CXDWZ_VAVLE && GL_CTHL_bTiaoShiMode))
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- bZhuangLiaoOkFlg = 0;
- GL_CTHL_AutoStep = 20;
- GL_CTHL_BB_VAVLE=0;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_DELAY/2;//延时一次穿入
-
-
- }
- GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1)
- GL_CTHL_CXSX_VAVLE = 0; //插销顶出
- }
- else if((dwTickCount >= GL_CTHL_AutoDelay) && GL_CTHL_CXDWZ_VAVLE)
- {
- cXcxcrCnt++;
- if(cXcxcrCnt >= 3)
- GL_CTHL_SetAlarmCode(GL_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- else
- {
- GL_CTHL_CXHJD_VAVLE=0;
- GL_CTHL_AutoStep = 190;
- GL_CTHL_AutoDelay = dwTickCount + 100;
- }
-
- }
-
- break;
- case 190:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 191;
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)
- GL_CTHL_AutoDelay = dwTickCount + 100;
- }
- break;
- case 191:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_CXQJD_VAVLE = 1;
- GL_CTHL_CL_MotorStep = 20; //插销定位
- GL_CTHL_bXCBackOK=0;
- GL_CTHL_AutoStep = 192;
- }
- break;
-
- case 192:
- if((GL_CTHL_CL_MotorStep == 0) && GL_CTHL_bXCBackOK)
- {
- GL_CTHL_AutoStep = 18;
- GL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- GL_CTHL_CXHJD_VAVLE=1;
- GL_CTHL_AutoDelay = dwTickCount + 100;
- }
- break;
- case 20:
- if( GL_CTHL_FKGD_VAVLE)//方块固定退
- {
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_FKGD_VAVLE = 0;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_DELAY/2;//延时一次穿入
- }
- }
- else
- {
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 21;
- GL_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
- GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带打开
-
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- break;
- case 21:
- if(!GL_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
- {
- // GL_CTHL_LENCountBuff
- // AxisMovePosAccDec(X_AXIS,5000,GL_CTHL_PARAM_TDFZ_LENTH*4/5,1500,800,6,6,0);
-
- GL_CTHL_AutoStep = 22;
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_Timer/2; //一次穿入时间
- }
- else if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
- }
- break;
- case 22:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 23;
- GL_CTHL_LENCountBuff = GL_CTHL_LENCountBuff * 2/5;
- // if(GL_CTHL_LENCountBuff > 150)
- AxisMovePosAccDec(X_AXIS,3500,GL_CTHL_LENCountBuff,800,800,6,6,0);
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_First_CL_Timer/2; //一次穿入时间
- }
- break;
- case 23:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- GL_CTHL_AutoStep = 24;
- GL_CTHL_MGuo_VAVLE = 0; //码勾退
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_PARAM_MGOff_XiaMo_DELAY;
- }
- }
- break;
- case 24:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 25;
- GL_CTHL_HeMoStep = 10; //下模的上升和下降电磁阀要配合
- GL_CTHL_CTXMSS_VAVLE = 0; //穿头下模退
- GL_CTHL_AutoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸输出
-
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- GL_CTHL_FKGD_VAVLE = 0; //方块固定关
- GL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- break;
- case 25:
- if(!GL_CTHL_CTM_Limit_IN)
- {
- GL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- GL_CTHL_AutoStep = 26;
- GL_CTHL_AutoDelay = dwTickCount + 3; //一次穿入延时返回
- }
- else if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning);//穿头下模下降异常
- }
- break;
- case 26:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- GL_CTHL_AutoStep = 27;
- // GL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- GL_CTHL_AutoDelay = dwTickCount + 0;
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- GL_CTHL_FKJD_VAVLE = 0; //方块夹带气缸输出
- //退下出错警告
- GL_CTHL_AutoDelay1 = dwTickCount + 25;
- GL_CTHL_AutoStep1 = 1;
- }
- break;
- case 27:
- if(dwTickCount >= GL_CTHL_AutoDelay)
- {
- //调试模式
- if((!GL_CTHL_bTiaoShiMode) || GL_CTHL_bTiaoShiStep)
- {
- GL_CTHL_bTiaoShiStep = 0;
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- GL_CTHL_FKGD_VAVLE = 0; //方块固定关
- GL_CTHL_AutoStep = 2;
- bCL_EN_FLG = 1;
- // cXcxcrCnt=0;
- AddToTal(GL_CTHL_TOTAL_ADDR);
- AddToTal(GL_CTHL_WORK_TOTAL_ADDR);
- AddToTal(GL_CTHL_CUR_TOTAL_ADDR);
- CalProSP(GL_CTHL_SPEED_ADDR);
- if(GL_CTHL_cZipCnt<3)
- GL_CTHL_cZipCnt++;
- }
- }
-
- break;
- }
- GL_CTHL_RunStepSave = GL_CTHL_AutoStep;
- }
- //退下模后启动送拉头
- switch(GL_CTHL_AutoStep1)
- {
- case 1:
- if(cStopMode==1)
- {
- cStopMode=2;
- bStop=1;
- }
- if(GL_CTHL_First_CT_VAVLE)
- {
- if(dwTickCount >= GL_CTHL_AutoDelay1)
- {
- GL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- GL_CTHL_AutoDelay1 = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- else
- {
- if(GL_CTHL_CTM_Origin_IN && GL_CTHL_First_CT_Origin_IN)
- {
- GL_CTHL_ZhuangLiaoStep = 1;
- GL_CTHL_TryCnt = 0;
- GL_CTHL_AutoStep1 = 0;
- GL_CTHL_MGuo_VAVLE = 0;
- GL_CTHL_JLTou_VAVLE = 0;
- if(!bRunning) //在调机状态下先判断有没有料
- {
- GL_CTHL_MGuo_VAVLE = 1;
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 100;
- bZhuangLiaoOkFlg = 0;
- }
- }
- else if(dwTickCount >= GL_CTHL_AutoDelay1)
- {
- //穿头模和一次穿入回位异常
- if(!GL_CTHL_CTM_Origin_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning);
- else if(!GL_CTHL_First_CT_Origin_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_First_CT_Origin_ALARM,bRunning);
- }
- }
- break;
-
- }
-
- }
- void GL_CTHL_CheckStart(void)
- {
- /*
- if(cWULATOUCnt) // 无拉头警告后按
- {
- if(GL_CTHL_START_IN_UP)
- {
- if(!bRunning)
- {
- if(GL_CTHL_SafeDoor_IN)
- {
- bRunning=1;
- GL_CTHL_TryCnt=0;
- cWULATOUCnt=0;
- GL_CTHL_ZhuangLiaoStep = 1;
- GL_CTHL_AutoStep=6;
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg= 0;
- GL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
-
- }
- else
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
- }
- }
- }
- */
- //启动 自动启动 单一自动
- if(GL_CTHL_START_IN_UP || bStart || GL_CTHL_bOnceStart)
- {
- //单一启动
- if(GL_CTHL_bOnceStart)
- {
- GL_CTHL_bOnceStart=0;
- bSingOneFlg=1;//一次标志
- bSingOneCnt=1;//走完一条
- }
- else
- {
- bSingOneFlg=0;
- bSingOneCnt=0;
- }
- if(!bRunning)
- {
- if(GL_CTHL_SafeDoor_IN)
- {
- GL_CTHL_CXDW_Stop = 0;
- cStopMode=0;
- bRunning = 1;
- cWULATOUCnt=0;
-
- GL_CTHL_CL_MotorStep = 40;
- bZhuangLiaoOkFlg= 0;
- GL_CTHL_SongDai_Step=1;
- GL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 180;
- GL_CTHL_LianLengthCheck = 0;
- GL_CTHL_LianLengthAutoCheck = 0;
- GL_CTHL_cZipCnt = 0;
- bTuiLaTouOkFlg = 1;
- bCL_EN_FLG = 0;
- cStopInCnt = 0;
- GL_CTHL_CTXMXJ_VAVLE = 0;
- GL_CTHL_bReStart = 0;
- //装料启动一次,保证下模已在原位(下面)
- if((GL_CTHL_ZhuangLiaoStep == 0) && !GL_CTHL_CTXMSS_VAVLE && GL_CTHL_CTM_Origin_IN)
- {
- GL_CTHL_ZhuangLiaoStep = 1;
- GL_CTHL_TryCnt = 0;
- }
- //已经定位好,并且保持在原位
- if(GL_CTHL_bDinweiOK && GL_CTHL_XKSC_Limit_IN && GL_CTHL_XKDW_VAVLE
- && GetEn(X_AXIS) && (GL_CTHL_RunStepSave != 19))
- {
- SetPos(X_AXIS, 0);
- GL_CTHL_GDXM_VAVLE = 1;
- GL_CTHL_AutoStep = 5;
- GL_CTHL_XSavePosBuff = 0;
-
- } //穿插销不到位停止
- else if(((GL_CTHL_RunStepSave == 19) || (GL_CTHL_RunStepSave == 190) || (GL_CTHL_RunStepSave == 191))
- && GL_CTHL_CXHJD_VAVLE && GL_CTHL_CXHDW_VAVLE
- && GL_CTHL_CTXMSS_VAVLE && GL_CTHL_CXDWZ_VAVLE)
- {
- if(GL_CTHL_CX_Limit_IN)
- {
- GL_CTHL_AutoStep = 19;
- }
- else
- {
- GL_CTHL_AutoStep = 16;
- GL_CTHL_bReStart = 1;
- GL_CTHL_AutoDelay = dwTickCount + 100;
- GL_CTHL_CXHJD_VAVLE = 0;
- GL_CTHL_CXHDW_VAVLE = 0;
- }
- }
- else
- {
- GL_CTHL_AutoStep = 1;
- GL_CTHL_AutoDelay = dwTickCount + 180;
- }
- GL_CTHL_cZipCnt = 0;
-
- SetEn(X_AXIS, MOTOR_EN);
- SetEn(Y_AXIS, MOTOR_EN);
- SetAlarmCode(GL_CTHL_ALARM_ADDR,0);
-
- }
- else
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
- }
- bStart = 0;
- }
- if(bStop)
- {
- bStop=0;
- bSingOneFlg=1;
- bSingOneCnt=0;
- }
-
- //停止
- if(GL_CTHL_STOP_IN_UP)
- {
- if(cStopMode < 2)
- cStopMode++;
- if(bRunning)
- {
- GL_CTHL_CXDW_Stop = 0;
- cStopMode=0;
- cXcxcrCnt=0;
- cWULATOUCnt=0;
- if(GL_CTHL_XKSC_Limit_IN)
- AxisEgmStop(X_AXIS);
- else
- AxisDecStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- GL_CTHL_AutoStep = 0;
-
- GL_CTHL_CL_MotorStep =0;
- GL_CTHL_SongDai_Step=0;
- GL_CTHL_HLJJ_VAVLE = 0;
- GL_CTHL_bCLFirst_Step=0;
- if(!GL_CTHL_bDinweiOK)
- GL_CTHL_XKDW_VAVLE =0;
- SetAlarmCode(GL_CTHL_ALARM_ADDR,0);
- bRunning=0;
- }
- else if(!bRunning)
- {
- bRunning=0;
- cXcxcrCnt=0;
- cStopMode=0;
- cWULATOUCnt=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- cStopMode=0;
- GL_CTHL_bDinweiOK = 0;
- if(GetAlarm(X_AXIS)==MOTOR_ALARM || GetAlarm(Y_AXIS)==MOTOR_ALARM )
- {
- SetClr(X_AXIS,ALARM_CLR);
- GL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 200;
- }
- GL_CTHL_TLiao_VAVLE=0;
-
- if(!GL_CTHL_HSLiao_VAVLE || !GL_CTHL_MGuo_VAVLE)
- GL_CTHL_JLTou_VAVLE =0;
- GL_CTHL_HSLiao_VAVLE =0;
- GL_CTHL_XKTD_VAVLE =0;
- GL_CTHL_XKDW_VAVLE =0;
- GL_CTHL_DXK_VAVLE =0;
- GL_CTHL_GDXM_VAVLE = 0;
- GL_CTHL_CXSX_VAVLE =0;
-
- GL_CTHL_First_CT_VAVLE =0;
- GL_CTHL_FKGD_VAVLE =0;
- GL_CTHL_CXQJD_VAVLE =0;
- GL_CTHL_CXDWZ_VAVLE =0;
- GL_CTHL_CXHJD_VAVLE =0;
- GL_CTHL_CXHDW_VAVLE =0;
- GL_CTHL_FKJD_VAVLE =0;
- GL_CTHL_HLJJ_VAVLE =0;
- GL_CTHL_BB_VAVLE=0;
- //GL_CTHL_CXHT_VAVLE = 0;
- GL_CTHL_CXSCDW_VAVLE =0;
- if((GL_CTHL_CTXMSS_VAVLE) || (GL_CTHL_CTM_Origin_IN && !GL_CTHL_CTXMSS_VAVLE))
- GL_CTHL_MGuo_VAVLE =0;
- if(GL_CTHL_CTXMSS_VAVLE || !GL_CTHL_CTM_Origin_IN)
- {
- GL_CTHL_HeMoStep = 10;
- }
- else if(!GL_CTHL_CTXMSS_VAVLE && !GL_CTHL_CTM_Limit_IN)
- GL_CTHL_CTXMXJ_VAVLE = 1;
- GL_CTHL_CTXMSS_VAVLE =0;
- GL_CTHL_AutoStep = 0;
- GL_CTHL_ZhuangLiaoStep=0;
- GL_CTHL_TLiaoStep=0;
- GL_CTHL_TD_MotorStep=0;
- GL_CTHL_JiaLianStep =0;
- // GL_CTHL_ZhenDongStep =0;
- GL_CTHL_SongLiaoStep =0;
- GL_CTHL_CL_MotorStep =0;
- GL_CTHL_AutoStep1 =0;
- GL_CTHL_bFKCXTDDW_Step=0;
- GL_CTHL_bCXCR_Step=0;
- GL_CTHL_bCLFirst_Step=0;
- GL_CTHL_RunStepSave = 0;
- GL_CTHL_SongDai_Step=0;
- SetAlarmCode(GL_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
- // if(cStopInCnt < 3)
- // cStopInCnt++;
- // if(bStop)
- // cStopInCnt = 0;
- GL_CTHL_TLiaoStep = 0;
- GL_CTHL_AutoStep = 0;
- GL_CTHL_CXDW_Stop = 0;
- //穿合链电机是往零点方向时可以停止
- // if((GetDir(Y_AXIS) == DIR_N) && GL_CTHL_SF_Origin_IN)
- // AxisEgmStop(Y_AXIS);
-
- // if(GL_CTHL_SF_ALR_IN || GL_CTHL_Y_SF_ALR_IN)
- // {
- // //SetEn(Z_AXIS, MOTOR_EN); //清伺服警告
- // GL_CTHL_ALARMCLR_VAVLE=1;
- // GL_CTHL_bSFBBAOJIN_Delay= dwTickCount + 200;
- // }
- /* if(cStopInCnt > 1)
- {
- GL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- GL_CTHL_ZhuangLiaoStep = 0;
- }
- else
- {
- GL_CTHL_TD_MotorStep = 0;
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- GL_CTHL_bFKCXTDDW_Step = 0;
- GL_CTHL_bCXCR_Step = 0;
- GL_CTHL_bCLFirst_Step = 0;
- }*/
- }
- bStop=0;
- }
-
- if(bAlarmStop)
- {
- bRunning = 0;
- bAlarmStop=0;
- cStopMode=0;
- cXcxcrCnt=0;
- if(GetAlarmCode(GL_CTHL_ALARM_ADDR) == GL_CTHL_SF_ALR_ALARM)
- GL_CTHL_X_EN_FLG=0;
- if(GetAlarmCode(GL_CTHL_ALARM_ADDR) == GL_CTHL_Y_SF_ALR_ALARM)
- GL_CTHL_Y_EN_FLG=0;
- AxisDecStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- if(GL_CTHL_CXSC_Limit_IN)
- {
- AxisEgmStop(X_AXIS);
- }
- GL_CTHL_AutoStep = 0;
- GL_CTHL_CL_MotorStep =0;
- GL_CTHL_bCLFirst_Step=0;
- GL_CTHL_SongLiaoStep =0;
- GL_CTHL_ZhuangLiaoStep=0;
- GL_CTHL_SongDai_Step=0;
- }
- }
- //拖带电机控制动作 X轴
- void GL_CTHL_TD_Motor(void) //
- {
- #if 1
- switch(GL_CTHL_TD_MotorStep)
- {
- //1步开始,纯定位, 没有穿入
- case 1:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(dwTickCount >= GL_CTHL_TD_MotorDelay) //给锁轴时间
- {
- GL_CTHL_bTest = 0;
- bCheckEN_FLG = 1;
- GL_CTHL_CheckInX02PosBuff= 0;
- GL_CTHL_TD_MotorStep = 2;
- SetPos(X_AXIS, 0); //启动位置设为0点
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0) //尼龙
- AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,DIR_P,800,600,15,15);
- else
- AxisContinueMoveAcc(X_AXIS,4000,DIR_P,800,600,15,15);
- }
- break;
- case 2://检测到过链
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)//200) //穿入2CM后退
- {
- GL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- GL_CTHL_GDXM_VAVLE = 0;
- if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1))//尼龙
- GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸输出
- }
- if((dwXRealPos >= GL_CTHL_PARAM_WLCDSHEZHI_LENTH) && GL_CTHL_PARAM_WLCDSHEZHI_LENTH)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- }
- if((dwXRealPos > (GL_CTHL_LianLengthAutoCheck+2000)) && GL_CTHL_LianLengthAutoCheck && GL_CTHL_cZipCnt>1)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
- //无拉链自动停机
- }
- if(GL_CTHL_FK_Check)
- {
- // user_datas[122] = dwXRealPos;
- GL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1)) //尼龙
- GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸输出
- GL_CTHL_GDXM_VAVLE = 0;
- GL_CTHL_XSavePosBuff = dwXRealPos;
- GL_CTHL_TD_MotorStep = 3;
- // user_datas[123] = dwXRealPos - GL_CTHL_CheckInX02PosBuff;
- if((dwXRealPos >= GL_CTHL_CheckInX02PosBuff) && GL_CTHL_CheckInX02PosBuff)
- AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,GL_CTHL_PARAM_FKDW_Length - (dwXRealPos- GL_CTHL_CheckInX02PosBuff),
- GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed/2,10,50,100);
- else
- AxisMovePosAccDec(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,GL_CTHL_PARAM_FKDW_Length,
- GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed/2,10,50,100);
- }
- if(GL_CTHL_CXSC_Limit_IN_UP)
- {
- GL_CTHL_X_CXPosBuff = dwXRealPos;
- // if(GL_CTHL_PARAM_CR_MODE==0)
- // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- break;
- case 3:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(GL_CTHL_CXSC_Limit_IN_UP && !GL_CTHL_bTest)
- {
- GL_CTHL_bTest = 1;
- GL_CTHL_X_CXPosBuff = dwXRealPos;
- user_datas[123] = GL_CTHL_X_CXPosBuff;
- }
- if(!X_DRV || (dwXRealPos >= (GL_CTHL_XSavePosBuff + GL_CTHL_PARAM_FKDW_Length)))
- {
- AxisEgmStop(X_AXIS);
- GL_CTHL_TD_MotorStep =4 ;
- GL_CTHL_LianLengthAutoCheckOLD = GL_CTHL_LianLengthAutoCheck;
- GL_CTHL_LianLengthAutoCheck = dwXRealPos;
- }
- break;
- case 4:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(GL_CTHL_PARAM_XCX_LENTH) //0的话不判断位置
- {
- // if(GL_CTHL_PARAM_CR_MODE==0)
- // {
- if ((dwXRealPos - GL_CTHL_X_CXPosBuff) > (GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_XCXWC_LENTH))
- {
- user_datas[121] = 1;
- GL_CTHL_TD_MotorStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
- else if((dwXRealPos - GL_CTHL_X_CXPosBuff) < (GL_CTHL_PARAM_XCX_LENTH - GL_CTHL_PARAM_XCXWC_LENTH))
- {
- user_datas[121] = 2;
- GL_CTHL_TD_MotorStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else if(GL_CTHL_X_CXPosBuff == 0)
- {
- user_datas[121] = 3;
- GL_CTHL_TD_MotorStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else
- {
- GL_CTHL_TD_MotorStep = 0;
- }
- // }
- // else
- // {
- // if(GL_CTHL_X_CXPosBuff == 0)
- // {
- // user_datas[121] = 3;
- // GL_CTHL_TD_MotorStep = 0;
- // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- // }
- // else
- // {
- // GL_CTHL_TD_MotorStep = 0;
- // }
- // }
- }
- else
- {
- GL_CTHL_TD_MotorStep = 0;
- }
- break;
-
- //穿拉头定位
- case 10:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(dwTickCount >= GL_CTHL_TD_MotorDelay)
- {
- GL_CTHL_TD_MotorStep = 11;
- SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
- AxisContinueMoveAcc(X_AXIS,4000,DIR_P,800,1200,18,5);
- GL_CTHL_CheckInX02PosBuff= 0;
- bCheckEN_FLG = 1;
- GL_CTHL_X_CXPosBuff = 0;
- GL_CTHL_bTest = 0;
- GL_CTHL_X_FKCheckPos = 0;
- user_datas[121] = 0;
- }
- break;
- case 11:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(dwXRealPos > 150) //穿入2CM后退
- {
- if((GL_CTHL_cZipCnt < 2) || (GL_CTHL_LianLengthCheck < 350))
- {
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed,DIR_P,3000,600,10,10);
- else
- AxisContinueMoveAcc(X_AXIS,6000,DIR_P,3000,600,10,10);
- }
- else ////两段速度移动距离
- {
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- AxisMovePosAccDecNotStop(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed + GL_CTHL_PARAM_TD_RunSpeed/3,GL_CTHL_LianLengthCheck-350,3000,8500,10,20,0);
- else
- AxisMovePosAccDecNotStop(X_AXIS,GL_CTHL_PARAM_TD_RunSpeed + GL_CTHL_PARAM_TD_RunSpeed/3,GL_CTHL_LianLengthCheck-450,3000,7000,10,20,0);
- }
- GL_CTHL_TD_MotorStep = 12;
- }
- break;
- case 12:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT)
- {
- if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)
- {
- GL_CTHL_CheckInX02PosBuff= 0;
- GL_CTHL_GDXM_VAVLE = 0;
- GL_CTHL_TD_MotorStep = 13;
-
- }
- }
- else
- {
- if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)
- {
- GL_CTHL_CheckInX02PosBuff= 0;
- GL_CTHL_GDXM_VAVLE = 0;
- GL_CTHL_TD_MotorStep = 13;
-
- }
- }
- break;
- case 13://检测到过链
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if(dwXRealPos > GL_CTHL_PARAM_TuiDXM_Lenght)//400)
- {
- GL_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- if((GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1) || (GL_CTHL_PARAM_QianMaSelect == 1)) //尼龙
- GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸输出
- }
- if((dwXRealPos >= GL_CTHL_PARAM_WLCDSHEZHI_LENTH) && GL_CTHL_PARAM_WLCDSHEZHI_LENTH)
- {
-
- GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- // AxisDecStop(X_AXIS);
- GL_CTHL_TD_MotorStep = 0;
- user_datas[121] = 10;
- AxisMovePosAccDec(X_AXIS,2000,600,
- GL_CTHL_PARAM_FKDW_Speed,1000,10,50,20);
- }
- if((dwXRealPos > (GL_CTHL_LianLengthAutoCheck+7000)) && GL_CTHL_LianLengthAutoCheck && GL_CTHL_cZipCnt>0)
- {
-
- GL_CTHL_SetAlarmCode(GL_CTHL_WLZDTJ_ALARM,bRunning);
- AxisDecStop(X_AXIS);
- GL_CTHL_TD_MotorStep = 0;
- user_datas[121] = 11;
- AxisMovePosAccDec(X_AXIS,2000,600,
- GL_CTHL_PARAM_FKDW_Speed,1000,10,50,20);
- break;
- //无拉链自动停机
- }
- if(GL_CTHL_FK_Check)
- {
- user_datas[122] = GetCurSpeed(X_AXIS);//dwXRealPos;
- GL_CTHL_LianLengthCheckReal=dwXRealPos;
- if(GL_CTHL_cZipCnt == 1)
- GL_CTHL_LianLengthCheck = dwXRealPos;
-
- //break;
- GL_CTHL_X_FKCheckPos = dwXRealPos + GL_CTHL_PARAM_FKDW_Length;
- GL_CTHL_TD_MotorStep = 14;
- // if(GetCurSpeed(X_AXIS) <= 10000)
- // user_datas[122] = GL_CTHL_PARAM_FKDW_Length - (dwXRealPos- GL_CTHL_CheckInX02PosBuff);
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- AxisMovePosAccDec(X_AXIS,8500,GL_CTHL_PARAM_FKDW_Length,
- GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed,10,50,20);
- else //尼龙
- AxisMovePosAccDec(X_AXIS,8500,GL_CTHL_PARAM_FKDW_Length,
- GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed,10,50,20);
- // else
- // AxisMovePosAccDec(X_AXIS,8000,GL_CTHL_PARAM_FKDW_Length-20,
- // GL_CTHL_PARAM_FKDW_Speed,GL_CTHL_PARAM_FKDW_Speed,10,35,30);
- //GL_CTHL_TD_MotorStep = 0;
- }
- //方块还没有感应之前感应到插销的话,肯定错位
- if(GL_CTHL_CXSC_Limit_IN_UP)
- {
- user_datas[121] = 4;
- GL_CTHL_X_CXPosBuff = dwXRealPos;
- // if(GL_CTHL_PARAM_CR_MODE==0)
- // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
- break;
- case 14:
- GL_CTHL_TDMotorStepSave = GL_CTHL_TD_MotorStep;
- if((dwXRealPos+350 >= GL_CTHL_X_FKCheckPos) && bRunning)
- {
- GL_CTHL_FKJD_VAVLE = 1;
- }
- if(GL_CTHL_CXSC_Limit_IN_UP && !GL_CTHL_bTest)
- {
- GL_CTHL_bTest = 1;
- GL_CTHL_X_CXPosBuff = dwXRealPos;
- user_datas[123] = GL_CTHL_X_CXPosBuff;
- user_datas[121] = 128;
- }
- if((!X_DRV ) || (dwXRealPos >= (GL_CTHL_X_FKCheckPos)))
- {
- // user_datas[123] = dwXRealPos-GL_CTHL_CheckInX02PosBuff;
- AxisEgmStop(X_AXIS);
- GL_CTHL_TD_MotorStep = 15;
- GL_CTHL_LianLengthAutoCheckOLD = GL_CTHL_LianLengthAutoCheck;
- GL_CTHL_LianLengthAutoCheck = dwXRealPos;
- }
- break;
- case 15:
-
- // if(GL_CTHL_PARAM_CR_MODE==0)
- // {
- if(((dwXRealPos - GL_CTHL_X_CXPosBuff) > (GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_XCXWC_LENTH)) && GL_CTHL_X_CXPosBuff)
- {
- user_datas[121] += 5;
- GL_CTHL_TD_MotorStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
- else if(((dwXRealPos - GL_CTHL_X_CXPosBuff) < (GL_CTHL_PARAM_XCX_LENTH - GL_CTHL_PARAM_XCXWC_LENTH)) && GL_CTHL_X_CXPosBuff)
- {
- user_datas[121] += 6;
- GL_CTHL_TD_MotorStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else if(GL_CTHL_X_CXPosBuff == 0)
- {
- user_datas[121] += 7;
- GL_CTHL_TD_MotorStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else
- {
- GL_CTHL_TD_MotorStep = 0;
- }
- // }
- // else
- // {
- // if(GL_CTHL_X_CXPosBuff == 0)
- // {
- // user_datas[121] += 7;
- // GL_CTHL_TD_MotorStep = 0;
- // GL_CTHL_SetAlarmCode(GL_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- // }
- // else
- // {
- // GL_CTHL_TD_MotorStep = 0;
- // }
- // }
- break;
-
-
-
- }
- #endif
- }
- //穿入电机动作,Y轴
- void GL_CTHL_CL_Motor(void) //
- {
- #if 1
- //1步开始, 穿链长度开始
- //20步开始 插销定位开始
- //40步,回原点为
- switch(GL_CTHL_CL_MotorStep)
- {
- //穿入长度位置
- case 1:
-
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- // if(GL_CTHL_PARAM_CR_MODE != 0) //电机穿入
- // {
- /*
- //穿入长度要根据检测长度减动一次穿入的3CM,反转的2CM
- if((GL_CTHL_LianLengthAutoCheck < (GL_CTHL_PARAM_CL_Length + 700)) && (GL_CTHL_LianLengthAutoCheck>700))
- {
- GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-700;
-
- // if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
- // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
- if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
- GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
- AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,150);
- }
- else if(GL_CTHL_LianLengthAutoCheck>700)
- {
- GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-GL_CTHL_PARAM_CL_Length;
- //if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
- // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
- if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
- GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
- AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,100);
- }
- */
- // (公分节判断)
- if((GL_CTHL_LianLengthAutoCheck < (GL_CTHL_LianLengthAutoCheckOLD)) &&
- (GL_CTHL_LianLengthAutoCheck < GL_CTHL_PARAM_GFJ_Length)) //
- {
- GL_CTHL_cZipCnt = 0;
- GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-900;
-
- // if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
- // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
- if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
- GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
- //正常穿入
- if(GL_CTHL_PARAM_GFJ_WorkMode == 0)
- {
- AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,150);
- }
- //停止
- else if(GL_CTHL_PARAM_GFJ_WorkMode == 1)
- {
- GL_CTHL_CL_MotorStep = 0;
- GL_CTHL_HLJJ_VAVLE = 0;
- bCL_OK_FLG = 1;
- bSingOneFlg= 1;
- bSingOneCnt=0;
- break;
- }
- else if(GL_CTHL_PARAM_GFJ_WorkMode == 2)
- {
- GL_CTHL_CL_MotorStep = 0;
- GL_CTHL_HLJJ_VAVLE = 0;
- bCL_OK_FLG = 1;
- break;
- }
-
- }
- //穿入长度要根据检测长度减动一次穿入的3CM,反转的2CM
- else if(GL_CTHL_LianLengthAutoCheck>700)
- {
- GL_CTHL_Y_CL_Length=GL_CTHL_LianLengthAutoCheck-GL_CTHL_PARAM_CL_Length-200;
- //if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_CL_MAX_Length)
- // GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_CL_MAX_Length-40;
- if(GL_CTHL_Y_CL_Length >= GL_CTHL_PARAM_Y_MAX_LENTH)
- GL_CTHL_Y_CL_Length = GL_CTHL_PARAM_Y_MAX_LENTH-40;
- else if(GL_CTHL_Y_CL_Length < 100)
- GL_CTHL_Y_CL_Length = 100;
- AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_Y_CL_Length,2000,2000,50,50,100);
- }
- GL_CTHL_CL_MotorStep = 2;
- // }
- // else //气缸穿入
- // {
- // GL_CTHL_CL_MotorStep = 10;
- // GL_CTHL_HL_VAVLE = 1;
- //
- // GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_CLT_Time;
- //
- // if(((GL_CTHL_LianLengthAutoCheckOLD > (GL_CTHL_LianLengthAutoCheck + 1200)) &&
- // GL_CTHL_LianLengthAutoCheck) && (GL_CTHL_cZipCnt > 1))
- // {
- // GL_CTHL_CL_MotorStep = 0;
- // bCL_OK_FLG = 1;
- // GL_CTHL_HLJJ_VAVLE = 0;
- // GL_CTHL_HL_VAVLE = 0;
- // }
- //
- // }
- }
- break;
- case 2:
- if((dwYRealPos + 120) > GL_CTHL_Y_CL_Length)
- GL_CTHL_HLJJ_VAVLE = 0;
- if(!Y_DRV || dwYRealPos >= GL_CTHL_Y_CL_Length)
- {
- AxisEgmStop(Y_AXIS);
- GL_CTHL_HLJJ_VAVLE = 0;
- GL_CTHL_CL_MotorStep = 3;
- bCL_OK_FLG = 1;
- GL_CTHL_CL_MotorDelay = dwTickCount + 20; //延时数控回零点
- }
- break;
- case 3:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- GL_CTHL_CL_MotorStep = 50;
-
- }
- break;
- //气缸穿入
- case 10:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- GL_CTHL_CL_MotorStep = 11;
- bCL_OK_FLG = 1;
- GL_CTHL_HLJJ_VAVLE = 0;
- GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HL_BACK_Time; //合链返回时间到后才能重新前夹链
- }
- break;
- case 11:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
-
- GL_CTHL_CL_MotorStep = 0;
- }
- break;
- //夹带插销到穿入位置
- case 20: //此处最好算好定位长度相减
- // if(cXcxcrCnt > 0 || GL_CTHL_LianLengthCheck - GL_CTHL_LianLengthCheckReal > 350)
- // {
- // GL_CTHL_LENTH = GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_CXDW_Length - (dwXRealPos - GL_CTHL_X_CXPosBuff) + 45;
- // }
- // else
- // {
- // GL_CTHL_LENTH = GL_CTHL_PARAM_XCX_LENTH + GL_CTHL_PARAM_CXDW_Length - (dwXRealPos - GL_CTHL_X_CXPosBuff);
- // }
- GL_CTHL_LENTH = GL_CTHL_PARAM_CXDW_Length;
- user_datas[121] = GL_CTHL_LENTH;
- user_datas[122] = GL_CTHL_X_CXPosBuff;
- if((GL_CTHL_LENTH > 0) )
- {
- GL_CTHL_CL_MotorStep = 21;
- }
- else
- {
- GL_CTHL_CL_MotorStep = 30;
- }
- GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_CXJZ_HT_DELAY;
- break;
- case 21:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- // if(GL_CTHL_PARAM_CR_MODE!= 0)
- // {
- GL_CTHL_Y_CL_PosBuff = dwYRealPos;
- AxisMovePosAccDec(Y_AXIS,8000,GL_CTHL_LENTH,800,500,6,6,20);
- // }
- // else
- // {
- // //GL_CTHL_CXHT_VAVLE = 1;
- // GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_XXHT_Time;
- // }
- GL_CTHL_CL_MotorStep = 22;
- }
- break;
- case 22:
- // if(GL_CTHL_PARAM_CR_MODE!= 0)
- // {
-
- if((dwYRealPos > GL_CTHL_Y_CL_PosBuff+GL_CTHL_LENTH-GL_CTHL_PARAM_CXDW_Length) && !GL_CTHL_CXDW_Stop)
-
- GL_CTHL_CXSCDW_VAVLE = 1; //Y21 插销上止定位电磁阀
- if(!Y_DRV /*|| (dwYRealPos >= GL_CTHL_PARAM_CXDW_Length)*/) //插销定位已经结束
- {
- AxisEgmStop(Y_AXIS);
- GL_CTHL_YsaveCXDWPosBuff = 0;
- if(GL_CTHL_CXDW_Stop)
- {
- GL_CTHL_CL_MotorStep = 23;
- GL_CTHL_CL_MotorDelay = dwTickCount + 30;
- }
- else
- {
- GL_CTHL_CL_MotorStep = 0;
- GL_CTHL_bXCBackOK = 1;
- GL_CTHL_CXQJD_VAVLE = 0;//YYQ
- //GL_CTHL_SongDai_VAVLE = 0; //松带
- }
-
-
- }
- // }
- // else if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- // {
- // GL_CTHL_CL_MotorStep = 23;
- // GL_CTHL_CL_MotorDelay = dwTickCount + 10;
- // GL_CTHL_CXQJD_VAVLE = 0;
- //
- // GL_CTHL_bXCBackOK = 1;
- // }
- break;
- case 23:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- //GL_CTHL_CXHT_VAVLE = 0;
- GL_CTHL_CL_MotorStep = 0;
- if(GL_CTHL_CXDW_Stop&& !bRunning)
- SetEn(Y_AXIS, MOTOR_DISEN);
- GL_CTHL_CXDW_Stop = 0;
- }
- break;
- case 30:
- GL_CTHL_YsaveCXDWPosBuff = 0;
- GL_CTHL_CL_MotorStep = 0;
- GL_CTHL_bXCBackOK = 1;
- GL_CTHL_CXQJD_VAVLE = 0;//YYQ
- break;
-
- //回原点开始
- case 40:
- // if(GL_CTHL_PARAM_CR_MODE == 0)
- // {
- // GL_CTHL_CL_MotorStep = 0;
- // GL_CTHL_CXQJD_VAVLE = 0;
- // //GL_CTHL_CXHT_VAVLE = 0;
- // GL_CTHL_HL_VAVLE = 0;
- // break;
- // }
- // else
- // {
- //要先离开
- if(GL_CTHL_SF_Origin_IN && (GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- GL_CTHL_CL_MotorStep = 41;
- SetDir(Y_AXIS, DIR_P);
- }
- else
- {
- SetDir(Y_AXIS, DIR_N);
- GL_CTHL_CL_MotorStep = 46;
-
- }
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- GL_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- else //已经锁轴
- GL_CTHL_CL_MotorDelay = dwTickCount + 5;
- // }
- break;
- case 41:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- GL_CTHL_CL_MotorStep = 42;
- AxisContinueMoveAcc(Y_AXIS,5000,DIR_P,1000,800,15,15);
- }
- break;
- case 42:
- if(!GL_CTHL_SF_Origin_IN)
- {
- GL_CTHL_CL_MotorStep = 43;
- GL_CTHL_YSavePosBuff = dwYRealPos;
- }
- break;
- case 43:
- //离开原点5CM停止
- if((dwYRealPos - GL_CTHL_YSavePosBuff) >= 800)
- {
- AxisEgmStop(Y_AXIS);
- GL_CTHL_CL_MotorStep = 46; //留空几步备用
- GL_CTHL_CL_MotorDelay = dwTickCount + 50;
- }
- break;
- case 46:
- if(dwTickCount >= GL_CTHL_CL_MotorDelay)
- {
- GL_CTHL_CL_MotorStep = 47; //检测回到原位
- if(!GL_CTHL_SF_Origin_IN)
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,800,15,10);
- }
- break;
- case 47:
- if(GL_CTHL_SF_Origin_IN)
- {
- GL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- break;
- //数控回原位 (条件为自动工作,SON一直没有松开)
- case 50:
- // if(GL_CTHL_PARAM_CR_MODE == 0)
- // {
- // GL_CTHL_CL_MotorStep = 0;
- // GL_CTHL_HLJJ_VAVLE = 0;
- // GL_CTHL_HL_VAVLE = 0;
- // break;
- // }
- // else
- // {
- if(dwYRealPos > 150)
- { //回零速度
- SetDir(Y_AXIS, DIR_N);
- AxisMovePosAccDecNotStop(Y_AXIS,GL_CTHL_PARAM_CL_Back_O_Speed,-dwYRealPos + 150,5000,2000,25,25,50);
- }
- else
- AxisContinueMoveAcc(Y_AXIS,1000,DIR_N,1000,1000,15,15);
- GL_CTHL_CL_MotorStep = 51;
- // }
- break;
- case 51:
- if(GL_CTHL_SF_Origin_IN)
- {
- GL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- else
- {
- if(dwYRealPos < -65)
- {
- GL_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- GL_CTHL_SetAlarmCode(GL_CTHL_YAxis_Origin_ALARM,0);
- }
- }
- break;
- }
- #endif
- }
- void GL_CTHL_HeMo(void)
- {
- switch(GL_CTHL_HeMoStep)
- {
- case 1:
- GL_CTHL_HeMoStep = 2;
- GL_CTHL_CTXMXJ_VAVLE = 1;
- //GL_CTHL_JLTou_VAVLE = 0; //接拉头关
- GL_CTHL_HeMo_Time = dwTickCount + 10;
- //GL_CTHL_TimeBuff=dwTickCount;
-
- // GL_CTHL_HeMoStep = 4;
- // GL_CTHL_CTXMSS_VAVLE = 1;
- // GL_CTHL_HeMo_Time = dwTickCount + 1800;
- GL_CTHL_CXSX_VAVLE=1;
-
- break;
- case 2:
- if(dwTickCount >= GL_CTHL_HeMo_Time)
- {
- GL_CTHL_HeMoStep = 3;
- GL_CTHL_CTXMSS_VAVLE = 1;
- GL_CTHL_HeMo_Time = dwTickCount + 25;
- }
- break;
- case 3:
- if(dwTickCount >= GL_CTHL_HeMo_Time)
- {
- GL_CTHL_HeMoStep = 4;
- GL_CTHL_CTXMXJ_VAVLE = 0;
- GL_CTHL_HeMo_Time = dwTickCount + 1800;
- }
- break;
- case 4:
- if(!GL_CTHL_CTM_Origin_IN)
- GL_CTHL_JLTou_VAVLE = 0; //接拉头
- if(GL_CTHL_CTM_Limit_IN)
- {
- GL_CTHL_JLTou_VAVLE = 0; //接拉头
- GL_CTHL_HeMoStep = 0;
- //user_datas[127]=dwTickCount-GL_CTHL_TimeBuff;
- }
- else if((dwTickCount >= GL_CTHL_HeMo_Time)&& bRunning)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Limit_ALARM,bRunning); //穿头下模上升异常
- }
- break;
- case 10:
- GL_CTHL_HeMoStep = 11;
- GL_CTHL_CTXMXJ_VAVLE = 1;
- GL_CTHL_CTXMSS_VAVLE = 0;
- GL_CTHL_HeMo_Time = dwTickCount + 200;
- //GL_CTHL_TimeBuff=dwTickCount;
- break;
- case 11:
- if(dwTickCount >= GL_CTHL_HeMo_Time)
- {
- //GL_CTHL_HeMoStep = 0;
- GL_CTHL_CTXMXJ_VAVLE = 0;
-
- }
- if(GL_CTHL_CTM_Origin_IN)
- {
- GL_CTHL_HeMoStep = 0;
- GL_CTHL_CTXMXJ_VAVLE = 0;
- //user_datas[127]=dwTickCount-GL_CTHL_TimeBuff;
- }
-
- break;
- }
- }
- //装拉头动作
- void GL_CTHL_ZLT_Step(void)
- {
- switch(GL_CTHL_ZhuangLiaoStep)
- {
- case 1:
-
- if(bZhuangLiaoOkFlg)
- {
- GL_CTHL_ZhuangLiaoStep = 0;
- }
- else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
- {
-
- if(((GL_CTHL_MGuo_VAVLE && GL_CTHL_LTou_Check) || (!GL_CTHL_MGuo_VAVLE)) && !GL_CTHL_JLiao_Limit_IN )//说明没有拉头
- {
- //穿头模和一次穿入必须在原位,接料不能有输出
- if(GL_CTHL_CTM_Origin_IN && !GL_CTHL_CTXMSS_VAVLE)
- {
- GL_CTHL_First_CT_VAVLE = 0;
- GL_CTHL_JLTou_VAVLE = 0;
- GL_CTHL_MGuo_VAVLE = 0;
- if(GL_CTHL_TLiaoStep == 0)
- {
- GL_CTHL_TLiaoStep = 1;
- GL_CTHL_ZhuangLiaoStep = 2;
- }
- }
-
- else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay + 500) //警告横送拉必须保证穿头模和一次穿入在原位,接料不能有输出
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning);
-
- }
- }
- else //已经有拉头直接跳到结束
- {
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 40;
- GL_CTHL_ZhuangLiaoStep = 9;
- }
- }
- break;
- case 2:
- if(GL_CTHL_TLiaoStep == 0) //推料已经完成
- {
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_JLTou_VAVLE = 0;
- GL_CTHL_MGuo_VAVLE = 0;
- if(!GL_CTHL_JLiao_Limit_IN && GL_CTHL_First_CT_Origin_IN)
- {
- GL_CTHL_ZhuangLiaoStep = 3;
- GL_CTHL_HSLiao_VAVLE = 1;
- }
- }
- break;
- case 3:
- //横送到位
- if(GL_CTHL_HSLiao_Limit_IN && !GL_CTHL_HSLiao_Origin_IN)
- {
- GL_CTHL_ZhuangLiaoStep = 4;
- // GL_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 2;
- }
- else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Limit_ALARM,bRunning);
- }
- break;
- case 4:
- if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
- {
- GL_CTHL_ZhuangLiaoStep = 5;
- GL_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
- GL_CTHL_CTXMSS_VAVLE = 0; //Y20 穿头下模上升电磁阀
- GL_CTHL_CTXMXJ_VAVLE = 0; //Y21 穿头下模下降电磁阀
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 5:
- if(GL_CTHL_JLiao_Limit_IN)
- {
- GL_CTHL_ZhuangLiaoStep = 6;
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_PARAM_MaGou_DELAY;
- }
- else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay) //接拉头(接料)到们信号异常
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_JLiao_Limit_ALARM,bRunning);
- }
- break;
- case 6:
- if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay) //延时码勾
- {
- GL_CTHL_MGuo_VAVLE = 1; //码勾输出
- GL_CTHL_ZhuangLiaoStep = 7;
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_PARAM_HSLiaoOff_DELAY;
- bTuiLaTouOkFlg = 0; //认为拉头没法带出
- }
- break;
- case 7:
- if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
- {
- GL_CTHL_HSLiao_VAVLE = 0;
- GL_CTHL_ZhuangLiaoStep = 8;
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 8:
- if(!GL_CTHL_HSLiao_Limit_IN) //
- {
- GL_CTHL_ZhuangLiaoStep = 9;
- GL_CTHL_TLiaoStep = 1; //推拉头
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_PARAM_CheckLT_DELAY; //也是给下模能上升的时间
- }
- else if (GL_CTHL_LTou_Check) //时间内信号这说明没有拉头
- {
- //重送3次
- GL_CTHL_TryCnt++;
- GL_CTHL_JLTou_VAVLE = 0; //接拉头关
- GL_CTHL_MGuo_VAVLE = 0; //码勾打开
- if(GL_CTHL_TryCnt >= 3)
- {
- GL_CTHL_TryCnt = 0;
- bZhuangLiaoOkFlg = 0;
- GL_CTHL_ZhuangLiaoStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_ZLT_ALARM,bRunning);
- cWULATOUCnt=1;
- }
- else
- {
- GL_CTHL_ZhuangLiaoStep = 20; //重新送3次
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Limit_ALARM,bRunning);
- if(bRunning)
- {
- GL_CTHL_ZhuangLiaoStep = 0 ;
- }
- }
- break;
- case 9:
- if(GL_CTHL_LTou_Check) //时间内信号这说明没有拉头
- {
- GL_CTHL_TryCnt++;
- GL_CTHL_JLTou_VAVLE = 0; //接拉头关
- GL_CTHL_MGuo_VAVLE = 0; //码勾打开
- if(GL_CTHL_TryCnt >= 3)
- {
- GL_CTHL_TryCnt=0;
- bZhuangLiaoOkFlg = 0;
- GL_CTHL_ZhuangLiaoStep = 0;
- GL_CTHL_SetAlarmCode(GL_CTHL_ZLT_ALARM,bRunning);
- cWULATOUCnt=1;
- }
- else
- {
- GL_CTHL_ZhuangLiaoStep = 20; //重新送3次
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- }
- else if((dwTickCount >= GL_CTHL_ZhuangLiaoDelay) || GL_CTHL_HSLiao_Origin_IN)
- {
- bZhuangLiaoOkFlg = 1;
- GL_CTHL_ZhuangLiaoStep = 0;
- }
- break;
- //装拉头不成攻重新送拉头
- case 20:
- if(GL_CTHL_HSLiao_Origin_IN)
- {
- GL_CTHL_JLTou_VAVLE = 0; //接拉头关
- GL_CTHL_MGuo_VAVLE = 0; //码勾打开
- GL_CTHL_ZhuangLiaoStep = 1;
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 10;
- }
- else if(dwTickCount >= GL_CTHL_ZhuangLiaoDelay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Origin_ALARM,bRunning);
- }
- break;
- }
- }
- void GL_CTHL_TLiao_Step(void)
- {
- switch(GL_CTHL_TLiaoStep)
- {
- case 1:
- if(bTuiLaTouOkFlg)
- {
- GL_CTHL_TLiaoStep = 0;
- }
- else
- {
- GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_TLiaoStep = 2;
- }
- break;
- case 2: //横送料在原位
- if(GL_CTHL_HSLiao_Origin_IN && !GL_CTHL_HSLiao_Limit_IN && !GL_CTHL_HSLiao_VAVLE)
- {
- GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_PARAM_HSLYDTL_DELAY;
- GL_CTHL_TLiaoStep = 21;
- }
- else if(dwTickCount >= GL_CTHL_TLiao_Delay)
- GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Origin_ALARM,1);
- break;
- case 21: //横送料在原位
- if((dwTickCount >= GL_CTHL_TLiao_Delay) && GL_CTHL_HSLiao_Origin_IN && !GL_CTHL_HSLiao_Limit_IN && !GL_CTHL_HSLiao_VAVLE)
- {
- GL_CTHL_TLiao_VAVLE = 1; //推料(推拉头)输出
- GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_TLiaoStep = 3;
- }
- else if(dwTickCount >= GL_CTHL_TLiao_Delay)
- GL_CTHL_SetAlarmCode(GL_CTHL_HSLiao_Origin_ALARM,1);
- break;
- case 3: //推拉头到位
- if(GL_CTHL_TLiao_Limit_IN)
- {
- GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_PARAM_TLiao_BACKDELAY;
- GL_CTHL_TLiaoStep = 4;
- }
- else if(dwTickCount >= GL_CTHL_TLiao_Delay)
- GL_CTHL_SetAlarmCode(GL_CTHL_TLiao_Limit_ALARM,1);
- break;
- case 4:
- if(dwTickCount >= GL_CTHL_TLiao_Delay)
- {
- GL_CTHL_TLiao_VAVLE = 0;
- GL_CTHL_TLiao_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_TLiaoStep = 5;
- }
- break;
- case 5:
- if(!GL_CTHL_TLiao_Limit_IN)
- {
- GL_CTHL_TLiaoStep = 0;
- GL_CTHL_TLiao_Delay = dwTickCount;
- bTuiLaTouOkFlg = 1;
- }
- else if(dwTickCount >= GL_CTHL_TLiao_Delay)
- GL_CTHL_SetAlarmCode(GL_CTHL_TLiao_Limit_ALARM,0);
- break;
- }
-
- }
- //振动盘控制
- void GL_CTHL_ZhenDongAction(void)
- {
-
- #if 1
- // if(bRunning)
- // {
- if(!GL_CTHL_PARAM_ZDP_AUTO)
- {
- if(GL_CTHL_ZhenDongPian_OUT == 1)
- {
- if(GL_CTHL_ZDP_IN)
- {
- if(dwTickCount >= GL_CTHL_ZDP_Delay)
- {
- GL_CTHL_ZhenDongPian_OUT = 0;
- GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Stop_TIME;//GL_CTHL_PARAM_ZDP_Stop_TIME + 50;
- }
- }
- else
- {
- GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Start_TIME;//GL_CTHL_PARAM_ZDP_Start_TIME;
- }
- }
- else
- {
- if(!GL_CTHL_ZDP_IN)
- {
- if(dwTickCount >= GL_CTHL_ZDP_Delay)
- {
- GL_CTHL_ZhenDongPian_OUT = 1;
- GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Start_TIME;//GL_CTHL_PARAM_ZDP_Start_TIME
- }
- }
- else
- GL_CTHL_ZDP_Delay = dwTickCount + GL_CTHL_PARAM_ZDP_Stop_TIME;//GL_CTHL_PARAM_ZDP_Stop_TIME+ 50;
- }
- }
- else if (GL_CTHL_PARAM_ZDP_AUTO ==1 )
- {
- GL_CTHL_ZhenDongPian_OUT=0;
- GL_CTHL_ZDP_Delay = dwTickCount + 0;
- }
- else if(GL_CTHL_PARAM_ZDP_AUTO == 2)
- {
- GL_CTHL_ZhenDongPian_OUT=1;
- GL_CTHL_ZDP_Delay = dwTickCount + 0;
-
- }
- //GL_CTHL_CuiQi_VAVLE = ~GL_CTHL_ZhenDongPian_OUT;
- #endif
- }
- void GL_CTHL_bFKCXTDDWStep(void)
- {
- switch(GL_CTHL_bFKCXTDDW_Step)
- {
- case 1:
-
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- GL_CTHL_FKGD_VAVLE = 0; //方块固定关
- GL_CTHL_bFKCXTDDW_Step = 2;
-
- break;
- case 2:
- if(!GL_CTHL_XKTD_Origin_IN) //斜口推带原位离开
- {
- GL_CTHL_bFKCXTDDW_Step = 3;
- GL_CTHL_bFKCXTDDW_Delay = dwTickCount + 20;
- }
- break;
- case 3://斜口定位
- if(dwTickCount >= GL_CTHL_bFKCXTDDW_Delay)
- {
- GL_CTHL_XKDW_VAVLE = 1;
- GL_CTHL_bFKCXTDDW_Step = 4;
- GL_CTHL_bFKCXTDDW_Delay = dwTickCount + GL_CTHL_PARAM_XKDW_TD_DELAY;
- }
- break;
- case 4:
- if(dwTickCount >= GL_CTHL_bFKCXTDDW_Delay)
- {
- AxisContinueMoveAcc(X_AXIS,GL_CTHL_PARAM_XKDW_Speed,DIR_P,GL_CTHL_PARAM_XKDW_Speed/2,GL_CTHL_PARAM_XKDW_Speed/2,10,10);//拖带电机
- GL_CTHL_bFKCXTDDW_Step = 5;
- GL_CTHL_XSavePosBuff = dwXRealPos;
- SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
- }
- break;
- case 5:
- if(GL_CTHL_XKSC_Limit_IN) //方块到位
- {
- AxisEgmStop(X_AXIS);
- GL_CTHL_bFKCXTDDW_Step = 6;
- GL_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
-
- GL_CTHL_bFKCXTDDW_Delay = dwTickCount + 300;
-
- }
- else if(dwXRealPos >= (GL_CTHL_XSavePosBuff + 800))
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_FKCXDW_ALARM,bRunning);//方块插销定位异常警告
-
- }
- break;
- case 6:
- if(dwTickCount >= GL_CTHL_bFKCXTDDW_Delay)
- {
- GL_CTHL_GDXM_VAVLE=1;
- GL_CTHL_bFKCXTDDW_Step = 0;
- }
- break;
- }
- }
- //插销穿入动作
- void GL_CTHL_bCXCRStep(void)
- {
- switch(GL_CTHL_bCXCR_Step)
- {
- case 11:
- if(!GL_CTHL_CXDW_Stop)
- GL_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- GL_CTHL_FKGD_VAVLE = 0; //方块固定关
- GL_CTHL_bCXCR_Step = 12;
- break;
- case 12:
- if(!GL_CTHL_XKTD_Origin_IN || GL_CTHL_CXDW_Stop) //斜口推带原位离开
- {
- GL_CTHL_bCXCR_Step = 13;
- GL_CTHL_bCXCR_Delay = dwTickCount + 65;
- }
- break;
- case 13:
- // if(GL_CTHL_PARAM_CR_MODE == 1)
- // {
- if((GL_CTHL_CL_MotorStep == 0) && (GL_CTHL_SF_Origin_IN) && (dwTickCount >= GL_CTHL_bCXCR_Delay)) //插销前夹带回到原位
- {
- GL_CTHL_bCXCR_Step = 14;
- if(!GL_CTHL_CXDW_Stop)
- GL_CTHL_FKGD_VAVLE = 1; //方块固定关
- GL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- //GL_CTHL_SongDai_VAVLE = 1; //松带
- GL_CTHL_bCXCR_Delay = dwTickCount + 0;
- }
- // }//气缸穿入
- // else
- // {
- // GL_CTHL_bCXCR_Step = 14;
- // if(!GL_CTHL_CXDW_Stop)
- // GL_CTHL_FKGD_VAVLE = 1; //方块固定关
- // GL_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- // //GL_CTHL_SongDai_VAVLE = 1; //松带
- // GL_CTHL_bCXCR_Delay = dwTickCount + 0;
- // }
- // break;
- case 14:
- if(dwTickCount >= GL_CTHL_bCXCR_Delay)
- {
- GL_CTHL_bCXCR_Step = 15;
- if(!GL_CTHL_CXDW_Stop)
- GL_CTHL_FKGD_VAVLE = 1; //方块固定
- //Y轴启动插销
- GL_CTHL_CL_MotorStep = 20; //插销定位
- GL_CTHL_BB_VAVLE=1;
- }
- break;
- case 15:
- if(GL_CTHL_CL_MotorStep == 0) //插销定位完成
- {
- if(!GL_CTHL_CXDW_Stop)
- {
- GL_CTHL_bCXCR_Step = 16;
- GL_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- GL_CTHL_bCXCR_Delay = dwTickCount + 10; //延时插销下移
- }
- else
- {
- GL_CTHL_bCXCR_Step = 0;
- }
- GL_CTHL_CXDW_Stop = 0;
- }
- break;
- case 16:
- if(dwTickCount >= GL_CTHL_bCXCR_Delay)
- {
- GL_CTHL_bCXCR_Step = 17;
- if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- GL_CTHL_CXSX_VAVLE = 0; //插销上下
- else
- GL_CTHL_CXSX_VAVLE = 1; //插销顶出
- GL_CTHL_bCXCR_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
- }
- break;
- case 17:
- if(GL_CTHL_CXXY_Limit_IN)
- {
- // if(GL_CTHL_START_IN_UP)
-
-
- GL_CTHL_bCXCR_Step = 18;
- if( cXcxcrCnt==0 && !X_DRV) //拖带电机反转
- {
- // SetDir(X_AXIS, DIR_N);
- AxisMovePosAccDec(X_AXIS,10000,-GL_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- GL_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- GL_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- GL_CTHL_bCXCR_Delay = dwTickCount + GL_CTHL_PARAM_CXCR_DELAY;
- }
- else if(dwTickCount >= GL_CTHL_bCXCR_Delay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CXGL_Limit_ALARM,bRunning);//插销下移异常
-
- }
- break;
- case 18:
- // if(START_IN_UP)
- {
- if(dwTickCount >= GL_CTHL_bCXCR_Delay)
- {
- GL_CTHL_bCXCR_Step = 19;
-
- GL_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
- GL_CTHL_bCXCR_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME +1000; //插销穿入到位异常时间
- //if(GL_CTHL_PARAM_CR_MODE == 1)
- GL_CTHL_CL_MotorStep = 50; //合链电机回原点
- }
- }
- break;
- case 19:
- // if( cXcxcrCnt > 1)
- {
- // GL_CTHL_SetAlarmCode(GL_CTHL_CX_Limit_ALARM,bRunning); //插销穿入到位异常
- }
-
- if( GL_CTHL_CX_Limit_IN )
- {
- cXcxcrCnt=0;
- bZhuangLiaoOkFlg = 0;
- GL_CTHL_bCXCR_Step = 0;
- GL_CTHL_BB_VAVLE=0;
- // GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
-
- }
- else if (dwTickCount >= GL_CTHL_bCXCR_Delay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CX_Limit_ALARM,bRunning); //插销穿入到
- GL_CTHL_bCXCR_Step = 0;
- /*
- cXcxcrCnt++;
-
- GL_CTHL_CXHJD_VAVLE=0;
- GL_CTHL_CXHDW_VAVLE=0;
- GL_CTHL_CXDWZ_VAVLE = 0;
- GL_CTHL_CXSX_VAVLE=1;
- GL_CTHL_bCXCR_Step = 11;
- */
- }
-
- break;
- }
- }
- void GL_CTHL_bCLFirstStep(void)
- {
- switch(GL_CTHL_bCLFirst_Step)
- {
- case 19:
- GL_CTHL_JLTou_VAVLE = 0; //接拉头
- bZhuangLiaoOkFlg = 0;
- GL_CTHL_bCLFirst_Step = 20;
- GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
- break;
- case 20:
- if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
- {
- GL_CTHL_bCLFirst_Step = 21;
- GL_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
- GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 21:
- if(!GL_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
- {
- GL_CTHL_bCLFirst_Step = 22;
- GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_PARAM_First_CL_Timer; //一次穿入时间
- }
- else if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
- }
- break;
- case 22:
- if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
- {
- GL_CTHL_bCLFirst_Step = 23;
- GL_CTHL_MGuo_VAVLE = 0; //码勾退
- GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_PARAM_MGOff_XiaMo_DELAY;
- GL_CTHL_FKGD_VAVLE = 0; //方块固定退
- GL_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- // if(GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 0)
- // GL_CTHL_CXSX_VAVLE = 1; //插销上下
- // else
- // GL_CTHL_CXSX_VAVLE = 0; //插销顶出
- }
- break;
- case 23:
- if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
- {
- GL_CTHL_bCLFirst_Step = 24;
- GL_CTHL_CTXMSS_VAVLE = 0; //穿头下模下降
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- GL_CTHL_bCLFirst_Delay = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 24:
- if(!GL_CTHL_CTM_Limit_IN)
- {
- GL_CTHL_bCLFirst_Step= 25;
- GL_CTHL_bCLFirst_Delay = dwTickCount + 25; //一次穿入延时返回
- }
- else if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,bRunning); //穿头下模下降异常
- }
- break;
- case 25:
- if(dwTickCount >= GL_CTHL_bCLFirst_Delay)
- {
-
- GL_CTHL_bCLFirst_Step= 0;
- GL_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
-
-
- //退下出错警告
- GL_CTHL_AutoDelay1 = dwTickCount + GL_CTHL_VAVLE_ERROR_TIME;
- GL_CTHL_AutoStep1 = 1;
- bTuiLaTouOkFlg = 1;
- }
- break;
- }
- }
- //手动动作
- void GL_CTHL_ManualAction(void)
- {
- if(bRunning) // 运行灯输出
- {
- GL_CTHL_Run_State=1;
- GL_CTHL_Stop_State=0;
- }
- else
- {
- GL_CTHL_Stop_State=1;
- GL_CTHL_Run_State=0;
- }
- if(GetEn(X_AXIS)==MOTOR_EN)
- GL_CTHL_X_EN_FLG=1;
- if(GetEn(Y_AXIS)==MOTOR_EN)
- GL_CTHL_Y_EN_FLG=1;
-
- if(dwTickCount>GL_CTHL_bSFBBAOJIN_Delay)
- {
- if((GetAlarm(X_AXIS)==MOTOR_ALARM) && GL_CTHL_X_EN_FLG) // 伺服报警
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_SF_ALR_ALARM,0);
- }
- if((GetAlarm(Y_AXIS)==MOTOR_ALARM) && GL_CTHL_Y_EN_FLG) // 伺服报警
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_Y_SF_ALR_ALARM,0);
- }
- SetClr(X_AXIS,ALARM_NOCLR);
- }
- if((dwYRealPos > (GL_CTHL_PARAM_Y_MAX_LENTH+20)) && Y_DRV && (GetDir(Y_AXIS)==DIR_P))
- {
- AxisEgmStop(Y_AXIS);
- // if(GL_CTHL_PARAM_CR_MODE != 0)
- // {
- GL_CTHL_SetAlarmCode(GL_CTHL_YAxis_Limit_ALARM,0);
- // }
- }
-
-
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(QDCT_TOTAL_ADDR);
- }
- if(GL_CTHL_bTLiao ) //手动推料(推拉头)
- {
- GL_CTHL_bTLiao = 0;
- if(GL_CTHL_TLiao_VAVLE)
- GL_CTHL_TLiao_VAVLE = 0;//GL_CTHL_TLiao_VAVLE;
- else if(!GL_CTHL_HSLiao_VAVLE && GL_CTHL_HSLiao_Origin_IN)
- {
- GL_CTHL_TLiao_VAVLE = 1;
- }
- else//条件警告
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_HENSONGLIAO_ALARM,0); // 横送料不能输出
- }
- }
- if(GL_CTHL_bHSL) //手动横送料
- {
- GL_CTHL_bHSL= 0;
- if(!GL_CTHL_First_CT_VAVLE)
- {
- if(GL_CTHL_HSLiao_VAVLE)
- {
- GL_CTHL_HSLiao_VAVLE = 0;//~GL_CTHL_HSLiao_VAVLE;
- }
- else if(!GL_CTHL_TLiao_VAVLE && !GL_CTHL_TLiao_Limit_IN && GL_CTHL_CTM_Origin_IN && !GL_CTHL_JLiao_Limit_IN &&
- !GL_CTHL_JLTou_VAVLE && !GL_CTHL_CTXMSS_VAVLE && !GL_CTHL_CXDWZ_VAVLE && (!GL_CTHL_bMG || (GL_CTHL_bMG && GL_CTHL_LTou_Check)))
- {
- GL_CTHL_HSLiao_VAVLE = 1;
- }
- else //条件警告 最后一个括号条件为已经有拉头
- {
- if(GL_CTHL_TLiao_Limit_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_TLiao_Limit_ALARM,0);
- else if(!GL_CTHL_CTM_Origin_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,0);
- else if(GL_CTHL_JLiao_Limit_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_JLiao_Limit_ALARM,0);
- }
- }
- }
- if(GL_CTHL_bJLT) //接拉头
- {
- GL_CTHL_bJLT = 0;
- if(GL_CTHL_JLTou_VAVLE)
- GL_CTHL_JLTou_VAVLE = 0;
- else if(!GL_CTHL_First_CT_VAVLE && !GL_CTHL_CTXMSS_VAVLE && GL_CTHL_CTM_Origin_IN && GL_CTHL_First_CT_Origin_IN)
- {
- GL_CTHL_MGuo_VAVLE = 0;
- GL_CTHL_JLTou_VAVLE = 1;
- GL_CTHL_CTXMXJ_VAVLE = 0;
- }
- else//条件警告
- {
- if(!GL_CTHL_CTM_Origin_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_CTM_Origin_ALARM,0);
- else if(!GL_CTHL_First_CT_Origin_IN)
- GL_CTHL_SetAlarmCode(GL_CTHL_First_CT_Origin_ALARM,0);
- }
- }
- if(GL_CTHL_bMG) //码勾
- {
- GL_CTHL_bMG = 0;
- GL_CTHL_MGuo_VAVLE = !GL_CTHL_MGuo_VAVLE;
- }
- if(GL_CTHL_bFKJD) //方块夹带
- {
- GL_CTHL_bFKJD = 0;
- GL_CTHL_FKJD_VAVLE = !GL_CTHL_FKJD_VAVLE;
- }
- if(GL_CTHL_bXKTD) //斜口推带
- {
- GL_CTHL_bXKTD = 0;
- if(GL_CTHL_XKTD_VAVLE)
- GL_CTHL_XKTD_VAVLE = 0;
- else if(((!GL_CTHL_DXK_VAVLE && (!GL_CTHL_XKSC_Limit_IN || !GL_CTHL_CTXMSS_VAVLE)) || (GL_CTHL_PARAM_UP_DOWN_OUT_SELECT == 1)) || GL_CTHL_PARAM_QianMaSelect)
- GL_CTHL_XKTD_VAVLE = 1;
- else//条件警告
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_DXKCTXM_Origin_ALARM,0);
- }
- }
- if(GL_CTHL_bXKDW) //斜口定位
- {
- GL_CTHL_bXKDW = 0;
- GL_CTHL_XKDW_VAVLE = ~GL_CTHL_XKDW_VAVLE;
- }
- if(GL_CTHL_bCTXM) //穿头下模
- {
- GL_CTHL_bCTXM = 0;
- if(GL_CTHL_CTXMSS_VAVLE)
- {
- GL_CTHL_HeMoStep = 10;
-
- // GL_CTHL_JLTou_VAVLE = 0;
- // GL_CTHL_CTXMXJ_VAVLE = 0;
- GL_CTHL_CTXMSS_VAVLE = 0;
- }
- else if(!GL_CTHL_HSLiao_VAVLE && GL_CTHL_HSLiao_Origin_IN && (!GL_CTHL_XKSC_Limit_IN || !GL_CTHL_XKTD_VAVLE))
- {
- // GL_CTHL_MGuo_VAVLE = 1;
- GL_CTHL_HeMoStep = 1;
- // GL_CTHL_CTXMSS_VAVLE = 1;
- // GL_CTHL_CTXMXJ_VAVLE = 1;
- // GL_CTHL_XMXJ_Time = dwTickCount + 450;
- }
- }
- if(GL_CTHL_bDXK) //顶斜口
- {
- GL_CTHL_bDXK = 0;
- if(GL_CTHL_DXK_VAVLE)
- {
- GL_CTHL_DXK_VAVLE = 0;
- }
- else if(!GL_CTHL_XKTD_VAVLE)
- {
- GL_CTHL_DXK_VAVLE = 1;
- GL_CTHL_GDXM_VAVLE = 1;
- }
- else //条件警告
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_XKTD_ALARM,0);
- }
- }
- if(GL_CTHL_bXKGD) //固定斜码电磁阀
- {
- GL_CTHL_bXKGD = 0;
- GL_CTHL_GDXM_VAVLE = ~GL_CTHL_GDXM_VAVLE;
- }
- if(GL_CTHL_bFKGD) //方块固定
- {
- GL_CTHL_bFKGD = 0;
- GL_CTHL_FKGD_VAVLE = ~GL_CTHL_FKGD_VAVLE;
- }
- if(GL_CTHL_bCXQJD) //插销前夹带
- {
- GL_CTHL_bCXQJD = 0;
- GL_CTHL_CXQJD_VAVLE = ~GL_CTHL_CXQJD_VAVLE;
- }
- if(GL_CTHL_bCXSY) //插销下移电磁阀
- {
- GL_CTHL_bCXSY = 0;
- GL_CTHL_CXSX_VAVLE = !GL_CTHL_CXSX_VAVLE;
- }
- //
- if(GL_CTHL_bCXHT)
- {
- GL_CTHL_bCXHT = 0;
- //GL_CTHL_CXHT_VAVLE = ~GL_CTHL_CXHT_VAVLE;
- if(GL_CTHL_CL_MotorStep == 0)
- GL_CTHL_CL_MotorStep = 20;
- SetEn(Y_AXIS, MOTOR_EN);
- GL_CTHL_CXDW_Stop = 1;
- }
- if(GL_CTHL_bBB)
- {
- GL_CTHL_bBB = 0;
- GL_CTHL_BB_VAVLE = ~GL_CTHL_BB_VAVLE;
- }
-
- if(GL_CTHL_bCXDWZ) //Y14 插销定位针电磁阀
- {
- GL_CTHL_bCXDWZ = 0;
- if(GL_CTHL_CXDWZ_VAVLE)
- GL_CTHL_CXDWZ_VAVLE = 0;
- else if(GL_CTHL_HSLiao_Origin_IN)
- {
- GL_CTHL_CXDWZ_VAVLE = 1;
- }
- else //条件警告
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_HENSONGLIAO_ALARM,0);
- }
-
- }
- if(GL_CTHL_bCXHJD) //Y15 插销后夹带电磁阀
- {
- GL_CTHL_bCXHJD = 0;
- GL_CTHL_CXHJD_VAVLE =~GL_CTHL_CXHJD_VAVLE;
- }
- if(GL_CTHL_bCXHDW) //Y16 插销后定位电磁阀
- {
- GL_CTHL_bCXHDW = 0;
- if(GL_CTHL_CXHDW_VAVLE)
- GL_CTHL_CXHDW_VAVLE = 0;
- else if(!GL_CTHL_CXQJD_VAVLE)
- GL_CTHL_CXHDW_VAVLE = 1;
- else//条件警告
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_CXQJD_ALARM,0);
- }
- }
- if(GL_CTHL_bFirst_CT) //Y20 一次穿头电磁阀
- {
- GL_CTHL_bFirst_CT = 0;
- GL_CTHL_First_CT_VAVLE = ~GL_CTHL_First_CT_VAVLE;
- }
- if(GL_CTHL_bHLJJ) //Y21 合链夹具电磁阀
- {
- GL_CTHL_bHLJJ = 0;
- GL_CTHL_HLJJ_VAVLE = ~GL_CTHL_HLJJ_VAVLE;
- }
- if(GL_CTHL_bHL)
- {
- GL_CTHL_bHL = 0;
- }
-
- if(GL_CTHL_bCXSCDW) //Y23 插销上止定位电磁阀
- {
- GL_CTHL_bCXSCDW = 0;
- GL_CTHL_CXSCDW_VAVLE = ~GL_CTHL_CXSCDW_VAVLE;
- }
- //自动装料
- if(GL_CTHL_bAutoZhuangLiao)
- {
- GL_CTHL_bAutoZhuangLiao = 0;
- if(GL_CTHL_ZhuangLiaoStep == 0)
- {
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg = 0;
- GL_CTHL_ZhuangLiaoStep = 1;
- GL_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- GL_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- }
- }
- //测试电机
- if(GL_CTHL_bCLMotor_N)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!GL_CTHL_SF_Origin_IN)
- {
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,1000,15,15);
- }
- else
- {
- GL_CTHL_bCLMotor_N = 0;
- }
-
- }
-
- if(GL_CTHL_bCLMotor_P) //后退限位已经取消
- {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_P,1000,1000,15,15);
- }
-
-
-
- if(!GL_CTHL_bCLMotor_P && !GL_CTHL_bCLMotor_N && (GL_CTHL_TD_MotorStep == 0) && (GL_CTHL_bFKCXTDDW_Step==0)&& (GL_CTHL_CL_MotorStep == 0))
- {
- AxisEgmStop(Y_AXIS);//AxisDecStop(Y_AXIS);
- }
-
- /* if(GL_CTHL_bCLMotor_N)
- {
- GL_CTHL_bCLMotor_N=0;
- SetEn(Y_AXIS, MOTOR_EN);
-
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,-GL_CTHL_PARAM_CL_Length,2000,2000,50,50,50);
- }
-
- if(GL_CTHL_bCLMotor_P) //后退限位已经取消
- {
- GL_CTHL_bCLMotor_P=0;
- SetEn(Y_AXIS, MOTOR_EN);
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisMovePosAccDec(Y_AXIS,GL_CTHL_PARAM_CL_Speed,GL_CTHL_PARAM_CL_Length,2000,2000,50,50,50);
- }
- */
- //合链电机返回原点
- if(GL_CTHL_bCLMotor_O)
- {
- GL_CTHL_bCLMotor_O = 0;
- if(GL_CTHL_CL_MotorStep == 0)
- GL_CTHL_CL_MotorStep = 40;
- }
-
- //拖带方块定位 ,因这步为前拖带定位, 很多电磁阀要关掉
- if(GL_CTHL_bFKTDDW)
- {
- GL_CTHL_bFKTDDW = 0;
- if(GL_CTHL_TD_MotorStep == 0)
- {
- GL_CTHL_XKDW_VAVLE = 0; //斜口定位
- GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- //GL_CTHL_CXSX_VAVLE = 1; //插销下移
- GL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位
- GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针
- GL_CTHL_bHLJJ = 0; //合链夹具
- GL_CTHL_FKJD_VAVLE = 0; //方块夹带
- if((GetEn(X_AXIS) == MOTOR_DISEN))
- {
- SetEn(X_AXIS, MOTOR_EN);
- GL_CTHL_TD_MotorDelay = dwTickCount + 200;
- }
- else
- GL_CTHL_TD_MotorDelay = dwTickCount + 50;
- GL_CTHL_TD_MotorStep = 1;
- GL_CTHL_cZipCnt = 0;
- }
- }
- //拖带方块插销定位(斜口推带,斜口定位,顶斜口)
- if(GL_CTHL_bFKCXTDDW)
- {
- GL_CTHL_bFKCXTDDW = 0;
- if((GL_CTHL_bFKCXTDDW_Step == 0) && (GL_CTHL_CL_MotorStep == 0) &&
- !GL_CTHL_CTXMSS_VAVLE)
- {
- GL_CTHL_bFKCXTDDW_Step = 1;
- SetEn(X_AXIS, MOTOR_EN);
- GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- //GL_CTHL_CXSX_VAVLE = 1; //插销上下
- GL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- GL_CTHL_CXHDW_VAVLE = 0; //插销后定位
- GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针
- GL_CTHL_HLJJ_VAVLE = 0; //合链夹具
- }
- }
- //插销穿入(包含电机前定位,插销下移,后夹,后定位)
- if(GL_CTHL_bCXCR)
- {
- GL_CTHL_bCXCR = 0;
- //拉头模在上面到们并且码勾输出,判断有拉头
- if(GL_CTHL_CTXMSS_VAVLE && GL_CTHL_MGuo_VAVLE && !GL_CTHL_CXQJD_VAVLE &&
- GL_CTHL_CTM_Limit_IN && !GL_CTHL_LTou_Check)
- {
- if(GL_CTHL_CL_MotorStep == 0)
- {
- GL_CTHL_bCXCR_Step = 11;
- GL_CTHL_CXSX_VAVLE = 1; //Y06 插销下移电磁阀关
- GL_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- GL_CTHL_CXHDW_VAVLE = 0;
-
- // if(GL_CTHL_PARAM_CR_MODE==0)
- // GL_CTHL_CXSCDW_VAVLE = 1;
- // if(GL_CTHL_PARAM_CR_MODE == 1)
- // {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!GL_CTHL_SF_Origin_IN)
- GL_CTHL_CL_MotorStep = 40;
- // }
- }
- }
- else //警告不能自动穿插销
- {
- GL_CTHL_SetAlarmCode(GL_CTHL_WFZIDONGCX_ALARM,0);
- }
- }
- //电机合链动作
- if(GL_CTHL_bMotorHL)
- {
- GL_CTHL_bMotorHL = 0;
- // if(GL_CTHL_PARAM_CR_MODE == 1)
- // {
- if(GL_CTHL_SF_Origin_IN)
- {
- if((GL_CTHL_CL_MotorStep == 0) && !GL_CTHL_CTXMSS_VAVLE && (!GL_CTHL_CTM_Limit_IN))
- {
- bCL_OK_FLG = 0;
- GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- GL_CTHL_CL_MotorStep = 1;
- GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HLJJ_CL_DELAY + 130;
- if((GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- SetEn(Y_AXIS, MOTOR_EN);
- GL_CTHL_CL_MotorDelay = dwTickCount + 250;
- }
- if((GL_CTHL_LianLengthAutoCheck ==0) || (GL_CTHL_PARAM_CL_Length == 0))
- {
- GL_CTHL_LianLengthAutoCheck = 1000;
- GL_CTHL_PARAM_CL_Length = 1000;
- }
- }
- // }
- else
- {
- GL_CTHL_bCLMotor_O = 1;
- }
- }
- else
- {
- GL_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- GL_CTHL_CL_MotorStep = 1;
- GL_CTHL_CL_MotorDelay = dwTickCount + GL_CTHL_PARAM_HLJJ_CL_DELAY;
- }
- }
- //一次穿链动作
- if(GL_CTHL_bCL_First)
- {
- GL_CTHL_bCL_First = 0;
- //拉头模在上面到们并且码勾输出,判断有拉头
- if(GL_CTHL_CTXMSS_VAVLE && GL_CTHL_MGuo_VAVLE && !GL_CTHL_CXQJD_VAVLE &&
- GL_CTHL_CTM_Limit_IN && !GL_CTHL_LTou_Check && (GL_CTHL_CL_MotorStep == 0))
- {
- GL_CTHL_bCLFirst_Step = 19;
- GL_CTHL_CXHJD_VAVLE = 1; //插销后夹带
- GL_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- GL_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- }
- }
- }
- }
- #endif
|