1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171 |
- #include "global.h"
- #if FJ_YING_XING_MACHINE==1
- void XY_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag);
- void XY_CTHL_ManualAction(void);
- void XY_CTHL_AutoStepAction(void);
- void XY_CTHL_TableAction(void);
- void XY_CTHL_TD_Motor(void);
- void XY_CTHL_CL_Motor(void);
- void XY_CTHL_CheckStart(void);
- void XY_CTHL_TLiao_Step(void); //推料(推拉头)
- void XY_CTHL_AlarmProtect(void);
- void XY_CTHL_ZLT_Step(void);
- void XY_CTHL_ZhenDongAction(void);
- void XY_CTHL_bFKCXTDDWStep(void);
- void XY_CTHL_bCXCRStep(void);
- void XY_CTHL_bCLFirstStep(void);
- void XY_CTHL_Color_Action(void);
- void XY_CTHL_ShiJue_Action(void);
- void ExtiAcitionX02(void)
- {
- if(bCheckEN_FLG)
- {
- bCheckEN_FLG = 0;
- XY_CTHL_CheckInX02PosBuff = GetPos(X_AXIS);
- YX_CTHL_CheckInX02PosBuff = GetPos(X_AXIS);
- }
- }
- //故障报警
- void XY_CTHL_SetAlarmCode(unsigned short alarm_code,unsigned short cStopFlag)
- {
- if(!cONERROR)
- {
- SetAlarmCode(XY_CTHL_ALARM_ADDR,alarm_code);
- cONERROR=1;
- }
- if(!cXiaoChaCNT)
- bAlarmStop = 1;
-
-
- }
- //视觉程序
- void XY_CTHL_ShiJue_Action(void)
- {
-
- #if 1
- if(!XY_CTHL_ZDP_IN)
- {
- // if(dwTickCount >= XY_CTHL_ShiJue_Delay2)
- {
- XY_CTHL_PARAM_ShiJue = 1;
- // XY_CTHL_ShiJue_Delay2 = dwTickCount + 500;//CTHL_PARAM_ZDP_Stop_TIME + 50;
- }
- }
- // else
- // {
- // XY_CTHL_ShiJue_Delay2 = dwTickCount + 500;//CTHL_PARAM_ZDP_Start_TIME;
- // }
-
- if(XY_CTHL_ZDP_IN)
- {
- /// if(dwTickCount >= XY_CTHL_ShiJue_Delay2)
- {
- XY_CTHL_PARAM_ShiJue = 0;
- // XY_CTHL_ShiJue_Delay2 = dwTickCount + 500;//CTHL_PARAM_ZDP_Start_TIME
- }
- }
- // else
- // XY_CTHL_ShiJue_Delay2 = dwTickCount + 500;//CTHL_PARAM_ZDP_Stop_TIME+ 50;
-
- #endif
-
- #if 1
- if(XY_CTHL_PARAM_ShiJue)
- {
-
- if(XY_CTHL_PARAM_SHIJUE_MODE)
- {
-
- switch(XY_CTHL_ShiJueStep)
- {
- case 0:
- // XY_CTHL_ShiJueStep=1;
- break;
- case 1:
- if(XY_CTHL_ShiJueStep1==0)
- {
- cShiJue=1;
- XY_CTHL_DINGCHU_VAVLE=0;
- XY_CTHL_ShiJue_Delay=dwTickCount+XY_CTHL_PARAM_JIANCHE_DEALY;
- XY_CTHL_ShiJueStep=2;
- }
- break;
- case 2:
- if((dwTickCount>=XY_CTHL_ShiJue_Delay) && !XY_CTHL_DINGCHU_VAVLE)
- {
-
- XY_CTHL_JIANCHE_VAVLE=1;
- XY_CTHL_ShiJue_Delay=dwTickCount+XY_CTHL_PARAM_GBXIANZZHI_DEALY;//延时关闭限制
- XY_CTHL_ShiJueStep=3;
- }
- break;
- case 3:
- if(dwTickCount>=XY_CTHL_ShiJue_Delay)
- {
-
- XY_CTHL_XIANZHI_VAVLE=0;
- XY_CTHL_ShiJue_Delay=dwTickCount+XY_CTHL_PARAM_DKXIANZZHI_DEALY;//延时打开限制
- XY_CTHL_ShiJueStep=4;
- }
- break;
- case 4:
- if(dwTickCount>=XY_CTHL_ShiJue_Delay)
- {
- XY_CTHL_SHIJUEMODE_VAVLE=1;
- XY_CTHL_XIANZHI_VAVLE=1;
- XY_CTHL_ShiJue_Delay=dwTickCount+XY_CTHL_PARAM_DINGLTOU_DEALY;//视觉检测时间
- XY_CTHL_ShiJueStep=5;
- }
- break;
- case 5:
- if(XY_CTHL_LMBJ_UP)
- {
- XY_CTHL_SHIJUEMODE_VAVLE=0;
- XY_CTHL_ShiJueStep1=1;
- XY_CTHL_ShiJueStep=1;
- }
- else if(dwTickCount>=XY_CTHL_ShiJue_Delay)
- {
- XY_CTHL_SHIJUEMODE_VAVLE=0;
- XY_CTHL_JIANCHE_VAVLE=0;
- XY_CTHL_ShiJueStep=1;
-
-
- }
- break;
-
-
- }
- switch(XY_CTHL_ShiJueStep1)
- {
- case 1:
- XY_CTHL_DINGCHU_VAVLE=1;
- XY_CTHL_ShiJue_Delay1=dwTickCount+XY_CTHL_PARAM_GBJIANCHE_DEALY;//延时退检测
- XY_CTHL_ShiJueStep1=2;
- break;
- case 2:
- if(dwTickCount>=XY_CTHL_ShiJue_Delay1)
- {
- XY_CTHL_JIANCHE_VAVLE=0;
- XY_CTHL_ShiJue_Delay1=dwTickCount+XY_CTHL_PARAM_DingLT_time;
- XY_CTHL_ShiJueStep1=3;
- }
- break;
- case 3:
- if(dwTickCount>=XY_CTHL_ShiJue_Delay1)
- {
-
- XY_CTHL_DINGCHU_VAVLE=0;
- XY_CTHL_ShiJueStep=1;
- XY_CTHL_ShiJueStep1=0;
- }
- break;
- }
-
- }
- else
- {
- XY_CTHL_ShiJueStep1=0;
- XY_CTHL_ShiJueStep=1;
-
- }
- }
- else
- {
- if(cShiJue)
- {
- cShiJue=0;
-
- XY_CTHL_XIANZHI_VAVLE=1;
- XY_CTHL_DINGCHU_VAVLE=0;
- }
- // XY_CTHL_ShiJueStep=1;
-
- // XY_CTHL_ShiJueStep1=0;
- ///XY_CTHL_ShiJueStep=0;
- }
- #endif
-
- }
- //色标保护
- void XY_CTHL_Color_Action(void)
- {
- if(XY_CTHL_PARAM_COLOR_CODE)
- {
- switch(XY_CTHL_ColorStep)
- {
-
- case 1:
-
- {
- bRunning=0;
- cXcxcrCnt=0;
- cXCXQXQD=0;
- bSingOneFlg=0;
- bCL_EN_FLG = 0;
- cBAOHUCNT=0;
- cBanAuTo=0;
- cXiaoChaTest=0;
- cCHULIANBAOJIN=0;
- XY_CTHL_XiaJiangXM_VAVLE=1;
- cWULATOUCnt=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- cStopMode=0;
- if(!XY_CTHL_SF_ALR_IN )
- {
- XY_CTHL_SF_ALR_CLR=1;
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 500;
- }
- XY_CTHL_TLiao_VAVLE=0;
- XY_CTHL_HSLiao_VAVLE =0;
- XY_CTHL_JLTou_VAVLE =0;
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_XKTD_VAVLE =0;
- XY_CTHL_XKDW_VAVLE =0;
- XY_CTHL_DXK_VAVLE =0;
- XY_CTHL_CXXY_VAVLE =0;
- XY_CTHL_CTXM_VAVLE =0;
- XY_CTHL_First_CT_VAVLE =0;
- XY_CTHL_FKGD_VAVLE =0;
- XY_CTHL_CXQJD_VAVLE =0;
- XY_CTHL_CXDWZ_VAVLE =0;
- XY_CTHL_CXHJD_VAVLE =0;
- XY_CTHL_CXHDW_VAVLE =0;
- XY_CTHL_FKJD_VAVLE =0;
- XY_CTHL_HLJJ_VAVLE =0;
- XY_CTHL_CXSCDW_VAVLE =0;
- if(XY_CTHL_CTM_Origin_IN || !XY_CTHL_CXSC_Limit_IN || cBanAuTo || bRunning)
- XY_CTHL_MGuo_VAVLE =0;
- XY_CTHL_AutoStep = 0;
- XY_CTHL_ZhuangLiaoStep=0;
- XY_CTHL_TLiaoStep=0;
- XY_CTHL_TD_MotorStep=0;
- XY_CTHL_JiaLianStep =0;
- XY_CTHL_SongLiaoStep =0;
- XY_CTHL_CL_MotorStep =0;
- XY_CTHL_AutoStep1 =0;
- XY_CTHL_bFKCXTDDW_Step=0;
- XY_CTHL_bCXCR_Step=0;
- XY_CTHL_bCLFirst_Step=0;
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
- XY_CTHL_TLiaoStep = 0;
- XY_CTHL_AutoStep = 0;
- }
- XY_CTHL_ColorStep=2;
- XY_CTHL_bColor_Delay=dwTickCount+500;
-
- break;
- case 2:
- if(dwTickCount >= XY_CTHL_bColor_Delay)
- {
- if(XY_CTHL_AUTO_run_LENGTH)
- {
- AxisMovePosAccDec(X_AXIS,3000,XY_CTHL_AUTO_run_LENGTH,800,600,6,6,0);
- XY_CTHL_ColorStep=3;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_COLOR_IN_ALARM,bRunning);
- }
-
- }
- break;
- case 3:
- if(!X_DRV)
- {
- XY_CTHL_bFKTDDW=1;
- XY_CTHL_ColorStep=4;
- XY_CTHL_bColor_Delay=dwTickCount+20;
-
- }
- break;
- case 4:
- if(dwTickCount >= XY_CTHL_bColor_Delay)
- {
- if(XY_CTHL_TD_MotorStep==0)
- {
- bStart=1;
- XY_CTHL_ColorStep=0;
- }
- }
- break;
-
- }
-
- }
- else
- {
- XY_CTHL_ColorStep=0;
- }
-
- }
- //初始化动作
- void XY_CTHL_InitAction(void)
- {
- float buff_pulse,buff_dist;
-
- buff_pulse = XY_CTHL_PARAM_CYCLE_PULSE;
- buff_dist = XY_CTHL_PARAM_CYCLE_LENGTH;
- XGearRatio = buff_pulse/buff_dist;
-
-
- buff_pulse = XY_CTHL_PARAM_CYCLE_PULSE;
- buff_dist = XY_CTHL_PARAM_SFCYCLE_LENGTH;
- YGearRatio = buff_pulse/buff_dist;
- //视觉启动
- XY_CTHL_ShiJueStep=1;
- bYFirstDingWeiFlg = 1;
- user_datas[121] = 0;
- user_datas[122] = 0;
- user_datas[123] = 0;
-
- if(XY_CTHL_MotorChose_MODE)
- SetEnReverse(X_AXIS, 0);
- else
- 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);
-
- if(!XY_CTHL_SF_Origin_IN)
- {
- XY_CTHL_bCLMotor_O=1;
- }
- // QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- }
- void XY_CTHL_Action(void)
- {
-
-
- // user_datas[122] =XY_CTHL_TLiaoStep;
-
-
- dwXRealPos = GetPos(X_AXIS);
- dwYRealPos = GetPos(Y_AXIS);
- dwZRealPos = GetPos(Z_AXIS);
- // user_datas[127] = GetAlarm(X_AXIS);
- // user_datas[128] = GetAlarm(Y_AXIS);
- user_datas[124] = dwXRealPos;
- user_datas[125] = dwYRealPos;
- user_datas[126] = XY_CTHL_LianLengthAutoCheck;
- user_datas[127] = XY_CTHL_LianLengthBCLENGTH_Check;
- user_datas[128] =XY_CTHL_AutoStep;
- XY_CTHL_ZhenDongAction();
- XY_CTHL_AlarmProtect();
- XY_CTHL_CheckStart();
- XY_CTHL_ZLT_Step();
- XY_CTHL_TLiao_Step();
- XY_CTHL_TD_Motor();
- XY_CTHL_CL_Motor();
- XY_CTHL_bFKCXTDDWStep();
- XY_CTHL_bCXCRStep();
- XY_CTHL_bCLFirstStep();
- XY_CTHL_ShiJue_Action();
- XY_CTHL_ManualAction();
- XY_CTHL_Color_Action();
- XY_CTHL_AutoStepAction();
- }
- void XY_CTHL_AlarmProtect(void)
- {
-
-
-
- }
- //自动动作
- void XY_CTHL_AutoStepAction(void)
- {
- if(XY_CTHL_PARAM_COLOR_CODE)
- {
- if(bRunning && XY_CTHL_Colorcode_IN_UP)
- {
- XY_CTHL_ColorStep=1;
- }
- }
-
- if(bRunning)
- {
- switch(XY_CTHL_AutoStep)
- {
- case 1:
- if(((XY_CTHL_SF_Origin_IN ) && (dwTickCount >= XY_CTHL_AutoDelay)) || cBanAuTo)
- {
- /* XY_CTHL_AutoStep = 10; //测试拖带定位
- XY_CTHL_AutoDelay = dwTickCount + 1000;
- break;
- */
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- XY_CTHL_FKGD_VAVLE = 0; //方块固定关
- // XY_CTHL_XKDW_VAVLE = 1;
- XY_CTHL_AutoStep = 2;
- XY_CTHL_AutoDelay = dwTickCount + 150;
- if(XY_CTHL_ZhuangLiaoStep == 0)
- {
- XY_CTHL_First_CT_VAVLE=0;
- XY_CTHL_ZhuangLiaoStep = 1;
- XY_CTHL_TryCnt = 0;
- }
- }
- }
- else if(dwTickCount >= (XY_CTHL_AutoDelay +10000))
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_SF_Origin_ALARM,bRunning);
- }
-
- break;
- case 2:
- if(!XY_CTHL_XKTD_Origin_IN && (dwTickCount >= XY_CTHL_AutoDelay)) //斜口推带原位离开
- {
- XY_CTHL_First_CT_VAVLE=0;
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 3;
- XY_CTHL_XKDW_VAVLE = 1;
- XY_CTHL_AutoDelay = dwTickCount + 20;
- }
- }
- else if(dwTickCount >= (XY_CTHL_AutoDelay+2000))
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_XKTD_Origin_ALARM,bRunning);
- }
- break;
- case 3://斜口定位
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_AutoStep = 4;
- // XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_XKDW_TD_DELAY;
- }
- break;
- case 4:
- if(!cBanAuTo)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- // XY_CTHL_LianLengthTEXT=dwXRealPos;
- // AxisContinueMoveAcc(X_AXIS,1000,DIR_P,800,600,15,60);//拖带电机
- AxisMovePosAccDecNotStop(X_AXIS,1200,500,600,500,20,100,00);
- XY_CTHL_AutoStep = 5;
- cDJzzcd=0;
- if(XY_CTHL_cZipCnt < 1)
- XY_CTHL_AutoDelay = dwTickCount +350;
- else
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_FKJD_DELAY;
- XY_CTHL_XSavePosBuff = dwXRealPos;
- // SetPos(X_AXIS, 0); //启动位置设为0点
-
- dwXRealPos = 0;
- }
-
- }
- else //半自动
- {
- XY_CTHL_AutoStep = 5;
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_FKJD_DELAY;
- XY_CTHL_XSavePosBuff = dwXRealPos;
- // SetPos(X_AXIS, 0); //启动位置设为0点
-
- }
- break;
- case 5:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
- }
-
- if(bCL_EN_FLG && (dwXRealPos >= 350) && XY_CTHL_XKSC_Limit_IN && !cStopGN)
- {
- XY_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- }
-
- if(XY_CTHL_XKSC_Limit_IN) //方块上止到位
- {
- XY_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- // user_datas[128] =XY_CTHL_LianLengthTEXT-dwXRealPos;
- if(!XY_CTHL_PARAM_DCGO_LENGTH)
- AxisEgmStop(X_AXIS);
- else
- {
- if(!cDJzzcd)
- {
- AxisMovePosAccDec(X_AXIS,1000,XY_CTHL_PARAM_DCGO_LENGTH,800,600,10,20,0);
- cDJzzcd=1;
- }
-
- }
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- // user_datas[128] = dwXRealPos;
-
- XY_CTHL_QDXK_VAVLE = 1;
- // AxisMovePosAccDec(X_AXIS,1200,10,1200,1200,6,6,0);
- if(XY_CTHL_cZipCnt < 1 && !bCL_OK_FLG)
- XY_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
-
- XY_CTHL_AutoStep = 6;
- XY_CTHL_AutoDelay = dwTickCount + 5000;//斜口推带回原位报警时间
- XY_CTHL_bLTCHECK_Delay = dwTickCount + 20;
- //电机穿入可以启动
-
- if(cStopGN)
- {
- XY_CTHL_HLJJ_VAVLE=0;
- }
- if(bCL_EN_FLG && XY_CTHL_XKSC_Limit_IN && !cStopGN )
- {
-
- XY_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- XY_CTHL_CL_MotorStep = 1;
- XY_CTHL_CL_MotorDelay = dwTickCount + XY_CTHL_PARAM_HLJJ_CL_DELAY;
- }
- }
- }
- else if(dwXRealPos >= (XY_CTHL_XSavePosBuff + 1500))
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_FKCXDW_ALARM,bRunning); //方块插销定位异常警告
-
- }
- break;
-
- case 6:
- if(XY_CTHL_CL_MotorStep==0 )
- {
- XY_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- }
- if(cStopGN)
- {
- XY_CTHL_XKTD_VAVLE=0;
- // cStopGN=0;
- }
- if(XY_CTHL_XKTD_Origin_IN) //斜口推带回到原位
- {
- if(bZhuangLiaoOkFlg && (XY_CTHL_ZhuangLiaoStep == 0))
- {
- if(dwTickCount >= XY_CTHL_bLTCHECK_Delay )
- {
- if(XY_CTHL_HSLiao_Origin_IN)
- {
- if(!XY_CTHL_LTou_Check)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- if(XY_CTHL_PARAM_TDFZ_LENTH && !X_DRV) //拖带电机反转
- {
- AxisMovePosAccDec(X_AXIS,8000,-XY_CTHL_PARAM_DXKFZ_LENTH,800,600,6,6,0);
- if(!XY_CTHL_PARAM_NLSL_MODE)
- XY_CTHL_FKJD_VAVLE= 0; //方块夹带气缸关
- }
- XY_CTHL_CTXM_VAVLE = 1; //穿头下模上升
- if(XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 1;
- XY_CTHL_AutoStep = 7;
- bCL_OK_FLG = 1; //不用穿合链的话认为已经完成
-
- XY_CTHL_XiaJiangXM_VAVLE=1;
- XY_CTHL_bXiaMoSJ_Delay = dwTickCount +20;
-
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- }
- }
- else
- {
- cWULATOUCnt=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_ZLT_ALARM,bRunning); // 没有拉头
- }
-
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay )
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_HSLiao_Origin_ALARM,bRunning);
- }
- }
-
- }
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay && !cBanAuTo)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_XKTD_Origin_ALARM,bRunning); //斜口推带回到异常
- }
- break;
- case 7:
-
- if(dwTickCount >= XY_CTHL_bXiaMoSJ_Delay )
- {
- XY_CTHL_XiaJiangXM_VAVLE=0;
- }
-
- if(XY_CTHL_CTM_Limit_IN)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- XY_CTHL_XKTD_VAVLE=1;
- }
- XY_CTHL_FKJD_VAVLE=0;
- XY_CTHL_JLTou_VAVLE = 0;
-
- XY_CTHL_AutoStep = 8;
- XY_CTHL_AutoDelay = dwTickCount + 10;
- }
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay )
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CTM_Limit_ALARM,bRunning); //穿头下模上升异常
- }
- break;
- case 8:
- if(!X_DRV)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- if(!XY_CTHL_PARAM_NLSL_MODE)
- XY_CTHL_DXK_VAVLE=1;
- else
- XY_CTHL_XKTD_VAVLE=1;
-
- if(cQDXK_DXK)
- {
- XY_CTHL_AutoStep = 0;
- bRunning = 0;
- // SetEn(X_AXIS, MOTOR_DISEN);
- }
- else
- {
- // if(!XY_CTHL_PARAM_NLSL_MODE)
- if(cBanAuTo)
- XY_CTHL_AutoDelay = dwTickCount + 500;
- else
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_DXK_XKDW_Off_DELAY;
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- if(XY_CTHL_XKTD_VAVLE)
- XY_CTHL_AutoStep = 9;
- else
- XY_CTHL_XKTD_VAVLE=1;
-
- }
- else
- XY_CTHL_AutoStep = 9;
- }
- }
- }
- break;
- case 9:
- if((dwTickCount >= XY_CTHL_AutoDelay) && (bCL_OK_FLG || cStopGN)) //顶斜口延时退斜口上止定位
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- // AxisMovePosAccDec(X_AXIS,2000,-150,1200,1200,3,6,0); //反转1.5CM
- XY_CTHL_XKDW_VAVLE = 0; //斜口定位
- XY_CTHL_FKJD_VAVLE = 0; //方块夹带气缸关
-
- XY_CTHL_AutoStep = 10;
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_XK_CR_DELAY;
- }
- }
- break;
- case 10:
- if(!cBanAuTo)
- {
-
- if((dwTickCount >= XY_CTHL_AutoDelay) && !X_DRV)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
-
- XY_CTHL_TD_MotorStep = 10; //启动拖带穿入
- // XY_CTHL_FKJD_VAVLE= 0;
- XY_CTHL_TD_MotorDelay = dwTickCount + 0;
- XY_CTHL_AutoStep = 11;
- }
-
- }
-
- }
- else
- {
- XY_CTHL_AutoStep = 801;
- XY_CTHL_AutoDelay = dwTickCount + 500;
-
- }
- break;
- case 801:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
-
- bRunning=0;
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_XKTD_VAVLE = 0;
- XY_CTHL_DXK_VAVLE=0;
- XY_CTHL_AutoStep = 0;
-
- }
- break;
- case 11:
-
- if(XY_CTHL_TD_MotorStep == 0) //穿入定位完成
- {
- //测试拖带定位
- /* XY_CTHL_AutoStep = 1;
- XY_CTHL_AutoDelay = dwTickCount + 1000;
- if(cZipCnt<3)
- cZipCnt++;
- break; */
-
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_XKDW_VAVLE = 0; //斜口上止定位关
- XY_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- XY_CTHL_CXSCDW_VAVLE = 1; //Y21 插销上止定位电磁阀
- // XY_CTHL_FKJD_VAVLE= 0;
- if((XY_CTHL_CL_MotorStep == 0) && XY_CTHL_PARAM_CR_MODE)
- {
- XY_CTHL_CXQJD_VAVLE = 1;
- }
- XY_CTHL_AutoStep = 12;
- }
-
-
- }
- break;
-
- case 12:
- if(!XY_CTHL_SF_Origin_IN && XY_CTHL_PARAM_CR_MODE)
- {
- XY_CTHL_CXQJD_VAVLE = 0;
- if(XY_CTHL_CL_MotorStep==0)
- XY_CTHL_CL_MotorStep = 40;
-
- // SetEn(Y_AXIS, MOTOR_DISEN);
-
- }
- if((XY_CTHL_CL_MotorStep == 0)&& (XY_CTHL_SF_Origin_IN) ) //插销前夹带回到原位
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 14;
- XY_CTHL_CXQJD_VAVLE = 1;
- SetEn(Y_AXIS, MOTOR_EN);
- if(!cCXCONE)
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_XCQJD_XCDW_DELAY;
- else
- XY_CTHL_AutoDelay = dwTickCount + 500;
- if(cXcxcrCnt>0)
- XY_CTHL_AutoDelay = dwTickCount + 300;
- }
- }
- break;
- case 14:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 15;
- XY_CTHL_XKDW_VAVLE = 1; //斜口定位
- XY_CTHL_FKGD_VAVLE = 1; //方块固定
- //Y轴启动插销
- XY_CTHL_CL_MotorStep = 20; //插销定位
- }
- }
- break;
- case 15:
- if(XY_CTHL_CL_MotorStep == 0) //插销定位完成
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 16;
- if(!XY_CTHL_PARAM_XCDWZ_MODE)
- {
- if(!XY_CTHL_PARAM_XCDWGY_MODE)
- XY_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- }
-
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_XCCR_DEALY; //延时插销下移
- }
- }
- break;
- case 16:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 17;
- if(XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 0;
- else
- XY_CTHL_CXXY_VAVLE = 1; //Y06 插销下移电磁阀
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
- XY_CTHL_SQJD_Delay= dwTickCount + XY_CTHL_PARAM_TQJD_DELAY;
- }
- }
- break;
- case 17:
- if(dwTickCount >= XY_CTHL_SQJD_Delay)
- {
- if(XY_CTHL_PARAM_CXXY_MODE)
- {
- if(XY_CTHL_CXXY_Origin_IN)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 18;
- if( cXcxcrCnt==0 && !X_DRV && !cCXCONE) //拖带电机反转
- {
- AxisMovePosAccDec(X_AXIS,8000,-XY_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- // XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- if(XY_CTHL_PARAM_CR_MODE == 0)
- XY_CTHL_CXHT_VAVLE = 0;
- if(XY_CTHL_PARAM_XCDWZ_MODE)
- {
- if(!XY_CTHL_PARAM_XCDWGY_MODE)
- XY_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- }
- XY_CTHL_SQJD_Delay= dwTickCount + XY_CTHL_PARAM_TQJD_DELAY;
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- XY_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- XY_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_SCDWOff_CXDW_DELAY;
- }
-
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CXXY_Limit_ALARM,bRunning); //插销下移异常
-
- }
- }
- else
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
-
- XY_CTHL_AutoStep = 18;
- if( cXcxcrCnt==0 && !X_DRV && !cCXCONE) //拖带电机反转
- {
- AxisMovePosAccDec(X_AXIS,8000,-XY_CTHL_PARAM_TDFZ_LENTH,800,600,15,15,0);
- }
- // XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- if(XY_CTHL_PARAM_CR_MODE == 0)
- XY_CTHL_CXHT_VAVLE = 0;
-
- if(XY_CTHL_PARAM_XCDWZ_MODE)
- {
- if(!XY_CTHL_PARAM_XCDWGY_MODE)
- XY_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- }
- XY_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- XY_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_SCDWOff_CXDW_DELAY;
-
- }
-
- }
- }
- break;
- case 18:
-
- // if(START_IN_UP)
- {
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- XY_CTHL_AutoStep = 19;
-
- XY_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
- XY_CTHL_AutoDelay = dwTickCount + 500; //插销穿入到位异常时间
- XY_CTHL_CL_MotorStep = 50; //合链电机回原点
- }
- }
- }
- break;
- case 19:
- if((XY_CTHL_CX_Limit_IN || XY_CTHL_PARAM_XCDWGY_MODE) && (cXcxcrCnt<4 || XY_CTHL_PARAM_CXTHREE_MODE))
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- if(!XY_CTHL_PARAM_XCDWGY_MODE || XY_CTHL_PARAM_XCDWGY_MODE==1)
- {
- cXcxcrCnt=0;
- cXiaoChaCNT=0;
- user_datas[100]=0;
- XY_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- bZhuangLiaoOkFlg = 0;
- if(!XY_CTHL_PARAM_XCDWGY_MODE)
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀
- XY_CTHL_AutoStep = 901;
- if(XY_CTHL_PARAM_XCDWGY_MODE==1)
- XY_CTHL_bTFKGD_Delay = dwTickCount + XY_CTHL_PARAM_FKGD_DELAY+70; //退方块固定时间
- else
- XY_CTHL_bTFKGD_Delay = dwTickCount + XY_CTHL_PARAM_FKGD_DELAY; //退方块固定时间
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- }
- else if(XY_CTHL_PARAM_XCDWGY_MODE==2)
- {
- XY_CTHL_AutoStep = 901;
- XY_CTHL_bTFKGD_Delay = dwTickCount + XY_CTHL_PARAM_FKGD_DELAY; //退方块固定时间
-
- }
- }
- }
-
-
- else if ((dwTickCount >= XY_CTHL_AutoDelay) && (cXcxcrCnt<3) && !XY_CTHL_PARAM_CXTHREE_MODE)
- {
- cXcxcrCnt++;
- XY_CTHL_CXHJD_VAVLE=0;
- // XY_CTHL_FKJD_VAVLE=0;
- XY_CTHL_CXHDW_VAVLE=0;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- if(cXcxcrCnt<3)
- {
- // XY_CTHL_CXDWZ_VAVLE = 0;
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_AutoStep = 12;
- }
- }
- else if((dwTickCount >= (XY_CTHL_AutoDelay +1500)) && XY_CTHL_PARAM_CXTHREE_MODE && !XY_CTHL_CX_Limit_IN && !XY_CTHL_PARAM_XCDWGY_MODE )
- {
- cXiaoChaCNT=1;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- XY_CTHL_CXHJD_VAVLE =0;
-
- cBAOHUCNT=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- if(XY_CTHL_START_IN_UP)
- {
- XY_CTHL_SetAlarmCode(0,bRunning);
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_AutoStep = 12;
- cXiaoChaCNT=0;
- cBAOHUCNT=0;
- cXcxcrCnt=0;
- XY_CTHL_CXHJD_VAVLE=0;
- XY_CTHL_CXHDW_VAVLE=0;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- }
- }
-
- if(( cXcxcrCnt > 2) && !XY_CTHL_PARAM_CXTHREE_MODE)
- {
- cXiaoChaCNT=1;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- XY_CTHL_CXHJD_VAVLE =0;
- cBAOHUCNT=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- if(XY_CTHL_START_IN_UP)
- {
- XY_CTHL_SetAlarmCode(0,bRunning);
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_AutoStep = 12;
- XY_CTHL_CXHJD_VAVLE=0;
- cXiaoChaCNT=0;
- cBAOHUCNT=0;
- cXcxcrCnt=0;
- XY_CTHL_CXHDW_VAVLE=0;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- }
- }
-
- break;
- case 901:
- if(dwTickCount >= (XY_CTHL_bTFKGD_Delay-30))
- {
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀
- }
- if(dwTickCount >= XY_CTHL_bTFKGD_Delay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- if(XY_CTHL_PARAM_XCDWGY_MODE==2)
- {
- XY_CTHL_AutoDelay = dwTickCount + 1000;//插销穿入异常时间
- XY_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀
-
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- XY_CTHL_AutoStep = 902;
- }
- else
- {
- XY_CTHL_AutoStep = 20;
- if(!cBAOHUCNT)
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
- else
- {
- XY_CTHL_AutoDelay = dwTickCount + 1000;//手动插销保护时间
- cBAOHUCNT=0;
- }
- }
-
- }
-
- }
- break;
- case 902:
- if((XY_CTHL_CX_Limit_IN ) && (cXcxcrCnt<4 || XY_CTHL_PARAM_CXTHREE_MODE))
- {
- XY_CTHL_AutoStep = 20;
- cXcxcrCnt=0;
- cXiaoChaCNT=0;
- user_datas[100]=0;
- if(!cBAOHUCNT)
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
- else
- {
- XY_CTHL_AutoDelay = dwTickCount + 1000;//手动插销保护时间
- cBAOHUCNT=0;
- }
-
- }
- else if ((dwTickCount >= XY_CTHL_AutoDelay) && (cXcxcrCnt<3) && !XY_CTHL_PARAM_CXTHREE_MODE)
- {
- cXcxcrCnt++;
- XY_CTHL_CXHJD_VAVLE=0;
- // XY_CTHL_FKJD_VAVLE=0;
- XY_CTHL_CXHDW_VAVLE=0;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- if(cXcxcrCnt<3)
- {
- // XY_CTHL_CXDWZ_VAVLE = 0;
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_AutoStep = 12;
- }
- }
- else if((dwTickCount >= (XY_CTHL_AutoDelay +3000)) && XY_CTHL_PARAM_CXTHREE_MODE && !XY_CTHL_CX_Limit_IN )
- {
- cXiaoChaCNT=1;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- XY_CTHL_CXHJD_VAVLE =0;
-
- cBAOHUCNT=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- if(XY_CTHL_START_IN_UP)
- {
- XY_CTHL_SetAlarmCode(0,bRunning);
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_AutoStep = 12;
- cXiaoChaCNT=0;
- cBAOHUCNT=0;
- cXcxcrCnt=0;
- XY_CTHL_CXHJD_VAVLE=0;
- XY_CTHL_CXHDW_VAVLE=0;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- }
- }
-
- if(( cXcxcrCnt > 2) && !XY_CTHL_PARAM_CXTHREE_MODE)
- {
- cXiaoChaCNT=1;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- XY_CTHL_CXHJD_VAVLE =0;
- cBAOHUCNT=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_CX_Limit_ALARM ,bRunning);//插销穿入到位异常
- if(XY_CTHL_START_IN_UP)
- {
- XY_CTHL_SetAlarmCode(0,bRunning);
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_AutoStep = 12;
- XY_CTHL_CXHJD_VAVLE=0;
- cXiaoChaCNT=0;
- cBAOHUCNT=0;
- cXcxcrCnt=0;
- XY_CTHL_CXHDW_VAVLE=0;
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE=0;
- else
- XY_CTHL_CXXY_VAVLE=1;
-
- }
- }
-
-
- break;
- case 20:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 21;
- XY_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
-
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- }
-
- }
- break;
- case 21:
-
- if(!XY_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 22;
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_First_CL_Timer; //一次穿入时间
- }
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
- }
- break;
- case 22:
- if(dwTickCount >= XY_CTHL_bTFKGD_Delay)
- {
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- }
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 23;
- XY_CTHL_MGuo_VAVLE = 0; //码勾退
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_MGOff_XiaMo_DELAY;
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- XY_CTHL_FKJD_VAVLE=0;
- XY_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀关
- }
- }
- break;
- case 23:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 24;
- XY_CTHL_CTXM_VAVLE = 0; //穿头下模下降
-
- XY_CTHL_XiaJiangXM_VAVLE=1;
- XY_CTHL_bXiaMoSJ_Delay = dwTickCount +150;
-
-
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- }
- }
- break;
- case 24:
-
- if(!XY_CTHL_CTM_Limit_IN)
- {
-
- XY_CTHL_AutoStep = 25;
- XY_CTHL_AutoDelay = dwTickCount + 20; //一次穿入延时返回
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CTM_Origin_ALARM,bRunning);//穿头下模下降异常
- }
- break;
- case 25:
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
-
- }
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_AutoStep = 26;
- XY_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- XY_CTHL_AutoDelay = dwTickCount + 5;
-
- //退下出错警告
- XY_CTHL_AutoDelay1 = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- XY_CTHL_AutoStep1 = 1;
- }
-
- break;
- case 26:
- cONERROR=0;
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- XY_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
-
- }
- if(dwTickCount >= XY_CTHL_AutoDelay)
- {
- // XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
- if(!XY_CTHL_DANBU_MODE || XY_CTHL_START_IN_UP)
- {
- XY_CTHL_FKGD_VAVLE = 0; //方块固定关
- if(!cCXCONE)
- {
- XY_CTHL_AutoStep = 4;
- bCL_EN_FLG = 1;
-
- AddToTal(XY_CTHL_TOTAL_ADDR);
- AddToTal(XY_CTHL_TRUST_ALARM_ADDR );
- AddToTal( XY_CTHL_TEST_ALARM_ADDR);
- CalProSP(XY_CTHL_SPEED_ADDR);
- if(XY_CTHL_cZipCnt<3)
- XY_CTHL_cZipCnt++;
- }
- else
- {
- bRunning=0;
- cCXCONE=0;
- XY_CTHL_AutoStep = 0;
- }
- }
-
-
- }
- break;
-
- }
- }
- //退下模后启动送拉头
- switch(XY_CTHL_AutoStep1)
- {
- case 1:
- if(cStopMode==1 || bSingOneFlg)
- {
- // cStopMode=2;
- if(cStopGN)
- bCL_EN_FLG=0;
- else
- bCL_EN_FLG = 1;
- cZhouWanone=1;
- cZhouWantwo =1;
- cStopGN=0;
-
- }
- if(XY_CTHL_CTM_Origin_IN && XY_CTHL_First_CT_Origin_IN)
- {
- XY_CTHL_ZhuangLiaoStep = 1;
- XY_CTHL_TryCnt = 0;
- XY_CTHL_AutoStep1 = 0;
- XY_CTHL_MGuo_VAVLE = 0;
- XY_CTHL_JLTou_VAVLE = 0;
- }
- else if(dwTickCount >= XY_CTHL_AutoDelay1)
- {
- //穿头模和一次穿入回位异常
- if(!XY_CTHL_CTM_Origin_IN)
- XY_CTHL_SetAlarmCode(XY_CTHL_CTM_Origin_ALARM,bRunning);
- else if(!XY_CTHL_First_CT_Origin_IN)
- XY_CTHL_SetAlarmCode(XY_CTHL_First_CT_Origin_ALARM,bRunning);
- }
- break;
-
- }
-
- }
- void XY_CTHL_CheckStart(void)
- {
- if(cXCXQXQD)
- {
- if(XY_CTHL_START_IN_UP || bStart)
- {
- cONERROR=0;
- bStart=0;
- if(!bRunning)
- {
- if(XY_CTHL_SafeDoor_IN || !XY_CTHL_ANQUANMEN_MODE)
- {
- bRunning=1;
- cXCXQXQD =0;
- cStopGN=0;
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_AutoStep=11;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
- }
- }
-
-
- }
- if(cBanAuTo)
- {
- if(XY_CTHL_START_IN_UP || bStart)
- {
- cONERROR=0;
- bStart=0;
- if(XY_CTHL_SafeDoor_IN || !XY_CTHL_ANQUANMEN_MODE)
- {
- if(!bRunning)
- {
- bRunning=1;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- XY_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- cBanAuTo=0;
- cStopGN=0;
- XY_CTHL_PARAM_BanAuto_MODE=0;
- XY_CTHL_PARAM_ZDP_AUTO= 0;
- XY_CTHL_ZhuangLiaoStep = 1;
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg= 0;
-
-
-
-
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- XY_CTHL_AutoDelay = dwTickCount + 260; //锁轴时间
-
- }
-
- if(GetEn(X_AXIS) == MOTOR_DISEN)
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_AutoDelay = dwTickCount + 300; //步进电机锁轴时间
-
- }
- else //已经锁轴
- XY_CTHL_AutoDelay = dwTickCount + 5;
- XY_CTHL_AutoStep=10;
- }
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
-
- }
- }
- }
-
- if(cWULATOUCnt) // 无拉头警告后按
- {
- if(XY_CTHL_START_IN_UP | bStart)
- {
- cONERROR=0;
- bStart=0;
- if(!bRunning)
- {
- if(XY_CTHL_SafeDoor_IN || !XY_CTHL_ANQUANMEN_MODE)
- {
- bRunning=1;
- XY_CTHL_TryCnt=0;
- XY_CTHL_First_CT_VAVLE=0;
- cWULATOUCnt=0;
- cStopGN=0;
- XY_CTHL_ZhuangLiaoStep = 1;
- XY_CTHL_AutoStep=6;
- XY_CTHL_PARAM_ZDP_AUTO= 0;
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg= 0;
- XY_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
-
- }
- }
- }
- if(XY_CTHL_SafeDoor_IN_DW && bRunning && XY_CTHL_ANQUANMEN_MODE && !cBanAuTo && !cCXCONE)
- {
- bStop=1;
- cStopGN=1;
- bCL_EN_FLG=0;
- XY_CTHL_HLJJ_VAVLE=0;
- XY_CTHL_CL_MotorStep=0;
- AxisEgmStop(Y_AXIS);
- // XY_CTHL_SetAlarmCode(XY_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
-
- //启动 自动启动 单一自动
- if((XY_CTHL_START_IN_UP || bStart || XY_CTHL_bSingleone) && !cWULATOUCnt && !cBanAuTo && !cXCXQXQD)
- {
-
-
- if(cCHULIANBAOJIN) //无链停机启动
- {
- bRunning=1;
- cCHULIANBAOJIN=0;
- SetPos(X_AXIS, 0);
- // dwXRealPos=0;
- XY_CTHL_AutoStep = 11;
- XY_CTHL_TD_MotorStep=9;
-
- XY_CTHL_ColorStep=0;
- XY_CTHL_cZipCnt=0;
- cStopGN=0;
- if(GetAlarm(Y_AXIS)==0 || (GetAlarm(X_AXIS)==0 && !XY_CTHL_MotorChose_MODE))
- {
- SetClr(Y_AXIS, MOTOR_NOALARM);
- SetClr(X_AXIS, MOTOR_NOALARM);
- SetEn(X_AXIS, MOTOR_DISEN);
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 500;
- }
-
- XY_CTHL_TD_MotorDelay = dwTickCount + 200;
- XY_CTHL_AutoDelay = dwTickCount + 150;
-
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
-
- }
-
-
- if(!bRunning )
-
- {
- if(XY_CTHL_SafeDoor_IN || !XY_CTHL_ANQUANMEN_MODE)
- {
- if(XY_CTHL_bSingleone)
- {
- bSingOneFlg=1;
- }
- if(cStopMode>1)
- bCL_EN_FLG = 0;
- cStopMode=0;
- bRunning = 1;
- cSTOPLENGTH=0;
- cHeLian=0;
- cStopGN=0;
- // cONERROR=0;
- cCXCONE=0;
- // XY_CTHL_DANBU_MODE=0;
- cXiaoChaTest=0;
- cWULATOUCnt=0;
- XY_CTHL_SD_VAVLE=0;
- XY_CTHL_PARAM_BanAuto_MODE=0;
- SetEn(X_AXIS, MOTOR_EN);
- SetEn(Y_AXIS, MOTOR_EN);
- XY_CTHL_CL_MotorStep = 40;
- if(GetEn(X_AXIS) == MOTOR_DISEN)
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_AutoDelay = dwTickCount + 300; //步进电机锁轴时间
- }
- else //已经锁轴
- XY_CTHL_AutoDelay = dwTickCount + 5;
-
- XY_CTHL_AutoStep = 1;
- bTuiLaTouOkFlg = 1;
- XY_CTHL_PARAM_ZDP_AUTO= 0;
- bZhuangLiaoOkFlg= 0;
- XY_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- XY_CTHL_First_CT_VAVLE=0;
- XY_CTHL_cZipCnt = 0;
- cQDXK_DXK=0;
- XY_CTHL_LianLengthCheck = 0;
- cStopInCnt = 0;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_SafeDoor_ALARM,0); // 安全门关上才能启动
- }
-
- }
- cONERROR=0;
- bStart = 0;
- XY_CTHL_bSingleone=0;
- }
- if(cZhouWantwo)
- {
- cZhouWantwo=0;
- if(cZhouWanone)
- {
- bRunning=0;
- cZhouWanone=0;
- // cStopMode=0;
- bSingOneFlg=0;
- cXiaoChaTest=0;
- cXcxcrCnt=0;
- cStopGN=0;
- cCHULIANBAOJIN=0;
- cBanAuTo=0;
- cONERROR=0;
- XY_CTHL_cZipCnt=0;
- cBAOHUCNT=0;
- // bCL_EN_FLG = 0;
- cWULATOUCnt=0;
- AxisEgmStop(X_AXIS);
- if(XY_CTHL_SF_Origin_IN)
- {
- XY_CTHL_CL_MotorStep =0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- SetPos(X_AXIS, 0);
- dwYRealPos=0;
- SetEn(X_AXIS, MOTOR_DISEN);
- // XY_CTHL_AutoDelay = dwTickCount;
- XY_CTHL_AutoStep = 0;
-
- XY_CTHL_bCLFirst_Step=0;
- // XY_CTHL_ZhuangLiaoStep=0;
- // XY_CTHL_AutoDelay = dwTickCount;
- // XY_CTHL_XKTD_VAVLE = 0;
- cQDXK_DXK=0;
- // XY_CTHL_XKDW_VAVLE =0;
-
- if(!XY_CTHL_SF_ALR_IN )
- {
- XY_CTHL_SF_ALR_CLR=1;
-
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
-
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
- }
- }
- /*
- if(XY_CTHL_STOP_IN_UP || XY_CTHL_STOPone)
- {
- if(bRunning)
- {
- bRunning=0;
- XY_CTHL_AutoDelay = dwTickCount;
- cXcxcrCnt=0;
- if(cStopMode<3)
- cStopMode=0;
- cXCXQXQD=0;
- bSingOneFlg=0;
- bCL_EN_FLG = 0;
- cBAOHUCNT=0;
- cBanAuTo=0;
- cXiaoChaTest=0;
- cCHULIANBAOJIN=0;
- XY_CTHL_XiaJiangXM_VAVLE=1;
- cWULATOUCnt=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- SetEn(X_AXIS, MOTOR_DISEN);
- // SetEn(Y_AXIS, MOTOR_DISEN);
- cStopMode=0;
- cQDXK_DXK=0;
- if(!XY_CTHL_SF_ALR_IN )
- {
- XY_CTHL_SF_ALR_CLR=1;
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarm(Y_AXIS)==0)
- {
- SetClr(Y_AXIS, MOTOR_NOALARM);
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- XY_CTHL_TLiao_VAVLE=0;
- XY_CTHL_HSLiao_VAVLE =0;
- XY_CTHL_JLTou_VAVLE =0;
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_XKTD_VAVLE =0;
- XY_CTHL_XKDW_VAVLE =0;
- XY_CTHL_DXK_VAVLE =0;
- XY_CTHL_CXXY_VAVLE =0;
- XY_CTHL_CTXM_VAVLE =0;
- XY_CTHL_First_CT_VAVLE =0;
- XY_CTHL_FKGD_VAVLE =0;
- XY_CTHL_CXQJD_VAVLE =0;
- XY_CTHL_CXDWZ_VAVLE =0;
- XY_CTHL_CXHJD_VAVLE =0;
- XY_CTHL_CXHDW_VAVLE =0;
- XY_CTHL_FKJD_VAVLE =0;
- XY_CTHL_HLJJ_VAVLE =0;
- XY_CTHL_CXSCDW_VAVLE =0;
- XY_CTHL_DLP_VAVLE=0;
- if(XY_CTHL_CTM_Origin_IN || !XY_CTHL_CXSC_Limit_IN || (cBanAuTo && !XY_CTHL_CXSC_Limit_IN) || bRunning)
- XY_CTHL_MGuo_VAVLE =0;
- XY_CTHL_AutoDelay = dwTickCount;
- XY_CTHL_AutoStep = 0;
- XY_CTHL_ZhuangLiaoStep=0;
- XY_CTHL_TLiaoStep=0;
- XY_CTHL_TD_MotorStep=0;
- XY_CTHL_JiaLianStep =0;
- // XY_CTHL_ZhenDongStep =0;
- XY_CTHL_SongLiaoStep =0;
- XY_CTHL_ColorStep=0;
- XY_CTHL_CL_MotorStep =0;
- XY_CTHL_AutoStep1 =0;
- XY_CTHL_bFKCXTDDW_Step=0;
- XY_CTHL_bCXCR_Step=0;
- XY_CTHL_bCLFirst_Step=0;
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
-
- XY_CTHL_TLiaoStep = 0;
- XY_CTHL_AutoStep = 0;
-
-
- }
- else if(!bRunning)
- {
- bRunning=0;
- cXcxcrCnt=0;
- if(cStopMode<3)
- cStopMode=0;
- bSingOneFlg=0;
- bCL_EN_FLG = 0;
- cBanAuTo=0;
- cXCXQXQD=0;
- cXiaoChaTest=0;
- cBAOHUCNT=0;
- cCHULIANBAOJIN=0;
- cWULATOUCnt=0;
- cDLPONE=0;
-
-
- XY_CTHL_XiaJiangXM_VAVLE=1;
-
- XY_CTHL_AutoDelay = dwTickCount;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- cStopMode=0;
- cQDXK_DXK=0;
- if(!XY_CTHL_SF_ALR_IN )
- {
- XY_CTHL_SF_ALR_CLR=1;
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarm(Y_AXIS)==1)
- {
- SetClr(Y_AXIS, MOTOR_NOALARM);
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- XY_CTHL_TLiao_VAVLE=0;
- XY_CTHL_HSLiao_VAVLE =0;
- XY_CTHL_JLTou_VAVLE =0;
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_XKTD_VAVLE =0;
- XY_CTHL_XKDW_VAVLE =0;
- XY_CTHL_DXK_VAVLE =0;
- XY_CTHL_CXXY_VAVLE =0;
- XY_CTHL_CTXM_VAVLE =0;
- XY_CTHL_DLP_VAVLE=0;
- XY_CTHL_SD_VAVLE=0;
- XY_CTHL_First_CT_VAVLE =0;
- XY_CTHL_FKGD_VAVLE =0;
- XY_CTHL_CXQJD_VAVLE =0;
- XY_CTHL_CXDWZ_VAVLE =0;
- XY_CTHL_CXHJD_VAVLE =0;
- XY_CTHL_CXHDW_VAVLE =0;
- XY_CTHL_FKJD_VAVLE =0;
- XY_CTHL_HLJJ_VAVLE =0;
- XY_CTHL_CXSCDW_VAVLE =0;
- if(XY_CTHL_CTM_Origin_IN || !XY_CTHL_CXSC_Limit_IN || (cBanAuTo && !XY_CTHL_CXSC_Limit_IN) || bRunning)
- XY_CTHL_MGuo_VAVLE =0;
- XY_CTHL_AutoDelay = dwTickCount;
- XY_CTHL_ColorStep=0;
- XY_CTHL_AutoStep = 0;
- XY_CTHL_ZhuangLiaoStep=0;
- XY_CTHL_TLiaoStep=0;
- XY_CTHL_TD_MotorStep=0;
- XY_CTHL_JiaLianStep =0;
- // XY_CTHL_ZhenDongStep =0;
- XY_CTHL_SongLiaoStep =0;
- XY_CTHL_CL_MotorStep =0;
- XY_CTHL_AutoStep1 =0;
- XY_CTHL_bFKCXTDDW_Step=0;
- XY_CTHL_bCXCR_Step=0;
- XY_CTHL_bCLFirst_Step=0;
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
-
- XY_CTHL_TLiaoStep = 0;
- XY_CTHL_AutoStep = 0;
-
- //穿合链电机是往零点方向时可以停止
- if(GetDir(Y_AXIS) == DIR_N)
- AxisEgmStop(Y_AXIS);
-
- }
- XY_CTHL_STOPone=0;
- }
- */
- //停止
- if(XY_CTHL_STOP_IN_UP || bStop)
- {
- XY_CTHL_PARAM_BanAuto_MODE=0;
- if(cStopMode < 2)
- cStopMode++;
- if(cStopMode==1 && bRunning)
- cZhouWanone=1;
- if(bRunning && cStopMode==2)
- {
- bRunning=0;
- XY_CTHL_AutoDelay = dwTickCount;
- cXcxcrCnt=0;
- XY_CTHL_PARAM_BanAuto_MODE=0;
- if(cStopMode<3)
- cStopMode=0;
- cXCXQXQD=0;
- bSingOneFlg=0;
- bCL_EN_FLG = 0;
- cBAOHUCNT=0;
- cONERROR=0;
- cBanAuTo=0;
- XY_CTHL_DANBU_MODE=0;
- cXiaoChaTest=0;
- cCHULIANBAOJIN=0;
- XY_CTHL_XiaJiangXM_VAVLE=1;
- cWULATOUCnt=0;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- SetEn(X_AXIS, MOTOR_DISEN);
- // SetEn(Y_AXIS, MOTOR_DISEN);
- cStopMode=0;
- cQDXK_DXK=0;
- if(!XY_CTHL_SF_ALR_IN )
- {
- XY_CTHL_SF_ALR_CLR=1;
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarm(Y_AXIS)==0 || (GetAlarm(X_AXIS)==0 && !XY_CTHL_MotorChose_MODE))
- {
- SetClr(Y_AXIS, MOTOR_NOALARM);
- SetClr(X_AXIS, MOTOR_NOALARM);
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- XY_CTHL_TLiao_VAVLE=0;
- XY_CTHL_HSLiao_VAVLE =0;
- XY_CTHL_JLTou_VAVLE =0;
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_XKTD_VAVLE =0;
- XY_CTHL_XKDW_VAVLE =0;
- XY_CTHL_DXK_VAVLE =0;
- XY_CTHL_CXXY_VAVLE =0;
- XY_CTHL_MGuo_VAVLE =0;
- XY_CTHL_CTXM_VAVLE =0;
- XY_CTHL_First_CT_VAVLE =0;
- XY_CTHL_FKGD_VAVLE =0;
- XY_CTHL_CXQJD_VAVLE =0;
- XY_CTHL_CXDWZ_VAVLE =0;
- XY_CTHL_CXHJD_VAVLE =0;
- XY_CTHL_CXHDW_VAVLE =0;
- XY_CTHL_FKJD_VAVLE =0;
- XY_CTHL_HLJJ_VAVLE =0;
- XY_CTHL_CXSCDW_VAVLE =0;
- XY_CTHL_DLP_VAVLE=0;
- if(XY_CTHL_CTM_Origin_IN || !XY_CTHL_CXSC_Limit_IN || (cBanAuTo && !XY_CTHL_CXSC_Limit_IN) || bRunning)
- XY_CTHL_MGuo_VAVLE =0;
- XY_CTHL_AutoDelay = dwTickCount;
- XY_CTHL_AutoStep = 0;
- XY_CTHL_ZhuangLiaoStep=0;
- XY_CTHL_TLiaoStep=0;
- XY_CTHL_TD_MotorStep=0;
- XY_CTHL_JiaLianStep =0;
- // XY_CTHL_ZhenDongStep =0;
- XY_CTHL_SongLiaoStep =0;
- XY_CTHL_ColorStep=0;
- XY_CTHL_CL_MotorStep =0;
- XY_CTHL_AutoStep1 =0;
- XY_CTHL_bFKCXTDDW_Step=0;
- XY_CTHL_bCXCR_Step=0;
- XY_CTHL_bCLFirst_Step=0;
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
-
- XY_CTHL_TLiaoStep = 0;
- XY_CTHL_AutoStep = 0;
-
-
- }
- else if(!bRunning)
- {
- bRunning=0;
- cXcxcrCnt=0;
- if(cStopMode<3)
- cStopMode=0;
- bSingOneFlg=0;
- bCL_EN_FLG = 0;
- cBanAuTo=0;
- cSTOPLENGTH=0;
- if(!XY_CTHL_PARAM_ShiJue)
- {
- XY_CTHL_JIANCHE_VAVLE=0;
- XY_CTHL_XIANZHI_VAVLE=0;
- XY_CTHL_DINGCHU_VAVLE=0;
- }
- cXCXQXQD=0;
- cONERROR=0;
- cXiaoChaTest=0;
- cBAOHUCNT=0;
- cCHULIANBAOJIN=0;
- cWULATOUCnt=0;
- cDLPONE=0;
- cCXCONE=0;
- XY_CTHL_DANBU_MODE=0;
-
- XY_CTHL_PARAM_BanAuto_MODE=0;
- XY_CTHL_XiaJiangXM_VAVLE=1;
-
- XY_CTHL_AutoDelay = dwTickCount;
- AxisEgmStop(X_AXIS);
- AxisEgmStop(Y_AXIS);
- SetEn(X_AXIS, MOTOR_DISEN);
- SetEn(Y_AXIS, MOTOR_DISEN);
- cStopMode=0;
- cQDXK_DXK=0;
- if(!XY_CTHL_SF_ALR_IN )
- {
- XY_CTHL_SF_ALR_CLR=1;
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- if(GetAlarm(Y_AXIS)==0 || (GetAlarm(X_AXIS)==0 && !XY_CTHL_MotorChose_MODE))
- {
- SetClr(Y_AXIS, MOTOR_NOALARM);
- SetClr(X_AXIS, MOTOR_NOALARM);
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 2000;
- }
- XY_CTHL_TLiao_VAVLE=0;
- XY_CTHL_HSLiao_VAVLE =0;
- XY_CTHL_JLTou_VAVLE =0;
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_XKTD_VAVLE =0;
- XY_CTHL_XKDW_VAVLE =0;
- XY_CTHL_DXK_VAVLE =0;
- XY_CTHL_CXXY_VAVLE =0;
- XY_CTHL_CTXM_VAVLE =0;
- XY_CTHL_DLP_VAVLE=0;
- XY_CTHL_First_CT_VAVLE =0;
- XY_CTHL_FKGD_VAVLE =0;
- XY_CTHL_CXQJD_VAVLE =0;
- XY_CTHL_CXDWZ_VAVLE =0;
- XY_CTHL_CXHJD_VAVLE =0;
- XY_CTHL_CXHDW_VAVLE =0;
- XY_CTHL_FKJD_VAVLE =0;
- XY_CTHL_HLJJ_VAVLE =0;
- XY_CTHL_CXSCDW_VAVLE =0;
- if(XY_CTHL_CTM_Origin_IN || !XY_CTHL_CXSC_Limit_IN || (cBanAuTo && !XY_CTHL_CXSC_Limit_IN) || bRunning)
- XY_CTHL_MGuo_VAVLE =0;
- XY_CTHL_AutoDelay = dwTickCount;
- XY_CTHL_ColorStep=0;
- XY_CTHL_AutoStep = 0;
- XY_CTHL_ZhuangLiaoStep=0;
- XY_CTHL_TLiaoStep=0;
- XY_CTHL_TD_MotorStep=0;
- XY_CTHL_JiaLianStep =0;
- // XY_CTHL_ZhenDongStep =0;
- XY_CTHL_SongLiaoStep =0;
- XY_CTHL_CL_MotorStep =0;
- XY_CTHL_AutoStep1 =0;
- XY_CTHL_bFKCXTDDW_Step=0;
- XY_CTHL_bCXCR_Step=0;
- XY_CTHL_bCLFirst_Step=0;
- if(GetAlarmCode(XY_CTHL_ALARM_ADDR) != 0)
- SetAlarmCode(XY_CTHL_ALARM_ADDR,0);
- SetPos(X_AXIS, 0);
-
- XY_CTHL_TLiaoStep = 0;
- XY_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);
- XY_CTHL_AutoStep = 0;
- XY_CTHL_CL_MotorStep =0;
- XY_CTHL_bCLFirst_Step=0;
- // XY_CTHL_SongLiaoStep =0;
- // XY_CTHL_ZhuangLiaoStep=0;
- // XY_CTHL_TLiaoStep=0;
- // XY_CTHL_TD_MotorStep=0;
- XY_CTHL_JiaLianStep =0;
- XY_CTHL_AutoStep1 =0;
-
-
- }
- }
- //拖带电机控制动作 X轴
- void XY_CTHL_TD_Motor(void) //
- {
- #if 1
- switch(XY_CTHL_TD_MotorStep)
- {
- //1步开始,纯定位, 没有穿入
- case 1:
- if(dwTickCount >= XY_CTHL_TD_MotorDelay) //给锁轴时间
- {
- bCheckEN_FLG = 1;
- XY_CTHL_SD_VAVLE=0;
- XY_CTHL_X_CXPosBuff=0;
- XY_CTHL_CheckInX02PosBuff= 0;
- XY_CTHL_TD_MotorStep = 2;
- SetPos(X_AXIS, 0); //启动位置设为0点
- AxisContinueMoveAcc(X_AXIS,XY_CTHL_PARAM_first_SPEED,DIR_P,3000,2000,50,80);
- }
- if(XY_CTHL_CXSC_Limit_IN_UP )
- {
-
- XY_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
- break;
- case 2://检测到过链
-
-
- if(dwXRealPos > 350) //穿入2CM后退
- {
- XY_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- XY_CTHL_QDXK_VAVLE=0;
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
-
- }
- if(dwXRealPos >= XY_CTHL_PARAM_DYTLL_LENTH)
- {
- if(bRunning)
- {
- cCHULIANBAOJIN=1;
- SetEn(X_AXIS, MOTOR_DISEN);
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0); //启动位置设为0点
- // dwXRealPos=0;
- }
- SetEn(X_AXIS, MOTOR_DISEN);
- XY_CTHL_SetAlarmCode(XY_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- }
- if(XY_CTHL_FK_Check_UP)
- {
- XY_CTHL_SD_VAVLE=1;
- XY_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- XY_CTHL_QDXK_VAVLE=0;
- XY_CTHL_TD_MotorStep = 3;
- // XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
- // XY_CTHL_TD_MotorStep = 3;
- // user_datas[123] = dwXRealPos - XY_CTHL_CheckInX02PosBuff;
- if((dwXRealPos >= XY_CTHL_CheckInX02PosBuff) && XY_CTHL_CheckInX02PosBuff)
- AxisMovePosAccDec(X_AXIS,XY_CTHL_GYHKSD_SPEED,XY_CTHL_PARAM_first_LENGTH,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,300,XY_CTHL_StopSlow_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,XY_CTHL_GYHKSD_SPEED,XY_CTHL_PARAM_first_LENGTH,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,300,XY_CTHL_StopSlow_LENGTH);
- }
- else if(XY_CTHL_CXSC_Limit_IN_DW && !XY_CTHL_PARAM_XCGY_MODE)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_FKGYYC_Limit_ALARM,bRunning);
- }
- else if(XY_CTHL_CXSC_Limit_IN_UP && !XY_CTHL_PARAM_XCGY_MODE)
- {
- AxisMovePosAccDec(X_AXIS,XY_CTHL_PARAM_first_SPEED * 7/10,XY_CTHL_PARAM_FKDW_Length,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,10,150,XY_CTHL_StopSlow_LENGTH);
- }
- if(XY_CTHL_FK_Check_DW)
- {
-
- XY_CTHL_XSavePosBuff = dwXRealPos;
- XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
-
- }
- if(XY_CTHL_CXSC_Limit_IN_UP )
- {
-
- XY_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
- break;
- case 3:
-
- if(XY_CTHL_FK_Check_DW)
- {
-
- XY_CTHL_XSavePosBuff = dwXRealPos;
- XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
-
- }
- if(XY_CTHL_CXSC_Limit_IN_UP )
- {
-
- XY_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
-
- if(!X_DRV)// || (dwXRealPos >= (XY_CTHL_XSavePosBuff + XY_CTHL_PARAM_FKDW_Length)))
- {
- AxisEgmStop(X_AXIS);
- if(!bRunning)
- XY_CTHL_FKJD_VAVLE = 0; //方块夹带气缸输出
- XY_CTHL_TD_MotorStep =4 ;
- // user_datas[122] = dwXRealPos-XY_CTHL_XSavePosBuff;
- XY_CTHL_LianLengthAutoCheckOLD = XY_CTHL_LianLengthAutoCheck;
- XY_CTHL_LianLengthAutoCheck = dwXRealPos;
- }
- break;
- case 4:
- if(XY_CTHL_PARAM_XCX_LENTH) //0的话不判断位置
- {
-
- if ((dwXRealPos - XY_CTHL_X_CXPosBuff) > (XY_CTHL_PARAM_XCX_LENTH + XY_CTHL_PARAM_XCXWC_LENTH))
- {
- user_datas[121] = 1;
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_SetAlarmCode(XY_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
-
- else if(XY_CTHL_X_CXPosBuff == 0)
- {
- user_datas[121] = 3;
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_SetAlarmCode(XY_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else
- {
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_X_CXPosBuff=dwXRealPos;
-
- }
-
- }
- else
- {
- XY_CTHL_TD_MotorStep = 0;
- // XY_CTHL_X_CXPosBuff=dwXRealPos;
- }
- break;
- case 9:
- if(dwTickCount >= XY_CTHL_TD_MotorDelay)
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_TD_MotorStep = 10;
- XY_CTHL_TD_MotorDelay=dwTickCount+500;
-
- }
- break;
- //穿拉头定位
- case 10:
- if(dwTickCount >= XY_CTHL_TD_MotorDelay)
- {
-
- SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
- XY_CTHL_SD_VAVLE=0;
- XY_CTHL_TD_MotorStep = 11;
- XY_CTHL_X_CXPosBuff=0;
- AxisContinueMoveAcc(X_AXIS,XY_CTHL_XCCR_SPEED,DIR_P,1200,1200,15,15);
- XY_CTHL_CheckInX02PosBuff= 0;
- bCheckEN_FLG = 1;
- }
- break;
- case 11:
- ctwoone=0;
- if(dwXRealPos > 350) //穿入2CM后退
- {
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
- XY_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- // XY_CTHL_QDXK_VAVLE =0;
- }
- if(dwXRealPos > 350) //穿入2CM后退
- {
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
- XY_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- XY_CTHL_QDXK_VAVLE =0;
- }
- if(dwXRealPos > XY_CTHL_XCCR_LENGTH) //穿入2CM后退
- {
- XY_CTHL_CheckInX02PosBuff= 0;
-
-
-
- XY_CTHL_TD_MotorStep = 12;
- if(((XY_CTHL_cZipCnt < 2) || (XY_CTHL_LianLengthCheck < XY_CTHL_XCCR_LENGTH)) || XY_CTHL_DANBU_MODE)
- AxisContinueMoveAcc(X_AXIS,XY_CTHL_PARAM_first_SPEED,DIR_P,3000,600,20,50);
- else ////两段速度移动距离
- AxisMovePosAccDecNotStop(X_AXIS,XY_CTHL_PARAM_TD_RunSpeed,XY_CTHL_LianLengthCheck-XY_CTHL_XCCR_LENGTH,1500,7000,25,300,250);
-
- }
- if(XY_CTHL_CXSC_Limit_IN_UP)
- {
-
- XY_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
- break;
- case 12://检测到过链
- if(dwXRealPos > 350) //穿入2CM后退
- {
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
- XY_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- // XY_CTHL_QDXK_VAVLE =0;
- }
- if(dwXRealPos > 350) //穿入2CM后退
- {
- if(XY_CTHL_PARAM_NLSL_MODE)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
- XY_CTHL_DXK_VAVLE = 0; //顶斜口气缸关
- XY_CTHL_QDXK_VAVLE =0;
- }
- if(XY_CTHL_PARAM_SD_MODE)
- {
- if(XY_CTHL_cZipCnt>1)
- {
- if(dwXRealPos> XY_CTHL_LianLengthCheck-XY_CTHL_PARAM_SD_LENGTH)
- XY_CTHL_SD_VAVLE=1;
- }
- }
- if(XY_CTHL_cZipCnt>1)
- {
- if(dwXRealPos >= (XY_CTHL_PARAM_WLCDSHEZHI_LENTH+ XY_CTHL_LianLengthAutoCheckERROR))
- {
- if(bRunning)
- {
- cCHULIANBAOJIN=1;
- SetEn(X_AXIS, MOTOR_DISEN);
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0); //启动位置设为0点
- // dwXRealPos=0;
- }
- XY_CTHL_SetAlarmCode(XY_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- SetEn(X_AXIS, MOTOR_DISEN);
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_AutoStep=0;
- }
- }
- else if(XY_CTHL_cZipCnt < 2 )
- {
-
- if(dwXRealPos >= XY_CTHL_PARAM_DYTLL_LENTH)
- {
- if(bRunning)
- {
- cCHULIANBAOJIN=1;
- SetEn(X_AXIS, MOTOR_DISEN);
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0); //启动位置设为0点
- // dwXRealPos=0;
- }
- XY_CTHL_SetAlarmCode(XY_CTHL_WLZDTJ_ALARM,bRunning); //无拉链自动停机
- SetEn(X_AXIS, MOTOR_DISEN);
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_AutoStep=0;
- }
- }
-
-
- if(XY_CTHL_FK_Check_UP)
- {
- XY_CTHL_SD_VAVLE=1;
- XY_CTHL_TD_MotorDelay= dwTickCount + XY_CTHL_PARAM_FKJDSECONG_DEALY;
- if( dwXRealPos<(XY_CTHL_LianLengthCheck*0.8) && XY_CTHL_cZipCnt > 1)
- {
- cSTOPLENGTH=1;
- XY_CTHL_cZipCnt=0;
- }
- if(XY_CTHL_cZipCnt == 1)
- XY_CTHL_LianLengthCheck = dwXRealPos;
-
-
-
-
- //变短重新量尺寸
- XY_CTHL_LianLengthCheckOLD=XY_CTHL_LianLengthNEWCheck;
- XY_CTHL_LianLengthNEWCheck = dwXRealPos;
- // XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
- //break;
- XY_CTHL_XSavePosBuff = dwXRealPos;
- XY_CTHL_TD_MotorStep = 13;
- // user_datas[122] = XY_CTHL_PARAM_FKDW_Length - (dwXRealPos- XY_CTHL_CheckInX02PosBuff);
- if(!cSTOPLENGTH || !XY_CTHL_MotorChose_MODE)
- {
- if(XY_CTHL_cZipCnt > 1 && !XY_CTHL_DANBU_MODE)
- {
- if((dwXRealPos >= XY_CTHL_CheckInX02PosBuff) && XY_CTHL_CheckInX02PosBuff)
- AxisMovePosAccDec(X_AXIS,XY_CTHL_GYHKSD_SPEED,XY_CTHL_PARAM_FKDW_Length- (dwXRealPos- XY_CTHL_CheckInX02PosBuff),
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,250,XY_CTHL_StopSlow_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,XY_CTHL_GYHKSD_SPEED,XY_CTHL_PARAM_FKDW_Length,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,250,XY_CTHL_StopSlow_LENGTH);
- }
- else
- {
- AxisMovePosAccDec(X_AXIS, XY_CTHL_GYHKSD_SPEED, XY_CTHL_PARAM_first_LENGTH,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,250,XY_CTHL_StopSlow_LENGTH);
-
- }
- }
- else if(cSTOPLENGTH && XY_CTHL_MotorChose_MODE)
- {
- AxisMovePosAccDec(X_AXIS, XY_CTHL_GYHKSD_SPEED*7/10, XY_CTHL_PARAM_first_LENGTH-XY_CTHL_PARAM_STOP_length,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,250,XY_CTHL_StopSlow_LENGTH);
- XY_CTHL_cZipCnt=0;
- cSTOPLENGTH=0;
- }
-
- //XY_CTHL_TD_MotorStep = 0;
- }
- else if(XY_CTHL_CXSC_Limit_IN_DW && !XY_CTHL_PARAM_XCGY_MODE)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_FKGYYC_Limit_ALARM,bRunning);
- SetEn(X_AXIS, MOTOR_DISEN);
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_AutoStep=0;
- }
- else if(XY_CTHL_CXSC_Limit_IN_UP && !XY_CTHL_PARAM_XCGY_MODE)
- {
-
- AxisMovePosAccDec(X_AXIS,XY_CTHL_GYHKSD_SPEED,XY_CTHL_PARAM_first_LENGTH,
- XY_CTHL_PARAM_FKDW_Speed,XY_CTHL_PARAM_FKDW_Speed,20,300,XY_CTHL_StopSlow_LENGTH);
- ctwoone=1;
- }
- if(ctwoone)
- {
- if(!X_DRV)
- {
-
- XY_CTHL_SetAlarmCode(XY_CTHL_FKGYYC_Limit_ALARM,bRunning);
- SetEn(X_AXIS, MOTOR_DISEN);
- XY_CTHL_TD_MotorStep = 0;
- XY_CTHL_AutoStep=0;
- ctwoone=0;
- }
- }
- if(XY_CTHL_FK_Check_DW)
- {
- // XY_CTHL_XSavePosBuff = dwXRealPos;
- XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
-
- }
- if(XY_CTHL_CXSC_Limit_IN_UP)
- {
-
- XY_CTHL_X_CXPosBuff = dwXRealPos;
-
- }
- if(XY_CTHL_CXSC_Limit_IN_DW)
- {
- cXCGYcheck=1;
- XY_CTHL_LianLengthXC_Check=dwXRealPos;
- // SetPos(Y_AXIS, 0); //启动位置设为0点
- }
- break;
- case 13:
- if(XY_CTHL_CXSC_Limit_IN_DW)
- {
- cXCGYcheck=1;
- XY_CTHL_LianLengthXC_Check=dwXRealPos;
- // SetPos(Y_AXIS, 0); //启动位置设为0点
- }
-
- if(XY_CTHL_PARAM_TQXCGZ_LENGTH)
- {
- if(dwXRealPos>=XY_CTHL_LianLengthNEWCheck+XY_CTHL_PARAM_TQXCGZ_LENGTH)
- {
- XY_CTHL_CXSCDW_VAVLE=1;
- }
- }
- if(dwTickCount >= XY_CTHL_TD_MotorDelay)
- {
- XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
- }
-
- if(XY_CTHL_CXSC_Limit_IN_UP)
- {
-
- XY_CTHL_X_CXPosBuff = dwXRealPos;
- user_datas[121] = dwXRealPos;
-
- }
-
- if((!X_DRV ) || (dwXRealPos >= (XY_CTHL_XSavePosBuff + XY_CTHL_PARAM_FKDW_Length) && (XY_CTHL_cZipCnt > 1)) || (dwXRealPos >= (XY_CTHL_XSavePosBuff + XY_CTHL_PARAM_first_LENGTH) && (XY_CTHL_cZipCnt < 2)))
- {
- // user_datas[123] = dwXRealPos-XY_CTHL_CheckInX02PosBuff;
- XY_CTHL_LianLengthBCLENGTH_Check=dwXRealPos-XY_CTHL_LianLengthXC_Check;
-
- AxisEgmStop(X_AXIS);
- XY_CTHL_QDXK_VAVLE =0;
- XY_CTHL_TD_MotorStep = 14;
- /* if(XY_CTHL_cZipCnt>2)
- {
- if(((XY_CTHL_LianLengthNEWCheck+XY_CTHL_LianLengthCheckOLD)*0.5) < (XY_CTHL_LianLengthCheck*0.95))
- {
- XY_CTHL_cZipCnt=0;
- cHeLian=1;
- }
- } */
-
- XY_CTHL_CXSCDW_VAVLE=1;
-
- user_datas[122] = dwXRealPos-XY_CTHL_X_CXPosBuff;
- if(XY_CTHL_cZipCnt==1)
- XY_CTHL_LianLengthAutoCheckERROR = dwXRealPos;
- XY_CTHL_LianLengthAutoCheckOLD = XY_CTHL_LianLengthAutoCheck;
- XY_CTHL_LianLengthAutoCheck = dwXRealPos;
- if(XY_CTHL_cZipCnt==1 )
- XY_CTHL_LianLengSave=dwXRealPos;
- }
- break;
- case 14:
- if(XY_CTHL_PARAM_XCX_LENTH) //0的话不判断位置
- {
-
- if ((dwXRealPos - XY_CTHL_X_CXPosBuff) > (XY_CTHL_PARAM_XCX_LENTH + XY_CTHL_PARAM_XCXWC_LENTH))
- {
- // user_datas[121] = 1;
- XY_CTHL_TD_MotorStep = 0;
- cXCXQXQD=1;
- XY_CTHL_CXQJD_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
-
- }
- else if((dwXRealPos - XY_CTHL_X_CXPosBuff) < (XY_CTHL_PARAM_XCX_LENTH - XY_CTHL_PARAM_XCXWC_LENTH))
- {
- // user_datas[121] = 2;
- XY_CTHL_TD_MotorStep = 0;
- cXCXQXQD=1;
- XY_CTHL_CXQJD_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else if(XY_CTHL_X_CXPosBuff == 0)
- {
- // user_datas[121] = 3;
- XY_CTHL_TD_MotorStep = 0;
- cXCXQXQD=1;
- XY_CTHL_CXQJD_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_XCXXCYC_ALARM,bRunning); // 小插销行程异常
- }
- else
- {
-
- XY_CTHL_TD_MotorStep = 0;
- }
-
- }
- else
- {
-
- XY_CTHL_TD_MotorStep = 0;
- }
- break;
-
-
-
- }
- #endif
- }
- //穿入电机动作,Y轴
- void XY_CTHL_CL_Motor(void) //
- {
- #if 1
- //1步开始, 穿链长度开始
- //20步开始 插销定位开始
- //40步,回原点为
- switch(XY_CTHL_CL_MotorStep)
- {
- //穿入长度位置
- case 1:
-
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- if(XY_CTHL_SF_Origin_IN)
- {
- // if(!cHeLian)
- // {
- if(!XY_CTHL_PARAM_AUTO_MODE)
- {
- //穿入长度要根据检测长度减动一次穿入的3CM,反转的2CM
- if(XY_CTHL_LianLengthAutoCheck <=700)
- {
- XY_CTHL_Y_CL_Length=XY_CTHL_LianLengthAutoCheck-500;
- if(XY_CTHL_Y_CL_Length<=0)
- XY_CTHL_Y_CL_Length=200;
- if(XY_CTHL_Y_CL_Length >= XY_CTHL_PARAM_CL_MAX_Length)
- XY_CTHL_Y_CL_Length = XY_CTHL_PARAM_CL_MAX_Length-40;
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_CL_Speed,XY_CTHL_Y_CL_Length,2000,2000,50,50,50);
- }
- else if(XY_CTHL_LianLengthAutoCheck>700)
- {
-
- user_datas[123] =XY_CTHL_LianLengthAutoCheck;
- if(XY_CTHL_cZipCnt<2)
- XY_CTHL_Y_CL_Length=XY_CTHL_LianLengthAutoCheck-XY_CTHL_PARAM_HLTSY_LENTH;
- else
- XY_CTHL_Y_CL_Length=XY_CTHL_LianLengSave-XY_CTHL_PARAM_HLTSY_LENTH;
- if(XY_CTHL_Y_CL_Length<=0)
- XY_CTHL_Y_CL_Length=300;
- if(XY_CTHL_Y_CL_Length >= XY_CTHL_PARAM_CL_MAX_Length)
- XY_CTHL_Y_CL_Length = XY_CTHL_PARAM_CL_MAX_Length-40;
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_CL_Speed,XY_CTHL_Y_CL_Length,2000,2000,50,50,50);
- }
-
- /* else
- {
- XY_CTHL_Y_CL_Length=XY_CTHL_LianLengthAutoCheck-XY_CTHL_PARAM_HLTSY_LENTH -500;
- cHeLian=0;
- if(XY_CTHL_Y_CL_Length<0)
- XY_CTHL_Y_CL_Length=200;
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_CL_Speed,XY_CTHL_Y_CL_Length,2000,2000,50,50,50);
-
- }*/
-
- }
- else
- {
-
- if(XY_CTHL_PARAM_CL_Length >= XY_CTHL_PARAM_CL_MAX_Length)
- XY_CTHL_PARAM_CL_Length = XY_CTHL_PARAM_CL_MAX_Length;
- //穿入长度要根据检测长度减动一次穿入的1CM,反转的2CM
- if((XY_CTHL_LianLengthAutoCheck < (XY_CTHL_PARAM_CL_Length + 500 )) && bRunning)
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_CL_Speed,(XY_CTHL_LianLengthAutoCheck-500),800,600,6,6,50);
- else
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_CL_Speed,(XY_CTHL_PARAM_CL_Length-100),800,600,6,6,50);
-
-
-
- }
- XY_CTHL_CL_MotorStep = 2;
- cHeLianone=0;
- }
- }
- break;
- case 2:
- if(XY_CTHL_cZipCnt>0 || bCL_OK_FLG)
- {
- if(dwYRealPos>700)
- {
- if(!cHeLianone )
- {
- XY_CTHL_XKTD_VAVLE=0;//斜口推带退
- cHeLianone=1;
- }
-
- }
-
- if(XY_CTHL_LianLengSave<3000)
- {
- if(dwYRealPos>100)
- {
- if(!cHeLianone )
- {
- XY_CTHL_XKTD_VAVLE=0;//斜口推带退
- cHeLianone=1;
- }
-
- }
- }
- }
- if(cStopGN)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
-
- if(XY_CTHL_PARAM_AUTO_MODE)
- {
- if((dwYRealPos + 120) > XY_CTHL_PARAM_CL_Length)
- XY_CTHL_HLJJ_VAVLE = 0;
- if(!Y_DRV || dwYRealPos >= XY_CTHL_PARAM_CL_Length)
- {
- XY_CTHL_HLJJ_VAVLE = 0;
- XY_CTHL_CL_MotorStep = 3;
- bCL_OK_FLG = 1;
- XY_CTHL_CL_MotorDelay = dwTickCount + 30; //延时数控回零点
- }
- }
- else
- {
- if((dwYRealPos + 120) > XY_CTHL_Y_CL_Length)
- XY_CTHL_HLJJ_VAVLE = 0;
- if(!Y_DRV || dwYRealPos >= XY_CTHL_Y_CL_Length)
- {
- XY_CTHL_HLJJ_VAVLE = 0;
- XY_CTHL_CL_MotorStep = 3;
- bCL_OK_FLG = 1;
- XY_CTHL_CL_MotorDelay = dwTickCount + 30; //延时数控回零点
- }
-
- }
- break;
- case 3:
- if(cStopGN)
- {
- XY_CTHL_XKTD_VAVLE=0;
- }
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
-
- XY_CTHL_CL_MotorStep = 50;
- // SetDir(Y_AXIS, DIR_N);
- }
- break;
- case 10:
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- XY_CTHL_CL_MotorStep = 11;
- bCL_OK_FLG = 1;
- XY_CTHL_HLJJ_VAVLE = 0;
- XY_CTHL_HL_VAVLE = 0;
- }
- break;
- case 11:
- XY_CTHL_CL_MotorStep = 0;
- break;
- //夹带插销到穿入位置
- case 20: //此处最好算好定位长度相减
- if(!XY_CTHL_PARAM_XCXJY_MODE)
- {
- if(XY_CTHL_PARAM_CR_MODE != 0)
- {
- if(cXcxcrCnt > 0)
- {
- if(cXcxcrCnt==1)
- XY_CTHL_LENTH = XY_CTHL_PARAM_CXDW_Length+XY_CTHL_PARAM_TDFZ_LENTH + 50;
- if(cXcxcrCnt>1)
- XY_CTHL_LENTH = XY_CTHL_PARAM_CXDW_Length +XY_CTHL_PARAM_TDFZ_LENTH + 120;
- XY_CTHL_CL_MotorStep = 21;
- }
- else
- {
- XY_CTHL_LENTH = XY_CTHL_PARAM_CXDW_Length ;
- XY_CTHL_CL_MotorStep = 21;
- }
- }
- else
- {
- XY_CTHL_CL_MotorStep = 21;
- }
- }
- else
- {
- XY_CTHL_LianLengthERROR_Check=dwYRealPos;
- AxisContinueMoveAcc(Y_AXIS,XY_CTHL_PARAM_LXC_SPEED,DIR_P,1200,1200,20,30);
- XY_CTHL_CL_MotorStep = 21;
-
-
- }
- break;
- case 21:
-
-
- if(!XY_CTHL_PARAM_XCXJY_MODE)
- {
- if(cXiaoChaTest)
- {
- if(XY_CTHL_PARAM_CR_MODE != 0)
- {
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- XY_CTHL_CL_MotorDelay = dwTickCount + 2000; //延时数控回零点
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_LXC_SPEED,XY_CTHL_LENTH,800,500,6,6,50);
- XY_CTHL_CL_MotorStep = 22;
- }
- else
- {
-
- XY_CTHL_CXHT_VAVLE = 1;
- XY_CTHL_CL_MotorDelay = dwTickCount +2000;
- XY_CTHL_CL_MotorStep = 22;
- }
- }
- }
- else
- {
- if(XY_CTHL_PARAM_CR_MODE != 0)
- {
- AxisMovePosAccDec(Y_AXIS,XY_CTHL_PARAM_LXC_SPEED,XY_CTHL_LENTH,800,500,6,6,50);
- XY_CTHL_CL_MotorStep = 22;
- }
- else
- {
- XY_CTHL_CXHT_VAVLE = 1;
- XY_CTHL_CL_MotorDelay = dwTickCount + 500;//XY_CTHL_PARAM_XXHT_Time;
- XY_CTHL_CL_MotorStep = 22;
-
- }
- }
- }
- else
- {
-
- if(cXCGYcheck)
- {
- XY_CTHL_LENTH=XY_CTHL_PARAM_CXDW_Length - XY_CTHL_LianLengthBCLENGTH_Check;
- if(0<XY_CTHL_LENTH)
- XY_CTHL_LENTH=100;
- if(dwYRealPos>XY_CTHL_LENTH)
- {
-
- cXCGYcheck=0;
- AxisEgmStop(Y_AXIS);
- XY_CTHL_CL_MotorStep = 0;
- XY_CTHL_LianLengthXC_Check=0;
- SetPos(Y_AXIS, 0); //启动位置设为0点
-
- }
- else if(dwYRealPos> (XY_CTHL_LianLengthERROR_Check+1000) )
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_XCXXCYC_ALARM,bRunning);
-
- }
- }
- else
- {
- if(XY_CTHL_CXSC_Limit_IN_DW)
- {
- XY_CTHL_LianLengthXC_Check=dwYRealPos;
- XY_CTHL_CL_MotorStep = 22;
- }
- }
-
- }
-
- break;
- case 22:
- if(!XY_CTHL_PARAM_XCXJY_MODE)
- {
- if(cXiaoChaTest)
- {
- if(XY_CTHL_PARAM_CR_MODE != 0)
- {
- if(dwTickCount >= (XY_CTHL_CL_MotorDelay-1000))
- {
- XY_CTHL_CXQJD_VAVLE = 0;
- }
-
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- XY_CTHL_CL_MotorStep = 40;
-
- cXiaoChaTest=0;
- }
- }
- else
- {
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- // XY_CTHL_CXHT_VAVLE = 0;
- XY_CTHL_CL_MotorStep = 0;
- }
- }
- }
- else
- {
- if(XY_CTHL_PARAM_CR_MODE != 0)
- {
- if(!Y_DRV || (dwYRealPos >= XY_CTHL_LENTH)) //插销定位已经结束
- {
- AxisEgmStop(Y_AXIS);
- XY_CTHL_YsaveCXDWPosBuff = 0;
- XY_CTHL_CL_MotorStep = 0;
-
- }
- }
- else
- {
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- // XY_CTHL_CXHT_VAVLE = 0;
- XY_CTHL_CL_MotorStep = 0;
- }
-
- }
-
- }
- }
- else
-
- {
- if(dwYRealPos>(XY_CTHL_LianLengthXC_Check+XY_CTHL_PARAM_CXDW_Length))
- {
-
- cXCGYcheck=0;
- AxisEgmStop(Y_AXIS);
- XY_CTHL_CL_MotorStep = 0;
- XY_CTHL_LianLengthXC_Check=0;
- SetPos(Y_AXIS, 0); //启动位置设为0点
-
- }
- }
- break;
- //回原点开始
- case 40:
- //要先离开
- if(XY_CTHL_SF_Origin_IN && (GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- XY_CTHL_CL_MotorStep = 41;
- SetDir(Y_AXIS, DIR_P);
- }
- else
- {
- SetDir(Y_AXIS, DIR_N);
- XY_CTHL_CL_MotorStep = 46;
-
- }
-
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- XY_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- else //已经锁轴
- XY_CTHL_CL_MotorDelay = dwTickCount + 5;
- break;
- case 41:
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- XY_CTHL_CL_MotorStep = 42;
- AxisContinueMoveAcc(Y_AXIS,5000,DIR_P,1000,800,15,15);
- }
- break;
- case 42:
- if(!XY_CTHL_SF_Origin_IN)
- {
- XY_CTHL_CL_MotorStep = 43;
- XY_CTHL_YSavePosBuff = dwYRealPos;
- }
- break;
- case 43:
- //离开原点5CM停止
- if((dwYRealPos - XY_CTHL_YSavePosBuff) >= 800)
- {
- AxisEgmStop(Y_AXIS);
- XY_CTHL_CL_MotorStep = 46; //留空几步备用
- XY_CTHL_CL_MotorDelay = dwTickCount + 50;
- }
- break;
- case 46:
- if(dwTickCount >= XY_CTHL_CL_MotorDelay)
- {
- XY_CTHL_CL_MotorStep = 47; //检测回到原位
- if(!XY_CTHL_SF_Origin_IN)
- AxisContinueMoveAcc(Y_AXIS,1500,DIR_N,1000,800,15,10);
- }
- break;
- case 47:
- if(XY_CTHL_SF_Origin_IN)
- {
- XY_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,XY_CTHL_PARAM_CL_Back_O_Speed,-dwYRealPos+150,5000,2500,30,200,00);
-
- }
- else
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,1000,15,15);
- XY_CTHL_CL_MotorStep = 51;
- break;
- case 51:
- if(XY_CTHL_SF_Origin_IN)
- {
- XY_CTHL_CL_MotorStep = 0;
- AxisEgmStop(Y_AXIS);
- SetPos(Y_AXIS, 0);
- }
- break;
-
- }
- #endif
- }
- //装拉头动作
- void XY_CTHL_ZLT_Step(void)
- {
-
- switch(XY_CTHL_ZhuangLiaoStep)
- {
- case 1:
- if(bZhuangLiaoOkFlg)
- {
- XY_CTHL_ZhuangLiaoStep = 0;
- }
-
- if(((XY_CTHL_MGuo_VAVLE && XY_CTHL_LTou_Check) || !XY_CTHL_MGuo_VAVLE) )//说明没有拉头
- {
- if(!XY_CTHL_JLiao_Limit_IN)
- {
- //穿头模和一次穿入必须在原位,接料不能有输出
- if(XY_CTHL_CTM_Origin_IN && !XY_CTHL_CTXM_VAVLE)
- {
- XY_CTHL_First_CT_VAVLE = 0;
- XY_CTHL_XiaJiangXM_VAVLE=0;
- // XY_CTHL_JLTou_VAVLE = 0;
- XY_CTHL_MGuo_VAVLE = 0;
- if(XY_CTHL_TLiaoStep == 0)
- {
- XY_CTHL_TLiaoStep = 1;
- XY_CTHL_ZhuangLiaoStep = 2;
- }
- }
-
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay + 500) //警告横送拉必须保证穿头模和一次穿入在原位,接料不能有输出
- {
- cWULATOUCnt=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_CTM_Origin_ALARM,bRunning);
-
- }
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay + 500)
- {
- cWULATOUCnt=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_JLiao_Limit_ALARM,bRunning);
- }
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay) //已经有拉头直接跳到结束
- {
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 40;
- XY_CTHL_ZhuangLiaoStep = 9;
- }
- break;
- case 2:
- if(XY_CTHL_TLiaoStep == 0) //推料已经完成
- {
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME ;
- XY_CTHL_JLTou_VAVLE = 0;
- XY_CTHL_MGuo_VAVLE = 0;
- if(!XY_CTHL_JLiao_Limit_IN && XY_CTHL_First_CT_Origin_IN)
- {
- XY_CTHL_ZhuangLiaoStep = 3;
- XY_CTHL_HSLiao_VAVLE = 1;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCCRYWYC_ALARM,bRunning);
- }
- }
- break;
- case 3:
- //横送到位
- if(XY_CTHL_HSLiao_Limit_IN && !XY_CTHL_HSLiao_Origin_IN)
- {
- XY_CTHL_ZhuangLiaoStep = 4;
- // XY_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
- XY_CTHL_XiaJiangXM_VAVLE=0;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 5;
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay)
- {
- cWULATOUCnt=1;
- XY_CTHL_HSLiao_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_HSLiao_Limit_ALARM,bRunning);
- if(bRunning)
- {
- XY_CTHL_ZhuangLiaoStep = 0 ;
- }
- }
- break;
- case 4:
- if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay)
- {
- XY_CTHL_ZhuangLiaoStep = 5;
- XY_CTHL_XiaJiangXM_VAVLE=0;
- XY_CTHL_JLTou_VAVLE = 1; //接拉头输出,不需要时间
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME ;
- }
- break;
- case 5:
- if(XY_CTHL_JLiao_Limit_IN)
- {
- XY_CTHL_ZhuangLiaoStep = 6;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_PARAM_MaGou_DELAY;
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay) //接拉头(接料)到们信号异常
- {
- cWULATOUCnt=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_JLiao_Limit_ALARM,bRunning);
- }
- break;
- case 6:
- if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay) //延时码勾
- {
- XY_CTHL_MGuo_VAVLE = 1; //码勾输出
- XY_CTHL_ZhuangLiaoStep = 7;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_PARAM_HSLiaoOff_DELAY;
- bTuiLaTouOkFlg = 0; //认为拉头没法带出
- }
- break;
- case 7:
- if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay)
- {
- XY_CTHL_HSLiao_VAVLE = 0;
- XY_CTHL_ZhuangLiaoStep = 8;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME ;
- }
- break;
- case 8:
- if(!XY_CTHL_HSLiao_Limit_IN) //
- {
- XY_CTHL_ZhuangLiaoStep = 9;
- XY_CTHL_TLiaoStep = 1; //推拉头
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_PARAM_CheckLT_DELAY; //也是给下模能上升的时间
- }
- else if (XY_CTHL_LTou_Check) //时间内信号这说明没有拉头
- {
- //重送3次
- XY_CTHL_TryCnt++;
- XY_CTHL_JLTou_VAVLE = 0; //接拉头关
- XY_CTHL_MGuo_VAVLE = 0; //码勾打开
- if(XY_CTHL_TryCnt >= 3)
- {
- XY_CTHL_TryCnt = 0;
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_ZhuangLiaoStep = 0;
- XY_CTHL_SetAlarmCode(XY_CTHL_ZLT_ALARM,bRunning);
- cWULATOUCnt=1;
- }
- else
- {
- XY_CTHL_ZhuangLiaoStep = 20; //重新送3次
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME ;
- }
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay)
- {
- cWULATOUCnt=1;
- XY_CTHL_HSLiao_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_HSLiao_Limit_ALARM,bRunning);
- if(bRunning)
- {
- XY_CTHL_ZhuangLiaoStep = 0 ;
- }
- }
- break;
- case 9:
- if(XY_CTHL_LTou_Check) //时间内信号这说明没有拉头
- {
- XY_CTHL_TryCnt++;
- XY_CTHL_JLTou_VAVLE = 0; //接拉头关
- XY_CTHL_MGuo_VAVLE = 0; //码勾打开
- if(XY_CTHL_TryCnt >= 3)
- {
- XY_CTHL_TryCnt=0;
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_ZhuangLiaoStep = 0;
- XY_CTHL_SetAlarmCode(XY_CTHL_ZLT_ALARM,bRunning);
- cWULATOUCnt=1;
- }
- else
- {
- XY_CTHL_ZhuangLiaoStep = 20; //重新送3次
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME ;
- }
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay)
- {
- bZhuangLiaoOkFlg = 1;
- if(XY_CTHL_AutoStep==6)
- {
- XY_CTHL_bLTCHECK_Delay=dwTickCount+30;
- XY_CTHL_AutoDelay = dwTickCount + 3000;//斜口推带回原位报警时间
- }
- XY_CTHL_ZhuangLiaoStep = 0;
- }
- break;
- //装拉头不成攻重新送拉头
- case 20:
- if(XY_CTHL_HSLiao_Origin_IN)
- {
- XY_CTHL_JLTou_VAVLE = 0; //接拉头关
- XY_CTHL_MGuo_VAVLE = 0; //码勾打开
- XY_CTHL_ZhuangLiaoStep = 1;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 10;
- }
- else if(dwTickCount >= XY_CTHL_ZhuangLiaoDelay)
- {
- cWULATOUCnt=1;
- XY_CTHL_HSLiao_VAVLE=0;
- XY_CTHL_JLTou_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_HSLiao_Origin_ALARM,bRunning);
- }
- break;
- }
- }
- void XY_CTHL_TLiao_Step(void)
- {
- switch(XY_CTHL_TLiaoStep)
- {
- case 1:
- if(bTuiLaTouOkFlg)
- {
- XY_CTHL_TLiaoStep = 0;
- }
- else
- {
- XY_CTHL_TLiao_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- XY_CTHL_TLiaoStep = 2;
- }
- break;
- case 2: //横送料在原位
- if(XY_CTHL_HSLiao_Origin_IN && !XY_CTHL_HSLiao_Limit_IN && !XY_CTHL_HSLiao_VAVLE)
- {
- // XY_CTHL_TLiao_VAVLE = 1; //推料(推拉头)输出
- XY_CTHL_TLiao_Delay = dwTickCount + 100;
- XY_CTHL_TLiaoStep =101;
- }
- else if(dwTickCount >= XY_CTHL_TLiao_Delay)
- {
- cWULATOUCnt=1;
- XY_CTHL_HSLiao_VAVLE=0;
- XY_CTHL_JLTou_VAVLE=0;
- XY_CTHL_SetAlarmCode(XY_CTHL_HSLiao_Origin_ALARM,1);
- }
- break;
- case 101:
- if(dwTickCount >= XY_CTHL_TLiao_Delay)
- {
- XY_CTHL_TLiao_VAVLE = 1; //推料(推拉头)输出
- XY_CTHL_TLiaoStep = 3;
- XY_CTHL_TLiao_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 3: //推拉头到位
- if(!XY_CTHL_TLiao_Origin_IN)
- {
- XY_CTHL_TLiao_Delay = dwTickCount + XY_CTHL_PARAM_TLiao_BACKDELAY;
- XY_CTHL_TLiaoStep = 4;
- }
- else if(dwTickCount >= XY_CTHL_TLiao_Delay)
- {
- cWULATOUCnt=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_TLiao_Limit_ALARM,1);
- }
- break;
- case 4:
- if(dwTickCount >= XY_CTHL_TLiao_Delay)
- {
- XY_CTHL_TLiao_VAVLE = 0;
- XY_CTHL_TLiao_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- XY_CTHL_TLiaoStep = 5;
- }
- break;
- case 5:
- if(XY_CTHL_TLiao_Origin_IN)
- {
- XY_CTHL_TLiaoStep = 0;
- XY_CTHL_TLiao_Delay = dwTickCount;
- bTuiLaTouOkFlg = 1;
- }
- else if(dwTickCount >= XY_CTHL_TLiao_Delay)
- {
- cWULATOUCnt=1;
- XY_CTHL_SetAlarmCode(XY_CTHL_TLiao_Limit_ALARM,0);
- }
- break;
- }
-
- }
- //振动盘控制
- void XY_CTHL_ZhenDongAction(void)
- {
-
- #if 1
- if(!cDLPONE)
- {
- if( XY_CTHL_ZhenDongPian_OUT && XY_CTHL_PARAM_DALIAOPIAN)
- {
- if(dwTickCount >= XY_CTHL_ZDP_auto_Delay )
- {
- XY_CTHL_ZDP_auto_Delay = dwTickCount + XY_CTHL_DLPJG_TIME + 40;
- XY_CTHL_DLP_VAVLE = ~XY_CTHL_DLP_VAVLE;
- }
- }
- else
- XY_CTHL_DLP_VAVLE = 0;
- }
- #endif
-
- #if 1
-
- // if(bRunning)
- // {
- if(!XY_CTHL_PARAM_ZDP_AUTO)
- {
- if(XY_CTHL_ZhenDongPian_OUT == 0)
- {
- if(!XY_CTHL_ZDP_IN)
- {
- if(dwTickCount >= XY_CTHL_ZDP_Delay)
- {
- XY_CTHL_ZhenDongPian_OUT = 1;
- XY_CTHL_ZDP_Delay = dwTickCount + XY_CTHL_PARAM_ZDP_Stop_TIME;//XY_CTHL_PARAM_ZDP_Stop_TIME + 50;
- }
- }
- else
- {
- XY_CTHL_ZDP_Delay = dwTickCount + XY_CTHL_PARAM_ZDP_Start_TIME;//XY_CTHL_PARAM_ZDP_Start_TIME;
- }
- }
- else
- {
- if(XY_CTHL_ZDP_IN)
- {
- if(dwTickCount >= XY_CTHL_ZDP_Delay)
- {
- XY_CTHL_ZhenDongPian_OUT = 0;
- XY_CTHL_ZDP_Delay = dwTickCount + XY_CTHL_PARAM_ZDP_Start_TIME;//XY_CTHL_PARAM_ZDP_Start_TIME
- }
- }
- else
- XY_CTHL_ZDP_Delay = dwTickCount + XY_CTHL_PARAM_ZDP_Stop_TIME;//XY_CTHL_PARAM_ZDP_Stop_TIME+ 50;
- }
- }
- else if (XY_CTHL_PARAM_ZDP_AUTO ==1 )
- {
- XY_CTHL_ZhenDongPian_OUT=0;
- XY_CTHL_ZDP_Delay = dwTickCount + 0;
- }
- else if(XY_CTHL_PARAM_ZDP_AUTO == 2)
- {
- XY_CTHL_ZhenDongPian_OUT=1;
- XY_CTHL_ZDP_Delay = dwTickCount + 0;
-
- }
- #endif
- }
- void XY_CTHL_bFKCXTDDWStep(void)
- {
- switch(XY_CTHL_bFKCXTDDW_Step)
- {
- case 1:
- if(dwTickCount >= XY_CTHL_bFKCXTDDW_Delay)
- {
- XY_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- XY_CTHL_FKGD_VAVLE = 0; //方块固定关
- XY_CTHL_bFKCXTDDW_Step = 2;
- }
- break;
- case 2:
- if(!XY_CTHL_XKTD_Origin_IN) //斜口推带原位离开
- {
- XY_CTHL_bFKCXTDDW_Step = 3;
- XY_CTHL_bFKCXTDDW_Delay = dwTickCount + 20;
- }
- break;
- case 3://斜口定位
- if(dwTickCount >= XY_CTHL_bFKCXTDDW_Delay)
- {
- XY_CTHL_XKDW_VAVLE = 1;
- XY_CTHL_bFKCXTDDW_Step = 4;
- // XY_CTHL_bFKCXTDDW_Delay = dwTickCount + XY_CTHL_PARAM_XKDW_TD_DELAY;
- }
- break;
- case 4:
-
- AxisContinueMoveAcc(X_AXIS,1200,DIR_P,800,600,10,50);//拖带电机
- XY_CTHL_bFKCXTDDW_Step = 5;
- XY_CTHL_bFKCXTDDW_Delay = dwTickCount +300;
- XY_CTHL_XSavePosBuff = dwXRealPos;
- // SetPos(X_AXIS, 0); //启动位置设为0点
- dwXRealPos = 0;
-
- break;
- case 5:
-
- if(dwTickCount >= XY_CTHL_bFKCXTDDW_Delay )
- {
- XY_CTHL_FKJD_VAVLE = 1; //方块夹带气缸输出
-
- }
-
- if(XY_CTHL_XKSC_Limit_IN) //方块到位
- {
- AxisEgmStop(X_AXIS);
- XY_CTHL_bFKCXTDDW_Step = 6;
- XY_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
- XY_CTHL_QDXK_VAVLE = 1;
- XY_CTHL_bFKCXTDDW_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
-
- }
- else if(dwXRealPos >= (XY_CTHL_XSavePosBuff + 1800))
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_FKCXDW_ALARM,bRunning);//方块插销定位异常警告
-
- }
- break;
- case 6:
- if(XY_CTHL_PARAM_TDFZ_LENTH && !X_DRV) //拖带电机反转
- AxisMovePosAccDec(X_AXIS,8000,-XY_CTHL_PARAM_DXKFZ_LENTH,800,600,6,6,0);
- if(XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 1;
- XY_CTHL_bFKCXTDDW_Step = 0;
- break;
- }
- }
- //插销穿入动作
- void XY_CTHL_bCXCRStep(void)
- {
- switch(XY_CTHL_bCXCR_Step)
- {
- case 11:
- XY_CTHL_XKTD_VAVLE = 1; //斜口推带气缸输出
- XY_CTHL_FKGD_VAVLE = 0; //方块固定关
- XY_CTHL_CXSCDW_VAVLE=1;
- XY_CTHL_bCXCR_Step = 12;
-
- break;
- case 12:
- if(!XY_CTHL_XKTD_Origin_IN) //斜口推带原位离开
- {
- XY_CTHL_bCXCR_Step = 13;
- // XY_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- XY_CTHL_bCXCR_Delay = dwTickCount + 20;
- }
- break;
- case 13:
- if((XY_CTHL_CL_MotorStep == 0) && (XY_CTHL_SF_Origin_IN) && (dwTickCount >= XY_CTHL_bCXCR_Delay)) //插销前夹带回到原位
- {
- XY_CTHL_bCXCR_Step = 14;
- // XY_CTHL_FKGD_VAVLE = 1; //方块固定开
- XY_CTHL_CXQJD_VAVLE = 1; //插销前夹带
- XY_CTHL_bCXCR_Delay = dwTickCount + XY_CTHL_PARAM_XCQJD_XCDW_DELAY+100;
- }
- break;
- case 14:
- if(dwTickCount >= XY_CTHL_bCXCR_Delay)
- {
- XY_CTHL_bCXCR_Step = 15;
- XY_CTHL_FKGD_VAVLE = 1; //方块固定
- //Y轴启动插销
- XY_CTHL_CL_MotorStep = 20; //插销定位
- }
- break;
- case 15:
- if(XY_CTHL_CL_MotorStep == 0) //插销定位完成
- {
- XY_CTHL_bCXCR_Step = 16;
- if(!XY_CTHL_PARAM_XCDWGY_MODE)
- XY_CTHL_CXDWZ_VAVLE = 1; //插销定位针(到位)电磁阀
- XY_CTHL_FKJD_VAVLE= 0;
- XY_CTHL_bCXCR_Delay = dwTickCount + 10; //延时插销下移
- }
- break;
- case 16:
- if(dwTickCount >= XY_CTHL_bCXCR_Delay)
- {
- XY_CTHL_bCXCR_Step = 17;
- if(XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 0;
- else
- XY_CTHL_CXXY_VAVLE = 1; //Y06 插销下移电磁阀
- XY_CTHL_bCXCR_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME; //插销下移异常时间
- }
- break;
- case 17:
- if(XY_CTHL_PARAM_CXXY_MODE)
- {
- if(XY_CTHL_CXXY_Origin_IN)
- {
- // if(XY_CTHL_START_IN_UP)
- {
- XY_CTHL_bCXCR_Step = 18;
- if( cXcxcrCnt==0 && !X_DRV) //拖带电机反转
- {
- // SetDir(X_AXIS, DIR_N);
- AxisMovePosAccDec(X_AXIS,10000,-XY_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- XY_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- XY_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- XY_CTHL_bCXCR_Delay = dwTickCount + XY_CTHL_PARAM_SCDWOff_CXDW_DELAY;
-
- }
- }
- else if(dwTickCount >= XY_CTHL_bCXCR_Delay)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CXXY_Limit_ALARM,bRunning);//插销下移异常
-
- }
- }
- else
- {
-
- XY_CTHL_bCXCR_Step = 18;
- if( cXcxcrCnt==0 && !X_DRV) //拖带电机反转
- {
- // SetDir(X_AXIS, DIR_N);
- AxisMovePosAccDec(X_AXIS,10000,-XY_CTHL_PARAM_TDFZ_LENTH,800,600,6,6,0);
- }
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带电磁阀
- XY_CTHL_CXSCDW_VAVLE = 0; //Y21 插销上止定位关
- XY_CTHL_CXHJD_VAVLE = 1; //Y14 插销后夹带输出
- XY_CTHL_bCXCR_Delay = dwTickCount + XY_CTHL_PARAM_SCDWOff_CXDW_DELAY;
-
-
- }
- break;
- case 18:
- // if(START_IN_UP)
- {
- if(dwTickCount >= XY_CTHL_bCXCR_Delay)
- {
- XY_CTHL_bCXCR_Step = 19;
-
- XY_CTHL_CXHDW_VAVLE = 1; //插销后定位(插销穿入)
- XY_CTHL_bCXCR_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME +1000; //插销穿入到位异常时间
- XY_CTHL_CL_MotorStep = 50; //合链电机回原点
- }
- }
- break;
- case 19:
- if( cXcxcrCnt > 1)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CX_Limit_ALARM,bRunning); //插销穿入到位异常
- }
-
- if( (XY_CTHL_CX_Limit_IN || XY_CTHL_PARAM_XCDWGY_MODE) && cXcxcrCnt<2 )
- {
- if(!XY_CTHL_PARAM_XCDWGY_MODE || XY_CTHL_PARAM_XCDWGY_MODE==1)
- {
- cXcxcrCnt=0;
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀
- XY_CTHL_bCXCR_Delay = dwTickCount + 200;
-
- XY_CTHL_bCXCR_Step = 20;
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- }
- else if(XY_CTHL_PARAM_XCDWGY_MODE==2)
- {
- XY_CTHL_bCXCR_Delay = dwTickCount + 200; //插销穿入到位异常时间
- XY_CTHL_bCXCR_Step = 20;
- }
-
- }
- else if (dwTickCount >= XY_CTHL_bCXCR_Delay)
- {
- cXcxcrCnt++;
-
- XY_CTHL_CXHJD_VAVLE=0;
- XY_CTHL_CXHDW_VAVLE=0;
- XY_CTHL_CXDWZ_VAVLE = 0;
- if(XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 0;
- else
- XY_CTHL_CXXY_VAVLE = 1; //Y06 插销下移电磁阀
- XY_CTHL_bCXCR_Step = 11;
- }
-
- break;
- case 20:
- if(dwTickCount >= XY_CTHL_bTFKGD_Delay)
- {
- if(XY_CTHL_PARAM_XCDWGY_MODE)
- {
- cXcxcrCnt=0;
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- }
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- XY_CTHL_bCXCR_Step = 0;
-
- }
- break;
- }
- }
- void XY_CTHL_bCLFirstStep(void)
- {
- switch(XY_CTHL_bCLFirst_Step)
- {
- case 19:
- XY_CTHL_JLTou_VAVLE = 0; //接拉头
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_bCLFirst_Step = 20;
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- XY_CTHL_bCLFirst_Delay = dwTickCount + XY_CTHL_PARAM_First_CL_DELAY;//延时一次穿入
- break;
- case 20:
- if(dwTickCount >= XY_CTHL_bCLFirst_Delay)
- {
- XY_CTHL_bCLFirst_Step = 21;
- XY_CTHL_First_CT_VAVLE = 1; //一次穿入电磁阀输出
- XY_CTHL_bTFKGD_Delay = dwTickCount + XY_CTHL_PARAM_FKGD_DELAY; //退方块固定时间
- XY_CTHL_bCLFirst_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 21:
- if(dwTickCount >= XY_CTHL_bTFKGD_Delay)
- {
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- }
- if(!XY_CTHL_First_CT_Origin_IN) //原点离开后才开始时间
- {
- XY_CTHL_bCLFirst_Step = 22;
- XY_CTHL_bCLFirst_Delay = dwTickCount + XY_CTHL_PARAM_First_CL_Timer; //一次穿入时间
- }
- else if(dwTickCount >= XY_CTHL_bCLFirst_Delay)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCCRYWYC_ALARM,bRunning); //一次穿入原位异常
- }
- break;
- case 22:
- if(dwTickCount >= XY_CTHL_bTFKGD_Delay)
- {
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- }
- if(dwTickCount >= XY_CTHL_bCLFirst_Delay)
- {
- XY_CTHL_bCLFirst_Step = 23;
- XY_CTHL_MGuo_VAVLE = 0; //码勾退
- XY_CTHL_bCLFirst_Delay = dwTickCount + XY_CTHL_PARAM_MGOff_XiaMo_DELAY;
- XY_CTHL_FKGD_VAVLE = 0; //方块固定退
- XY_CTHL_CXHJD_VAVLE = 0; //Y14 插销后夹带打开
- XY_CTHL_CXXY_VAVLE = 0; //Y06 插销下移电磁阀关
- }
- break;
- case 23:
- if(dwTickCount >= XY_CTHL_bCLFirst_Delay)
- {
- XY_CTHL_bCLFirst_Step = 24;
- XY_CTHL_CTXM_VAVLE = 0; //穿头下模下降
- XY_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- XY_CTHL_bCLFirst_Delay = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- }
- break;
- case 24:
- if(!XY_CTHL_CTM_Limit_IN)
- {
- XY_CTHL_bCLFirst_Step= 25;
- XY_CTHL_bCLFirst_Delay = dwTickCount + 25; //一次穿入延时返回
- }
- else if(dwTickCount >= XY_CTHL_bCLFirst_Delay)
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CTM_Origin_ALARM,bRunning); //穿头下模下降异常
- }
- break;
- case 25:
- if(dwTickCount >= XY_CTHL_bCLFirst_Delay)
- {
-
- XY_CTHL_bCLFirst_Step= 0;
- XY_CTHL_First_CT_VAVLE = 0; //一次穿入电磁阀关
- XY_CTHL_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
-
-
- //退下出错警告
- XY_CTHL_AutoDelay1 = dwTickCount + XY_CTHL_VAVLE_ERROR_TIME;
- XY_CTHL_AutoStep1 = 1;
- bTuiLaTouOkFlg = 1;
- }
- break;
- }
- }
- //手动动作
- void XY_CTHL_ManualAction(void)
- {
- if(cBanAuTo)
- {
- XY_CTHL_PARAM_BanZiDong=1;
- }
- else
- {
- XY_CTHL_PARAM_BanZiDong=0;
- }
-
- if(XY_CTHL_PARAM_CL_Length > XY_CTHL_PARAM_CL_MAX_Length)
- {
- XY_CTHL_PARAM_CL_Length = XY_CTHL_PARAM_CL_MAX_Length;
- }
-
-
-
- if(dwTickCount >= XY_CTHL_bSFBBAOJIN_Delay)
- {
- // SetEn(X_AXIS,MOTOR_EN);
- XY_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(XY_CTHL_bTLiao ) //手动推料(推拉头)
- {
- XY_CTHL_bTLiao = 0;
- if(XY_CTHL_TLiao_VAVLE)
- XY_CTHL_TLiao_VAVLE = 0;//XY_CTHL_TLiao_VAVLE;
- else if(!XY_CTHL_HSLiao_VAVLE && XY_CTHL_HSLiao_Origin_IN)
- {
- XY_CTHL_TLiao_VAVLE = 1;
- }
- else//条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_HENSONGLIAO_ALARM,0); // 横送料不能输出
- }
-
- }
-
- if(XY_CTHL_bHSL) //手动横送料
- {
- XY_CTHL_bHSL= 0;
- if(!XY_CTHL_First_CT_VAVLE)
- {
- if(XY_CTHL_HSLiao_VAVLE)
- {
- XY_CTHL_HSLiao_VAVLE = 0;//~XY_CTHL_HSLiao_VAVLE;
- }
- else if(XY_CTHL_First_CT_Origin_IN &&
- !XY_CTHL_JLTou_VAVLE && !XY_CTHL_CTXM_VAVLE && !XY_CTHL_CXDWZ_VAVLE && (!XY_CTHL_bMG || (XY_CTHL_bMG && XY_CTHL_LTou_Check)))
- {
- if(!XY_CTHL_TLiao_VAVLE && XY_CTHL_TLiao_Origin_IN)
- {
- if(!XY_CTHL_JLiao_Limit_IN)
- {
- if(XY_CTHL_CTM_Origin_IN)
- XY_CTHL_HSLiao_VAVLE = 1;
- else
- XY_CTHL_SetAlarmCode(XY_CTHL_YCXM_Origin_ALARM,0);
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_JLiao_Limit_ALARM,0);
- }
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_TLiao_Limit_ALARM,0);
- }
- }
- else //条件警告 最后一个括号条件为已经有拉头
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCCT_ALARM,0);
- }
- }
- }
- if(XY_CTHL_bJLT) //接拉头
- {
- XY_CTHL_bJLT = 0;
- if(XY_CTHL_JLTou_VAVLE)
- XY_CTHL_JLTou_VAVLE = 0;
- else if(!XY_CTHL_First_CT_VAVLE && !XY_CTHL_CTXM_VAVLE && XY_CTHL_CTM_Origin_IN )
- {
- if(XY_CTHL_First_CT_Origin_IN)
- {
- XY_CTHL_MGuo_VAVLE = 0;
- XY_CTHL_JLTou_VAVLE = 1;
- XY_CTHL_XiaJiangXM_VAVLE=0;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCCT_ALARM,0);
- }
- }
- else//条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCXM_Origin_ALARM,0);
- }
- }
- if(XY_CTHL_bMG) //码勾
- {
- XY_CTHL_bMG = 0;
- XY_CTHL_MGuo_VAVLE = !XY_CTHL_MGuo_VAVLE;
- }
- if(XY_CTHL_bFKJD) //方块夹带
- {
- XY_CTHL_bFKJD = 0;
- XY_CTHL_FKJD_VAVLE = !XY_CTHL_FKJD_VAVLE;
- }
- if(XY_CTHL_bXKTD) //斜口推带
- {
- XY_CTHL_bXKTD = 0;
- if(XY_CTHL_XKTD_VAVLE)
- XY_CTHL_XKTD_VAVLE = 0;
- else if(!XY_CTHL_DXK_VAVLE )
- {
- if(!XY_CTHL_XKSC_Limit_IN || !XY_CTHL_CTXM_VAVLE || XY_CTHL_PARAM_NLSL_MODE)
- XY_CTHL_XKTD_VAVLE = 1;
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCXM_Origin_ALARM,0);
- }
- }
- else//条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_DXKCTXM_Origin_ALARM,0);
- }
- }
- if(XY_CTHL_bXKDW) //斜口定位
- {
- XY_CTHL_bXKDW = 0;
- XY_CTHL_XKDW_VAVLE = ~XY_CTHL_XKDW_VAVLE;
- }
- if(XY_CTHL_bCTXM) //穿头下模
- {
- XY_CTHL_bCTXM = 0;
- if(XY_CTHL_CTXM_VAVLE)
- {
-
- XY_CTHL_XiaJiangXM_VAVLE=1;
- cXMdelay=1;
- XY_CTHL_bXiaMoSJ_Delay = dwTickCount +250;
-
- XY_CTHL_CTXM_VAVLE = 0;
- XY_CTHL_JLTou_VAVLE = 0;
-
- }
- else if(!XY_CTHL_HSLiao_VAVLE && (!XY_CTHL_XKSC_Limit_IN || !XY_CTHL_XKTD_VAVLE))
- {
- if(XY_CTHL_HSLiao_Origin_IN)
- {
- if(XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 1;
- // XY_CTHL_MGuo_VAVLE = 1;
- XY_CTHL_CTXM_VAVLE = 1;
-
- XY_CTHL_XiaJiangXM_VAVLE=1;
- cXMdelay=1;
- XY_CTHL_bXiaMoSJ_Delay = dwTickCount + 30;
- }
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_HENSONGLIAO_ALARM,0);
- }
-
- }
- }
- if(cXMdelay)
- {
- if(dwTickCount >= XY_CTHL_bXiaMoSJ_Delay )
- {
- XY_CTHL_XiaJiangXM_VAVLE=0;
- cXMdelay=0;
- }
- }
-
- if(XY_CTHL_bQianDXK) //前顶斜口
- {
- XY_CTHL_bQianDXK = 0;
- if(XY_CTHL_QDXK_VAVLE)
- XY_CTHL_QDXK_VAVLE = 0;
- else if(!XY_CTHL_XKTD_VAVLE)
- XY_CTHL_QDXK_VAVLE = 1;
- else //条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_XKTD_ALARM,0);
- }
- }
-
-
- if(XY_CTHL_bDXK) //顶斜口
- {
- XY_CTHL_bDXK = 0;
- if(!XY_CTHL_PARAM_NLSL_MODE)
- {
- if(XY_CTHL_DXK_VAVLE)
- XY_CTHL_DXK_VAVLE = 0;
- else if(!XY_CTHL_XKTD_VAVLE)
- {
- if(!XY_CTHL_PARAM_NLSL_MODE)
- XY_CTHL_DXK_VAVLE = 1;
- }
- else //条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_XKTD_ALARM,0);
- }
- }
- else
- {
- if(XY_CTHL_XKTD_VAVLE)
- XY_CTHL_XKTD_VAVLE = 0;
- else if(!XY_CTHL_DXK_VAVLE )
- {
- if(!XY_CTHL_XKSC_Limit_IN || !XY_CTHL_CTXM_VAVLE || XY_CTHL_PARAM_NLSL_MODE)
- XY_CTHL_XKTD_VAVLE = 1;
- else
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_YCXM_Origin_ALARM,0);
- }
- }
- else//条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_DXKCTXM_Origin_ALARM,0);
- }
-
-
-
- }
- }
-
- if(XY_CTHL_bQianDXK_DXK)
- {
- XY_CTHL_bQianDXK_DXK = 0;
- if(!XY_CTHL_XKTD_VAVLE && XY_CTHL_AutoStep==0)
- {
- cQDXK_DXK=1;
- XY_CTHL_AutoStep = 8;
-
- if((GetEn(X_AXIS) == MOTOR_EN))
- XY_CTHL_AutoDelay = dwTickCount + 10;
- else
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_AutoDelay = dwTickCount + 1000;
- }
- bRunning=1;
- }
-
- }
-
- if(XY_CTHL_bFKGD) //方块固定
- {
- XY_CTHL_bFKGD = 0;
- XY_CTHL_FKGD_VAVLE = ~XY_CTHL_FKGD_VAVLE;
- }
- if(XY_CTHL_bCXQJD) //插销前夹带
- {
- XY_CTHL_bCXQJD = 0;
- XY_CTHL_CXQJD_VAVLE = ~XY_CTHL_CXQJD_VAVLE;
- }
- if(XY_CTHL_bCXSY) //插销下移电磁阀
- {
- XY_CTHL_bCXSY = 0;
- XY_CTHL_CXXY_VAVLE = !XY_CTHL_CXXY_VAVLE;
- }
- if(XY_CTHL_bCXDWZ) //Y14 插销定位针电磁阀
- {
- XY_CTHL_bCXDWZ = 0;
- if(XY_CTHL_CXDWZ_VAVLE)
- XY_CTHL_CXDWZ_VAVLE = 0;
- else if(XY_CTHL_HSLiao_Origin_IN)
- {
- XY_CTHL_CXDWZ_VAVLE = 1;
- }
- else //条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_HENSONGLIAO_ALARM,0);
- }
-
- }
- if(XY_CTHL_bCXHJD) //Y15 插销后夹带电磁阀
- {
- XY_CTHL_bCXHJD = 0;
- XY_CTHL_CXHJD_VAVLE =~XY_CTHL_CXHJD_VAVLE;
- }
- if(XY_CTHL_bCXHDW) //Y16 插销后定位电磁阀
- {
- XY_CTHL_bCXHDW = 0;
- if(XY_CTHL_CXHDW_VAVLE)
- XY_CTHL_CXHDW_VAVLE = 0;
- else if(!XY_CTHL_CXQJD_VAVLE)
- XY_CTHL_CXHDW_VAVLE = 1;
- else//条件警告
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_CXQJD_ALARM,0);
- }
- }
- if(XY_CTHL_bFirst_CT) //Y20 一次穿头电磁阀
- {
- XY_CTHL_bFirst_CT = 0;
- XY_CTHL_First_CT_VAVLE = ~XY_CTHL_First_CT_VAVLE;
- }
- if(XY_CTHL_DLP) //Y20 一次穿头电磁阀
- {
- XY_CTHL_DLP = 0;
- if(!XY_CTHL_DLP_VAVLE)
- {
- cDLPONE=1;
- XY_CTHL_DLP_VAVLE=1;
- }
- else
- {
- cDLPONE=0;
- XY_CTHL_DLP_VAVLE=0;
-
- }
- }
- if(XY_CTHL_bCXHT)
- {
- XY_CTHL_bCXHT = 0;
- XY_CTHL_CXHT_VAVLE = ~XY_CTHL_CXHT_VAVLE;
- }
- //视觉功能模式
- if(XY_CTHL_bJianChe)
- {
- XY_CTHL_bJianChe = 0;
- XY_CTHL_JIANCHE_VAVLE = ~XY_CTHL_JIANCHE_VAVLE;
- }
- if(XY_CTHL_bDingChu)
- {
- XY_CTHL_bDingChu = 0;
- XY_CTHL_DINGCHU_VAVLE = ~XY_CTHL_DINGCHU_VAVLE;
- }
- if(XY_CTHL_bXianZhi)
- {
- XY_CTHL_bXianZhi = 0;
- XY_CTHL_XIANZHI_VAVLE = ~XY_CTHL_XIANZHI_VAVLE;
- }
-
-
- if(XY_CTHL_SD)
- {
- XY_CTHL_SD = 0;
- XY_CTHL_SD_VAVLE = ~XY_CTHL_SD_VAVLE;
- }
- if(XY_CTHL_bHL)
- {
- XY_CTHL_bHL = 0;
- XY_CTHL_HL_VAVLE = ~XY_CTHL_HL_VAVLE;
- }
- if(XY_CTHL_bHLJJ) //Y21 合链夹具电磁阀
- {
- XY_CTHL_bHLJJ = 0;
- XY_CTHL_HLJJ_VAVLE = ~XY_CTHL_HLJJ_VAVLE;
- }
- if(XY_CTHL_bCXSCDW) //Y23 插销上止定位电磁阀
- {
- XY_CTHL_bCXSCDW = 0;
- XY_CTHL_CXSCDW_VAVLE = ~XY_CTHL_CXSCDW_VAVLE;
- }
- //自动装料
- if(XY_CTHL_bAutoZhuangLiao)
- {
- XY_CTHL_bAutoZhuangLiao = 0;
- if(XY_CTHL_ZhuangLiaoStep == 0)
- {
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg = 0;
- XY_CTHL_ZhuangLiaoStep = 1;
- XY_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- }
- }
- //测试电机
- if(XY_CTHL_bCLMotor_N)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!XY_CTHL_SF_Origin_IN)
- {
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_N,1000,1000,15,15);
- }
- else
- {
- XY_CTHL_bCLMotor_N = 0;
- }
-
- }
-
-
- if(XY_CTHL_bCLMotor_P) //后退限位已经取消
- {
- SetEn(Y_AXIS, MOTOR_EN);
- if(!Y_DRV)
- // Y轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(Y_AXIS,2000,DIR_P,1000,1000,15,15);
- }
-
- if(!XY_CTHL_bCLMotor_P && !XY_CTHL_bCLMotor_N && (XY_CTHL_CL_MotorStep == 0))
- {
- AxisEgmStop(Y_AXIS);//AxisDecStop(Y_AXIS);
- }
- //测试电机
- if(XY_CTHL_MotorTEST)
- {
- SetEn(X_AXIS, MOTOR_EN);
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,3000,DIR_P,1000,1000,30,80);
-
-
-
- }
- if(!XY_CTHL_MotorTEST_N && !XY_CTHL_MotorTEST && (XY_CTHL_TD_MotorStep == 0) && XY_CTHL_ColorStep==0 && (XY_CTHL_bFKCXTDDW_Step==0))
- {
- AxisEgmStop(X_AXIS);//AxisDecStop(Y_AXIS);
- }
- if(XY_CTHL_MotorTEST_N)
- {
- SetEn(X_AXIS, MOTOR_EN);
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,3000,DIR_N,1000,1000,30,80);
-
-
-
- }
- if(!XY_CTHL_MotorTEST_N && !XY_CTHL_MotorTEST && (XY_CTHL_TD_MotorStep == 0) && XY_CTHL_ColorStep==0 && (XY_CTHL_bFKCXTDDW_Step==0))
- {
- AxisEgmStop(X_AXIS);//AxisDecStop(Y_AXIS);
- }
- //合链电机返回原点
- if(XY_CTHL_bCLMotor_O)
- {
- XY_CTHL_bCLMotor_O = 0;
- if(XY_CTHL_CL_MotorStep == 0)
- XY_CTHL_CL_MotorStep = 40;
- }
- //拖带方块定位 ,因这步为前拖带定位, 很多电磁阀要关掉
- if(XY_CTHL_bFKTDDW)
- {
- XY_CTHL_bFKTDDW = 0;
- if(XY_CTHL_TD_MotorStep == 0)
- {
- XY_CTHL_XKDW_VAVLE = 0; //斜口定位
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- if(!XY_CTHL_PARAM_CXXY_MODE)
- XY_CTHL_CXXY_VAVLE = 0; //插销下移
- XY_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- XY_CTHL_CXHDW_VAVLE = 0; //插销后定位
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针
- XY_CTHL_bHLJJ = 0; //合链夹具
- XY_CTHL_FKJD_VAVLE = 0; //方块夹带
- if((GetEn(X_AXIS) == MOTOR_DISEN))
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_TD_MotorDelay = dwTickCount + 200;
- }
- else
- XY_CTHL_TD_MotorDelay = dwTickCount + 50;
- XY_CTHL_TD_MotorStep = 1;
- }
- }
- //拖带方块插销定位(斜口推带,斜口定位,顶斜口)
- if(XY_CTHL_bFKCXTDDW)
- {
- XY_CTHL_bFKCXTDDW = 0;
- if((XY_CTHL_bFKCXTDDW_Step == 0) && (XY_CTHL_CL_MotorStep == 0) &&
- !XY_CTHL_CTXM_VAVLE)
- {
- XY_CTHL_bFKCXTDDW_Step = 1;
- // SetEn(X_AXIS, MOTOR_EN);
- if((GetEn(X_AXIS) == MOTOR_EN))
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_bFKCXTDDW_Delay = dwTickCount + 10;
- }
- else
- {
- SetEn(X_AXIS, MOTOR_EN);
- XY_CTHL_bFKCXTDDW_Delay = dwTickCount + 1000;
- }
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- XY_CTHL_CXXY_VAVLE = 0; //插销下移
- XY_CTHL_CXHJD_VAVLE = 0; //插销后夹带
- XY_CTHL_CXHDW_VAVLE = 0; //插销后定位
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针
- XY_CTHL_HLJJ_VAVLE = 0; //合链夹具
- }
- }
- //插销穿入(包含电机前定位,插销下移,后夹,后定位)
- if(XY_CTHL_bCXCR)
- {
- XY_CTHL_bCXCR = 0;
- //拉头模在上面到们并且码勾输出,判断有拉头
- if(XY_CTHL_CTXM_VAVLE && XY_CTHL_MGuo_VAVLE && !XY_CTHL_CXQJD_VAVLE &&
- XY_CTHL_CTM_Limit_IN && !XY_CTHL_LTou_Check)
- {
- if(XY_CTHL_CL_MotorStep == 0)
- {
- XY_CTHL_bCXCR_Step = 11;
- SetEn(Y_AXIS, MOTOR_EN);
- if(!XY_CTHL_SF_Origin_IN)
- XY_CTHL_CL_MotorStep = 40;
- }
- }
- else //警告不能自动穿插销
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_WFZIDONGCX_ALARM,0);
- }
- }
-
-
- //半自动
- if(XY_CTHL_bBanZiDong)
- {
- XY_CTHL_bBanZiDong=0;
- cBanAuTo=1;
- XY_CTHL_PARAM_BanAuto_MODE=1;
- XY_CTHL_ZhuangLiaoDelay = dwTickCount + 150;
- XY_CTHL_MGuo_VAVLE = 1; //判断是否已经有料
- XY_CTHL_ZhuangLiaoStep = 1;
- bTuiLaTouOkFlg = 1;
- bZhuangLiaoOkFlg= 0;
- bCL_EN_FLG=0;
- XY_CTHL_AutoStep = 1;
- bRunning=1;
- }
-
- if(XY_CTHL_CXC)//穿小插
- {
- XY_CTHL_CXC=0;
- cCXCONE=1;
- cBanAuTo=0;
- XY_CTHL_PARAM_BanAuto_MODE=0;
- XY_CTHL_AutoStep = 11;
- bRunning=1;
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- XY_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- }
- //小插销测试
- if(XY_CTHL_bXiaoChaTest)
- {
- XY_CTHL_bXiaoChaTest=0;
- cXiaoChaTest=1;
- if(GetEn(Y_AXIS) == MOTOR_DISEN)
- {
- SetEn(Y_AXIS, MOTOR_EN);
- XY_CTHL_CL_MotorDelay = dwTickCount + 260; //锁轴时间
-
- }
- if(XY_CTHL_CL_MotorStep==0)
- XY_CTHL_CL_MotorStep = 20;
- }
- //电机合链动作
- if(XY_CTHL_bMotorHL)
- {
- XY_CTHL_bMotorHL = 0;
- if(XY_CTHL_PARAM_CR_MODE != 0)
- if(XY_CTHL_SF_Origin_IN)
- {
- if((XY_CTHL_CL_MotorStep == 0) && !XY_CTHL_CTXM_VAVLE && (!XY_CTHL_CTM_Limit_IN))
- {
- bCL_OK_FLG = 0;
- XY_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- XY_CTHL_CL_MotorStep = 1;
- XY_CTHL_CL_MotorDelay = dwTickCount + XY_CTHL_PARAM_HLJJ_CL_DELAY + 130;
- if((GetEn(Y_AXIS) == MOTOR_DISEN))
- {
- SetEn(Y_AXIS, MOTOR_EN);
- XY_CTHL_CL_MotorDelay = dwTickCount + 250;
- }
- }
- }
- else
- {
- XY_CTHL_bCLMotor_O =1;
-
- }
- else
- {
- bCL_OK_FLG = 0;
- XY_CTHL_CL_MotorStep = 1;
- XY_CTHL_HLJJ_VAVLE = 1; //Y20 合链夹具电磁阀输出后,电机穿入
- XY_CTHL_CL_MotorDelay = dwTickCount + XY_CTHL_PARAM_HLJJ_CL_DELAY + 130;
-
- }
- }
- //一次穿链动作
- if(XY_CTHL_bCL_First)
- {
- XY_CTHL_bCL_First = 0;
- //拉头模在上面到们并且码勾输出,判断有拉头
- if(XY_CTHL_CTXM_VAVLE && XY_CTHL_MGuo_VAVLE && !XY_CTHL_CXQJD_VAVLE &&
- XY_CTHL_CTM_Limit_IN && !XY_CTHL_LTou_Check && (XY_CTHL_CL_MotorStep == 0))
- {
- XY_CTHL_bCLFirst_Step = 19;
- XY_CTHL_CXHJD_VAVLE = 1; //插销后夹带
- XY_CTHL_CXDWZ_VAVLE = 0; //插销定位针(到位)电磁阀
- XY_CTHL_CXQJD_VAVLE = 0; //插销前夹带
- }
- }
- }
- }
- #endif
|