123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704 |
- #include "global.h"
- #if FIE_YUE_MACHINE
- unsigned long cSlowPusle;
- unsigned char bStartOnceTime,bOnceProcess;
- unsigned short cWorkCnt;
- unsigned char TryCnt = 0;
- unsigned short cTbCnt = 0;
- unsigned char ZhuangLiaoOkFlg = 0;
- unsigned char SongLaTouOkFlg = 0;
- unsigned char FirstStartFlg = 0;
- unsigned char cBackFlg = 0;
- unsigned char HengSongFlg = 0;
- unsigned char cManHSLStep = 0;
- static long save_limit_pos;
- void QDCT_ManualAction(void);
- void QDCT_JiaLianAction(void);
- void QDCT_AutoStepAction(void);
- void QDCT_TableAction(void);
- void QDCT_Motor(void);
- void QDCT_CheckStart(void);
- void QDCT_SL_Step(void);
- void QDCT_XiaQieAction(void);
- void QDCT_AlarmProtect(void);
- void QDCT_ZLT_Step(void);
- void QDCT_TuiLian(void);
- void QDCT_SongLian(void);
- void QDCT_ExtiActionX31(void)
- {
- if(cSeBiaoEn && !cSeBiaoOk)
- {
- user_datas[123]++;
- cSeBiaoEn = 0;
- cSeBiaoOk = 1;
- SetRemainLength(X_AXIS,QDCT_SEBIAO_LENGTH,QDCT_SEBIAO_LOW_SPEED);
- }
- user_datas[123]++;
- }
- //故障报警
- void QDCT_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(QDCT_ALARM_ADDR,alarm_code);
- QDCT_bAlarmStop = 1;
- }
- unsigned char QDCT_GetYL_Mode(void)
- {
- #if CTQD_MACHINE_KIND
- {
- if(QDCT_PARAM_SET_ZIPPER_LENGTH > QDCT_PARAM_YL_TRANS_LENGTH)return 1;
- else return 0;
- }
- #else
- return 0;
- #endif
- }
- //初始化动作
- void QDCT_InitAction(void)
- {
- float buff_pulse,buff_dist;
-
- buff_pulse = QDCT_PARAM_CYCLE_PULSE;
- buff_dist = QDCT_PARAM_CYCLE_LENGTH;
- XGearRatio = buff_pulse/buff_dist;
-
- buff_pulse = QDCT_PARAM_YL_CYCLE_PULSE;
- buff_dist = QDCT_PARAM_YL_CYCLE_LENGTH;
- YGearRatio = buff_pulse/buff_dist;
- QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- }
- void QDCT_Action(void)
- {
- QDCT_AlarmProtect();
- QDCT_CheckStart();
- QDCT_TuiLian();
- QDCT_ZLT_Step();
- QDCT_TableAction();
- QDCT_SL_Step();
- QDCT_SongLian();
- QDCT_JiaLianAction();
- QDCT_XiaQieAction();
- QDCT_Motor();
- QDCT_ManualAction();
- QDCT_AutoStepAction();
- }
- void QDCT_AlarmProtect(void)
- {
- static unsigned short ka_dai_cnt;
- dwRealPos = GetPos(X_AXIS);
- if(QDCT_PARAM_BACK_ALARM_MODE)
- { //感应后限模式
- if(!bRunning)
- {
- if(QDCT_BACK_LIMIT_IN_UP)
- {
- if(X_DRV && (QDCT_bMotorBack) || (QDCT_MotorStep != 0)) //到后限不能再后退但可以点前进
- {
- QDCT_bMotorBack = 0;
-
- AxisEgmStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- }
- }
- }
- else
- {
- if(QDCT_BACK_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
-
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- }
- }
- }
- else
- {
- if(QDCT_GO_LIMIT_IN_UP) //数控后限模式
- {
- save_limit_pos = dwRealPos;
- SetData32bits(200,save_limit_pos);
- }
-
- if(QDCT_PARAM_MAX_BACK_LENGTH < (dwRealPos - save_limit_pos))
- {
- if(!bRunning)
- {
- if((QDCT_MotorStep == 0) && X_DRV && QDCT_bMotorBack) //到后限不能再后退但可以点前进
- {
- QDCT_bMotorBack = 0;
- AxisDecStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
-
- }
- }
- else
- {
- AxisDecStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- }
- }
-
- }
-
- if(QDCT_KA_DAI_IN)
- {
- if(ka_dai_cnt < 110)ka_dai_cnt++;
- }
- else
- {
- ka_dai_cnt = 0;
- if(GetAlarmCode(QDCT_ALARM_ADDR) == QDCT_KD_ALARM)QDCT_SetAlarmCode(QDCT_NO_ALARM);
- }
- if(ka_dai_cnt > 100)QDCT_SetAlarmCode(QDCT_KD_ALARM);
-
- if(bRunning)
- {
- if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- }
- }
- void QDCT_JiaLianAction(void)
- {
- if(QDCT_JZ_IN_UP && QDCT_GO_LIMIT_IN)
- {
- QDCT_YD_OUT = 0;
- QDCT_TL_OUT = 0;
- }
-
- if(QDCT_JiaLianStep == 1)
- {
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_JD_DELAY;
- QDCT_JiaLianStep = 2;
- }
- else if((QDCT_JiaLianStep == 2) && (dwTickCount >= QDCT_JD_Delay))
- {
- QDCT_JD_OUT = 1;
- QDCT_JD_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_JiaLianStep = 3;
- }
- else if(QDCT_JiaLianStep == 3)
- {
- if(QDCT_JZ_IN)
- {
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_DELAY;
- QDCT_TL_OUT = 0;
- QDCT_YD_OUT = 0;
- QDCT_JiaLianStep = 4;
- }
- else if(dwTickCount >= QDCT_JD_Delay)
- {
- QDCT_SetAlarmCode(QDCT_JD_ALARM);
- }
- }
- else if(QDCT_JiaLianStep == 4)
- {
- if(QDCT_PARAM_KL_TIME)
- {
- QDCT_JiaLianStep = 5;
- }
- else
- {
- QDCT_JiaLianStep = 7;
- }
- }
- else if((QDCT_JiaLianStep == 5) && (dwTickCount >= QDCT_JD_Delay))
- {
- QDCT_KL_OUT = 1;
- QDCT_JiaLianStep = 6;
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_TIME;
- }
- else if((QDCT_JiaLianStep == 6) && (dwTickCount >= QDCT_JD_Delay))
- {
- QDCT_KL_OUT = 0;
- QDCT_JiaLianStep = 7;
- }
- else if((QDCT_JiaLianStep == 7))
- {
- QDCT_JiaLianStep = 0;
- }
- }
- //自动动作
- void QDCT_AutoStepAction(void)
- {
- if(bRunning)
- {
- if(QDCT_AutoStep == 1)
- {
- QDCT_AutoStep = 2;
- QDCT_ZhenDongStep = 1;
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- }
- else if((QDCT_AutoStep == 2) && (dwTickCount >= QDCT_AutoDelay))
- {
- QDCT_AutoStep = 3;
- }
- else if(QDCT_AutoStep == 3)
- {
- if(QDCT_MotorStep == 0)
- {
- QDCT_MotorStep = 61;
- ZhuangLiaoOkFlg = 0;
- QDCT_AutoStep = 4;
- }
- }
- else if(QDCT_AutoStep == 4)
- {
- QDCT_AutoStep = 5;
- }
- else if(QDCT_AutoStep == 5)
- {
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- QDCT_AutoStep = 6;
- }
- else if(QDCT_AutoStep == 6)
- {
- if(QDCT_ZhuangLiaoStep == 0)
- {
- QDCT_AutoStep = 7;
- }
- }
- else if(QDCT_AutoStep == 7)
- {
- QDCT_AutoStep = 8;
- }
- else if(QDCT_AutoStep == 8)
- {
- QDCT_AutoStep = 9;
- }
- else if(QDCT_AutoStep == 9)
- {
- if(QDCT_MotorStep == 0)
- {
- QDCT_AutoStep = 10;
- }
- }
- else if(QDCT_AutoStep == 10)
- {
- QDCT_AutoStep = 11;
- }
- else if(QDCT_AutoStep == 11)
- {
- if((QDCT_MotorStep == 0) && (QDCT_ZhuangLiaoStep == 0)) //
- {
- if(QDCT_SEBIAO_MODE)
- QDCT_MotorStep = 1;
- else
- QDCT_MotorStep = 30;
- QDCT_AutoStep = 12;
- }
- }
- else if(QDCT_AutoStep == 12)
- {
- if(QDCT_MotorStep == 0)
- {
- ZhuangLiaoOkFlg = 0;
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- QDCT_AutoStep = 13;
- }
- }
- else if(QDCT_AutoStep == 13)
- {
- QDCT_AutoStep = 14;
- }
- else if(QDCT_AutoStep == 14)
- {
- if(bStartOnceTime)
- {
- bStartOnceTime = 0;
- cBackFlg = 1;
- QDCT_AutoStep = 0;
- bRunning = 0;
- }
- else
- {
- if(QDCT_XiaQieStep == 0)
- {
- QDCT_XiaQieStep = 1;
- ZhuangLiaoOkFlg = 0;
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- QDCT_AutoStep = 15;
- }
- }
- }
- else if(QDCT_AutoStep == 15)
- {
- if(((QDCT_XiaQieStep == 0) || (QDCT_XiaQieStep == 6)) && !QDCT_SQ_LIMIT_IN)
- {
- if(QDCT_MotorStep == 0)
- {
-
- QDCT_MotorStep = 40;
- ZhuangLiaoOkFlg = 0;
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- QDCT_AutoStep = 16;
-
- if((QDCT_SongLianStep == 0) && QDCT_GetYL_Mode())QDCT_SongLianStep = 1;
- }
- }
- }
- else if((QDCT_AutoStep == 16) && (QDCT_MotorStep == 0) && (QDCT_SongLianStep == 0))
- {
- CalProSP(QDCT_SPEED_ADDR); //计算生产速度
- AddToTal(QDCT_TOTAL_ADDR); //生产总量加1并保存
- AddToTal(QDCT_NOWTOTAL_ADDR); //生产总量加1并保存
- cWorkCnt++;
- dwZipCnt++;
- cTbCnt++;
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- if(cTbCnt >= QDCT_PARAM_TABLE_NUM)
- {
- QDCT_TB_OUT = 1;
- cTbCnt = 0;
- QDCT_TableDelay = dwTickCount + QDCT_PARAM_TABLE_TIME;
- }
-
- if(QDCT_ZHA_STOP_TIME == 0)
- {
- if(GetTotal(QDCT_NOWTOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR))
- {
- bStartOnceTime = 0;
- QDCT_SetAlarmCode(QDCT_TOTAL_ALARM);
- }
- else
- {
- QDCT_AutoStep = 17;
- }
- }
- else
- {
- if(GetTotal(QDCT_NOWTOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR))
- {
- ClrcToTal(QDCT_NOWTOTAL_ADDR);
- QDCT_AutoDelay = dwTickCount + QDCT_ZHA_STOP_TIME;
- QDCT_AutoStep = 17;
- }
- else
- {
- QDCT_AutoDelay = dwTickCount;
- QDCT_AutoStep = 17;
- }
- }
- }
- else if((QDCT_AutoStep == 17) && (dwTickCount >= QDCT_AutoDelay))
- {
- {
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
- QDCT_AutoStep = 2;
- }
-
- }
- }
- }
- void QDCT_SongLian(void)
- {
- switch(QDCT_SongLianStep)
- {
- case 0:
- break;
- case 1:
- QDCT_YL_DIR_OUT = 1;
- AxisMovePos(Y_AXIS,QDCT_PARAM_YL_CUT_SPEED,QDCT_PARAM_YL_CUT_LENGTH);
- QDCT_SongLianStep = 2;
- break;
- case 2:
- if(!Y_DRV)QDCT_SongLianStep = 3;
- break;
- case 3:
- QDCT_SongLianStep = 4;
- break;
- case 4:
- QDCT_SongLianStep = 0;
- break;
- default:;
- }
- }
- void QDCT_TuiLian(void)
- {
- switch(QDCT_TuiLianStep)
- {
- case 0:
- break;
- case 1:
- QDCT_TuiLianStep = 2;
- break;
- case 2:
- if(QDCT_SQ_LIMIT_IN)
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- else
- {
- if(!QDCT_YD_OUT)QDCT_TLDelay = dwTickCount + QDCT_PARAM_TL_DELAY;
- else
- QDCT_TLDelay = dwTickCount;
- QDCT_YD_OUT = 1;
- QDCT_TuiLianStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= QDCT_TLDelay)
- {
- QDCT_TL_OUT = 1;
- QDCT_TLDelay = dwTickCount;
- QDCT_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= QDCT_TLDelay)
- {
- QDCT_TuiLianStep = 0;
- }
- break;
- }
- }
- //台面电机动作
- void QDCT_TableAction(void)
- {
- if(QDCT_TB_OUT && (dwTickCount >= QDCT_TableDelay))QDCT_TB_OUT = 0;
- }
- void QDCT_CheckStart(void)
- {
- if(bRunning)
- QDCT_PARAM_RUN_STATE = 1;
- else
- QDCT_PARAM_RUN_STATE = 0;
- //启动 自动启动 单一自动
- if(START_IN_UP || bStart || QDCT_bOnceStart)
- {
- if(QDCT_bOnceStart)
- {
- QDCT_bOnceStart = 0;
- bStartOnceTime = 1;
- dwZipCnt = 0;
- }
- bStart = 0;
-
- if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- else if(QDCT_LTCZ_IN)QDCT_SetAlarmCode(QDCT_LTCZ_ALARM);
- else if(!QDCT_HSL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
- else if(QDCT_HSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
- else if(!QDCT_XM_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- else if(QDCT_SQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- else if(QDCT_GO_LIMIT_IN && QDCT_JZ_IN && QDCT_HSL_ORIGIN_IN && !QDCT_SL_LIMIT_IN)
- {
- if(!bRunning && (QDCT_AutoStep == 0) && (GetAlarmCode(QDCT_ALARM_ADDR) == 0))
- {
- bRunning = 1;
- QDCT_AutoStep = 4;
- cWorkCnt = 0;
- TryCnt = 0;
- SongLaTouOkFlg = 1;
- dwZipCnt = 0;
- FirstStartFlg = 0;
- cBackFlg = 0;
- HengSongFlg = 0;
- if(QDCT_GetYL_Mode())
- {
- QDCT_YL_WORK_OUT = 1;
- }
- else QDCT_YL_WORK_OUT = 0;
- }
- }
- else
- {
- if(!bRunning && (QDCT_AutoStep == 0) && (GetAlarmCode(QDCT_ALARM_ADDR) == 0))
- {
- bRunning = 1;
- QDCT_AutoStep = 1;
- cWorkCnt = 0;
- TryCnt = 0;
- SongLaTouOkFlg = 1;
- dwZipCnt = 0;
- FirstStartFlg = 1;
- cBackFlg = 0;
- HengSongFlg = 0;
- if(QDCT_GetYL_Mode())
- {
- QDCT_YL_WORK_OUT = 1;
- }
- else QDCT_YL_WORK_OUT = 0;
- }
- }
- }
-
- if(bStop)
- {
- bStop = 0;
- if(bRunning)bStartOnceTime = 1;
- }
- //停止
- if(STOP_IN_UP)
- {
- if(bRunning)
- {
- AxisDecStop(X_AXIS);
- AxisDecStop(Y_AXIS);
- bRunning = 0;
- QDCT_bOnceStart = 0;
- HengSongFlg = 0;
- bStop = 0;
- bStartOnceTime = 0;
- QDCT_AutoStep = 0;
- QDCT_MotorStep = 0;
- QDCT_JiaLianStep = 0;
- QDCT_XiaQieStep = 0;
- QDCT_ZhenDongStep = 0;
- QDCT_SongLiaoStep = 0;
- QDCT_TuiLianStep =0;
- QDCT_SongLianStep = 0;
- QDCT_CS_OUT = 0;
- QDCT_SQ_OUT = 0;
- QDCT_XM_OUT = 0;
- QDCT_JD_OUT = 0;
- QDCT_SL_OUT = 0;
- cManHSLStep = 0;
- if(!QDCT_HSL_OUT)
- {
- QDCT_JLT_OUT= 0;
- }
- QDCT_ZhuangLiaoStep = 0;
- QDCT_KL_OUT = 0;
- QDCT_TL_OUT = 0;
- QDCT_YD_OUT = 0;
- QDCT_YL_WORK_OUT = 0;
- QDCT_YL_OUT = 0;
- cBackFlg = 0;
- QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- if(GetAlarmCode(QDCT_ALARM_ADDR) != 0)QDCT_SetAlarmCode(QDCT_NO_ALARM);
-
- if(!X_DRV && (QDCT_GO_DEC_IN) && !bRunning && (QDCT_MotorStep == 0))
- {
- QDCT_MotorStep = 20;
- }
-
- }
- else
- {
- AxisDecStop(X_AXIS);
- AxisDecStop(Y_AXIS);
- bRunning = 0;
- QDCT_bOnceStart = 0;
- HengSongFlg = 0;
- bStop = 0;
- bStartOnceTime = 0;
- QDCT_AutoStep = 0;
- QDCT_MotorStep = 0;
- QDCT_JiaLianStep = 0;
- QDCT_XiaQieStep = 0;
- QDCT_ZhenDongStep = 0;
- QDCT_SongLiaoStep = 0;
- QDCT_TuiLianStep =0;
- QDCT_SongLianStep = 0;
- QDCT_CS_OUT = 0;
- QDCT_SQ_OUT = 0;
- QDCT_XM_OUT = 0;
- QDCT_JD_OUT = 0;
- QDCT_SL_OUT = 0;
-
- QDCT_JLT_OUT= 0;
- QDCT_ZhuangLiaoStep = 0;
- cManHSLStep = 0;
-
- QDCT_KL_OUT = 0;
- QDCT_TL_OUT = 0;
- QDCT_YD_OUT = 0;
- QDCT_YL_WORK_OUT = 0;
- QDCT_YL_OUT = 0;
- cBackFlg = 0;
- QDCT_SZ_OUT = QDCT_MOTOR_DISEN;
- if(GetAlarmCode(QDCT_ALARM_ADDR) != 0)QDCT_SetAlarmCode(QDCT_NO_ALARM);
-
- if(!X_DRV && (QDCT_GO_DEC_IN) && !bRunning && (QDCT_MotorStep == 0))
- {
- QDCT_MotorStep = 20;
- }
- }
- }
-
-
- if(QDCT_bAlarmStop)
- {
- bRunning = 0;
- QDCT_bOnceStart = 0;
- HengSongFlg = 0;
- QDCT_bAlarmStop = 0;
- bStartOnceTime = 0;
- AxisDecStop(X_AXIS);
- QDCT_AutoStep = 0;
- QDCT_ZhuangLiaoStep = 0;
- QDCT_MotorStep = 0;
- QDCT_JiaLianStep = 0;
- QDCT_XiaQieStep = 0;
- QDCT_ZhenDongStep = 0;
- QDCT_SongLiaoStep = 0;
- QDCT_SongLianStep = 0;
- QDCT_CS_OUT = 0;
- QDCT_SQ_OUT = 0;
- cManHSLStep = 0;
- }
- }
- //电机控制动作
- void QDCT_Motor(void) //
- {
- static long save_buff,length_buff,gou_zhen_buff,back_dec_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
- long len_buf;
- short *revise_buff;
- switch(QDCT_MotorStep)
- {
- case 1:
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- QDCT_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_dec_buff = dwRealPos;
- back_buff = dwRealPos;
- QDCT_DIR_OUT = QDCT_Y_DIR_N;
- if(1)//(dwZipCnt == 0)
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_N, QDCT_SEBIAO_HIGH_SPEED,1,5,5);
- }
- else
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 0;
- MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_N, QDCT_SEBIAO_HIGH_SPEED,1,5,5);
- }
- QDCT_MotorStep = 3;
- }
- break;
- case 3:
- if((dwRealPos - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH))QDCT_JLT_OUT = 1;
- if(!QDCT_JLT_IN)QDCT_XM_OUT = 0;
- /* if(dwZipCnt != 0)
- {
- if(cSeBiaoOk)
- {
- {
- QDCT_MotorStep = 4;
- }
- }
- else if(!cSeBiaoEn)
- {
- if((dwRealPos - back_dec_buff) >= (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_TQ_CHECK_LENGTH))
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- }
- }
- }
- else*/
- {
- if(!X_DRV)
- {
- QDCT_JLT_OUT = 1;
- QDCT_MotorStep = 4;
- }
- }
-
- break;
- case 4:
- if((dwRealPos - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH))QDCT_JLT_OUT = 1;
- if(!X_DRV && !QDCT_JLT_IN)
- {
- QDCT_XM_OUT = 0;
- QDCT_MotorStep = 5;
- }
- break;
- case 5:
-
- if(1)//(dwZipCnt == 0)
- QDCT_MotorStep = 0;
- else
- {
- if(((dwRealPos - back_dec_buff) > (QDCT_PARAM_SET_ZIPPER_LENGTH + QDCT_SEBIAO_ERROR_LENGHT))
- || ((dwRealPos - back_dec_buff) < (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_ERROR_LENGHT)))
- {
- QDCT_SetAlarmCode(QDCT_SE_BIAO_ALARM);
- }
- else
- {
- QDCT_MotorStep = 0;
- }
- }
- break;
- case 20:
- {
- if(QDCT_SZ_OUT == QDCT_MOTOR_DISEN)
- {
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
- QDCT_MotorDelay = dwTickCount + 50;
- }
-
- QDCT_MotorStep = 21;
- }
- break;
- case 21:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- QDCT_DIR_OUT = QDCT_Y_DIR_N;
- AxisMovePos(X_AXIS,20,-QDCT_PARAM_ON_BACK_LENGTH);
- QDCT_MotorStep = 22;
- }
- break;
- case 22:
- if(!X_DRV)
- {
- QDCT_MotorStep = 0;
- }
- break;
- case 30:
- if(QDCT_SZ_OUT == QDCT_MOTOR_DISEN)
- {
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
- QDCT_MotorDelay = dwTickCount + 50;
- }
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- QDCT_MotorStep = 31;
- break;
- case 31:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- gou_zhen_buff = dwRealPos;
- save_buff = dwRealPos;
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_XM_START_TIME;
- QDCT_DIR_OUT = QDCT_Y_DIR_N;
-
- if(QDCT_GetYL_Mode())
- {
- len_buf = QDCT_PARAM_YL_TRANS_LENGTH - QDCT_YL_MOTOR_SAFE_LENGTH;
- MoveAction_Pulse2_AccDec(X_AXIS,PosToPulse(X_AXIS,len_buf),PosToPulse(X_AXIS,QDCT_PARAM_PUTIN_SPEED_LENGTH),PosToPulse(X_AXIS,0),QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_PUTIN_SPEED,1, 5,10);
- QDCT_MotorStep = 132;
- }
- else
- {
- MoveAction_Pulse2_AccDec(X_AXIS,PosToPulse(X_AXIS,QDCT_PARAM_SET_ZIPPER_LENGTH-QDCT_PARAM_TC_LENGTH),PosToPulse(X_AXIS,QDCT_PARAM_PUTIN_SPEED_LENGTH),PosToPulse(X_AXIS,0),QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_PUTIN_SPEED,1, 5,10);
- QDCT_MotorStep = 32;
- }
- }
- break;
- case 32:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_buff = dwRealPos;
- QDCT_MotorStep = 33;
- }
- break;
- case 33:
- if((dwRealPos - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH))
- {
- QDCT_JLT_OUT = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 34;
- }
- else if(!X_DRV)
- {
- QDCT_JLT_OUT = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 34;
- }
- break;
- case 34:
- if(!QDCT_JLT_IN)
- {
- QDCT_XM_OUT = 0;
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 35;
- }
- else if(!X_DRV && !QDCT_JLT_IN)
- {
- QDCT_XM_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 35;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- break;
- case 35:
- if(!X_DRV && QDCT_XM_ORIGIN_IN)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorStep = 36;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- break;
- case 36:
- if(!X_DRV)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_DIR_OUT = QDCT_Y_DIR_P;
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_FZ_LENGTH,5,10,10);
- QDCT_MotorStep = 37;
- }
- break;
- case 37:
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorStep = 0;
- }
- break;
- case 132:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_buff = dwRealPos;
- QDCT_MotorStep = 133;
- }
- break;
- case 133:
- if((dwRealPos - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH))
- {
- QDCT_JLT_OUT = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 134;
- }
- else if(!X_DRV)
- {
- QDCT_MotorStep = 136;
- }
- break;
- case 134:
- if(!QDCT_JLT_IN)
- {
- QDCT_XM_OUT = 0;
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 135;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- break;
- case 135:
- if(!X_DRV && QDCT_XM_ORIGIN_IN)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorStep = 136;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- break;
- case 136:
- {
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_YL_OUT = 1;
- QDCT_MotorStep = 137;
- }
- break;
- case 137:
- if(!QDCT_YL_ORIGIN_IN)
- {
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_YL_DELAY_START;
- QDCT_MotorStep = 138;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_YL_ORIGIN_ALARM);
- break;
- case 138:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- SetPos(Y_AXIS, 0);
- revise_buff = &QDCT_PARAM_YL_OFFSET_LENGTH;
- QDCT_YL_DIR_OUT = 1;
- AxisMovePos(Y_AXIS,QDCT_PARAM_YL_SPEED,QDCT_PARAM_SET_ZIPPER_LENGTH -QDCT_PARAM_TC_LENGTH- QDCT_PARAM_YL_TRANS_LENGTH + (*revise_buff) + QDCT_YL_MOTOR_SAFE_LENGTH);
- if(!QDCT_XM_OUT)QDCT_MotorStep = 139;
- else QDCT_MotorStep = 150;
- }
- break;
- case 139:
- if(!Y_DRV)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_YL_DIR_OUT = 0;
- AxisMovePos(Y_AXIS,QDCT_PARAM_YL_SPEED,-QDCT_PARAM_YL_FZ_LENGTH);
- QDCT_MotorStep = 140;
- }
- break;
- case 140:
- if(!Y_DRV)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorStep = 0;
- }
- break;
- case 150:
- if(((dwRealPos+GetPos(Y_AXIS) - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH)) || !Y_DRV)
- {
- QDCT_JLT_OUT = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 151;
- }
- break;
- case 151:
- if(!QDCT_JLT_IN)
- {
- QDCT_XM_OUT = 0;
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 152;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- break;
- case 152:
- if(!Y_DRV && QDCT_XM_ORIGIN_IN)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_MotorStep = 139;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- break;
- case 40:
- {
- jz_buff = dwRealPos;
-
- if((QDCT_PARAM_SJZ_LENGTH == 0) || QDCT_GetYL_Mode())
- {
- QDCT_JD_OUT = 0;
- }
- QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
- QDCT_MotorStep = 41;
- }
- break;
- case 41:
- if(QDCT_JD_OUT && (dwTickCount >= QDCT_MotorDelay))
- {
- QDCT_DIR_OUT = QDCT_Y_DIR_N;
- if(QDCT_GetYL_Mode())
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,-QDCT_PARAM_CUT_BACK_LENGTH,1,10,10);
- else
- AxisMovePosAccDec(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,-(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH),1,10,10);
- QDCT_MotorStep = 42;
- }
- break;
- case 42: // 切断完成后拉电机动作
- if(((QDCT_PARAM_SJZ_LENGTH) <= (dwRealPos - jz_buff)))
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 43;
- }
- else if(!X_DRV)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QDCT_MotorStep = 0;
- QDCT_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- if(QDCT_JD_OUT || (QDCT_SZ_OUT == QDCT_MOTOR_DISEN))
- {
- QDCT_JD_OUT = 0;
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
- QDCT_MotorDelay = dwTickCount + 50;
- }
-
- if((QDCT_TuiLianStep == 0) && !QDCT_TL_OUT)QDCT_TuiLianStep = 1;
- QDCT_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(QDCT_GO_LIMIT_IN || QDCT_GO_DEC_IN)
- {
- QDCT_DIR_OUT = QDCT_Y_DIR_N;
- AxisMovePos(X_AXIS,20,-QDCT_PARAM_ON_BACK_LENGTH);
- QDCT_MotorDelay = dwTickCount + 1000;
- }
- QDCT_MotorStep = 63;
- QDCT_JD_OUT = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay))
- {
- go_buff = dwRealPos;
- QDCT_DIR_OUT = QDCT_Y_DIR_P;
- if(dwZipCnt > 0)
- {
- MoveAction_Const_Stop_AccDec(X_AXIS,QDCT_DIR_P,QDCT_PARAM_JJGO_SPEED,1,5,10);
- }
- else
- {
- MoveAction_Const_Stop_AccDec(X_AXIS,QDCT_DIR_P,QDCT_PARAM_FIRSTSPEED,1,5,10);
- }
-
- QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDCT_MotorStep = 64;
- }
- break;
- case 64:
- if(dwZipCnt > 0)
- {
- if(((go_buff - dwRealPos) > ((QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_PARAM_OFFSET_LENGTH) - (QDCT_PARAM_GO_LOWSPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDCT_PARAM_JJGO_SPEED,QDCT_PARAM_GO_LOWSPEED,5))) + QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH)) || QDCT_GO_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QDCT_PARAM_GO_LOWSPEED);
- QDCT_MotorStep = 66;
- QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- }
- else
- {
- if(QDCT_GO_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QDCT_PARAM_GO_LOWSPEED);
- QDCT_MotorStep = 66;
- }
- }
- break;
- case 65:
- if(QDCT_GO_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 66;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- break;
- case 66:
- if(!X_DRV)
- {
- QDCT_MotorDelay = dwTickCount;
- QDCT_MotorStep = 67;
- }
- break;
- case 67:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(QDCT_JiaLianStep == 0)
- {
- QDCT_JiaLianStep = 1;
- QDCT_MotorStep = 68;
- }
- }
- break;
- case 68:
- if(QDCT_JiaLianStep == 0)
- {
- QDCT_MotorStep = 0;
- }
- break;
- case 100://测试用
- if((dwTickCount >= QDCT_MotorDelay) && !X_DRV)
- {
- AxisMovePos(X_AXIS,QDCT_PARAM_JJBACK_SPEED,-(QDCT_PARAM_SET_ZIPPER_LENGTH));
- QDCT_MotorStep = 101;
- QDCT_MotorDelay = dwTickCount + 1000;
- }
- break;
- case 101:
- if((dwTickCount >= QDCT_MotorDelay) && !X_DRV)
- {
- QDCT_MotorStep = 102;
- }
- break;
- case 102:
- AxisMovePos(X_AXIS,QDCT_PARAM_JJBACK_SPEED,(QDCT_PARAM_SET_ZIPPER_LENGTH));
- QDCT_MotorStep = 100;
- QDCT_MotorDelay = dwTickCount + 1000;
- break;
- }
- }
- //切断动作
- void QDCT_XiaQieAction(void)
- {
- user_datas[121] = QDCT_AutoStep;
- user_datas[122] = QDCT_ZhuangLiaoStep;
- // user_datas[123] = QDCT_TuiLianStep;
- user_datas[124] = QDCT_MotorStep;
- user_datas[125] = QDCT_JiaLianStep;
- user_datas[126] = cSeBiaoEn;
- user_datas[127] = cSeBiaoOk;
- if(QDCT_XiaQieStep == 1)
- {
- if(QDCT_GO_LIMIT_IN)
- {
- QDCT_SetAlarmCode(QDCT_GO_LIMIT_ALARM);
- }
- else if(!QDCT_TL_ORIGIN_IN)
- QDCT_SetAlarmCode(QDCT_TL_ORIGIN_ALARM);
- else
- {
- QDCT_XiaQieStep = 2;
- }
- }
- else if(QDCT_XiaQieStep == 2)
- {
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUT_DELAY;
- QDCT_XiaQieStep = 3;
- }
- else if((QDCT_XiaQieStep == 3) && (dwTickCount >= QDCT_XiaQieDelay))
- {
- QDCT_SQ_OUT = 1;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_XiaQieStep = 4;
- }
- else if(QDCT_XiaQieStep == 4)
- {
- if(QDCT_SQ_LIMIT_IN)
- {
- QDCT_XiaQieStep = 5;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_DELAY_CS;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- }
- }
- else if((QDCT_XiaQieStep == 5) && (dwTickCount >= QDCT_XiaQieDelay))
- {
- QDCT_XiaQieStep = 6;
- if(QDCT_PARAM_CS_ENABLE)QDCT_CS_OUT = 1;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CS_TIME;
- }
- else if((QDCT_XiaQieStep == 6) && (dwTickCount >= QDCT_XiaQieDelay))
- {
- QDCT_CS_OUT = 0;
- QDCT_XiaQieStep = 7;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_COLD_TIME;
- }
- else if((QDCT_XiaQieStep == 7) && (dwTickCount >= QDCT_XiaQieDelay))
- {
- QDCT_SQ_OUT = 0;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_XiaQieStep = 8;
- }
- else if(QDCT_XiaQieStep == 8)
- {
- if(!QDCT_SQ_LIMIT_IN)
- {
- QDCT_XiaQieStep = 0;
- if(cBackFlg)
- {
- cBackFlg = 0;
- if(QDCT_MotorStep==0)QDCT_MotorStep = 40;
- }
- QDCT_YD_OUT = 1;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- }
- }
- }
- //装拉头动作
- void QDCT_ZLT_Step(void)
- {
- if(QDCT_ZhuangLiaoStep == 1)
- {
- if(ZhuangLiaoOkFlg)
- {
- QDCT_ZhuangLiaoStep = 0;
- }
- else
- {
- if(FirstStartFlg && QDCT_JLT_IN)
- {
- QDCT_ZhuangLiaoStep = 6;
- }
- else
- {
- FirstStartFlg = 0;
- if(QDCT_SongLiaoStep == 0)
- {
- QDCT_SongLiaoStep = 1;
- QDCT_ZhuangLiaoStep = 2;
- }
- }
- }
- }
- else if(QDCT_ZhuangLiaoStep == 2)
- {
- if(QDCT_SongLiaoStep == 0)
- {
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- if(QDCT_JLT_IN)QDCT_JLT_OUT = 1;
- QDCT_ZhuangLiaoStep = 3;
- }
- }
- else if(QDCT_ZhuangLiaoStep == 3)
- {
- if(QDCT_HSL_ORIGIN_IN && QDCT_XM_ORIGIN_IN && !QDCT_JLT_IN)
- {
- QDCT_HSL_OUT = 1;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 4;
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- if(!QDCT_HSL_ORIGIN_IN)
- {
- QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
- QDCT_HSL_OUT = 1;
- }
- else
- QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 4)
- {
- if(QDCT_HSL_LIMIT_IN)
- {
- QDCT_ZhuangLiaoStep = 20;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_PARAM_DELAY_JLT;
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
- QDCT_HSL_OUT = 0;
- }
- }
- else if((QDCT_ZhuangLiaoStep == 20) && (dwTickCount >= QDCT_ZhuangLiaoDelay))
- {
- QDCT_JLT_OUT = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 5;
- }
- else if(QDCT_ZhuangLiaoStep == 5)
- {
- if(QDCT_JLT_IN)
- {
- QDCT_ZhuangLiaoStep = 6;
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 6)
- {
-
- QDCT_HSL_OUT = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
-
- if(!bRunning)
- {
- QDCT_ZhuangLiaoStep = 0;
- SongLaTouOkFlg = 0;
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- }
- else
- {
- QDCT_ZhuangLiaoStep = 7;
- if(FirstStartFlg)
- {
- FirstStartFlg = 0;
- }
- else
- SongLaTouOkFlg = 0;
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- }
- }
- else if(QDCT_ZhuangLiaoStep == 7)
- {
- if(!QDCT_HSL_LIMIT_IN && QDCT_GO_LIMIT_IN)
- {
- QDCT_XM_OUT = 1;
-
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 8;
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- if(QDCT_HSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
- QDCT_HSL_OUT = 0;
- }
- }
- else if(QDCT_ZhuangLiaoStep == 8)
- {
- if(!QDCT_XM_ORIGIN_IN)
- {
- QDCT_ZhuangLiaoStep = 9;
- QDCT_ZhuangLiaoDelay = dwTickCount + 1000;
-
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- QDCT_SetAlarmCode(QDCT_XM_LIMIT_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 9)
- {
- if(QDCT_LTCZ_IN)
- {
- QDCT_ZhuangLiaoStep = 0;
- ZhuangLiaoOkFlg = 1;
- TryCnt = 0;
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- if(bRunning)
- {
- TryCnt++;
- if(TryCnt > 4)
- {
- QDCT_SetAlarmCode(QDCT_LTCZ_ALARM);
- QDCT_JLT_OUT = 1;
- QDCT_XM_OUT = 0;
- }
- else
- {
- QDCT_ZhuangLiaoStep = 10;
- }
- }
- else
- {
- QDCT_ZhuangLiaoStep = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount;
- }
- }
-
- }
- else if(QDCT_ZhuangLiaoStep == 10) //装拉头失败重复装几次拉头
- {
- QDCT_XM_OUT = 0;
- QDCT_JLT_OUT = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 11;
- }
- else if(QDCT_ZhuangLiaoStep == 11)
- {
- if(QDCT_XM_ORIGIN_IN)
- {
- QDCT_ZhuangLiaoStep = 12;
- }
- else if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 12)
- {
- QDCT_ZhuangLiaoStep = 1;
- }
- }
- void QDCT_SL_Step(void)
- {
- if(QDCT_SongLiaoStep == 1)
- {
- if(SongLaTouOkFlg)
- {
- QDCT_SongLiaoStep = 0;
- }
- else
- {
- QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_SongLiaoStep = 2;
- }
- }
- else if(QDCT_SongLiaoStep == 2)
- {
- if(QDCT_HSL_ORIGIN_IN && !QDCT_HSL_LIMIT_IN)
- {
- QDCT_SL_OUT = 1;
- QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_SongLiaoStep = 3;
- }
- else if(dwTickCount >= QDCT_SL_Delay)
- {
- QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
- QDCT_HSL_OUT = 1;
- }
- }
- else if(QDCT_SongLiaoStep == 3)
- {
- if(QDCT_SL_LIMIT_IN)
- {
- QDCT_SL_Delay = dwTickCount + QDCT_PARAM_SL_BACKDELAY;
- QDCT_SongLiaoStep = 4;
- }
- else if(dwTickCount >= QDCT_SL_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
-
- }
- else if((QDCT_SongLiaoStep == 4) && (dwTickCount >= QDCT_SL_Delay))
- {
- QDCT_SL_OUT = 0;
- QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_SongLiaoStep = 5;
- }
- else if(QDCT_SongLiaoStep == 5)
- {
- if(!QDCT_SL_LIMIT_IN)
- {
- QDCT_SongLiaoStep = 0;
- QDCT_SL_Delay = dwTickCount;
- SongLaTouOkFlg = 1;
- }
- else if(dwTickCount >= QDCT_SL_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- }
- }
- //手动动作
- void QDCT_ManualAction(void)
- {
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(QDCT_TOTAL_ADDR);
- }
-
- if(QDCT_bClerNowTotal)
- {
- QDCT_bClerNowTotal = 0;
- cTbCnt = 0;
- ClrcToTal(QDCT_NOWTOTAL_ADDR);
- }
-
-
- if(QDCT_bQieDuan)
- {
- QDCT_bQieDuan = 0;
- if(QDCT_XiaQieStep == 0)QDCT_XiaQieStep = 1;
- }
-
- if(QDCT_bQianDianDW)
- {
- QDCT_bQianDianDW = 0;
- if((QDCT_MotorStep == 0) && !QDCT_SQ_LIMIT_IN)
- {
- QDCT_MotorStep = 61;
- dwZipCnt = 0;
- }
- else if(QDCT_SQ_LIMIT_IN)
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
- }
-
- if(QDCT_bManXM)
- {
- QDCT_bManXM = 0;
- QDCT_XM_OUT = ~QDCT_XM_OUT;
-
- if(QDCT_HSL_OUT == 1)QDCT_XM_OUT = 0;
- }
-
- if(QDCT_bManSQ)
- {
- QDCT_bManSQ = 0;
- QDCT_SQ_OUT = ~QDCT_SQ_OUT;
- if(QDCT_GO_LIMIT_IN) QDCT_SQ_OUT = 0;
- }
-
- if(QDCT_bManJD)
- {
- QDCT_bManJD = 0;
- QDCT_JD_OUT = ~QDCT_JD_OUT;
-
- if((QDCT_JiaLianStep == 0) && QDCT_JD_OUT)QDCT_JiaLianStep = 2;
- }
-
- if(QDCT_bManSL)
- {
- QDCT_bManSL = 0;
- QDCT_SL_OUT = ~QDCT_SL_OUT;
-
- if(!QDCT_HSL_ORIGIN_IN)QDCT_SL_OUT = 0;
- }
-
- if(QDCT_bManHSL)
- {
- QDCT_bManHSL = 0;
-
- if(QDCT_HSL_OUT || QDCT_XM_OUT || QDCT_SL_LIMIT_IN)
- {
- QDCT_HSL_OUT = 0;
- }
- else
- {
- if(cManHSLStep== 0)cManHSLStep = 1;
- }
-
- }
-
- switch(cManHSLStep)
- {
- case 1:
- QDCT_JLT_OUT = 1;
- QDCT_HSL_OUT = 1;
- cManHSLStep = 2;
- break;
- case 2:
- if(QDCT_HSL_LIMIT_IN)
- {
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_PARAM_DELAY_JLT;
- cManHSLStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= QDCT_ZhuangLiaoDelay)
- {
- QDCT_JLT_OUT = 0;
- cManHSLStep = 0;
- }
- break;
- }
-
- if(QDCT_bManZD)
- {
- QDCT_bManZD = 0;
- QDCT_ZDP_OUT = ~QDCT_ZDP_OUT;
- }
-
- if(QDCT_bManKL)
- {
- QDCT_bManKL = 0;
- QDCT_KL_OUT = ~QDCT_KL_OUT;
- }
-
-
- if(QDCT_bManJLT)
- {
- QDCT_bManJLT = 0;
- QDCT_JLT_OUT = ~QDCT_JLT_OUT;
- }
-
- if(QDCT_bManYD)
- {
- QDCT_bManYD = 0;
- QDCT_YD_OUT = ~QDCT_YD_OUT;
- }
-
- if(QDCT_bManTL)
- {
- QDCT_bManTL = 0;
-
- if(QDCT_TL_OUT)
- {
- QDCT_TL_OUT = 0;
- QDCT_YD_OUT = 0;
- }
- else
- {
- if(QDCT_TuiLianStep==0)QDCT_TuiLianStep=1;
- }
- }
- if(QDCT_bZhuangLiao)
- {
- QDCT_bZhuangLiao = 0;
- if(QDCT_ZhuangLiaoStep == 0)
- {
- TryCnt = 0;
- SongLaTouOkFlg = 1;
- QDCT_ZhuangLiaoStep = 1;
- FirstStartFlg = 0;
- ZhuangLiaoOkFlg = 0;
- }
- }
-
- if(QDCT_bSongLT)
- {
- QDCT_bSongLT = 0;
- if(QDCT_SongLiaoStep == 0)
- {
- QDCT_SongLiaoStep = 1;
- SongLaTouOkFlg = 0;
- }
- }
-
- if(QDCT_bChuanLT)
- {
- QDCT_bChuanLT = 0;
- if(!QDCT_BACK_LIMIT_IN)
- {
- if(QDCT_MotorStep == 0)QDCT_MotorStep = 30;
- }
- }
-
- if(QDCT_bManSZ)
- {
- QDCT_bManSZ = 0;
- QDCT_SZ_OUT = ~QDCT_SZ_OUT;
- }
- //电机控制
- if(QDCT_bMotorGo && !QDCT_GO_LIMIT_IN && !QDCT_SQ_LIMIT_IN)
- {
- QDCT_JD_OUT = 0;
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
- QDCT_DIR_OUT = QDCT_Y_DIR_P;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_P, 5,5,10,10);
- }
- else if(QDCT_bMotorGo && QDCT_SQ_LIMIT_IN)
- QDCT_SetAlarmCode(QDCT_SQ_LIMIT_ALARM);
-
- if(QDCT_bMotorBack && !QDCT_BACK_LIMIT_IN)
- {
- QDCT_JD_OUT = 0;
- QDCT_SZ_OUT = QDCT_MOTOR_EN;
- QDCT_DIR_OUT = QDCT_Y_DIR_N;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, QDCT_DIR_N, 5,5,10,10);
- }
-
- if(!QDCT_bMotorGo && !QDCT_bMotorBack && (QDCT_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(QDCT_GO_LIMIT_IN && (QDCT_MotorStep == 0) && !QDCT_bMotorBack &&(QDCT_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- if(QDCT_bManMotorSL)
- {
- QDCT_YL_DIR_OUT = 1;
- if(!Y_DRV)AxisContinueMove(Y_AXIS,10,0);
- }
- else
- {
- if(Y_DRV && (QDCT_SongLianStep == 0) && (QDCT_MotorStep == 0))AxisEgmStop(Y_AXIS);
- }
-
- }
-
- if(QDCT_PARAM_ZD_ENABLE)QDCT_ZDP_OUT = 1;
- else QDCT_ZDP_OUT = 0;
-
- }
- #endif
|