123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608 |
- #include "global.h"
- #if TONG_YONG_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_ExtiActionX31(void);
- void QueDuan_BingLian(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)
- {
- QueDuan_AlarmProtect();
- 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)
- {
- 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_XM_VAVLE)QD_GZ_VAVLE = 0;
- }
-
- 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;
- QD_JZ_DIR = QD_YDIR_N;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,QD_DIR_N,10,1,5,5);
- }
-
- if(QD_bBackMotor && !QD_BACK_LIMIT_IN)
- {
- QD_SZ_OUT = 0;
- QD_JZ_DIR = QD_YDIR_P;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,10,1,5,5);
- }
-
- if(!QD_bGoMotor && !QD_bBackMotor && (QD_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(QD_QIAN_LIMIT_IN && (QD_MotorStep == 0) && !QD_bBackMotor &&(QD_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- }
- }
- void QueDuan_YuanDianAction(void)
- {
- switch(QD_YuanDianStep)
- {
- case 0:break;
- case 1:
- if(QD_MotorStep == 0)QD_MotorStep = 61;
- QD_YuanDianStep = 2;
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 30;
- QD_YuanDianStep = 3;
- QD_JD_VAVEL = 1;
- }
- break;
- case 3:
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 0;
- QD_YuanDianStep = 0;
- }
- break;
- }
- }
- void QueDuan_AlarmProtect(void)
- {
- cRealPos = GetPos(X_AXIS);
- if(!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);
- }
- }
- // 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; //前点定位
- }
- }
- break;
- case 2:
- if(QD_MotorStep == 0)
- {
- 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_NO_GL_TUIFANGKUAI)
- {
-
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep == 6)) && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_MotorDelay = dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- }
- QD_AutoStep = 5;
- }
- }
- else
- {
- if(((QD_XiaQieStep == 0) || (QD_XiaQieStep == 13)) && !QD_SHANG_MU_LIMIT_IN && !QD_XIA_MU_LIMIT_IN)
- {
- if(QD_MotorStep == 0)
- {
- QD_MotorStep = 40; //切完后退
- QD_AutoStep = 5;
- }
- }
- }
- break;
- case 5:
- if(QD_MotorStep == 0)
- {
- cZipCnt++;
- QD_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(QD_TOTAL_ADDR);
- CalProSP(QD_PROSPEED_ADDR);
-
- if(cTableCnt >= QD_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- QD_TABLE_VAVLE = 1;
- QD_TBDelay = dwTickCount + QD_PARAM_TB_TIME;
- }
-
- if((GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) || SingOneFlg)
- {
- bRunning = 0;
- QD_AutoStep = 0;
- SingOneFlg = 0;
-
- if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
- }
- else
- {
- QD_AutoStep = 1;
-
- if(QD_PARAM_NOW_CNT >= QD_PARAM_ZHA_SHU)
- {
- QD_AutoDelay = dwTickCount + QD_PARAM_ZS_STOP_TIME + 50;
- QD_PARAM_NOW_CNT = 0;
- }
- else
- QD_AutoDelay = dwTickCount + QD_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- void QueDuan_StepCheckStart(void)
- {
- // 启动
- if((START_IN_UP) || bStart || QD_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (QD_AutoStep == 0))
- {
- if(!QD_SHANG_MU_ORIGIN_IN)QD_SetAlarmCode(QD_SM_YUANWEI);
- else if(QD_XIA_MU_LIMIT_IN)QD_SetAlarmCode(QD_XM_DAOWEI);
- else if(GetAlarmCode(QD_ALARM_ADDR) != 0);
- else if(GetTotal(QD_TOTAL_ADDR) >= QD_PARAM_SET_TOTAL) QD_SetAlarmCode(QD_TOTAL_ALARM);
- else if(QD_BL_VAVLE)QD_SetAlarmCode(QD_BL_ALARM);
- else if(QD_SM_VAVLE)QD_SetAlarmCode(QD_SM_ALARM);
- else
- {
- bRunning = 1;
- QD_AutoStep = 1;
- if(QD_bSingle) SingOneFlg= 1;
- cZipCnt = 0;
- cTuiFangKuaiCnt = 0;
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- }
- }
- QD_bSingle = 0;
- }
- //停止
- if(STOP_IN_UP || bStop)
- {
- bStop = 0;
- if(bRunning)
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 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_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_VAVLE = 0;
- AxisDecStop(X_AXIS);
- QD_YuanDianStep = 0;
- QD_BinLianStep = 0;
- QD_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
- if(GetAlarmCode(QD_ALARM_ADDR) != 0)SetAlarmCode(QD_ALARM_ADDR,0);
- }
- else
- {
- bRunning = 0;
- QD_XiaQieStep = 0;
- QD_AutoStep = 0;
- QD_MotorStep = 0;
- QD_TuiLianStep = 0;
- QD_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_SZ_OUT = 1;
- QD_GZ_VAVLE = 0;
- QD_TABLE_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_YuanDianStep = 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;
- QD_CheckDelay = dwTickCount;
- SingOneFlg = 0;
- bRunning = 0;
- AxisDecStop(X_AXIS);
- dwTickCount = QD_TBDelay;
- QD_TABLE_VAVLE = 0;
- }
-
- }
- //记忆长度模式误差检测
- void QueDuan_CheckLength(long zip_length)
- {
- static long start_dist;
- switch(QD_CheckLengthStep)
- {
- case 0:break;
- case 1:
- start_dist = cRealPos;
- QD_CheckLengthStep = 2;
- break;
- case 2:
- if(QD_GUO_LIAN_IN_DW) dwSaveLength = cRealPos - start_dist;
- break;
- }
- }
- void QueDuan_Motor_CS(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- user_datas[121]= QD_MotorStep;
- user_datas[122]= length_buff;
- user_datas[123] = cRealPos;
- user_datas[124] = dwSaveLength - (*length_buffer);
- user_datas[125] = QD_AutoStep;
- user_datas[126] = QD_XiaQieStep;
- user_datas[127] = QD_XiaQieStep;
- QueDuan_CheckLength(length_buff);
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QD_MotorStep = 31;
-
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- save_buff = cRealPos;
- back_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_P;
- if(QD_PARAM_BACK_MODE == QD_BACK_INDUCTION_MODE) // 纯感应模式
- {
- if(QD_PARAM_DEC_MODE == QD_BACK_DIGITAL_MODE) // 数控降速
- {
- if(cZipCnt < 2)
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_CHECK_BACK_HSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- else
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- }
- else
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- }
- else
- {
- if(QD_PARAM_BACK_MODE == QD_BACK_INPUT_LENGTH_MODE)
- {
- gouzhen_buff = cRealPos;
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- length_buff = QD_PARAM_ZIPPER_LENGTH + (*length_buffer);
- AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_SPEED,(-length_buff),QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_BACK_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)));
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 34;
- }
- else
- {
- if(cZipCnt < 2)
- {
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_CHECK_BACK_HSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 32;
- }
- else
- {
- gouzhen_buff = cRealPos;
- AxisMovePosAccDec(X_AXIS,QD_PARAM_BACK_SPEED,(-length_buff),QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- MoveChangSpeedPos(X_AXIS, QD_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,QD_PARAM_BACK_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)));
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 34;
- QD_CheckLengthStep = 1;
- }
- }
- }
- }
- break;
- case 32:
- if(QD_PARAM_BACK_MODE == QD_BACK_INDUCTION_MODE) //感应方式
- {
- if(QD_PARAM_DEC_MODE == QD_BACK_DIGITAL_MODE) // 数控降速
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_XM;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_DCC)))))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_XM;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- else
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_XM;
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- else
- {
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_XM;
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- }
- }
- break;
- case 33:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_XM_VAVLE = 1;
- QD_MotorStep = 34;
- }
- break;
- case 34:
- if(((cZipCnt < 2) || (QD_PARAM_BACK_MODE == QD_BACK_INDUCTION_MODE)) && (QD_PARAM_BACK_MODE != QD_BACK_INPUT_LENGTH_MODE))
- {
- if((((cRealPos - checkdelay_buff) >= QD_PARAM_DELAY_CHECK) && (QD_PARAM_LT_ENABLE)) || (((cRealPos - checkdelay_buff) >= QD_PARAM_NO_LT_DELAY_CHECK) && (QD_PARAM_LT_ENABLE == 0)))
- {
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- QD_MotorStep = 35;
- }
- }
- }
- else
- {
- if(QD_PARAM_LT_ENABLE == 0)
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - (QD_PARAM_DELAY_XM_LENGTH)))QD_XM_VAVLE = 1;
- if((cRealPos - gouzhen_buff) >= (length_buff - QD_PARAM_GOUZHEN_LENGTH))
- {
- QD_XM_VAVLE = 1;
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 36;
- }
- }
- else
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - (QD_PARAM_DELAY_XM_LENGTH)))
- {
- QD_XM_VAVLE = 1;
- QD_MotorStep = 36;
- }
- }
- }
- break;
- case 35:
- if(QD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- }
-
- if(QD_GUO_LIAN_IN_UP)
- {
- gou_zhen_buff = cRealPos;
- }
-
- if((cRealPos - gou_zhen_buff) >= QD_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 36;
- }
- break;
- case 36:
- if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
- {
- if(QD_PARAM_BACK_MODE == QD_BACK_INDUCTION_MODE)
- {
- QD_GZ_VAVLE = 1;
- }
- else
- {
- if((cZipCnt < 2) || (QD_PARAM_BACK_MODE != QD_BACK_INPUT_LENGTH_MODE))
- {
- QD_GZ_VAVLE = 1;
- }
- else
- {
- if(QD_PARAM_LT_ENABLE == 1)QD_GZ_VAVLE = 1;
- }
- }
- QD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_MotorStep = 37;
- }
- break;
- case 37:
- if(QD_XIA_MU_LIMIT_IN)
- {
- QD_MotorStep = 38;
- QD_MotorDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- }
- else if(dwTickCount >= QD_MotorDelay) QD_SetAlarmCode(QD_XM_DAOWEI);
- break;
- case 38:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_TFK_VAVEL = 1;
- QD_MotorStep = 39;
- }
- break;
- case 39:
- if(!X_DRV && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)))
- {
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff;
- }
- if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
-
- if((QD_PARAM_BACK_MODE != QD_BACK_INDUCTION_MODE)&&(QD_PARAM_BACK_MODE != QD_BACK_INPUT_LENGTH_MODE) && (cZipCnt >= 2))
- {
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- if((dwSaveLength - (*length_buffer)+ QD_PARAM_ERROR_LENGTH) < length_buff)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- QD_CheckLengthStep = 0;
- }
- else if((dwSaveLength - (*length_buffer)-QD_PARAM_ERROR_LENGTH) > length_buff)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- QD_CheckLengthStep = 0;
- }
- else
- QD_CheckLengthStep = 0;
- }
- if((QD_PARAM_BACK_MODE == QD_BACK_INDUCTION_MODE) && (cZipCnt >= 2))
- {
- if((cRealPos - save_buff) > (length_buff+QD_PARAM_ERROR_LENGTH))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- else if((cRealPos - save_buff) < (length_buff-QD_PARAM_ERROR_LENGTH))QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
- case 40:
- dwTickCount + QD_PARAM_CUT_BACK_DELAY;
- QD_JZ_DIR = QD_YDIR_P;
- QD_MotorStep = 41;
- break;
- case 41:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount + 35;
- QD_MotorStep = 42;
-
- }
- break;
-
- case 42:
- if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 43;
- }
- break;
- case 43:
- // 切断完成后拉电机动作
- if(dwTickCount >= QD_MotorDelay)
- {
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_buff)))
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- else if(!X_DRV)
- {
- QD_JD_VAVEL = 0;
- QD_MotorStep = 44;
- }
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
-
- break;
-
- case 61: // 前点定位数控模式
- if(QD_SZ_OUT)
- {
- QD_SZ_OUT = 0;
- QD_MotorDelay = dwTickCount + 50;
-
- }
-
- if((QD_TuiLianStep == 0) && !QD_TL_VAVLE)QD_TuiLianStep = 1;
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN || QD_QIAN_DEC_IN)
- {
- MV_Set_Acc_CPU(X_AXIS, 10);
- QD_JZ_DIR = QD_YDIR_P;
- AxisMovePos(X_AXIS,QD_PARAM_CHECK_BACK_HSPEED,-QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 63;
- QD_JD_VAVEL = 0;
- }
- break;
- case 63:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- go_buff = cRealPos;
- QD_JZ_DIR = QD_YDIR_N;
- if(cZipCnt > 0)
- {
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
- else
- {
- 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 > 0)
- {
- if(((go_buff - cRealPos) > (go_length_buff - (QD_PARAM_GO_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || (QD_QIAN_DEC_IN_UP))
- {
-
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- else
- {
- if(QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 66:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 68;
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_YBD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- QD_BL_VAVLE = 0;
- QD_MotorStep = 0;
- }
- break;
-
- }
- }
- 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(((cRealPos - bl_pos_buff+QD_PARAM_HL_BACK_LENGTH) >= QD_PARAM_ZIPPER_LENGTH) || QD_SM_VAVLE)
- {
- QD_BL_VAVLE = 0;
- QD_BinLianStep = 0;
- }
- break;
- default:;
- }
-
- }
- //不带过链感应长度输入电机长度
- void QueDuan_Motor_NoGL(void)
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- user_datas[124]= QD_MotorStep;
- // user_datas[125]= go_length_buff;
- // user_datas[123] = length_buff;
- user_datas[127] = cRealPos;
- // user_datas[126] = go_buff - cRealPos;
- // user_datas[121] = QD_PARAM_GOUZHEN_LENGTH;
- if(QD_GUO_LIAN_IN_DW)user_datas[122]++;
- switch(QD_MotorStep)
- {
- case 30:
- QD_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
-
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- if(QD_PARAM_BL_ENABLE)QD_BinLianStep = 1;
-
- if(QD_PARAM_LENGTH_MODE == 0)
- QD_MotorStep = 101;
- else
- QD_MotorStep = 31;
- break;
- case 31:
- if(dwTickCount >= QD_MotorDelay)
- {
- back_buff = cRealPos;
- gou_zhen_buff = cRealPos;
- save_buff = cRealPos;
- if(cZipCnt > 0)
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
- else
- MoveAction_Const_AccDec(X_AXIS,QD_DIR_P,QD_PARAM_CHECK_BACK_HSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);
-
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep = 33;
- }
- break;
- case 32:
- if(((cRealPos - gou_zhen_buff) > (QD_PARAM_ZIPPER_LENGTH - (*length_buffer) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)QD_GZ_VAVLE = 1;
- if((cRealPos - back_buff) > (QD_PARAM_ZIPPER_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)))))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
-
- QD_MotorStep = 33;
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 33:
- if(((cRealPos - gou_zhen_buff) > (QD_PARAM_ZIPPER_LENGTH - (*length_buffer) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE) QD_GZ_VAVLE = 1;
-
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 34;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - (*length_buffer))) && QD_GZ_VAVLE)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- else if(dwTickCount >= QD_MotorDelay)
- {
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 34:
- if(!X_DRV && (dwTickCount >= QD_MotorDelay))
- {
- AxisMovePos(X_AXIS,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_FZ_LENGTH);
- 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;
- AxisContinueMove(X_AXIS,QD_PARAM_FIRST_SPEED,QD_DIR_P);
- QD_MotorStep = 102;
- }
- else
- {
- MoveAction_Const_Back(X_AXIS,QD_DIR_P,QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,PosToPulse(X_AXIS,((length_buff - QD_PARAM_TC_LENGTH) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,30))))));
- QD_MotorStep = 102;
- }
- }
- break;
- case 102:
- if(cZipCnt < 2)
- {
- if(QD_GUO_LIAN_IN_UP)
- {
- QD_MotorDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- QD_MotorStep = 103;
- }
- }
- else
- {
- if(((cRealPos - gou_zhen_buff) > ((length_buff - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
- {
- save_buff = cRealPos;
- QD_GZ_VAVLE = 1;
- }
- if((cRealPos - back_buff) > ((length_buff - QD_PARAM_TC_LENGTH) - (QD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_BACK_SPEED,QD_PARAM_BACK_LOW_SPEED,10)))))
- {
- if(X_DRV)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_BACK_LOW_SPEED);
- }
-
- QD_MotorStep = 103;
- }
- }
- break;
- case 103:
- if(cZipCnt < 2)
- {
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_GZ_VAVLE = 1;
- QD_MotorStep = 104;
- }
- }
- else
- {
- if(((cRealPos - gou_zhen_buff) > ((length_buff - QD_PARAM_TC_LENGTH) - QD_PARAM_GOUZHEN_LENGTH)) && !QD_GZ_VAVLE)
- {
- QD_GZ_VAVLE = 1;
- }
-
-
- if(QD_GOUZHEN_IN)
- {
- QD_YD_VAVLE = 1;
- QD_MotorDelay = dwTickCount + 5;
- QD_MotorStep = 105;
- }
- else if(((cRealPos - save_buff) >= (QD_PARAM_ERROR_LENGTH + QD_PARAM_ZIPPER_LENGTH - QD_PARAM_TC_LENGTH)) && QD_GZ_VAVLE)
- {
- QD_SetAlarmCode(QD_LENGTH_LONG_ALARM);
- }
- }
- break;
- case 104:
- if(cZipCnt < 2)
- {
- if(QD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- QD_YD_VAVLE = 1;
- QD_MotorStep = 105;
- }
- }
- else
- {
-
- }
- break;
- case 105:
- if(!X_DRV)
- {
- if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - back_buff;
- }
- else if(cZipCnt == 1)
- {
- length_buff = cRealPos - back_buff;
- SetData32bits(1,length_buff);
- }
- AxisMovePos(X_AXIS,QD_PARAM_BACK_LOW_SPEED,QD_PARAM_FZ_LENGTH);
- QD_MotorStep = 0;
- }
- break;
- case 40:
- if(dwTickCount >= QD_MotorDelay)
- {
- jz_buff = cRealPos;
- if(QD_PARAM_SJZ_LENGTH == 0)
- {
- QD_JD_VAVEL = 0;
- }
- QD_MotorDelay = dwTickCount + 35;
- QD_MotorStep = 41;
-
- }
- break;
-
- case 41: if((dwTickCount >= QD_MotorDelay) || (QD_JD_VAVEL == 1))
- {
- AxisMovePos(X_AXIS,QD_PARAM_CUT_BACK_SPEED,-(QD_PARAM_SJZ_LENGTH+QD_PARAM_BACK_LENGTH));
- QD_MotorStep = 42;
- }
- break;
- case 42:
- if(((QD_PARAM_SJZ_LENGTH) <= (cRealPos - jz_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_TL_VAVLE)
- {
- if(!QD_SHANG_MU_LIMIT_IN && (QD_TuiLianStep == 0))
- {
- QD_TuiLianStep = 1;
- QD_MotorStep = 62;
- }
- }
- else
- QD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QD_MotorDelay)
- {
- if(QD_QIAN_LIMIT_IN || QD_QIAN_DEC_IN)
- {
- AxisMovePos(X_AXIS,QD_PARAM_CHECK_BACK_HSPEED,-QD_PARAM_ON_BACK_LENGTH);
- QD_MotorDelay = dwTickCount + 1000;
- }
- QD_MotorStep = 63;
- QD_JD_VAVEL = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QD_QIAN_LIMIT_IN && (dwTickCount >= QD_MotorDelay) && !QD_SHANG_MU_LIMIT_IN)
- {
- go_buff = cRealPos;
-
- if(cZipCnt > 0)
- {
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_GO_HIGH_SPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
- else
- {
- MoveAction_Const_AccDec(X_AXIS, QD_DIR_N,QD_PARAM_FIRST_GO_HIGHSPEED,QD_PARAM_START_SPEED,QD_PARAM_ACC,QD_PARAM_DCC);//
- }
- length_buffer = &QD_PARAM_OFFSET_LENGTH;
- QD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QD_MotorStep =64;
- }
- break;
- case 64:
-
- if(QD_PARAM_LENGTH_MODE == 0)
- {
- if(((go_buff - cRealPos) > ((go_length_buff - (*length_buffer) - QD_PARAM_FZ_LENGTH) - (QD_PARAM_GO_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_DCC))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- else
- {
- if(((go_buff - cRealPos) > ((QD_PARAM_ZIPPER_LENGTH - (*length_buffer) - QD_PARAM_FZ_LENGTH) - (QD_PARAM_GO_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QD_PARAM_GO_HIGH_SPEED,QD_PARAM_GO_LOW_SPEED,QD_PARAM_DCC))) + QD_PARAM_BACK_LENGTH + QD_PARAM_SJZ_LENGTH)) || QD_QIAN_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QD_PARAM_GO_LOW_SPEED);
- QD_MotorStep =65;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- }
- break;
- case 65:
- if(QD_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QD_MotorStep = 66;
- }
- else if(dwTickCount >= QD_MotorDelay)QD_SetAlarmCode(QD_NO_ZIPPER_ALARM);
- else if(QD_JD_ORIGIN_IN)QD_SetAlarmCode(QD_JD_ORIGIN_ALARM);
- break;
- case 66:
- if(!X_DRV)
- {
- QD_MotorDelay = dwTickCount;
- QD_MotorStep = 67;
- }
- break;
- case 67:
- if((dwTickCount >= QD_MotorDelay) && (QD_TuiLianStep == 0) && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- QD_JD_VAVEL = 1;
- }
- QD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= QD_MotorDelay)
- {
- QD_YD_VAVLE = 0;
- QD_TL_VAVLE = 0;
- if(QD_PARAM_BL_ENABLE)QD_BL_VAVLE = 0;
- QD_MotorStep = 0;
- QD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- //电机动作
- void QueDuan_Motor(void) //
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI: QueDuan_Motor_CS();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_Motor_NoGL();break;
- default:;
- }
- }
- //超声方式下切
- void QueDuan_XiaQue_CS(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(bRunning)
- {
- QD_XiaQieStep = 6;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else
- QD_XiaQieStep = 2;
- break;
- case 2:
- QD_XM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 3;
- break;
- case 3:
- if(QD_XIA_MU_LIMIT_IN)
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_GZ_DELAY;
- QD_XiaQieStep = 4;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 4:
- QD_GZ_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_TFK_DELAY;
- QD_XiaQieStep = 5;
-
- break;
- case 5:
- QD_TFK_VAVEL = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 6;
- break;
- case 6:
- if(QD_XIA_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 7;
- QD_XiaQieDelay = dwTickCount + 2000;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_XM_DAOWEI);
- }
- break;
- case 7:
- if(QD_GOUZHEN_IN)
- {
- cTuiFangKuaiCnt = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 8;
- }
- else if((dwTickCount >= QD_XiaQieDelay))
- {
- if(cTuiFangKuaiCnt == 0)
- {
- QD_TFK_VAVEL = 0;
- cTuiFangKuaiCnt++;
- QD_XiaQieDelay = dwTickCount + 1000;
- QD_XiaQieStep = 100;
- }
- else
- QD_SetAlarmCode(QD_GZ_ALARM);
- }
- break;
- case 100:
- if((dwTickCount >= QD_XiaQieDelay))
- {
- QD_XiaQieStep = 5;
- }
- break;
- case 8:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 9;
- }
- break;
- case 9:
- if(QD_SHANG_MU_LIMIT_IN && ((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(!QD_PARAM_CS_MODE)
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; // QD_PARAM_DELAYBACK_SM; //
- QD_XiaQieStep = 12;
- }
- else
- {
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAY_CS; //
- QD_XiaQieStep = 10;
- }
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 10:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if(QD_PARAM_CS_ENABLE)QD_CS_OUT = 1;
- QD_YD_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_TIME; //
- QD_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_CS_OUT = 0;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CS_COLD_TIME; //
- QD_XiaQieStep = 12;
- }
- break;
- case 12:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SM_VAVLE = 0;
- QD_XM_VAVLE = 0;
- QD_TFK_VAVEL = 0;
- QD_GZ_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME;
- QD_XiaQieStep = 13;
- }//
- break;
- case 13:
- if(QD_SHANG_MU_ORIGIN_IN && !QD_XIA_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 0;
- QD_XiaQieDelay = dwTickCount;
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
- break;
- }
- }
- void QueDuan_TuiLianAction(void)
- {
- switch(QD_TuiLianStep)
- {
- 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)
- {
- QD_TL_VAVLE = 1;
- QD_BL_VAVLE = 1;
- if(!bRunning)QD_TFK_VAVEL = 0;
- QD_TLDelay = dwTickCount + QD_PARAM_TL_DELAY;
- QD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QD_TLDelay)
- {
- QD_TuiLianStep = 0;
- }
- break;
- case 10:
- // if(bRunning)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_NO_GL(void)
- {
- switch(QD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- QD_YD_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_CUT_DELAY;
- QD_XiaQieStep = 2;
- break;
- case 2:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_XiaQieStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- if((QD_PARAM_TIAOSHI_MODE && QD_bTS) || (QD_PARAM_TIAOSHI_MODE == 0))
- {
- QD_SM_VAVLE = 1;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 4;
- }
- }
- break;
- case 4:
- if(QD_SHANG_MU_LIMIT_IN)
- {
- QD_XiaQieStep = 5;
- QD_XiaQieDelay = dwTickCount + QD_PARAM_DELAYBACK_SM; //
- }
- else if(dwTickCount >= QD_XiaQieDelay)QD_SetAlarmCode(QD_SM_DAOWEI);
- break;
- case 5:
- if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_GZ_VAVLE = 0;
- QD_SM_VAVLE = 0;
- QD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- QD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(QD_SHANG_MU_ORIGIN_IN && !QD_SHANG_MU_LIMIT_IN)
- {
- if(QD_TuiLianStep == 0)QD_TuiLianStep = 1;
- if(!bRunning)QD_JD_VAVEL = 0;
- QD_XiaQieStep = 0;
-
- }
- else if(dwTickCount >= QD_XiaQieDelay)
- {
- QD_SetAlarmCode(QD_SM_YUANWEI);
- }
-
- break;
- }
- }
- //切断动作
- void QueDuan_XiaQue(void)
- {
- switch(QD_MACHINE_TYPE)
- {
- case QD_NO_CS_TUIFANGKUAI:QueDuan_XiaQue_CS();break;
- case QD_NO_GL_TUIFANGKUAI:QueDuan_XiaQue_NO_GL();break;
- default:;
- }
- }
- #endif
|