12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770 |
- #include "global.h"
- #if CHANG_SHENG_GEI_LI_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;
- 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] = dwRealPos;
- cDinWeiPos = dwRealPos;
- }
- }
- }
- //故障报警
- 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;
- 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,2);
- }
- void QDCT_Action(void)
- {
- 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; //锁轴
- QDCT_TestMotorDelay = dwTickCount + 50;
- cTestMotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= QDCT_TestMotorDelay)//锁轴时间到
- {
- AxisContinueMoveAcc(X_AXIS,5, 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,0);
- // 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_START_SPEED,
- 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(dwRealPos <= (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)
- {
- 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;
- }
- }
- //后振动盘
- 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;
- dwRealPos = 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 = dwRealPos;
- 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
- {
- //单拉头时开链
- if(QDCT_LATOU)
- {
- if(QDCT_PARAM_KL_QC_SELECT==1)
- {
- QDCT_KL_OUT = 1;
- }
- else
- {
- QDCT_CQ_OUT = 1;
- QDCT_CQDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
- }
- }
- else //夹带输出后吹气
- {
- QDCT_CQ_OUT = 1;
- QDCT_CQDelay = dwTickCount + QDCT_PARAM_CQ_TIME;
- }
- // QDCT_YD_OUT = 0;
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_TIME;
- }
- 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_LATOU && 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)) //第一条要到前限位才能合模
- {
- if((cCheckDinWei == 0) && (QDCT_PARAM_QLT_ON || QDCT_PARAM_HLT_ON))
- QDCT_HeMoStep = 1;
- 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
- QDCT_AutoStep = 14;
- 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))
- {
- 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);
-
-
- 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
- {
- QDCT_SetAlarmCode(QDCT_ZHA_ALARM); //扎数到
- SingOneFlg = 1;
- }
- if(SingOneFlg)
- {
- SingOneFlg = 0;
- QDCT_AutoStep = 0;
- bRunning = 0;
- if(QDCT_LATOU)
- QDCT_QHSL_OUT = 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;
- if(QDCT_LATOU)
- QDCT_QHSL_OUT = 0;
- //QDCT_HHSL_OUT = 0;
- }
- else
- QDCT_AutoStep = 2;
- }
- break;
- case 50:
- QDCT_YL_OUT = 1;
- QDCT_AutoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_AutoStep = 51;
- break;
- case 51:
- if(QDCT_YL_LIMIT_IN)
- {
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_DELAY;
- QDCT_AutoStep = 52;
- }
- else if(dwTickCount >= QDCT_AutoDelay)
- QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- break;
- case 52:
- if((dwTickCount >= QDCT_AutoDelay) && (QDCT_MotorStep == 0))
- {
- //QDCT_YL_DIR = QDCT_YL_DIR_N;
- jz_over = 1;
- QDCT_MotorStep = 150; //走松夹子
- if(!Y_DRV)//压轮电机动作
- AxisMovePos(Y_AXIS,QDCT_PARAM_YL_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH-QDCT_PARAM_TRANS_LENGTH+1000));
- QDCT_AutoStep = 53;
- }
- break;
- case 53:
- if((dwTickCount >= QDCT_AutoDelay))
- {
- if(!Y_DRV)
- {
- QDCT_AutoStep = 54;
- //QDCT_YL_DIR = QDCT_YL_DIR_P;
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_YL_FZ_DELAY;
- }
- }
- break;
- case 54:
- if((dwTickCount >= QDCT_AutoDelay))
- {
- if(!Y_DRV)AxisMovePos(Y_AXIS,QDCT_PARAM_YL_SPEED,(QDCT_PARAM_FZ_LENGTH));
- 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_LATOU))QDCT_SetAlarmCode(QDCT_START_GL_ORIGIN_ALARM);
- else if((QDCT_HHSL_LIMIT_IN && !QDCT_LATOU) || 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_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)))
- {
- 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))
- {
- 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;
- }
- else
- {
- if(!X_DRV)
- QDCT_SZ_OUT = 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_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;
- }
- //测试停止
- cTestMotorStep = 0;
- }
-
- if(sl_flg)
- {
- if(dwTickCount >= sl_delay)
- {
- sl_flg = 0;
- 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;
- 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_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)
- {
- if(QDCT_SL_OUT)
- {
- 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,back_delay;
- long speed_buff;
- long len_buff;
- unsigned short start_speed;
-
- user_datas[127] = length_buff;
-
- 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)
- {
- //QDCT_YL_DIR = QDCT_YL_DIR_N;
- if(!Y_DRV)AxisMovePos(Y_AXIS,QDCT_PARAM_YL_SL_SPEED,QDCT_PARAM_YL_SL_LENGTH);
- 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_MotorYDelay = dwTickCount + 40;
- QDCT_MotorStepY = 163;
- }
- else if(dwTickCount >= QDCT_MotorYDelay)
- QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- break;
- case 163:
- if(dwTickCount >= QDCT_MotorYDelay)
- {
- QDCT_MotorStepY = 0;
- }
- break;
- }
- switch(QDCT_MotorStep)
- {
- case 1:
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- QDCT_MotorStep = 2;
- QDCT_YD_OUT = 0;
- user_datas[129]=0;
- break;
- case 2:
- cSeBiaoOk = 0;
- cSeBiaoEn = 0;
- SetPos(X_AXIS,0);
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_buff = dwRealPos;
- back_dec_buff = dwRealPos;
- 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,100);
- 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) || (dwRealPos >= (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((dwRealPos) >= (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((dwRealPos + 100) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- }
- if(dwZipCnt>=1)
- {
- //如果慢速长度到,
- if(dwRealPos >= (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-dwRealPos,
- 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=dwRealPos;
- }
- }
-
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
-
- break;
- case 4:
- //到拉链空位
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwRealPos >= (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((dwRealPos) >= (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((dwRealPos + 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=dwRealPos;
- }
- }
-
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
- break;
- case 5:
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwRealPos >= (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(dwRealPos+QDCT_SEBIAO_BACK_LSPEED_LENGTH+QDCT_SEBIAO_LENGTH+50 < length_buff)
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_SEBIAO_HIGH_SPEED,length_buff-dwRealPos-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=dwRealPos;
- }
- }
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 4;
- }
- break;
- case 6:
- if((!KaDaiFlag && QDCT_SEBIAO_IN_UP) || (dwRealPos >= (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] = dwRealPos;
- 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=dwRealPos;
- }
- }
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- 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(dwRealPos >= (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((dwRealPos + 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((dwRealPos + 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((dwRealPos + 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-dwRealPos,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_SEBIAO_LOW_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 8;
- }
-
- }
-
- }
-
- }
- }
- if(((dwRealPos >= (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 && (((dwRealPos > (length_buff + QDCT_SEBIAO_ERROR_LENGHT))
- || dwRealPos < (length_buff - QDCT_SEBIAO_ERROR_LENGHT))))
- {
- QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
- }
- else
- {
- QDCT_MotorStep = 9;
- //第一条保存长度
- if(dwZipCnt==0) length_buff = dwRealPos;
- }
- }
- //卡带处理,停止后可再次启动
- 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=dwRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 3;
- }
- break;
- case 8:
- if(((dwRealPos >= (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 && (((dwRealPos > (QDCT_PARAM_SET_ZIPPER_LENGTH + QDCT_SEBIAO_ERROR_LENGHT))
- || dwRealPos < (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_ERROR_LENGHT))))
- {
- QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
- }
- else
- {
- QDCT_MotorStep = 9;
- //第一条保存长度
- if(dwZipCnt==0) length_buff = dwRealPos;
- }
- }
- //卡带处理,停止后可再次启动
- 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=dwRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 3;
- }
- case 9:
- QDCT_MotorStep = 0;
- break;
-
- case 30:
- QDCT_MotorDelay = dwTickCount;
- if(QDCT_SZ_OUT == QDCT_MOTOR_DISEN)
- {
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
- QDCT_MotorDelay = dwTickCount + 50;
- }
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- 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 = dwRealPos;
- save_buff = dwRealPos;
- back_buff = dwRealPos;
- qdct_length_buff = &QDCT_PARAM_OFFSET_LENGTH;
- if((*qdct_length_buff+QDCT_PARAM_SET_ZIPPER_LENGTH) < 0)
- *qdct_length_buff = 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( 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,100);
- else
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_Mold_Distance+10,start_speed,QDCT_PARAM_PUTIN_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- if(QDCT_LATOU == 0) //双头跳转
- QDCT_MotorStep = 33;
- else //单头跳转
- QDCT_MotorStep = 333;
- cChuan_LianCheckOK = 0;
- }
- break;
- case 33: //这一步关夹拉头
- //下模提前输出
- if(!QDCT_GO_LIMIT_IN && !QDCT_PARAM_XM_MODE && !QDCT_PARAM_CS_ENABLE && (dwRealPos >= QDCT_PARAM_Mold_Distance))
- QDCT_XQ_OUT = 1;
- //如果当前长度到达拉链长,最优先停
- if(dwRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 35;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- break;
- }
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //如果穿入长度到也停止,开模
- if((dwRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 35;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- if(QDCT_PARAM_QLT_ON )
- {
- //QDCT_QJLT_OUT = 0;
- }
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- break;
- }
-
- //如果慢速长度到,
- if(dwRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH))
- {
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- //拉链长度大于(模具长度 + 穿入长度)说明穿入部分还有拉链加速
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)> (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH))
- {
- 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_PUTIN_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,0);
- QDCT_MotorStep = 34;
- }
- else
- {
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)- dwRealPos,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE+10,QDCT_PARAM_DEC_PULSE+10,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=dwRealPos;
- }
- }
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- 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(dwRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 35;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- break;
- }
- //如果穿入长度到也停止,开模
- if((dwRealPos + 8) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- QDCT_MotorStep = 35;
- if(QDCT_PARAM_HLT_ON)
- {
- QDCT_HJLT_OUT = 0;
- }
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- break;
- }
- else if((dwRealPos + 80) >= (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=dwRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 5;
- }
- break;
- case 35:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(QDCT_PARAM_HLT_ON )
- {
- QDCT_HJLT_OUT = 0;
- }
- QDCT_XM_OUT = 0;
-
- QDCT_MotorStep = 37;
- QDCT_MotorDelay = dwTickCount;
- }
- break;
- case 36:
-
- if(!X_DRV)
- {
- QDCT_MotorStep = 37;
- }
-
- 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(dwRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwRealPos),
- QDCT_PARAM_START_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE+10,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10,0);
- }
- QDCT_MotorStep = 38;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 6;
- }
- break;
- case 38:
- if(((dwRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH + 400)) && (QDCT_PARAM_SET_ZIPPER_LENGTH > (dwRealPos + 4000)))
- {
- cSL_En = 2;
-
- }
- if((!X_DRV && !KaDaiFlag) || (dwRealPos>= QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- 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(dwRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwRealPos),
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwRealPos),
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_BACK_LOWSPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- }
- else
- {
- KaDaiSaveLen=dwRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- 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,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- QDCT_MotorStep = 39;
- }
- break;
- case 39:
-
- if(!X_DRV)
- {
- 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 < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 7;
- }
- break;
- case 40:
- QDCT_MotorStep = 0;
- break;
- //这是单头程序
- case 333: //这一步关夹拉头
-
- //如果当前长度到达拉链长,最优先停
- if(dwRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 335; //直接跳到拖带结束
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- //下模和夹拉头打开
- QDCT_QJLT_OUT = 0; //夹拉头
- QDCT_XM_OUT = 0; //拉头下模
- QDCT_MotorDelay = dwTickCount;
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- break;
- }
- //如果穿入长度到也停止,开模
- if((dwRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- QDCT_MotorStep = 335;
- if(QDCT_PARAM_MODE==1)//反穿停电机
- {
- AxisEgmStop(X_AXIS);
- }
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- QDCT_QJLT_OUT = 0; //夹拉头
- QDCT_XM_OUT = 0; //拉头下模
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //下模提前输出
- if(!QDCT_GO_LIMIT_IN && !QDCT_PARAM_XM_MODE && !QDCT_PARAM_CS_ENABLE )
- QDCT_XQ_OUT = 1;
- break;
- }
- //如果慢速长度到,
- if(dwRealPos >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LOW_SPEED_LENGTH))
- {
- //下模提前输出
- if(!QDCT_GO_LIMIT_IN && !QDCT_PARAM_XM_MODE && !QDCT_PARAM_CS_ENABLE )
- QDCT_XQ_OUT = 1;
- if(QDCT_PARAM_XM_MODE)
- QDCT_SL_OUT = 0;//送带退
- //拉链长度大于(模具长度 + 穿入长度)说明穿入部分还有拉链加速
- if((QDCT_PARAM_SET_ZIPPER_LENGTH +*qdct_length_buff)> (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH))
- {
- //到达穿入长度处时要回到穿入速度给开模时间
- 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_PUTIN_LOW_SPEED,
- QDCT_PARAM_ACC_PULSE+5,QDCT_PARAM_DEC_PULSE+5,0);
- }
- else
- {
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff- dwRealPos,
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE+5,QDCT_PARAM_DEC_PULSE+10,0);
- }
- QDCT_MotorStep = 334;
- }
- //卡带处理,停止后可再次启动
- 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=dwRealPos;
- }
- }
- //行程超限
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 8;
- }
- break;
- case 334:
-
- //到达拉链长度要停止
- if(dwRealPos >= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 335; //直接跳到拖带结束
- //下模和夹拉头打开
- QDCT_QJLT_OUT = 0; //夹拉头
- QDCT_XM_OUT = 0; //拉头下模
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- break;
- }
- //如果穿入长度到也停止,开模
- if((dwRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_MotorStep = 335; //说明拉链还有长度 电机没有停止
- if(QDCT_PARAM_MODE==1) //反穿停电机
- {
- AxisEgmStop(X_AXIS);
- }
- //下模和夹拉头打开
- QDCT_QJLT_OUT = 0; //夹拉头
- QDCT_XM_OUT = 0; //拉头下模
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_BACK_DELAY;
- }
- //提前2.5MM
- else if((dwRealPos + 25) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH ))
- {
- QDCT_QJLT_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=dwRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 9;
- }
- break;
- case 335:
- if(dwRealPos>= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff))
- {
- AxisEgmStop(X_AXIS);
- }
- if(QDCT_CHUAN_LIAN_OK)
- cChuan_LianCheckOK = 1;
- //两路顶针离开
- if(!QDCT_XM_OUT && ((!QDCT_QLTCZ_IN || (!QDCT_PARAM_QLT_ON)) ) && !KaDaiFlag)
- {
- if(X_DRV) //正穿不停止
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > dwRealPos + QDCT_PARAM_LOWSPEED_LENGTH)
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff - dwRealPos),
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE+5,QDCT_PARAM_DEC_PULSE+10,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff - dwRealPos),
- QDCT_PARAM_PUTIN_LOW_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE+5,QDCT_PARAM_DEC_PULSE+10,0);
- QDCT_MotorStep = 338;
- //user_datas[122]=0;
- }
- else if(dwTickCount >= QDCT_MotorDelay)
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)> dwRealPos)
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff - dwRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10,0);
- QDCT_MotorStep = 338;
- //user_datas[122]=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=dwRealPos;
- }
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 10;
- }
-
- break;
- case 338:
- if((dwRealPos) >= (QDCT_PARAM_Mold_Distance + QDCT_PARAM_PUTIN_LENGTH + 100) && (QDCT_PARAM_SET_ZIPPER_LENGTH > (dwRealPos + 4000)))
- {
- cSL_En = 2;
- }
- if((!X_DRV && !KaDaiFlag) || (dwRealPos>= (QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)))
- {
- AxisEgmStop(X_AXIS);
- cSL_En = 2;
- QDCT_YD_OUT = 1;
- QDCT_MotorStep = 339;
- 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(dwRealPos < QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff)
- {
- if((QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff) > (dwRealPos+QDCT_PARAM_LOWSPEED_LENGTH))
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE+30,QDCT_PARAM_LOWSPEED_LENGTH);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_BACK_LOWSPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH + *qdct_length_buff-dwRealPos),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE+30,QDCT_PARAM_DEC_PULSE+30,0);
- }
- }
- else
- {
- KaDaiSaveLen=dwRealPos;
- }
- }
-
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 11;
- }
- break;
-
- case 339:
- 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,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- }
- QDCT_MotorStep = 340;
- }
- break;
- case 340:
- if(!X_DRV)
- {
- 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 < dwRealPos)
- {
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- user_datas[128] = 12;
- }
- break;
-
- case 80:
- jz_buff = dwRealPos;
- 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,QDCT_PARAM_ACC_PULSE+5,QDCT_PARAM_DEC_PULSE+5,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,QDCT_PARAM_ACC_PULSE+5,QDCT_PARAM_DEC_PULSE+5,50);
- QDCT_MotorStep = 82;
- }
- break;
- case 82:
- if(QDCT_LONG_LENGTH_USE)// 无限长切断完成后拉电机动作
- {
- if((QDCT_CHUAN_LIAN_CHECK_SELECT == 0)|| cChuan_LianCheckOK)
- {
- if(((QDCT_PARAM_SJZ_LENGTH) <= (jz_buff- dwRealPos)))
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
-
- }
- else if(!X_DRV)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
- }
- else
- {
- //松夹子长度
- if(((QDCT_PARAM_SJZ_LENGTH) <= (dwRealPos - jz_buff)))
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
- else if(!X_DRV)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
- }
- }
- else //普通长度
- {//松夹子长度
- if(((QDCT_PARAM_SJZ_LENGTH) <= (dwRealPos - jz_buff)))
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
- else if(!X_DRV)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 83;
- }
-
- }
- if(!QDCT_JD_OUT)
- {
- cSL_En = 2;
- }
- if(QDCT_PARAM_MAX_BACK_LENGTH < dwRealPos)
- {
- 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 < dwRealPos)
- {
- 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)) || (QDCT_SZ_OUT == QDCT_MOTOR_DISEN))
- {
- if(!QDCT_GO_LIMIT_IN)
- QDCT_JD_OUT = 0;
-
- if((QDCT_SZ_OUT == QDCT_MOTOR_DISEN))
- QDCT_MotorDelay = dwTickCount + 40;
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
-
- }
- //下模不动时要推链
- if(QDCT_PARAM_XM_MODE && !QDCT_SL_OUT && !QDCT_JD_OUT)
- QDCT_TuiLianStep = 1;
- QDCT_SZ_OUT = 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,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- 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,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 63;
- QDCT_MotorDelay = dwTickCount + 500;
- }
- break;
- case 63:// 前进
- if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay))
- {
- go_buff = dwRealPos;
- //不是第一次
- if(dwZipCnt > 0)
- {
- speed_buff = QDCT_PARAM_JJGO_SPEED;
- if(dwZipCnt == 5) //扎数到的启动
- AxisMovePosAccDecNotStop(X_AXIS,QDCT_PARAM_JJGO_SPEED/2,-(dwRealPos-QDCT_PARAM_GO_LOWSPEED_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_GO_LOWSPEED,QDCT_PARAM_ACC_PULSE+20,QDCT_PARAM_DEC_PULSE+10,0);
- // AxisMoveTwoPosNoStop(X_AXIS,QDCT_PARAM_JJGO_SPEED/2,(dwRealPos-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,-(dwRealPos-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+20,0);
- // AxisMoveTwoPosNoStop(X_AXIS,QDCT_PARAM_JJGO_SPEED,(dwRealPos-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 + MOTOR_ALARM_TIME;
- }//第一次
- else
- {
- AxisContinueMoveAcc(X_AXIS,QDCT_PARAM_GO_LOWSPEED,QDCT_DIR_N,QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,
- QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE);
- //QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDCT_MotorStep = 65;
- }
- }
- break;
- case 65:
- //碰到前点限位停止
- if(QDCT_GO_LIMIT_IN)
- {
- SetPos(X_AXIS, QDCT_PARAM_JJDINGWEI_LENGTH);
- QDCT_MotorStep = 66;
- dwRealPos = 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(dwRealPos <= 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;
- }
- break;
- // //切断后压轮送出链
- // case 160:
- // if((dwTickCount >= QDCT_MotorDelay) && !Y_DRV)
- // {
- // //QDCT_YL_DIR = QDCT_YL_DIR_N;
- // if(!Y_DRV)
- // AxisMovePos(Y_AXIS,QDCT_PARAM_YL_SL_SPEED,QDCT_PARAM_YL_SL_LENGTH);
- // QDCT_MotorDelay = dwTickCount + QDCT_PARAM_YL_BACK_DELAY;
- // QDCT_MotorStep = 161;
- // }break;
- // case 161:
- // if(dwTickCount >= QDCT_MotorDelay)QDCT_YL_OUT = 0;
- // if(!Y_DRV)
- // {
- // QDCT_YL_OUT = 0;
- // QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- // QDCT_MotorStep = 162;
- // }
- // break;
- // case 162:
- // if(!QDCT_YL_LIMIT_IN)
- // {
- // QDCT_MotorDelay = dwTickCount;
- // QDCT_MotorStep = 0;
- // }
- // else if(dwTickCount >= QDCT_MotorDelay)
- // QDCT_SetAlarmCode(QDCT_YL_LIMIT_ALARM);
- // break;
- case 150:
- // if(dwTickCount >= QDCT_MotorDelay)
- {
- jz_buff = dwRealPos;
- //QDCT_JJ_DIR = //QDCT_JJ_DIR_N;
- QDCT_JD_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME+150;
- QDCT_MotorStep = 151;
- }
- break;
- case 151:
- if(QDCT_JD_OUT || (dwTickCount >= QDCT_MotorDelay))
- {
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED/2,-(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),
- QDCT_PARAM_START_SPEED,QDCT_PARAM_START_SPEED,QDCT_PARAM_ACC_PULSE,QDCT_PARAM_DEC_PULSE,0);
- QDCT_MotorStep = 152;
- }
- break;
- case 152:
- if(!X_DRV) QDCT_MotorStep = 0;
- break;
- //以下为夹子进去夹废料
- case 200:
- //QDCT_JJ_DIR = QDCT_JJ_DIR_P;
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_GO_LOWSPEED,dwRealPos-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)
- {
- dwRealPos = GetPos(X_AXIS);
- user_datas[121] = dwRealPos;// GetPos(Y_AXIS);//QDCT_HZhuangLiaoStep;//QDCT_AutoStep;
- 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] = QDCT_QZhuangLiaoStep;
- //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 )
- {
- if(QDCT_GO_LIMIT_IN)
- {
- QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
- QDCT_XiaQieStep = 0;
- }
- else
- {
- QDCT_SetAlarmCode(QDCT_DEC_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_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;
- 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_LATOU))
- {
- QDCT_XM_OUT = 1; //下模输出
- QDCT_HeMoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_HeMoStep = 2;
- QDCT_QZhuangLiaoStep = 0;
- QDCT_HZhuangLiaoStep = 0;
- }
- }
- 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)
- {
- QDCT_SetAlarmCode(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 || (dwRealPos > 1600) || ((dwRealPos > 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;
-
- 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 + 85;
- }
- 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 + 55;
- }
- 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(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_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_MotorStep = 61;
- dwZipCnt = 0;
- }
- else if(QDCT_SQ_LIMIT_IN)
- QDCT_SetAlarmCode(QDCT_SQ_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_bManHHSL)
- {
- QDCT_bManHHSL = 0;
- QDCT_HHSL_OUT = ~QDCT_HHSL_OUT;
-
- if(QDCT_XM_OUT || QDCT_HTLT_LIMIT_IN)QDCT_HHSL_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;
- QDCT_SZ_OUT = ~QDCT_SZ_OUT;
- }
- //电机控制
- 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;
- 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;
- //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)
- {
- //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)
- {
- //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_MotorStep == 0) && (QDCT_AutoStep == 0))
- {
- if(Y_DRV)AxisDecStop(Y_AXIS);
- }
-
- if(QDCT_bYL)
- {
- QDCT_bYL = 0;
- QDCT_YL_OUT = ~QDCT_YL_OUT;
- }
-
- 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
|