12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013 |
- #include "global.h"
- #if FU_XIAO_WEI_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 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(0)//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;
- 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[124] = dwXRealPos;
- user_datas[125] = dwYRealPos;
- user_datas[126] = XY_CTHL_LianLengthAutoCheck;
- user_datas[127] = XY_CTHL_LianLengSave;
- user_datas[128] = GetCurSpeed(X_AXIS);//XY_CTHL_PARAM_ShiJue;//、、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(0)//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)
- {
- // AxisContinueMoveAcc(X_AXIS,1000,DIR_P,800,600,10,10);//拖带电机
- AxisMovePosAccDecNotStop(X_AXIS,1600,150,600,1000,5,3,00);
- XY_CTHL_AutoStep = 5;
- 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) //方块上止到位
- {
- AxisEgmStop(X_AXIS);
- 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 )
- XY_CTHL_XKTD_VAVLE = 0; //斜口推带气缸关闭
-
- XY_CTHL_AutoStep = 6;
- XY_CTHL_AutoDelay = dwTickCount + 5000;//斜口推带回原位报警时间
- XY_CTHL_bLTCHECK_Delay = dwTickCount + 20;
- //电机穿入可以启动
- bCL_OK_FLG = 1; //不用穿合链的话认为已经完成
- if(cStopGN)
- {
- XY_CTHL_HLJJ_VAVLE=0;
- }
- if(bCL_EN_FLG && XY_CTHL_XKSC_Limit_IN && !cStopGN )
- {
- 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;
- }
- }
- }
- 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;
-
- 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(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 + 2000;
-
- }
- 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;
- XY_CTHL_AutoDelay = dwTickCount + XY_CTHL_PARAM_XCQJD_XCDW_DELAY;
- 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_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;
- 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;
-
- 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;
- 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)
- {
- 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_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_CXHDW_VAVLE = 0; //插销后定位(插销穿入)关闭
- //退下出错警告
- 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;
- SetEn(X_AXIS, MOTOR_EN);
- // dwXRealPos=0;
- XY_CTHL_TD_MotorStep=10;
- XY_CTHL_AutoStep = 11;
- 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);
- XY_CTHL_bSFBBAOJIN_Delay= dwTickCount + 500;
- }
-
- XY_CTHL_TD_MotorDelay = dwTickCount + 500;
- 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;
- 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_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,600,20,50);
- }
- 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 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;
-
- }
- break;
- case 13:
-
- 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;
- 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;
- }
- } */
- 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(!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)
- {
- 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_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;
- }
- break;
- case 21:
-
- 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;
-
- }
- }
-
-
- break;
- case 22:
-
- 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;
- }
-
- }
-
- }
- 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,35);
- }
- 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,2000,10,70,50);
-
-
- }
- else
- AxisContinueMoveAcc(Y_AXIS,1000,DIR_N,1000,1000,15,35);
- 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_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_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_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(!XY_CTHL_SF_ALR_IN && ((GetAlarm(Y_AXIS)==0) || XY_CTHL_PARAM_DB_MODE)) // 伺服报警
- {
- XY_CTHL_SetAlarmCode(XY_CTHL_SF_ALR_ALARM,0);
- }
-
- if(dwTickCount >= XY_CTHL_bSFBBAOJIN_Delay)
- {
- 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;
- }
- 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)
- {
-
- 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;
-
- 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 )
- {
- 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,2000,DIR_P,1000,1000,15,15);
-
-
-
- }
- 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,2000,DIR_N,1000,1000,15,15);
-
-
-
- }
- 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
|