1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012 |
- #include "global.h"
- #if 0
- void ChuanTou_AlarmProtect(void);
- void ChuanTou_ManualAction(void);
- void ChuanTou_AutoAction(void);
- void ChuanTou_StepCheckStart(void);
- void ChuanTou_Motor(void);
- void ChuanTou_SongLiaoAction(void);
- static unsigned cSongLiaoOk = 0;
- void CT_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(CT_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void ChuanTou_InitAction(void)
- {
- float length_buff,pulse_buff;
- save_limit_pos = CT_SAVE_POS;
- axis_x->speed_unit = 500;
- length_buff = CT_PARAM_CYCLE_LENGTH;
- pulse_buff = CT_PARAM_CYCLE_PULSE;
- XGearRatio = pulse_buff/length_buff;
- }
- void ChuanTou_Action(void)
- {
- ChuanTou_AlarmProtect();
- ChuanTou_Motor();
- ChuanTou_ManualAction();
- ChuanTou_AutoAction();
- ChuanTou_SongLiaoAction();
- ChuanTou_StepCheckStart(); // 调用脚踏开关检测程序
- }
- //手动动作
- void ChuanTou_ManualAction(void)
- {
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(CT_TOTAL_ADDR);
- }
-
- if(CT_bGZ)
- {
- CT_bGZ = 0;
- CT_GZ_VAVLE = ~CT_GZ_VAVLE;
- }
-
- if(CT_bHL)
- {
- CT_bHL = 0;
- CT_HL_VAVLE = ~CT_HL_VAVLE;
- }
-
- if(CT_bJL)
- {
- CT_bJL = 0;
- CT_JL_VAVLE = ~CT_JL_VAVLE;
- }
-
- if(CT_bSL)
- {
- CT_bSL = 0;
- CT_SL_VAVEL = ~CT_SL_VAVEL;
- }
-
- if(CT_bHSL)
- {
- CT_bHSL = 0;
- CT_HSL_VAVLE = ~CT_HSL_VAVLE;
- }
-
- if(CT_bZL)
- {
- CT_bZL = 0;
- }
-
- if(CT_bGJ)
- {
- CT_bGJ = 0;
- CT_GJ_VAVLE = ~CT_GJ_VAVLE;
- }
-
- if(CT_bFZ)
- {
- CT_bFZ = 0;
- CT_FD_VAVLE = ~CT_FD_VAVLE;
- }
-
- if(CT_bCT_XM)
- {
- CT_bCT_XM = 0;
- }
-
- if(CT_bDW)
- {
- CT_bDW = 0;
- }
-
- if(CT_bAuto_ZL)
- {
- CT_bAuto_ZL = 0;
- }
-
- if(CT_bHM)
- {
- CT_bHM = 0;
- }
- }
- }
- void ChuanTou_AlarmProtect(void)
- {
- }
- void ChuanTou_HeMu_Action(void)
- {
- switch (CT_HeMuStep)
- {
- case 1:
- CT_HeMuStep = 2;
- break;
- case 2:
- CT_HeMuStep = 3;
- break;
- case 3:
- CT_HeMuStep = 4;
- break;
- }
- }
- //送料
- void ChuanTou_SongLiaoAction(void)
- {
- switch(CT_SL_Step)
- {
- case 1:
- {
- if(cSongLiaoOk)
- {
- CT_SL_Step = 0;
- }
- else
- {
- if(CT_HSL_ORIGIN_IN && CT_SONG_LIAO_ORIGIN_IN)
- {
- CT_SL_VAVEL = 1;
- CT_SL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_SL_Step = 2;
- }
- }
- }break;
- case 2:
- {
- if(CT_SONG_LIAO_LIMIT_IN)
- {
- CT_SL_Step = 3;
- CT_SL_Delay = dwTickCount + CT_PARAM_SL_DELAY_BACK;
- }
- else if(dwTickCount >= CT_SL_Delay)
- {
- CT_SetAlarmCode(CT_SL_LIMIT_ALARM);
- }
- }break;
- case 3:
- {
- if(dwTickCount >= CT_SL_Delay)
- {
- CT_SL_VAVEL = 0;
- CT_SL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_SL_Step = 4;
- }
- }break;
- case 4:
- {
- if(CT_SONG_LIAO_ORIGIN_IN)
- {
- cSongLiaoOk = 1;
- CT_SL_Step = 0;
- }
- else if(dwTickCount >= CT_SL_Delay)
- {
- CT_SetAlarmCode(CT_SL_ORIGIN_ALARM);
- }
- }
- break;
- }
- }
- //横送料
- void ChuanTou_HengSongLiao_Action(void)
- {
- switch(CT_HSL_Step)
- {
- case 1:
- {
- if(CT_SONG_LIAO_ORIGIN_IN && CT_HSL_ORIGIN_IN && CT_XIA_MU_IN && cSongLiaoOk)
- {
- CT_GJ_VAVLE = 0;
- CT_HSL_Step = 2;
- }
- else if(!bRunning)
- {
- CT_HSL_Step = 0;
- }
- }
- break;
- case 2:
- {
- CT_HSL_VAVLE = 1;
- cSongLiaoOk = 0;
- CT_HSL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_HSL_Step = 3;
- }
- break;
- case 3:
- {
- if(CT_HSL_LIMIT_IN)
- {
- CT_ZL_XM_VAVLE = 1;
- CT_HSL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_HSL_Step = 4;
- }
- else if(dwTickCount >= CT_HSL_Delay)
- {
- CT_SetAlarmCode(CT_HSL_LIMIT_ALARM);
- }
- }
- break;
- case 4:
- {
- if(CT_ZHUANG_LIAO_IN)
- {
- CT_HSL_Delay = dwTickCount + CT_PARAM_LOCK_TIME;
- CT_HSL_Step = 5;
- }
- else if(dwTickCount >= CT_HSL_Delay)
- {
- CT_SetAlarmCode(CT_ZL_LIMIT_ALARM);
- }
- }
- break;
- case 5:
- if(dwTickCount >= CT_HSL_Delay)
- {
- CT_GJ_VAVLE = 1;
- CT_HSL_Delay = dwTickCount + CT_PARAM_GJ_TIME;
- CT_HSL_Step = 6;
- }
- break;
- case 6:
- CT_HSL_VAVLE = 0;
- CT_HSL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_HSL_Step = 7;
- break;
- case 7:
- if(CT_HSL_ORIGIN_IN)
- {
- CT_ZL_XM_VAVLE = 0;
- CT_HSL_Step = 8;
- }
- else if(dwTickCount >= CT_HSL_Delay)
- {
- CT_SetAlarmCode(CT_HSL_ORIGIN_ALARM);
- }
- break;
- case 8:
- CT_HSL_Step = 0;
- CT_SL_Step = 1;
- break;
- }
- }
- void ChuanTou_AutoAction(void)
- {
- if(bRunning)
- {
- switch(CT_AutoStep)
- {
- case 1:
- if(dwTickCount >= CT_AutoDelay)
- {
- CT_AutoStep = 2;
- if(CT_MotorStep == 0)
- {
- CT_MotorStep = 61; //前点定位
- // else CT_MotorStep = 1;
- }
- }
- break;
- case 2:
- if(CT_MotorStep == 0)
- {
- if(CT_PARAM_DC_MODE == 0)
- CT_MotorStep = 20; //后退到位
- else
- CT_MotorStep = 30;
- CT_AutoStep = 3;
- }
- break;
- case 3:
- if(CT_MotorStep == 0)
- {
- if(CT_XiaQieStep == 0)CT_XiaQieStep = 1;
- CT_AutoStep = 4;
- }
- break;
- case 4:
- break;
- case 5:
- if(CT_MotorStep == 0)
- {
- cZipCnt++;
- CT_PARAM_NOW_CNT++;
- cTableCnt++;
- AddToTal(CT_TOTAL_ADDR);
- CalProSP(CT_PROSPEED_ADDR);
-
- if(cTableCnt >= CT_PARAM_TABLE_NUM)
- {
- cTableCnt = 0;
- CT_TABLE_VAVLE = 1;
- CT_TBDelay = dwTickCount + CT_PARAM_TB_TIME;
- }
-
- if((GetTotal(CT_TOTAL_ADDR) >= CT_PARAM_SET_TOTAL) || SingOneFlg)
- {
- bRunning = 0;
- CT_AutoStep = 0;
- SingOneFlg = 0;
-
- if(GetTotal(CT_TOTAL_ADDR) >= CT_PARAM_SET_TOTAL) CT_SetAlarmCode(CT_TOTAL_ALARM);
- }
- else
- {
- CT_AutoStep = 1;
-
- if(CT_PARAM_NOW_CNT >= CT_PARAM_ZHA_SHU)
- {
- CT_AutoDelay = dwTickCount + CT_PARAM_ZS_STOP_TIME + 50;
- CT_PARAM_NOW_CNT = 0;
- }
- else
- CT_AutoDelay = dwTickCount + CT_PARAM_CYCLE_DELAY;
- }
- }
- break;
- }
- }
- }
- void ChuanTou_StepCheckStart(void)
- {
- // 启动
- if((START_IN_UP) || bStart || CT_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (CT_AutoStep == 0))
- {
- if(!CT_SHANG_MU_ORIGIN_IN)CT_SetAlarmCode(CT_SM_YUANWEI);
- else if(CT_XIA_MU_LIMIT_IN)CT_SetAlarmCode(CT_XM_DAOWEI);
- else if(GetAlarmCode(CT_ALARM_ADDR) != 0);
- else if(GetTotal(CT_TOTAL_ADDR) >= CT_PARAM_SET_TOTAL) CT_SetAlarmCode(CT_TOTAL_ALARM);
- else if(CT_BL_VAVLE)CT_SetAlarmCode(CT_BL_ALARM);
- else if(CT_SM_VAVLE)CT_SetAlarmCode(CT_SM_ALARM);
- else
- {
- bRunning = 1;
- CT_AutoStep = 1;
- if(CT_bSingle) SingOneFlg= 1;
- cZhuangLiaoOk = 0;
- dwZipCnt = 0;
- }
- }
- CT_bSingle = 0;
- }
- //停止
- if(STOP_IN_UP || bStop)
- {
- bStop = 0;
- user_datas[127] = 0;
-
- if(bRunning)
- {
- bRunning = 0;
- CT_AutoStep = 0;
- CT_MotorStep = 0;
- CT_AutoDelay = dwTickCount;
- CT_MotorDelay = dwTickCount;
- SingOneFlg = 0;
- if(GetAlarmCode(CT_ALARM_ADDR) != 0)SetAlarmCode(CT_ALARM_ADDR,0);
- }
- else
- {
- bRunning = 0;
- CT_AutoStep = 0;
- CT_MotorStep = 0;
- CT_AutoDelay = dwTickCount;
- CT_MotorDelay = dwTickCount;
- SingOneFlg = 0;
- AxisDecStop(X_AXIS);
- if(GetAlarmCode(CT_ALARM_ADDR) != 0)SetAlarmCode(CT_ALARM_ADDR,0);
- }
- }
-
- if(bAlarmStop)
- {
- bAlarmStop = 0;
- bRunning = 0;
- CT_AutoStep = 0;
- CT_MotorStep = 0;
- CT_AutoDelay = dwTickCount;
- CT_MotorDelay = dwTickCount;
- SingOneFlg = 0;
- AxisDecStop(X_AXIS);
- }
-
- }
- //电机动作
- void ChuanTou_Motor(void) //
- {
- static long save_buff,length_buff,gou_zhen_buff,checkdelay_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff;
- user_datas[124]= CT_MotorStep;
- // user_datas[125]= go_length_buff;
- // user_datas[123] = length_buff;
- user_datas[127] = cRealPos;
- user_datas[126] = go_buff - cRealPos;
- user_datas[121] = CT_PARAM_GOUZHEN_LENGTH;
- if(CT_GUO_LIAN_IN_DW)user_datas[122]++;
- switch(CT_MotorStep)
- {
- case 0:
- break;
- case 1: // 前点定位数控模式
- if(CT_SZ_OUT)
- {
- CT_SZ_OUT = 0;
- CT_MotorDelay = dwTickCount + 50;
- }
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
- if((CT_TuiLianStep == 0) && !CT_TL_VAVLE && !CT_PARAM_TL_MODE)CT_TuiLianStep = 1;
- CT_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= CT_MotorDelay)
- {
- if(CT_QIAN_LIMIT_IN)
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_P;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,CT_PARAM_GO_HIGH_SPEED,CT_PARAM_ON_BACK_LENGTH);
- CT_MotorDelay = dwTickCount + 1000;
- }
- CT_MotorStep = 3;
- CT_JD_VAVEL = 0;
- }
- break;
- case 3:
- if(!X_DRV && !CT_QIAN_LIMIT_IN && (dwTickCount >= CT_MotorDelay))
- {
- if(cZipCnt == 0)
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
- AxisContinueMove(X_AXIS,CT_PARAM_FIRST_SPEED,CT_DIR_P); //第一条走低速
- }
- else
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
- AxisMoveTwoPos(X_AXIS,CT_PARAM_GO_HIGH_SPEED,(length_buff - CT_PARAM_Go_LOW_SPEED_LENGTH + CT_PARAM_BACK_LENGTH +CT_PARAM_SJZ_LENGTH),CT_PARAM_GO_LOW_SPEED,0xFFFFFF,CT_DIR_P);//第二条开始走两段速
- }
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 4;
- }
- break;
- case 4:
- if(CT_QIAN_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- CT_MotorStep = 5;
- }
- else if(dwTickCount >= CT_MotorDelay)CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- else if(CT_JD_ORIGIN_IN)CT_SetAlarmCode(CT_JD_ORIGIN_ALARM);
-
- break;
- case 5:
- if(!X_DRV)
- {
- CT_MotorDelay = dwTickCount;
- CT_MotorStep = 6;
- }
- break;
- case 6:
- if((dwTickCount >= CT_MotorDelay) && (CT_TuiLianStep == 0))
- {
- if(bRunning)
- {
- CT_JD_VAVEL = 1;
- }
- CT_MotorStep = 7;
- CT_MotorDelay = dwTickCount + 100;
- }
- break;
- case 7:
- if(dwTickCount >= CT_MotorDelay)
- {
- CT_YBD_VAVLE = 0;
- CT_TL_VAVLE = 0;
- CT_MotorStep = 0;
- }
- break;
- case 20:// 后退使用电机定长
- CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_BACK;
- CT_MotorStep = 21;
- break;
- case 21:
- if(dwTickCount >= CT_MotorDelay)
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_N;
- AxisMovePos(X_AXIS,CT_PARAM_BACK_SPEED,-CT_PARAM_ZIPPER_LENGTH);
- CT_MotorStep = 22;
- }
- break;
- case 22:
- if(!X_DRV)
- {
- CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_FZ;
- CT_MotorStep = 23;
- }
- break;
- case 23:
- if(dwTickCount >= CT_MotorDelay)
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_DIR_P;
- AxisMovePos(X_AXIS,CT_PARAM_GO_LOW_SPEED,CT_PARAM_FZ_LENGTH);
- CT_MotorStep = 24;
- }
- break;
- case 24:
- if(!X_DRV)
- {
- CT_MotorStep = 0;
- CT_MotorDelay = dwTickCount;
- }
- break;
- case 30:
- CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_BACK;
- CT_MotorStep = 31;
-
- if(CT_PARAM_BL_ENABLE)CT_BinLianStep = 1;
- break;
- case 31: // 后退使用钩针定长
- if(dwTickCount >= CT_MotorDelay)
- {
- save_buff = cRealPos;
- back_buff = cRealPos;
- SetAccTime(X_AXIS,5);
- SetDecTime(X_AXIS,5);
-
-
- if(CT_PARAM_DEC_MODE == 0)
- {
- if(CT_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- AxisContinueMove(X_AXIS,CT_PARAM_FIRST_SPEED,CT_DIR_P);
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 32;
- }
- else
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
- AxisContinueMove(X_AXIS,CT_PARAM_BACK_SPEED,CT_DIR_P);
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 32;
- }
- }
- else
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
- AxisContinueMove(X_AXIS,CT_PARAM_BACK_SPEED,CT_DIR_P);
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 32;
- }
- }
- else
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
- if(cZipCnt < 2)
- {
- CT_XHG_VAVLE = 0;
- AxisContinueMove(X_AXIS,CT_PARAM_FIRST_SPEED,CT_DIR_P);
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 32;
- }
- else
- {
- gouzhen_buff = cRealPos;
- CT_XHG_VAVLE = 1;
- //AxisMoveTwoPos(X_AXIS,CT_PARAM_BACK_SPEED,(length_buff - CT_PARAM_Back_LOW_SPEED_LENGTH),CT_PARAM_GO_LOW_SPEED,CT_PARAM_Back_LOW_SPEED_LENGTH,CT_DIR_N);
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,CT_PARAM_BACK_SPEED,-length_buff);
- MoveChangSpeedPos(X_AXIS, CT_PARAM_BACK_LOW_SPEED,(PosToPulse(X_AXIS,CT_PARAM_Back_LOW_SPEED_LENGTH) + MV_Cal_Dec_pulse(CT_PARAM_BACK_SPEED,CT_PARAM_BACK_LOW_SPEED,10)));
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 33;
- }
-
- // AxisContinueMove(X_AXIS,CT_PARAM_BACK_SPEED,CT_DIR_N);
- }
- }
- break;
- case 32:
- if(CT_PARAM_DEC_MODE)
- {
- if(cZipCnt < 2)
- {
- if(CT_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- CT_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
- CT_MotorStep = 33;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- CT_MotorStep = 36;
- }
- }
- else
- {
- if(CT_PARAM_BACK_MODE)
- {
- if(cZipCnt < 2)
- {
- if(CT_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- CT_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
- CT_MotorStep = 33;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - (CT_PARAM_Back_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(CT_PARAM_BACK_SPEED,CT_PARAM_BACK_LOW_SPEED,10)))))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
- }
- if(CT_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- CT_MotorDelay = dwTickCount;
- if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
- CT_MotorStep = 33;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- }
- }
- }
- else
- {
-
- if(CT_GUO_LIAN_IN_UP)
- {
- checkdelay_buff = cRealPos;
- if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
- CT_MotorDelay = dwTickCount;
- CT_MotorStep = 33;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- }
- }
- }
- break;
- case 33:
- if((cZipCnt < 2) || (CT_PARAM_DEC_MODE == 0))
- {
- if((cRealPos - checkdelay_buff) >= CT_PARAM_DELAY_CHECK)
- {
- if(CT_PARAM_GOUZHEN_LENGTH != 0)CT_GZ_VAVLE = 1;
- CT_MotorStep = 34;
- }
- }
- else
- {
- if((cRealPos - back_buff) > (length_buff - CT_PARAM_Back_LOW_SPEED_LENGTH))
- {
-
- if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_BACK_LOW_SPEED);
- CT_MotorStep = 34;
- }
- }
- break;
- case 34:
- if((cZipCnt < 2) || (CT_PARAM_DEC_MODE == 0))
- {
- if(CT_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- CT_MotorStep = 35;
- }
- }
- else
- {
- if(CT_PARAM_GOUZHEN_LENGTH != 0)
- {
- if((cRealPos - gouzhen_buff) >= (length_buff - CT_PARAM_GOUZHEN_LENGTH))
- {
- if(CT_PARAM_GOUZHEN_LENGTH != 0)CT_GZ_VAVLE = 1;
- CT_MotorStep = 36;
- }
- }
- else
- {
- CT_MotorStep = 36;
- }
- }
- break;
- case 35:
- if(CT_GUO_LIAN_IN_DW)
- {
- gou_zhen_buff = cRealPos;
- }
-
- if(CT_GUO_LIAN_IN_UP)
- {
- gou_zhen_buff = cRealPos;
- }
- if((cRealPos - gou_zhen_buff) >= CT_PARAM_MOTOR_DELAY_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- CT_MotorDelay = dwTickCount + VAVLE_ALARM_TIME;
- CT_MotorStep = 36;
- }
- break;
- case 36:
- if(!X_DRV && ((CT_PARAM_TIAOSHI_MODE && CT_bTS) || (CT_PARAM_TIAOSHI_MODE == 0)))
- {
- if(CT_PARAM_GOUZHEN_LENGTH == 0)CT_GZ_VAVLE = 1;
- if(CT_PARAM_DEC_MODE == 0)CT_GZ_VAVLE = 1;
- if(!CT_PARAM_TL_MODE)CT_YBD_VAVLE = 1;
- CT_MotorDelay = dwTickCount + CT_PARAM_TFK_DELAY;
- CT_MotorStep = 37;
- }
- break;
- case 37:
- if(dwTickCount >= CT_MotorDelay)
- {
- CT_TFK_VAVEL = 1;
- CT_MotorDelay = dwTickCount + 1000;
- CT_MotorStep = 38;
- }
- break;
- case 38:
- if(CT_GOUZHEN_IN && !X_DRV && ((CT_PARAM_TIAOSHI_MODE && CT_bTS) || (CT_PARAM_TIAOSHI_MODE == 0)))
- {
- if(CT_PARAM_TL_MODE)CT_YBD_VAVLE = 1;
-
- if(cZipCnt == 1)
- {
- length_buff = cRealPos - save_buff - CT_PARAM_OFFSET_LENGTH;
- }
- if(cZipCnt == 0)
- {
- go_length_buff = cRealPos - save_buff;
- }
- cTuiFangKuaiCnt = 0;
- CT_MotorStep = 0;
- }
- else if(dwTickCount >= CT_MotorDelay)
- {
- if(cTuiFangKuaiCnt == 0)
- {
- CT_MotorStep = 100;
- CT_TFK_VAVEL = 0;
- cTuiFangKuaiCnt++;
- CT_MotorDelay = dwTickCount + 1000;
- }
- else
- CT_SetAlarmCode(CT_GZ_ALARM);
- }
- break;
- case 100:
- if(dwTickCount >= CT_MotorDelay)
- {
- CT_MotorStep = 37;
- }
- break;
- case 40:
- if(dwTickCount >= CT_MotorDelay)
- {
- AxisMovePos(X_AXIS,CT_PARAM_CUT_BACK_SPEED,-(CT_PARAM_SJZ_LENGTH));
- CT_MotorStep = 41;
- }
- break;
- case 41:
- if(!X_DRV)
- {
- CT_JD_VAVEL = 0;
- CT_MotorDelay = dwTickCount + 5;
- CT_MotorStep = 42;
- }
- break;
- case 42:
- if(dwTickCount >= CT_MotorDelay)
- {
- save_buff = cRealPos;
-
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,CT_PARAM_CUT_BACK_SPEED,-(CT_PARAM_BACK_LENGTH));
- CT_MotorStep = 44;
- }
-
- break;
-
- case 43: // 切断完成后拉电机动作
- if(((CT_PARAM_SJZ_LENGTH) <= (cRealPos - save_buff)))
- {
- CT_JD_VAVEL = 0;
- CT_MotorStep = 44;
- }
- else if(!X_DRV)
- {
- CT_JD_VAVEL = 0;
- CT_MotorStep = 44;
- }
- break;
- case 44: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- CT_MotorStep = 0;
- CT_MotorDelay = dwTickCount;
- }
-
- break;
- case 61: // 前点定位数控模式
- if(CT_SZ_OUT)
- {
- CT_SZ_OUT = 0;
- CT_MotorDelay = dwTickCount + 50;
- }
-
-
- if(CT_PARAM_TL_MODE)
- {
- // if(CT_TuiLianStep == 0)CT_TuiLianStep = 1;
- }
- else
- {
- if((CT_TuiLianStep == 0) && !CT_TL_VAVLE)CT_TuiLianStep = 1;
- }
- CT_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= CT_MotorDelay)
- {
- if(CT_QIAN_LIMIT_IN)
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_P;
- MV_Set_Acc_CPU(X_AXIS, 10);
- AxisMovePos(X_AXIS,CT_PARAM_FIRST_SPEED,-CT_PARAM_ON_BACK_LENGTH);
- CT_MotorDelay = dwTickCount + 1000;
- }
- CT_MotorStep = 63;
- CT_JD_VAVEL = 0;
- }
- break;
- case 63:
- if(!X_DRV && !CT_QIAN_LIMIT_IN && (dwTickCount >= CT_MotorDelay))
- {
- if(CT_PARAM_TL_MODE)CT_JZ_DIR = CT_YDIR_N;
- go_buff = cRealPos;
- if(cZipCnt > 0)
- {
- MoveAction_Const_Stop(X_AXIS, CT_DIR_N,CT_PARAM_GO_HIGH_SPEED);//
- }
- else
- {
- MoveAction_Const_Stop(X_AXIS, CT_DIR_N,CT_PARAM_GO_LOW_SPEED);
- }
- // MoveAction_Const_Stop(X_AXIS, CT_DIR_P,CT_PARAM_GO_HIGH_SPEED);//
- // AxisContinueMove(X_AXIS,CT_PARAM_GO_HIGH_SPEED,CT_DIR_P); //第一条走低速
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep =64;
- }
- break;
- case 64:
- if(CT_PARAM_GO_MODE)
- {
- if(cZipCnt > 0)
- {
-
- if((go_buff - cRealPos) > (go_length_buff - (CT_PARAM_Go_LOW_SPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(CT_PARAM_BACK_SPEED,CT_PARAM_BACK_LOW_SPEED,10))) + CT_PARAM_BACK_LENGTH + CT_PARAM_SJZ_LENGTH))
- {
-
- MoveChangSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);
- CT_MotorStep =65;
- }
- }
- else
- {
- // if(CT_QIAN_DEC_IN)
- {
- // if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);
- CT_MotorStep =65;
- }
- }
- }
- else
- {
- // if(CT_QIAN_DEC_IN)
- {
- // if(X_DRV)MoveChangSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);//AxisChangeSpeed(X_AXIS,CT_PARAM_GO_LOW_SPEED);
- CT_MotorStep =65;
- }
- }
- break;
- case 65:
- if(CT_QIAN_LIMIT_IN_UP)
- {
- if(CT_PARAM_DAO_MODE)
- {
- dandao_buff = cRealPos;
- CT_MotorStep = 70;
- }
- else
- {
- AxisEgmStop(X_AXIS);
- CT_MotorStep = 66;
- }
- }
- else if(dwTickCount >= CT_MotorDelay)CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- else if(CT_JD_ORIGIN_IN)CT_SetAlarmCode(CT_JD_ORIGIN_ALARM);
- break;
- case 70:
- if((dandao_buff - cRealPos) >= CT_PARAM_DANDAO_MODE_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- CT_MotorStep = 66;
- }
- break;
- case 66:
- if(!X_DRV)
- {
- CT_MotorDelay = dwTickCount;
- CT_MotorStep = 67;
- }
- break;
- case 67:
- if((dwTickCount >= CT_MotorDelay) && (CT_TuiLianStep == 0) && ((CT_PARAM_TIAOSHI_MODE && CT_bTS) || (CT_PARAM_TIAOSHI_MODE == 0)) )
- {
- if(bRunning)
- {
- CT_JD_VAVEL = 1;
- }
- CT_MotorStep = 68;
- CT_MotorDelay = dwTickCount + CT_PARAM_DELAY_BACK;
- }
- break;
- case 68:
- if(dwTickCount >= CT_MotorDelay)
- {
- CT_YBD_VAVLE = 0;
- CT_TL_VAVLE = 0;
- CT_MotorStep = 0;
- }
- break;
-
- }
- }
- #endif
|