12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564 |
- #include "global.h"
- #if XIN_SHENG_MACHINE
- void QueDuan_AlarmProtect(void);
- void QueDuan_ManualAction(void);
- void QueDuan_AutoAction(void);
- void QueDuan_StepCheckStart(void);
- void QueDuan_XiaQue(void);
- void QueDuan_Motor(void);
- void QueDuan_YuanDianAction(void);
- void QueDuan_TuiLianAction(void);
- void QueDuan_TuiFangKuai(void);
- void QueDuan_ExtiActionX31(void);
- void QueDuan_BingLian(void);
- static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
- static long save_limit_pos,cRealPos;
- unsigned char cCheckLianFlg = 0;
- unsigned char cCheckLianFlgEN = 0;
- unsigned char cGoLimitEn = 0;
- long TestDisplay;
- void QueDuan_ExtiActionX31(void)
- {
- cCheckLianFlg = 1;
- }
- void QD_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(QD_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void QueDuan_InitAction(void)
- {
- float length_buff,pulse_buff;
- save_limit_pos = QD_SAVE_POS;
- axis_x->speed_unit = 500;
- SetAccTime(X_AXIS,10);
- SetDecTime(X_AXIS,10);
-
- length_buff = QD_PARAM_CYCLE_LENGTH;
- pulse_buff = QD_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
-
- axis_y->speed_unit = 300;
- SetAccTime(Y_AXIS,3);
- SetDecTime(Y_AXIS,3);
-
- length_buff = QD_PARAM_TL_CYCLE_LENGTH;
- pulse_buff = QD_PARAM_TL_CYCLE_PULSE;
- YGearRatio = pulse_buff/length_buff;
-
- QD_SZ_OUT = 1;
- }
- void QueDuan_Action(void)
- {
- QueDuan_AlarmProtect();
- QueDuan_TuiFangKuai();
- QueDuan_Motor();
- QueDuan_XiaQue();
- QueDuan_ManualAction();
- QueDuan_YuanDianAction();
- QueDuan_TuiLianAction();
- QueDuan_BingLian();
- QueDuan_AutoAction();
- QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
- }
- long testFlg = 0;
- //手动动作
- void QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
-
- if(QD_bCalSin || testFlg)
- {
- QD_bCalSin = 0;
- testFlg = 0;
- // CalculateSModelLine(FreqTab_X,MAX_SPEED,MAX_FREQ,MIN_FREQ,FLEXIBLE);
- }
- if(QD_bClearTotal) //切断计数清零
- {
- QD_bClearTotal = 0;
- ClrcToTal(QD_TOTAL_ADDR);
- }
-
- if(QD_bClearNowTotal)
- {
- QD_bClearNowTotal = 0;
- QD_PARAM_NOW_CNT = 0;
- }
-
- if(QD_bXiaQie)
- {
- QD_bXiaQie = 0;
- if(QD_XiaQieStep == 0)QD_XiaQieStep = 1;
- }
-
- if(QD_bQianDianDW)
- {
- QD_bQianDianDW = 0;
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 61;
- cZipCnt = 0;
- }
- }
-
- if(QD_bTL)
- {
- if(QD_PARAM_TL_MODE)
- {
- if(!Y_DRV)AxisMovePos(Y_AXIS,QD_PARAM_TL_SPEED,QD_PARAM_TL_LENGTH);
- }
- else
- {
- QD_bTL = 0;
- QD_TL_VAVLE = ~QD_TL_VAVLE;
- }
- }
-
- if(!Y_DRV)QD_bTL = 0;
-
- if(QD_bYD)
- {
- QD_bYD = 0;
- QD_YD_VAVLE = ~QD_YD_VAVLE;
- }
-
- if(QD_bGZ)
- {
- QD_bGZ = 0;
- QD_GZ_VAVLE = ~QD_GZ_VAVLE;
- }
-
- if(QD_bJD)
- {
- QD_bJD = 0;
- QD_JD_VAVEL = ~QD_JD_VAVEL;
- }
-
- if(QD_bXM)
- {
- QD_bXM = 0;
- QD_XM_VAVLE = ~QD_XM_VAVLE;
- }
-
- if(QD_bSM)
- {
- QD_bSM = 0;
- QD_SM_VAVLE = ~QD_SM_VAVLE;
- }
-
- if(QD_bTFK)
- {
- QD_bTFK = 0;
- QD_TFK_VAVEL = ~QD_TFK_VAVEL;
- }
-
- if(QD_bTB)
- {
- QD_bTB = 0;
- QD_TABLE_VAVLE = ~QD_TABLE_VAVLE;
- }
-
- if(QD_bYBD)
- {
- QD_bYBD = 0;
- QD_YBD_VAVLE = ~QD_YBD_VAVLE;
- }
-
- if(QD_bTestCS)
- {
- QD_bTestCS = 0;
- QD_CS_OUT = 1;
- QD_CSDelay = dwTickCount + QD_PARAM_CS_TIME;
- }
-
- if(QD_bBL)
- {
- QD_bBL = 0;
- QD_BL_VAVLE = ~QD_BL_VAVLE;
- }
-
- if(QD_XiaQieStep == 0)
- {
- if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0;
- }
-
- if(QD_bYuanDianDW)
- {
- QD_bYuanDianDW = 0;
- if(QD_YuanDianStep == 0)QD_YuanDianStep = 1;
- }
-
- //电机控制
- if(QD_bGoMotor && !QD_QIAN_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_N;
- if(!X_DRV)AxisContinueMove(X_AXIS,20,QD_DIR_N);
- }
-
- if(QD_bBackMotor && !QD_BACK_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
-
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- if(!X_DRV)AxisContinueMove(X_AXIS,20,QD_DIR_P);
- }
-
- if(!QD_bGoMotor && !QD_bBackMotor && (QD_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(QD_QIAN_LIMIT_IN && (QD_MotorStep == 0) && !QD_bBackMotor &&(QD_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- }
- }
- void QueDuan_YuanDianAction(void)
- {
- switch(QD_YuanDianStep)
- {
- case 0:break;
- case 1:
- if(QD_MotorStep == 0)QD_MotorStep = 61;
- QD_YuanDianStep = 2;
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 30;
- QD_YuanDianStep = 3;
- QD_JD_VAVEL = 1;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 0;
- QD_YuanDianStep = 0;
- }
- break;
- }
- }
- void QueDuan_AlarmProtect(void)
- {
- cRealPos = GetPos(X_AXIS);
- if(QD_PARAM_BACK_ALARM_MODE)
- { //感应后限模式
- if(!bRunning)
- {
- if(QD_BACK_LIMIT_IN_UP)
- {
- if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
- {
- QD_bBackMotor = 0;
-
- AxisDecStop(X_AXIS);
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
-
- }
- }
- }
- else
- {
- if(QD_BACK_LIMIT_IN_UP)
- {
- AxisDecStop(X_AXIS);
-
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
- }
- }
- }
- else
- {
-
- if(QD_QIAN_LIMIT_IN_UP) //数控后限模式
- {
- save_limit_pos = cRealPos;
- SetData32bits(200,save_limit_pos);
- }
-
- if(QD_PARAM_MAX_BACK_LENGTH < (cRealPos - save_limit_pos))
- {
- if(!bRunning)
- {
- if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
- {
- QD_bBackMotor = 0;
- AxisDecStop(X_AXIS);
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
-
- }
- }
- else
- {
- AxisDecStop(X_AXIS);
- QD_JD_VAVEL = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
- }
- }
-
- }
-
- // if(!QD_KADAI_IN)QD_KaDaiDelay = dwTickCount + 3000;
-
- /* if(bRunning)
- {
- if(dwTickCount >= QD_KaDaiDelay)QD_SetAlarmCode(QD_KA_DAI_ALARM);
- }*/
- }
- void QueDuan_AutoAction(void)
- {
- if(bRunning)
- {
- if(dwTickCount >= QD_TBDelay)QD_TABLE_VAVLE = 0;
- switch(QD_AutoStep)
- {
- case 1:
- if(dwTickCount >= QD_AutoDelay)
- {
- QD_AutoStep = 2;
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 61; //前点定位
- // else QD_MotorStep = 1;
- }
- }
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- if(QD_PARAM_DC_MODE == 0)
- QD_MotorStep = 20; //后退到位
- else
- QD_MotorStep = 30;
- QD_AutoStep = 3;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- if(QD_XiaQieStep == 0)QD_XiaQieStep = 1;
- QD_AutoStep = 4;
- }
- break;
- case 4:
- if(QD_MACHINE_TYPE == QD_QQ_TUIFANGKUAI)
- {
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 4)) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- }
- QD_AutoStep = 5;
- }
- }
- else if(QD_MACHINE_TYPE == QD_NO_GL_TUIFANGKUAI)
- {
-
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 5)) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- }
- QD_AutoStep = 5;
- }
- }
- else
- {
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep >= 13)) && !QD_SHANG_MU_LIMIT_IN && !QD_XIA_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- // QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- }
- QD_AutoStep = 5;
- }
- }
- break;
- case 5:
- if(QD_MotorStep == 0)
- {
- cZipCnt++;
- QD_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(QD_TOTAL_ADDR);
- CalProSP(QD_PROSPEED_ADDR);
-
- if(cTableCnt >= QD_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- QD_TABLE_VAVLE = 1;
- QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME;
- }
-
- if((GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) || SingOneFlg)
- {
- bRunning = 0;
- QD_AutoStep = 0;
- SingOneFlg = 0;
-
- if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
- }
- else
- {
- QD_AutoStep = 1;
-
- if(QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU)
- {
- QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME + 50;
- QD_PARAM_NOW_CNT = 0;
- }
- else
- QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- void QueDuan_StepCheckStart(void)
- {
- // 启动
- if((START_IN_UP) || bStart || QD_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (QD_AutoStep == 0))
- {
- if(!QD_SHANG_MU_ORIGIN_IN)QD_SetAlarmCode(QD_SM_YUANWEI);
- else if(QD_XIA_MU_LIMIT_IN)QD_SetAlarmCode(QD_XM_DAOWEI);
- else if(GetAlarmCode(QD_ALARM_ADDR) != 0);
- else if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
- else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM);
- else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM);
- else
- {
- bRunning = 1;
- QD_AutoStep = 1;
- if(QD_bSingle) SingOneFlg= 1;
- cZipCnt = 0;
- cTuiFangKuaiCnt = 0;
- if(QD_PARAM_TL_MODE)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- }
- }
- QD_bSingle = 0;
- }
- //停止
- if(STOP_IN_UP || bStop)
- {
- bStop = 0;
- user_datas[127] = 0;
- /* if(bRunning)
- {
- if(SingOneFlg)
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- SingOneFlg = 0;
- QD_JD_VAVEL = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_XHG_VAVLE = 0;
- // QD_CS_OUT = 0;
- QD_TL_VAVLE = 0;
- QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- QD_TFK_VAVEL = 0;
- QD_TABLE_VAVLE = 0;
- QD_BL_VAVLE = 0;
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- QD_CheckDelay = dwTickCount;
-
- AxisDecStop(X_AXIS);
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }
- else
- {
- SingOneFlg = 1;
- }
- }
- else
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 0;
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- QD_CheckDelay = dwTickCount;
- SingOneFlg = 0;
- QD_JD_VAVEL = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVEL= 0;
- QD_TL_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- //QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- QD_XHG_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }*/
-
- if(bRunning)
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 0;
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- QD_CheckDelay = dwTickCount;
- dwTickCount = QD_TBDelay;
- SingOneFlg = 0;
- QD_JD_VAVEL = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVEL= 0;
- QD_TL_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- //QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- QD_XHG_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }
- else
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 0;
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- QD_CheckDelay = dwTickCount;
- dwTickCount = QD_TBDelay;
- SingOneFlg = 0;
- QD_JD_VAVEL = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVEL= 0;
- QD_TL_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- QD_XHG_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }
- }
-
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_YuanDianStep = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_TuiFangKuaiStep = 0;
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- QD_CheckDelay = dwTickCount;
- SingOneFlg = 0;
- bRunning = 0;
- AxisDecStop(X_AXIS);
- dwTickCount = QD_TBDelay;
- QD_TABLE_VAVLE = 0;
- }
-
- }
- void QueDuan_Motor_CS(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- user_datas[124]= QD_MotorStep;
- user_datas[125]= go_length_buff;
- user_datas[123] = length_buff;
- user_datas[127] = cRealPos;
- // user_datas[126] = go_buff - cRealPos;
- // user_datas[121] = QD_XiaQieStep;
-
-
- switch(QD_MotorStep)
- {
- case 0:
- break;
- case 1: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE && !QD_PARAM_TL_MODE)QD_TuiLianStep = 1;
- QD_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 3;
- QD_JD_VAVEL = 0;
- }
- break;
- case 3:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
- {
- if(cZipCnt == 0)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); //第一条走低速
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,(length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH +QD_PARAM_SJZ_LENGTH),QD_PARAM_GO_LOW_SPEED,0xFFFFFF,QD_DIR_P);//第二条开始走两段速
- }
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 4;
- }
- break;
- case 4:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 5;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
-
- break;
- case 5:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 6;
- }
- break;
- case 6:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0))
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 7;
- QD_MotorDelay = dwTickCount + 100;
- }
- break;
- case 7:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YBD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
- case 20:// 后退使用电机定长
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 21;
- break;
- case 21:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-QD_PARAM_ZIPPER_LENGTH);
- QD_MotorStep = 22;
- }
- break;
- case 22:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_FZ;
- QD_MotorStep = 23;
- }
- break;
- case 23:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 24;
- }
- break;
- case 24:
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 31;
-
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
- break;
- case 31: // 后退使用钩针定长
- if(dwTickCount >= QD_MotorDelay)
- {
- save_buff = cRealPos;
- back_buff = cRealPos;
-
- if(QD_PARAM_DEC_MODE == 0)
- {
- if(QD_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- }
- else
- {
- if(cZipCnt < 2)
- {
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- else
- {
- gouzhen_buff = cRealPos;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)));
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 33;
- }
- }
- }
- break;
- case 32:
- if(QD_PARAM_DEC_MODE)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep = 33;
- dwTickCount = QD_MotorDelay + QD_PARAM_DELAY_XM;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- dwTickCount = QD_MotorDelay;
- QD_MotorStep = 36;
- }
- }
- else
- {
- if(QD_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)))))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- else
- {
-
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- break;
- case 33:
- if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0))
- {
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_XM_VAVLE = 1;
- QD_MotorStep = 34;
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep = 34;
- }
- }
- break;
- case 34:
- if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0))
- {
- if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && QD_PARAM_LT_ENABLE) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 35;
- }
- }
- }
- else
- {
- if(QD_PARAM_GOUZHEN_LENGTH != 0)
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - (QD_PARAM_DELAY_XM_LENGTH)))QD_XM_VAVLE = 1;
- if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
- {
- QD_XM_VAVLE = 1;
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 36;
- }
- }
- else
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - (QD_PARAM_DELAY_XM_LENGTH)))
- {
- QD_XM_VAVLE = 1;
- QD_MotorStep = 36;
- }
- }
- }
- user_datas[121] = gouzhen_buff;
- user_datas[126] = QD_PARAM_DELAY_XM_LENGTH;
- break;
- case 35:
-
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- }
-
- if(QD_GUO_LIAN_IN_UP)
- {
- gou_zhen_buff = cRealPos;
- }
-
- if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 36;
- }
- break;
- case 36:
- if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
- {
- if(QD_PARAM_GOUZHEN_LENGTH == 0)QD_GZ_VAVLE = 1;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 37;
- }
- break;
- case 37:
- if(QD_XIA_MU_LIMIT_IN)
- {
- QD_MotorStep = 38;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- else if(dwTickCount >= QD_MotorDelay) QD_SetAlarmCode(QD_XM_DAOWEI);
- break;
- case 38:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_TFK_VAVEL = 1;
- QD_MotorStep = 39;
- }
- break;
- case 39:
- if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
- {
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH;
- }
- if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
- QD_MotorStep = 0;
- }
- break;
- case 40:
- dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- QD_MotorStep = 41;
- break;
- case 41:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
- QD_MotorStep = 45;
-
- }
- break;
-
- case 45: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 43;
- }
- break;
- case 43:
- // 切断完成后拉电机动作
- if(dwTickCount >= QD_MotorDelay)
- {
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- user_datas[126] = cRealPos - jz_buff;
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
-
- break;
-
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
-
- if(QD_PARAM_TL_MODE)
- {
- }
- else
- {
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1;
- }
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 63;
- QD_JD_VAVEL = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
- {
- go_buff = cRealPos;
- if(cZipCnt > 0)
- {
- MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);//
- }
- else
- {
- MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED);
- }
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 64;
- }
- break;
- case 64:
- if(QD_PARAM_GO_MODE)
- {
- if(cZipCnt > 0)
- {
- if(((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || (QD_QIAN_DEC_IN_UP))
- {
-
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- else
- {
- if(QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- }
- else
- {
- QD_MotorStep =65;
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- if(QD_PARAM_DAO_MODE)
- {
- dandao_buff = cRealPos;
- QD_MotorStep = 70;
- }
- else
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 70:
- if((dandao_buff - cRealPos) >= QD_PARAM_DANDAO_MODE_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- break;
- case 66:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 68;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
-
- }
- }
- //推方块动作
- void QueDuan_TuiFangKuai(void)
- {
-
- }
- void QueDuan_BingLian(void)
- {
- static long bl_pos_buff;
-
- switch(QD_BinLianStep)
- {
- case 0:break;
- case 1:
- bl_pos_buff = cRealPos;
- QD_BinLianStep = 2;
- break;
- case 2:
- if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
- {
- QD_BL_VAVLE = 1;
- QD_BinLianStep = 3;
- }
-
- break;
- case 3:
- if(QD_SM_VAVLE)QD_BL_VAVLE = 0;
- break;
- default:;
- }
-
- }
- void QueDuan_Motor_QD(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- user_datas[124]= QD_MotorStep;
- // user_datas[125]= go_length_buff;
- // user_datas[123] = length_buff;
- user_datas[127] = cRealPos;
- user_datas[126] = go_buff - cRealPos;
- user_datas[121] = QD_PARAM_GOUZHEN_LENGTH;
- if(QD_GUO_LIAN_IN_DW)user_datas[122]++;
- switch(QD_MotorStep)
- {
- case 0:
- break;
- case 1: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE && !QD_PARAM_TL_MODE)QD_TuiLianStep = 1;
- QD_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 3;
- QD_JD_VAVEL = 0;
- }
- break;
- case 3:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
- {
- if(cZipCnt == 0)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P); //第一条走低速
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,(length_buff - QD_PARAM_Go_LOW_SPEED_LENGTH + QD_PARAM_BACK_LENGTH +QD_PARAM_SJZ_LENGTH),QD_PARAM_GO_LOW_SPEED,0xFFFFFF,QD_DIR_P);//第二条开始走两段速
- }
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 4;
- }
- break;
- case 4:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 5;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
-
- break;
- case 5:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 6;
- }
- break;
- case 6:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0))
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 7;
- QD_MotorDelay = dwTickCount + 100;
- }
- break;
- case 7:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YBD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
- case 20:// 后退使用电机定长
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 21;
- break;
- case 21:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_N;
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-QD_PARAM_ZIPPER_LENGTH);
- QD_MotorStep = 22;
- }
- break;
- case 22:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_FZ;
- QD_MotorStep = 23;
- }
- break;
- case 23:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_DIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 24;
- }
- break;
- case 24:
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 31;
-
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
- break;
- case 31: // 后退使用钩针定长
- if(dwTickCount >= QD_MotorDelay)
- {
- save_buff = cRealPos;
- back_buff = cRealPos;
- SetAccTime(X_AXIS,5);
- SetDecTime(X_AXIS,5);
-
-
- if(QD_PARAM_DEC_MODE == 0)
- {
- if(QD_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- }
- else
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- if(cZipCnt < 2)
- {
- QD_XHG_VAVLE = 0;
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- else
- {
- gouzhen_buff = cRealPos;
- QD_XHG_VAVLE = 1;
- //AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,(length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH),QD_PARAM_GO_LOW_SPEED,QD_PARAM_Back_LOW_SPEED_LENGTH,QD_DIR_N);
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)));
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 33;
- }
-
- // AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_N);
- }
- }
- break;
- case 32:
- if(QD_PARAM_DEC_MODE)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- QD_MotorStep = 36;
- }
- }
- else
- {
- if(QD_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)))))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- else
- {
-
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- break;
- case 33:
- if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0))
- {
- if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && QD_PARAM_LT_ENABLE) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
- {
- if(QD_PARAM_GOUZHEN_LENGTH != 0)QD_GZ_VAVLE = 1;
- QD_MotorStep = 34;
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - QD_PARAM_Back_LOW_SPEED_LENGTH))
- {
-
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 34;
- }
- }
- break;
- case 34:
- if((cZipCnt < 2) || (QD_PARAM_DEC_MODE == 0))
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 35;
- }
- }
- else
- {
- if(QD_PARAM_GOUZHEN_LENGTH != 0)
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
- {
- if(QD_PARAM_GOUZHEN_LENGTH != 0)QD_GZ_VAVLE = 1;
- QD_MotorStep = 36;
- }
- }
- else
- {
- QD_MotorStep = 36;
- }
- }
- break;
- case 35:
-
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- }
-
- if(QD_GUO_LIAN_IN_UP)
- {
- gou_zhen_buff = cRealPos;
- }
- if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 36;
- }
- break;
- case 36:
- if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
- {
- if(QD_PARAM_GOUZHEN_LENGTH == 0)QD_GZ_VAVLE = 1;
- if(QD_PARAM_DEC_MODE == 0)QD_GZ_VAVLE = 1;
- if(!QD_PARAM_TL_MODE)QD_YBD_VAVLE = 1;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_MotorStep = 37;
- }
- break;
- case 37:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_TFK_VAVEL = 1;
- QD_MotorDelay = dwTickCount + 1000;
- QD_MotorStep = 38;
- }
- break;
- case 38:
- if(QD_GOUZHEN_IN && !X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
- {
- if(QD_PARAM_TL_MODE)QD_YBD_VAVLE = 1;
-
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff - QD_PARAM_OFFSET_LENGTH;
- }
- if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
- cTuiFangKuaiCnt = 0;
- QD_MotorStep = 0;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- if(cTuiFangKuaiCnt == 0)
- {
- QD_MotorStep = 100;
- QD_TFK_VAVEL = 0;
- cTuiFangKuaiCnt++;
- QD_MotorDelay = dwTickCount + 1000;
- }
- else
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 100:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 37;
- }
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
-
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
- QD_MotorStep = 45;
-
- }
- break;
-
- case 45: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 43;
- }
- break;
- case 41:
-
- if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
-
- QD_MotorDelay = dwTickCount + 20;
- QD_MotorStep = 42;
- }
- break;
- case 42:
- if(dwTickCount >= QD_MotorDelay)
- {
-
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 44;
- }
-
- break;
-
- case 43:
- // 切断完成后拉电机动作
- if(dwTickCount >= QD_MotorDelay)
- {
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- user_datas[126] = cRealPos - jz_buff;
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
-
- break;
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
-
-
- if(QD_PARAM_TL_MODE)
- {
- // if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- else
- {
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1;
- }
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 63;
- QD_JD_VAVEL = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))
- {
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_N;
- go_buff = cRealPos;
- if(cZipCnt > 0)
- {
- MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);//
- }
- else
- {
- MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED);
- }
- // MoveAction_Const_Stop(X_AXIS, QD_DIR_P,QD_PARAM_GO_HIGH_SPEED);//
- // AxisContinueMove(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_DIR_P); //第一条走低速
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
- break;
- case 64:
- if(QD_PARAM_GO_MODE)
- {
- if(cZipCnt > 0)
- {
-
- if(((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,30))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
-
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- else
- {
- // if(QD_QIAN_DEC_IN)
- {
- // if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- }
- else
- {
- // if(QD_QIAN_DEC_IN)
- {
- // if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- if(QD_PARAM_DAO_MODE)
- {
- dandao_buff = cRealPos;
- QD_MotorStep = 70;
- }
- else
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 70:
- if((dandao_buff - cRealPos) >= QD_PARAM_DANDAO_MODE_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- break;
- case 66:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 68;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YBD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
-
- }
- }
- //不带过链感应长度输入电机长度
- void QueDuan_Motor_NoGL(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- user_datas[124]= QD_MotorStep;
- // user_datas[125]= go_length_buff;
- // user_datas[123] = length_buff;
- // user_datas[127] = cRealPos;
- // user_datas[126] = go_buff - cRealPos;
- // user_datas[121] = QD_PARAM_GOUZHEN_LENGTH;
- if(QD_GUO_LIAN_IN_DW)user_datas[122]++;
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 31;
-
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- // AxisContinueMove(X_AXIS,QD_PARAM_BACK_SPEED,QD_DIR_P);
- MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 33;
- }
- break;
- case 32:
- if(((cRealPos - gou_zhen_buff) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
- {
- if(user_datas[127] == 0)
- user_datas[127] = cRealPos - gou_zhen_buff;
- save_buff = cRealPos;
- QD_GZ_VAVLE = 1;
- }
- if((cRealPos - back_buff) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - (QD_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)))))
- {
- if(X_DRV)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
-
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 33:
- if(((cRealPos - gou_zhen_buff) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
- {
- QD_GZ_VAVLE = 1;
- if(user_datas[127] == 0)
- user_datas[127] = cRealPos - gou_zhen_buff;
-
- }
-
-
- if(QD_GOUZHEN_IN)
- {
- // AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- //user_datas[126] = cRealPos - save_buff;
- QD_MotorDelay = dwTickCount + 5;
- QD_MotorStep = 34;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH)) && QD_GZ_VAVLE)
- {
- // user_datas[126] = cRealPos - save_buff;
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 34:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- AxisMovePos(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 35;
- }
- break;
- case 35:
- if(!X_DRV)
- {
- QD_MotorStep = 36;
- }
- break;
- case 36:
- QD_MotorStep = 0;
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
-
-
- /* if(1)//(QD_PARAM_SJZ_LENGTH <= 200)
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH));
- QD_MotorStep = 41;
- }*/
- /* else
- {
- QD_JD_VAVEL = 0;
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 43;
- }*/
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_SJ_TIME;
- QD_MotorStep = 45;
-
- }
- break;
-
- case 45: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 43;
- }
- break;
- case 41:
-
- if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
-
- QD_MotorDelay = dwTickCount + 20;
- QD_MotorStep = 42;
- }
- break;
- case 42:
- if(dwTickCount >= QD_MotorDelay)
- {
-
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 44;
- }
-
- break;
-
- case 43:
- // 切断完成后拉电机动作
- if(dwTickCount >= QD_MotorDelay)
- {
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- user_datas[126] = cRealPos - jz_buff;
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
-
- break;
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
- }
-
- if(!QD_TL_VAVLE)
- {
- if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
- {
- QD_TuiLianStep = 1;
- QD_MotorStep = 62;
- }
- }
- else
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN)
- {
- AxisMovePos(X_AXIS,QD_PARAM_FIRST_SPEED,-QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 63;
- QD_JD_VAVEL = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay) && !QD_SHANG_MU_LIMIT_IN)
- {
- go_buff = cRealPos;
- if(cZipCnt > 0)
- {
- MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED);//
- }
- else
- {
- MoveAction_Const_Stop(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED);
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
- break;
- case 64:
- if(((go_buff - cRealPos) > ((QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH - QD_PARAM_FZ_LENGTH) - (QD_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,30))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 66:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 68;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
-
- }
- }
- //电机动作
- void QueDuan_Motor(void) //
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_CS_TUIFANGKUAI:
- {
- QueDuan_Motor_CS();
- }break;
- case QD_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
- case QD_QQ_TUIFANGKUAI: QueDuan_Motor_QD();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_Motor_NoGL();break;
- default:;
- }
- }
- //超声方式下切
- void QueDuan_XiaQue_CS(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(bRunning)
- {
- QD_XiaQieStep = 6;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else
- QD_XiaQieStep = 2;
- break;
- case 2:
- QD_XM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 3;
- break;
- case 3:
- if(QD_XIA_MU_LIMIT_IN)
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- QD_XiaQieStep = 4;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 4:
- QD_GZ_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_XiaQieStep = 5;
-
- break;
- case 5:
- QD_TFK_VAVEL = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 6;
- break;
- case 6:
- if(QD_XIA_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 7;
- QD_XiaQieDelay = dwTickCount + 1000;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 7:
- if(QD_GOUZHEN_IN)
- {
- QD_YD_VAVLE = 1;
- cTuiFangKuaiCnt = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 8;
- }
- else if((dwTickCount >= QD_XiaQieDelay))
- {
- if(cTuiFangKuaiCnt == 0)
- {
- QD_TFK_VAVEL = 0;
- cTuiFangKuaiCnt++;
- QD_XiaQieDelay = dwTickCount + 1000;
- QD_XiaQieStep = 100;
- }
- else
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 100:
- if((dwTickCount >= QD_XiaQieDelay))
- {
- QD_XiaQieStep = 5;
- }
- break;
- case 8:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 9;
- }
- break;
- case 9:
- if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(QD_MACHINE_TYPE == QD_NO_CS_TUIFANGKUAI)
- {
- QD_XiaQieDelay = QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 12;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 10;
- }
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 10:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
- QD_XiaQieStep = 12;
- }
- break;
- case 12:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_TFK_VAVEL = 0;
- QD_GZ_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 13;
- }//
- break;
- case 13:
- if(QD_SHANG_MU_ORIGIN_IN && !QD_XIA_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 0;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
- break;
- }
- }
- void QueDuan_TuiLianNormal(void)
- {
- switch(QD_TuiLianStep)
- {
- case 0:
- break;
- case 1:
- QD_TuiLianStep = 2;
- break;
- case 2:
- QD_YBD_VAVLE = 1;
- QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
- QD_TuiLianStep = 3;
- break;
- case 3:
- if(dwTickCount >= QD_TLDelay)
- {
- if(QD_PARAM_TL_MODE)
- {
- QD_TuiLianStep = 10;
- }
- else
- {
- QD_TL_VAVLE = 1;
- if(!bRunning)QD_TFK_VAVEL = 0;
- QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
- QD_TuiLianStep = 4;
- }
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- // QD_TL_VAVLE = 0;
- QD_TuiLianStep = 0;
- }
- break;
- case 10:
- if(bRunning && QD_PARAM_TL_MODE)AxisMovePos(Y_AXIS,QD_PARAM_TL_SPEED,QD_PARAM_TL_LENGTH);
- QD_TuiLianStep = 11;
- break;
- case 11:
- if(!Y_DRV)
- {
- {
- QD_TuiLianStep = 0;
- }
- }
- break;
- }
- }
- void QueDuan_TuiLianNoGL(void)
- {
- switch(QD_TuiLianStep)
- {
- case 0:
- break;
- case 1:
- QD_TuiLianStep = 2;
- break;
- case 2:
- if(!QD_YD_VAVLE)QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
- QD_YD_VAVLE = 1;
- QD_TuiLianStep = 3;
- break;
- case 3:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TL_VAVLE = 1;
- QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
- QD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TuiLianStep = 0;
- }
- break;
- }
- }
- void QueDuan_TuiLianAction(void)
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_GL_TUIFANGKUAI: QueDuan_TuiLianNoGL();break;
- default:QueDuan_TuiLianNormal();
- }
- }
- //气动推方块方式下切
- void QueDuan_XiaQue_QD(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(!bRunning)
- {
- QD_XiaQieDelay = dwTickCount + 50;
- QD_GZ_VAVLE = 1;
- QD_XiaQieStep = 20;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 2;
- }
- break;
- case 20:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieDelay = dwTickCount + 1000;
- QD_YBD_VAVLE = 1;
- QD_TFK_VAVEL = 1;
- QD_XiaQieStep = 21;
- }
- break;
- case 21:
- if(QD_GOUZHEN_IN)
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- cTuiFangKuaiCnt = 0;
- QD_XiaQieStep = 2;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 22:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieStep = 20;
- }
- break;
- case 2:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 3;
- }
- break;
- case 3:
- if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- QD_XiaQieStep = 4;
- QD_XiaQieDelay = dwTickCount + 100;
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 4:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 0;
- if(bRunning)QD_TFK_VAVEL = 0;
- QD_GZ_VAVLE = 0;
-
- if(!QD_PARAM_TL_MODE)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 5;
- }
- break;
- case 5:
- if(QD_SHANG_MU_ORIGIN_IN && (QD_TuiLianStep == 0))
- {
- if(QD_PARAM_TL_MODE)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- QD_XiaQieStep = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TL_DELAY;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
- break;
- }
- }
- void QueDuan_XiaQue_NO_GL(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- QD_YD_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 2;
- break;
- case 2:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 4;
- }
- }
- break;
- case 4:
- if(QD_SHANG_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 5;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_GZ_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(QD_SHANG_MU_ORIGIN_IN && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- if(!bRunning)QD_JD_VAVEL = 0;
- QD_XiaQieStep = 0;
-
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
-
- break;
- }
- }
- //切断动作
- void QueDuan_XiaQue(void)
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_QQ_TUIFANGKUAI:QueDuan_XiaQue_QD();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- default:;
- }
- }
- #endif
|