1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324 |
- #include "global.h"
- #if PENG_WEI_CHANG_MACHINE == 1
- void JSKL_CheckStart(void);
- void JSKL_Motor(void);
- void JSKL_ManualAction(void);
- void JSKL_AutoAction(void);
- void JSKL_FD_Action(void);
- void JSKL_Check(void);
- unsigned char cJSKL_CheckLTimes =0;
- unsigned char cJSKL_CheckRTimes =0;
- unsigned char cStopFlg =0;
- unsigned char cCheckOkLFlg = 0;
- unsigned char cCheckOkRFlg = 0;
- unsigned char cBackFDFlag = 0;
- unsigned char cJSKL_left_enable = 0;
- unsigned char cJSKL_right_enable = 0;
- unsigned char cManPJStep = 0;
- unsigned char cErrorLflg,cErrorRflg;
- //故障报警
- void JSKL_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(JSKL_ALARM_ADDR,alarm_code);
- JSKL_bAlarmStop = 1;
- }
- void JSKL_InitAction(void)
- {
- float length_buff,pulse_buff;
-
- length_buff = 2480;
- pulse_buff = 1600;
- XGearRatio = pulse_buff/length_buff;
- CalFreqTab_X_Free(14);
- JSKL_SZ_OUT = 1;
- cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
- cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
- }
- void JSKL_Action(void)
- {
- JSKL_CheckStart(); //启动
- JSKL_Check();
- JSKL_Motor(); //拖带控制
- JSKL_FD_Action();
- JSKL_ManualAction();
- JSKL_AutoAction();
- }
- void JSKL_ManualAction(void)
- {
- //清总产量
- if(JSKL_bClear) //清总产量
- {
- JSKL_bClear = 0;
- ClrcToTal(JSKL_TOTAL_ADDR);
- }
-
- if(bRunning == 0) ////手动
- {
- if(JSKL_bGZ)
- {
- JSKL_bGZ = 0;
- JSKL_GZ_VAVLE = ~JSKL_GZ_VAVLE;
- }
-
- if(JSKL_bFD)
- {
- JSKL_bFD = 0;
- JSKL_FD_VAVLE = ~JSKL_FD_VAVLE;
- }
-
- if(JSKL_bXM)
- {
- JSKL_bXM = 0;
-
- if(JSKL_XM_VAVLE)
- {
- if(!JSKL_SM_LIMIT_IN)JSKL_XM_VAVLE = 0;
- else
- JSKL_SM_VAVLE = 0;
- }
- else
- JSKL_XM_VAVLE = 1;
- }
-
- if(JSKL_bSM)
- {
- JSKL_bSM = 0;
- JSKL_SM_VAVLE = ~JSKL_SM_VAVLE;
- }
-
- if(JSKL_bTL)
- {
- JSKL_bTL = 0;
- if(JSKL_cMotorStep==0)JSKL_cMotorStep=20;
- }
-
- if(JSKL_bPJ)
- {
- JSKL_bPJ = 0;
- cManPJStep = 1;
- }
- switch(cManPJStep)
- {
- case 1:
- JSKL_PJ_VAVLE = 1;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- cManPJStep = 2;
- break;
- case 2:
- {
- if(JSKL_PJ_LIMIT_IN)
- {
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_PJ_DELAYBACK;
- cManPJStep = 3;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_PJ_LIMIT_ALARM);
- }break;
- case 3:
- {
- if(dwTickCount >= JSKL_cFDDelay)
- {
- JSKL_PJ_VAVLE = 0;
- cManPJStep = 0;
- }
- }break;
- }
- /* if(JSKL_bZDP)
- {
- JSKL_bZDP = 0;
- JSKL_ZDP_VAVLE =~JSKL_ZDP_VAVLE;
- }*/
-
- if(JSKL_bLTM)
- {
- JSKL_bLTM = 0;
- JSKL_LTM_VAVLE =~JSKL_LTM_VAVLE;
- }
-
- if(JSKL_bRTM)
- {
- JSKL_bRTM = 0;
- JSKL_RTM_VAVLE =~JSKL_RTM_VAVLE;
- }
-
- if(JSKL_bMotor)
- {
- JSKL_SZ_OUT = 0;
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS, JSKL_DIR_P, 5,5,10,10);
- }
- else
- {
- if(JSKL_cMotorStep == 0)
- {
- if(X_DRV)AxisDecStop(X_AXIS);
- }
- }
- }
- if(JSKL_PARAM_ZDP_ENABLE)
- JSKL_ZDP_VAVLE = 1;
- else
- JSKL_ZDP_VAVLE = 0;
- }
- unsigned char JSKL_SingleLeftWork(void)
- {
- if(JSKL_PARAM_SINGLE_MODE)
- {
- return 1;
- }
- else
- {
- if(cJSKL_left_enable)return 1;
- else return 0;
- }
- }
- unsigned char JSKL_SingleRightWork(void)
- {
- if(JSKL_PARAM_SINGLE_MODE)
- {
- return 1;
- }
- else
- {
- if(cJSKL_right_enable)return 1;
- else return 0;
- }
- }
- void JSKL_AutoAction(void)
- {
- if(bRunning)
- {
- switch(JSKL_cAutoStep)
- {
- case 0:
- break;
- case 1:
- if(dwTickCount >= JSKL_cAutoDelay)
- {
- JSKL_cAutoStep = 2;
- JSKL_cMotorStep = 1; //启动拖带
- }
- break;
- case 2:
- //拖带已经完成
- if(JSKL_cMotorStep == 0)
- {
- JSKL_cAutoStep = 3;
- }
- break;
- case 3:
- {
- if(JSKL_cFDStep == 0)
- {
- JSKL_cFDStep = 1; //分带动作启动
- JSKL_cAutoStep = 4;
- }
- }
- break;
- case 4:
- if(JSKL_cFDStep == 0)
- {
- JSKL_cAutoStep = 5;
- }
- break;
- case 5:
- {
- JSKL_cAutoStep = 6;
- }
- break;
- case 6:
- {
- JSKL_cAutoStep = 7;
- }
- break;
- case 7:
- {
- {
- JSKL_cAutoDelay = dwTickCount + JSKL_PARAM_DELAY_START;
- AddToTal(JSKL_TOTAL_ADDR);
- CalProSP(JSKL_PROSPEED_ADDR);
- cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
- cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
- JSKL_cAutoStep = 1;
- }
- }
- break;
- }
- }
- }
- // 检测是否踏了脚踏开关
- void JSKL_CheckStart(void)
- {
- DISPLAY_DATA0 = JSKL_cAutoStep;
- DISPLAY_DATA1 = JSKL_cMotorStep;
- DISPLAY_DATA2 = JSKL_cFDStep;
- DISPLAY_DATA3 = JSKL_cCheckLStep;
- DISPLAY_DATA4 = JSKL_cCheckRStep;
- DISPLAY_DATA5 = cJSKL_CheckLTimes;
- DISPLAY_DATA6 = cJSKL_CheckRTimes;
- DISPLAY_DATA7 = 0-dwRealPos;//dwRealPos;
- static unsigned short Fd_flg =0;
- static unsigned short Tm_flg = 0;
- if((START_IN_UP || JSKL_bStart || JSKL_bGZStart || JSKL_bOnceStart) && !bRunning && (JSKL_cAutoStep==0))
- {
- if(JSKL_FD_IN)
- JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
- else if(!JSKL_XM_ORIGIN_IN)
- JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
- else if(!JSKL_PJ_ORIGIN_IN)
- JSKL_SetAlarmCode(JSKL_PJ_ORIGIN_ALARM);
- else if(JSKL_SM_LIMIT_IN)
- JSKL_SetAlarmCode(JSKL_SM_LIMIT_ALARM);
- else
- {
- if(JSKL_bStart || JSKL_bOnceStart || JSKL_bStart || START_IN_UP)
- {
- JSKL_bStart = 0;
- JSKL_cAutoStep = 1;
- bRunning = 1;
- cJSKL_CheckRTimes = 0;
- cJSKL_CheckLTimes = 0;
- cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
- cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
- Fd_flg = 0;
- cBackFDFlag = 0;
- }
- if(JSKL_bGZStart)
- {
- JSKL_bGZStart = 0;
- JSKL_cAutoStep = 2;
- JSKL_cMotorStep = 40;
- bRunning = 1;
- cJSKL_CheckRTimes = 0;
- cJSKL_CheckLTimes = 0;
- cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
- cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
- Fd_flg = 0;
- cBackFDFlag = 0;
- }
- if(JSKL_bOnceStart)
- {
- JSKL_bOnceStart = 0;
- JSKL_cAutoStep = 2;
- JSKL_cMotorStep = 40;
- SingOneFlg = 1;
- bRunning = 1;
- cJSKL_CheckRTimes = 0;
- cJSKL_CheckLTimes = 0;
- cJSKL_left_enable = JSKL_PARAM_LEFT_ENABLE;
- cJSKL_right_enable = JSKL_PARAM_RIGHT_ENABLE;
- Fd_flg = 0;
- cBackFDFlag = 0;
- }
- else
- SingOneFlg = 0;
-
- SetAlarmCode(JSKL_ALARM_ADDR,JSKL_NO_ALARM);
- }
- }
-
- if(GetAlarmCode(JSKL_ALARM_ADDR) != 0)JSKL_FMQ_OUT = 1;
- else
- JSKL_FMQ_OUT = 0;
- //停止
- if(STOP_IN_UP || JSKL_bStop)
- {
- JSKL_cAutoStep = 0;
- JSKL_cMotorStep = 0;
- // JSKL_cCheckLStep = 0;
- // JSKL_cCheckRStep = 0;
- JSKL_cFDStep = 0;
- bRunning = 0;
- JSKL_bStop = 0;
- JSKL_FMQ_OUT = 0;
- JSKL_SM_VAVLE = 0;
-
- if(JSKL_XM_VAVLE)
- {
- cBackFDFlag = 1;
- JSKL_FD_VAVLE = 1;
-
- if(JSKL_L_QL_IN)cErrorLflg = 1;
- else
- cErrorLflg = 0;
- if(JSKL_R_QL_IN)cErrorRflg = 1;
- else
- cErrorRflg = 0;
- if(cJSKL_left_enable)
- {
- if(cErrorLflg)
- {
- cErrorLflg = 0;
- JSKL_LTM_VAVLE = 0;
- }
- else
- {
- if(JSKL_cCheckLStep==0)
- {
- JSKL_cCheckLStep=2;
- JSKL_LTM_VAVLE = 1;
- JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
-
- }
- }
- }
- else
- {
- if(JSKL_cCheckLStep==0)
- {
- JSKL_cCheckLStep=2;
- JSKL_LTM_VAVLE = 1;
- JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
-
- }
- }
-
- if(cJSKL_right_enable)
- {
- if(cErrorRflg)
- {
- cErrorRflg = 0;
- JSKL_RTM_VAVLE = 0;
- }
- else
- {
- if(JSKL_cCheckRStep==0)
- {
- JSKL_cCheckRStep=2;
- JSKL_RTM_VAVLE = 1;
- JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
- }
- }
- }
- else
- {
- if(JSKL_cCheckRStep==0)
- {
- JSKL_cCheckRStep=2;
- JSKL_RTM_VAVLE = 1;
- JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
- }
- }
- if(!cJSKL_left_enable || !cJSKL_right_enable)
- {
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_ALL_BACK + JSKL_PARAM_DELAY_FD_BACK2;
- }
- else
- {
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_FD_BACK2;
- }
- }
- else
- {
- /*
- if(JSKL_SingleLeftWork())
- {
- if(!cCheckOkLFlg)JSKL_LTM_VAVLE = 1;
- }
- if(JSKL_SingleRightWork())
- {
- if(!cCheckOkRFlg)JSKL_RTM_VAVLE = 1;
- }
- */
- cStopFlg = 1;
- }
- // if(!JSKL_SM_LIMIT_IN )JSKL_XM_VAVLE = 0;
- JSKL_PJ_VAVLE = 0;
- JSKL_SZ_OUT = 1;
- SingOneFlg = 0;
- cStopFlg = 1;
- SetAlarmCode(JSKL_ALARM_ADDR,JSKL_NO_ALARM);
- }
- if(Fd_flg)
- {
- if(dwTickCount >= JSKL_cFDDelay)
- {
- Fd_flg = 0;
- JSKL_FD_VAVLE = 0;
- JSKL_GZ_VAVLE = 0;
- }
- }
- if(cStopFlg)
- {
- if(JSKL_XM_ORIGIN_IN)
- {
- cStopFlg = 0;
- if(cJSKL_left_enable)
- {
- if((JSKL_cCheckLStep==0))
- {
- JSKL_LTM_VAVLE = 1;
- JSKL_cCheckLStep=2;
- JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
- }
- }
- else
- {
- JSKL_LTM_VAVLE = 0;
- }
- if(cJSKL_right_enable)
- {
-
- if((JSKL_cCheckRStep==0))
- {
- JSKL_RTM_VAVLE = 1;
- JSKL_cCheckRStep=2;
- JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
- }
- }
- else
- {
- JSKL_RTM_VAVLE = 0;
- }
- Fd_flg = 1;
- JSKL_cFDDelay = dwTickCount + 50;
- }
- }
-
- if(cBackFDFlag)
- {
- if(SingOneFlg)
- {
- cBackFDFlag = 0;
- JSKL_XM_VAVLE = 0;
- Tm_flg = 1;
- SingOneFlg = 0;
- }
- else
- {
- if(JSKL_FD_IN)
- {
- cBackFDFlag = 0;
- JSKL_XM_VAVLE = 0;
- Tm_flg = 1;
-
- }
- }
- }
-
- if(Tm_flg)
- {
- if(!JSKL_XM_LIMIT_IN)
- {
- Tm_flg = 0;
- JSKL_LTM_VAVLE = 0;
- JSKL_RTM_VAVLE = 0;
- }
- }
- if(JSKL_bAlarmStop)
- {
- JSKL_bAlarmStop = 0;
- JSKL_cFDStep = 0;
- JSKL_cCheckLStep = 0;
- JSKL_cCheckRStep = 0;
- bRunning = 0;
- JSKL_cAutoStep = 0;
- JSKL_cMotorStep = 0;
- SingOneFlg = 0;
- }
- }
- //高速输入X31/X17外部色标信号中断
- void JSKL_ExtiActionX31(void)
- {
- }
- long JSKL_GetMod(long dist0,long dist1)
- {
- if(dist0 > dist1)return(dist0-dist1);
- else return(dist1-dist0);
- }
- void JSKL_Motor(void)
- {
- static long save_dist;
- dwRealPos = GetPos(X_AXIS);
- switch(JSKL_cMotorStep)
- {
- case 0:break;
- case 1:
- if(JSKL_SZ_OUT)
- {
- JSKL_SZ_OUT = 0;
- JSKL_cMotorDelay = dwTickCount + 100;
- }
- JSKL_cMotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= JSKL_cMotorDelay)
- {
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,JSKL_DIR_P,JSKL_PARAM_HIGH_SPEED,1,10,1);
- JSKL_cMotorDelay = dwTickCount + JSKL_PARAM_ZIPPER_TIME+200;
- JSKL_cMotorStep = 3;
- }
- break;
- case 40:
- if(JSKL_SZ_OUT)
- {
- JSKL_SZ_OUT = 0;
- JSKL_cMotorDelay = dwTickCount + 100;
- }
- JSKL_cMotorStep = 41;
- break;
- case 41:
- if(dwTickCount >= JSKL_cMotorDelay)
- {
- if(!X_DRV)MoveAction_Const_AccDec(X_AXIS,JSKL_DIR_P,JSKL_PARAM_HIGH_SPEED,1,10,1);
- JSKL_cMotorStep = 4;
- }
- break;
- case 3:
- if(JSKL_GuoLian_IN_DW)
- {
- JSKL_cMotorDelay = dwTickCount + JSKL_PARAM_GZ_DELAY;
- JSKL_cMotorStep = 4;
- }
- else if(dwTickCount >= JSKL_cMotorDelay)
- JSKL_SetAlarmCode(JSKL_GUOLIAN_ALARM);
- break;
- case 4:
- if(dwTickCount >= JSKL_cMotorDelay)
- {
- JSKL_GZ_VAVLE = 1;
- JSKL_cMotorDelay = dwTickCount + 3000;
- JSKL_cGLCheckDelay = dwTickCount + JSKL_PARAM_DELAY_CHECK;
- JSKL_cMotorStep = 5;
- }
- break;
- case 5:
- {
- if(JSKL_GZ_ORIGIN_IN_DW)
- {
- if(X_DRV)MoveChangSpeed(X_AXIS,JSKL_PARAM_LOW_SPEED);
- JSKL_cMotorDelay = dwTickCount + 3000;
- JSKL_cMotorStep = 6;
- }
- else if((dwTickCount >= JSKL_cMotorDelay) || ((JSKL_GuoLian_IN_UP || JSKL_GuoLian_IN_DW) && (dwTickCount >= JSKL_cGLCheckDelay)))
- JSKL_SetAlarmCode(JSKL_GZ_ALARM);
- }break;
- case 6:
- {
- if(!JSKL_GZ_IN)
- {
- save_dist = dwRealPos;
-
- if(JSKL_PARAM_STOP_DELAY==0)
- {
- AxisEgmStop(X_AXIS);
- JSKL_cMotorStep = 8;
- }
- else
- JSKL_cMotorStep = 7;
- }
- else if((dwTickCount >= JSKL_cMotorDelay) || ((JSKL_GuoLian_IN_UP || JSKL_GuoLian_IN_DW) && (dwTickCount >= JSKL_cGLCheckDelay)))
- JSKL_SetAlarmCode(JSKL_GZ_ALARM);
- }break;
- case 7:
- {//位置是负
- if(JSKL_GetMod(save_dist,dwRealPos) >= JSKL_PARAM_STOP_DELAY)
- {
- AxisEgmStop(X_AXIS);
- JSKL_cMotorStep = 8;
- }
- }break;
- case 8:
- {
- if(!X_DRV)
- {
- JSKL_cMotorStep = 0;
- JSKL_cMotorDelay = dwTickCount;
- }
- }break;
- case 20:
- {
- if(JSKL_SZ_OUT)
- {
- JSKL_SZ_OUT = 0;
- JSKL_cMotorDelay = dwTickCount + 130;
- }
- else
- JSKL_cMotorDelay = dwTickCount;
- JSKL_cMotorStep = 21;
- }
- break;
- case 21:
- if(dwTickCount >= JSKL_cMotorDelay)
- {
- if(!X_DRV)AxisMovePosAccDec(X_AXIS,20,JSKL_PARAM_FZ_LENGTH,1,10,10);
- JSKL_cMotorDelay = dwTickCount + 5000;
- JSKL_cMotorStep = 22;
- }
- break;
- case 22:
- // if(JSKL_GZ_ORIGIN_IN)JSKL_SetAlarmCode(JSKL_TL_ALARM);
-
- if(JSKL_GZ_ORIGIN_IN)
- {
- JSKL_LTM_VAVLE = 0;
- JSKL_RTM_VAVLE = 0;
- JSKL_cMotorStep = 0;
- JSKL_cMotorDelay = dwTickCount;
- }
- else if(dwTickCount >= JSKL_cMotorDelay)
- JSKL_SetAlarmCode(JSKL_GZ_ALARM);
- break;
- default:;
- }
-
- }
- void JSKL_Check(void)
- {
- switch(JSKL_cCheckLStep)
- {
- case 0:break;
- case 1:
- {
- if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1;
- JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_TM_TIME;
- JSKL_cCheckLStep = 2;
- }break;
- case 2:
- {
- if(dwTickCount >= JSKL_cCheckLDelay)
- {
- JSKL_LTM_VAVLE = 0;
- JSKL_cCheckLDelay = dwTickCount + JSKL_PARAM_DELAY_TM_BACK;
- JSKL_cCheckLStep = 3;
- }
- }break;
- case 3:
- {
- if((dwTickCount >= JSKL_cCheckLDelay))
- {
- JSKL_cCheckLStep = 0;
- }
- }break;
- }
-
- switch(JSKL_cCheckRStep)
- {
- case 0:break;
- case 1:
- {
- if(JSKL_SingleRightWork())JSKL_RTM_VAVLE = 1;
- JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_TM_TIME;
- JSKL_cCheckRStep = 2;
- }break;
- case 2:
- {
- if(dwTickCount >= JSKL_cCheckRDelay)
- {
- JSKL_RTM_VAVLE = 0;
- JSKL_cCheckRDelay = dwTickCount + JSKL_PARAM_DELAY_TM_BACK;
- JSKL_cCheckRStep = 3;
- }
- }break;
- case 3:
- {
- if(dwTickCount >= JSKL_cCheckRDelay)
- {
- JSKL_cCheckRStep = 0;
- }
- }
- break;
- }
- }
- void JSKL_FD_Action(void)
- {
- unsigned short length_buff;
- static unsigned short xm_times = 0;
- static unsigned char jl_flg;
- static unsigned char tm_flg;
-
-
-
- if(JSKL_XM_LIMIT_IN_UP) JSKL_SM_VAVLE = 1;
- if(JSKL_SM_LIMIT_IN_DW)JSKL_XM_VAVLE = 0;
-
-
- if(tm_flg)
- {
- if(JSKL_XM_ORIGIN_IN)
- {
- if(cJSKL_left_enable)JSKL_LTM_VAVLE = 1;
- if(cJSKL_right_enable)JSKL_RTM_VAVLE = 1;
- tm_flg = 0;
- }
- }
-
- if(jl_flg)
- {
- if(JSKL_XM_ORIGIN_IN && !JSKL_XM_VAVLE) //X07 下模退到位
- {
- jl_flg = 0;
- if(!cJSKL_left_enable)JSKL_LTM_VAVLE = 0;
- else
- {
- if(JSKL_cCheckLStep == 0)JSKL_cCheckLStep = 1;
- }
- if(!cJSKL_right_enable)JSKL_RTM_VAVLE = 0;
- else
- {
- if(JSKL_cCheckRStep == 0)JSKL_cCheckRStep = 1;
- }
- }
- }
- switch(JSKL_cFDStep)
- {
- case 0:break;
- case 1:
- {
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_FD_DELAY;
- JSKL_cFDStep = 2;
- }break;
- case 2:
- {
- if(dwTickCount >= JSKL_cFDDelay)
- {
- if(JSKL_PARAM_FD_ENABLE)JSKL_FD_VAVLE = 1;
- JSKL_cXMDelay = dwTickCount + JSKL_PARAM_DELAY_TM_BACK;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 3;
- }
- }break;
- case 3:
- {
- if((JSKL_FD_IN || (JSKL_PARAM_FD_ENABLE==0)))// && (dwTickCount >= JSKL_cXMDelay)) //分带到位
- {
- if((JSKL_cCheckLStep == 0) && (JSKL_cCheckRStep == 0))
- {
- JSKL_XM_VAVLE = 1; // 下模Y03
- cCheckOkLFlg = 0;
- cCheckOkRFlg = 0;
- JSKL_cFDDelay = dwTickCount + 1000;
- JSKL_cFDStep = 4;
- }
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- {
- JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
- }
- }break;
- case 4:
- {
- /*
- if(!cJSKL_left_enable && !cJSKL_right_enable ) //双边同时不选择
- {
- // if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1; //左入料Y06
- // if(JSKL_SingleRightWork())JSKL_RTM_VAVLE = 1; //右入料Y07
- JSKL_LTM_VAVLE = 0; //左入料Y06
- JSKL_RTM_VAVLE = 0; //右入料Y07
- cCheckOkLFlg = 1;
- cCheckOkRFlg = 1;
- }
- else if(cJSKL_left_enable && !cJSKL_right_enable)
- {
- cCheckOkRFlg = 1;
- if(JSKL_L_QL_IN) //左有料检测 X13
- {
- JSKL_LTM_VAVLE = 0;
- cCheckOkLFlg = 1;
- cJSKL_CheckLTimes = 0;
- }
- else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES) //检测次数
- {
- JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
- }
- }
- else if(!cJSKL_left_enable && cJSKL_right_enable)
- {
- cCheckOkLFlg = 1;
- if(JSKL_R_QL_IN) //右有料检测 X14
- {
- JSKL_RTM_VAVLE = 0;
- cCheckOkRFlg = 1;
- cJSKL_CheckRTimes = 0;
- }
- else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
-
- }
- }
- else
- {
- if(JSKL_L_QL_IN)
- {
- JSKL_LTM_VAVLE = 0;
- cCheckOkLFlg = 1;
- cJSKL_CheckLTimes = 0;
- }
- else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
-
- }
- if(JSKL_R_QL_IN)
- {
- JSKL_RTM_VAVLE = 0;
- cCheckOkRFlg = 1;
- cJSKL_CheckRTimes = 0;
- }
- else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
-
- }
- }
- */
-
- //下模到位X06 锁模到位 X10
- if(JSKL_XM_LIMIT_IN && JSKL_SM_LIMIT_IN)
- {
- if(!cJSKL_left_enable && !cJSKL_right_enable ) //双边同时不选择
- {
- // if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1; //左入料Y06
- // if(JSKL_SingleRightWork())JSKL_RTM_VAVLE = 1; //右入料Y07
- JSKL_LTM_VAVLE = 0; //左入料Y06
- JSKL_RTM_VAVLE = 0; //右入料Y07
- cCheckOkLFlg = 1;
- cCheckOkRFlg = 1;
- }
- else if(cJSKL_left_enable && !cJSKL_right_enable)
- {
- cCheckOkRFlg = 1;
- if(JSKL_L_QL_IN) //左有料检测 X13
- {
- JSKL_LTM_VAVLE = 0;
- cCheckOkLFlg = 1;
- cJSKL_CheckLTimes = 0;
- }
- else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES) //检测次数
- {
- JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
- break;
- }
- }
- else if(!cJSKL_left_enable && cJSKL_right_enable)
- {
- cCheckOkLFlg = 1;
- if(JSKL_R_QL_IN) //右有料检测 X14
- {
- JSKL_RTM_VAVLE = 0;
- cCheckOkRFlg = 1;
- cJSKL_CheckRTimes = 0;
- }
- else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
- break;
- }
- }
- else
- {
- if(JSKL_L_QL_IN)
- {
- JSKL_LTM_VAVLE = 0;
- cCheckOkLFlg = 1;
- cJSKL_CheckLTimes = 0;
- }
- else if(cJSKL_CheckLTimes >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_TM_LEFT_ALARM);
- break;
- }
- if(JSKL_R_QL_IN)
- {
- JSKL_RTM_VAVLE = 0;
- cCheckOkRFlg = 1;
- cJSKL_CheckRTimes = 0;
- }
- else if(cJSKL_CheckRTimes >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_TM_RIGHT_ALARM);
- break;
- }
- }
-
-
-
- xm_times = 0;
- if(cCheckOkLFlg && cCheckOkRFlg) //两边同时OK
- {
- if(cJSKL_left_enable && !cJSKL_right_enable)
- {
- if(JSKL_SingleRightWork()) JSKL_RTM_VAVLE = 1; //
- }
- else if(!cJSKL_left_enable && cJSKL_right_enable)
- {
- if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1;
-
- }
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_FD_BACK; //
- JSKL_cFDStep = 5;
- }
- else
- {
-
- JSKL_SM_VAVLE = 0; //Y04 锁模关
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- if(cJSKL_left_enable && !cJSKL_right_enable) //选择左边,
- {
- //if(JSKL_SingleRightWork())
- JSKL_LTM_VAVLE = 1;
- JSKL_RTM_VAVLE = 1;
- JSKL_cFDStep = 40;
- }
- else if(!cJSKL_left_enable && cJSKL_right_enable) //选择右边
- {
- // if(JSKL_SingleLeftWork())JSKL_LTM_VAVLE = 1;
- JSKL_LTM_VAVLE = 1;
- JSKL_RTM_VAVLE = 1;
- JSKL_cFDStep = 50;
- }
- else //两边选择
- {
- JSKL_cFDStep = 60;
- if(!cCheckOkLFlg)
- JSKL_LTM_VAVLE = 1;
- if(!cCheckOkRFlg)
- JSKL_RTM_VAVLE = 1;
- }
-
- }
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- {
- if(xm_times >= JSKL_PARAM_TM_TIMES)
- {
- JSKL_SetAlarmCode(JSKL_XM_LIMIT_ALARM);
- }
- else
- {
- xm_times++;
- JSKL_XM_VAVLE = 0;
- JSKL_cFDStep = 70;
- JSKL_cXMDelay = dwTickCount + 250;
- }
-
- }
- }break;
- case 70:
- if(JSKL_XM_ORIGIN_IN && (dwTickCount >= JSKL_cXMDelay))
- {
- if((JSKL_cCheckLStep== 0) && cJSKL_left_enable)
- JSKL_cCheckLStep = 1;
- if((JSKL_cCheckRStep == 0) && cJSKL_right_enable)
- JSKL_cCheckRStep = 1;
- JSKL_cFDStep = 3;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- }
- break;
- case 40:
-
- if(JSKL_XM_LIMIT_IN_DW)
- JSKL_RTM_VAVLE = 0;
- if(JSKL_XM_ORIGIN_IN)
- {
- JSKL_cFDStep = 41;
- if(JSKL_cCheckLStep == 0)JSKL_cCheckLStep = 1;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
-
- break;
- case 41:
- if(JSKL_cCheckLStep == 0)
- {
- JSKL_XM_VAVLE = 1;
- cJSKL_CheckLTimes++;
- JSKL_cFDStep = 42;
- }
- break;
- case 42:
- if(!JSKL_XM_ORIGIN_IN)
- {
- JSKL_cFDStep = 4;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- }
- break;
- case 50:
-
- if(JSKL_XM_LIMIT_IN_DW)
- JSKL_LTM_VAVLE = 0;
- if(JSKL_XM_ORIGIN_IN)
- {
- JSKL_cFDStep = 51;
- if(JSKL_cCheckRStep == 0)JSKL_cCheckRStep = 1;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
- break;
- case 51:
- if(JSKL_cCheckRStep == 0)
- {
- JSKL_XM_VAVLE = 1;
- cJSKL_CheckRTimes++;
- JSKL_cFDStep = 52;
- }
- break;
- case 52:
- if(!JSKL_XM_ORIGIN_IN)
- {
- JSKL_cFDStep = 4;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- }
- break;
- case 60:
- if(JSKL_XM_ORIGIN_IN)
- {
- JSKL_cFDStep = 61;
-
- if(!cCheckOkRFlg)
- {
- if(JSKL_cCheckRStep == 0)JSKL_cCheckRStep = 1;
- cJSKL_CheckRTimes++;
- }
-
- if(!cCheckOkLFlg)
- {
- if(JSKL_cCheckLStep == 0)JSKL_cCheckLStep = 1;
- cJSKL_CheckLTimes++;
- }
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_XM_ORIGIN_ALARM);
- break;
- case 61:
- if((JSKL_cCheckRStep == 0) && (JSKL_cCheckLStep == 0))
- {
- JSKL_XM_VAVLE = 1;
- JSKL_cFDStep = 62;
- }
- break;
- case 62:
- if(!JSKL_XM_ORIGIN_IN)
- {
- JSKL_cFDStep = 4;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- }
- break;
- case 5:
- if(dwTickCount >= JSKL_cFDDelay)
- {
-
- JSKL_FD_VAVLE = 0; //Y02分带退
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 6;
- }
- break;
- case 6:
- {
- if(!JSKL_FD_IN) //分带到位信号离开
- {
- if(!X_DRV)AxisMovePosAccDec(X_AXIS,20,-JSKL_PARAM_FD_GO_LENGTH,1,10,10);
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_FZ_DELAY; //P05延时反转
- JSKL_cPJDelay = dwTickCount + JSKL_PARAM_PJ_DELAY;
- JSKL_cFDStep = 7;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
- }break;
- case 7:
- {
- if((dwTickCount >= JSKL_cFDDelay) && !X_DRV)
- {
- JSKL_cMotorStep = 20;
- JSKL_cFDStep = 8;
- }
- }break;
- case 8:
- {
-
- if(((X_DRV) || (JSKL_cMotorStep == 0)) && (dwTickCount >= JSKL_cPJDelay))
- {
- if(SingOneFlg && bRunning)
- {
-
- JSKL_cAutoStep = 0;
- JSKL_cFDStep = 0;
- bRunning = 0;
- }
- else
- {
- JSKL_cFDStep = 100;
- // JSKL_cFDDelay = dwTickCount + JSKL_PARAM_PJ_DELAY;
- }
- }
- }break;
- case 100:
- if(dwTickCount >= JSKL_cFDDelay)
- {
- JSKL_PJ_VAVLE = 1;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 9;
-
- }
- break;
- case 9:
- {
- if(JSKL_PJ_ORIGIN_IN)JSKL_cPJDelay = dwTickCount + 40;
-
- if((dwTickCount >= JSKL_cPJDelay) && !JSKL_PJ_ORIGIN_IN)
- {
- JSKL_LTM_VAVLE = 0;
- JSKL_RTM_VAVLE = 0;
- }
- if(JSKL_PJ_LIMIT_IN)
- {
- AxisEgmStop(X_AXIS);
- JSKL_cMotorDelay = dwTickCount;
- JSKL_cMotorStep = 0;
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_PJ_DELAYBACK;
- JSKL_cFDStep = 10;
-
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_PJ_LIMIT_ALARM);
- }break;
- case 10:
- {
- if(dwTickCount >= JSKL_cFDDelay)
- {
- JSKL_PJ_VAVLE = 0; //迫紧关
-
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 11;
- if(JSKL_PARAM_PJ_PUSH_LENGTH > JSKL_PARAM_FZ_LENGTH)length_buff = JSKL_PARAM_FZ_LENGTH- 10;
- else length_buff = JSKL_PARAM_PJ_PUSH_LENGTH;
- if(!X_DRV)AxisMovePosAccDec(X_AXIS,20,-length_buff,1,10,10);
- JSKL_FD_VAVLE = 1; //分带输出
- JSKL_LTM_VAVLE = 1;//左进料打开
- JSKL_RTM_VAVLE = 1;//右进料打开
-
-
- }
- }break;
- case 11:
- {
- if(!JSKL_PJ_LIMIT_IN)
- {
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 12;
- JSKL_SM_VAVLE = 0; //锁模关
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_PJ_LIMIT_ALARM);
- }break;
- case 12:
- {
- if(JSKL_PJ_ORIGIN_IN&&!X_DRV)
- {
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 13;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_PJ_ORIGIN_ALARM);
- }break;
- case 13:
- if(JSKL_FD_IN)
- {
- JSKL_cFDStep = 14;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
-
- break;
- case 14:
- {
- if(!JSKL_SM_LIMIT_IN)
- {
- JSKL_XM_VAVLE = 0;
- jl_flg = 1; //由下模退到位启动进料时间
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 15;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_SM_LIMIT_ALARM);
- }break;
- case 15:
- {
- if(!JSKL_XM_LIMIT_IN)
- {
- JSKL_FD_VAVLE = 0; //分带关
- tm_flg = 1;
- JSKL_LTM_VAVLE = 0;
- JSKL_RTM_VAVLE = 0;
- if(!cJSKL_left_enable || !cJSKL_right_enable)
- {
- JSKL_cFDStep = 16;
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_ALL_BACK+JSKL_PARAM_DELAY_FD_BACK2;
- }
- else
- {
- JSKL_cFDStep = 17;
- JSKL_cFDDelay = dwTickCount + JSKL_PARAM_DELAY_FD_BACK2;
- }
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- JSKL_SetAlarmCode(JSKL_XM_LIMIT_ALARM);
- }break;
- case 16:
- if((dwTickCount >= JSKL_cFDDelay))
- {
- // if(!cJSKL_left_enable)JSKL_LTM_VAVLE = 0; //不选择就关闭
- // if(!cJSKL_right_enable)JSKL_RTM_VAVLE = 0; //不选择就关闭
- JSKL_FD_VAVLE = 0;
- JSKL_GZ_VAVLE = 0;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 18;
- }
- break;
- case 17:
- {
- if(dwTickCount >= JSKL_cFDDelay)
- {
- // if(!cJSKL_left_enable)JSKL_LTM_VAVLE = 0; //不选择就关闭
- // if(!cJSKL_right_enable)JSKL_RTM_VAVLE = 0; //不选择就关闭
- JSKL_FD_VAVLE = 0;
- JSKL_GZ_VAVLE = 0;
- JSKL_cFDDelay = dwTickCount + JSKL_VAVLE_ALARM_TIME;
- JSKL_cFDStep = 18;
- }
- }break;
- case 18:
- {
- if(!JSKL_FD_IN)
- {
- JSKL_cFDStep = 0;
- JSKL_cFDDelay = dwTickCount;
- }
- else if(dwTickCount >= JSKL_cFDDelay)
- {
- JSKL_SetAlarmCode(JSKL_FD_LIMIT_ALARM);
- }
- }break;
- default:;
- }
- }
- #endif
|