123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989 |
- #include "global.h"
- #if HONG_YE_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;
- static long save_limit_pos,cRealPos;
- unsigned char cCheckLianFlg = 0;
- unsigned char cCheckLianFlgEN = 0;
- unsigned char cGoLimitEn = 0;
- void QueDuan_ExtiActionX31(void)
- {
- cCheckLianFlg = 1;
-
- // user_datas[123]++;
- }
- 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(); // 调用脚踏开关检测程序
- }
- //手动动作
- void QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
- 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 = 1;
- 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_XiaQieStep == 0) && !QD_SHANG_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(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;
- if(QD_PARAM_TL_MODE)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- }
- }
- QD_bSingle = 0;
- }
- //停止
- if(STOP_IN_UP || bStop)
- {
- bStop = 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;
- 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;
- 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;
- 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_BinLianStep;
- 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;
- 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)
- {
- 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;
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_GO_LOW_SPEED,PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH));
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 33;
- }
- }
- }
- break;
- case 32:
- if(QD_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- cCheckLianFlg = 0;
- checkdelay_buff = cRealPos;
-
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep = 33;
- dwTickCount = QD_MotorDelay;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- QD_MotorStep = 36;
- }
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- cCheckLianFlg = 0;
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- 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_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)
- {
- cCheckLianFlgEN = 1;
- if(cCheckLianFlg)
- {
- cCheckLianFlg = 0;
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 35;
- }
- }
- }
- else
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
- {
- QD_MotorStep = 36;
- }
- }
- break;
- case 35:
- if(cCheckLianFlg)
- {
- cCheckLianFlg = 0;
- gou_zhen_buff = cRealPos;
- }
-
- 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)))
- {
- cCheckLianFlgEN = 0;
- if(QD_PARAM_DEC_MODE == 0)QD_GZ_VAVLE = 1;
- QD_YD_VAVLE = 1;
- QD_BL_VAVLE = 1;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_MotorStep = 37;
- }
- break;
- case 37:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 38;
- }
- break;
- case 38:
- 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;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- // 切断完成后拉电机动作
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_MotorDelay = dwTickCount + 50;
- QD_JD_VAVEL = 0;
-
- }
- else if(QD_PARAM_SJZ_LENGTH <= 100)
- {
- QD_MotorDelay = dwTickCount + 40;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 200)
- {
- QD_MotorDelay = dwTickCount + 30;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 300)
- {
- QD_MotorDelay = dwTickCount + 20;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 400)
- {
- QD_MotorDelay = dwTickCount + 10;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 500)
- {
- QD_MotorDelay = dwTickCount + 5;
- QD_JD_VAVEL = 0;
- }
- else
- {
- QD_MotorDelay = dwTickCount;
- }
- QD_MotorStep = 41;
- }
- break;
- case 41:
- if(dwTickCount >= QD_MotorDelay)
- {
- save_buff = cRealPos;
-
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH));
- QD_MotorStep = 42;
- }
-
- break;
-
- case 42: // 切断完成后拉电机动作
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - save_buff)))
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- 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)
- {
- 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_GO_LOW_SPEED);
- }
- 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 + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH))
- {
-
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- else
- {
- 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_BL_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;
- 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_BinLianStep;
- 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;
- 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_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);
- AxisMovePos(X_AXIS,QD_PARAM_BACK_SPEED,-length_buff);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_GO_LOW_SPEED,PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH));
- 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_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- cCheckLianFlg = 0;
- checkdelay_buff = cRealPos;
-
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- // QD_CheckDelay = dwTickCount + QD_PARAM_DELAY_CHECK;
- 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))
- {
- // if(X_DRV)MoveChangSpeedPos(X_AXIS, QD_PARAM_GO_LOW_SPEED,PosToPulse(X_AXIS,QD_PARAM_Back_LOW_SPEED_LENGTH));
- }*/
- QD_MotorStep = 36;
- }
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- cCheckLianFlg = 0;
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- // QD_CheckDelay = dwTickCount + QD_PARAM_DELAY_CHECK;
- 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_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_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)
- {
- //user_datas[125]= cRealPos - checkdelay_buff;
- cCheckLianFlgEN = 1;
- if(cCheckLianFlg)//(!QD_GUO_LIAN_IN)
- {
- // AxisChangeSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- cCheckLianFlg = 0;
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 35;
- }
- }
- }
- else
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
- {
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 36;
- }
- }
- break;
- case 35:
- if(cCheckLianFlg)
- {
- cCheckLianFlg = 0;
- gou_zhen_buff = cRealPos;
- }
-
- 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)))
- {
- cCheckLianFlgEN = 0;
- 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 + VAVLE_ALARM_TIME;
- 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;
- }
- QD_MotorStep = 0;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- // 切断完成后拉电机动作
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_MotorDelay = dwTickCount + 50;
- QD_JD_VAVEL = 0;
-
- }
- else if(QD_PARAM_SJZ_LENGTH <= 100)
- {
- QD_MotorDelay = dwTickCount + 40;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 200)
- {
- QD_MotorDelay = dwTickCount + 30;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 300)
- {
- QD_MotorDelay = dwTickCount + 20;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 400)
- {
- QD_MotorDelay = dwTickCount + 10;
- QD_JD_VAVEL = 0;
- }
- else if(QD_PARAM_SJZ_LENGTH <= 500)
- {
- QD_MotorDelay = dwTickCount + 5;
- QD_JD_VAVEL = 0;
- }
- else
- {
- QD_MotorDelay = dwTickCount;
- }
- QD_MotorStep = 41;
- }
- break;
- case 41:
- if(dwTickCount >= QD_MotorDelay)
- {
- save_buff = cRealPos;
-
- if(QD_PARAM_TL_MODE)QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH));
- QD_MotorStep = 42;
- }
-
- break;
-
- case 42: // 切断完成后拉电机动作
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - save_buff)))
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- 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;
- }
- // cGoLimitEn = 1;
- SetAccTime(X_AXIS,10);
- SetDecTime(X_AXIS,10);
- 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;
- 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 + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH))
- {
-
- 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(void) //
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
- case QD_QQ_TUIFANGKUAI: QueDuan_Motor_QD();break;
- default:;
- }
- }
- //超声方式下切
- void QueDuan_XiaQue_CS(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 2;
- break;
- case 2:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XM_VAVLE = 1;
- 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:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_GZ_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY; //
- QD_XiaQieStep = 5;
- }
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_TFK_VAVEL = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(QD_GOUZHEN_IN)
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 7;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 7:
- if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 8;
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 8:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 9;
- }
- break;
- case 9:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_TFK_VAVEL = 0;
- QD_GZ_VAVLE = 0;
-
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 10;
- }
- break;
- case 10:
- 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_TuiLianAction(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;
- 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_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 + QD_PARAM_CUT_DELAY;
- QD_TFK_VAVEL = 1;
- QD_XiaQieStep = 2;
- }
- 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;
- 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(void)
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_QQ_TUIFANGKUAI:QueDuan_XiaQue_QD();break;
- default:;
- }
- }
- #endif
|