1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129 |
- #include "global.h"
- #if YU_WEN_XUAN_MACHINE
- unsigned short cTaiMiamMotor;
- unsigned long cSlowPusle;
- unsigned char bDecEn;
- unsigned char bStartOnceTime;
- unsigned short cWorkCnt;
- unsigned char TryCnt = 0;
- unsigned short cZhaCnt = 0;
- unsigned char ZhuangLiaoOkFlg = 0;
- unsigned char SongLaTouOkFlg = 0;
- static long save_limit_pos;
- static unsigned long cZipCnt = 0;
- void QDCT_ManualAction(void);
- void QDCT_JiaLianAction(void);
- void QDCT_AutoStepAction(void);
- void QDCT_ZhenDongAction(void);
- void QDCT_TableAction(void);
- void QDCT_GL_Step(void);
- void QDCT_Motor(void);
- void QDCT_CheckStart(void);
- void QDCT_SL_Step(void);
- void QDCT_XiaQieAction(void);
- void QDCT_ExtiActionX31(void)
- {
- if(cSeBiaoEn && !cSeBiaoOk)
- {
- cSeBiaoEn = 0;
- cSeBiaoOk = 1;
- SetRemainLength(X_AXIS,QDCT_SEBIAO_LENGTH,10);
- }
- }
- //故障报警
- void QDCT_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(QDCT_ALARM_ADDR,alarm_code);
- QDCT_bAlarmStop = 1;
- }
- //初始化动作
- void QDCT_InitAction(void)
- {
- float buff_pulse,buff_dist;
-
- buff_pulse = QDCT_PARAM_CYCLE_PULSE;
- buff_dist = QDCT_PARAM_CYCLE_LENGTH;
- XGearRatio = buff_pulse/buff_dist;
- }
- void QDCT_Action(void)
- {
- QDCT_CheckStart();
- QDCT_ZhenDongAction();
- QDCT_TableAction();
- QDCT_SL_Step();
- QDCT_JiaLianAction();
- QDCT_XiaQieAction();
- QDCT_Motor();
- QDCT_ManualAction();
- QDCT_AutoStepAction();
- }
- void QDCT_AlarmProtect(void)
- {
- dwRealPos = GetPos(X_AXIS);
- if(QDCT_PARAM_BACK_ALARM_MODE)
- { //感应后限模式
- if(!bRunning)
- {
- if(QDCT_BACK_LIMIT_IN_UP)
- {
- if((QDCT_MotorStep == 0) && X_DRV && QDCT_bMotorBack) //到后限不能再后退但可以点前进
- {
- QDCT_bMotorBack = 0;
-
- AxisDecStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
-
- }
- }
- }
- else
- {
- if(QDCT_BACK_LIMIT_IN_UP)
- {
- AxisDecStop(X_AXIS);
-
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- }
- }
- }
- else
- {
-
- if(QDCT_GO_LIMIT_IN_UP) //数控后限模式
- {
- save_limit_pos = dwRealPos;
- SetData32bits(200,save_limit_pos);
- }
-
- if(QDCT_PARAM_MAX_BACK_LENGTH < (dwRealPos - save_limit_pos))
- {
- if(!bRunning)
- {
- if((QDCT_MotorStep == 0) && X_DRV && QDCT_bMotorBack) //到后限不能再后退但可以点前进
- {
- QDCT_bMotorBack = 0;
- AxisDecStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
-
- }
- }
- else
- {
- AxisDecStop(X_AXIS);
- QDCT_JD_OUT = 0;
- QDCT_SetAlarmCode(QDCT_BACK_LIMIT_ALARM);
- }
- }
-
- }
- }
- void QDCT_JiaLianAction(void)
- {
- if(QDCT_JiaLianStep == 1)
- {
- // QDCT_JD_Delay = dwTickCount + QDCT_PARAM_JD_DELAY;
- QDCT_JiaLianStep = 2;
- }
- else if((QDCT_JiaLianStep == 2) && (dwTickCount >= QDCT_JD_Delay))
- {
- QDCT_JD_OUT = 1;
- QDCT_JD_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_JiaLianStep = 3;
- }
- else if(QDCT_JiaLianStep == 3)
- {
- if(QDCT_JZ_LEFT_IN && QDCT_JZ_RIGHT_IN)
- {
- QDCT_JiaLianStep = 4;
- }
- else if(dwTickCount >= QDCT_JD_Delay)
- {
- if(!QDCT_JZ_LEFT_IN)QDCT_SetAlarmCode(QDCT_JD_LEFT_ALARM);
- else if(!QDCT_JZ_RIGHT_IN)QDCT_SetAlarmCode(QDCT_JD_RIGHT_ALARM);
- }
- }
- else if(QDCT_JiaLianStep == 4)
- {
- if(QDCT_PARAM_KL_TIME)
- {
- // QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_DELAY;
- QDCT_JiaLianStep = 5;
- }
- else
- {
- QDCT_JiaLianStep = 7;
- }
- }
- else if((QDCT_JiaLianStep == 5) && (dwTickCount >= QDCT_JD_Delay))
- {
- QDCT_KL_OUT = 1;
- QDCT_JiaLianStep = 6;
- QDCT_JD_Delay = dwTickCount + QDCT_PARAM_KL_TIME;
- }
- else if((QDCT_JiaLianStep == 6) && (dwTickCount >= QDCT_JD_Delay))
- {
- QDCT_KL_OUT = 0;
- QDCT_JiaLianStep = 7;
- }
- else if((QDCT_JiaLianStep == 7))
- {
- QDCT_JiaLianStep = 0;
- }
- }
- //自动动作
- void QDCT_AutoStepAction(void)
- {
- if(bRunning)
- {
- if(QDCT_AutoStep == 1)
- {
- QDCT_AutoStep = 2;
- QDCT_ZhenDongStep = 1;
- }
- else if((QDCT_AutoStep == 2) && (dwTickCount >= QDCT_AutoDelay))
- {
- QDCT_AutoStep = 3;
- }
- else if(QDCT_AutoStep == 3)
- {
- if(QDCT_MotorStep == 0)
- {
- QDCT_MotorStep = 1;
- ZhuangLiaoOkFlg = 0;
- QDCT_AutoStep = 4;
- }
- }
- else if(QDCT_AutoStep == 4)
- {
- QDCT_AutoStep = 5;
- }
- else if(QDCT_AutoStep == 5)
- {
- if(QDCT_ZhuangLiaoStep == 0)
- {
- QDCT_ZhuangLiaoStep = 1;
- QDCT_AutoStep = 6;
- }
- }
- else if(QDCT_AutoStep == 6)
- {
- if(QDCT_ZhuangLiaoStep == 0)
- {
- QDCT_AutoStep = 7;
- }
- }
- else if(QDCT_AutoStep == 7)
- {
- QDCT_AutoStep = 8;
- }
- else if(QDCT_AutoStep == 8)
- {
- QDCT_AutoStep = 9;
- }
- else if(QDCT_AutoStep == 9)
- {
- if(QDCT_MotorStep == 0)
- {
- QDCT_AutoStep = 10;
- }
- }
- else if(QDCT_AutoStep == 10)
- {
- QDCT_AutoStep = 11;
- }
- else if(QDCT_AutoStep == 11)
- {
- if(QDCT_MotorStep == 0) //
- {
- if(QDCT_SEBIAO_MODE)
- QDCT_MotorStep = 1;
- else
- QDCT_MotorStep = 30;
- QDCT_AutoStep = 12;
- }
- }
- else if(QDCT_AutoStep == 12)
- {
- if(QDCT_MotorStep == 0)
- {
- QDCT_AutoStep = 13;
- }
- }
- else if(QDCT_AutoStep == 13)
- {
- QDCT_AutoStep = 14;
- }
- else if(QDCT_AutoStep == 14)
- {
- if(QDCT_XiaQieStep == 0)
- {
- QDCT_XiaQieStep = 1;
- QDCT_AutoStep = 15;
- }
- }
- else if(QDCT_AutoStep == 15)
- {
- if(QDCT_XiaQieStep == 0)
- {
- QDCT_AutoStep = 16;
- }
- }
- else if(QDCT_AutoStep == 16)
- {
- CalProSP(QDCT_SPEED_ADDR); //计算生产速度
- AddToTal(QDCT_TOTAL_ADDR); //生产总量加1并保存
- AddToTal(QDCT_NOWTOTAL_ADDR); //生产总量加1并保存
- cWorkCnt++;
- cZhaCnt++;
- cZipCnt++;
-
- if(GetTotal(QDCT_NOWTOTAL_ADDR) >= GetTotal(QDCT_SETTOTAL_ADDR))
- {
- ClrcToTal(QDCT_NOWTOTAL_ADDR);
- bStartOnceTime = 0;
- QDCT_SetAlarmCode(QDCT_TOTAL_ALARM);
- }
- else
- {
- if(bStartOnceTime)
- {
- bStartOnceTime = 0;
- QDCT_AutoStep = 0;
- bRunning = 0;
- }
- else
- QDCT_AutoStep = 17;
- }
- }
- else if(QDCT_AutoStep == 17)
- {
- if(cZhaCnt >= QDCT_ZHA_NO)
- {
- cZhaCnt = 0;
- QDCT_AutoDelay = dwTickCount + QDCT_ZHA_STOP_TIME;
- QDCT_AutoStep = 2;
- }
- else
- {
- QDCT_AutoDelay = dwTickCount + QDCT_PARAM_CYCLE_DELAY;
- QDCT_AutoStep = 2;
- }
-
- /* if(!QDCT_LTCZ_IN)
- {
- QDCT_AutoStep = 2;
- }
- else
- {
- QDCT_SetAlarmCode(QDCT_LTCZ_ALARM);
- }*/
- }
- }
- }
- //振动盘控制
- void QDCT_ZhenDongAction(void)
- {
- if(QDCT_ZhenDongStep == 1)
- {
- QDCT_ZhenDongStep = 2;
- }
- else if(QDCT_ZhenDongStep == 2)
- {
- if(QDCT_LT_IN)
- {
-
- }
- else
- {
- QDCT_ZDP_OUT = 1;
- QDCT_ZhenDongStep = 3;
- }
- }
- else if(QDCT_ZhenDongStep == 3)
- {
- if(QDCT_PARAM_ZD_MODE)
- {
- QDCT_ZhenDongStep = 0;
- }
- else
- {
- QDCT_ZhenDongStep = 4;
- QDCT_ZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_WORK_TIME ;
- }
- }
- else if((QDCT_ZhenDongStep == 4) && (dwTickCount >= QDCT_ZhenDongDelay))
- {
- QDCT_ZDP_OUT = 0;
- QDCT_ZhenDongStep = 2;
- }
- else if(QDCT_ZhenDongStep == 6)
- {
- QDCT_ZhenDongStep = 0;
- }
- }
- //台面电机动作
- void QDCT_TableAction(void)
- {
- if(QDCT_TB_OUT && (dwTickCount >= QDCT_TableDelay))QDCT_TB_OUT = 0;
- }
- void QDCT_CheckStart(void)
- {
- //启动 自动启动 单一自动
- if(START_IN_UP || bStart || QDCT_bOnceStart)
- {
- if(QDCT_bOnceStart)
- {
- QDCT_bOnceStart = 0;
- bStartOnceTime = 1;
- }
- bStart = 0;
-
- if(!QDCT_NO_ZIPPER_CHECK_IN)QDCT_SetAlarmCode(QDCT_START_NO_ZIPPER_ALARM);
- else if(QDCT_JLT_IN)QDCT_SetAlarmCode(QDCT_START_JLT_ALARM);
- else if(QDCT_LTCZ_IN)QDCT_SetAlarmCode(QDCT_START_LTCZ_ALARM);
- else if(!QDCT_HSL_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_GL_ORIGIN_ALARM);
- else if(QDCT_HSL_LIMIT_IN)QDCT_SetAlarmCode(QDCT_START_SL_LIMIT_ALARM);
- else if(!QDCT_SQ_LIMIT_IN)QDCT_SetAlarmCode(QDCT_START_SQ_ORIGIN_ALARM);
- else if(!QDCT_XQ_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_XQ_ORIGIN_ALARM);
- else if(!QDCT_XM_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_START_SM_ORIGIN_ALARM);
- else
- {
- if(!bRunning && (QDCT_AutoStep == 0) && (GetAlarmCode(QDCT_ALARM_ADDR) == 0))
- {
- bRunning = 1;
- QDCT_AutoStep = 1;
- cWorkCnt = 0;
- TryCnt = 0;
- SongLaTouOkFlg = 1;
- cZipCnt = 0;
- }
- }
- }
-
- //停止
- if(STOP_IN_UP|| bStop)
- {
- AxisDecStop(X_AXIS);
- bRunning = 0;
- QDCT_bOnceStart = 0;
- bStop = 0;
- bStartOnceTime = 0;
-
- QDCT_SQ_OUT = 0;
- QDCT_XQ_OUT = 0;
- QDCT_XM_OUT = 0;
- QDCT_JD_OUT = 0;
- QDCT_SL_OUT = 0;
- QDCT_JLT_OUT= 0;
- QDCT_HSL_OUT = 0;
- QDCT_KL_OUT = 0;
- QDCT_ZDP_OUT= 0;
- QDCT_SLT_OUT= 0;
- if(GetAlarmCode(QDCT_ALARM_ADDR) != 0)QDCT_SetAlarmCode(QDCT_NO_ALARM);
- }
-
- if(bAlarmStop)
- {
- QDCT_bOnceStart = 0;
- bAlarmStop = 0;
- bStartOnceTime = 0;
- QDCT_ZDP_OUT = 0;
- AxisDecStop(X_AXIS);
- }
- }
- //电机控制动作
- void QDCT_Motor(void) //
- {
- static long save_buff,length_buff,gou_zhen_buff,back_dec_buff,dandao_buff,back_buff,gouzhen_buff,go_buff,go_length_buff,jz_buff;
-
- user_datas[123] = QD_PARAM_ON_BACK_LENGTH;
- user_datas[124] = QD_AutoStep;
- user_datas[127] = QDCT_MotorStep;
- switch(QDCT_MotorStep)
- {
- case 1:
- QDCT_MotorDelay = dwTickCount + QD_PARAM_DELAY_BACK;
- QDCT_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_dec_buff = dwRealPos;
- if(cZipCnt == 0)
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- AxisContinueMove(X_AXIS,QDCT_BACK_LOWSPEED,QDCT_DIR_P);
- }
- else
- {
- AxisContinueMove(X_AXIS,QDCT_PARAM_JJBACK_SPEED,QDCT_DIR_P);
- }
- QDCT_MotorStep = 3;
- }
- break;
- case 3:
- if(cZipCnt != 0)
- {
- if(QDCT_PARAM_SET_ZIPPER_LENGTH >= (QDCT_SEBIAO_LENGTH + QDCT_REMAIN_CHECK_LENGTH))
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- }
- else
- {
- if((dwRealPos - back_dec_buff) >= (QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_SEBIAO_LENGTH - QDCT_REMAIN_CHECK_LENGTH))
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 1;
- }
- }
- }
- if((dwRealPos - back_dec_buff) > (QDCT_PARAM_SET_ZIPPER_LENGTH - (QDCT_BACK_LOWSPEED_LENGTH + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDCT_PARAM_JJBACK_SPEED,QDCT_BACK_LOWSPEED,30)))))
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,QDCT_BACK_LOWSPEED);
- }
-
- if(cSeBiaoOk)
- {
- cSeBiaoOk = 0;
- cSeBiaoEn = 0;
- QDCT_MotorStep = 4;
- }
-
- break;
- case 4:
- if(!X_DRV)
- {
- QDCT_MotorStep = 0;
- }
- break;
- case 30:
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_DELAY_BACK;
- QDCT_MotorStep = 31;
-
- break;
- case 31:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- back_buff = dwRealPos;
- gou_zhen_buff = dwRealPos;
- save_buff = dwRealPos;
- MoveAction_Pulse2(X_AXIS,PosToPulse(X_AXIS,QDCT_PARAM_SET_ZIPPER_LENGTH),PosToPulse(X_AXIS,QDCT_PARAM_PUTIN_SPEED_LENGTH),PosToPulse(X_AXIS,QDCT_BACK_LOWSPEED_LENGTH),QDCT_PARAM_JJBACK_SPEED,QDCT_PARAM_PUTIN_SPEED);
- QDCT_MotorStep = 33;
- }
- break;
- case 32:
- if((dwRealPos - back_buff) >= (QDCT_PARAM_PUTIN_LENGTH + QDCT_PARAM_PUTIN_START_LENGTH))
- {
- QDCT_JLT_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 33;
- }
- else if(!X_DRV)
- {
- QDCT_JLT_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 33;
- }
- break;
- case 33:
- if(!QDCT_JLT_IN)
- {
- QDCT_XM_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 34;
- }
- else if(!X_DRV)
- {
- QDCT_XM_OUT = 0;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 34;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- break;
- case 34:
- if(!X_DRV && QDCT_XM_ORIGIN_IN && !QDCT_XM_LIMIT_IN)
- {
- // AxisMovePos(X_AXIS,QDCT_BACK_LOWSPEED,QDCT_PARAM_JJFZ_LENGTH);
- QDCT_MotorStep = 35;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- break;
- case 35:
- if(!X_DRV)
- {
- QDCT_MotorStep = 36;
- }
- break;
- case 36:
- QDCT_MotorStep = 0;
- break;
- case 40:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- jz_buff = dwRealPos;
-
- if(QDCT_PARAM_SJZ_LENGTH == 0)
- {
- QDCT_JD_OUT = 0;
- }
- QDCT_MotorDelay = dwTickCount + QDCT_PARAN_SJ_TIME;
- QDCT_MotorStep = 41;
- }
- break;
- case 41:
- if(QDCT_JD_OUT && (dwTickCount >= QDCT_MotorDelay))
- {
- AxisMovePos(X_AXIS,QDCT_PARAM_CUTBACK_SPEED,-(QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH));
- QDCT_MotorStep = 42;
- }
- break;
- case 42: // 切断完成后拉电机动作
- if(((QDCT_PARAM_SJZ_LENGTH) <= (dwRealPos - jz_buff)))
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 43;
- }
- else if(!X_DRV)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorStep = 43;
- }
- break;
- case 43: // 切断完成后拉电机动作
- if(!X_DRV)
- {
- QDCT_MotorStep = 0;
- QDCT_MotorDelay = dwTickCount;
- }
-
- break;
- case 61: // 前点定位数控模式
- if(QDCT_JD_OUT)
- {
- QDCT_JD_OUT = 0;
- QDCT_MotorDelay = dwTickCount + 50;
- }
-
- if(!QDCT_TL_OUT)
- {
- //if(QD_TuiLianStep == 0)
- {
- QDCT_MotorStep = 62;
- }
- }
- else
- QDCT_MotorStep = 62;
- break;
- case 62:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(QDCT_GO_LIMIT_IN || QDCT_GO_DEC_IN)
- {
- AxisMovePos(X_AXIS,QDCT_BACK_LOWSPEED,-QDCT_PARAM_ON_BACK_LENGTH);
- QDCT_MotorDelay = dwTickCount + 1000;
- }
- QDCT_MotorStep = 63;
- QDCT_JD_OUT = 0;
- }
- break;
- case 63:
- if(!X_DRV && !QDCT_GO_LIMIT_IN && (dwTickCount >= QDCT_MotorDelay) && QDCT_XM_ORIGIN_IN)
- {
- go_buff = dwRealPos;
- if(dwZipCnt > 0)
- {
- MoveAction_Const_Stop(X_AXIS, QDCT_DIR_N,QDCT_PARAM_JJGO_SPEED);//
- }
- else
- {
- MoveAction_Const_Stop(X_AXIS, QDCT_DIR_N,QDCT_PARAM_GO_LOWSPEED);
- }
-
- QDCT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- QDCT_MotorStep = 64;
- }
- break;
- case 64:
- if(((go_buff - dwRealPos) > ((QDCT_PARAM_SET_ZIPPER_LENGTH - QDCT_PARAM_OFFSET_LENGTH) - (QDCT_PARAM_GO_LOWSPEED + PulseToPos(X_AXIS,MV_Cal_Dec_pulse(QDCT_PARAM_JJBACK_SPEED,QDCT_BACK_LOWSPEED,30))) + QDCT_BACK_LOWSPEED_LENGTH + QDCT_PARAM_SJZ_LENGTH + QDCT_PARAM_CUT_BACK_LENGTH)) || QDCT_GO_DEC_IN_UP)
- {
- MoveChangSpeed(X_AXIS,QDCT_PARAM_GO_LOWSPEED);
- QDCT_MotorStep =65;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- break;
- case 65:
- if(QDCT_GO_LIMIT_IN_UP)
- {
- AxisEgmStop(X_AXIS);
- QDCT_MotorStep = 66;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_NO_ZIPPER_ALARM);
- else if(QDCT_JD_ALARM)QDCT_SetAlarmCode(QDCT_JD_ALARM);
- break;
- case 66:
- if(!X_DRV)
- {
- QDCT_MotorDelay = dwTickCount;
- QDCT_MotorStep = 67;
- }
- break;
- case 67:
- if(dwTickCount >= QDCT_MotorDelay)
- {
- if(bRunning)
- {
- QDCT_JD_OUT = 1;
- QDCT_MotorDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_MotorStep = 68;
- }
- else
- {
- QDCT_MotorStep = 0;
- }
- }
- break;
- case 68:
- if(QDCT_JZ_LEFT_IN && QDCT_JZ_RIGHT_IN)
- {
- QDCT_MotorDelay = dwTickCount + QDCT_PARAM_JD_DELAY;
- QDCT_MotorStep = 69;
- }
- else if(dwTickCount >= QDCT_MotorDelay)QDCT_SetAlarmCode(QDCT_JD_ALARM);
- break;
- case 69:
- if(dwTickCount >= QDCT_MotorDelay)QDCT_MotorStep = 0;
- break;
-
- }
- }
- //切断动作
- void QDCT_XiaQieAction(void)
- {
- if(QDCT_XiaQieStep == 1)
- {
- QDCT_XiaQieStep = 2;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_XQ_OUT = 1;
- }
- else if(QDCT_XiaQieStep == 2)
- {
- if(QDCT_XQ_LIMIT_IN)
- {
- QDCT_XiaQieStep = 3;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(14);
- }
- }
- else if(QDCT_XiaQieStep == 3)
- {
- QDCT_SQ_OUT = 1;
- QDCT_XiaQieDelay = dwTickCount + QDCT_PARAM_CUTBACK_DELAY;
- QDCT_XiaQieStep = 4;
- }
- else if((QDCT_XiaQieStep == 4) && (dwTickCount >= QDCT_XiaQieDelay))
- {
- QDCT_SQ_OUT = 0;
- QDCT_XQ_OUT = 0;
- QDCT_XiaQieDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_XiaQieStep = 5;
- }
- else if(QDCT_XiaQieStep == 5)
- {
- if(!QDCT_SQ_LIMIT_IN && QDCT_XQ_ORIGIN_IN)
- {
- QDCT_XiaQieStep = 0;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- if(!QDCT_SQ_LIMIT_IN) QDCT_SetAlarmCode(QDCT_SQ_ORIGIN_ALARM);
- else if(!QDCT_XQ_ORIGIN_IN)QDCT_SetAlarmCode(QDCT_XQ_ORIGIN_ALARM);
- }
- }
- }
- //装拉头动作
- void QDCT_ZLT_Step(void)
- {
- if(QDCT_ZhuangLiaoStep == 1)
- {
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_ZhuangLiaoStep = 2;
- }
- else if(QDCT_ZhuangLiaoStep == 2)
- {
- if(QDCT_SongLiaoStep == 0)
- {
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 3;
- }
- }
- else if(QDCT_ZhuangLiaoStep == 3)
- {
- if(QDCT_HSL_ORIGIN_IN)
- {
- QDCT_HSL_OUT = 1;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 4;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_HSL_ORIGIN_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 4)
- {
- if(QDCT_HSL_LIMIT_IN)
- {
- QDCT_JLT_OUT = 1;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 5;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 5)
- {
- if(QDCT_JLT_IN)
- {
- QDCT_ZhuangLiaoStep = 6;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_JLT_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 6)
- {
- QDCT_HSL_OUT = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 7;
- }
- else if(QDCT_ZhuangLiaoStep == 7)
- {
- if(!QDCT_HSL_LIMIT_IN)
- {
- QDCT_XM_OUT = 1;
- if(QDCT_SongLiaoStep == 0)QDCT_SongLiaoStep = 1;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 8;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_HSL_LIMIT_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 8)
- {
- if(QDCT_XM_LIMIT_IN)
- {
- QDCT_ZhuangLiaoStep = 9;
- QDCT_ZhuangLiaoDelay = dwTickCount + 1000;
-
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_XM_LIMIT_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 9)
- {
- if(QDCT_LTCZ_IN)
- {
- if(QDCT_PARAM_LOCK_TIME)
- {
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_PARAM_LOCK_TIME;
- QDCT_SLT_OUT = 1;
- QDCT_ZhuangLiaoStep = 20;
- }
- else
- {
- QDCT_ZhuangLiaoStep = 0;
- ZhuangLiaoOkFlg = 1;
- }
- TryCnt = 0;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- TryCnt++;
- if(TryCnt > 4)
- {
- QDCT_SetAlarmCode(QDCT_ZLT_ALARM);
- }
- else
- {
- QDCT_ZhuangLiaoStep = 10;
- }
- }
- SongLaTouOkFlg = 0;
- }
- else if(QDCT_ZhuangLiaoStep == 10) //装拉头失败重复装几次拉头
- {
- QDCT_XM_OUT = 0;
- QDCT_JLT_OUT = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_ZhuangLiaoStep = 11;
- }
- else if(QDCT_ZhuangLiaoStep == 11)
- {
- if(QDCT_XM_ORIGIN_IN)
- {
- QDCT_ZhuangLiaoStep = 12;
- }
- else if(dwTickCount >= QDCT_XiaQieDelay)
- {
- QDCT_SetAlarmCode(QDCT_XM_ORIGIN_ALARM);
- }
- }
- else if(QDCT_ZhuangLiaoStep == 12)
- {
- QDCT_ZhuangLiaoStep = 1;
- }
- else if(QDCT_ZhuangLiaoStep == 20)
- {
- QDCT_ZhuangLiaoStep = 0;
- QDCT_ZhuangLiaoDelay = dwTickCount;
- ZhuangLiaoOkFlg = 1;
- }
- }
- void QDCT_SL_Step(void)
- {
- if(QDCT_SongLiaoStep == 1)
- {
- if(SongLaTouOkFlg)
- {
- QDCT_SongLiaoStep = 0;
- }
- else
- {
- QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_SongLiaoStep = 2;
- }
- }
- else if(QDCT_SongLiaoStep == 2)
- {
- if(QDCT_HSL_ORIGIN_IN)
- {
- QDCT_SL_OUT = 1;
- QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_SongLiaoStep = 3;
- }
- else if(dwTickCount >= QDCT_SL_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- }
- else if(QDCT_SongLiaoStep == 3)
- {
- if(QDCT_HSL_LIMIT_IN)
- {
- QDCT_SL_OUT = 0;
- QDCT_SL_Delay = dwTickCount + QDCT_VAVLE_ERROR_TIME;
- QDCT_SongLiaoStep = 4;
- }
- else if(dwTickCount >= QDCT_SL_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
-
- }
- else if(QDCT_SongLiaoStep == 4)
- {
- if(!QDCT_HSL_LIMIT_IN)
- {
- QDCT_SongLiaoStep = 0;
- }
- else if(dwTickCount >= QDCT_SL_Delay)
- QDCT_SetAlarmCode(QDCT_SL_ALARM);
- }
- }
- //手动动作
- void QDCT_ManualAction(void)
- {
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(QDCT_TOTAL_ADDR);
- }
-
- if(QDCT_bClerNowTotal)
- {
- QDCT_bClerNowTotal = 0;
- ClrcToTal(QDCT_NOWTOTAL_ADDR);
- }
-
-
- if(QDCT_bManXQ)
- {
- QDCT_bManXQ = 0;
- if(QDCT_XiaQieStep == 0)QDCT_XiaQieStep = 1;
- }
-
- if(QDCT_bQianDianDW)
- {
- QDCT_bQianDianDW = 0;
- if(QDCT_MotorStep == 0)
- {
- QDCT_MotorStep = 61;
- dwZipCnt = 0;
- }
- }
-
- if(QDCT_bManXM)
- {
- QDCT_bManXM = 0;
- QDCT_XM_OUT = ~QDCT_XM_OUT;
- }
-
- if(QDCT_bManSQ)
- {
- QDCT_bManSQ = 0;
- QDCT_SQ_OUT = ~QDCT_SQ_OUT;
- }
-
- if(QDCT_bManJD)
- {
- QDCT_bManJD = 0;
- QDCT_JD_OUT = ~QDCT_JD_OUT;
- }
-
- if(QDCT_bManSL)
- {
- QDCT_bManSL = 0;
- QDCT_SL_OUT = ~QDCT_SL_OUT;
- }
-
- if(QDCT_bManHSL)
- {
- QDCT_bManHSL = 0;
- QDCT_HSL_OUT = ~QDCT_HSL_OUT;
- }
-
- if(QDCT_bManZD)
- {
- QDCT_bManZD = 0;
- if(QDCT_ZDP_OUT == 0)
- {
- QDCT_ZDP_OUT = 1;
- QDCT_ZhenDongDelay = dwTickCount + QDCT_PARAM_ZD_WORK_TIME;
- }
- }
-
- if(QDCT_bManKL)
- {
- QDCT_bManKL = 0;
- if(QDCT_KL_OUT == 0)
- {
- QDCT_KL_OUT = 1;
- QDCT_KL_Delay = dwTickCount + QDCT_PARAM_KL_DELAY;
- }
- }
-
- if(QDCT_bManSLT)
- {
- QDCT_bManSLT = 0;
- QDCT_SLT_OUT = ~QDCT_SLT_OUT;
- }
-
- if(QDCT_bManJLT)
- {
- QDCT_bManJLT = 0;
- QDCT_JLT_OUT = ~QDCT_JLT_OUT;
- }
-
- if(QDCT_bZhuangLiao)
- {
- QDCT_bZhuangLiao = 0;
- if(QDCT_ZhuangLiaoStep == 0)QDCT_ZhuangLiaoStep = 1;
- }
-
- if(QDCT_bSongLT)
- {
- QDCT_bSongLT = 0;
- if(QDCT_SongLiaoStep == 0)
- {
- QDCT_SongLiaoStep = 1;
- SongLaTouOkFlg = 0;
- }
- }
-
- if(QDCT_bChuanLT)
- {
- QDCT_bChuanLT = 0;
- if(QDCT_MotorStep == 0)QDCT_MotorStep = 30;
- }
- //电机控制
- if(QDCT_bMotorGo && !QDCT_GO_LIMIT_IN)
- {
- QDCT_JD_OUT = 0;
- if(!X_DRV)AxisContinueMove(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_DIR_P);
- }
-
- if(QDCT_bMotorBack && !QDCT_BACK_LIMIT_IN)
- {
- QDCT_JD_OUT = 0;
- if(!X_DRV)AxisContinueMove(X_AXIS,QDCT_PARAM_JJGO_SPEED,QDCT_DIR_N);
- }
-
- if(!QDCT_bMotorGo && !QDCT_bMotorBack && (QDCT_MotorStep == 0))
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
-
- if(QDCT_GO_LIMIT_IN && (QDCT_MotorStep == 0) && !QDCT_bMotorBack &&(QDCT_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- }
- }
- #endif
|