1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474 |
- #include "global.h"
- #if JIN_HONG_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 BKQD_TuiDaiAction(void);
- void BK_StopCode(void);
- void BK_Motor_SZ(unsigned char En);
- short *BK_length_buffer;
- void BK_QueDuan_ExtiActionX31(void)
- {
- BK_cCheckLianFlg = 1;
- }
- void BKQD_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(BKQD_ALARM_ADDR,alarm_code);
- bAlarmStop = 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 || (dwXRealPos < 10))
- {
- BKQD_StopCodeDelay=dwTickCount+350;
- BKQD_StopStep = 3;
- }
- break;
- case 3:
- if(dwTickCount >= BKQD_StopCodeDelay)
- {
- // if(!cSTOPONE)
- {
- BKQD_StopStep=0;
- }
- // else
- // {
- // QD_SetAlarmCode(QD_PARAM_ANQUANMEN_ALARM);
- // BKQD_StopStep=0;
- // cSTOPONE=0;
- // }
- BK_Motor_SZ(BKQD_MOTOR_DIS); //电机松轴
- }
- break;
- }
- }
- //电机松轴
- void BK_Motor_SZ(unsigned char En)
- {
- if(En) //使能
- {
- if(BKQD_PARAM_MOTOR_SELECT)
- BKQD_SZ_OUT = 1; //伺服电机
- else
- BKQD_SZ_OUT = 0; //步进电机
- }
- else //松轴
- {
- if(BKQD_PARAM_MOTOR_SELECT)
- BKQD_SZ_OUT = 0; //伺服电机
- else
- BKQD_SZ_OUT = 1; //步进电机
- }
- }
- 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;
- if(BKQD_PARAM_KAIBEE_SELECT > 1)
- BKQD_PARAM_KAIBEE_SELECT = 1;
- BK_Motor_SZ(BKQD_MOTOR_DIS); //电机松轴
- SetDirReverse(X_AXIS, 0);
- axis_set_parameter(axis_x, AXIS_ACCDEC_MODE,0);
-
-
- }
- void BK_QueDuan_Action(void)
- {
- BK_QueDuan_AlarmProtect();
- BK_StopCode();
- BK_QueDuan_Motor();
- BK_QueDuan_XiaQue();
- BK_QueDuan_ManualAction();
- BK_QueDuan_TuiLianAction();
- BK_QueDuan_BingLian();
- BK_QueDuan_AutoAction();
-
- BK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
- }
- //手动动作
- void BK_QueDuan_ManualAction(void)
- {
- if(bRunning == 0)
- {
- BK_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;
- BK_cZipCnt = 0;
- BK_Motor_SZ(BKQD_MOTOR_EN); //电机锁轴
- BKQD_MotorDelay = dwTickCount + 150;
- }
- }
-
- 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_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;
- if(BKQD_XM_VAVLE)
- {
- BKQD_XM_VAVLE = 0;
- }
- else
- {
- BKQD_XM_VAVLE = 1;
- }
- }
-
- if(BKQD_bSM)
- {
- BKQD_bSM = 0;
- if(BKQD_SM_VAVLE)
- BKQD_SM_VAVLE = 0;
- else if(!BKQD_TL_VAVLE)
- 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_BL_VAVLE = ~BKQD_BL_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)
- {
- BK_Motor_SZ(BKQD_MOTOR_EN); //电机锁轴
- BKQD_STOPINDelay = dwTickCount;
- 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) //后退限位已经取消
- {
- BK_Motor_SZ(BKQD_MOTOR_EN); //电机锁轴
- BKQD_STOPINDelay = dwTickCount;
- 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) && (dwTickCount >= BKQD_STOPINDelay))
- {
- if(X_DRV) AxisEgmStop(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)
- {
- dwXRealPos = GetPos(X_AXIS);
- if(!bRunning)
- {
- ;
- }
- else
- {
- if(BKQD_PARAM_RUN_LENGTH < 5000)
- BKQD_PARAM_RUN_LENGTH= 5000;
- if((dwXRealPos > BKQD_PARAM_RUN_LENGTH) && (BK_cGoLimitEn != 0)) //第一条手动时不保护
- {
- BKQD_StopStep = 1;
- BK_cGoLimitEn = 0;
- bStop = 1;
- // AxisEgmStop(X_AXIS);
- BKQD_JD_VAVLE = 0;
- BKQD_SetAlarmCode(BKQD_BACK_ALARM);
- }
- }
- }
- void BK_QueDuan_AutoAction(void)
- {
- if(bRunning)
- {//台面电机定时关掉
- 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; //前点定位
- }
- BK_cGoLimitEn = 0;
- }
- break;
- case 2:
- if(BKQD_MotorStep == 0)
- {
- BKQD_MotorStep = 30;
- BKQD_AutoStep = 3;
- BK_cGoLimitEn = 1;
- }
- break;
- case 3: //后面两步为延时反转步
- if((BKQD_MotorStep == 0))
- {
- if(BKQD_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
- BK_XiaQueOver = 0;
- if(BKQD_XiaQieStep == 0)
- BKQD_XiaQieStep = 1;
- BKQD_AutoStep = 4;
- }
- }
- break;
- case 4:
-
- // if((BKQD_MACHINE_TYPE == BKQD_NO_GL_TUIFANGKUAI) || (BKQD_MACHINE_TYPE == BKQD_CS_TUIFANGKUAI))
- // {
- //
- if((BKQD_XiaQieStep == 0) || (BK_XiaQueOver != 0))// && !BKQD_SHANG_MU_LIMIT_IN)
- {
-
- if(BKQD_MotorStep == 0)
- {
- BKQD_MotorStep = 40; //切完后退
-
- }
- BKQD_AutoStep = 5;
- }
- /*
- // }
- // else
- // {
- if(((BKQD_XiaQieStep == 0) || (BKQD_XiaQieStep == 13)) && !BKQD_SHANG_MU_LIMIT_IN && !BKQD_XIA_MU_LIMIT_IN)
- {
- if(BKQD_MotorStep == 0)
- {
- BKQD_MotorStep = 40; //切完后退
- BKQD_AutoStep = 5;
- }
- }
- }
- */
- break;
- case 5:
- if(BKQD_MotorStep == 0)
- {
- BK_XiaQueOver = 0;
- BK_cZipCnt++;
- BKQD_PARAM_NOW_CNT++;
- BK_cTableCnt++;
- AddToTal(BKQD_TOTAL_ADDR);
- AddToTal(CT_WORKTOTAL_ADDR);
- CalProSP(BKQD_PROSPEED_ADDR);
-
- if(BK_cTableCnt >= BKQD_PARAM_TABLE_NUM)
- {
- BK_cTableCnt = 0;
- BKQD_TABLE_VAVLE = 1;
- BKQD_TBDelay = dwTickCount + BKQD_PARAM_TB_TIME;
- }
-
- if(/*(GetTotal(BKQD_TOTAL_ADDR) >= BKQD_PARAM_SET_TOTAL) ||*/BK_QDSingOneFlg)
- {
-
- bRunning = 0;
- BKQD_AutoStep = 0;
- BK_QDSingOneFlg = 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;
- if(BKQD_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- BKQD_AutoStep = 0;
- BK_QDSingOneFlg = 0;
- BKQD_SetAlarmCode(BKQD_TOTAL_ALARM);
- BKQD_TABLE_VAVLE = 0;
- }
- }
- else
- BKQD_AutoDelay = dwTickCount + BKQD_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- void BK_QueDuan_StepCheckStart(void)
- {
- // 启动
- if((BKQD_START_IN_UP) || bStart || BKQD_bSingle)
- {
- bStart = 0;
- if(!bRunning && (BKQD_AutoStep == 0))
- {
- if((BKQD_XIA_MU_LIMIT_IN|| BKQD_KAIKUO_XIAMO_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_bSingle)
- BK_QDSingOneFlg= 0;
- BK_cZipCnt = 0;
- BK_cTuiFangKuaiCnt = 0;
- BKQD_BL_VAVLE = 0; //并链关
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- BK_Motor_SZ(BKQD_MOTOR_EN); //电机锁轴
- BKQD_AutoDelay = dwTickCount + 150;
- }
- }
- BKQD_bSingle = 0;
- }
- //停止
- if((BKQD_STOP_IN_UP && (dwTickCount >= BKQD_STOPINDelay)) || bStop)
- {
- bStop = 0;
- BKQD_STOPINDelay = dwTickCount + 100;
- if(bRunning)
- {
- BKQD_AutoDelay = dwTickCount;
- BKQD_MotorDelay = dwTickCount;
- BKQD_XiaQieDelay = dwTickCount;
- BKQD_KaDaiDelay = dwTickCount;
- BKQD_CSDelay = dwTickCount;
- BKQD_TBDelay = dwTickCount;
- BKQD_TFKDelay = dwTickCount;
- BKQD_TLDelay = dwTickCount;
- BK_QDSingOneFlg = 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_GZ_VAVLE = 0;
- BKQD_TABLE_VAVLE = 0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- if((BKQD_StopStep == 0) && X_DRV)
- BKQD_StopStep = 1;
- // AxisDecStop(X_AXIS);
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- user_datas[121] = 0;
- user_datas[122] = 0;
-
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- }
- else
- {
- 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;
- BK_QDSingOneFlg = 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_DGLG_VAVLE = 0; //顶过链杆关
- BKQD_GZ_VAVLE = 0;
- BKQD_CS_OUT = 0;
- BKQD_XiaQieStep = 0;
- BKQD_MotorStep = 0;
- BKQD_TuiLianStep = 0;
- BKQD_TABLE_VAVLE = 0;
-
- // BK_Motor_SZ(BKQD_MOTOR_DIS); //电机松轴
-
- if((BKQD_StopStep == 0))
- {
- AxisEgmStop(X_AXIS);
- BK_Motor_SZ(BKQD_MOTOR_DIS); //电机松轴
- }
- // AxisEgmStop(X_AXIS);
-
- 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;
- BK_QDSingOneFlg = 0;
- bRunning = 0;
- if(X_DRV)
- BKQD_StopStep=1;
- // AxisEgmStop(X_AXIS);
- dwTickCount = BKQD_TBDelay;
- BKQD_TABLE_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 = dwXRealPos;
- BK_dwSaveLength = 0;
- BKQD_CheckLengthStep = 2;
- break;
- case 2:
- if(BKQD_GUO_LIAN_IN_DW){
- BK_dwSaveLength = dwXRealPos - start_dist;
- }
- break;
- }
- }
- void BK_QueDuan_BingLian(void)
- {
- static long bl_pos_buff,HL_delay;
-
- switch(BKQD_BinLianStep)
- {
- case 0:break;
- case 1:
- bl_pos_buff = dwXRealPos;
- BKQD_BinLianStep = 2;
- break;
- case 2:
- if((dwXRealPos - bl_pos_buff) >= BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_BL_VAVLE = 1;
- BKQD_BinLianStep = 3;
- }
- break;
- case 3://有过链检测
- if(BKQD_GUO_LIAN_IN_DW || ((dwXRealPos - bl_pos_buff) >= (BKQD_PARAM_ZIPPER_LENGTH - BKQD_PARAM_HL_DELAY_BACK)))
- {
- BKQD_BL_VAVLE = 0;
- BKQD_BinLianStep = 0;
- }
- break;
- case 10:
- bl_pos_buff = dwXRealPos;
- BKQD_BinLianStep = 11;
- break;
- case 11:
- if((dwXRealPos - 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,go_buff,checkdelay_buff,dandao_buff,gouzhen_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] = dwXRealPos;
- // user_datas[124] = dwXRealPos;
- 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;
- //310步到315步为数控模式
- case 310:
- BKQD_MotorStep = 311;
- // BKQD_JZ_DIR = BKQD_YDIR_P;
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 1; //并链起动
- break;
- case 311:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- BK_length_buffer = &BKQD_PARAM_OFFSET_LENGTH;
-
- // 轴 第一段速度 第一段长度要减去送链长度 第二段速度 第二段长度 方向
- BK_DCC_TIME_BL= BKQD_PARAM_DCC + 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,BK_DCC_TIME_BL,BKQD_PARAM_BACK_LOW_SPEED_LENGTH);
- gou_zhen_buff = dwXRealPos;
- save_buff = dwXRealPos;
- BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- BKQD_MotorStep = 312;
- }
- break;
- case 312:
- if(dwXRealPos >= 10)
- BKQD_TL_VAVLE = 0;
- //勾针提前输出
- if (!BKQD_GZ_VAVLE && ((dwXRealPos + BKQD_PARAM_GOUZHEN_LENGTH+BKQD_PARAM_TL_LENGTH) >= (BKQD_PARAM_ZIPPER_LENGTH )))
- {
- BKQD_GZ_VAVLE = 1;
- }
- if((dwXRealPos) >= (BKQD_PARAM_ZIPPER_LENGTH + (*BK_length_buffer) - 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 + 2000; //钩针未到位延时警告
- BKQD_MotorStep = 313;
- }//下面条件为无效代码
- else if((dwXRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_TL_LENGTH + (*BK_length_buffer) + BKQD_PARAM_ERROR_LENGTH)) && BKQD_PARAM_ERROR_LENGTH)
- {
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
-
- break;
- case 313:
- if(!BKQD_GZ_VAVLE && (dwXRealPos + BKQD_PARAM_GOUZHEN_LENGTH + BKQD_PARAM_TL_LENGTH) > (BKQD_PARAM_ZIPPER_LENGTH ))
- {
- BKQD_GZ_VAVLE = 1;
- }
- if(BKQD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 0;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 314;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if((dwXRealPos >= (BKQD_PARAM_ZIPPER_LENGTH - BKQD_PARAM_TL_LENGTH + (*BK_length_buffer) + BKQD_PARAM_ERROR_LENGTH)) && BKQD_PARAM_ERROR_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- break;
-
- case 314:
- if(!X_DRV && (dwTickCount >= BKQD_MotorDelay))
- {
- BKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- BKQD_YD_VAVLE = 1;//压带
-
- BKQD_MotorStep = 315;
- }
- break;
- case 315:
- if(!BKQD_PARAM_WC_LENGTH)
- {
- BKQD_PARAM_WC_LENGTH=100;
- }
- if(BK_cZipCnt == 0) //第一条把误差到正负9MM
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH -BKQD_PARAM_TL_LENGTH + (*BK_length_buffer)-BKQD_PARAM_WC_LENGTH;
- kk = BKQD_PARAM_ZIPPER_LENGTH -BKQD_PARAM_TL_LENGTH + (*BK_length_buffer)+BKQD_PARAM_WC_LENGTH;
- }
- else
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH -BKQD_PARAM_TL_LENGTH + (*BK_length_buffer)-BKQD_PARAM_WC_LENGTH;
- kk = BKQD_PARAM_ZIPPER_LENGTH -BKQD_PARAM_TL_LENGTH + (*BK_length_buffer)+BKQD_PARAM_WC_LENGTH;
- }
- if(((dwXRealPos) < (ch)))
- {
-
- SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_SHORT_ALARM);
- if(dwTickCount >= BKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((dwXRealPos > 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 = 0;//390; //延时反转步
- }
- break;
- //330步到349步单感应模式
- case 330:
- gou_zhen_buff = dwXRealPos;
- save_buff = dwXRealPos;
- BKQD_MotorStep = 331;
- SetDir(X_AXIS, BKQD_DIR_P);
-
- break;
- case 331:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- BKQD_MotorStep = 332;
- if(BK_cZipCnt < 2)
- {
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来BKQD_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,3000,BKQD_DIR_P,BKQD_PARAM_START_SPEED/2,BKQD_PARAM_START_SPEED/2,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,BKQD_PARAM_START_SPEED,BKQD_PARAM_ACC,BKQD_PARAM_DCC);
- }
- }
- break;
- case 332:
- if(dwXRealPos >= 10)
- BKQD_TL_VAVLE = 0;
- if(dwXRealPos >250)
- {
-
-
- if(BKQD_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = dwXRealPos;
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
- BKQD_MotorDelay = dwTickCount + 16;//BKQD_PARAM_DELAY_XM;
- BKQD_MotorStep = 333;
- }
-
-
- }
- break;
- case 333: //此步为前两条运行
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = dwXRealPos;
- BKQD_MotorStep = 335;
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_GYMODE_DEALY;
-
- }
- break;
- case 334:
- if(BKQD_GUO_LIAN_IN_DW) //下降沿,定位长度
- {
- gou_zhen_buff = dwXRealPos;
- BKQD_MotorStep = 335;
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_GYMODE_DEALY;
- }
- if(BK_cZipCnt > 1) //第三条开始要长度误差
- {
- if(dwXRealPos >= (length_buff + BKQD_PARAM_ERROR_LENGTH))
- {
- BKQD_SetAlarmCode(BKQD_LENGTH_LONG_ALARM);
-
- }
- }
- break;
- case 335:
- if(dwTickCount >= BKQD_MotorDelay)
- {
-
- BKQD_GZ_VAVLE = 1;
- }
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = dwXRealPos;
-
- }
- //在空们都把延时清零
- if(BKQD_GUO_LIAN_IN)
- {
- gou_zhen_buff = dwXRealPos;
- }
- if(BKQD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 10;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 336;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else
- {
- if(BK_cZipCnt > 1) //2 条后才有长度误差
- {
- if(dwXRealPos >= (length_buff + BKQD_PARAM_ERROR_LENGTH))
- {
- AxisEgmStop(X_AXIS);
-
- if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- }
- }
- break;
- case 336:
- if(BK_cZipCnt > 1) //长度检测
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH;
-
- if(((dwXRealPos + BKQD_PARAM_ERROR_LENGTH) < (ch)) && BKQD_PARAM_ERROR_LENGTH)
- {
- SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM);
-
- if(dwTickCount >= BKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((dwXRealPos > (ch + BKQD_PARAM_ERROR_LENGTH)) && BKQD_PARAM_ERROR_LENGTH)//(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 = 337;
- }
- }
- else
- {
- if(BK_cZipCnt == 1)
- {
- length_buff = dwXRealPos - save_buff +BKQD_PARAM_TL_LENGTH;
- SetData32bits(BKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- BKQD_MotorStep = 337;
- }
- break;
- case 337:
- BKQD_MotorStep = 0;//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:
- gou_zhen_buff = dwXRealPos;
- BKQD_MotorStep = 351;
-
-
- break;
- case 351:
- if(dwTickCount >= BKQD_MotorDelay)
- {
-
- if(BK_cZipCnt < 2)
- {
- BKQD_MotorStep = 352;
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 10; //并链起动
- //第一条都是过链感应,后拉速度减半//原来BKQD_PARAM_CHECK_BACK_HSPEED/2
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,3000,BKQD_DIR_P,BKQD_PARAM_START_SPEED/2,BKQD_PARAM_START_SPEED/2,8,13);
-
-
- }
- else
- {
- if(BKQD_PARAM_BL_ENABLE)
- BKQD_BinLianStep = 1; //并链起动
- BKQD_DGLG_VAVLE = 1; //顶过链杆关
- BKQD_CheckLengthStep = 1; //长度检测,第3条才有对比
- //走数控方式,因第二条中已经测量出来拉链长度,可以直接按长度数控方式走
- BKQD_MotorStep = 311;
- }
- }
- break;
- case 352:
- if(dwXRealPos >= 10)
- BKQD_TL_VAVLE = 0;
-
-
-
- if(BKQD_GUO_LIAN_IN_DW)
- {
- checkdelay_buff = dwXRealPos;
- AxisContinueMoveChangeSpeed(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED/2,25,15);
- // BKQD_MotorDelay = dwTickCount + 16;//BKQD_PARAM_DELAY_XM;
- gou_zhen_buff = dwXRealPos;
- BKQD_MotorStep = 355;
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_GYMODE_DEALY;
- }
-
-
-
- break;
-
-
- case 355:
- if(dwTickCount >= BKQD_MotorDelay)
- {
-
- BKQD_GZ_VAVLE = 1;
- }
- if(BKQD_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = dwXRealPos;
-
- }
- //在空们都把延时清零
- if(BKQD_GUO_LIAN_IN)
- {
- gou_zhen_buff = dwXRealPos;
- }
- if(BKQD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 10;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 336;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- break;
- case 356:
- if(BK_cZipCnt == 1)
- {
- length_buff = dwXRealPos + BKQD_PARAM_TL_LENGTH;
- SetData32bits(BKQD_PARAM_ZIPPER_LENGTH_ADDR,length_buff); //测量记录长度
- }
- BKQD_MotorStep = 337;
- break;
- case 357:
- BKQD_MotorStep = 0;//390;
- break;
-
-
-
-
-
- //此两步为到位后反转步
- case 390:
- BKQD_MotorDelay = dwTickCount + 30;
- BKQD_MotorStep = 391;
- break;
- case 391:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,-BKQD_PARAM_FZ_LENGTH,3000,3000,BKQD_PARAM_ACC,BKQD_PARAM_DCC,00);
- BKQD_MotorStep = 0;
- }
- break;
-
- case 40:
- //切完延时后拉带松夹子
- if(BKQD_PARAM_SJZ_LENGTH == 0)
- {
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_CUT_BACK_DELAY;
- BKQD_MotorStep = 43;
- BKQD_JD_VAVLE = 0;
-
- }
- else
- {
- jz_buff = dwXRealPos;
- BKQD_MotorStep = 41;
-
- }
- break;
-
-
- case 41:
- BKQD_GZ_VAVLE=0;
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_SJZ_LENGTH + BKQD_PARAM_BACK_LENGTH,2500,2000,25,25,40);
- BKQD_MotorStep = 42;
- break;
- case 42:
- if(BKQD_PARAM_SJZ_LENGTH <= (dwXRealPos - jz_buff))
- BKQD_JD_VAVLE = 0;
- if(!X_DRV)
- {
- BKQD_MotorStep = 0;
- }
- break;
-
- case 43:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- BKQD_GZ_VAVLE=0; //延时退勾针有助于切断带丝情况
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_BACK_LENGTH,2500,2000,15,15,30);
- BKQD_MotorStep = 44;
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- BKQD_MotorStep = 0;
-
- BKQD_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- BKQD_BL_VAVLE = 0;//并链也要打开
- if(dwTickCount >= BKQD_MotorDelay)
- {
- // BKQD_JZ_DIR = BKQD_YDIR_N;
- if(!BKQD_TL_VAVLE && BK_cZipCnt && (BKQD_TuiLianStep == 0)) //没送链情况下主动送链
- {
- if(!BKQD_SHANG_MU_LIMIT_IN)
- {
- BKQD_TuiLianStep = 1;
- BKQD_MotorStep = 62;
- }
- }
- else
- BKQD_MotorStep = 62;
- }
- break;
- case 62:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- if(BKQD_QIAN_LIMIT_IN)
- {
- //前点亮的情况下先后退离开信号后再前进定位 ,10公分
- AxisMovePosAccDec(X_AXIS,3000,1000,2000,2000,10,10,30);
- 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)
- {
- BKQD_YD_VAVLE = 1;
- // BKQD_HL_VAVLE = 1;
- // BKQD_YX_VAVLE = 1;
- //李永庆代码,当位置在慢速之外,走数控到慢速点
- if(BK_cZipCnt > 0)
- {
- if(dwXRealPos>(BKQD_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
- BK_DCC_TIME_BL= BKQD_PARAM_DCC + BKQD_PARAM_GO_HIGH_SPEED/500;
- AxisMovePosAccDecNotStop(X_AXIS,BKQD_PARAM_GO_HIGH_SPEED,-dwXRealPos,
- BKQD_PARAM_START_SPEED,BKQD_PARAM_GO_LOW_SPEED,BKQD_PARAM_ACC,BK_DCC_TIME_BL,
- BKQD_PARAM_GO_LOW_SPEED_LENGTH + BKQD_PARAM_GO_DW_LENGTH);
- }
- else
- {
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,BKQD_PARAM_GO_LOW_SPEED,15,15);
-
- }
- }
- else
- {
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,BKQD_PARAM_GO_LOW_SPEED,15,15);
- }
-
- BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- BKQD_MotorStep =64;
- }
-
- break;
- case 64:
- if(BK_cZipCnt > 1)
- {
-
- if(BKQD_QIAN_LIMIT_IN) //前点限位
- {
- if(BKQD_PARAM_GO_DW_LENGTH)
- {
- SetPos(X_AXIS, BKQD_PARAM_GO_DW_LENGTH);
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,-BKQD_PARAM_GO_DW_LENGTH,1200,1000,5,5,00);
- }
- else
- AxisEgmStop(X_AXIS);
- BKQD_MotorStep = 66;
- }
- }
- else
- {
- if(BKQD_QIAN_LIMIT_IN) //前点限位
- {
- if(BKQD_PARAM_GO_DW_LENGTH)
- {
- SetPos(X_AXIS, BKQD_PARAM_GO_DW_LENGTH);
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,-BKQD_PARAM_GO_DW_LENGTH,1200,1000,5,5,00);
- }
- else
- AxisEgmStop(X_AXIS);
- BKQD_MotorStep = 66;
- }
- }
- break;
- case 66:
- if(!X_DRV || (dwXRealPos <= 0))
- {
- SetPos(X_AXIS, 0);
- BKQD_MotorDelay = dwTickCount + 5;
- 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*3/5;
- }
- BKQD_MotorStep = 68;
- }
- break;
- case 68:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- BKQD_YD_VAVLE = 0;
- BKQD_MotorStep = 69;
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK*2/5;
- }
- break;
-
- case 69:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- 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;
- if(!bRunning)BKQD_TFK_VAVLE = 0;
- 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_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;
- if(bRunning)
- BKQD_MotorStep = 390; //延时反转步
- }
- break;
- case 3:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
- if((BKQD_PARAM_TIAOSHI_MODE && BKQD_bTS) || (BKQD_PARAM_TIAOSHI_MODE == 0))
- {
- BKQD_SM_VAVLE = 1;
- BKQD_XM_VAVLE = 1;
- BKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- BKQD_XiaQieStep = 4;
- BKQD_CheckTime = dwTickCount;
- }
- }
- break;
- case 4:
- if(BKQD_SHANG_MU_ORIGIN_DW)
- user_datas[124] = dwTickCount - BKQD_CheckTime;
- if(BKQD_SHANG_MU_LIMIT_IN_UP)
- user_datas[125] = dwTickCount - BKQD_CheckTime;
-
-
-
- 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 *3/5; //
- BKQD_XiaQieStep = 10;
- } //
- }
- else if(dwTickCount >= BKQD_XiaQieDelay)
- {
- if(!BKQD_SHANG_MU_LIMIT_IN)
- BKQD_SetAlarmCode(BKQD_SM_DAOWEI);
- else
- BKQD_SetAlarmCode(BKQD_XM_DAOWEI);
- }
- break;
- case 5:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
- BKQD_XiaQieDelay = dwTickCount + BKQD_PARAM_DELAY_CS *2/5;
- BKQD_XiaQieStep = 6;
- BK_XiaQueOver = 1;
- }
- break;
- case 6:
- if(dwTickCount >= BKQD_XiaQieDelay)
- {
- BK_XiaQueOver = 1;
- BKQD_SM_VAVLE = 0;
- BKQD_XM_VAVLE = 0;
- BKQD_XiaQieDelay = dwTickCount + VAVLE_ALARM_TIME; //
- BKQD_XiaQieStep = 7;
- }
- break;
- case 7:
- 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;
- 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 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
|