12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157 |
- #include "global.h"
- #if FJ_YING_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_NoGL(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);
- short *length_buffer;
- void BK_QueDuan_ExtiActionX31(void)
- {
- cCheckLianFlg = 1;
- }
- void BKQD_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(BKQD_ALARM_ADDR,alarm_code);
- bAlarmStop = 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;
- SetDirReverse(X_AXIS, 1);
- // BKQD_SZ_OUT = 1;
- }
- void BK_QueDuan_Action(void)
- {
-
- BK_QueDuan_AlarmProtect();
- BK_QueDuan_Motor_NoGL();
- BK_QueDuan_XiaQue();
- BK_QueDuan_ManualAction();
- BK_QueDuan_TuiLianAction();
- BK_QueDuan_BingLian();
- BK_QueDuan_AutoAction();
- BK_QueDuan_StepCheckStart(); // 调用脚踏开关检测程序
-
-
- }
- //手动动作
- void BK_QueDuan_ManualAction(void)
- {
- //条数或扎数达到后,台面电机转两秒之后再停机
- if(cTABLETIME)
- {
- if(cTABLETOTAL)
- {
- cTABLETOTAL=0;
- BKQD_TABLE_VAVLE = 1;
- BKQD_TableDelay=dwTickCount + 2000;
-
- }
- if(dwTickCount >= BKQD_TableDelay)
- {
- BKQD_TABLE_VAVLE = 0;
- cTABLETIME=0;
-
- }
- }
- if(bRunning == 0)
- {
-
-
-
- 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(!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_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_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)
- {
- 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)
- {
- BKQD_cRealPos = GetPos(X_AXIS);
-
- if(!bRunning)
- {
- ;
-
- }
- else
- {
- if((BKQD_cRealPos > BKQD_PARAM_RUN_LENGTH) && (BKQD_PARAM_RUN_LENGTH > 3000)
- && (cGoLimitEn != 0))
- {
- AxisEgmStop(X_AXIS);
- BKQD_JD_VAVLE = 0;
- BKQD_SetAlarmCode(BKQD_BACK_ALARM);
- }
- }
- }
- void BK_QueDuan_AutoAction(void)
- {
- //台面电机定时关掉
-
-
- if(BKQD_QIAN_STOP_Auto)
- {
-
- cDLJ_ATUO=1;
- AxisEgmStop(X_AXIS);
-
-
-
- }
- if(BKQD_QIAN_START_Auto)
- {
- if(cDLJ_ATUO)
- {
- 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((BKQD_cRealPos < BKQD_PARAM_ZIPPER_LENGTH) && (BKQD_MotorStep > 311))
- AxisMoveTwoPos(X_AXIS,1000,(BKQD_PARAM_ZIPPER_LENGTH - BKQD_cRealPos) + (*length_buffer),
- BKQD_PARAM_BACK_LOW_SPEED,BKQD_PARAM_BACK_LOW_SPEED_LENGTH,BKQD_DIR_P,5000,3000,20,30);
-
-
- }
-
-
- }
- if(!cDLJ_ATUO)
- {
- if(bRunning)
- {
- if(!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 && !X_DRV)
- {
- BKQD_MotorStep = 61; //前点定位
- }
- cGoLimitEn = 0;
- }
- break;
- case 2:
- if(BKQD_MotorStep == 0)
- {
- BKQD_MotorStep = 30;
- BKQD_AutoStep = 3;
- cGoLimitEn = 1;
- }
- break;
- case 3:
- if(BKQD_MotorStep == 0)
- {
- if(BKQD_SAFE_IN)
- {
- bStop = 1;
- }
- else
- {
-
- if(BKQD_XiaQieStep == 0)
- BKQD_XiaQieStep = 1;
- BKQD_AutoStep = 4;
- }
- }
- break;
- case 4:
-
- // 闭口
- if((BKQD_XiaQieStep == 0) || ((BKQD_XiaQieStep == 6) && BKQD_KB_MODE)|| ((BKQD_XiaQieStep == 13) && (BKQD_KB_MODE == 0)))// && !BKQD_SHANG_MU_LIMIT_IN)
- {
- if(BKQD_MotorStep == 0)
- {
- cGoLimitEn=0;
- BKQD_MotorStep = 40; //切完后退
-
- }
- BKQD_AutoStep = 5;
- }
-
- break;
- case 5:
-
- if(BKQD_MotorStep == 0)
- {
- 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)
- {
-
- {
- bRunning = 0;
- BKQD_AutoStep = 0;
- SingOneFlg = 0;
-
- }
-
- }
- 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;
- cTABLETIME = 1;
- cTABLETOTAL= 1;
- if(BKQD_PARAM_ZS_STOP_TIME == 0)
- {
- bRunning = 0;
- BKQD_AutoStep = 0;
- SingOneFlg = 0;
- cTABLETIME = 1;
- cTABLETOTAL= 1;
- BKQD_SetAlarmCode(BKQD_TOTAL_ALARM);
- }
- }
- 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_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;
- cZipCnt = 0;
- cTABLETIME = 0;
- cTABLETOTAL= 0;
- cTuiFangKuaiCnt = 0;
- BKQD_BL_VAVLE = 0; //并链关
- cDLJ_ATUO=0;
- BKQD_DGLG_VAVLE = 0; //顶过链杆关
- SetAlarmCode(BKQD_ALARM_ADDR,0);
- }
- }
- BKQD_bSingle = 0;
- }
- //停止
- if(BKQD_STOP_IN_UP || bStop)
- {
- bStop = 0;
- 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;
- dwTickCount = BKQD_TBDelay;
- SingOneFlg = 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; //顶过链杆关
- AxisDecStop(X_AXIS);
- BKQD_BinLianStep = 0;
- BKQD_BL_VAVLE = 0;
- cTABLETIME = 0;
- cTABLETOTAL= 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;
- 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;
- AxisDecStop(X_AXIS);
- cTABLETIME = 0;
- 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;
- AxisDecStop(X_AXIS);
- 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 = BKQD_cRealPos;
- dwSaveLength = 0;
- BKQD_CheckLengthStep = 2;
- break;
- case 2:
- if(BKQD_GUO_LIAN_IN_DW){
- dwSaveLength = BKQD_cRealPos - start_dist;
- // user_datas[127] = BKQD_cRealPos;
-
- }
- break;
- }
- }
- void BK_QueDuan_BingLian(void)
- {
- static long bl_pos_buff,HL_delay;
-
- switch(BKQD_BinLianStep)
- {
- case 1:
- bl_pos_buff = BKQD_cRealPos;
-
- BKQD_BinLianStep = 2;
- break;
- case 2:
- if((BKQD_cRealPos - bl_pos_buff) >= BKQD_PARAM_DELAY_HL_LENGTH)
- {
- BKQD_BL_VAVLE = 1;
- BKQD_BinLianStep = 3;
- }
- break;
- case 3://有过链检测
- if((BKQD_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 = BKQD_cRealPos;
- BKQD_BinLianStep = 11;
- break;
- case 11:
- if((BKQD_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[124]= BKQD_cRealPos;
- user_datas[125]= bRunning;
- // user_datas[123] = length_buff - (*length_buffer);
- // user_datas[127] = BKQD_cRealPos;
- // user_datas[126] = go_buff - BKQD_cRealPos;
-
-
- if((BKQD_MotorStep >= 101) && (BKQD_MotorStep <= 103))
- {
- if(BKQD_QIAN_LIMIT_IN_DW)BKQD_HL_VAVLE = 0;
- }
- if(!cDLJ_ATUO)
- {
- switch(BKQD_MotorStep)
- {
- case 30:
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_DELAY_BACK;
-
- SetPos(X_AXIS, 0);
- length_buffer = &BKQD_PARAM_OFFSET_LENGTH;
- if(BKQD_PARAM_BL_ENABLE) //
- BKQD_BinLianStep = 1;
-
-
- BKQD_MotorStep = 31;
- break;
- case 31:
- if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH ))
- BKQD_GZ_VAVLE = 1;
- if(dwTickCount >= BKQD_MotorDelay)
- {
- back_buff = BKQD_cRealPos;
- gou_zhen_buff = BKQD_cRealPos;
- save_buff = BKQD_cRealPos;
- 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 + (*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 = 32;
- }
- break;
- case 32:
- //勾针提前输出
- if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH ))
- BKQD_GZ_VAVLE = 1;
-
- if((BKQD_cRealPos) > (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_BACK_LOW_SPEED_LENGTH)) //- (*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 = 33;
- }
- else if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))//BKQD_PARAM_ERROR_LENGTH))
- {
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- break;
- case 33:
- if(BKQD_cRealPos >= (BKQD_PARAM_ZIPPER_LENGTH-BKQD_PARAM_GOUZHEN_LENGTH ))
- {
- BKQD_GZ_VAVLE = 1;
-
- }
- if(BKQD_GOUZHEN_IN)
- {
- AxisEgmStop(X_AXIS);
- BKQD_MotorDelay = dwTickCount + 15;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 34;
- BKQD_BL_VAVLE = 0; //停止时并链一定要打开
- }
- else if((BKQD_cRealPos >= BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)))// && dwTickCount >= BKQD_MotorDelay)
- {
- AxisEgmStop(X_AXIS);
- if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_GZ_ALARM);
- }
- break;
- case 34:
- if(!X_DRV && (dwTickCount >= BKQD_MotorDelay))
- {
- BKQD_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- BKQD_YD_VAVLE = 1;
- BKQD_MotorStep = 35;
- }
- break;
- case 35:
- if(cZipCnt == 0)
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-120;
- kk = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+120;
- }
- else
- {
- ch = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)-100;
- kk = BKQD_PARAM_ZIPPER_LENGTH - 200 + (*length_buffer)+100;
- }
- user_datas[128] = ch;
- user_datas[127] = kk;
- if(((BKQD_cRealPos) < (ch)))
- {
- SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM);
- if(dwTickCount >= BKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else if((BKQD_cRealPos > kk))//(BKQD_PARAM_ERROR_LENGTH - 200 + (*length_buffer)+50)))
- {
- SetAlarmCode(BKQD_ALARM_ADDR,BKQD_LENGTH_LONG_ALARM);
- if(dwTickCount >= BKQD_MotorDelay)
- bAlarmStop = 1;
- }
- else
- {
-
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_BACK_LOW_SPEED,-BKQD_PARAM_FZ_LENGTH,3000,1000,BKQD_PARAM_ACC,BKQD_PARAM_DCC,00);
- BKQD_MotorStep = 0;
- }
-
- break;
-
- case 40:
- //切完延时后拉带松夹子
- if(BKQD_PARAM_SJZ_LENGTH == 0)
- {
- BKQD_MotorDelay = dwTickCount + BKQD_PARAM_TDYS_DELAY;
- jz_buff = BKQD_cRealPos;
- BKQD_MotorStep = 43;
- BKQD_JD_VAVLE = 0;
- }
- else
- {
- jz_buff = BKQD_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(!X_DRV || (BKQD_PARAM_SJZ_LENGTH <= (BKQD_cRealPos - jz_buff)))
- {
-
- BKQD_JD_VAVLE = 0;
- BKQD_GZ_VAVLE=0;
-
- BKQD_MotorStep = 44;
- }
- break;
- case 43:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- SetDir(X_AXIS, BKQD_DIR_P);
- AxisMovePosAccDec(X_AXIS,BKQD_PARAM_CUT_BACK_SPEED,BKQD_PARAM_BACK_LENGTH,1000,1000,25,50,0);
- BKQD_MotorStep = 44;
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV || (BKQD_cRealPos - jz_buff) >= (BKQD_PARAM_SJZ_LENGTH+BKQD_PARAM_BACK_LENGTH))
- {
- AxisEgmStop(X_AXIS);
- BKQD_MotorStep = 0;
- BKQD_GZ_VAVLE=0;
- BKQD_MotorDelay = dwTickCount;
- }
- break;
- case 61: // 前点定位数控模式
- if(BKQD_SZ_OUT)
- {
- BKQD_SZ_OUT = 0;
- BKQD_MotorDelay = dwTickCount + 150;
- SetPos(X_AXIS, 0);
- }
- else
- BKQD_MotorDelay = dwTickCount;
- BKQD_BL_VAVLE = 0;//并链也要打开
-
-
-
- if(!BKQD_TL_VAVLE && cZipCnt) //没送链情况下主动送链
- {
- if(!BKQD_SHANG_MU_LIMIT_IN && (BKQD_TuiLianStep == 0))
- {
- BKQD_TuiLianStep = 1;
- BKQD_MotorStep = 62;
- }
- }
- else
- BKQD_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= BKQD_MotorDelay)
- {
- if(BKQD_QIAN_LIMIT_IN)
- {
- SetPos(X_AXIS, 0);//在前点,直接置零点
- //前点亮的情况下先退出
- 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)
- {
- go_buff = BKQD_cRealPos;
- BKQD_YD_VAVLE = 1;
- BKQD_HL_VAVLE = 1;
- BKQD_YX_VAVLE = 1;
- if(cZipCnt > 0)
- {
-
- if(BKQD_cRealPos>(BKQD_PARAM_GO_LOW_SPEED_LENGTH))
- {
-
-
- DCC_TIME_BL=BKQD_PARAM_GO_HIGH_SPEED/500;
- AxisMovePosAccDecNotStop(X_AXIS,BKQD_PARAM_GO_HIGH_SPEED,-BKQD_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);
- }
-
- }
- else
- {
- // X轴 运行速度 启动速度 加速度 减速度
- AxisContinueMoveAcc(X_AXIS,BKQD_PARAM_GO_LOW_SPEED,BKQD_DIR_N,BKQD_PARAM_GO_LOW_SPEED/3,1000,15,15);
- }
-
- BKQD_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- BKQD_MotorStep =64;
- }
-
- break;
- case 64:
- if(cZipCnt > 1)
- {
- //李永庆代码
- if(((BKQD_cRealPos) < (BKQD_PARAM_GO_LOW_SPEED_LENGTH+1200)))// || (BKQD_QIAN_DEC_IN))
- {
- user_datas[126]= GetCurSpeed(X_AXIS);
- BKQD_MotorStep =65;
- }
- if(BKQD_QIAN_LIMIT_IN) //前点限位
- {
- SetPos(X_AXIS, BKQD_PARAM_QDW_LENGTH);
- AxisMovePosAccDec(X_AXIS,1000,-BKQD_PARAM_QDW_LENGTH,1000,1000,5,5,00);
- BKQD_MotorStep = 66;
- }
- }
- else
- {
- if(BKQD_QIAN_LIMIT_IN) //前点限位
- {
- SetPos(X_AXIS, BKQD_PARAM_QDW_LENGTH);
- AxisMovePosAccDec(X_AXIS,1000,-BKQD_PARAM_QDW_LENGTH,1000,1000,5,5,00);
- BKQD_MotorStep = 66;
- }
- }
-
- break;
- case 65:
- if(BKQD_QIAN_LIMIT_IN)
- {
-
- SetPos(X_AXIS, BKQD_PARAM_QDW_LENGTH);
- AxisMovePosAccDec(X_AXIS,1000,-BKQD_PARAM_QDW_LENGTH,1000,1000,5,5,00);
- BKQD_MotorStep = 66;
-
- }
- else if(dwTickCount >= BKQD_MotorDelay)
- BKQD_SetAlarmCode(BKQD_NO_ZIPPER_ALARM);
-
- break;
- case 66:
- if(!X_DRV || BKQD_cRealPos<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_TL_VAVLE = 0;
- BKQD_MotorStep = 0;
- BKQD_MotorDelay = dwTickCount;
- }
- break;
-
- }
- }
- }
-
-
-
- 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:
- if(BKQD_PARAM_TL_DELAY)
- BKQD_TLDelay = dwTickCount + BKQD_PARAM_TL_DELAY;
- else
- BKQD_TLDelay = dwTickCount + 100;
- 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 = 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;
- }
- 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;
- }
- }
- 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;
- 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
|