123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735 |
- #include "global.h"
- #if JIN_HONG_MACHINE==1
- unsigned short cTaiMiamMotor;
- unsigned long cSlowPusle;
- unsigned char bDecEn,cXiaMo_En,cHemo_OK,cQTltOK,cHTltOk,cQHsltOK,cHHsltOK,cSL_En;
- unsigned char bStartOnceTime,bOnceProcess,cBackLimitCheck_EN;
- unsigned short cWorkCnt;
- unsigned char QTryCnt = 0, HTryCnt = 0;
- unsigned short cZhaCnt = 0;
- unsigned char QZhuangLiaoOkFlg = 0,HZhuangLiaoOkFlg = 0;
- unsigned char QTuiLaTouOkFlg = 0,HTuiLaTouOkFlg = 0;
- unsigned char ManFlg;
- unsigned char cStopFlg = 0, cResetOrigin_Flag= 0,cCheck_Go_In_Flag;
- unsigned char cFirstQStartFlg = 0,cFirstHStartFlg = 0;
- unsigned char cCountFlg = 0,cQDCT_TuiLianOKFlag = 0;
- short *qdct_length_buff;
- long save_limit_pos, cDinWeiPos;
- unsigned char cTuiLianStep,cChuan_LianCheckOK = 0,cChuan_Lian_ErrorNum,cSongLaTouEn = 0,cCheckDinWei;
- unsigned char KaDaiFlag = 0;
- long KaDaiSaveLen,KaDaiSaveLenY;
- unsigned char LengthType;
- unsigned long CutRemainLength;
- long temppos;
- void QDCT_ManualAction(void);
- void QDCT_JiaLianAction(void);
- void QDCT_AutoStepAction(void);
- void QDCT_QZhenDongAction(void);
- void QDCT_HZhenDongAction(void);
- void QDCT_TableAction(void);
- void QDCT_Motor(void);
- void QDCT_CheckStart(void);
- void QDCT_QTuiLT_Step(void);
- void QDCT_HTuiLT_Step(void);
- void QDCT_XiaQieAction(void);
- void QDCT_AlarmProtect(void);
- void QDCT_QZLT_Step(void);
- void QDCT_HZLT_Step(void);
- void QDCT_TuiLian(void);
- void QDCT_TuiLianAction(void);
- void QDCT_HeMo_Step(void);//装拉头完成合模动作
- void QDCT_TestMotor(void);
- void QDCT_ExtiActionX31(void)
- {
-
-
- }
- void QDCT_SeBiaoAction(void)
- {
- if(QDCT_SEBIAO_IN_DW)
- {
- if(cSeBiaoEn && !cSeBiaoOk)
- {
- cSeBiaoEn = 0;
- cSeBiaoOk = 1;
- if(QDCT_XM_OUT)
- {
- AxisChangeSpeedDirect(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED);
- }
- //user_datas[126] = dwXRealPos;
- cDinWeiPos = dwXRealPos;
- }
- }
- }
- //故障报警
- void QDCT_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(QDCT_ALARM_ADDR,alarm_code);
- if(alarm_code != QDCT_KD_ALARM)
- QDCT_bAlarmStop = 1;
- }
- //初始化动作
- void QDCT_InitAction(void)
- {
- float buff_pulse,buff_dist;
-
- buff_pulse = QDCT_PARAM_CYCLE_PULSE;
- buff_dist = QDCT_PARAM_CYCLE_LENGTH;
- XGearRatio = buff_pulse/buff_dist;
-
- buff_pulse = QDCT_PARAM_YLCYCLE_PULSE;
- buff_dist = QDCT_PARAM_YLCYCLE_LENGTH;
- YGearRatio = buff_pulse/buff_dist;
-
- //QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- SetEnReverse(X_AXIS, 0);
- SetEn(X_AXIS, QDCT_MOTOR_DISEN);
- SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
- QDCT_QZDPStep= 1;
- QDCT_HZDPStep= 1;
- QDCT_TLPStep = 1;
- cWorkCnt = 0;
- cZhaCnt = 0;
- dwZipCnt = 0;
- cBackLimitCheck_EN = 1;
- if(QDCT_PARAM_MAX_BACK_LENGTH < 13000) QDCT_PARAM_MAX_BACK_LENGTH = 25000;
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_NO_ALARM);
- SetDirReverse(X_AXIS, 0);
-
- //设置加减速模式
- //axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,QDCT_SEBIAO_LOW_SPEED);
- }
- void QDCT_Action(void)
- {
- //设置加减速模式
- //axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,QDCT_SEBIAO_LOW_SPEED);
- //InputPinConfig();
- QDCT_SeBiaoAction();
- QDCT_TuiLian();
- QDCT_AlarmProtect();
- QDCT_QZhenDongAction();
- QDCT_HZhenDongAction();
- QDCT_CheckStart();
- QDCT_QZLT_Step();
- QDCT_HZLT_Step();
- QDCT_TableAction();
- QDCT_QTuiLT_Step();
- QDCT_HTuiLT_Step();
- QDCT_JiaLianAction();
- QDCT_XiaQieAction();
- QDCT_Motor();
- QDCT_ManualAction();
- QDCT_AutoStepAction();
- QDCT_HeMo_Step();
- QDCT_TestMotor();
- //OutputPinConfig();
- }
- unsigned char cTestMotorStep;
- unsigned long cTesttime;
- void QDCT_TestMotor(void)
- {
- switch(cTestMotorStep)
- {
- //1到10步为回到原点
- case 1:
- //QDCT_SZ_OUT = QDCT_MOTOR_EN; //锁轴
- SetEn(X_AXIS, QDCT_MOTOR_EN);
- QDCT_TestMotorDelay = dwTickCount + 50;
- cTestMotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= QDCT_TestMotorDelay)//锁轴时间到
- {
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_GO_LOWSPEED, QDCT_DIR_N,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,10,10);
- cTestMotorStep= 3;
- }
- break;
- case 3: //回到原点
- if(QDCT_GO_LIMIT_IN) //最前点感应
- {
- AxisEgmStop(X_AXIS);
- QDCT_TestMotorDelay = dwTickCount + 50;
- cTestMotorStep= 4;
- SetPos(X_AXIS, 0);
- }
- break;
- case 4:
- if(!X_DRV)
- {
- QDCT_TestMotorDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
- cTestMotorStep= 5;
- }
- break;
- case 5:
- if(dwTickCount >= QDCT_TestMotorDelay)
- {
- if(1)//QDCT_bTest)
- {
- QDCT_bTest = 0;
- cTestMotorStep= 6;
-
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_SET_ZIPPER_LENGTH,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,100);
- // AxisMovePointAccDec(unsigned short axis,unsigned short speed,long pos,unsigned short start_speed,unsigned short acc_pulse,unsigned short dec_pulse)
- // AxisMovePoint(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-QDCT_PARAM_SET_ZIPPER_LENGTH);
- cTesttime = dwTickCount;
- }
- }
- break;
- case 6:
- if(!X_DRV)
- {
- QDCT_TestMotorDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
- cTestMotorStep= 7;
- }
- break;
- case 7:
- if(dwTickCount >= QDCT_TestMotorDelay)
- {
- if(1)//QDCT_bTest)
- {
- QDCT_bTest = 0;
- cTestMotorStep= 8;
- // MoveAction_Pulse2_AccDec(X_AXIS,PosToPulse(X_AXIS,-(QDCT_PARAM_SET_ZIPPER_LENGTH)),PosToPulse(X_AXIS,-QDCT_PARAM_SET_ZIPPER_LENGTH/2),PosToPulse(X_AXIS,-QDCT_PARAM_SET_ZIPPER_LENGTH/2),5,5,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- // AxisMove(X_AXIS,QDCT_PARAM_JJGO_SPEED,-(QDCT_PARAM_SET_ZIPPER_LENGTH-600),QDCT_PARAM_JJGO_SPEED/2,-600,QDCT_DIR
- // AxisMovePos(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_SET_ZIPPER_LENGTH);
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-QDCT_PARAM_SET_ZIPPER_LENGTH,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,500);
- // AxisMovePointAccDec(unsigned short axis,unsigned short speed,long pos,unsigned short start_speed,unsigned short acc_pulse,unsigned short dec_pulse)
- // AxisMovePoint(X_AXIS,QDCT_PARAM_JJGO_SPEED,0);
- cTesttime = dwTickCount;
- }
- }
- break;
- case 8:
- if(!X_DRV)
- {
- // if(dwXRealPos <= (QDCT_PARAM_SET_ZIPPER_LENGTH/2))
- // {
- // MoveChangSpeed(X_AXIS,5);
- cTestMotorStep= 4;
- // }
- }
- break;
- }
- }
- //
- void QDCT_TuiLian(void)
- {
-
- if(cQDCT_TuiLianOKFlag && (QDCT_YD_OUT && QDCT_SL_OUT))
- {
- QDCT_TuiLianStep = 0;
- return;
- }
- switch(QDCT_TuiLianStep)
- {
- case 0:
- break;
- case 1:
- QDCT_TuiLianStep = 2;
- QDCT_YD_OUT = 1;
- break;
- case 2:
- QDCT_TLDelay = dwTickCount+QDCT_PARAM_DELAY_SL;
- QDCT_TuiLianStep = 3;
- break;
- case 3:
- if(dwTickCount >= QDCT_TLDelay)
- {
- if(QDCT_PARAM_XM_MODE) QDCT_SL_OUT = 1;
- QDCT_TLDelay = dwTickCount;
- QDCT_TuiLianStep = 4;
- cQDCT_TuiLianOKFlag = 1;
- }
- break;
- case 4:
- if(dwTickCount >= QDCT_TLDelay)
- {
- QDCT_TuiLianStep = 0;
- }
- break;
- }
- }
- //前振动
- void QDCT_QZhenDongAction(void)
- {
- switch(QDCT_QZDPStep)
- {
- case 1:
- if((dwTickCount >= QDCT_QZhenDongDelay))
- {
- if(!QDCT_PARAM_QLT_ON && bRunning)
- {
- QDCT_QZDP_OUT = 0;
- QDCT_QZDPStep = 0;
- }
- else
- {
- if(!QDCT_QZDP_IN)
- {
- QDCT_QZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_DELAY_WORK;
- QDCT_QZDPStep = 2;
- }
- else
- {
- QDCT_QZDP_OUT = 0;
- }
- }
- }
- break;
- case 2:
- if((dwTickCount >= QDCT_QZhenDongDelay))
- {
- QDCT_QZDP_OUT = 1;
- if(QDCT_QZDP_IN)
- {
- QDCT_QZDPStep = 3;
- QDCT_QZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_WORK_TIME;
-
- }
- }
- break;
- case 3:
- if((QDCT_QZDPStep == 3) && (dwTickCount >= QDCT_QZhenDongDelay))
- {
- if(QDCT_QZDP_IN)
- {
- QDCT_QZDPStep = 1;
- QDCT_QZDP_OUT = 0;
- }
- else
- {
- QDCT_QZDPStep = 2;
- }
- }
- break;
- }
- //打拉片,两个共用一个盘
- if((QDCT_TLPStep == 1) && (dwTickCount >= QDCT_TLPDelay))
- {
- if((QDCT_QZDP_OUT | QDCT_HZDP_OUT) && QDCT_PARAM_TLP_ENABLE)
- {
- QDCT_TLPStep = 2;
- QDCT_TLPDelay = dwTickCount + QDCT_PARAM_TLP_TIME;
- QDCT_TLP_OUT = 1;
- }
- }
- else if((QDCT_TLPStep == 2) && (dwTickCount >= QDCT_TLPDelay))
- {
- QDCT_TLPStep = 1;
- QDCT_TLPDelay = dwTickCount + QDCT_PARAM_TLP_TIME;
- QDCT_TLP_OUT = 0;
- }
-
- if(QDCT_QZDP_OUT || QDCT_HZDP_OUT)
- {
- QDCT_ZDPCQ_OUT = 1;
- }
- else
- {
- QDCT_ZDPCQ_OUT = 0;
- }
- }
- //后振动盘
- void QDCT_HZhenDongAction(void)
- {
- switch(QDCT_HZDPStep)
- {
- case 1:
- if((dwTickCount >= QDCT_HZhenDongDelay))
- {
- //后拉头使能
- if(!QDCT_PARAM_HLT_ON && bRunning)
- {
- QDCT_HZDP_OUT = 0;
- QDCT_HZDPStep = 0;
- }
- else
- {
- if(!QDCT_HZDP_IN)
- {
- QDCT_HZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_DELAY_WORK;
- QDCT_HZDPStep = 2;
- }
- else
- {
- QDCT_HZDP_OUT = 0;
- }
- }
- }
- break;
- case 2:
- if((dwTickCount >= QDCT_HZhenDongDelay))
- {
- QDCT_HZDP_OUT = 1;
- if(QDCT_HZDP_IN)
- {
- QDCT_HZDPStep = 3;
- QDCT_HZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_WORK_TIME;
- }
- }
- break;
- case 3:
- if((dwTickCount >= QDCT_HZhenDongDelay))
- {
- if(QDCT_HZDP_IN)
- {
- QDCT_HZDPStep = 1;
- QDCT_HZDP_OUT = 0;
- }
- else
- {
- QDCT_HZDPStep = 2;
- }
- }
- break;
- }
- }
- void QDCT_AlarmProtect(void)
- {
- static unsigned short ka_dai_cnt;
- dwXRealPos = GetPos(X_AXIS);
- dwYRealPos = GetPos(Y_AXIS);
-
- if(QDCT_PARAM_BACK_ALARM_MODE)
- { //感应后限模式
- if(!bRunning)
- {
- if(QDCT_BACK_LIMIT_IN_UP)
- {
- if(X_DRV && (QDCT_bMotorBack) || (QDCT_MotorStep != 0)) //到后限不能再后退但可以点前进
- {
- QDCT_bMotorBack = 0;
-
- AxisEgmStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 1;
- }
- }
- }
- else
- {
- if(QDCT_BACK_LIMIT_IN)
- {
- if((dwTickCount >= QDCT_MotorBackLimitDelay) && cBackLimitCheck_EN && X_DRV)
- {
- AxisEgmStop(X_AXIS);
-
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- }
- }
- else
- {
- QDCT_MotorBackLimitDelay = dwTickCount + 30;
- }
- }
- }
- else //软件限位
- {
-
- }
-
- if(QDCT_KA_DAI_IN)
- {
- if(ka_dai_cnt < 110)ka_dai_cnt++;
- }
- else
- {
- ka_dai_cnt = 0;
- // if(GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_KD_ALARM)QDCT_SetAlarmCode(QDCT_NO_ALARM);
- }
- if(ka_dai_cnt > 100)
- {
- QDCT_YD_OUT = 0;
- if(bRunning)
- {
- QDCT_SetAlarmCode(QDCT_KD_ALARM);
- if(KaDaiFlag==0)
- {
- KaDaiSaveLen = dwXRealPos;
- KaDaiSaveLenY = dwYRealPos;
- KaDaiFlag = 1;
- }
- }
- }
-
- }
- void QDCT_JiaLianAction(void)
- {
- switch(QDCT_JiaLianStep)
- {
- case 1:
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_JD_DELAY;
- QDCT_JiaLianStep = 2;
- break;
- case 2:
- if(dwTickCount >= QDCT_JD_Delay)
- {
- QDCT_JD_OUT = 1;
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_DELAY_KL;
- QDCT_JiaLianStep = 3;
- }
- break;
- case 3:
- if((dwTickCount >= QDCT_JD_Delay))
- {
- if(!QDCT_PARAM_QLT_ON && !QDCT_PARAM_HLT_ON)
- {
- QDCT_JD_Delay = dwTickCount;
- QDCT_YD_OUT = 0;
- QDCT_JiaLianStep = 4;
- }
- else
- {
- QDCT_CQ_OUT = 1;
- //QDCT_KL_OUT = 1;
- QDCT_CQDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
- QDCT_JD_Delay = dwTickCount;
- QDCT_JiaLianStep = 4;
- }
- }
- break;
- case 4:
- if(dwTickCount >= QDCT_JD_Delay)
- {
- //QDCT_KL_OUT = 0;
- QDCT_JiaLianStep = 0;
- }
- break;
- }
- }
- unsigned char QDCT_CheckLength(void)
- {
- //无限长度
- if(QDCT_LONG_LENGTH_USE)
- {
- if(QDCT_PARAM_SET_ZIPPER_LENGTH > QDCT_PARAM_TRANS_LENGTH)
- return 1;
- else
- return 0;
- }
- else
- return 0;
- }
- //自动动作
- void QDCT_AutoStepAction(void)
- {
- static unsigned char jz_over;
-
- if(bRunning)
- {
- switch(QDCT_AutoStep)
- {
- case 1:
- jz_over = 0;
- QTryCnt = 0;
- cChuan_Lian_ErrorNum = 0;
- QDCT_AutoStep = 2;
- if(QDCT_QZDPStep == 0 && !QZDPAutoDisable)
- QDCT_QZDPStep = 1;
- if(QDCT_HZDPStep == 0 && !HZDPAutoDisable)
- QDCT_HZDPStep = 1;
- QDCT_AutoDelay = dwTickCount + 5;
- if(!QZhuangLiaoOkFlg)
- QDCT_QZhuangLiaoStep = 1;//前装料
- if(!HZhuangLiaoOkFlg)
- QDCT_HZhuangLiaoStep = 1;//后装料
- cSL_En = 2; //第一条可不受限制横送料
-
- break;
- case 2:
- if((QDCT_MotorStep == 0))
- {
- cSL_En = 2; //第一条可不受限制横送料
- if(dwTickCount >= QDCT_AutoDelay)
- {
- QDCT_AutoStep = 3;
- SetAlarmCode(QDCT_ALARM_ADDR,0);
- }
- user_datas[122]=0;
- }
- break;
- case 3:
- if(QDCT_MotorStep == 0)
- {
- QDCT_MotorStep = 61; //前进定位好后自动夹链和开链
-
- QDCT_AutoStep = 4;
- cBackLimitCheck_EN = 0;
- }
- break;
- case 4:
- //考虑第一条电机在前点要退出来,第二条后也不可能在前点,不能合模
- if(!QDCT_GO_LIMIT_IN || QDCT_JD_OUT)
- QDCT_AutoStep = 9;
- break;
- case 5:
- QDCT_AutoStep = 9;
- break;
- case 6:
- QDCT_AutoStep = 7;
- break;
- case 7:
- QDCT_AutoStep = 8;
- break;
- case 9:
- if(((QDCT_GO_LIMIT_IN || dwZipCnt) && !QDCT_PARAM_HM_MODE)
- || ((QDCT_MotorStep == 68 || QDCT_MotorStep == 0) && QDCT_PARAM_HM_MODE)) //第一条要到前限位才能合模
- {
- if((cCheckDinWei == 0) && (QDCT_PARAM_QLT_ON || QDCT_PARAM_HLT_ON))
- {
- QDCT_HeMoStep = 1;
- QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- }
- QTryCnt = 0;
- QDCT_AutoStep = 10;
- }
- break;
- case 10:
- if((QDCT_MotorStep == 0) && (QDCT_HeMoStep == 0)) //前定位完成,QDCT_GO_LIMIT_IN也肯定有信号
- {
- cXiaMo_En = 0;
- QDCT_AutoStep = 11;
- cCheck_Go_In_Flag = 1;
- }
- break;
-
- case 11:
- if((QDCT_MotorStep == 0)) //开始后拉穿入
- {
- cBackLimitCheck_EN = 1;
- if(QDCT_SEBIAO_MODE) //色标模式
- {
- QDCT_MotorStep = 1;
- }
- else
- {
- QDCT_MotorStep = 30;//穿入启动
- }
- cSL_En = 0; //不受限制横送料
- cChuan_LianCheckOK = 0;
- QDCT_AutoStep = 12;
- }
- break;
-
- case 12:
-
- if(((QDCT_MotorStep == 0) || (QDCT_MotorStep == 40)) && !X_DRV)
- {
- QDCT_AutoStep = 13;
-
- }
- break;
-
- case 13:
-
- if(QDCT_CheckLength()) //判断长度转换压轮电机拖带
- {
- QDCT_AutoStep = 50;
- }
- else
- {
- if(LengthType==0)
- QDCT_AutoStep = 14;
- else
- QDCT_AutoStep = 15;
- }
- break;
- case 14:
- if((QDCT_XiaQieStep == 0))
- {
- QDCT_XiaQieStep = 1;
- cSL_En = 0; //下切时只横送不能锁紧拉头
- QDCT_AutoStep = 15;
- }
- break;
- case 15://拖带完成
- if(!X_DRV && !Y_DRV)
- {
- if(((QDCT_XiaQieStep == 0) || (QDCT_XiaQieStep == 7)) && !QDCT_SQ_LIMIT_IN && (!QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE))
- {
- if(QDCT_MotorStep == 0)
- {
- if(jz_over)//无限长方式由压轮带出拉链
- {
- jz_over = 0;
- QDCT_MotorStepY = 160;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_YL_SL_DELAY;
- }
- else
- QDCT_MotorStep = 80;
- QDCT_AutoStep = 16;
- }
- }
- }
- break;
- /**/
- case 16:
- if((QDCT_MotorStep == 0) && (QDCT_CheckLength()==0 || QDCT_MotorStepY==0 || QDCT_MotorStepY==162 || QDCT_MotorStepY==163))
- {
- cXiaMo_En= 1;
- cSL_En = 2; //横送料打开
- if(bStartOnceTime)
- {
- bStartOnceTime = 0;
- SingOneFlg = 1;
- }
- if((QDCT_CHUAN_LIAN_CHECK_SELECT == 0) || (!QDCT_PARAM_QLT_ON && !QDCT_PARAM_HLT_ON) || cChuan_LianCheckOK)
- {
- CalProSP(QDCT_SPEED_ADDR); //计算生产速度
- if(cCheckDinWei == 0)
- {
- AddToTal(QDCT_TOTAL_ADDR); //生产总量加1并保存
- AddToTal(QDCT_NOWTOTAL_ADDR); //生产总量加1并保存
- cWorkCnt++;
- cZhaCnt++;
-
- QDCT_PARAM_TB_CNT1++;
- QDCT_PARAM_TB_CNT2++;
- cChuan_Lian_ErrorNum = 0;
- if(GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_CLOK_ALARM)
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_NO_ALARM);
- }
- else
- {
- SingOneFlg = 1;
- }
- cCheckDinWei = 0;
- if(dwZipCnt < 3)
- dwZipCnt++;
- }
- else
- {
- cChuan_Lian_ErrorNum++;
-
- if(cChuan_Lian_ErrorNum >= 1)
- {
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_CLOK_ALARM);
- if(cChuan_Lian_ErrorNum >= 2)
- SingOneFlg = 1;
- }
- }
- if(QDCT_PARAM_TB_CNT1 >= QDCT_PARAM_TABLE_NUM)
- {
- QDCT_TB_OUT = 1;
- QDCT_PARAM_TB_CNT1 = 0;
- //QDCT_PARAM_TB_CNT2 = 0;
- QDCT_TableDelay = dwTickCount + QDCT_PARAM_TABLE_TIME;
- }
- if((GetTotal(QDCT_TOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR)) && (GetTotal(QDCT_SETTOTAL_ADDR) != 0))
- {
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_TOTAL_ALARM);
- SingOneFlg = 1;
- QDCT_AutoStep = 17;
- }
- else
- {
- QDCT_AutoStep = 17;
- }
- }
- break;
- case 17:
- if(GetTotal(QDCT_NOWTOTAL_ADDR) >= QDCT_ZHA_NO) //扎数到
- {
-
- //扎数到了,台面输出
- QDCT_TB_OUT = 1;
- QDCT_PARAM_TB_CNT1 = 0;
- QDCT_TableDelay = dwTickCount + QDCT_PARAM_TABLE_TIME2;
-
- ClrcToTal(QDCT_NOWTOTAL_ADDR);
-
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
- if(( QDCT_ZHA_STOP_TIME > 0)) //扎数不能为0
- {
- if(QDCT_ZHA_NO > 0)
- {
- QDCT_AutoDelay = dwTickCount + QDCT_ZHA_STOP_TIME;
- dwZipCnt = 0;
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_ZHA_ALARM);
- }
- }
- else
- {
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_ZHA_ALARM);
- SingOneFlg = 1;
- }
- if(SingOneFlg)
- {
- SingOneFlg = 0;
- QDCT_AutoStep = 0;
- bRunning = 0;
- //QDCT_HHSL_OUT = 0;
- }
- else
- QDCT_AutoStep = 2;
- }
- else
- {
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
- //单条停止
- if(SingOneFlg)
- {
- SingOneFlg = 0;
- QDCT_AutoStep = 0;
- bRunning = 0;
- //QDCT_HHSL_OUT = 0;
- }
- else
- QDCT_AutoStep = 2;
- }
- break;
- case 50:
- if(GetEn(Y_AXIS) == QDCT_MOTOR_DISEN)
- {
- SetEn(Y_AXIS, QDCT_MOTOR_EN);
- }
- if(QDCT_SYL_OUT && !QDCT_SYL_ORIGIN_IN)
- {
- QDCT_AutoDelay = dwTickCount + 1;
- QDCT_AutoStep = 52;
- }
- else
- {
- QDCT_SYL_OUT = 1;
- QDCT_AutoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_AutoStep = 51;
- }
- break;
- case 51:
- if(!QDCT_SYL_ORIGIN_IN)
- {
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_DELAY;
- QDCT_AutoStep = 52;
- }
- else if(dwTickCount >= QDCT_AutoDelay)
- QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
- break;
- case 52:
- if(dwTickCount >= QDCT_AutoDelay)
- {
- QDCT_YL_OUT = 1;
- QDCT_AutoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_AutoStep = 53;
- }
- break;
- case 53:
- if(QDCT_YL_LIMIT_IN)
- {
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_DELAY;
- QDCT_AutoStep = 54;
- }
- else if(dwTickCount >= QDCT_AutoDelay)
- QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- break;
- case 54:
- if((dwTickCount >= QDCT_AutoDelay) && (QDCT_MotorStep == 0))
- {
- //QDCT_YL_DIR = QDCT_YL_DIR_N;
- jz_over = 1;
- QDCT_MotorStep = 150; //走松夹子
- if(!Y_DRV)//压轮电机动作
- AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH-QDCT_PARAM_TRANS_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_YL_SPEED/400,QDCT_PARAM_YL_SPEED/400,0);
- QDCT_AutoStep = 55;
- }
- break;
- case 55:
- if((dwTickCount >= QDCT_AutoDelay))
- {
- if(!Y_DRV && KaDaiFlag==0)
- {
- QDCT_AutoStep = 56;
- //QDCT_YL_DIR = QDCT_YL_DIR_P;
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_FZ_DELAY;
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(Y_DRV)
- AxisDecStop(Y_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH-QDCT_PARAM_TRANS_LENGTH-KaDaiSaveLenY),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_YL_SPEED/400,QDCT_PARAM_YL_SPEED/400,0);
- }
- else
- {
- KaDaiSaveLenY=dwYRealPos;
- }
- }
- }
- break;
- case 56:
- if((dwTickCount >= QDCT_AutoDelay))
- {
- if(!Y_DRV)AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SPEED,(-QDCT_PARAM_FZ_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,10,10,0);
- QDCT_AutoStep = 14;
- }
- break;
- //检测到拉链没有穿进去
- case 70:
- if((dwTickCount >= QDCT_AutoDelay)) //张开夹子
- {
- //检测到拉链没有穿入,进到第一个拉头处夹住出不计数
- QDCT_MotorStep = 200;
- QDCT_AutoStep = 71;
- }
- break;
- case 71:
- if(QDCT_MotorStep == 0)
- {
- QDCT_XM_OUT = 0; //下模退
- QDCT_QJLT_OUT = 0; //前后夹拉头退
- QDCT_HJLT_OUT = 0;
- QDCT_AutoDelay = dwTickCount + 40;
- QDCT_AutoStep = 72;
- }
- break;
- case 72:
- if((dwTickCount >= QDCT_AutoDelay)) //延时下切
- {
- if(cChuan_Lian_ErrorNum == 0)
- QDCT_AutoStep = 14;
- else
- QDCT_SetAlarmCode(QDCT_CLOK_ALARM);
- }
- break;
-
- }
- }
- }
- //台面电机动作
- void QDCT_TableAction(void)
- {
- if(QDCT_TB_OUT && (dwTickCount >= QDCT_TableDelay))
- QDCT_TB_OUT = 0;
- }
- void QDCT_CheckStart(void)
- {
- static unsigned char long_stop_flg = 0,yd_back_flg,sl_flg;
- static unsigned long long_time_delay,yd_back_delay,sl_delay,sl_delayStart,dw_Stop_In_Delay;
-
-
-
-
- QDCT_STATE_RUN = bRunning;
- if(GetAlarmCode(QDCT_ALARM_ADDR) == 0)
- QDCT_STATE_ERROR = 0;
- else
- QDCT_STATE_ERROR = 1;
-
- //启动 自动启动 单一自动
- if((QDCT_START_IN_UP || bStart || (QDCT_bOnceStart && !KaDaiFlag) || QDCT_bCheckDinWei))
- {
- if((dwTickCount >= sl_delayStart) && !bRunning)
- {
- if(QDCT_bOnceStart)
- {
- QDCT_bOnceStart = 0;
- bStartOnceTime = 1;
- dwZipCnt = 0;
- }
- bStart = 0;
-
- if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
- else if(QDCT_PARAM_SET_ZIPPER_LENGTH <500)QDCT_SetAlarmCode(QDCT_ZIPPER_LENGTH_ALARM);
- else if((QDCT_QLTCZ_IN || QDCT_HLTCZ_IN) && !QDCT_XM_OUT)QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
- else if(!QDCT_QHSL_ORIGIN_IN || !QDCT_HHSL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_GL_ORIGIN_ALARM);
- else if(QDCT_HHSL_LIMIT_IN || QDCT_QHSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_START_SL_LIMIT_ALARM);
- //else if(!QDCT_XQ_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_XQ_ORIGIN_ALARM);
- else if(!QDCT_XM_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_SM_ORIGIN_ALARM);
- else if(QDCT_XQ_LIMIT_IN && !QDCT_PARAM_XM_MODE)QDCT_SetAlarmCode(QDCT_XQ_LIMIT_ALARM);
- else if(QDCT_SQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- else if(QDCT_YL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- else if(!QDCT_SYL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
- else if(QDCT_KA_DAI_IN)QDCT_SetAlarmCode(QDCT_KD_ALARM);
- else if(QDCT_GO_LIMIT_IN && (QDCT_YD_OUT && ((QDCT_SL_OUT && QDCT_PARAM_XM_MODE) || !QDCT_PARAM_XM_MODE) || (GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_ZLT_ALARM)))
- {
- if(((GetAlarmCode(QDCT_ALARM_ADDR) == 0) || (GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_ZLT_ALARM)))
- {
- AxisEgmStop(X_AXIS);
- cCheckDinWei = QDCT_bCheckDinWei;
- bRunning = 1;
- cTuiLianStep = 0;
- yd_back_flg = 0;
- QDCT_AutoStep = 4;
- SetAlarmCode(QDCT_ALARM_ADDR,0);
- sl_flg = 0;
- QDCT_MotorStep = 66;
- cWorkCnt = 0;
- QTryCnt = 0;
- HTryCnt = 0;
- QTuiLaTouOkFlg = 1;
- HTuiLaTouOkFlg = 1;
- if(QDCT_QJLT_OUT)// 前夹拉头关
- {
- QZhuangLiaoOkFlg = 1;
- }
- else
- {
- QZhuangLiaoOkFlg = 0;
- QDCT_QZhuangLiaoStep = 1;
-
- }
- if(QDCT_HJLT_OUT)
- {
- HZhuangLiaoOkFlg = 1;
- }
- else
- {
- HZhuangLiaoOkFlg = 0;
- QDCT_HZhuangLiaoStep = 1;
- }
- HTuiLaTouOkFlg = 1;
- dwZipCnt = 0;
- cFirstQStartFlg = 1;
- cFirstHStartFlg = 1;
- if(!QZDPAutoDisable)
- QDCT_QZDPStep = 1;
- if(!HZDPAutoDisable)
- QDCT_HZDPStep = 1;
- QDCT_TLPStep = 1;
-
- SingOneFlg = 0;
- cCheck_Go_In_Flag = 1;
- cSL_En = 2;
- cXiaMo_En = 1;
- SetPos(X_AXIS, 0);
- cBackLimitCheck_EN = 1;
- if(QDCT_TB_OUT)
- QDCT_TableDelay = dwTickCount + 300;
- KaDaiFlag = 0;
- KaDaiSaveLen=0;
- KaDaiSaveLenY=0;
- }
- }
- else
- {
- if((GetAlarmCode(QDCT_ALARM_ADDR) == 0))
- {
- AxisEgmStop(X_AXIS);
- cCheckDinWei = QDCT_bCheckDinWei;
- cBackLimitCheck_EN = 1;
- bRunning = 1;
- yd_back_flg = 0;
- QDCT_AutoStep = 1;
- cWorkCnt = 0;
- QTryCnt = 0;
- HTryCnt = 0;
- QTuiLaTouOkFlg = 1;
- HTuiLaTouOkFlg = 1;
- dwZipCnt = 0;
- cFirstQStartFlg = 1;
- cFirstHStartFlg = 1;
- if(QDCT_QJLT_OUT)// 前夹拉头关
- {
- QZhuangLiaoOkFlg = 1;
- }
- else
- {
- QZhuangLiaoOkFlg = 0;
- QDCT_QZhuangLiaoStep = 1;
-
- }
- if(QDCT_HJLT_OUT)
- {
- HZhuangLiaoOkFlg = 1;
- }
- else
- {
- HZhuangLiaoOkFlg = 0;
- QDCT_HZhuangLiaoStep = 1;
- }
- if(!QZDPAutoDisable)
- QDCT_QZDPStep = 1;
- if(!HZDPAutoDisable)
- QDCT_HZDPStep = 1;
- QDCT_TLPStep = 1;
- SingOneFlg = 0;
- cCheck_Go_In_Flag = 1;
- cSL_En = 2;
- cXiaMo_En = 1;
- if(QDCT_TB_OUT)
- QDCT_TableDelay = dwTickCount + 300;
- KaDaiFlag = 0;
- KaDaiSaveLen=0;
- KaDaiSaveLenY=0;
- }
- }
- }
- QDCT_bCheckDinWei= 0;
- }
-
- if(cStopFlg == 1)
- {
- if(!X_DRV) cStopFlg = 0;
- }
-
- if(bStop)
- {
- SingOneFlg = 1;
- bStop = 0;
- }
- //停止
- if(QDCT_STOP_IN_UP && (dwTickCount >= dw_Stop_In_Delay))
- {
- //
- SingOneFlg = 0;
- if(bRunning)
- {
- dw_Stop_In_Delay = dwTickCount +50;
- //SetDecTime(X_AXIS,12) ;
- //SetDecTime(Y_AXIS,12) ;
- AxisDecStop(X_AXIS);
- AxisDecStop(Y_AXIS);
- bRunning = 0;
- QDCT_bOnceStart = 0;
- bStartOnceTime = 0;
- bStop = 0;
- QDCT_AutoStep = 0;
- //QDCT_QZhuangLiaoStep = 0;
- //QDCT_HZhuangLiaoStep = 0;
- QDCT_HeMoStep = 0;
- QDCT_MotorStep = 0;
- QDCT_JiaLianStep = 0;
- if(!QDCT_PARAM_CS_ENABLE)QDCT_XiaQieStep = 0;
- QDCT_ZhenDongStep = 0;
- QDCT_QTLTStep = 0;
- QDCT_HTLTStep = 0;
- ManFlg = 0;
- cBackLimitCheck_EN = 1;
- QDCT_MotorStepY = 0;
- QDCT_YL_OUT = 0;
- QDCT_SYL_OUT = 0;
- }
- else
- {
- if(!X_DRV)
- //QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- SetEn(X_AXIS, QDCT_MOTOR_DISEN);
- if(!Y_DRV)
- SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
-
- //SetDecTime(X_AXIS,12) ;
- //SetDecTime(Y_AXIS,12) ;
- AxisDecStop(X_AXIS);
- AxisDecStop(Y_AXIS);
- bRunning = 0;
- QDCT_bOnceStart = 0;
- bStop = 0;
- bStartOnceTime = 0;
- QDCT_AutoStep = 0;
- QDCT_QZhuangLiaoStep = 0;
- QDCT_HZhuangLiaoStep = 0;
- QDCT_MotorStep = 0;
- QDCT_JiaLianStep = 0;
- QDCT_XiaQieStep = 0;
- QDCT_ZhenDongStep = 0;
- QDCT_HeMoStep = 0;
-
- QDCT_QTLTStep = 0;
- QDCT_HTLTStep = 0;
- QDCT_SQ_OUT = 0;
- if(!QDCT_PARAM_XM_MODE)QDCT_XQ_OUT = 0;
-
- QDCT_XM_OUT = 0;
- QDCT_JD_OUT = 0;
- QDCT_QTLT_OUT = 0;
- QDCT_HTLT_OUT = 0;
- QDCT_QHSL_OUT = 0;
- //QDCT_KL_OUT = 0;
- QDCT_YL_OUT = 0;
- QDCT_SYL_OUT = 0;
- QDCT_CS_OUT = 0;
- KaDaiFlag = 0;
- KaDaiSaveLen=0;
- KaDaiSaveLenY=0;
-
- long_stop_flg = 1;
- long_time_delay = dwTickCount+1500;
-
- QDCT_HHSL_OUT= 0;
-
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_NO_ALARM);
- ManFlg = 0;
- cSL_En = 2;
- cXiaMo_En = 1;
- cBackLimitCheck_EN = 1;
- if((dwTickCount - QDCT_TableDelay) >= 1000)
- QDCT_TableDelay = dwTickCount + 300;
- QDCT_MotorStepSave=0;
- QDCT_MotorStepY = 0;
- }
- //测试停止
- cTestMotorStep = 0;
- }
-
- if(sl_flg)
- {
- if(dwTickCount >= sl_delay)
- {
- sl_flg = 0;
- if(QDCT_PARAM_XM_MODE) QDCT_SL_OUT = 0;
- sl_delayStart = dwTickCount+500;
- }
- }
-
- if(long_stop_flg)
- {
- if(dwTickCount >= long_time_delay)
- {
- if(QDCT_STOP_IN)
- {
- QDCT_QJLT_OUT = 0;
- QDCT_HJLT_OUT = 0;
- QDCT_YD_OUT = 0;
- if(QDCT_PARAM_XM_MODE) QDCT_SL_OUT = 0;
-
- }
- }
- else if(!QDCT_STOP_IN)
- {
- long_stop_flg = 0;
- }
- }
-
-
- if(QDCT_bAlarmStop)
- {
-
- bRunning = 0;
- QDCT_bOnceStart = 0;
- QDCT_bAlarmStop = 0;
- bStartOnceTime = 0;
- AxisDecStop(X_AXIS);
- AxisDecStop(Y_AXIS);
- QDCT_AutoStep = 0;
- QDCT_QZhuangLiaoStep = 0;
- QDCT_HZhuangLiaoStep = 0;
- QDCT_MotorStep = 0;
- QDCT_MotorStepY = 0;
- QDCT_JiaLianStep = 0;
- QDCT_ZhenDongStep = 0;
- if(!QDCT_QTLT_OUT)
- QDCT_QTLTStep = 0;
- if(!QDCT_HTLT_OUT)
- QDCT_HTLTStep = 0;
- ManFlg = 0;
- KaDaiFlag = 0;
- KaDaiSaveLen=0;
- KaDaiSaveLenY=0;
- if(GetAlarmCode(QDCT_ALARM_ADDR) != QDCT_ZLT_ALARM && !QDCT_JD_OUT)
- {
- if(QDCT_SL_OUT && QDCT_PARAM_XM_MODE)
- {
- QDCT_YD_OUT = 1;
- sl_flg = 1;
- sl_delay = dwTickCount+1000;
- }
- }
- }
- }
- unsigned long GetLength(long dist0,long dist1)
- {
- if(dist0 < dist1)
- return (dist1-dist0);
- else
- return (dist0-dist1);
- }
- //电机控制动作
- void QDCT_Motor(void) //
- {
- /*
- 1~5步追色标
- 30步开始后拉
- 61 前进定位
- 80步开始为切断后后拉松夹子
- 200步,进去一定位置夹废料
- */
- static long save_buff,length_buff,gou_zhen_buff,back_dec_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff,xm_delay_back;
- unsigned short start_speed;
-
- user_datas[127] = length_buff;
- qdct_length_buff = (short *)&QDCT_PARAM_OFFSET_LENGTH;
-
- if(!QDCT_NO_ZIPPER_CHECK_IN && bRunning)
- {
- QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
- }
- switch(QDCT_MotorStepY)//走链
- {
- case 160:
- if((dwTickCount >= QDCT_MotorYDelay) && !Y_DRV)
- {
- if(!Y_DRV)
- {
- AxisMovePosAccDec(Y_AXIS,QDCT_PARAM_YL_SL_SPEED,QDCT_PARAM_YL_SL_LENGTH,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_YL_SL_SPEED/400,QDCT_PARAM_YL_SL_SPEED/400,0);
- //user_datas[123]++;
- }
- QDCT_MotorYDelay = dwTickCount + QDCT_PARAM_YL_BACK_DELAY;
- QDCT_MotorStepY = 161;
- }break;
- case 161:
- if(dwTickCount >= QDCT_MotorYDelay)QDCT_YL_OUT = 0;
- if(!Y_DRV)
- {
- QDCT_YL_OUT = 0;
- QDCT_MotorYDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStepY = 162;
- }
- break;
- case 162:
- if(!QDCT_YL_LIMIT_IN)
- {
- QDCT_SYL_OUT=0;//送压轮退
- QDCT_MotorYDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStepY = 163;
- }
- else if(dwTickCount >= QDCT_MotorYDelay)
- QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- break;
- case 163:
- if(QDCT_SYL_ORIGIN_IN)
- {
- QDCT_MotorStepY = 0;
- SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
- }
- else if(dwTickCount >= QDCT_MotorYDelay)
- QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
- break;
- }
- switch(QDCT_MotorStep)
- {
- case 1:
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- QDCT_MotorStep = 2;
- QDCT_YD_OUT = 0;
- LengthType = 0;
- break;
- case 2:
- cSeBiaoOk = 0;
- cSeBiaoEn = 0;
- SetPos(X_AXIS,0);
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_buff = dwXRealPos;
- back_dec_buff = dwXRealPos;
- cSeBiaoOk = 0;
- cSeBiaoEn = 0;
- cChuan_LianCheckOK = 0;
- if(dwZipCnt>=1)
- {
- //夹子运动到模具位置时变为穿入速度
- if( QDCT_PARAM_Mold_Distance > 120)
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED*2,QDCT_PARAM_Mold_Distance,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,50);
- else
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED*2,QDCT_PARAM_Mold_Distance+10,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- else//第一条测长度
- {
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED,QDCT_DIR_P,
- QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- QDCT_MotorStep = 3;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- }
- break;
- case 3:
- //到拉链空位
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1)) //空位变慢
- {
- AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- QDCT_MotorStep = 7;
- break;
- }
-
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //如果穿入长度到
- if((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_MotorStep = 5;
- if(QDCT_PARAM_MODE) //反穿停电机
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- }
- else
- {
- QDCT_MotorDelay = dwTickCount;
- }
- QDCT_XM_OUT = 0;
- if(cCheckDinWei == 0)
- QDCT_QJLT_OUT = 0;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- break;
- }
- else if((dwXRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- }
-
- if(dwZipCnt>=1)
- {
- //如果慢速长度到,
- if(dwXRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH))
- {
- //拉链长度大于(模具长度 + 穿入长度)说明穿入部分还有拉链加速
- if(length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH > QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH)
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,QDCT_PARAM_PUTIN_LENGTH - QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
- else
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH-dwXRealPos,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
- }
- QDCT_MotorStep = 4;
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
-
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
-
- break;
- case 4:
- //到拉链空位
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1)) //空位变慢
- {
- AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- QDCT_MotorStep = 7;
- break;
- }
-
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //如果穿入长度到
- if((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_MotorStep = 5;
- if(QDCT_PARAM_MODE) //反穿停电机
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- }
- else
- {
- QDCT_MotorDelay = dwTickCount;
- }
- QDCT_XM_OUT = 0;
- if(cCheckDinWei == 0)
- QDCT_QJLT_OUT = 0;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- break;
- }
- else if((dwXRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
-
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
- break;
- case 5:
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1) ) //空位变慢
- {
- AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- QDCT_MotorStep = 7;
- break;
- }
- // //到达穿入长度位置
- if(dwTickCount>= QDCT_MotorDelay)
- {
- if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
- {
- if(cCheckDinWei == 0)
- {
- if(QDCT_PARAM_QLT_ON )//&& !QDCT_GO_LIMIT_IN)
- {
- QDCT_QJLT_OUT = 0;
- }
- }
- if(dwZipCnt>=1)
- {
- if(dwXRealPos+QDCT_SEBIAO_BACK_LSPEED_LENGTH+QDCT_SEBIAO_LENGTH+50 < length_buff)
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,length_buff-dwXRealPos-QDCT_SEBIAO_BACK_LSPEED_LENGTH-QDCT_SEBIAO_LENGTH,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
- else
- AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
- }
- else
- {
- if(!X_DRV)//反穿轴停的情况,要重新启动后拉
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED,QDCT_DIR_P,
- QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- QDCT_MotorStep = 6;
- }
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
-
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
- break;
- case 6:
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwXRealPos >= (length_buff -QDCT_SEBIAO_LENGTH - QDCT_SEBIAO_BACK_LSPEED_LENGTH) && dwZipCnt>=1) ) //空位变慢
- {
- AxisChangeSpeedDirect(X_AXIS,QDCT_SEBIAO_LOW_SPEED);
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- QDCT_MotorStep = 7;
- user_datas[129] = dwXRealPos;
- break;
- }
-
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
-
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
- break;
- case 7:
-
- if((cCheckDinWei == 0))
- {
- if(QDCT_XM_OUT)
- {
- if(dwXRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- QDCT_HJLT_OUT = 0;
- if(QDCT_PARAM_MODE) //反穿停电机
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- }
- else
- {
- QDCT_MotorDelay = dwTickCount;
- }
- QDCT_XM_OUT = 0;
- QDCT_QJLT_OUT = 0;
- }
- else if((dwXRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- }
- }
- else
- {
- if(dwTickCount >= QDCT_MotorDelay)
- {
-
- if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
- {
- if(QDCT_PARAM_QLT_ON )
- {
- QDCT_QJLT_OUT = 0;
- }
- if(!X_DRV && !KaDaiFlag)//反穿轴停的情况,要重新启动后拉
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED,QDCT_DIR_P,
- QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- }
- }
- }
-
- if(cSeBiaoOk)
- {
- if(cCheckDinWei == 0)
- {
- if(QDCT_XM_OUT)
- {
- if((dwXRealPos + 300) >= (cDinWeiPos + QDCT_SEBIAO_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- QDCT_HJLT_OUT = 0;
- if(QDCT_PARAM_MODE) //反穿停电机
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- }
- else
- {
- QDCT_MotorDelay = dwTickCount;
- }
- QDCT_XM_OUT = 0;
- if(cCheckDinWei == 0)
- QDCT_QJLT_OUT = 0;
- }
- else if((dwXRealPos + 400) >= (cDinWeiPos + QDCT_SEBIAO_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- }
- }
- else
- {
-
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
- {
- if(QDCT_PARAM_QLT_ON )
- {
- QDCT_QJLT_OUT = 0;
- }
- AxisMovePosAccDec(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,cDinWeiPos + QDCT_SEBIAO_LENGTH-dwXRealPos,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 8;
- }
-
- }
-
- }
-
- }
- }
- if(((dwXRealPos >= (cDinWeiPos + QDCT_SEBIAO_LENGTH )))&& cSeBiaoOk)
- {
- AxisEgmStop(X_AXIS);
- if(cCheckDinWei == 0)
- {
- if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
- {
- if(QDCT_PARAM_QLT_ON )
- {
- QDCT_QJLT_OUT = 0;
- }
-
- }
- }
- if((dwZipCnt >= 1) && QDCT_SEBIAO_ERROR_LENGHT && (((dwXRealPos > (length_buff + QDCT_SEBIAO_ERROR_LENGHT))
- || dwXRealPos < (length_buff - QDCT_SEBIAO_ERROR_LENGHT))))
- {
- QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
- }
- else
- {
- QDCT_MotorStep = 9;
- //第一条保存长度
- if(dwZipCnt==0) length_buff = dwXRealPos;
- }
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 3;
- }
- break;
- case 8:
- if(((dwXRealPos >= (cDinWeiPos + QDCT_SEBIAO_LENGTH )))&& cSeBiaoOk || (!X_DRV && !KaDaiFlag))
- {
- AxisEgmStop(X_AXIS);
- if(cCheckDinWei == 0)
- {
- if(((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
- {
- if(QDCT_PARAM_QLT_ON )
- {
- QDCT_QJLT_OUT = 0;
- }
-
- }
- }
- if(QDCT_SEBIAO_ERROR_LENGHT && (((dwXRealPos > (QDCT_PARAM_SET_ZIPPER_LENGTH + QDCT_SEBIAO_ERROR_LENGHT))
- || dwXRealPos < (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_ERROR_LENGHT))))
- {
- QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
- }
- else
- {
- QDCT_MotorStep = 9;
- //第一条保存长度
- if(dwZipCnt==0) length_buff = dwXRealPos;
- }
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_SEBIAO_LOW_SPEED, QDCT_DIR_P,QDCT_SEBIAO_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 3;
- }
- break;
- case 9:
- QDCT_MotorStep = 0;
- break;
-
- case 30:
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- if(GetEn(X_AXIS) == QDCT_MOTOR_DISEN)
- {
- //QDCT_SZ_OUT = QDCT_MOTOR_EN;
- SetEn(X_AXIS, QDCT_MOTOR_EN);
- if(QDCT_PARAM_DELAY_BACK < 50)
- QDCT_MotorDelay = dwTickCount + 50;
- }
- QDCT_YD_OUT = 0; //压带
- QDCT_MotorStep = 31;
- cCheck_Go_In_Flag = 0;
- cChuan_LianCheckOK = 0;
- SetPos(X_AXIS,0);
- break;
- case 31:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- gou_zhen_buff = dwXRealPos;
- save_buff = dwXRealPos;
- back_buff = dwXRealPos;
- if((*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH) < 0)
- *qdct_length_buff = 0;
-
- //拉链长度小于刀口到模具距离加穿入长度,需要在切断后继续穿入
- if((*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH < QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH))
- {
- CutRemainLength = QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH - (*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH);
- LengthType = 1;
- }
- else
- {
- LengthType = 0;
- }
- if(QDCT_PARAM_PUTIN_LOW_SPEED < QDCT_PARAM_START_SPEED)
- start_speed = QDCT_PARAM_PUTIN_LOW_SPEED;
- else
- start_speed = QDCT_PARAM_START_SPEED;
-
- if(LengthType == 0)
- {
- if( QDCT_PARAM_Mold_Distance > 120)
- //夹子运动到模具位置时变为穿入速度
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED*2,QDCT_PARAM_Mold_Distance,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
- 10,10,50);
- else
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_Mold_Distance+10,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
- 10,10,0);
- QDCT_MotorStep = 33;
- }
- else//超短链
- {
- //拉链长度小于刀口到模具距离,走到拉链长度停
- if(*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH < QDCT_PARAM_Mold_Distance)
- {
- AxisMovePosAccDec(X_AXIS,start_speed*3,*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_PUTIN_LOW_SPEED,10,10,0);
- }
- else
- {
- AxisMovePosAccDecNotStop(X_AXIS,start_speed*3,QDCT_PARAM_Mold_Distance,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,10,10,0);
- }
- QDCT_MotorStep = 433;
- }
- cChuan_LianCheckOK = 0;
- }
- break;
-
- case 33:
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //下切刀提前输出
- if(!QDCT_GO_LIMIT_IN && !QDCT_PARAM_XM_MODE && !QDCT_PARAM_CS_ENABLE && (dwXRealPos >= QDCT_PARAM_Mold_Distance))
- QDCT_XQ_OUT = 1;
- //如果当前长度到达拉链长,最优先停
- if(dwXRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- QDCT_MotorStep = 35;
- break;
- }
- //如果穿入长度到也停止,开模
- if((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_MotorStep = 35;
- break;
- }
- //如果慢速长度到,
- if(dwXRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH))
- {
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- //穿入长度大于穿入慢速
-
- if(QDCT_PARAM_PUTIN_LENGTH > QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH)
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_PUTIN_LENGTH - QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 34;
-
- }
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
- break;
- case 34:
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //到达拉链长度要停止
- if(dwXRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- QDCT_MotorStep = 35;
- break;
- }
- //如果穿入长度到也停止,开模
- if((dwXRealPos + 8) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_MotorStep = 35;
- break;
- }
- else if((dwXRealPos + 80) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON && (cChuan_LianCheckOK || (QDCT_CHUAN_LIAN_CHECK_SELECT == 0)) && !QDCT_GO_LIMIT_IN)
- {
- QDCT_HJLT_OUT = 0;
- }
- }
-
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 5;
- }
- break;
- case 35:
- if(QDCT_PARAM_MODE)//反穿停
- {
- AxisEgmStop(X_AXIS);
- if(QDCT_PARAM_QLT_ON)
- {
- QDCT_QJLT_OUT = 0;
- }
- }
- else
- {
- AxisChangeSpeedDirect(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED/3);
- }
- if(QDCT_PARAM_HLT_ON && (cChuan_LianCheckOK || (QDCT_CHUAN_LIAN_CHECK_SELECT == 0)) && !QDCT_GO_LIMIT_IN)
- {
- QDCT_HJLT_OUT = 0;
- }
- QDCT_XM_OUT = 0;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- QDCT_MotorStep = 37;
- break;
- case 36:
- break;
- case 37:
- //两路顶针离开
- if(!QDCT_XM_OUT && ((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (!QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) ))
- {
- if(QDCT_PARAM_QLT_ON )
- {
- QDCT_QJLT_OUT = 0;
- }
-
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(dwXRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
- {
- if(QDCT_CheckLength())//无限长
- {
- if((QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- else//普通长
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- }
- QDCT_MotorStep = 38;
- }
- }
- else if(dwTickCount >= QDCT_MotorDelay+2000)
- {
- if((QDCT_QLTCZ_IN && QDCT_PARAM_QLT_ON) || (QDCT_HLTCZ_IN && QDCT_PARAM_HLT_ON))
- QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
-
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 6;
- }
- break;
- case 38:
- if(((dwXRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH + 400)) && (QDCT_PARAM_SET_ZIPPER_LENGTH > (dwXRealPos + 4000)))
- {
- cSL_En = 2;
- }
- if(QDCT_CheckLength() && !QDCT_YL_LIMIT_IN && !QDCT_GO_LIMIT_IN && dwXRealPos>=4000)
- {
- QDCT_SYL_OUT=1;//送压轮
- }
- if((!X_DRV && !KaDaiFlag) || (dwXRealPos>= QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- if(!QDCT_CheckLength())
- {
- QDCT_YD_OUT = 1;
- }
- QDCT_MotorStep = 390;
- QDCT_MotorDelay = dwTickCount+10;
- }
-
- //卡带处理,停止后可再次启动
- if(KaDaiFlag==1)
- {
- if(X_DRV)
- AxisDecStop(X_AXIS);
- else if(QDCT_bOnceStart && !QDCT_KA_DAI_IN)
- {
- QDCT_bOnceStart=0;
- bStartOnceTime = 1;
- KaDaiFlag=0;
- if(dwXRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
- {
- if(QDCT_CheckLength())//无限长
- {
- if((QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_TRANS_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- else//普通长
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwXRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwXRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- }
- }
- else
- {
- KaDaiSaveLen=dwXRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 6;
- }
- break;
- case 390:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(QDCT_PARAM_FZ_LENGTH != 0) //反转长度
- {
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,-QDCT_PARAM_FZ_LENGTH,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,10,10,0);
- }
- QDCT_MotorStep = 39;
- }
- break;
- case 39:
-
- if(!X_DRV)
- {
- if(!QDCT_CheckLength())
- {
- QDCT_YD_OUT = 1;
- }
- QDCT_MotorStep = 40;
- if(bRunning)
- {
- if(!QDCT_NO_ZIPPER_CHECK_IN)
- QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 7;
- }
- break;
- case 40:
- QDCT_MotorStep = 0;
- break;
-
- //超短链
- case 433:
-
- //如果当前长度到达拉链长,最优先停
- if(dwXRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 434;
- QDCT_MotorDelay = dwTickCount + 50;
- if(QDCT_PARAM_XM_MODE)
- {
- QDCT_SL_OUT = 0;//送带退
- }
- }
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 8;
- }
- break;
- case 434:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- //下切
- if((QDCT_XiaQieStep == 0) && (QDCT_SL_ORIGIN_IN || !QDCT_PARAM_XM_MODE))
- {
- QDCT_XiaQieStep = 1;
- cSL_En = 0; //下切时只横送不能锁紧拉头
- QDCT_MotorStep = 435;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- }
- }
- break;
- case 435:
- //下切完
- if(QDCT_XiaQieStep==0)
- {
- QDCT_YD_OUT = 0; //压带
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED,CutRemainLength,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_PUTIN_LOW_SPEED,10,10,0);
- QDCT_MotorStep = 436;
- }
- else if(dwTickCount >= QDCT_MotorDelay)
- {
- QDCT_SetAlarmCode(QDCT_XQ_ALARM);
- }
- break;
- case 436:
- if(dwXRealPos>= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH) || !X_DRV)
- {
- AxisEgmStop(X_AXIS);
- //下模和夹拉头打开
- QDCT_QJLT_OUT = 0; //夹拉头
- QDCT_HJLT_OUT = 0; //夹拉头
- QDCT_XM_OUT = 0; //拉头下模
- QDCT_MotorStep = 437;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 10;
- }
- break;
- case 437:
-
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //两路顶针离开
- if(!QDCT_XM_OUT && (!QDCT_QLTCZ_IN || !QDCT_PARAM_QLT_ON) && (!QDCT_HLTCZ_IN || !QDCT_PARAM_HLT_ON))
- {
- //结束
- QDCT_MotorStep = 40;
-
- }
- else if(dwTickCount >= QDCT_MotorDelay)
- {
- QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
- }
- if(bRunning)
- {
- if(!QDCT_NO_ZIPPER_CHECK_IN)
- QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 10;
- }
- break;
- case 80:
- jz_buff = dwXRealPos;
- if(QDCT_PARAM_SJZ_LENGTH == 0)
- {
- QDCT_JD_OUT = 0;
- }
- QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
- QDCT_MotorStep = 81;
- break;
- case 81:
- if(!QDCT_JD_OUT || (dwTickCount >= QDCT_MotorDelay))
- {
- if((QDCT_CHUAN_LIAN_CHECK_SELECT == 0) || cChuan_LianCheckOK)
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,15,15,50);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,(1000 + QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,15,15,50);
- QDCT_MotorStep = 82;
- }
- break;
- case 82:
- //松夹子长度
- if(((QDCT_PARAM_SJZ_LENGTH) <= (dwXRealPos - jz_buff)))
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
- else if(!X_DRV)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
-
- if(!QDCT_JD_OUT || (500 <= (dwXRealPos - jz_buff)))
- {
- cSL_En = 2;
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 13;
- }
- break;
- case 83: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QDCT_MotorStep = 0;
- QDCT_MotorDelay = dwTickCount;
- }
-
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 14;
- }
- break;
- case 61: // 前点定位数控模式
- QDCT_MotorDelay = dwTickCount;
- if((QDCT_JD_OUT && (!QDCT_GO_LIMIT_IN)) || (GetEn(X_AXIS) == QDCT_MOTOR_DISEN))
- {
- if(!QDCT_GO_LIMIT_IN)
- QDCT_JD_OUT = 0;
-
- if((GetEn(X_AXIS) == QDCT_MOTOR_DISEN))
- QDCT_MotorDelay = dwTickCount + 40;
- }
- //下模不动时要推链
- if(QDCT_PARAM_XM_MODE && !QDCT_SL_OUT && !QDCT_JD_OUT)
- QDCT_TuiLianStep = 1;
- //QDCT_SZ_OUT = QDCT_MOTOR_EN;
- SetEn(X_AXIS, QDCT_MOTOR_EN);
- QDCT_MotorStep = 62;
- break;
- case 62://电机锁轴时间到
- if(dwTickCount >= QDCT_MotorDelay)
- {
- //已经夹住并且在前点的条件,认为布带已经夹好
- if(QDCT_JD_OUT && QDCT_GO_LIMIT_IN)
- {
- QDCT_MotorStep = 67;
- }
- else{
- //前点亮的情况下要先后退离开
- if(QDCT_GO_LIMIT_IN )
- {
- //后退离开长度
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_START_SPEED, QDCT_DIR_P,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- 10,10);
- QDCT_MotorDelay = dwTickCount + 500;
- QDCT_MotorStep = 620;
- }
- else
- {
- QDCT_MotorStep = 63;
- QDCT_MotorDelay = dwTickCount;
- }
- QDCT_JD_OUT = 0;
- }
- }
- break;
- case 620:
- if(QDCT_GO_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);
- }
- else //后退离开长度
- {
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_START_SPEED,500,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- 10,10,0);
- QDCT_MotorStep = 63;
- QDCT_MotorDelay = dwTickCount + 500;
- }
- break;
- case 63:// 前进
- if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay) && QDCT_SYL_ORIGIN_IN)
- {
- go_buff = dwXRealPos;
-
- //不是第一次
- if(dwZipCnt > 0)
- {
-
- if(dwZipCnt == 5) //扎数到的启动
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJGO_SPEED/2,-(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,0);
- // AxisMoveTwoPosNoStop(X_AXIS,QDCT_PARAM_JJGO_SPEED/2,(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH-QDCT_PARAM_JJDINGWEI_LENGTH),
- // QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_GO_LOWSPEED_LENGTH-100,QDCT_DIR_N,
- // QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10);
- else
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJGO_SPEED,-(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH-QDCT_PARAM_JJDINGWEI_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE,0);
- // AxisMoveTwoPosNoStop(X_AXIS,QDCT_PARAM_JJGO_SPEED,(dwXRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH-QDCT_PARAM_JJDINGWEI_LENGTH),
- // QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_GO_LOWSPEED_LENGTH-100,QDCT_DIR_N,
- // QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10);
- QDCT_MotorStep = 65;
- QDCT_MotorDelay = dwTickCount + QDCT_MOTOR_ALARM_TIME;
- }//第一次
- else
- {
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_GO_LOWSPEED,QDCT_DIR_N,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- 15,15);
- QDCT_MotorDelay = dwTickCount + QDCT_MOTOR_ALARM_TIME;
- QDCT_MotorStep = 65;
- }
- }
- else if(dwTickCount >= QDCT_MotorDelay+3000)
- {
- if(!QDCT_SYL_ORIGIN_IN)
- QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
- }
- break;
- case 65:
- //碰到前点限位停止
- if(QDCT_GO_LIMIT_IN)
- {
- SetPos(X_AXIS, QDCT_PARAM_JJDINGWEI_LENGTH);
- QDCT_MotorStep = 66;
- dwXRealPos = GetPos(X_AXIS);
- user_datas[125]=GetCurSpeed(X_AXIS);
- AxisMovePosAccDec(X_AXIS,3000,-QDCT_PARAM_JJDINGWEI_LENGTH,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,5,5,0);
- }
- else if(dwTickCount >= QDCT_MotorDelay)
- QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- break;
- case 66:
- if(dwXRealPos <= 0 || !X_DRV) //位置到零点后停止
- {
- AxisEgmStop(X_AXIS);
- SetPos(X_AXIS, 0);
- QDCT_MotorStep = 67;
- }
- break;
- case 67:
- if(!X_DRV) //电机已经
- {
- QDCT_MotorDelay = dwTickCount;
- QDCT_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(QDCT_JiaLianStep == 0)
- {
- QDCT_JiaLianStep = 1;
- QDCT_MotorStep = 69;
- }
- }
- break;
- case 69:
- if(QDCT_JiaLianStep == 0)
- {
-
- QDCT_MotorStep = 0;
- if(bRunning == 0)
- {
- SetEn(X_AXIS, QDCT_MOTOR_DISEN); //手动下松轴方便手拉
- QDCT_YD_OUT = 0;
- }
- }
- break;
-
- case 150:
- jz_buff = dwXRealPos;
- QDCT_JD_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
- QDCT_MotorStep = 151;
- break;
- case 151:
- if(QDCT_JD_OUT || (dwTickCount >= QDCT_MotorDelay))
- {
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwXRealPos+QDCT_PARAM_CUT_BACK_LENGTH)
- {
- temppos = QDCT_PARAM_MAX_BACK_LENGTH-dwXRealPos-200;
- }
- else
- {
- temppos = QDCT_PARAM_CUT_BACK_LENGTH;
- }
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,temppos,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,15,15,0);
- QDCT_MotorStep = 152;
- }
- break;
- case 152:
- if(!X_DRV)
- {
- QDCT_MotorStep = 153;
- QDCT_MotorDelay = dwTickCount + 30;
- }
- break;
- case 153:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- jz_buff = dwXRealPos;
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJGO_SPEED,-(QDCT_PARAM_TRANS_LENGTH + temppos-3500),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 154;
- }
- break;
- case 154:
-
- if((!X_DRV))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 0;
- }
- break;
- //以下为夹子进去夹废料
- case 200:
- //QDCT_JJ_DIR = QDCT_JJ_DIR_P;
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_GO_LOWSPEED,dwXRealPos-350,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 201;
- break;
- case 201:
- if(!X_DRV)
- {
- QDCT_JD_OUT = 1;
- QDCT_MotorStep = 202;
- QDCT_MotorDelay = dwTickCount + 50;
- }
- break;
-
- case 202:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- QDCT_MotorStep = 0;
- }
- break;
- }
- }
- //切断动作
- void QDCT_XiaQieAction(void)
- {
- dwXRealPos = GetPos(X_AXIS);
- dwYRealPos = GetPos(Y_AXIS);
- user_datas[121] = dwXRealPos;// GetPos(Y_AXIS);//QDCT_HZhuangLiaoStep;//QDCT_AutoStep;
- //user_datas[122] = dwYRealPos;
- if(user_datas[122]<GetCurSpeed(X_AXIS))
- user_datas[122] = GetCurSpeed(X_AXIS);
- user_datas[123] = QDCT_MotorStep;
- user_datas[124] = QDCT_AutoStep ;
- //user_datas[125] = QZhuangLiaoOkFlg;//QDCT_XiaQieStep;//cChuan_LianCheckOK;
- user_datas[126] = GetCurSpeed(X_AXIS);
- //user_datas[127] = QDCT_HZhuangLiaoStep;
- //user_datas[128] = QDCT_MotorStepSave;//HZhuangLiaoOkFlg;//QDCT_HeMoStep;//tXAxisStepper.cPmovPulse;
-
- #if 1
-
- switch(QDCT_XiaQieStep)
- {
- case 1:
- if(bRunning)
- {
- if(!QDCT_NO_ZIPPER_CHECK_IN)
- {
- QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
- }
- }
- if(QDCT_GO_LIMIT_IN )
- {
-
- QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
- QDCT_XiaQieStep = 0;
- }
- else
- {
- QDCT_XiaQieStep = 2;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUT_DELAY;
- }
-
- break;
- case 2:
- if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_XiaQieStep = 3;
- QDCT_YD_OUT = 1;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- if(!QDCT_PARAM_XM_MODE)// && !QDCT_PARAM_CS_ENABLE)
- {
- QDCT_XQ_OUT = 1;
- }
- }
- break;
- case 3:
- if(QDCT_XQ_LIMIT_IN || QDCT_PARAM_CS_ENABLE)//|| QDCT_PARAM_XM_MODE )//|| QDCT_PARAM_CS_ENABLE)
- {
- QDCT_XiaQieDelay = dwTickCount;
- QDCT_XiaQieStep = 4;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_XQ_ALARM);
- QDCT_XiaQieStep = 0;
- }
- break;
- case 4:
- if(dwTickCount >= QDCT_XiaQieDelay)
- {
- if(!QDCT_SL_ORIGIN_IN && QDCT_PARAM_XM_MODE)
- QDCT_SetAlarmCode(QDCT_SL_ORIGIN_ALARM);
- else
- {
- QDCT_SQ_OUT = 1; //上切刀输出
- if(!QDCT_PARAM_XM_MODE)QDCT_XQ_OUT = 1;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_XiaQieStep = 5;
- }
- }
- break;
- case 5:
-
- //上下切刀到位
- if(QDCT_SQ_LIMIT_IN && (QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE))
- {
- cQDCT_TuiLianOKFlag = 0;
- if(QDCT_PARAM_CS_ENABLE)
- {
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_DELAY;
- QDCT_XiaQieStep = 50; //跳到超声处理
- }
- else
- {
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUTBACK_DELAY;
- QDCT_XiaQieStep = 6;
- }
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- if(!QDCT_SQ_LIMIT_IN)
- {
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- QDCT_XiaQieStep = 0;
- }
- else if(QDCT_PARAM_XM_MODE== 0) // 下模动才警告下模
- {
- QDCT_SetAlarmCode(QDCT_XQ_ALARM);
- QDCT_XiaQieStep = 0;
- }
- }
- break;
- case 6:
- if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SQ_OUT = 0;
- if(!QDCT_PARAM_XM_MODE)QDCT_XQ_OUT = 0;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_XiaQieStep = 7;
- }
- break;
- case 7:
- if(!QDCT_SQ_LIMIT_IN && (!QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE))
- {
- //下模动
- if(QDCT_PARAM_XM_MODE && !QDCT_SL_OUT && !bRunning)
- QDCT_TuiLianStep = 1;
- QDCT_XiaQieStep = 0;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_XiaQieStep = 0;
- if(QDCT_SQ_LIMIT_IN) QDCT_SetAlarmCode(QDCT_SQ_ORIGIN_ALARM);
- else if(QDCT_XQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_XQ_ALARM);
- }
- break;
- case 50:
- if(dwTickCount >= QDCT_XiaQieDelay)
- {
- // if(QDCT_PARAM_CS_CONTROL)
- QDCT_CS_OUT = 1;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_TIME;
- QDCT_XiaQieStep = 51;
- }
- break;
- case 51:
- if((dwTickCount >= QDCT_XiaQieDelay))
- {
- QDCT_CS_OUT = 0;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_COLD_TIME;
- QDCT_XiaQieStep = 6;
- }
- break;
- }
- #endif
- }
- //装拉头完成合模动作
- void QDCT_HeMo_Step(void)
- {
- switch(QDCT_HeMoStep)
- {
- case 0:
- break;
- case 1:
- if(QZhuangLiaoOkFlg && HZhuangLiaoOkFlg && (QDCT_QZhuangLiaoStep == 0) && (QDCT_HZhuangLiaoStep == 0))
- {
- // 前横送输出 前限位 前横送输出 前夹拉头 后横送输出 后夹拉头
- if(!QDCT_QHSL_OUT && (QDCT_GO_LIMIT_IN || cXiaMo_En)&& QDCT_QJLT_IN && !QDCT_HHSL_OUT && QDCT_HJLT_IN)
- {
- QDCT_XM_OUT = 1; //下模输出
- QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HeMoStep = 2;
- QDCT_QZhuangLiaoStep = 0;
- QDCT_HZhuangLiaoStep = 0;
- }
- else if(dwTickCount >= QDCT_HeMoDelay)
- {
- if(!QDCT_HJLT_IN)
- {
- QDCT_SetAlarmCode(QDCT_HJLT_ALARM);
- }
- else if(!QDCT_QJLT_IN)
- {
- QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- }
- else if(!QDCT_GO_LIMIT_IN)
- {
- QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
- }
- else if(QDCT_QHSL_OUT || QDCT_HHSL_OUT)
- {
- QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
- }
- }
- }
- break;
- case 2:
- if(QDCT_XM_LIMIT_IN) //下模到位
- {
- QDCT_HeMoStep = 3;
- QDCT_HeMoDelay = dwTickCount + 100;
- }
- else if(dwTickCount >= QDCT_HeMoDelay)
- {
- QDCT_SetAlarmCode(QDCT_XM_LIMIT_ALARM);
- }
- break;
- case 3:
- //两个顶针信号或调试模式
- if((QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) && (QDCT_HLTCZ_IN || (!QDCT_PARAM_HLT_ON)) )
- {
- QTryCnt = 0;
- HTryCnt = 0;
- cHemo_OK = 1;
- QDCT_HeMoStep = 0;
- }
- else if(dwTickCount >= QDCT_HeMoDelay)
- {
- if(bRunning)
- {
- QTryCnt++;
- QDCT_HeMoStep = 4;
- if(QTryCnt >= 4)
- {
- SetAlarmCode(QDCT_ALARM_ADDR,QDCT_ZLT_ALARM);
- cHemo_OK = 0;
- if(!QDCT_QLTCZ_IN && QDCT_PARAM_QLT_ON)
- {
- QZhuangLiaoOkFlg = 0;
- QDCT_QJLT_OUT = 0;
- }
- if(!QDCT_HLTCZ_IN && QDCT_PARAM_HLT_ON)
- {
- HZhuangLiaoOkFlg = 0;
- QDCT_HJLT_OUT = 0;
- }
- }
- else
- {
- if(!QDCT_QLTCZ_IN && QDCT_PARAM_QLT_ON)
- QZhuangLiaoOkFlg = 0;
- if(!QDCT_HLTCZ_IN && QDCT_PARAM_HLT_ON)
- HZhuangLiaoOkFlg = 0;
- }
- }
- }
- break;
- case 4:
- if(QDCT_GO_LIMIT_IN || (dwXRealPos > 1600) || ((dwXRealPos > 1200) && !X_DRV))
- {
- QDCT_XM_OUT = 0;
- QDCT_HeMoDelay = dwTickCount + 600;
- if(QTryCnt >= 4)
- {
- QDCT_HeMoStep = 0;
- QDCT_SetAlarmCode(QDCT_ZLT_ALARM);
- }
- else
- QDCT_HeMoStep = 5;
- }
- break;
- case 5:
- if(!QDCT_XM_LIMIT_IN) //下模下到位
- {
- QDCT_HeMoDelay = dwTickCount + 250;
- QDCT_HeMoStep = 6;
- }
- else if(dwTickCount >= QDCT_HeMoDelay)
- {
- QDCT_HeMoStep = 0;
- QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- }
- break;
- case 6:
- if(dwTickCount >= QDCT_HeMoDelay)
- {
- QDCT_HeMoStep = 1;
- QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
-
- if((QZhuangLiaoOkFlg == 0)&& QDCT_PARAM_QLT_ON)
- {
- QDCT_QJLT_OUT = 0;
- QDCT_QZhuangLiaoStep = 1;
- }
- if((HZhuangLiaoOkFlg== 0 )&& QDCT_PARAM_HLT_ON)
- {
- QDCT_HJLT_OUT = 0;
- QDCT_HZhuangLiaoStep = 1;
- }
-
- }
- break;
- }
- if(bRunning && (QDCT_HeMoStep == 0) && (QDCT_XM_ORIGIN_IN_UP) && (QTryCnt < 3) && !QDCT_XM_OUT)
- {
- if((!QDCT_QJLT_OUT) && (QDCT_QZhuangLiaoStep == 0) && QDCT_PARAM_QLT_ON)
- {
- QZhuangLiaoOkFlg = 0;
- QDCT_QZhuangLiaoStep = 1;
- }
- if(!QDCT_HJLT_OUT &&(QDCT_HZhuangLiaoStep == 0) && QDCT_PARAM_HLT_ON)
- {
- HZhuangLiaoOkFlg = 0;
- QDCT_HZhuangLiaoStep = 1;
- }
- }
- }
- //前装拉头动作(横送拉头)
- void QDCT_QZLT_Step(void)
- {
- switch(QDCT_QZhuangLiaoStep)
- {
- case 1:
- if(!QDCT_PARAM_QLT_ON) //不打开
- {
- QZhuangLiaoOkFlg = 1;
- QDCT_QJLT_OUT = 1;
- }
- if(QZhuangLiaoOkFlg)
- {
- QDCT_QZhuangLiaoStep = 0;
- }
- else
- {
- if(cFirstQStartFlg && QDCT_QJLT_IN && QDCT_QJLT_OUT)
- {
- QZhuangLiaoOkFlg = 1;
- QDCT_QZhuangLiaoStep = 0;
- cFirstQStartFlg = 0;
- }
- else
- {
- cFirstQStartFlg = 0;
- if(QDCT_QTLTStep == 0)
- {
- QDCT_QTLTStep = 1; //推拉头开始 当QTuiLaTouOkFlg = 1 时动作自动清零
- }
- QDCT_QZhuangLiaoStep = 2;
- }
- }
- break;
- case 2: //推拉头完成
- if(QDCT_QTLTStep == 0)
- {
- QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_QZhuangLiaoStep = 3;
- }
- break;
- case 3: //横送料原点 下模原点
- if(!QDCT_XM_OUT && QDCT_XM_ORIGIN_IN ) //
- {
- if((cSL_En >= 1) || (!bRunning))
- {
- QDCT_QZhuangLiaoStep = 4;
- QDCT_QZhuangLiaoDelay = dwTickCount + 0;//QDCT_PARAM_HSL_DELAY;
- }
- }
- else if(dwTickCount >= QDCT_QZhuangLiaoDelay)
- {
- if(!QDCT_XM_ORIGIN_IN)
- QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- }
- break;
- case 4: //横送输出
- if((dwTickCount >= QDCT_QZhuangLiaoDelay))
- {
- QDCT_QHSL_OUT = 1; //前横送输出
- QDCT_QJLT_OUT = 0; // 前夹拉头关
- QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_QZhuangLiaoStep = 5;
- }
- break;
- case 5: //横送到位
- if(QDCT_QHSL_LIMIT_IN)
- {
- QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_PARAM_DELAY_JLT;
- QDCT_QZhuangLiaoStep = 6;
- }
- else if(dwTickCount >= QDCT_QZhuangLiaoDelay)
- {
- if(QDCT_QHSL_OUT) //在自动程序运行结束时关闭了横送的情况,不报横送故障
- QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
- QDCT_QHSL_OUT = 0;
- }
- break;
- case 6://延时夹拉头
- if((dwTickCount >= QDCT_QZhuangLiaoDelay)/* && ((cSL_En >= 2) || (!bRunning))*/)
- {
- QDCT_QJLT_OUT = 1;
-
- QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_QZhuangLiaoStep = 7;
- }
- break;
- case 7://夹拉头到位
- if(QDCT_QJLT_IN)
- { //
- QTuiLaTouOkFlg = 0;
- QDCT_QTLTStep = 1; //横送料退回时启动推拉头
- QDCT_QZhuangLiaoDelay = dwTickCount + QDCT_PARAM_HSL_DELAY_BACK;
- QDCT_QZhuangLiaoStep = 8;
- }
- else if(dwTickCount >= QDCT_QZhuangLiaoDelay)
- {
- QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- QDCT_QHSL_OUT = 0;
- }
- break;
- case 8:
- if(dwTickCount >= QDCT_QZhuangLiaoDelay)
- {
- QDCT_QHSL_OUT = 0;
- QZhuangLiaoOkFlg = 1;
- QDCT_QZhuangLiaoStep = 9;
- }
- break;
- case 9:
- if(!QDCT_QHSL_LIMIT_IN)
- {
- QDCT_QZhuangLiaoStep = 10;
- QDCT_QZhuangLiaoDelay = dwTickCount + 30;
- }
- break;
- case 10:
- if((dwTickCount >= QDCT_QZhuangLiaoDelay) || QDCT_QHSL_ORIGIN_IN)
- {
- QDCT_QZhuangLiaoStep = 0;
- }
- break;
- }
- }
- //后装拉头动作
- void QDCT_HZLT_Step(void)
- {
- switch(QDCT_HZhuangLiaoStep)
- {
- case 1:
- if(!QDCT_PARAM_HLT_ON)
- {
- HZhuangLiaoOkFlg = 1;
- QDCT_HJLT_OUT = 1;
- }
- if(HZhuangLiaoOkFlg)
- {
- QDCT_HZhuangLiaoStep = 0;
- }
- else
- {
- if(cFirstHStartFlg && QDCT_HJLT_IN && QDCT_HJLT_OUT)
- {
- HZhuangLiaoOkFlg = 1;
- cFirstHStartFlg = 0;
- QDCT_HZhuangLiaoStep = 0;
- }
- else
- {
- cFirstHStartFlg = 0;
- if(QDCT_HTLTStep == 0)
- {
- QDCT_HTLTStep = 1;
- }
- QDCT_HZhuangLiaoStep = 2;
- }
- }
- break;
- case 2:
- if(QDCT_HTLTStep == 0)//后推拉头完成
- {
- QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HZhuangLiaoStep = 3;
- }
- break;
- case 3:
- if(!QDCT_XM_OUT && QDCT_XM_ORIGIN_IN ) //
- {
- if((cSL_En >= 1) || (!bRunning))
- {
- QDCT_HZhuangLiaoDelay = dwTickCount + 0;//QDCT_PARAM_HSL_DELAY;
- QDCT_HZhuangLiaoStep = 4;
- }
- }
- else if(dwTickCount >= QDCT_HZhuangLiaoDelay)
- {
- if(!QDCT_XM_ORIGIN_IN)
- QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- }
- break;
- case 4:
- if(dwTickCount >= QDCT_HZhuangLiaoDelay)
- {
- QDCT_HHSL_OUT = 1; //横送料输出
- QDCT_HJLT_OUT = 0;
- QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HZhuangLiaoStep = 5;
- }
- break;
- case 5:
- if(QDCT_HHSL_LIMIT_IN) //横送到位
- {
- QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_PARAM_DELAY_JLT;
- QDCT_HZhuangLiaoStep = 6;
- }
- else if(dwTickCount >= QDCT_HZhuangLiaoDelay)
- {
- if(QDCT_HHSL_OUT) //在自动程序运行结束时关闭了横送的情况,不报横送故障
- QDCT_SetAlarmCode(QDCT_HHSL_LIMIT_ALARM);
- QDCT_HHSL_OUT = 0;
- }
- break;
- case 6: //延时夹拉头
- if((dwTickCount >= QDCT_HZhuangLiaoDelay)/* && ((cSL_En >= 2) || (!bRunning))*/)
- {
- QDCT_HJLT_OUT = 1;
- QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HZhuangLiaoStep = 7;
- }
- break;
- case 7://夹拉头到位
- if(QDCT_HJLT_IN)
- {
- HTuiLaTouOkFlg = 0;
- QDCT_HTLTStep = 1; //横送料退回时启动推拉头
- QDCT_HZhuangLiaoDelay = dwTickCount + QDCT_PARAM_HSL_DELAY_BACK;
- QDCT_HZhuangLiaoStep = 8;
- }
- else if(dwTickCount >= QDCT_HZhuangLiaoDelay)
- {
- QDCT_SetAlarmCode(QDCT_HJLT_ALARM);
- QDCT_HHSL_OUT = 0;
- }
- break;
- case 8: //延时退横送料
- if((dwTickCount >= QDCT_HZhuangLiaoDelay))
- {
- QDCT_HHSL_OUT = 0;
- HZhuangLiaoOkFlg = 1;
- QDCT_HZhuangLiaoStep = 9;
- }
- break;
- case 9:
- if(!QDCT_HHSL_LIMIT_IN)
- {
- QDCT_HZhuangLiaoStep = 10;
- QDCT_HZhuangLiaoDelay = dwTickCount + 30;
- }
- break;
- case 10:
- if((dwTickCount >= QDCT_HZhuangLiaoDelay) || QDCT_HHSL_ORIGIN_IN)
- {
- QDCT_HZhuangLiaoStep = 0;
- }
- break;
- }
- }
- //前推拉头动作
- void QDCT_QTuiLT_Step(void)
- {
- static unsigned long q_dlp_delay;
-
- if(QDCT_QDLP_OUT && (dwTickCount >= q_dlp_delay))
- QDCT_QDLP_OUT = 0;
- switch(QDCT_QTLTStep)
- {
- case 1:
- //前拉头使能
- if(!QDCT_PARAM_QLT_ON)
- {
- QTuiLaTouOkFlg = 1;
- }
- if(QTuiLaTouOkFlg)
- {
- QDCT_QTLTStep = 0;
- }
- else
- {
- QDCT_QTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_QTLTStep = 2;
- }
- break;
- case 2:
- if(QDCT_QHSL_ORIGIN_IN && !QDCT_QHSL_LIMIT_IN)
- {
- QDCT_QTLT_OUT = 1;
- if(QTryCnt<= QDCT_PARAM_TRY_TIMES)
- QDCT_QDLP_OUT = 1;
- q_dlp_delay = dwTickCount + QDCT_PARAM_DLP_TIME;
- QDCT_QTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_QTLTStep = 3;
- }
- break;
- case 3:
- if(QDCT_QTLT_LIMIT_IN)
- {
- QDCT_QTLT_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
- QDCT_QTLTStep = 4;
- }
- else if(dwTickCount >= QDCT_QTLT_Delay)
- {
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- QDCT_QTLT_OUT=0;
- }
- break;
- case 4:
- if((dwTickCount >= QDCT_QTLT_Delay))
- {
- QDCT_QTLT_OUT = 0;
- QDCT_QTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_QTLTStep = 5;
- QTuiLaTouOkFlg = 1;
- }
- break;
- case 5:
- if(!QDCT_QTLT_LIMIT_IN)
- {
- QDCT_QTLTStep = 0;
- QDCT_QTLT_Delay = dwTickCount;
- }
- else if(dwTickCount >= QDCT_QTLT_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- break;
- }
- }
- //后推拉头动作
- void QDCT_HTuiLT_Step(void)
- {
- static unsigned long h_dlp_delay;
- // static unsigned short dlp_flg = 0;
- if(QDCT_HDLP_OUT && (dwTickCount >= h_dlp_delay))
- QDCT_HDLP_OUT = 0;
- switch(QDCT_HTLTStep)
- {
- case 1:
- if(!QDCT_PARAM_HLT_ON)
- {
- HTuiLaTouOkFlg = 1;
- }
- if(HTuiLaTouOkFlg)
- {
- QDCT_HTLTStep = 0;
- }
- else
- {
- QDCT_HTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HTLTStep = 2;
- }
- break;
- case 2:
- if(QDCT_HHSL_ORIGIN_IN && !QDCT_HHSL_LIMIT_IN)
- {
- QDCT_HTLT_OUT = 1;
- if(QTryCnt<= QDCT_PARAM_TRY_TIMES)
- QDCT_HDLP_OUT = 1;
- h_dlp_delay = dwTickCount + QDCT_PARAM_DLP_TIME;
- QDCT_HTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HTLTStep = 3;
- }
- break;
- case 3:
- if(QDCT_HTLT_LIMIT_IN)
- {
- QDCT_HTLT_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
- QDCT_HTLTStep = 4;
- }
- else if(dwTickCount >= QDCT_HTLT_Delay)
- {
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- QDCT_HTLT_OUT=0;
- }
- break;
- case 4:
- if((dwTickCount >= QDCT_HTLT_Delay))
- {
- QDCT_HTLT_OUT = 0;
- QDCT_HTLT_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HTLTStep = 5;
- HTuiLaTouOkFlg = 1;
- }
- break;
- case 5:
- if(!QDCT_HTLT_LIMIT_IN)
- {
- QDCT_HTLTStep = 0;
- QDCT_HTLT_Delay = dwTickCount;
-
-
- }
- else if(dwTickCount >= QDCT_HTLT_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- break;
- }
- }
- //手动动作
- void QDCT_ManualAction(void)
- {
- static unsigned char cs_flg;
- static long cs_delay;
-
- //轴使能状态,供屏显示
- if(GetEn(X_AXIS)==QDCT_MOTOR_DISEN)
- {
-
- QDCT_AxisEn_status=0;
- }
- else
- {
- QDCT_AxisEn_status=1;
- }
- //轴使能状态,供屏显示
- if(GetEn(Y_AXIS)==QDCT_MOTOR_DISEN)
- {
-
- QDCT_YAxisEn_status=0;
- }
- else
- {
- QDCT_YAxisEn_status=1;
- }
-
- //前振动盘
- if(QDCT_bManQZD)
- {
- QDCT_bManQZD = 0;
- if(QDCT_QZDPStep)
- {
- QDCT_QZDP_OUT = 0;
- QDCT_QZDPStep = 0;
- QZDPAutoDisable=1;
- }
- else
- {
- QDCT_QZDP_OUT = 1;
- QDCT_QZDPStep = 2;
- if(QDCT_TLPStep==0)QDCT_TLPStep = 1;
- QZDPAutoDisable=0;
- }
- }
- //后振动盘
- if(QDCT_bManHZD)
- {
- QDCT_bManHZD = 0;
- if(QDCT_HZDPStep)
- {
- QDCT_HZDP_OUT = 0;
- QDCT_HZDPStep = 0;
- HZDPAutoDisable=1;
- }
- else
- {
- QDCT_HZDP_OUT = 1;
- QDCT_HZDPStep = 2;
- HZDPAutoDisable=0;
- }
- }
-
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(QDCT_TOTAL_ADDR);
- }
-
- if(QDCT_bClerNowTotal)
- {
- QDCT_bClerNowTotal = 0;
- QDCT_PARAM_TB_CNT1 = 0;
- QDCT_PARAM_TB_CNT2 = 0;
- ClrcToTal(QDCT_NOWTOTAL_ADDR);
- }
- //切断
- if(QDCT_bQieDuan)
- {
- QDCT_bQieDuan = 0;
- if(QDCT_XiaQieStep == 0)
- {
- if(QDCT_PARAM_XM_MODE) //下模不动
- {
- if(QDCT_SL_ORIGIN_IN )
- QDCT_XiaQieStep = 1;
- else
- QDCT_SetAlarmCode(QDCT_SL_ORIGIN_ALARM);
- }
- else
- {
- QDCT_XiaQieStep = 1;
- }
- }
- }
- //测试行程
- if(QDCT_bReset_Origin)
- {
- QDCT_bReset_Origin = 0;
- cTestMotorStep = 1;
- }
- //前点定位
- if(QDCT_bQianDianDW)
- {
- QDCT_bQianDianDW = 0;
- if((QDCT_MotorStep == 0) && !QDCT_SQ_LIMIT_IN && (!QDCT_XQ_LIMIT_IN || QDCT_PARAM_XM_MODE) && QDCT_SYL_ORIGIN_IN && !QDCT_YL_LIMIT_IN)
- {
- QDCT_MotorStep = 61;
- dwZipCnt = 0;
- }
- else if(QDCT_SQ_LIMIT_IN)
- {
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- }
- else if(!QDCT_SYL_ORIGIN_IN)
- {
- QDCT_SetAlarmCode(QDCT_SYL_ORIGIN_ALARM);
- }
- else if(QDCT_YL_LIMIT_IN)
- {
- QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- }
- }
- //下模
- if(QDCT_bManXM)
- {
- QDCT_bManXM = 0;
- QDCT_XM_OUT = ~QDCT_XM_OUT;
-
- if(QDCT_QHSL_OUT || QDCT_HHSL_OUT)QDCT_XM_OUT = 0;
- }
- //上切刀
- if(QDCT_bManSQ)
- {
- QDCT_bManSQ = 0;
-
- if(QDCT_SQ_OUT)
- QDCT_SQ_OUT = 0;
- // 送料原点 下模动 //下模不动
- else if((QDCT_SL_ORIGIN_IN && (QDCT_PARAM_XM_MODE != 0))||(QDCT_PARAM_XM_MODE == 0))
- {
- QDCT_SQ_OUT = 1;
- cQDCT_TuiLianOKFlag = 0;
- }
- }
- //下切刀
- if(QDCT_bManXQ)
- {
- QDCT_bManXQ = 0;
-
- if(!QDCT_PARAM_XM_MODE) //有下刀
- {
- QDCT_XQ_OUT = ~QDCT_XQ_OUT;
- //QDCT_SL_OUT = 0;
- }
- else
- {
- QDCT_SL_OUT = ~QDCT_SL_OUT;
- //QDCT_XQ_OUT = 0;
- }
- cQDCT_TuiLianOKFlag = 0;
- if(QDCT_GO_LIMIT_IN)
- {
- QDCT_XQ_OUT = 0;
- QDCT_SL_OUT=0;
- }
- }
- //夹带
- if(QDCT_bManJD)
- {
- QDCT_bManJD = 0;
- QDCT_JD_OUT = ~QDCT_JD_OUT;
- }
- //前推拉头
- if(QDCT_bManQTLT)
- {
- QDCT_bManQTLT = 0;
- if(QDCT_QHSL_ORIGIN_IN)
- {
- if(QDCT_QTLTStep == 0)
- {
- QDCT_QTLTStep = 1;
- QTuiLaTouOkFlg = 0;
- QTryCnt = 0;
- }
- else
- {
- QDCT_QTLT_OUT = 0;
- }
- }
- }
- //后推拉头
- if(QDCT_bManHTLT)
- {
- QDCT_bManHTLT = 0;
- if(QDCT_HHSL_ORIGIN_IN)
- {
- if(QDCT_HTLTStep == 0)
- {
- QDCT_HTLTStep = 1;
- HTuiLaTouOkFlg = 0;
- QTryCnt = 0;
- }
- else //后推拉头
- QDCT_HTLT_OUT = 0;
- }
- }
- //前横送料
- if(QDCT_bManQHSL)
- {
- QDCT_bManQHSL = 0;
- QDCT_QHSL_OUT = ~QDCT_QHSL_OUT;
- if(QDCT_XM_OUT || QDCT_QTLT_LIMIT_IN) QDCT_QHSL_OUT = 0;
- if(QDCT_QHSL_OUT && QDCT_QJLT_OUT) QDCT_QJLT_OUT=0;
- }
-
- if(QDCT_bManHHSL)
- {
- QDCT_bManHHSL = 0;
- QDCT_HHSL_OUT = ~QDCT_HHSL_OUT;
-
- if(QDCT_XM_OUT || QDCT_HTLT_LIMIT_IN)QDCT_HHSL_OUT = 0;
- if(QDCT_HHSL_OUT && QDCT_HJLT_OUT) QDCT_HJLT_OUT=0;
- }
- /*
- //前振动盘
- if(QDCT_bManQZD)
- {
- QDCT_bManQZD = 0;
- if(QDCT_QZDPStep)
- {
- QDCT_QZDP_OUT = 0;
- QDCT_QZDPStep = 0;
- }
- else
- {
- QDCT_QZDP_OUT = 1;
- QDCT_QZDPStep = 2;
- if(QDCT_TLPStep==0)QDCT_TLPStep = 1;
- }
- }
- //后振动盘
- if(QDCT_bManHZD)
- {
- QDCT_bManHZD = 0;
- if(QDCT_HZDPStep)
- {
- QDCT_HZDP_OUT = 0;
- QDCT_HZDPStep = 0;
- }
- else
- {
- QDCT_HZDP_OUT = 1;
- QDCT_HZDPStep = 2;
- }
- }
- */
- //前夹拉头
- if(QDCT_bManQJLT)
- {
- QDCT_bManQJLT = 0;
- QDCT_QJLT_OUT = ~QDCT_QJLT_OUT;
- if(!QDCT_QJLT_OUT)
- QZhuangLiaoOkFlg = 0;
- }
- //后夹拉头
- if(QDCT_bManHJLT)
- {
- QDCT_bManHJLT = 0;
- QDCT_HJLT_OUT = ~QDCT_HJLT_OUT;
- if(!QDCT_HJLT_OUT)
- HZhuangLiaoOkFlg = 0;
- }
- //台面电机
- if(QDCT_bTable)
- {
- QDCT_bTable = 0;
-
- QDCT_TB_OUT = ~QDCT_TB_OUT;
- if(QDCT_TB_OUT)
- QDCT_TableDelay = dwTickCount+100000;
- else
- QDCT_TableDelay = dwTickCount+100;
- }
- //前装料
- if(QDCT_bQZuangLT)
- {
- QDCT_bQZuangLT = 0;
- if(QDCT_QZhuangLiaoStep == 0)
- {
- QTryCnt = 0;
- QTuiLaTouOkFlg = 1;
- QDCT_QZhuangLiaoStep = 3;
- cFirstQStartFlg = 0;
- }
- }
- //后装料
- if(QDCT_bHZuangLT)
- {
- QDCT_bHZuangLT = 0;
- if(QDCT_HZhuangLiaoStep == 0)
- {
- QTryCnt = 0;
- HTuiLaTouOkFlg = 1;
- QDCT_HZhuangLiaoStep = 3;
- cFirstHStartFlg = 0;
- }
- }
- //压带
- if(QDCT_bManYD)
- {
- QDCT_bManYD = 0;
- QDCT_YD_OUT = ~QDCT_YD_OUT;
- }
- //吹气
- if(QDCT_bManCQ)
- {
- QDCT_bManCQ = 0;
- QDCT_CQ_OUT = 1;//~QDCT_CQ_OUT; //吹气
- QDCT_CQDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
- }
- //推拉片
- if(QDCT_bManDLP)
- {
- QDCT_bManDLP = 0;
- QDCT_TLP_OUT = ~QDCT_TLP_OUT;
- }
- //穿拉头
- if(QDCT_bChuanLT)
- {
- QDCT_bChuanLT = 0;
- if(!QDCT_BACK_LIMIT_IN)
- {
- if(QDCT_MotorStep == 0)QDCT_MotorStep = 30;
- }
- }
- //电机松轴
- if(QDCT_bManSZ)
- {
- QDCT_bManSZ = 0;
- if(GetEn(X_AXIS)==QDCT_MOTOR_DISEN)
- {
- SetEn(X_AXIS, QDCT_MOTOR_EN);
- }
- else
- {
- SetEn(X_AXIS, QDCT_MOTOR_DISEN);
- }
- }
- //电机控制
- if(QDCT_bMotorGo && !QDCT_GO_LIMIT_IN && !QDCT_SQ_LIMIT_IN)
- {
- QDCT_JD_OUT = 0;
- //QDCT_JJ_DIR = QDCT_JJ_DIR_P;
- //QDCT_SZ_OUT = QDCT_MOTOR_EN;
- SetEn(X_AXIS, QDCT_MOTOR_EN);
- cBackLimitCheck_EN= 0;
- if(!X_DRV)AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_N,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
- else if(QDCT_bMotorGo && QDCT_SQ_LIMIT_IN)
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
-
- if(QDCT_bMotorBack && !QDCT_BACK_LIMIT_IN)
- {
- // QDCT_JD_OUT = 0;
- //QDCT_SZ_OUT = QDCT_MOTOR_EN;
- SetEn(X_AXIS, QDCT_MOTOR_EN);
- //QDCT_JJ_DIR = QDCT_JJ_DIR_N;
- cBackLimitCheck_EN = 1;
- if(!X_DRV)AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED, QDCT_DIR_P,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
-
- if(!QDCT_bMotorGo && !QDCT_bMotorBack && (QDCT_MotorStep == 0) && (cStopFlg == 0) && (cTestMotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(QDCT_GO_LIMIT_IN && (QDCT_MotorStep == 0) && !QDCT_bMotorBack &&(QDCT_AutoStep == 0) && (cStopFlg == 0) && (cStopFlg == 0) && (cTestMotorStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- if(QDCT_bYLGO)
- {
- SetEn(Y_AXIS, QDCT_MOTOR_EN);
- //QDCT_YL_DIR = QDCT_YL_DIR_P;
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS,QDCT_PARAM_START_SPEED, QDCT_YL_DIR_P,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
-
- if(QDCT_bYLBACK)
- {
- SetEn(Y_AXIS, QDCT_MOTOR_EN);
- //QDCT_YL_DIR = QDCT_YL_DIR_N;
- if(!Y_DRV)AxisContinueMoveAcc(Y_AXIS,QDCT_PARAM_START_SPEED, QDCT_YL_DIR_N,
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- }
-
- if(!QDCT_bYLGO && !QDCT_bYLBACK && (QDCT_MotorStepY == 0) && (QDCT_AutoStep == 0))
- {
- if(Y_DRV)AxisDecStop(Y_AXIS);
- }
-
- if(QDCT_bYL)
- {
- QDCT_bYL = 0;
- QDCT_YL_OUT = ~QDCT_YL_OUT;
- }
- if(QDCT_bSYL)
- {
- QDCT_bSYL = 0;
- QDCT_SYL_OUT = ~QDCT_SYL_OUT;
- }
- //Y电机松轴
- if(QDCT_bManSZ_Y)
- {
- QDCT_bManSZ_Y = 0;
- if(GetEn(Y_AXIS)==QDCT_MOTOR_DISEN)
- {
- SetEn(Y_AXIS, QDCT_MOTOR_EN);
- }
- else
- {
- SetEn(Y_AXIS, QDCT_MOTOR_DISEN);
- }
- }
-
- if(QDCT_bManKL)
- {
- QDCT_bManKL = 0;
- //QDCT_KL_OUT = ~QDCT_KL_OUT;
- // QDCT_JiaLianStep = 3;
- }
-
- if(QDCT_bManCS)
- {
- QDCT_bManCS = 0;
- cs_delay = dwTickCount + QDCT_PARAM_CS_TIME;
- QDCT_CS_OUT = 1;
- cs_flg = 1;
- }
- }
- if(cs_flg)
- {
- if(QDCT_CS_OUT && (dwTickCount >= cs_delay))
- {
- QDCT_CS_OUT = 0;
- cs_flg = 0;
- }
- }
- //这里特殊改动
- // if(QDCT_PARAM_XM_MODE!== 0)
- // {
-
- if(QDCT_CQ_OUT && (dwTickCount >= QDCT_CQDelay)) QDCT_CQ_OUT = 0;
- // }
- }
- #endif
|