123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 |
- #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);
- void ChuanTou_ZhuangLiaoStep(void);
- void ChuanTou_CLT_Step(void);
- void ChuanTou_ZhenDongAction(void);
- static unsigned char cSongLiaoOk = 0;
- static unsigned char cZhuangLiaoOk = 0;
- static unsigned char cZLCnt = 0;
- void CT_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(CT_ALARM_ADDR,alarm_code);
- bAlarmStop = 1;
- }
- void ChuanTou_InitAction(void)
- {
- float length_buff,pulse_buff;
-
- length_buff = CT_PARAM_CYCLE_LENGTH;
- pulse_buff = CT_PARAM_CYCLE_PULSE;
-
- XGearRatio = pulse_buff/length_buff;
- YGearRatio = 1;
-
- if(CT_PARAM_CR_MODE)
- {
- if(!CT_CR_ORIGIN_IN)
- {
- if(CT_MotorStep == 0)CT_MotorStep = 100;
- }
- }
- }
- void ChuanTou_Action(void)
- {
- ChuanTou_AlarmProtect();
- ChuanTou_StepCheckStart(); // 调用脚踏开关检测程序
- ChuanTou_Motor();
- ChuanTou_ManualAction();
- ChuanTou_AutoAction();
- ChuanTou_CLT_Step();
- ChuanTou_ZhenDongAction();
- ChuanTou_SongLiaoAction();
- }
- //手动动作
- void ChuanTou_ManualAction(void)
- {
- if(bRunning == 0)
- {
- if(bClearTotal) //切断计数清零
- {
- bClearTotal = 0;
- ClrcToTal(CT_TOTAL_ADDR);
- }
-
- if(CT_bFD)
- {
- CT_bFD = 0;
- CT_FD_VAVLE = ~CT_FD_VAVLE;
- }
-
- if(CT_bXM)
- {
- CT_bXM = 0;
- CT_XM_VAVLE = ~CT_XM_VAVLE;
- }
-
- if(CT_bQYD)
- {
- CT_bQYD = 0;
- CT_QYD_VAVLE = ~CT_QYD_VAVLE;
- }
-
- if(CT_bHYD)
- {
- CT_bHYD = 0;
- CT_HYD_VAVLE = ~CT_HYD_VAVLE;
- }
- if(CT_bSL)
- {
- CT_bSL = 0;
- if(CT_SL_Step == 0)
- {
- cSongLiaoOk = 0;
- CT_SL_Step = 1;
- }
- }
-
- if(CT_bHL)
- {
- CT_bHL = 0;
- CT_HL_VAVLE = ~CT_HL_VAVLE;
- }
-
- if(CT_bCR)
- {
- CT_bCR = 0;
- CT_CR_VAVLE = ~CT_CR_VAVLE;
- }
-
-
- if(CT_bHSL)
- {
- CT_bHSL = 0;
- CT_HSL_VAVLE = ~CT_HSL_VAVLE;
- }
-
- if(CT_bZL)
- {
- CT_bZL = 0;
- if(CT_ZL_Step == 0)
- {
- cSongLiaoOk = 1;
- cZhuangLiaoOk = 0;
- CT_ZL_Step = 1;
- }
- }
-
- if(CT_bCLT)
- {
- CT_bCLT = 0;
- if(CT_CLT_Step == 0)CT_CLT_Step = 1;
- }
-
- if(CT_bCT_XM)
- {
- CT_bCT_XM = 0;
- }
-
- if(CT_bDW)
- {
- CT_bDW = 0;
- if(CT_MotorStep == 0)CT_MotorStep = 1;
- }
-
- if(CT_bAuto_ZL)
- {
- CT_bAuto_ZL = 0;
- }
-
- if(CT_bHM)
- {
- CT_bHM = 0;
- }
-
- if(CT_bMotor)
- {
- if(!X_DRV)AxisContinueMove(X_AXIS,20,CT_DIR_N);
- }
-
- if((QD_MotorStep == 0) && !CT_bMotor && (CT_AutoStep == 0))
- {
- if(X_DRV)AxisEgmStop(X_AXIS);
- }
-
- if(CT_bZDP)
- {
- CT_bZDP = 0;
- CT_ZDP_Delay = dwTickCount + CT_PARAM_ZDP_TIME;
- CT_ZDP_OUT = 1;
- }
- }
-
- }
- void ChuanTou_AlarmProtect(void)
- {
- }
- //振动盘控制
- void ChuanTou_ZhenDongAction(void)
- {
- if(bRunning)
- {
- if(CT_PARAM_ZDP_MODE)
- {
- if(CT_ZDP_IN_UP && (CT_ZDP_OUT == 0))
- {
- CT_ZDP_OUT = 1;
- CT_ZDP_Delay = dwTickCount + CT_PARAM_ZDP_TIME;
- }
-
- if((dwTickCount >= CT_ZDP_Delay) && CT_ZDP_OUT)
- {
- CT_ZDP_OUT = 0;
- }
- }
- else
- {
- if(CT_ZDP_IN_DW)CT_ZDP_OUT = 0;
- if(CT_ZDP_IN_UP)CT_ZDP_OUT = 1;
- }
- }
- else
- {
- if(CT_ZDP_IN_UP && (CT_ZDP_OUT == 0))
- {
- CT_ZDP_OUT = 1;
- CT_ZDP_Delay = dwTickCount + CT_PARAM_ZDP_TIME;
- }
-
- if((dwTickCount >= CT_ZDP_Delay) && CT_ZDP_OUT)
- {
- CT_ZDP_OUT = 0;
- }
- }
- }
- //送料
- void ChuanTou_SongLiaoAction(void)
- {
- switch(CT_SL_Step)
- {
- case 1:
- {
- if(cSongLiaoOk)
- {
- CT_SL_Step = 0;
- }
- else
- {
- CT_SL_Step = 2;
- CT_SL_Delay = dwTickCount + 1000;
- }
- }break;
- case 2:
- {
- if(CT_SL_ORIGIN_IN && CT_CR_ORIGIN_IN && CT_XM_ORIGIN_IN)
- {
- CT_SL_VAVEL = 1;
- CT_SL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_SL_Step = 3;
- }
- else if(dwTickCount >= CT_SL_Delay)
- {
- if(!CT_SL_ORIGIN_IN)CT_SetAlarmCode(CT_SL_ORIGIN_ALARM);
- else if(!CT_CR_ORIGIN_IN)CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- else if(!CT_XM_ORIGIN_IN)CT_SetAlarmCode(CT_XM_ORIGIN_ALARM);
- }
- }
- break;
- case 3:
- {
- if(CT_SL_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 4:
- {
- if(dwTickCount >= CT_SL_Delay)
- {
- CT_SL_VAVEL = 0;
- CT_SL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_SL_Step = 5;
- }
- }break;
- case 5:
- {
- if(!CT_SL_LIMIT_IN)
- {
- cSongLiaoOk = 1;
- CT_SL_Step = 0;
- }
- else if(dwTickCount >= CT_SL_Delay)
- {
- CT_SetAlarmCode(CT_SL_LIMIT_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_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_ZhuangLiaoStep(void)
- {
- switch(CT_ZL_Step)
- {
- case 1:
- {
- if(cZhuangLiaoOk)CT_ZL_Step = 0;
- else
- {
- CT_CR_VAVLE = 0;
- CT_ZL_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_ZL_Step = 2;
- }
- }break;
- case 2:
- {
- if(CT_CR_ORIGIN_IN)
- {
- if(CT_SL_Step == 0) CT_SL_Step = 1;
- CT_ZL_Step = 3;
- }
- else if(dwTickCount >= CT_ZL_Delay)
- {
- CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- }
- }
- break;
- case 3:
- {
- if(CT_SL_Step == 0)
- {
- CT_ZL_Step = 4;
- CT_ZL_Delay = dwTickCount + 1000;
- }
- }break;
- case 4:
- {
- if(CT_XM_ORIGIN_IN)
- {
- CT_XM_VAVLE = 1;
- cZLCnt++;
- CT_ZL_Delay = dwTickCount + 1000;
- CT_ZL_Step = 5;
- }
- else if(dwTickCount >= CT_ZL_Delay)
- CT_SetAlarmCode(CT_XM_ORIGIN_ALARM);
-
- }break;
- case 5:
- {
- if(CT_DZ_IN)
- {
- cZhuangLiaoOk = 1;
- cZLCnt = 0;
- CT_ZL_Step = 0;
- }
- else if(dwTickCount >= CT_ZL_Delay)
- {
- if(cZLCnt >= 2)
- {
- cSongLiaoOk = 0;
- cZhuangLiaoOk = 0;
- CT_SetAlarmCode(CT_DZ_ALARM);
- }
- else
- {
- cSongLiaoOk = 0;
- CT_XM_VAVLE = 0;
- CT_ZL_Step = 1;
- }
- }
- }
- break;
- default:;
- }
- }
- void ChuanTou_CLT_Step(void)
- {
- static long xm_buff;
- static long dwRealPosY;
-
- dwRealPosY = GetPos(Y_AXIS);
- switch(CT_CLT_Step)
- {
- case 1:
- CT_CLT_Delay = dwTickCount + 1000;
- CT_QYD_VAVLE = 1;
- CT_HYD_VAVLE = 1;
- CT_CLT_Step = 2;
- break;
- case 2:
- if(CT_CR_ORIGIN_IN)
- {
- CT_CLT_Delay = dwTickCount + CT_PARAM_FD_DELAY;
- CT_CLT_Step = 3;
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- break;
- case 3:
- if(dwTickCount >= CT_CLT_Delay)
- {
- CT_FD_VAVLE = 1;
- if(CT_PARAM_HL_ENABLE)CT_HL_VAVLE = 1;
- CT_CLT_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_CLT_Step = 4;
- }
- break;
- case 4:
- if(CT_FD_IN)
- {
- CT_CLT_Delay = dwTickCount + CT_PARAM_XM_DELAY;
- CT_CLT_Step = 5;
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_FD_IN_ALARM);
- break;
- case 5:
- if(dwTickCount >= CT_CLT_Delay)
- {
- if(CT_ZL_Step == 0)
- {
- CT_ZL_Step = 1;
- CT_CLT_Step = 6;
- }
- }
- break;
- case 6:
- if(CT_ZL_Step == 0)
- {
- if(CT_PARAM_CR_MODE == 0)
- {
- CT_CR_VAVLE = 1;
- CT_XM_BACK_Delay = dwTickCount + CT_PARAM_XM_BACK_DELAY;
- CT_CLT_Delay = dwTickCount + MOTOR_ALARM_TIME;
- CT_CLT_Step = 7;
- }
- else
- {
- xm_buff = dwRealPosY;
- CT_CRDR_OUT = CT_Y_DIR_P;
- if(!Y_DRV)AxisContinueMove(Y_AXIS,CT_PARAM_CR_SPEED,QD_DIR_P);
-
- CT_CLT_Delay = dwTickCount + MOTOR_ALARM_TIME;
- CT_CLT_Step = 20;
- }
- }
- break;
- case 7:
- if(dwTickCount >= CT_XM_BACK_Delay)CT_XM_VAVLE = 0;
-
- if(CT_CR_LIMIT_IN)
- {
- CT_XM_VAVLE = 0;
- CT_QYD_VAVLE = 0;
- CT_HYD_VAVLE = 0;
- CT_FD_VAVLE = 0;
- if(CT_PARAM_HL_ENABLE)CT_HL_VAVLE = 0;
- CT_CLT_Step = 8;
- CT_CLT_Delay = dwTickCount + VAVLE_ALARM_TIME;
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_CR_LIMIT_ALARM);
- break;
- case 8:
- if(!CT_FD_IN)
- {
- CT_CLT_Step = 9;
- CT_CLT_Delay = dwTickCount + CT_PARAM_CR_BACK_DELAY;
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_FD_IN_ALARM);
- break;
- case 9:
- if(dwTickCount >= CT_CLT_Delay)
- {
- if(CT_PARAM_CR_MODE == 0)
- {
- CT_CR_VAVLE = 0;
- CT_CLT_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_CLT_Step = 10;
- }
- else
- {
- CT_CRDR_OUT = CT_Y_DIR_N;
- if(!Y_DRV)AxisContinueMove(Y_AXIS,CT_PARAM_CR_SPEED,QD_DIR_N);
- CT_CLT_Delay = dwTickCount + VAVLE_ALARM_TIME;
- CT_CLT_Step = 30;
- }
- }
- break;
- case 10:
- if(CT_CR_ORIGIN_IN)
- {
- CT_CLT_Step = 0;
- cSongLiaoOk = 0; // 穿完回到位就可以送料
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- break;
- case 20:
- if((dwRealPosY - xm_buff) >= CT_PARAM_XM_BACK_DELAY)CT_XM_VAVLE = 0;
-
- if(CT_CR_LIMIT_IN)
- {
- AxisDecStop(Y_AXIS);
- CT_CLT_Step = 21;
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_CR_LIMIT_ALARM);
- break;
- case 21:
- if(!Y_DRV)
- {
- CT_CLT_Step = 7;
- }
- break;
- case 30:
- if(CT_CR_ORIGIN_IN)
- {
- AxisDecStop(Y_AXIS);
- CT_CLT_Step = 31;
- }
- else if(dwTickCount >= CT_CLT_Delay)
- CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- break;
- case 31:
- if(!Y_DRV)
- {
- CT_CLT_Step = 0;
- cSongLiaoOk = 0; // 穿完回到位就可以送料
- }
- 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 = 1;
- }
- }
- break;
- case 2:
- if(CT_MotorStep == 0)
- {
- CT_AutoStep = 3;
- }
- break;
- case 3:
- if((CT_MotorStep == 0) && (CT_CLT_Step == 0))
- {
- CT_CLT_Step = 1;
- CT_AutoStep = 4;
- }
- break;
- case 4:
- if((CT_CLT_Step == 0) || (CT_CLT_Step >= 10))
- {
- CT_AutoStep = 5;
- }
- break;
- case 5:
- dwZipCnt++;
- AddToTal(CT_TOTAL_ADDR);
- CalProSP(CT_PROSPEED_ADDR);
-
-
- if(SingOneFlg)
- {
- bRunning = 0;
- CT_AutoStep = 0;
- SingOneFlg = 0;
- }
- else
- {
- CT_AutoStep = 1;
- CT_AutoDelay = dwTickCount + CT_PARAM_CYCLE_DELAY;
- }
- break;
- }
- }
- }
- void ChuanTou_StepCheckStart(void)
- {
- // 启动
- if((CT_START_IN_UP) || bStart || CT_bSingle)
- {
- bStart = 0;
-
- if(!bRunning && (CT_AutoStep == 0))
- {
- if(CT_FD_IN)CT_SetAlarmCode(CT_FD_IN_ALARM);
- else if(CT_DZ_IN)CT_SetAlarmCode(CT_DZ_ALARM);
- else if(!CT_XM_ORIGIN_IN)CT_SetAlarmCode(CT_XM_ORIGIN_ALARM);
- else if(!CT_CR_ORIGIN_IN)CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- else if(!CT_SL_ORIGIN_IN)CT_SetAlarmCode(CT_SL_ORIGIN_ALARM);
- else if(CT_QYD_VAVLE | CT_HYD_VAVLE | CT_HL_VAVLE)CT_SetAlarmCode(CT_OUT_ALARM);
- {
- bRunning = 1;
-
- if(cZhuangLiaoOk)
- CT_AutoStep = 2;
- else
- CT_AutoStep = 1;
-
- if(CT_bSingle) SingOneFlg= 1;
- dwZipCnt = 0;
- }
- }
- CT_bSingle = 0;
- }
- //停止
- if(CT_STOP_IN_UP || bStop)
- {
- bStop = 0;
-
- if(bRunning)
- {
- bRunning = 0;
- CT_AutoStep = 0;
- CT_MotorStep = 0;
- CT_AutoDelay = dwTickCount;
- CT_MotorDelay = dwTickCount;
- AxisDecStop(X_AXIS);
- SingOneFlg = 0;
- }
- else
- {
- bRunning = 0;
- CT_AutoStep = 0;
- CT_MotorStep = 0;
- CT_HeMuStep = 0;
- CT_SL_Step = 0;
- CT_HSL_Step = 0;
- CT_ZL_Step = 0;
- CT_CLT_Step = 0;
- CT_ZD_Step = 0;
-
- CT_AutoDelay = dwTickCount;
- CT_MotorDelay = dwTickCount;
- CT_HeMuDelay = dwTickCount;
- CT_SL_Delay = dwTickCount;
- CT_HSL_Delay = dwTickCount;
- CT_ZL_Delay = dwTickCount;
- CT_XM_BACK_Delay = dwTickCount;
- CT_CLT_Delay = dwTickCount;
- CT_ZDP_Delay = dwTickCount;
-
- SingOneFlg = 0;
- AxisDecStop(X_AXIS);
-
- if(CT_PARAM_CR_MODE)//按停止电机复位
- {
- if(!CT_CR_ORIGIN_IN)
- {
- if(CT_MotorStep == 0)CT_MotorStep = 100;
- }
- }
-
- CT_SZ_OUT = CT_MOTOR_Y_DISEN;
- SetEn(X_AXIS,CT_MOTOR_DISEN);
-
- CT_FD_VAVLE = 0;
- CT_XM_VAVLE = 0;
- CT_SL_VAVEL = 0;
- CT_QYD_VAVLE = 0;
- CT_HL_VAVLE = 0;
- CT_HYD_VAVLE = 0;
- CT_CR_VAVLE = 0;
- CT_ZDP_OUT = 0;
- CT_HSL_VAVLE = 0;
-
- cSongLiaoOk = 0;
- cZhuangLiaoOk = 0;
- cZLCnt = 0;
- 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);
- AxisDecStop(Y_AXIS);
- }
-
- }
- //电机动作
- void ChuanTou_Motor(void) //
- {
- static long back_buff,save_buff;
-
- dwRealPos = GetPos(X_AXIS);
-
- switch(CT_MotorStep)
- {
- case 0:
- break;
- case 1:
- if(GetEn(X_AXIS) == CT_MOTOR_DISEN)
- {
- SetEn(X_AXIS,CT_MOTOR_DISEN);
- CT_SZ_OUT = CT_MOTOR_Y_EN;
- CT_MotorDelay = dwTickCount + 50;
- }
-
- CT_MotorStep = 2;
- break;
- case 2:
- if(dwTickCount >= CT_MotorDelay)
- {
- save_buff = dwRealPos;
- if(!X_DRV)AxisContinueMove(X_AXIS,CT_PARAM_HSPEED,QD_DIR_N);
- CT_MotorStep = 3;
- }
- break;
- case 3:
- if(CT_GUO_LIAN_IN_UP)
- {
- MoveChangSpeed(X_AXIS,CT_PARAM_LSPEED);
- CT_MotorStep = 4;
- }
- else if((dwRealPos - save_buff) >= CT_PARAM_MAX_LENGTH)
- CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- break;
- case 4:
- if(CT_GUO_LIAN_IN_DW)
- {
- back_buff = dwRealPos;
- CT_MotorStep = 5;
- }
- else if((dwRealPos - save_buff) >= CT_PARAM_MAX_LENGTH)
- CT_SetAlarmCode(CT_NO_ZIPPER_ALARM);
- break;
- case 5:
- if((dwRealPos - back_buff) >= CT_PARAM_STOP_LENGTH)
- {
- AxisEgmStop(X_AXIS);
- CT_MotorStep = 6;
- }
-
- break;
- case 6:
- if(!X_DRV)
- {
- CT_MotorStep = 0;
- }
- break;
- case 100: //穿入电机慢慢复位动作
- CT_CRDR_OUT = CT_Y_DIR_N;
- if(!Y_DRV)AxisContinueMove(Y_AXIS,10,QD_DIR_N);
-
- CT_MotorDelay = dwTickCount + MOTOR_ALARM_TIME;
- CT_MotorStep = 101;
- break;
- case 101:
- if(CT_CR_ORIGIN_IN)
- {
- AxisDecStop(Y_AXIS);
- CT_MotorStep = 102;
- }
- else if(dwTickCount >= CT_MotorDelay)
- CT_SetAlarmCode(CT_CR_ORIGIN_ALARM);
- break;
- case 102:
- if(!Y_DRV)
- {
- CT_MotorStep = 0;
- }
- break;
- }
- }
- #endif
|