123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211 |
- #include "global.h"
- #if FJ_YING_XING_MACHINE ==1
- 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_ExtiActionX31(void);
- void QueDuan_BingLian(void);
- void QD_TuiDaiAction(void);
- static unsigned long cZipCnt = 0,cTableCnt = 0,cTuiFangKuaiCnt = 0;
- static long save_limit_pos,cRealPos;
- static long dwSaveLength;
-
- unsigned char cCheckLianFlg = 0;
- unsigned char cCheckLianFlgEN = 0;
- unsigned char cGoLimitEn = 0;
- short *length_buffer;
- 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;
-
- length_buff = QD_PARAM_CYCLE_LENGTH;
- pulse_buff = QD_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- QD_SZ_OUT = 1;
- }
- void QueDuan_Action(void)
- {
- InputPinConfig();
- QueDuan_AlarmProtect();
- QueDuan_Motor();
- QueDuan_XiaQue();
- QueDuan_ManualAction();
- QueDuan_TuiLianAction();
- QueDuan_BingLian();
- QueDuan_AutoAction();
- QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
- OutputPinConfig();
-
- }
- //手动动作
- void QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
- cGoLimitEn = 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_TL_VAVLE)
- {
- QD_XiaQieStep = 1;
- }
- }
-
- if(QD_bQianDianDW)
- {
- QD_bQianDianDW = 0;
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 61;
- cZipCnt = 0;
- }
- }
-
- if(QD_bTL)
- {
- QD_bTL = 0;
- if(QD_TL_VAVLE)
- {
- QD_TL_VAVLE = 0;
- }
- else if(!QD_GZ_VAVLE && !QD_SM_VAVLE)
- {
- 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_VAVLE = ~QD_JD_VAVLE;
- }
-
- if(QD_bXM)
- {
- QD_bXM = 0;
- QD_XM_VAVLE = ~QD_XM_VAVLE;
- if(!QD_XM_VAVLE)QD_GZ_VAVLE = 0;
- }
-
- if(QD_bSM)
- {
- QD_bSM = 0;
- if(QD_SM_VAVLE)
- QD_SM_VAVLE = 0;
- else if(!QD_TL_VAVLE)
- QD_SM_VAVLE = 1;
- }
- //推方块
- if(QD_bTFK)
- {
- QD_bTFK = 0;
- QD_TFK_VAVLE = ~QD_TFK_VAVLE;
- }
- //台面电机
- 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_bHL) //护链,双开用
- {
- QD_bHL = 0;
- QD_HL_VAVLE = ~QD_HL_VAVLE;
- }
-
- if(QD_bYX)
- {
- QD_bYX = 0;
- QD_YX_VAVLE = ~QD_YX_VAVLE;
- }
- if(QD_XiaQieStep == 0)
- {
- if(dwTickCount >= QD_CSDelay)QD_CS_OUT = 0;
- }
- //电机控制
- if(QD_bGoMotor && !QD_QIAN_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
- // QD_JZ_DIR = QD_YDIR_N;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED/3,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
- }
-
- if(QD_bBackMotor) //后退限位已经取消
- {
- QD_SZ_OUT = 0;
- // QD_JZ_DIR = QD_YDIR_P;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED/3,QD_DIR_P,QD_PARAM_GO_LOW_SPEED/3,15,15);
- }
-
- 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_AlarmProtect(void)
- {
- cRealPos = GetPos(X_AXIS);
- if(!bRunning)
- {
- ;
- //
- #if 0
- if(QD_BACK_LIMIT_IN_UP)
- {
- if((QD_MotorStep == 0) && X_DRV && QD_bBackMotor) //到后限不能再后退但可以点前进
- {
- QD_bBackMotor = 0;
-
- AxisDecStop(X_AXIS);
- QD_JD_VAVLE = 0;
- QD_SetAlarmCode(QD_BACK_ALARM);
-
- }
- }
- #endif
- }
- else
- {
- if((cRealPos > QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH > 3000)
- && (cGoLimitEn != 0))
- {
- AxisEgmStop(X_AXIS);
- QD_JD_VAVLE = 0;
- QD_SetAlarmCode(QD_BACK_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; //前点定位
- }
- cGoLimitEn = 0;
- }
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 30;
- QD_AutoStep = 3;
- cGoLimitEn = 1;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- if(QD_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
-
- if(QD_XiaQieStep == 0)
- QD_XiaQieStep = 1;
- QD_AutoStep = 4;
- }
- }
- break;
- case 4:
-
- // 闭口
- if((QD_XiaQieStep == 0) || ((QD_XiaQieStep == 6) && QD_KB_MODE)|| ((QD_XiaQieStep == 13) && (QD_KB_MODE == 0)))// && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- cGoLimitEn=0;
- QD_MotorStep = 40; //切完后退
-
- }
- QD_AutoStep = 5;
- }
- break;
- case 5:
-
- if(QD_MotorStep == 0)
- {
- cZipCnt++;
- QD_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(QD_TOTAL_ADDR);
- AddToTal(CT_WORKTOTAL_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( 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_PARAM_ZHA_SHU > 0))
- {
- QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME;
- QD_PARAM_NOW_CNT = 0;
- if(QD_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- QD_AutoStep = 0;
- SingOneFlg = 0;
- QD_SetAlarmCode(QD_TOTAL_ALARM);
- }
- }
- 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_XIA_MU_LIMIT_IN && !QD_PARAM_XM_ENABLE)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;
- QD_BL_VAVLE = 0; //并链关
- QD_DGLG_VAVLE = 0; //顶过链杆关
- SetAlarmCode(QD_ALARM_ADDR,0);
- }
- }
- QD_bSingle = 0;
- }
- //停止
- if(STOP_IN_UP || bStop)
- {
- bStop = 0;
- if(bRunning)
- {
-
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- dwTickCount = QD_TBDelay;
- SingOneFlg = 0;
- QD_JD_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVLE= 0;
- QD_TL_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- //QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- QD_DGLG_VAVLE = 0; //顶过链杆关
- AxisDecStop(X_AXIS);
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
- SetAlarmCode(QD_ALARM_ADDR,0);
- }
- else
- {
- QD_AutoDelay = dwTickCount;
- QD_MotorDelay = dwTickCount;
- QD_XiaQieDelay = dwTickCount;
- QD_KaDaiDelay = dwTickCount;
- QD_CSDelay = dwTickCount;
- QD_TBDelay = dwTickCount;
- QD_TFKDelay = dwTickCount;
- QD_TLDelay = dwTickCount;
- dwTickCount = QD_TBDelay;
- SingOneFlg = 0;
- QD_JD_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_YD_VAVLE = 0;
- QD_TFK_VAVLE= 0;
- QD_YX_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_DGLG_VAVLE = 0; //顶过链杆关
- QD_CS_OUT = 0;
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- SetAlarmCode(QD_ALARM_ADDR,0);
- }
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- }
-
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
-
- QD_XiaQieStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 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;
- SingOneFlg = 0;
- bRunning = 0;
- AxisDecStop(X_AXIS);
- dwTickCount = QD_TBDelay;
- QD_TABLE_VAVLE = 0;
- QD_JD_VAVLE=0;
- QD_GZ_VAVLE=0;
- }
-
- }
- //记忆长度模式误差检测
- void QueDuan_CheckLength(long zip_length)
- {
- static long start_dist;
- switch(QD_CheckLengthStep)
- {
- case 0:break;
- case 1:
- start_dist = cRealPos;
- dwSaveLength = 0;
- QD_CheckLengthStep = 2;
- break;
- case 2:
- if(QD_GUO_LIAN_IN_DW){
- dwSaveLength = cRealPos - start_dist;
- // user_datas[127] = cRealPos;
- }
- break;
- }
- }
- #if !QD_KB_MODE //开口
- //开口切专用
- //30步开始后拉开始,分解4种工作模式
- //40步开始用切断后拉动作
- //60步开始为前方向,开闭口一样
- void QueDuan_Motor_KK(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;
- unsigned short ch;
- user_datas[121]= QD_MotorStep;
- user_datas[122]= length_buff;
- user_datas[123] = cRealPos;
- user_datas[124] = GetCurSpeed(X_AXIS);
- user_datas[125] = QD_AutoStep;
- user_datas[126] = QD_XiaQieStep;
- // user_datas[127] = QD_XiaQieStep;
- QueDuan_CheckLength(length_buff);
-
- switch(QD_MotorStep)
- {
- case 30:
- switch(QD_PARAM_BACK_MODE) //开口分四种模式
- {
- case 0: //单数控模式
- QD_MotorStep = 310; //每种模式留20步
- QD_DGLG_VAVLE = 1; //顶过链杆关
- break;
- case 1://单感应模式
- QD_MotorStep = 330; //每种模式留20步
-
- break;
- case 2: //先感应后数控模式+检测
- QD_MotorStep = 350; //每种模式留20步
- break;
- default: //数控模式+过链检测长度
- QD_MotorStep = 370; //每种模式留20步
- break;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- break;
- //310步到315步为数控模式
- case 310:
- QD_MotorStep = 311;
- SetDir(X_AXIS, QD_DIR_P);
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
- break;
- case 311:
- if(dwTickCount >= QD_MotorDelay)
- {
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
-
-
-
-
- //李永庆代码
-
- //两段速度移动距离 拉链长度+慢速长度停止
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
-
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 312;
- }
- break;
- case 312:
- //勾针提前输出 ,争取时间推方块
- if (!QD_GZ_VAVLE && (cRealPos >= (QD_PARAM_ZIPPER_LENGTH- 230)))
- QD_GZ_VAVLE = 1;
-
- if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- QD_MotorStep = 313;
-
- }
- else if(cRealPos >= (QD_PARAM_ZIPPER_LENGTH + (*length_buffer) + QD_PARAM_ERROR_LENGTH))
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 313:
- if(!QD_GZ_VAVLE && ((cRealPos) > (QD_PARAM_ZIPPER_LENGTH - 230)))
- QD_GZ_VAVLE = 1;
-
- if(!X_DRV)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_MotorStep = 314;
- QD_BL_VAVLE = 0; //停止时并链一定要打开
-
- if((QD_PARAM_BACK_MODE == 2) && !QD_DGLG_VAVLE) //模式2,先检测长度后数控
- {//对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
- if(cZipCnt > 1) //长度检测
- {
- if(QD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(((dwSaveLength + QD_PARAM_MOTOR_DELAY_LENGTH) > (length_buff + QD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);//拉链变长,对比警告
- }
- else if((dwSaveLength + QD_PARAM_MOTOR_DELAY_LENGTH+ QD_PARAM_ERROR_LENGTH) < length_buff)
- {
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM); ////拉链变短
- }
-
- QD_CheckLengthStep = 0;
- }
- }
- }
- }
- break;
- case 314:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay)) //数控到停止
- {
- QD_MotorStep = 0;
- QD_TFK_VAVLE = 1; //推方块输出
- }
- break;
- //330步到349步单感应模式
- case 330:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- SetDir(X_AXIS, QD_DIR_P);
- QD_MotorStep = 331;
-
-
-
- user_datas[127] = 0;
- break;
- case 331:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 332;
- if(cZipCnt < 2)
- {
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来QD_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,9000,QD_DIR_P,QD_PARAM_START_SPEED,8,13);
-
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH + (*length_buffer)-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
-
- }
- else
- {
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
- //因为每条都是过链感应,所以直接运行检测模式后拉速度
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_CHECK_BACK_HSPEED,QD_DIR_P,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
-
- }
- }
- break;
- case 332:
- if(cZipCnt > 1) //第二条开始数控降速
- {
- if((cRealPos + QD_PARAM_BACK_LOW_SPEED_LENGTH + 600)>= length_buff)
- {
- CancelPmoveState(X_AXIS); //长度模式去掉
- AxisChangeSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- user_datas[127] = cRealPos;
- QD_MotorStep = 334; //到检测定位
- }
- if(QD_GUO_LIAN_IN_DW) //重新到链上
- {
- CancelPmoveState(X_AXIS);
- AxisChangeSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 335; //到检测定位
- }
- //
- // if((cRealPos >= (QD_PARAM_BACK_LOW_SPEED_LENGTH + 60)) && QD_GUO_LIAN_IN)
- // {
-
- // }
- }
- else //第一条工作
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount + 0;//QD_PARAM_DELAY_XM;
- QD_MotorStep = 333;
- }
- else if((cRealPos >= QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
- {
- // QD_SetAlarmCode(QD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
- }
- }
- break;
- case 333:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 334;
- }
- break;
- case 334:
- if(QD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- //滤波有待调试
- // 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 = 335;
- }
- // }
- }
- break;
- case 335:
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QD_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- //定位停止
- if(((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) && !QD_GUO_LIAN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 336;
- QD_GZ_VAVLE = 1;
- }
- break;
- case 336:
- if(!X_DRV)
- {
- QD_GZ_VAVLE = 1;
-
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- // QD_XM_VAVLE = 1;
- QD_MotorStep = 337;
- }
- break;
- case 337:
- if(1)
- {
- QD_MotorStep = 338;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- // else if(dwTickCount >= QD_MotorDelay) QD_SetAlarmCode(QD_XM_DAOWEI);
- break;
- case 338:
- if((dwTickCount >= QD_MotorDelay))
- {
- QD_TFK_VAVLE = 1; //推方块输出
- QD_MotorStep = 339;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- break;
- case 339:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- SetData32bits(QD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
- }
- else if(cZipCnt > 1) //长度检测
- {
- if(QD_PARAM_ERROR_LENGTH != 0) //长度误差值不能为0
- {
- if(cRealPos >= length_buff) //拉链变长,对比警告
- {
- if((cRealPos - save_buff) > (length_buff+QD_PARAM_ERROR_LENGTH))
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- else //拉链变短
- {
- if((cRealPos - save_buff + QD_PARAM_ERROR_LENGTH) < (length_buff))
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM);
- }
- }
- }
- QD_MotorStep = 0;
- break;
- //350步到369步单感应模式
- case 350:
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- SetDir(X_AXIS, QD_DIR_P);
-
- QD_MotorStep = 351;
-
-
-
- break;
- case 351:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 352;
- //第一,二条都是过链感应,测量长度
- if(cZipCnt < 2)
- {
- if(QD_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
- QD_BinLianStep = 10; //并链起动
- QD_DGLG_VAVLE = 0; //顶过链杆关
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,9000,QD_DIR_P,QD_PARAM_START_SPEED,8,12);
-
- }
- else
- {
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
- QD_DGLG_VAVLE = 1; //顶过链杆关
- QD_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- QD_MotorStep = 311;
- }
- }
- break;
- case 352:
- //前两条都按最低速度工作
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount + 2;//因慢速,加8MS滤波
- QD_MotorStep = 353;
- }
- else if((cRealPos >= QD_PARAM_RUN_LENGTH) && (QD_PARAM_RUN_LENGTH >= 5000)) //模组最长限制
- {
- // QD_SetAlarmCode(QD_PARAM_RUN_LENGTH_ALARM); //超出轨道运行长度
- }
- break;
- case 353:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_MotorStep = 354;
- }
- break;
- case 354:
- if(QD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 355;
- }
-
- }
- break;
- case 355:
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
-
- }
- //在空们都把延时清零
- if(QD_GUO_LIAN_IN)
- {
- gou_zhen_buff = cRealPos;
- }
- //定位停止
- if(((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH) && !QD_GUO_LIAN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 356;
- QD_GZ_VAVLE = 1;
- }
- break;
- case 356:
- if(!X_DRV)
- {
- QD_GZ_VAVLE = 1;
-
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- // QD_XM_VAVLE = 1;
- QD_MotorStep = 357;
- }
- break;
- case 357:
- if(1)
- {
- QD_MotorStep = 358;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- break;
- case 358:
- if((dwTickCount >= QD_MotorDelay))
- {
- QD_TFK_VAVLE = 1; //推方块输出
- QD_MotorStep = 359;
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- break;
- case 359:
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- //测量出来长度
- SetData32bits(QD_PARAM_ZIPPER_LENGTH_ADDR,length_buff);
- }
- QD_MotorStep = 0;
- break;
- //370步到389步为数控模式
- case 370:
- QD_MotorStep = 371;
- SetDir(X_AXIS, QD_DIR_P);
- if(QD_PARAM_BL_ENABLE)
- QD_BinLianStep = 1; //并链起动
-
- QD_CheckLengthStep = 1; //长度检测开始
-
- break;
- case 371:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- //李永庆代码
-
- //两段速度移动距离 拉链长度+慢速长度停止
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH,QD_DIR_P);
-
-
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 372;
- }
- break;
- case 372:
- //勾针提前输出 ,争取时间推方块
- if (!QD_GZ_VAVLE && (cRealPos >= (QD_PARAM_ZIPPER_LENGTH - 230)))
- QD_GZ_VAVLE = 1;
- if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- QD_MotorStep = 373;
-
- }
- break;
- case 373:
- if(!QD_GZ_VAVLE && ((cRealPos) > (QD_PARAM_ZIPPER_LENGTH - 230)))
- QD_GZ_VAVLE = 1;
-
- if(!X_DRV)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_MotorStep = 374;
- QD_BL_VAVLE = 0; //停止时并链一定要打开
- //对比长度 ,发须要有过链信号,模式2,3. 模式0,1不用在这里经
- if(cZipCnt > 1) //长度检测
- {
- if((QD_PARAM_ERROR_LENGTH != 0) && length_buff) //长度误差值不能为0
- {
- if((dwSaveLength > (length_buff + QD_PARAM_ERROR_LENGTH)) || (dwSaveLength == 0))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);//拉链变长,对比警告
- }
- //上升沿的长度
- else if((dwSaveLength + QD_PARAM_ERROR_LENGTH) < length_buff)
- {
- QD_SetAlarmCode(QD_LENGTH_SHORT_ALARM); ////拉链变短
- }
-
- QD_CheckLengthStep = 0;
- }
- }
- else if(cZipCnt == 1) //长度检测
- {
- if(dwSaveLength)
- length_buff = dwSaveLength;
- }
- }
- break;
- case 374:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay)) //数控到停止
- {
- QD_MotorStep = 0;
- QD_TFK_VAVLE = 1; //推方块输出
- }
- break;
- //切完延时后拉带松夹子
- case 40:
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVLE = 0;
- }
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- SetDir(X_AXIS, QD_DIR_P);
-
- QD_MotorStep = 41;
- break;
- case 41:
-
- if((dwTickCount >= QD_MotorDelay))
- {
- jz_buff = cRealPos;
- if(QD_JD_VAVLE)
- //两段速度移动距离
- { // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,QD_PARAM_SJZ_LENGTH,5000,QD_PARAM_BACK_LENGTH,QD_DIR_P);
- }
- else
- {//夹子已经张开
- SetDir(X_AXIS,QD_DIR_P);
- AxisMovePosAccDec(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH),QD_PARAM_START_SPEED,10,10);
- } // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
-
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- QD_JD_VAVLE = 0;
- QD_MotorStep = 43;
- }
- if(!X_DRV)
- {
- QD_JD_VAVLE = 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 + 150;
- SetDir(X_AXIS, QD_DIR_N);
- SetPos(X_AXIS, 0);
- }
- else
- QD_MotorDelay = dwTickCount;
-
- QD_BL_VAVLE = 0;//并链也要打开
- // QD_JZ_DIR = QD_YDIR_N;
- if(!QD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- 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)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- // QD_JZ_DIR = QD_YDIR_P;
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,1000);
- QD_MotorDelay = dwTickCount + 300;
- }
- QD_MotorStep = 63;
- QD_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))// && !QD_SHANG_MU_LIMIT_IN)
- {
-
- // QD_JZ_DIR = QD_YDIR_N;
- SetDir(X_AXIS, QD_DIR_N);
- go_buff = cRealPos;
- QD_YD_VAVLE = 1;
- QD_HL_VAVLE = 1;
- QD_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(cRealPos>(QD_PARAM_GO_LOW_SPEED_LENGTH))
- {
- AxisMoveThreePosNoStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos -QD_PARAM_GO_LOW_SPEED_LENGTH-300,
- QD_PARAM_GO_HIGH_SPEED*2/3,350,
- QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_DIR_N) ;
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
-
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((cRealPos) < (QD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QD_QIAN_DEC_IN))
- {
- user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,QD_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- QD_MotorStep =65;
- }
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- else
- {
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV)
- {
- SetPos(X_AXIS, 0);
- 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_VAVLE = 1;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- QD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_YX_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- void QueDuan_BingLian(void)
- {
- static long bl_pos_buff,HL_delay;
-
- 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_GUO_LIAN_IN_DW || ((cRealPos - bl_pos_buff) >= (QD_PARAM_ZIPPER_LENGTH - QD_PARAM_HL_DELAY_BACK)))
- {
- QD_BL_VAVLE = 0;
- QD_BinLianStep = 0;
- }
- break;
- case 10:
- bl_pos_buff = cRealPos;
- QD_BinLianStep = 11;
- break;
- case 11:
- if((cRealPos - bl_pos_buff) >= QD_PARAM_DELAY_HL_LENGTH)
- {
- QD_BL_VAVLE = 1;
- QD_BinLianStep = 12;
- }
- break;
- case 12://有过链检测
- if(QD_GUO_LIAN_IN_DW)
- {
- QD_BL_VAVLE = 0;
- QD_BinLianStep = 0;
- }
- break;
- default:;
- }
-
- }
- #if QD_KB_MODE==1 //闭口
- //作闭口专用程序
- //不带过链感应长度输入电机长度 闭口有勾针到位
- 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;
- long pulse_buff;
- unsigned short ch,kk;
- user_datas[121] = QD_MotorStep;
- user_datas[122] = QD_AutoStep;
- user_datas[124]= cRealPos;
- user_datas[125]= bRunning;
- // user_datas[123] = length_buff - (*length_buffer);
- // user_datas[127] = cRealPos;
- // user_datas[126] = go_buff - cRealPos;
-
- if((QD_MotorStep >= 101) && (QD_MotorStep <= 103))
- {
- if(QD_QIAN_LIMIT_IN_DW)QD_HL_VAVLE = 0;
- }
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- if(QD_PARAM_BL_ENABLE) //
- QD_BinLianStep = 1;
-
- if(QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) //双开带过链感应
- {
- if(QD_PARAM_DEC_MODE == QD_BACK_NOMAL_DEC_MODE)//测长数控
- QD_MotorStep = 101;
- else
- QD_MotorStep = 31;
- }
- else //闭口走长度
- QD_MotorStep = 31;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- //李永庆代码
- SetDir(X_AXIS, QD_DIR_P);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
- AxisMoveTwoPos(X_AXIS,QD_PARAM_BACK_SPEED,QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH-200,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_BACK_LOW_SPEED_LENGTH + (*length_buffer),QD_DIR_P);
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- break;
- case 32:
- //勾针提前输出
- if (!QD_GZ_VAVLE && ((cRealPos + QD_PARAM_GOUZHEN_LENGTH + 200) >= (QD_PARAM_ZIPPER_LENGTH )))
- QD_GZ_VAVLE = 1;
- if((cRealPos) > (QD_PARAM_ZIPPER_LENGTH-QD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*length_buffer) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- QD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- QD_MotorStep = 33;
- }
- else if(cRealPos >= (QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//QD_PARAM_ERROR_LENGTH))
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 33:
- if(!QD_GZ_VAVLE && (cRealPos + QD_PARAM_GOUZHEN_LENGTH + 200) > (QD_PARAM_ZIPPER_LENGTH ))
- {
- QD_GZ_VAVLE = 1;
- QD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- }
- //提前12MM取消数控模式,进入连续运动
- // if((cRealPos + 180 + 200) > (QD_PARAM_ZIPPER_LENGTH ))
- // {
- // CancelPmoveState(X_AXIS);
- // SetStartSpeed(X_AXIS,1500);
- // AxisChangeSpeed(X_AXIS,1500);
- // }
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + 10;
- QD_YD_VAVLE = 1;
- QD_MotorStep = 34;
- QD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if((cRealPos >= QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))// && dwTickCount >= QD_MotorDelay)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 34:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_YD_VAVLE = 1;
- QD_MotorStep = 35;
- }
- break;
- case 35:
- if(cZipCnt == 0)
- {
- ch = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-90;
- kk = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+90;
- }
- else
- {
- ch = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-70;
- kk = QD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+70;
- }user_datas[128] = ch;
- user_datas[127] = kk;
- if(((cRealPos) < (ch)))
- {
- SetAlarmCode(QD_ALARM_ADDR,QD_LENGTH_LONG_ALARM);
- if(dwTickCount >= QD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((cRealPos > kk))//(QD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(QD_ALARM_ADDR,QD_LENGTH_LONG_ALARM);
- if(dwTickCount >= QD_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
- SetDir(X_AXIS, QD_DIR_P);
- AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,-QD_PARAM_FZ_LENGTH,3000,QD_PARAM_ACC,QD_PARAM_DCC);
- SetDir(X_AXIS, QD_DIR_P);
- QD_MotorStep = 0;
- }
-
- break;
- case 101:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
-
- if(cZipCnt <= 2)
- {
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_FIRST_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorStep = 102;
- }
- else
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorStep = 102;
- }
- }
- break;
- case 102:
- if(cZipCnt <= 2)
- {
- //拉链上升沿,就是到空位
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- if(X_DRV)
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED); //降速
- QD_MotorStep = 103;
- }
- }
- else
- {
- //1为双开
- if((QD_SK_MODE) && (((cRealPos + QD_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH))))
- {
- QD_YX_VAVLE = 1;
- QD_HL_VAVLE = 1;
- }
- if(((cRealPos - gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
- {
- QD_GZ_VAVLE = 1;
- QD_YX_VAVLE = 1;
- }
- 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,QD_PARAM_DCC))))
- {
- if(X_DRV)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- QD_MotorStep = 103;
- }
- }
- break;
- case 103:
- if(cZipCnt <= 2)
- {//双开暂不用,先保留
- #if QD_SK_MODE
- if((QD_SK_MODE) && ((dwTickCount + QD_PARAM_GZ_DELAY/2) >= QD_MotorDelay))
- {
- QD_YX_VAVLE = 1;
- QD_HL_VAVLE = 1;
- }
- #endif
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_GZ_VAVLE = 1;
- QD_YX_VAVLE = 1;
- #if QD_SK_MODE //双开暂不用,先保留
- if(QD_SK_MODE)
- QD_MotorStep = 154;
- else
- #endif
- QD_MotorStep = 160;
- }
- }
- else
- {
- #if QD_SK_MODE //双开暂不用,先保留
- if((QD_SK_MODE) && (((cRealPos + QD_PARAM_YALIAN_LENGTH- gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH))))
- {
- QD_YX_VAVLE = 1;
- QD_HL_VAVLE = 1;
- }
- #endif
- if(((cRealPos - gou_zhen_buff) > (length_buff - QD_PARAM_GOUZHEN_LENGTH)))
- {
- QD_GZ_VAVLE = 1;
- QD_YX_VAVLE = 1;
- #if QD_SK_MODE //双开暂不用,先保留
- if(QD_SK_MODE)
- QD_MotorStep = 154;
- else
- #endif
- QD_MotorStep = 160;
- }
-
-
- if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + length_buff)) && QD_GZ_VAVLE)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- break;
- case 154:
- #if QD_SK_MODE //双开暂不用,先保留
- if(QD_GZ_UP_IN)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_CHECK_GZ;
- QD_MotorStep = 104;
- }
- #endif
- break;
- case 160:
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 105;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + length_buff)) && QD_GZ_VAVLE && (cZipCnt > 2))
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- break;
- case 104:
- #if QD_SK_MODE //双开暂不用,先保留
- if(dwTickCount >= QD_MotorDelay)
- {
- //勾针离开就是到位
- if(!QD_GOUZHEN_IN && QD_GZ_UP_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 105;
- }
- }
- #endif
- break;
- case 105:
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_HL_VAVLE = 1;
- QD_YD_VAVLE = 1;
-
- if(cZipCnt == 1)
- {
- go_length_buff = cRealPos - back_buff;
- }
- else if(cZipCnt == 2)
- {
- length_buff = cRealPos - back_buff;
- }
- else if(cZipCnt > 2)
- {
- if(((cRealPos - save_buff) < (length_buff - QD_PARAM_ERROR_LENGTH- (*length_buffer))))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if(((cRealPos - save_buff) > (QD_PARAM_ERROR_LENGTH + length_buff - (*length_buffer))))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else
- {
- }
- }
- AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH,1,QD_PARAM_ACC,QD_PARAM_DCC);
-
- }
- break;
- case 106:
- if(!X_DRV)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- else
- {
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 0;
- }
- }
-
- break;
- case 40:
- QD_JD_VAVLE = 0;
- SetDir(X_AXIS, QD_DIR_P);
-
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
-
- QD_MotorStep = 41;
- break;
- case 41:
-
- if((dwTickCount >= QD_MotorDelay))
- {
- //夹子已经张开
- AxisMovePosAccDec(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH),QD_PARAM_START_SPEED,10,10);
- // AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
-
- // if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- // {
- // QD_JD_VAVLE = 0;
- // QD_MotorStep = 43;
- // }
- // else
- if(!X_DRV)
- {
- QD_JD_VAVLE = 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 + 150;
- SetPos(X_AXIS, 0);
- }
- else
- QD_MotorDelay = dwTickCount;
-
- QD_BL_VAVLE = 0;//并链也要打开
- SetDir(X_AXIS,QD_DIR_N);
- if(!QD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- 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)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- SetDir(X_AXIS,QD_DIR_P);
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,QD_PARAM_GO_LOW_SPEED,1000);
- QD_MotorDelay = dwTickCount + 300;
- }
- QD_MotorStep = 63;
- QD_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay))// && !QD_SHANG_MU_LIMIT_IN)
- {
- SetDir(X_AXIS, QD_DIR_N);
-
- go_buff = cRealPos;
- QD_YD_VAVLE = 1;
- QD_HL_VAVLE = 1;
- QD_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(cRealPos>(QD_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- // AxisMovePosAccDecNotStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- // SetStartSpeed(X_AXIS,QD_PARAM_START_SPEED);
- // SetAccTime(X_AXIS,QD_PARAM_ACC);
- // SetDecTime(X_AXIS,QD_PARAM_DCC);
- //两段速度移动距离
- // 轴 第一段速度 第一段长度 第二段速度 第二段长度 方向
- // AxisMoveTwoPos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos-QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH+ 100,QD_DIR_N);
- //跑三段速度
- AxisMoveThreePosNoStop(X_AXIS,QD_PARAM_GO_HIGH_SPEED,cRealPos -QD_PARAM_GO_LOW_SPEED_LENGTH-300,
- QD_PARAM_GO_HIGH_SPEED*2/3,350,
- QD_PARAM_GO_LOW_SPEED,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_DIR_N) ;
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
-
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_LOW_SPEED_LENGTH,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,QD_PARAM_GO_LOW_SPEED,QD_DIR_N,QD_PARAM_GO_LOW_SPEED/3,15,15);
- // MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((cRealPos) < (QD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (QD_QIAN_DEC_IN))
- {
- user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,QD_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- QD_MotorStep =65;
- }
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- else
- {
- if(QD_QIAN_LIMIT_IN) //前点限位
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN)
- {
-
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
-
- }
- else if(dwTickCount >= QD_MotorDelay)
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV)
- {
- SetPos(X_AXIS, 0);
- 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_VAVLE = 1;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- QD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_HL_VAVLE = 0;
- QD_YX_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- #endif
- //电机动作
- void QueDuan_Motor(void)
- {
- if(QD_KB_MODE) //闭口
- {
- #if QD_KB_MODE //闭口
- QueDuan_Motor_NoGL();
- #endif
- }
- else //开口
- {
- #if !QD_KB_MODE //开口
- QueDuan_Motor_KK(); //
- #endif
- }
- }
- //超声方式下切,开口专用
- void QueDuan_XiaQue_KK(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
-
- QD_XiaQieStep = 2;
- break;
- case 2:
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 3;
- break;
- case 3:
- if(1)
- {
- QD_XiaQieDelay = dwTickCount + 0;//QD_PARAM_GZ_DELAY;
- QD_XiaQieStep = 4;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 4:
- if(QD_GZ_VAVLE) //勾针已经有输出就不需要延时
- {
- QD_XiaQieDelay = dwTickCount + 0;
- }
- else
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_GZ_VAVLE = 1;
- cTuiFangKuaiCnt=0;
- QD_XiaQieStep = 5;
-
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_TFK_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(1)
- {
- QD_XiaQieStep = 7;
- QD_XiaQieDelay = dwTickCount + 1000;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 7:
- if(QD_GOUZHEN_IN)
- {
- cTuiFangKuaiCnt = 0;
- QD_YD_VAVLE = 1;
- if(!bRunning)
- QD_XiaQieDelay = dwTickCount + 200;
- else
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
-
- if(!QD_QIAN_LIMIT_IN)
- QD_XiaQieStep = 8;
- else
- QD_SetAlarmCode(QD_QIAN_LIMIT_ALARM);
- }
- else if((dwTickCount >= QD_XiaQieDelay))
- {
- if(cTuiFangKuaiCnt < QD_PARAM_TFK_NUMBER)
- {
- QD_TFK_VAVLE = 0;
- cTuiFangKuaiCnt++;
- QD_XiaQieDelay = dwTickCount + 500;
- 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;
- if(QD_PARAM_XM_ENABLE == 0) //配置下模动
- QD_XM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 9;
- }
- break;
- case 9://上下模到位,调试模下的话,等按下一步按键 下模不动
- if(QD_SHANG_MU_LIMIT_IN && (QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(!QD_PARAM_CS_MODE) //无超声配置
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- QD_XiaQieStep = 12;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 10;
- }
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- if(!QD_SHANG_MU_LIMIT_IN)QD_SetAlarmCode(QD_SM_DAOWEI);
- else QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 10:
- if(dwTickCount >= QD_XiaQieDelay)
- {
-
- 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;
- if(QD_PARAM_XM_ENABLE == 0) //配置下模动
- QD_XM_VAVLE = 0;
- QD_TFK_VAVLE = 0;
- QD_GZ_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 13;
- }//
- break;
- case 13:
- if(!QD_SHANG_MU_LIMIT_IN)
- {
- //启动推链(送链)
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)
- QD_TuiLianStep = 1;
- }
- if(!QD_SHANG_MU_LIMIT_IN && (!QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE))
- {
- QD_XiaQieStep = 0;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
- break;
- }
- }
- void QueDuan_TuiLianAction(void)
- {
- if(QD_PARAM_XM_ENABLE == 0)
- {
- QD_TuiLianStep = 0;
- }
- else
- {
- switch(QD_TuiLianStep)
- {
- case 1:
- QD_TuiLianStep = 2;
- break;
- case 2:
- QD_TLDelay = dwTickCount + QD_PARAM_YD_DELAY;
- QD_TuiLianStep = 3;
- break;
- case 3:
- if(!QD_SM_VAVLE && !QD_SHANG_MU_LIMIT_IN)//dwTickCount >= QD_TLDelay)
- {
- QD_TL_VAVLE = 1;
- if(!bRunning)QD_TFK_VAVLE = 0;
- QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
- QD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TuiLianStep = 0;
- }
- break;
- case 10:
-
- QD_TuiLianStep = 11;
- break;
- case 11:
- if(!Y_DRV)
- {
- {
- QD_TuiLianStep = 0;
- }
- }
- break;
- }
- }
- }
- //闭口专用
- void QueDuan_XiaQue_NO_GL(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(!bRunning)
- {
- if((QD_MACHINE_TYPE == QD_CS_TUIFANGKUAI) && QD_SK_MODE)
- {
- //跳到双开
- // QD_YD_VAVLE = 1;
- QD_HL_VAVLE = 1; //护链
- QD_YX_VAVLE = 1; //压带
- QD_GZ_VAVLE = 1; //勾针
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 100;
- }
- else
- {
- // QD_GZ_VAVLE = 1; //勾针
-
- // QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- // QD_XiaQieStep = 100;
- QD_YD_VAVLE = 1;
- QD_XiaQieStep = 2;
- QD_XiaQieDelay = dwTickCount + 30;
- }
- }
- else
- {
- QD_YD_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 2;
- }
- break;
- case 2:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieStep = 3;
- QD_XiaQieDelay = dwTickCount;
- }
- break;
- case 3:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
- {
- QD_SM_VAVLE = 1;
- QD_XM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 4;
- }
- }
- break;
- case 4://永兴为下模固定
- if(QD_SHANG_MU_LIMIT_IN && (QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE))
- {
- QD_GZ_VAVLE = 0;
- if(!QD_PARAM_CS_MODE) //气切
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- QD_XiaQieStep = 5;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 10;
- } //
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
-
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(!QD_SHANG_MU_LIMIT_IN && (!QD_XIA_MU_LIMIT_IN || QD_PARAM_XM_ENABLE)) //下模不动就不用判断
- {
- if(QD_TuiLianStep == 0)
- QD_TuiLianStep = 1;
- if(!bRunning)
- QD_JD_VAVLE = 0;
- QD_XiaQieStep = 0;
-
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
-
- break;
- //10~11步为超声
- 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 = 5;
- }
- break;
- case 100:
- if(dwTickCount >= QD_XiaQieDelay)
- {
-
- //这是双开程序,暂时不考虑
- #if 1
- if(QD_GOUZHEN_IN)
- {
- QD_YD_VAVLE = 1;
- QD_XiaQieStep = 3;
- }
- #endif
- }
- break;
- }
- }
- //切断动作
- void QueDuan_XiaQue(void)
- {
-
- if(QD_KB_MODE) //闭口
- {
- QueDuan_XiaQue_NO_GL(); //
- }
- else //开口
- {
- QueDuan_XiaQue_KK();
- }
- #if 0
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- case QD_CS_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- default:;
- }
- #endif
- }
- #endif
|