1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918 |
- #include "global.h"
- #if JU_XING_MACHINE ==1
- void BK_QueDuan_AlarmProtect(void);
- void BK_QueDuan_ManualAction(void);
- void BK_QueDuan_AutoAction(void);
- void BK_QueDuan_StepCheckStart(void);
- void BK_QueDuan_XiaQue(void);
- void BK_QueDuan_Motor(void);
- void BK_QueDuan_YuanDianAction(void);
- void BK_QueDuan_TuiLianAction(void);
- void BK_QueDuan_ExtiActionX31(void);
- void BK_QueDuan_BingLian(void);
- void BK_StopCode(void);
- void BKQD_TuiDaiAction(void);
- short *BK_length_buffer;
- void BKQD_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(BKQD_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void BK_QueDuan_ExtiActionX31(void)
- {
- KK_cCheckLianFlg = 1;
- }
- void BK_StopCode(void)
- {
- switch(BKQD_StopStep)
- {
- case 1:
- BKQD_StopStep=2;
- if(X_DRV)
- {
- AxisChangeSpeedDirect(X_AXIS,GetCurSpeed(X_AXIS) * 2/3);
- AxisDecStop(X_AXIS);
- }
- break;
- case 2:
- if(!X_DRV || (KK_cRealPos < 10))
- {
- BKQD_StopCodeDelay=dwTickCount+350;
- BKQD_StopStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= BKQD_StopCodeDelay)
- {
- if(!cSTOPONE)
- {
- BKQD_StopStep=0;
-
- }
- else
- {
- BKQD_SetAlarmCode(BKQD_PARAM_ANQUANMEN_ALARM);
- BKQD_StopStep=0;
- cSTOPONE=0;
- }
- BKQD_SZ_OUT = 1; //电机松轴
- }
- break;
- }
- }
- void BK_QueDuan_InitAction(void)
- {
- float length_buff,pulse_buff;
-
- length_buff = BKQD_PARAM_CYCLE_LENGTH;
- pulse_buff = BKQD_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- // BKQD_SZ_OUT = 1;
- BKQD_SetAlarmCode(0);
- SetDirReverse(X_AXIS, 1);
- }
- void BK_QueDuan_Action(void)
- {
-
- BK_QueDuan_AlarmProtect();
- BK_QueDuan_Motor();
- BK_QueDuan_XiaQue();
- BK_QueDuan_ManualAction();
- BK_QueDuan_TuiLianAction();
- BK_QueDuan_BingLian();
- BK_StopCode();
- BK_QueDuan_AutoAction();
- BK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
-
-
- }
- //手动动作
- void BK_QueDuan_ManualAction(void)
- {
- //条数或扎数达到后,台面电机转两秒之后再停机
- if(KK_cTABLETIME)
- {
- if(KK_cTABLETOTAL)
- {
- KK_cTABLETOTAL=0;
- BKQD_TABLE_VAVLE = 1;
- BKQD_TableDelay=dwTickCount + 2000;
-
- }
- if(dwTickCount >= BKQD_TableDelay)
- {
- BKQD_TABLE_VAVLE = 0;
- KK_cTABLETIME=0;
-
- }
- }
- if(bRunning == 0)
- {
-
-
-
- KK_cGoLimitEn = 0;
- if(BKQD_bClearTotal) //切断计数清零
- {
- BKQD_bClearTotal = 0;
- ClrcToTal(BKQD_TOTAL_ADDR);
- }
-
- if(BKQD_bClearNowTotal)
- {
- BKQD_bClearNowTotal = 0;
- BKQD_PARAM_NOW_CNT = 0;
- }
-
- if(BKQD_bXiaQie)
- {
- BKQD_bXiaQie = 0;
- if((BKQD_XiaQieStep == 0) && !BKQD_TL_VAVLE)
- {
- BKQD_XiaQieStep = 1;
- }
- }
-
- if(BKQD_bQianDianDW)
- {
- BKQD_bQianDianDW = 0;
- if(BKQD_MotorStep == 0)
- {
- BKQD_MotorStep = 61;
- cZipCnt = 0;
- }
- }
-
- if(BKQD_bTL)
- {
- BKQD_bTL = 0;
- if(BKQD_TL_VAVLE)
- {
- BKQD_TL_VAVLE = 0;
- }
- else if(!BKQD_GZ_VAVLE && !BKQD_SM_VAVLE)
- {
- BKQD_TL_VAVLE = ~BKQD_TL_VAVLE;
- }
- }
- if(BKQD_bECQ)
- {
- BKQD_bECQ=0;
- KK_cShuangDao=1;
- KK_cDiErLaChu=1;
- KK_cECQ_STOP=1;
- bRunning = 1;
- BKQD_AutoStep = 1;
-
- }
-
-
- // if(!Y_DRV)BKQD_bTL = 0;
-
- if(BKQD_bYD)
- {
- BKQD_bYD = 0;
- BKQD_YD_VAVLE = ~BKQD_YD_VAVLE;
- }
-
- if(BKQD_bGZ)
- {
- BKQD_bGZ = 0;
- BKQD_GZ_VAVLE = ~BKQD_GZ_VAVLE;
- }
-
- if(BKQD_bJD)
- {
- BKQD_bJD = 0;
- BKQD_JD_VAVLE = ~BKQD_JD_VAVLE;
- }
-
- if(BKQD_bXM)
- {
- BKQD_bXM = 0;
- BKQD_XM_VAVLE = ~BKQD_XM_VAVLE;
- if(!BKQD_XM_VAVLE)BKQD_GZ_VAVLE = 0;
- }
- if(BKQD_GOUZHEN_IN_UP)
- {
- BKQD_YD_VAVLE=1;
- }
-
- if(BKQD_bSM)
- {
- BKQD_bSM = 0;
- if(BKQD_SM_VAVLE)
- BKQD_SM_VAVLE = 0;
- else if(!BKQD_TL_VAVLE || !BKQD_PARAM_XM_ENABLE)
- BKQD_SM_VAVLE = 1;
- }
- //推方块
- if(BKQD_bTFK)
- {
- BKQD_bTFK = 0;
- BKQD_TFK_VAVLE = ~BKQD_TFK_VAVLE;
- }
- //台面电机
- if(BKQD_bTB)
- {
- BKQD_bTB = 0;
- BKQD_TABLE_VAVLE = ~BKQD_TABLE_VAVLE;
- }
-
- // if(BKQD_bYBD)
- // / {
- // BKQD_bYBD = 0;
- // BKQD_YBD_VAVLE = ~BKQD_YBD_VAVLE;
- // }
-
- if(BKQD_bTestCS)
- {
- BKQD_bTestCS = 0;
- BKQD_CS_OUT = 1;
- BKQD_CSDelay = dwTickCount + BKQD_PARAM_CS_TIME;
- }
-
- if(BKQD_bBL)//吹气
- {
- BKQD_bBL = 0;
- BKQD_CQ_VAVLE = ~BKQD_CQ_VAVLE;
- }
-
- if(BKQD_bHL) //护链,双开用
- {
- BKQD_bHL = 0;
- BKQD_HL_VAVLE = ~BKQD_HL_VAVLE;
- }
-
- if(BKQD_bYX)
- {
- BKQD_bYX = 0;
- BKQD_YX_VAVLE = ~BKQD_YX_VAVLE;
- }
- if(BKQD_XiaQieStep == 0)
- {
- if(dwTickCount >= BKQD_CSDelay)BKQD_CS_OUT = 0;
- }
- //电机控制
- if(BKQD_bGoMotor && !BKQD_QIAN_LIMIT_IN)
- {
- BKQD_SZ_OUT = 0;
- // BKQD_JZ_DIR = BKQD_YDIR_N;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_GO_LOW_SPEED,10,12);
-
- }
-
- if(BKQD_bBackMotor) //后退限位已经取消
- {
- BKQD_SZ_OUT = 0;
- // BKQD_JZ_DIR = BKQD_YDIR_P;
- if(!X_DRV)
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_P,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_GO_LOW_SPEED,10,12);
- }
-
- if(!BKQD_bGoMotor && !BKQD_bBackMotor && (BKQD_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(BKQD_QIAN_LIMIT_IN && (BKQD_MotorStep == 0) && !BKQD_bBackMotor &&(BKQD_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
- }
- }
- void BK_QueDuan_AlarmProtect(void)
- {
- KK_cRealPos = GetPos(X_AXIS);
-
- if(!bRunning)
- {
- ;
- //
- #if 0
- if(BKQD_BACK_LIMIT_IN_UP)
- {
- if((BKQD_MotorStep == 0) && X_DRV && BKQD_bBackMotor) //到后限不能再后退但可以点前进
- {
- BKQD_bBackMotor = 0;
-
- AxisDecStop(X_AXIS);
- BKQD_JD_VAVLE = 0;
- BKQD_SetAlarmCode(BKQD_BACK_ALARM);
-
- }
- }
- #endif
- }
- else
- {
- if((KK_cRealPos > BKQD_PARAM_RUN_LENGTH) && (BKQD_PARAM_RUN_LENGTH > 3000)
- && (KK_cGoLimitEn != 0))
- {
- AxisEgmStop(X_AXIS);
- BKQD_JD_VAVLE = 0;
- BKQD_SetAlarmCode(BKQD_BACK_ALARM);
- }
- }
- }
- void BK_QueDuan_AutoAction(void)
- {
- //台面电机定时关掉
-
-
- if(BKQD_QIAN_STOP_Auto)
- {
-
- KK_cDLJ_ATUO=1;
- AxisEgmStop(X_AXIS);
-
-
-
- }
- if(BKQD_QIAN_START_Auto)
- {
- if(KK_cDLJ_ATUO)
- {
- KK_cDLJ_ATUO=0;
- BKQD_AutoDelay = dwTickCount + 1000;
- BKQD_MotorDelay = dwTickCount + 2000;
- if((BKQD_MotorStep==63 || BKQD_MotorStep==64 || BKQD_MotorStep==65) && !BKQD_QIAN_LIMIT_IN)
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,BKQD_PARAM_GO_LOW_SPEED/3,15,15);
- else if((KK_cRealPos < BKQD_PARAM_ZIPPER_LENGTH) && (BKQD_MotorStep > 311))
- AxisMoveTwoPos(X_AXIS,1000,(BKQD_PARAM_ZIPPER_LENGTH - KK_cRealPos) + (*BK_length_buffer),
- BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED_LENGTH,BKQD_DIR_P,5000,3000,20,30);
-
- }
-
-
- }
- if(!KK_cDLJ_ATUO)
- {
- if(bRunning)
- {
- if(!KK_cTABLETIME)
- {
- if(dwTickCount >= BKQD_TBDelay)
- BKQD_TABLE_VAVLE = 0;
- }
- switch(BKQD_AutoStep)
- {
- case 1:
- if(dwTickCount >= BKQD_AutoDelay)
- {
- BKQD_AutoStep = 2;
- if(BKQD_MotorStep == 0)
- {
- BKQD_MotorStep = 61; //前点定位
- }
- KK_cGoLimitEn = 0;
- }
- break;
- case 2:
- if(BKQD_MotorStep == 0)
- {
- if(!KK_cShuangDao)
- BKQD_MotorStep = 30;
- else
- BKQD_MotorStep = 801;
- BKQD_AutoStep = 3;
- KK_cGoLimitEn = 1;
- }
- break;
- case 3:
- if(BKQD_MotorStep == 0)
- {
- if(BKQD_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
-
- if(!KK_cShuangDao)
- {
- if(BKQD_XiaQieStep == 0)
- BKQD_XiaQieStep = 1;
- }
- else
- {
- if(BKQD_XiaQieStep == 0)
- BKQD_XiaQieStep = 201;
- }
- BKQD_AutoStep = 4;
- }
- }
- break;
- case 4:
-
- // 闭口
- if((BKQD_XiaQieStep == 0) || ((BKQD_XiaQieStep == 6) && BKQD_KB_MODE)|| ((BKQD_XiaQieStep == 14) && (BKQD_KB_MODE == 0)))// && !BKQD_SHANG_MU_LIMIT_IN)
- {
- if(BKQD_MotorStep == 0)
- {
- KK_cGoLimitEn=0;
- BKQD_MotorStep = 40; //切完后退
-
- }
- BKQD_AutoStep = 5;
- }
-
- break;
- case 5:
-
- if(BKQD_MotorStep == 0)
- {
- if(!KK_cDiErLaChu)
- cZipCnt++;
- BKQD_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(BKQD_TOTAL_ADDR);
- AddToTal(CT_WORKTOTAL_ADDR);
- CalProSP(BKQD_PROSPEED_ADDR);
-
- if(cTableCnt >= BKQD_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- BKQD_TABLE_VAVLE = 1;
- BKQD_TBDelay = dwTickCount + BKQD_PARAM_TB_TIME;
- }
-
- if( SingOneFlg || cZhouWanone)
- {
-
- {
- cZhouWanone=0;
- cStopMode=0;
- bRunning = 0;
- BKQD_AutoStep = 0;
- SingOneFlg = 0;
- BKQD_TABLE_VAVLE = 0;
-
- }
-
- // if(GetTotal(BKQD_TOTAL_ADDR) >= BKQD_PARAM_SET_TOTAL) BKQD_SetAlarmCode(BKQD_TOTAL_ALARM);
- }
- else
- {
- BKQD_AutoStep = 1;
-
- if((BKQD_PARAM_NOW_CNT >= BKQD_PARAM_ZHA_SHU) && (BKQD_PARAM_ZHA_SHU > 0))
- {
- BKQD_AutoDelay = dwTickCount + BKQD_PARAM_ZS_STOP_TIME;
- BKQD_PARAM_NOW_CNT = 0;
- KK_cTABLETIME = 1;
- KK_cTABLETOTAL= 1;
- if(BKQD_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- BKQD_AutoStep = 0;
- SingOneFlg = 0;
- KK_cTABLETIME = 1;
- KK_cTABLETOTAL= 1;
- BKQD_SetAlarmCode(BKQD_TOTAL_ALARM);
- }
- }
- else
- BKQD_AutoDelay = dwTickCount + BKQD_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- }
- void BK_QueDuan_StepCheckStart(void)
- {
- // 启动
- if((START_IN_UP) || bStart || BKQD_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (BKQD_AutoStep == 0))
- {
- if(BKQD_XIA_MU_LIMIT_IN && !BKQD_PARAM_XM_ENABLE)BKQD_SetAlarmCode(BKQD_XM_DAOWEI);
- // else if(GetAlarmCode(BKQD_ALARM_ADDR) != 0);
- //else if(GetTotal(BKQD_TOTAL_ADDR) >= BKQD_PARAM_SET_TOTAL) BKQD_SetAlarmCode(BKQD_TOTAL_ALARM);
- // else if(BKQD_BL_VAVLE)BKQD_SetAlarmCode(BKQD_BL_ALARM);
- else if(BKQD_SM_VAVLE)BKQD_SetAlarmCode(BKQD_SM_ALARM);
- else
- {
- bRunning = 1;
- BKQD_AutoStep = 1;
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_PARAM_BL_ENABLE=1 ; //并链起动
- if(BKQD_bSingle)
- {
- SingOneFlg= 1;
- BKQD_bSingle=0;
-
- }
- else
- {
- SingOneFlg=0;
- }
- cZipCnt = 0;
- KK_cTABLETIME = 0;
- KK_cTABLETOTAL= 0;
- cSTOPONE=0;
- cTuiFangKuaiCnt = 0;
- BKQD_BL_VAVLE = 0; //并链关
- KK_cDLJ_ATUO=0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- }
- }
- BKQD_bSingle = 0;
- }
- if(BKQD_STOP_ANNIU_IN_UP)
- {
- bRunning = 0;
- BKQD_XiaQieStep = 0;
- BKQD_AutoStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- dwTickCount = BKQD_TBDelay;
- BKQD_CHUIQIStep=0;
- SingOneFlg = 0;
- BKQD_JD_VAVLE = 0;
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_YD_VAVLE = 0;
- BKQD_TFK_VAVLE= 0;
- BKQD_YX_VAVLE = 0;
- BKQD_HL_VAVLE = 0;
- BKQD_TL_VAVLE = 0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- BKQD_CS_OUT = 0;
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_SZ_OUT = 1;
- BKQD_GZ_VAVLE = 0;
- BKQD_TABLE_VAVLE = 0;
- BKQD_StopStep=1;
- KK_cTABLETIME = 0;
- KK_cTABLETOTAL= 0;
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- SetAlarmCode(BKQD_ALARM_ADDR,0);
-
- }
- if((BKQD_ANQUANMEN_LIMIT_IN_UP || BKQD_ANQUANMEN_LIMIT_IN) && bRunning)
- {
-
- BKQD_StopStep=1;
- cSTOPONE=1;
- }
- if(STOP_IN_UP)
- {
- if(bRunning)
- {
- KK_cShuangDao=0;
- KK_cDiErLaChu=0;
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- dwTickCount = BKQD_TBDelay;
- BKQD_CHUIQIStep=0;
- SingOneFlg = 0;
- BKQD_JD_VAVLE = 0;
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_YD_VAVLE = 0;
- BKQD_TFK_VAVLE= 0;
- BKQD_YX_VAVLE = 0;
- BKQD_HL_VAVLE = 0;
- cStopMode=0;
- cZhouWanone=0;
- BKQD_TL_VAVLE = 0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- BKQD_CS_OUT = 0;
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- // BKQD_SZ_OUT = 1;
- BKQD_GZ_VAVLE = 0;
- BKQD_TABLE_VAVLE = 0;
- if((BKQD_StopStep == 0) && X_DRV)
- BKQD_StopStep = 1;
- KK_cTABLETIME = 0;
- KK_cTABLETOTAL= 0;
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- bRunning = 0;
- BKQD_XiaQieStep = 0;
- BKQD_AutoStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- }
- else
- {
- KK_cShuangDao=0;
- KK_cDiErLaChu=0;
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- dwTickCount = BKQD_TBDelay;
- BKQD_CHUIQIStep=0;
- SingOneFlg = 0;
- BKQD_JD_VAVLE = 0;
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_YD_VAVLE = 0;
- BKQD_TFK_VAVLE= 0;
- BKQD_YX_VAVLE = 0;
- BKQD_HL_VAVLE = 0;
- cStopMode=0;
- cZhouWanone=0;
- BKQD_TL_VAVLE = 0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- BKQD_CS_OUT = 0;
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_SZ_OUT = 1;
- BKQD_GZ_VAVLE = 0;
- BKQD_TABLE_VAVLE = 0;
- if((BKQD_StopStep == 0))
- {
- KK_cSTOPONE = 0;
- AxisEgmStop(X_AXIS);
- BKQD_SZ_OUT = 1;
- }
- KK_cTABLETIME = 0;
- KK_cTABLETOTAL= 0;
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- bRunning = 0;
- BKQD_XiaQieStep = 0;
- BKQD_AutoStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
-
- }
- }
- //停止
- if( bStop)
- {
- bStop = 0;
- if(cStopMode < 2)
- cStopMode++;
- if(cStopMode==1 && bRunning)
- cZhouWanone=1;
- if(bRunning && cStopMode==2)
- {
-
- KK_cShuangDao=0;
- KK_cDiErLaChu=0;
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- dwTickCount = BKQD_TBDelay;
- SingOneFlg = 0;
- bRunning = 0;
- BKQD_XiaQieStep = 0;
- BKQD_AutoStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_JD_VAVLE = 0;
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_YD_VAVLE = 0;
- BKQD_TFK_VAVLE= 0;
- BKQD_TL_VAVLE = 0;
- BKQD_HL_VAVLE = 0;
- BKQD_CS_OUT = 0;
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- //BKQD_SZ_OUT = 1;
- BKQD_GZ_VAVLE = 0;
- BKQD_TABLE_VAVLE = 0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- if((BKQD_StopStep == 0) && X_DRV)
- BKQD_StopStep = 1;
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- KK_cTABLETIME = 0;
- KK_cTABLETOTAL= 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
-
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- }
- else if(!bRunning)
- {
- KK_cShuangDao=0;
- KK_cDiErLaChu=0;
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- dwTickCount = BKQD_TBDelay;
- BKQD_CHUIQIStep=0;
- SingOneFlg = 0;
- BKQD_JD_VAVLE = 0;
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_YD_VAVLE = 0;
- BKQD_TFK_VAVLE= 0;
- BKQD_YX_VAVLE = 0;
- BKQD_HL_VAVLE = 0;
- cStopMode=0;
- cZhouWanone=0;
- BKQD_TL_VAVLE = 0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- BKQD_CS_OUT = 0;
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_SZ_OUT = 1;
- BKQD_GZ_VAVLE = 0;
- BKQD_TABLE_VAVLE = 0;
- if((BKQD_StopStep == 0))
- {
- KK_cSTOPONE = 0;
- AxisEgmStop(X_AXIS);
- BKQD_SZ_OUT = 1;
- }
- KK_cTABLETIME = 0;
- KK_cTABLETOTAL= 0;
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- bRunning = 0;
- BKQD_XiaQieStep = 0;
- BKQD_AutoStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- }
-
- }
-
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- BKQD_XiaQieStep = 0;
- BKQD_AutoStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
-
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- SingOneFlg = 0;
- bRunning = 0;
- // BKQD_StopStep=1;
- cStopMode=0;
- cZhouWanone=0;
- dwTickCount = BKQD_TBDelay;
- BKQD_TABLE_VAVLE = 0;
- BKQD_TFK_VAVLE =0;
- BKQD_JD_VAVLE=0;
- BKQD_GZ_VAVLE=0;
- }
-
- }
- //记忆长度模式误差检测
- void BK_QueDuan_CheckLength(long zip_length)
- {
- static long start_dist;
- switch(BKQD_CheckLengthStep)
- {
- case 0:break;
- case 1:
- start_dist = KK_cRealPos;
- dwSaveLength = 0;
- BKQD_CheckLengthStep = 2;
- break;
- case 2:
- if(BKQD_GUO_LIAN_IN_DW)
- {
- dwSaveLength = KK_cRealPos - start_dist;
- // user_datas[127] = KK_cRealPos;
-
- }
- break;
- }
- }
- void BK_QueDuan_BingLian(void)
- {
- static long bl_pos_buff,HL_delay;
-
- switch(BKQD_BinLianStep)
- {
- case 1:
- bl_pos_buff = KK_cRealPos;
-
- BKQD_BinLianStep = 2;
- break;
- case 2:
- if((KK_cRealPos - bl_pos_buff) >= BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_BL_VAVLE = 1;
- BKQD_BinLianStep = 3;
- }
- break;
- case 3://有过链检测
- if((KK_cRealPos - bl_pos_buff) >= (BKQD_PARAM_ZIPPER_LENGTH - BKQD_PARAM_HL_DELAY_BACK))
- {
- BKQD_BL_VAVLE = 0;
- BKQD_BinLianStep = 0;
- }
- if(BKQD_GUO_LIAN_IN_DW && BKQD_PARAM_BACK_MODE ==1) //|| (BKQD_PARAM_BACK_MODE==2 && cZipCnt < 2)))
- {
- BKQD_BL_VAVLE = 0;
- BKQD_BinLianStep = 0;
- }
- break;
- case 10:
- bl_pos_buff = KK_cRealPos;
- BKQD_BinLianStep = 11;
- break;
- case 11:
- if((KK_cRealPos - bl_pos_buff) >= BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_BL_VAVLE = 1;
- BKQD_BinLianStep = 12;
- }
- break;
- case 12://有过链检测
- if(BKQD_GUO_LIAN_IN_DW)
- {
- BKQD_BL_VAVLE = 0;
- BKQD_BinLianStep = 0;
- }
- break;
- default:;
- }
-
- }
- //作闭口专用程序
- //不带过链感应长度输入电机长度 闭口有勾针到位
- void BK_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] = BKQD_MotorStep;
- user_datas[122] = BKQD_AutoStep;
- user_datas[123]= KK_cRealPos;
- user_datas[125]= bRunning;
- // user_datas[123] = length_buff - (*BK_length_buffer);
- // user_datas[127] = KK_cRealPos;
- // user_datas[126] = go_buff - KK_cRealPos;
-
-
- if((BKQD_MotorStep >= 101) && (BKQD_MotorStep <= 103))
- {
- if(BKQD_QIAN_LIMIT_IN_DW)BKQD_HL_VAVLE = 0;
- }
- if(!KK_cDLJ_ATUO)
- {
- switch(BKQD_MotorStep)
- {
- case 30:
- switch(BKQD_PARAM_BACK_MODE) //开口分四种模式
- {
- case 0: //单数控模式
- BKQD_MotorStep = 310; //每种模式留20步
- BKQD_DGLG_VAVLE = 1; //顶过链杆关
- break;
- case 1://单感应模式
- BKQD_MotorStep = 330; //每种模式留20步
-
- break;
- case 2: //先感应后数控模式+检测
- BKQD_MotorStep = 350; //每种模式留20步
- break;
- default: //数控模式+过链检测长度
- BKQD_MotorStep = 370; //每种模式留20步
- break;
- }
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK;
- break;
-
- case 310:
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK;
- SetDir(X_AXIS, BKQD_DIR_P);
- BKQD_JZ_DIR = BKQD_YDIR_P;
- SetPos(X_AXIS, 0);
- BK_length_buffer = &BKQD_PARAM_OFFSET_LENGTH;
- if(BKQD_PARAM_BL_ENABLE) //
- BKQD_BinLianStep = 1;
- BKQD_MotorStep = 311;
- break;
- case 311:
- if(KK_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH ))
- BKQD_GZ_VAVLE = 1;
- if(dwTickCount >= BKQD_MotorDelay)
- {
- back_buff = KK_cRealPos;
- gou_zhen_buff = KK_cRealPos;
- save_buff = KK_cRealPos;
- BK_length_buffer = &BKQD_PARAM_OFFSET_LENGTH;
- DCC_TIME_BL=BKQD_PARAM_GO_HIGH_SPEED/500;
- //李永庆代码
- //两段速度移动距离
- // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
- AxisMovePosAccDecNotStop(X_AXIS,BKQD_PARAM_BACK_SPEED,BKQD_PARAM_ZIPPER_LENGTH + (*BK_length_buffer), BKQD_PARAM_START_SPEED,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_ACC,DCC_TIME_BL,BKQD_PARAM_BACK_LOW_SPEED_LENGTH);
- BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- BKQD_MotorStep = 312;
- }
- break;
- case 312:
- if(BKQD_PARAM_BL_ENABLE)
- {
- if(KK_cRealPos>BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_YD_VAVLE=1;
- }
- if(KK_cRealPos>(BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_HL_DELAY_BACK-200))
- {
- BKQD_YD_VAVLE=0;
- }
-
- }
- //勾针提前输出
- if(KK_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH ))
- BKQD_GZ_VAVLE = 1;
-
- if((KK_cRealPos) > (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*BK_length_buffer) - (BKQD_PARAM_BACK_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(BKQD_PARAM_BACK_SPEED,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_DCC)))))
- {
- BKQD_MotorDelay = dwTickCount + 3000; //钩针未到位延时警告
- BKQD_MotorStep = 313;
- }
- else if(KK_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH + 200 + (*BK_length_buffer)))//BKQD_PARAM_ERROR_LENGTH))
- {
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- break;
- case 313:
- if(BKQD_PARAM_BL_ENABLE)
- {
- if(KK_cRealPos>BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_YD_VAVLE=1;
- }
- if(KK_cRealPos>(BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_HL_DELAY_BACK-200))
- {
- BKQD_YD_VAVLE=0;
- }
-
- }
- if(KK_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH ))
- {
- BKQD_GZ_VAVLE = 1;
- // BKQD_MotorDelay = dwTickCount + 2000; //钩针未到位延时警告
- }
-
- if(BKQD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 10;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 314;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if(KK_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH+100+(*BK_length_buffer)))
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- break;
- case 314:
- if(BKQD_PARAM_BL_ENABLE)
- {
- if(KK_cRealPos>BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_YD_VAVLE=1;
- }
- if(KK_cRealPos>(BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_HL_DELAY_BACK-200))
- {
- BKQD_YD_VAVLE=0;
- }
-
- }
- if(!X_DRV && (dwTickCount >= BKQD_MotorDelay))
- {
- BKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 315;
- SetDir(X_AXIS, BKQD_DIR_N);
- BKQD_JZ_DIR = BKQD_YDIR_N;
- }
- break;
- case 315:
- if(cZipCnt == 0)
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH + (*BK_length_buffer)-120;
- kk = BKQD_PARAM_ZIPPER_LENGTH + (*BK_length_buffer)+120;
- }
- else
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH + (*BK_length_buffer)-100;
- kk = BKQD_PARAM_ZIPPER_LENGTH + (*BK_length_buffer)+100;
- }user_datas[128] = ch;
- user_datas[127] = kk;
- if(((KK_cRealPos) < (ch)))
- {
- SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM);
- if(dwTickCount >= BKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((KK_cRealPos > kk))//(BKQD_PARAM_ERROR_LENGTH - 200 + (*BK_length_buffer)+50)))
- {
- SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM);
- if(dwTickCount >= BKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
-
- BKQD_MotorStep =390;
- }
-
- break;
-
- case 330:
- back_buff = KK_cRealPos;
- gou_zhen_buff = KK_cRealPos;
- save_buff = KK_cRealPos;
- BKQD_MotorStep = 331;
- SetDir(X_AXIS, BKQD_DIR_P);
- user_datas[127] = 0;
- break;
- case 331:
- if(dwTickCount >= BKQD_MotorDelay)
- {
-
- BKQD_MotorStep = 332;
- if(cZipCnt < 2)
- {
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来BKQD_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,9000,BKQD_DIR_P,BKQD_PARAM_START_SPEED,2000,8,13);
-
- }
- else
- {
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 1; //并链起动
- //因为每条都是过链感应,所以直接运行检测模式后拉速度
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_CHECK_BACK_HSPEED,BKQD_DIR_P,BKQD_PARAM_START_SPEED,2000,BKQD_PARAM_ACC,BKQD_PARAM_DCC);
- }
- }
- break;
- case 332:
- if(cZipCnt > 1) //第三条开始数控降速
- {
- if((KK_cRealPos + BKQD_PARAM_BACK_LOW_SPEED_LENGTH + 300)>= length_buff)
- {
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
-
- BKQD_MotorStep = 334; //到检测定位
- }
-
- if(BKQD_GUO_LIAN_IN_UP) //重新到链上
- {
- BKQD_GZ_VAVLE = 1;
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
-
- gou_zhen_buff = KK_cRealPos;
- BKQD_MotorStep = 333; //到检测定位
- BKQD_MotorDelay = dwTickCount + 3;//BKQD_PARAM_DELAY_XM;
-
-
- }
-
-
-
- if(!BKQD_GZ_VAVLE && (KK_cRealPos + BKQD_PARAM_GOUZHEN_LENGTH) > (BKQD_PARAM_ZIPPER_LENGTH ))
- {
-
- BKQD_GZ_VAVLE = 1;
-
-
- }
- }
- else //第一条工作
- {
-
- if(BKQD_GUO_LIAN_IN_UP)
- {
-
- checkdelay_buff = KK_cRealPos;
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
-
- BKQD_MotorDelay = dwTickCount + 3;//BKQD_PARAM_DELAY_XM;
- BKQD_MotorStep = 333;
- }
- }
-
-
- break;
- case 333: //此步为前两条运行
-
-
-
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = KK_cRealPos;
-
- }
- if(dwTickCount >= BKQD_MotorDelay)
- {
- if(BKQD_GUO_LIAN_IN)
- {
-
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
-
- back_buff = KK_cRealPos;
- BKQD_MotorDelay = dwTickCount + 30;
- BKQD_MotorStep = 335;
- }
- }
- else
- {
- if(!BKQD_GUO_LIAN_IN)
- {
- BKQD_MotorStep = 332;
-
- }
- }
-
- break;
- case 334:
-
-
- if(BKQD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
-
- gou_zhen_buff = KK_cRealPos;
- BKQD_MotorStep = 335;
- BKQD_MotorDelay = dwTickCount + 30;
- BKQD_GZ_VAVLE = 1;
-
-
- }
- if(cZipCnt > 1) //第三条开始要长度误差
- {
- if(KK_cRealPos >= (length_buff + BKQD_PARAM_ERROR_LENGTH))
- {
- BKQD_SetAlarmCode(BKQD_LENGTH_LONG_ALARM);
- user_datas[128] = 1;
- }
- }
-
-
- break;
- case 335:
-
-
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = KK_cRealPos;
- BKQD_GZ_VAVLE = 1;
-
- }
- //在空们都把延时清零
- if(BKQD_GUO_LIAN_IN)
- {
- gou_zhen_buff = KK_cRealPos;
- }
- if(BKQD_GOUZHEN_IN)
- {
-
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 10;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 336;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else
- {
- if(cZipCnt > 1) //2 条后才有长度误差
- {
- if(KK_cRealPos >= (length_buff + 100))
- {
- AxisEgmStop(X_AXIS);
- user_datas[128] = 2;
- if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- }
- }
-
- break;
- case 336:
- if(cZipCnt > 1) //长度检测
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH;
- user_datas[127] = ch;
- if(((KK_cRealPos + BKQD_PARAM_ERROR_LENGTH) < (ch)) && BKQD_PARAM_ERROR_LENGTH)
- {
- BKQD_SetAlarmCode(BKQD_LENGTH_LONG_ALARM);
- user_datas[128] = 3;
-
- }
- else if((KK_cRealPos > (ch + BKQD_PARAM_ERROR_LENGTH)) && BKQD_PARAM_ERROR_LENGTH)//(BKQD_PARAM_ERROR_LENGTH - 200 + (*BK_length_buffer)+50)))
- {
- user_datas[128] = 4;
- BKQD_SetAlarmCode(BKQD_LENGTH_SHORT_ALARM);
-
- }
- else
- {
- BKQD_MotorStep = 337;
- }
- }
- else
- {
- if(cZipCnt == 1)
- {
- length_buff = KK_cRealPos - save_buff;
- SetData32bits(BKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- BKQD_MotorStep = 337;
- }
- break;
- case 337:
- BKQD_MotorStep = 390;
-
- // SetDir(X_AXIS, BKQD_DIR_N);
- // if(dwTickCount >= BKQD_MotorDelay)
- // {
- // AxisMovePosAccDec(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,-BKQD_PARAM_FZ_LENGTH,3000,BKQD_PARAM_ACC,BKQD_PARAM_DCC);
- // BKQD_MotorStep = 0;
- // }
- break;
- //350步到369步单感应模式
- case 350:
- back_buff = KK_cRealPos;
- gou_zhen_buff = KK_cRealPos;
- save_buff = KK_cRealPos;
- BKQD_MotorStep = 351;
- break;
-
- case 351:
- if(dwTickCount >= BKQD_MotorDelay)
- {
-
- BKQD_MotorStep = 352;
- //第一,二条都是过链感应,测量长度
- if(cZipCnt < 2)
- {
- if(BKQD_PARAM_BL_ENABLE) //因为长度未知,只能通过过链退合链
- BKQD_BinLianStep = 10; //并链起动
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,9000,BKQD_DIR_P,BKQD_PARAM_START_SPEED,2000,8,12);
-
- }
- else
- {
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 1; //并链起动
- BKQD_DGLG_VAVLE = 1; //顶过链杆关
- BKQD_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- BKQD_MotorStep = 311;
- }
- }
- break;
- case 352:
-
-
- //前两条都按最低速度工作
- if(BKQD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = KK_cRealPos;
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
-
- BKQD_MotorDelay = dwTickCount + 3;//BKQD_PARAM_DELAY_XM;
- BKQD_MotorStep = 353;
- BKQD_GZ_VAVLE = 1;
- }
-
- break;
- case 353:
-
-
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = KK_cRealPos;
-
- }
- if(dwTickCount >= BKQD_MotorDelay)
- {
- if(BKQD_GUO_LIAN_IN)
- {
-
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
-
- back_buff = KK_cRealPos;
- BKQD_MotorDelay = dwTickCount + 30;
- BKQD_MotorStep = 354;
- }
- }
- else
- {
- if(!BKQD_GUO_LIAN_IN)
- {
- BKQD_MotorStep = 352;
-
- }
- }
-
- break;
- case 354:
-
- if(BKQD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = KK_cRealPos;
- BKQD_MotorStep = 355;
- BKQD_GZ_VAVLE = 1;
- }
- }
- if(BKQD_GOUZHEN_IN)
- {
-
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 10;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 356;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- break;
- case 355:
-
- //在空们都把延时清零
- if(BKQD_GOUZHEN_IN)
- {
-
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 10;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 356;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- break;
- case 356:
- if(cZipCnt == 1)
- {
- length_buff = KK_cRealPos - save_buff;
- SetData32bits(BKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- BKQD_MotorStep = 357;
-
- break;
- case 357:
- BKQD_MotorStep = 390; //延时反转步
- break;
-
- //此两步为到位后反转步
- case 390:
- SetDir(X_AXIS, BKQD_DIR_N);
- BKQD_MotorDelay = dwTickCount + 30;
- BKQD_MotorStep = 391;
- break;
- case 391:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- SetDir(X_AXIS, BKQD_DIR_N);
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,-BKQD_PARAM_FZ_LENGTH,3000,1000,BKQD_PARAM_ACC,BKQD_PARAM_DCC,0);
- BKQD_MotorStep = 0;
- }
- break;
-
- case 801:
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK;
- SetDir(X_AXIS, BKQD_DIR_P);
- BKQD_JZ_DIR = BKQD_YDIR_P;
- SetPos(X_AXIS, 0);
- BKQD_MotorStep = 802;
- break;
- case 802:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- BKQD_MotorStep = 803;
- AxisMovePosAccDec(X_AXIS,3000,BKQD_PARAM_SHUANGDAO_LENGTH,1000,1000,25,50,0);
- }
- break;
- case 803:
- if(!X_DRV || KK_cRealPos>=BKQD_PARAM_SHUANGDAO_LENGTH)
- {
- BKQD_MotorStep = 0;
- KK_cDiErLaChu=1;
- }
- case 40:
- //切完延时后拉带松夹子
- if(BKQD_PARAM_SJZ_LENGTH == 0 || KK_cShuangDao)
- {
- SetDir(X_AXIS, BKQD_DIR_P);
- jz_buff = KK_cRealPos;
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_BACK_LENGTH,1000,1000,25,50,0);
- BKQD_MotorStep = 44;
- BKQD_JD_VAVLE = 0;
- }
- else
- {
- jz_buff = KK_cRealPos;
- SetDir(X_AXIS, BKQD_DIR_P);
- BKQD_MotorStep = 41;
- }
- break;
- case 41:
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_SJZ_LENGTH+BKQD_PARAM_BACK_LENGTH,1000,1000,25,50,0);
- BKQD_MotorStep = 42;
- break;
-
- case 42:
- if((BKQD_PARAM_SJZ_LENGTH <= (KK_cRealPos - jz_buff)) )
- {
- BKQD_JD_VAVLE = 0;
- BKQD_GZ_VAVLE=0;
- BKQD_MotorStep = 44;
- }
- break;
-
- case 44: // 切断完成后拉电机动作
- if(((BKQD_PARAM_SJZ_LENGTH+BKQD_PARAM_BACK_LENGTH) <= (KK_cRealPos - jz_buff)) ||!X_DRV)
- {
- AxisEgmStop(X_AXIS);
- if(!KK_cECQ_STOP)
- BKQD_MotorStep = 0;
- else
- {
- cStopMode=2;
- bStop=1;
-
- }
- BKQD_GZ_VAVLE=0;
- BKQD_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- if(!KK_cDiErLaChu)
- {
- if(BKQD_SZ_OUT)
- {
- BKQD_SZ_OUT = 0;
- BKQD_MotorDelay = dwTickCount + 150;
- SetPos(X_AXIS, 0);
- }
- else
- BKQD_MotorDelay = dwTickCount;
- BKQD_BL_VAVLE = 0;//并链也要打开
- SetDir(X_AXIS,BKQD_DIR_N);
-
- BKQD_JZ_DIR = BKQD_YDIR_N;
- if(!BKQD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- if(!BKQD_SHANG_MU_LIMIT_IN && (BKQD_TuiLianStep == 0))
- {
- BKQD_TuiLianStep = 1;
- BKQD_MotorStep = 62;
- }
- }
- else
- BKQD_MotorStep = 62;
- }
- else
- {
- if(BKQD_SHANG_MU_ORIGIN_IN)
- {
- KK_cDiErLaChu=0;
- BKQD_MotorStep = 65;
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,1000,15,15);
- }
- }
- break;
- case 62:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- if(BKQD_QIAN_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- SetDir(X_AXIS,BKQD_DIR_N);
-
- BKQD_JZ_DIR = BKQD_YDIR_P;
- //前点亮的情况下先退出
- AxisMovePos(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,1000);
- BKQD_MotorDelay = dwTickCount + 300;
- }
- BKQD_MotorStep = 63;
- BKQD_JD_VAVLE = 0;
- }
- break;
- case 63:
- if(!X_DRV && !BKQD_QIAN_LIMIT_IN && (dwTickCount >= BKQD_MotorDelay))// && !BKQD_SHANG_MU_LIMIT_IN)
- {
-
- SetDir(X_AXIS, BKQD_DIR_N);
- BKQD_JZ_DIR = BKQD_YDIR_N;
- go_buff = KK_cRealPos;
- BKQD_YD_VAVLE = 1;
- BKQD_HL_VAVLE = 1;
- BKQD_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(cZipCnt > 0)
- {
-
- if(KK_cRealPos>(BKQD_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- DCC_TIME_BL=BKQD_PARAM_GO_HIGH_SPEED/500;
- AxisMovePosAccDecNotStop(X_AXIS,BKQD_PARAM_GO_HIGH_SPEED,-BK_cRealPos,
- BKQD_PARAM_START_SPEED,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_ACC,DCC_TIME_BL,
- BKQD_PARAM_GO_LOW_SPEED_LENGTH);
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,1000,15,15);
-
- // MoveAction_Const_AccDec(X_AXIS, BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED_LENGTH,BKQD_PARAM_START_SPEED,BKQD_PARAM_ACC,BKQD_PARAM_DCC);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,1000,15,15);
- // MoveAction_Const_AccDec(X_AXIS, BKQD_DIR_N,BKQD_PARAM_FIRST_GO_HIGHSPEED,BKQD_PARAM_START_SPEED,BKQD_PARAM_ACC,BKQD_PARAM_DCC);//
- }
-
- BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- BKQD_MotorStep =64;
- }
-
- break;
- case 64:
-
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((KK_cRealPos) < (BKQD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (BKQD_QIAN_DEC_IN))
- {
- user_datas[126]= GetCurSpeed(X_AXIS);
- // MoveChangSpeedDec(X_AXIS,BKQD_PARAM_GO_HIGH_SPEED*2/3,6,8);
- // AxisChangeSpeed(X_AXIS,40);
- BKQD_MotorStep =65;
- }
- if(BKQD_QIAN_LIMIT_IN) //前点限位
- {
- BKQD_TFK_VAVLE=0;
- AxisEgmStop(X_AXIS);
- BKQD_MotorStep = 66;
- }
- }
- else
- {
- if(BKQD_QIAN_LIMIT_IN) //前点限位
- {
- BKQD_TFK_VAVLE=0;
- AxisEgmStop(X_AXIS);
- BKQD_MotorStep = 66;
- }
- }
-
- break;
- case 65:
-
- if(BKQD_QIAN_LIMIT_IN)
- {
- BKQD_TFK_VAVLE=0;
- AxisEgmStop(X_AXIS);
- BKQD_MotorStep = 66;
-
- }
- else if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_NO_ZIPPER_ALARM);
-
- break;
- case 66:
-
- if(!X_DRV)
- {
- BKQD_TFK_VAVLE=0;
- SetPos(X_AXIS, 0);
- BKQD_MotorDelay = dwTickCount;
- BKQD_MotorStep = 67;
- }
- break;
- case 67: //等推链完成后,
- if((dwTickCount >= BKQD_MotorDelay) && (BKQD_TuiLianStep == 0) && ((BKQD_PARAM_TIAOSHI_MODE && BKQD_bTS) || (BKQD_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- BKQD_JD_VAVLE = 1;
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK;
- }
- BKQD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- BKQD_YD_VAVLE = 0;
- BKQD_HL_VAVLE = 0;
- BKQD_YX_VAVLE = 0;
- BKQD_CHUIQIStep=1;
- BKQD_TL_VAVLE = 0;
- BKQD_MotorStep = 0;
- BKQD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- }
- //电机动作
- void BK_QueDuan_Motor(void)
- {
- BK_QueDuan_Motor_NoGL();
-
-
- }
- void BK_QueDuan_TuiLianAction(void)
- {
- if(BKQD_PARAM_XM_ENABLE == 0)
- {
- BKQD_TuiLianStep = 0;
- }
- else
- {
- switch(BKQD_TuiLianStep)
- {
- case 1:
- BKQD_TuiLianStep = 2;
- break;
- case 2:
- BKQD_TLDelay = dwTickCount + BKQD_PARAM_YD_DELAY;
- BKQD_TuiLianStep = 3;
- break;
- case 3:
- if(!BKQD_SM_VAVLE && !BKQD_SHANG_MU_LIMIT_IN)//dwTickCount >= BKQD_TLDelay)
- {
- BKQD_TL_VAVLE = 1;
- // BKQD_TFK_VAVLE = 0;
- // if(!bRunning)BKQD_TFK_VAVLE = 1;
-
- BKQD_TLDelay = dwTickCount + BKQD_PARAM_TL_DELAY;
- BKQD_TuiLianStep = 4;
- }
- break;
- case 4:
- if(dwTickCount >= BKQD_TLDelay)
- {
- BKQD_TuiLianStep = 0;
-
- }
- break;
- case 10:
-
- BKQD_TuiLianStep = 11;
- break;
- case 11:
- if(!Y_DRV)
- {
- {
- BKQD_TuiLianStep = 0;
- }
- }
- break;
- }
- }
- }
- //闭口专用
- void BK_QueDuan_XiaQue_NO_GL(void)
- {
- switch(BKQD_XiaQieStep)
- {
- case 0:
- break;
- case 1:
- if(!bRunning)
- {
- // BKQD_GZ_VAVLE = 1; //勾针
-
- // BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CUT_DELAY;
- // BKQD_XiaQieStep = 100;
- BKQD_YD_VAVLE = 1;
- BKQD_XiaQieStep = 2;
- BKQD_XiaQieDelay = dwTickCount + 30;
-
- }
- else
- {
- BKQD_YD_VAVLE = 1;
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CUT_DELAY;
- BKQD_XiaQieStep = 2;
- }
- break;
- case 2:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
- BKQD_XiaQieStep = 3;
- BKQD_XiaQieDelay = dwTickCount;
- }
- break;
- case 3:
- if(dwTickCount >= BKQD_XiaQieDelay )
- {
-
- if(BKQD_SHANG_MU_ORIGIN_IN)
- {
- if((BKQD_PARAM_TIAOSHI_MODE && BKQD_bTS) || (BKQD_PARAM_TIAOSHI_MODE == 0))
- {
- BKQD_SM_VAVLE = 1;
- if(!BKQD_PARAM_XM_ENABLE)
- BKQD_XM_VAVLE = 1;
- BKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- BKQD_XiaQieStep = 4;
- }
- }
- else if(dwTickCount >= (BKQD_XiaQieDelay+3000))
- {
- BKQD_SetAlarmCode(BKQD_SM_YUANWEI);
- }
-
- }
-
- break;
- case 4://永兴为下模固定
- if(BKQD_SHANG_MU_LIMIT_IN && (BKQD_XIA_MU_LIMIT_IN || BKQD_PARAM_XM_ENABLE))
- {
- BKQD_GZ_VAVLE = 0;
- if(!BKQD_PARAM_CS_MODE) //气切
- {
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_DELAYBACK_SM; //
- BKQD_XiaQieStep = 5;
- }
- else
- {
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_DELAY_CS; //
- BKQD_XiaQieStep = 10;
- } //
- }
- else if(dwTickCount >= BKQD_XiaQieDelay)
- BKQD_SetAlarmCode(BKQD_SM_DAOWEI);
- break;
- case 5:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
-
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- BKQD_XiaQieStep = 6;
- }
- break;
- case 6:
- if(!BKQD_SHANG_MU_LIMIT_IN && (!BKQD_XIA_MU_LIMIT_IN || BKQD_PARAM_XM_ENABLE)) //下模不动就不用判断
- {
- if(BKQD_TuiLianStep == 0)
- BKQD_TuiLianStep = 1;
- if(!bRunning)
- BKQD_JD_VAVLE = 0;
- if(BKQD_PARAM_SHUANGDAO_MODE)
- {
- if(!BK_cShuangDao)
- BK_cShuangDao=1;
- else
- BK_cShuangDao=0;
- }
-
- BKQD_XiaQieStep = 0;
-
- }
- else if(dwTickCount >= BKQD_XiaQieDelay)
- {
- BKQD_SetAlarmCode(BKQD_SM_YUANWEI);
- }
-
- break;
- //10~11步为超声
- case 10:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
- if(BKQD_PARAM_CS_ENABLE)BKQD_CS_OUT = 1;
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CS_TIME; //
- BKQD_XiaQieStep = 11;
- }
- break;
- case 11:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
- BKQD_CS_OUT = 0;
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CS_COLD_TIME; //
- BKQD_XiaQieStep = 5;
- }
- break;
-
-
- case 201:
- BKQD_XiaQieStep = 3;
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_CUT_DELAY;
- break;
-
-
- case 100:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
-
- //这是双开程序,暂时不考虑
- #if 1
- if(BKQD_GOUZHEN_IN)
- {
- BKQD_YD_VAVLE = 1;
- BKQD_XiaQieStep = 3;
- }
- #endif
- }
- break;
- }
- }
- //切断动作
- void BK_QueDuan_XiaQue(void)
- {
- BK_QueDuan_XiaQue_NO_GL();
- }
-
- #endif
|