123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891 |
- #include "global.h"
- #if CHANG_SHENG_GEI_LI_MACHINE
- long RealPosBuff = 0; //记录齿数
- unsigned long ToothNumBuff = 0;
- unsigned long RemainKongWeiToothNum = 0; // 空位剩余齿数
- unsigned char cFirstFlg = 0,cSeBiaoStep = 0;
- unsigned short SecondToothNum = 0;
- unsigned char cCntEn = 0;
- unsigned long dwSeBiaoDelayCnt = 0;
- void StopProc(void);
- void StartProc(void);
- unsigned long CalEncodePulse(void);
- void JYDC_DelayAction(void);
- void JYDC_InitAction(void);
- void JYDC_ExtiActionX30(void);
- void JYDC_Action(void);
- void ModeSelect(void);
- void JYDC_ChuiQi(void);
- void JYDC_XiaChong(void);
- void JYDC_SetAlarmCode(unsigned alarm_code);
- void JYDC_StartStopAction(void);
- void JYDC_AutoRunStep(void);
- unsigned long GetToothNum(unsigned long zipper_length);
- unsigned long JYDC_ToothGetLength(unsigned long tooth_num);
- unsigned char JYDC_STOP_IN_FLAG,JYDC_STOP_IN_FLAG_OLD,JYDC_STOP_FILTER;
- unsigned char cAccSpeed = 5;
- unsigned char cXC_OnceFlg = 0;
- void JYDC_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(JYDC_ALARM_ADDR,alarm_code);
- JYDC_bAlarmStop = 1;
- }
- void JYDC_DelayAction(void)
- {
- }
- void JYDC_InitAction(void)
- {
- if(MODE_SELECT > 3)MODE_SELECT = 0;
- ModeSelect();
- CUR_LEN_JY = 0;
- JYDC_STOP_IN_FLAG = STOP_IN;
- JYDC_STOP_IN_FLAG_OLD = JYDC_STOP_IN_FLAG;
- }
- //手动动作
- void JYDC_ManualAction(void)
- {
- //警告跳出
- if(bClearTotal)
- {
- bClearTotal = 0;
- ClrcToTal(JYDC_TOTAL_ADDR);
- }
-
- if(!JYDC_bRunning)
- {
- if(JYDC_bAddTooth)
- {
- JYDC_bAddTooth = 0;
- if(JYDC_PARAM_REVICHISHU < 65535)JYDC_PARAM_REVICHISHU++;
- }
-
- if(JYDC_bDecTooth)
- {
- JYDC_bDecTooth = 0;
- if(JYDC_PARAM_REVICHISHU != 0)JYDC_PARAM_REVICHISHU--;
- }
-
- if(JYDC_bManXiaChong || JYDC_ManXiaChong_UP)
- {
- JYDC_bManXiaChong = 0;
-
- if(JYDC_XiaChongStep == 0)//if(!JYDC_bRunning && !STOP_IN && !X_DRV && (JYDC_XiaChongStep == 0))
- {
- JYDC_XiaChongStep = 1;
- }
- }
-
- if(JYDC_bManSuoChi)
- {
- JYDC_bManSuoChi = 0;
- JYDC_SuoChi_VAVLE = ~JYDC_SuoChi_VAVLE;
- }
-
- if(JYDC_bManChuiQi)
- {
- JYDC_bManChuiQi = 0;
- JYDC_ChuiQi_VAVLE = 1;
- JYDC_ChuiQiDelay = dwTickCount + JYDC_PARAM_CHUIQI_TIME * 10;
- }
-
- if(JYDC_bChangeLength)
- {
- JYDC_bChangeLength = 0;
- ModeSelect();
- SetData32bits(31,CalInch(SET_ZIPPER_LENGTH));
- JYDC_PARAM_REVICHISHU = GetToothNum(SET_ZIPPER_LENGTH);
- CUR_LEN_JY = 0;
- cFirstFlg = 1;
- }
-
- if(JYDC_bSetInch)
- {
- JYDC_bSetInch = 0;
- SetData32bits(6,CalLengthCM(SET_ZIPPER_LENGTH_INCH));
- JYDC_bChangeLength = 1;
- }
-
- if(JYDC_bSetTooth)
- {
- JYDC_bSetTooth = 0;
- SetData32bits(6,JYDC_ToothGetLength(JYDC_PARAM_REVICHISHU));
- JYDC_bChangeLength = 1;
- }
- if(MACHINE_TYPE != JIAO_YA_CHU_CHI)
- {
- if(JYDC_bManXiChiMotor)
- {
- JYDC_bManXiChiMotor = 0;
- JYDC_XiChi_MOTOR = ~JYDC_XiChi_MOTOR;
- }
- }
- if(JYDC_bManGuaChiMotor)
- {
- if(!X_DRV)
- {
- JYDC_SuoChi_VAVLE = 0;
- AxisContinueMove(X_AXIS,JYDC_PARAM_SET_SPEED,0);
- }
- }
- else if(!JYDC_bManMotor)
- {
- if(X_DRV)
- {
- AxisEgmStop(X_AXIS);
- JYDC_SuoChi_VAVLE = 1;
- }
- }
-
- if(JYDC_bManMotor)
- {
- if(!X_DRV)
- {
- JYDC_SuoChi_VAVLE = 0;
- AxisContinueMove(X_AXIS,10,0);
- }
- }
- else if(!JYDC_bManGuaChiMotor)
- {
- if(X_DRV)
- {
- AxisEgmStop(X_AXIS);
- JYDC_SuoChi_VAVLE = 1;
- }
- }
- }
- }
- //高速输入X30/X16定时器中断
- void JYDC_ExtiActionX30(void)
- {
- CUR_LEN_JY++;
-
- if(JYDC_bRunning)
- {
- if(cAccSpeed > 1)cAccSpeed--;
- }
- if(JYDC_SEBIAO_MODE)
- {
- if(cSeBiaoStep == 1)
- {
- dwSeBiaoDelayCnt--;
- if(dwSeBiaoDelayCnt == 0)
- {
- CUR_LEN_JY = 0;
- cFirstFlg = 1;
- RemainKongWeiToothNum = SET_KOUWEI_JY;
- cSeBiaoStep = 2;
- }
- }
- else if(cSeBiaoStep == 2)
- {
- if((CUR_LEN_JY >= ToothNumBuff) && JYDC_bRunning)
- {
- AxisEgmStop(X_AXIS);
- if(JYDC_bTest)
- {
- JYDC_bRunning = 0;
- JYDC_AutoStep = 0;
- JYDC_SuoChi_VAVLE = 1;
- cSeBiaoStep = 0;
- }
- }
- }
- }
- else
- {
- if((CUR_LEN_JY >= ToothNumBuff) && JYDC_bRunning)
- {
- AxisEgmStop(X_AXIS);
- if(JYDC_bTest)
- {
- JYDC_bRunning = 0;
- JYDC_AutoStep = 0;
- JYDC_SuoChi_VAVLE = 1;
- }
- }
- }
- }
- //高速输入X31/X17外部色标信号中断
- void JYDC_ExtiActionX31(void)
- {
- if(cSeBiaoEn)
- { cSeBiaoEn = 0;
- dwSeBiaoDelayCnt = JYDC_SEBIAO_DELAY;
- if(dwSeBiaoDelayCnt == 0)
- {
- CUR_LEN_JY = 0;
- cFirstFlg = 1;
- RemainKongWeiToothNum = SET_KOUWEI_JY;
- cSeBiaoStep = 2;
- }
- else
- {
- cSeBiaoStep = 1;
- }
- }
- }
- //胶牙定寸动作
- void JYDC_Action(void)
- {
- if((JYDC_COUNT_IN_DW && JYDC_COUNT_DIR) || (JYDC_COUNT_IN_UP && !JYDC_COUNT_DIR))
- {
- JYDC_ExtiActionX30();
- }
- JYDC_ManualAction();
- JYDC_ChuiQi();
- JYDC_XiaChong();
- JYDC_StartStopAction();
- JYDC_AutoRunStep();
- }
- void ModeSelect(void)
- {
- switch(MODE_SELECT) //模具选择
- {
- case 0: //3#模具
- JY_JIZHUN_CISHU = JY_JIZHUN_CISHU1;//基准长度对应齿数
- JY_JIZHUN_LEN = JY_JIZHUN_LEN1;//基准长度
- SET_DAOKOU_JY = SET_DAOKOU_JY1; //机械模具刀口
- break;
- case 1: //5#模具
- JY_JIZHUN_CISHU = JY_JIZHUN_CISHU2;//基准长度对应齿数
- JY_JIZHUN_LEN = JY_JIZHUN_LEN2;//基准长度
- SET_DAOKOU_JY = SET_DAOKOU_JY2; //机械模具刀口
- break;
- case 2: //8#模具
- JY_JIZHUN_CISHU = JY_JIZHUN_CISHU3;//基准长度对应齿数
- JY_JIZHUN_LEN = JY_JIZHUN_LEN3;//基准长度
- SET_DAOKOU_JY = SET_DAOKOU_JY3; //机械模具刀口
- break;
- default: //特殊模具
- JY_JIZHUN_CISHU = JY_JIZHUN_CISHU4;//基准长度对应齿数
- JY_JIZHUN_LEN = JY_JIZHUN_LEN4;//基准长度
- SET_DAOKOU_JY = SET_DAOKOU_JY4; //机械模具刀口
- break;
- }
-
- if((JY_JIZHUN_CISHU == 0) || (JY_JIZHUN_LEN == 0))
- {
- JY_JIZHUN_CISHU = 49;
- JY_JIZHUN_LEN = 1250;
- SET_DAOKOU_JY = 10;
- }
- }
- //输入拉链长度返回所输入拉链长度所对应的齿数
- unsigned long GetToothNum(unsigned long zipper_length)
- {
- float length_buff1,tooth_buff,length_buff2;
- length_buff1 = zipper_length;
- tooth_buff = JY_JIZHUN_CISHU;
- length_buff2 = JY_JIZHUN_LEN;
- return (unsigned long)round(length_buff1 * tooth_buff / length_buff2);
- }
- //输入齿数返回拉链长度
- unsigned long JYDC_ToothGetLength(unsigned long tooth_num)
- {
- float toothbuff1,tooth_buff,length_buff2;
- toothbuff1 = tooth_num;
- tooth_buff = JY_JIZHUN_CISHU;
- length_buff2 = JY_JIZHUN_LEN;
-
- return (unsigned long)round((toothbuff1 * length_buff2 / tooth_buff));
- }
- //吹气动作
- void JYDC_ChuiQi(void)
- {
- if(JYDC_XiaChong_DW)
- {
- JYDC_ChuiQi_VAVLE = 1;
- JYDC_ChuiQiDelay = dwTickCount + JYDC_PARAM_CHUIQI_TIME * 10;
- }
-
- if(JYDC_ChuiQi_VAVLE)
- {
- if(JYDC_ChuiQiDelay < dwTickCount)JYDC_ChuiQi_VAVLE = 0;
- }
-
- if(JYDC_XiChiChuiQi_VAVLE)
- {
- if(JYDC_XiChiChuiQiDelay < dwTickCount)JYDC_XiChiChuiQi_VAVLE = 0;
- }
- }
- //下冲动作
- void JYDC_XiaChong(void)
- { static unsigned long dwSHACHE_TIME;
-
- if(JYDC_PARAM_SHACHE_TIME != 0)
- {
- if(dwTickCount >= dwSHACHE_TIME)
- JYDC_ShaChe_VAVLE = 0;
- }
- if(JYDC_XiaChongStep == 1)
- {
- JYDC_ShaChe_VAVLE = 0;
- JYDC_SuoChi_VAVLE = 1; //手动下冲不锁齿
- JYDC_XiaChongDelay = dwTickCount + XIACONG_DELAY_TIME*10;
- JYDC_XiaChongStep = 2;
- }
- else if((JYDC_XiaChongStep == 2) && (dwTickCount >= JYDC_XiaChongDelay))
- {
- JYDC_XiaChong_MOTOR = 1;
- JYDC_XiaChongDelay = dwTickCount + JYDC_PARAM_XC_ALARM_TIME * 10;
- JYDC_XiaChongStep = 3;
- }
- else if(JYDC_XiaChongStep == 3)
- {
- if(JYDC_XiaChong_IN_UP)
- {
- JYDC_XiaChong_MOTOR = 0;
- if(JYDC_bRunning)JYDC_SuoChi_VAVLE = 0;
- JYDC_XiaChongDelay = dwTickCount + JYDC_PARAM_SHACHE_DELAY_TIME * 10;
- JYDC_XiaChongStep = 4;
- }
- else if(dwTickCount >= JYDC_XiaChongDelay)
- {
- JYDC_SetAlarmCode(JYDC_XIACHONG_ARRIVE_ALARM);
- JYDC_XiaChong_MOTOR = 0;
- JYDC_ShaChe_VAVLE = 0;
- }
- }
- else if((JYDC_XiaChongStep == 4) && (dwTickCount >= JYDC_XiaChongDelay))
- {
- JYDC_ShaChe_VAVLE = 1;
- JYDC_XiaChongStep = 5;
- // if(JYDC_PARAM_SHACHE_TIME == 0)
- JYDC_XiaChongStep = 6;
- dwSHACHE_TIME = dwTickCount + JYDC_PARAM_SHACHE_TIME;
- }
- else if((JYDC_XiaChongStep == 5) && (dwTickCount >= JYDC_XiaChongDelay))
- {
- JYDC_ShaChe_VAVLE = 0;
- JYDC_XiaChongStep = 6;
- }
- else if(JYDC_XiaChongStep == 6)
- {
- if(!JYDC_bRunning)
- {
- CUR_LEN_JY = 0;
- cFirstFlg = 1;
- RemainKongWeiToothNum = 0;
- }
- JYDC_XiaChongStep = 0;
- }
- }
- //启动停止故障停止动作
- void JYDC_StartStopAction(void)
- {
- if((START_IN_UP || JYDC_bStart) && !JYDC_bRunning && (JYDC_AutoStep ==0))
- {
- if(GetTotal(JYDC_TOTAL_ADDR) >= SET_TOTAL)JYDC_SetAlarmCode(JYDC_TOTAL_ALARM);
- else
- {
- JYDC_AutoStep = 1;
- JYDC_bRunning = 1;
- JYDC_SuoChi_VAVLE = 0;
- JYDC_AutoDelay = 0;
- cAccSpeed = 6;
- }
- JYDC_bStart = 0;
- }
-
- if(JYDC_KaDai_IN && (GetAlarmCode(100) == 0))
- {
- JYDC_SetAlarmCode(JYDC_KADAI_ALARM);
- }
-
- JYDC_STOP_IN_FLAG_OLD = JYDC_STOP_IN_FLAG;
-
- if(STOP_IN)
- {
- if(JYDC_STOP_FILTER < 50)
- {
- JYDC_STOP_FILTER++;
- }
- else
- JYDC_STOP_IN_FLAG = 1;
- }
- else if(JYDC_STOP_FILTER > 25)
- {
- JYDC_STOP_FILTER--;
- }
- else
- JYDC_STOP_IN_FLAG = 0;
-
- if((JYDC_STOP_IN_FLAG && !JYDC_STOP_IN_FLAG_OLD)|| JYDC_bStop)
- {
- JYDC_bStop = 0;
- if(JYDC_bRunning && (SingOneFlg == 0))
- {
- JYDC_ChuiQi_VAVLE = 1;
- JYDC_ChuiQiDelay = dwTickCount + JYDC_PARAM_CHUIQI_TIME * 10;
- JYDC_AutoDelay = dwTickCount;
- JYDC_bRunning = 0;
- JYDC_AutoStep = 0;
- JYDC_XiChi_MOTOR = 0;
- AxisEgmStop(X_AXIS);
- JYDC_SuoChi_VAVLE = 1;
- SingOneFlg = 0;
- JYDC_bManGuaChiMotor = 0;
- }
- else
- {
- JYDC_ChuiQi_VAVLE = 1;
- JYDC_ChuiQiDelay = dwTickCount + JYDC_PARAM_CHUIQI_TIME * 10;
- JYDC_XiaChongDelay = dwTickCount;
- JYDC_AutoDelay = dwTickCount;
- JYDC_SuoChi_VAVLE = 0;
- JYDC_bRunning = 0;
- JYDC_AutoStep = 0;
- JYDC_XiChi_MOTOR = 0;
- AxisEgmStop(X_AXIS);
- SingOneFlg = 0;
- JYDC_bManGuaChiMotor = 0;
- }
- }
-
- if(JYDC_bAlarmStop)
- {
- JYDC_bAlarmStop = 0;
- JYDC_XiaChongStep = 0;
- JYDC_XiaChong_MOTOR = 0;
- JYDC_ShaChe_VAVLE = 1;
- AxisEgmStop(X_AXIS);
- JYDC_AutoStep = 0;
- if(JYDC_bRunning)JYDC_SuoChi_VAVLE = 1;
- JYDC_bRunning = 0;
- JYDC_XiaChongDelay = dwTickCount;
- JYDC_AutoDelay = dwTickCount;
- SingOneFlg = 0;
- JYDC_bManGuaChiMotor = 0;
- }
- }
- unsigned long ToothTransPulse(unsigned long tooth)
- {
- return(JY_JIZHUN_LEN * tooth * 2000 / 250 / JY_JIZHUN_CISHU);
- }
- unsigned char CheckSpeedError(unsigned char cspeed)
- {
- unsigned char buff;
- buff = cspeed/cAccSpeed;
-
- if(buff < 5)return 5;
- else
- return buff;
- }
- unsigned char CheckMaxLowSpeed(unsigned char cspeed)
- {
- if(cspeed > JYDC_PARAM_SET_SPEED)
- return JYDC_PARAM_SET_SPEED;
- else
- return cspeed;
- }
- //自动运行动作
- void JYDC_AutoRunStep(void)
- {
- // DISPLAY_DATA0 = cAccSpeed;
- // DISPLAY_DATA1 = ToothNumBuff;
- // DISPLAY_DATA2 = SET_TOTAL;
- // DISPLAY_DATA3 = GetTotal(JYDC_TOTAL_ADDR);
- DISPLAY_DATA5 = JYDC_AutoStep;
- DISPLAY_DATA6 = JYDC_XiaChongStep;
-
- if(JYDC_bRunning)
- {
- unsigned short buff;
- if(JYDC_AutoStep == 1)
- {
- if(JYDC_XICHI_MOTOR_MODE)JYDC_XiChi_MOTOR = 1;
- else JYDC_XiChi_MOTOR = 0;
- if(JYDC_SEBIAO_MODE)
- {
- JYDC_AutoStep = 20;
- JYDC_SuoChi_VAVLE = 0;
- dwZipCnt = 0;
- }
- else
- {
- if(CUR_LEN_JY >= JYDC_PARAM_REVICHISHU)
- {
- CUR_LEN_JY = 0;
- JYDC_XiaChongStep = 1;
- JYDC_AutoStep = 2;
- }
- else
- JYDC_AutoStep = 2;
-
- }
- }
- else if((JYDC_AutoStep == 2) && (JYDC_XiaChongStep == 0))
- {
- cFirstFlg = 1;
- if(RemainKongWeiToothNum == 0)
- {
- RemainKongWeiToothNum = SET_KOUWEI_JY;
- }
- else
- {
-
- }
-
- JYDC_AutoStep = 3;
- }
- else if(JYDC_AutoStep == 3)
- {
- if(RemainKongWeiToothNum >= SET_DAOKOU_JY)
- {
- if(cFirstFlg)
- {
- if(JYDC_PARAM_REVICHISHU <= SET_KOUWEI_JY)
- {
- ToothNumBuff = JYDC_PARAM_REVICHISHU + SET_DAOKOU_JY;
- RemainKongWeiToothNum = 0;
- }
- else
- {
- ToothNumBuff = JYDC_PARAM_REVICHISHU + (RemainKongWeiToothNum-SET_DAOKOU_JY) + SET_DAOKOU_JY;
- // ToothNumBuff = JYDC_PARAM_REVICHISHU+SET_DAOKOU_JY;
- RemainKongWeiToothNum -= SET_DAOKOU_JY;
- }
- }
- else
- {
- ToothNumBuff = ToothNumBuff + SET_DAOKOU_JY;
- RemainKongWeiToothNum -= SET_DAOKOU_JY;
- }
- }
- else
- {
- if(cFirstFlg)
- {
- ToothNumBuff = JYDC_PARAM_REVICHISHU - RemainKongWeiToothNum + SET_DAOKOU_JY;
- }
- else
- {
- ToothNumBuff = ToothNumBuff + RemainKongWeiToothNum;
- }
- RemainKongWeiToothNum = 0;
- }
-
- JYDC_SuoChi_VAVLE = 0;
- // JYDC_AutoDelay = dwTickCount + 50;
- JYDC_AutoStep = 4;
- }
- else if((JYDC_AutoStep == 4) && (dwTickCount >= JYDC_AutoDelay))
- {
- if(((ToothNumBuff) > (JYDC_PARAM_LOW_LENGTH + CUR_LEN_JY))
- && (ToothNumBuff> (SET_DAOKOU_JY+ 2)))
- {
- AxisContinueMove(X_AXIS,JYDC_PARAM_SET_SPEED,0);
- AxisChangeSpeed(X_AXIS,CheckSpeedError(JYDC_PARAM_SET_SPEED));
- JYDC_AutoDelay = dwTickCount + NO_TOOTHCOUT_TIME * 10;
- JYDC_XiChiChuiQi_VAVLE = 1;
- JYDC_XiChiChuiQiDelay = dwTickCount + 200;
- JYDC_AutoStep = 5;
- }
- else
- {
- AxisContinueMove(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED/2),0);
- JYDC_AutoDelay = dwTickCount + NO_TOOTHCOUT_TIME * 10;
- JYDC_XiChiChuiQi_VAVLE = 1;
- JYDC_XiChiChuiQiDelay = dwTickCount + 200;
- JYDC_AutoStep = 6;
- }
-
- /* DISPLAY_DATA6 = ToothTransPulse(ToothNumBuff);
- DISPLAY_DATA7 = ToothTransPulse(JYDC_PARAM_LOW_LENGTH);
- AxisMoveTwoPos(X_AXIS,JYDC_PARAM_SET_SPEED,ToothTransPulse(ToothNumBuff - JYDC_PARAM_LOW_LENGTH),JYDC_PARAM_LOW_SPEED,ToothTransPulse(JYDC_PARAM_LOW_LENGTH+5),0);
- JYDC_AutoStep = 6;
- JYDC_AutoDelay = dwTickCount + NO_TOOTHCOUT_TIME;*/
- }
- else if(JYDC_AutoStep == 5)
- {
- if(cFirstFlg)
- {
- if((ToothNumBuff) <= (JYDC_PARAM_LOW_LENGTH + CUR_LEN_JY))
- {
- AxisChangeSpeed(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED));
- cFirstFlg = 0;
- JYDC_AutoStep = 6;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_COUNT_ALARM);
- }
- else
- {
- if(X_DRV)AxisChangeSpeed(X_AXIS,CheckSpeedError(JYDC_PARAM_SET_SPEED));
- }
- }
- else
- {
- if((ToothNumBuff) <= (JYDC_PARAM_LOW_LENGTH + CUR_LEN_JY))
- {
- AxisChangeSpeed(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED));
- JYDC_AutoStep = 6;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_COUNT_ALARM);
- }
- else
- {
- if(X_DRV)AxisChangeSpeed(X_AXIS,CheckSpeedError(JYDC_PARAM_SET_SPEED));
- }
- }
- }
- else if(JYDC_AutoStep == 6)
- {
- if(!X_DRV)
- {
- JYDC_XiaChongStep = 1;
- JYDC_AutoStep = 7;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_COUNT_ALARM);
- }
- }
- else if(JYDC_AutoStep == 7)
- {
- if(JYDC_XiaChongStep == 0)
- {
- if(RemainKongWeiToothNum == 0)
- {
- JYDC_AutoStep = 8;
- JYDC_AutoDelay = dwTickCount;
- }
- else
- {
- JYDC_AutoStep = 3;
- JYDC_AutoDelay = dwTickCount;
- }
- }
- }
- else if((JYDC_AutoStep == 8) && (JYDCRunFlg == 1))
- {
- AddToTal(JYDC_TOTAL_ADDR);
- CUR_LEN_JY = 0;
- if((GetTotal(JYDC_TOTAL_ADDR) >= SET_TOTAL) || JYDC_bStop || SingOneFlg)
- {
- if(JYDC_bStop || SingOneFlg)
- {
- JYDC_bStop = 0;
- JYDC_AutoStep = 0;
- JYDC_bRunning = 0;
- SingOneFlg = 0;
- JYDC_SuoChi_VAVLE = 1;
- JYDC_XiChi_MOTOR = 0;
- }
- else
- {
- JYDC_SetAlarmCode(JYDC_TOTAL_ALARM);
- }
- }
- else
- {
- JYDC_AutoStep = 1;
- JYDC_AutoDelay = JYDC_PARAM_CYCLE_DELAY * 10 + dwTickCount;
- CalProSP(JYDC_PROSPEED_ADDR);
- }
- }
- //20步以上为色标
- else if((JYDC_AutoStep == 20) && (dwTickCount >= JYDC_AutoDelay)) //色标动作
- {
- cSeBiaoEn = 1;
- if(dwZipCnt == 0)
- AxisContinueMove(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED),0);
- else
- AxisContinueMove(X_AXIS,JYDC_PARAM_SET_SPEED,0);
-
- JYDC_AutoDelay = dwTickCount + NO_TOOTHCOUT_TIME * 10;
- JYDC_XiChiChuiQi_VAVLE = 1;
- JYDC_XiChiChuiQiDelay = dwTickCount + 200;
- JYDC_AutoStep = 21;
- }
- else if(JYDC_AutoStep == 21)
- {
- if(!X_DRV)
- {
- JYDC_AutoStep = 22;
- JYDC_AutoDelay = dwTickCount;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_SEBIAO_ALARM);
- }
- }
- else if(JYDC_AutoStep == 22)
- {
- if(RemainKongWeiToothNum >= SET_DAOKOU_JY)
- {
- if(cFirstFlg)
- {
- if(JYDC_PARAM_REVICHISHU <= SET_KOUWEI_JY)
- {
- ToothNumBuff = JYDC_PARAM_REVICHISHU + SET_DAOKOU_JY;
- RemainKongWeiToothNum = 0;
- }
- else
- {
- ToothNumBuff = JYDC_PARAM_REVICHISHU + (RemainKongWeiToothNum-SET_DAOKOU_JY) + SET_DAOKOU_JY;
- RemainKongWeiToothNum -= SET_DAOKOU_JY;
- }
- }
- else
- {
- ToothNumBuff = ToothNumBuff + SET_DAOKOU_JY;
- RemainKongWeiToothNum -= SET_DAOKOU_JY;
- }
- }
- else
- {
- if(cFirstFlg)
- {
- ToothNumBuff = JYDC_PARAM_REVICHISHU - RemainKongWeiToothNum + SET_DAOKOU_JY;
- }
- else
- {
- ToothNumBuff = ToothNumBuff + RemainKongWeiToothNum;
- }
- RemainKongWeiToothNum = 0;
- }
-
- JYDC_AutoStep = 23;
- }
- else if((JYDC_AutoStep == 23) && (dwTickCount >= JYDC_AutoDelay))
- {
- if((ToothNumBuff - CUR_LEN_JY) > JYDC_PARAM_LOW_LENGTH)
- {
- if(!X_DRV)AxisContinueMove(X_AXIS,JYDC_PARAM_SET_SPEED,0);
- JYDC_AutoDelay = dwTickCount + NO_TOOTHCOUT_TIME * 10;
- JYDC_XiChiChuiQi_VAVLE = 1;
- JYDC_XiChiChuiQiDelay = dwTickCount + 200;
- JYDC_AutoStep = 24;
- }
- else
- {
- if(!X_DRV)AxisContinueMove(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED),0);
- JYDC_AutoDelay = dwTickCount + NO_TOOTHCOUT_TIME * 10;
- JYDC_XiChiChuiQi_VAVLE = 1;
- JYDC_XiChiChuiQiDelay = dwTickCount + 200;
- JYDC_AutoStep = 25;
- }
- }
- else if(JYDC_AutoStep == 24)
- {
- if(cFirstFlg)
- {
- if((ToothNumBuff - CUR_LEN_JY) <= (JYDC_PARAM_LOW_LENGTH))
- {
- AxisChangeSpeed(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED));
- cFirstFlg = 0;
- JYDC_AutoStep = 25;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_COUNT_ALARM);
- }
- }
- else
- {
- if((ToothNumBuff - CUR_LEN_JY) <= JYDC_PARAM_LOW_LENGTH)
- {
- AxisChangeSpeed(X_AXIS,CheckMaxLowSpeed(JYDC_PARAM_LOW_SPEED));
- JYDC_AutoStep = 25;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_COUNT_ALARM);
- }
- }
- }
- else if(JYDC_AutoStep == 25)
- {
- if(!X_DRV)
- {
- JYDC_XiaChongStep = 1;
- JYDC_AutoStep = 26;
- }
- else if(dwTickCount >= JYDC_AutoDelay)
- {
- JYDC_SetAlarmCode(JYDC_COUNT_ALARM);
- }
- }
- else if(JYDC_AutoStep == 26)
- {
- if(JYDC_XiaChongStep == 0)
- {
- if(RemainKongWeiToothNum == 0)
- {
- JYDC_AutoStep = 27;
- JYDC_AutoDelay = dwTickCount;
- }
- else
- {
- JYDC_AutoStep = 22;
- JYDC_AutoDelay = dwTickCount;
- }
- }
- }
- else if((JYDC_AutoStep == 27) && (JYDCRunFlg == 1))
- {
- AddToTal(JYDC_TOTAL_ADDR);
- dwZipCnt++;
- CUR_LEN_JY = 0;
- cSeBiaoStep = 0;
- if((GetTotal(JYDC_TOTAL_ADDR) >= SET_TOTAL) || JYDC_bStop || SingOneFlg)
- {
- if(JYDC_bStop || SingOneFlg)
- {
- JYDC_bStop = 0;
- JYDC_AutoStep = 0;
- JYDC_bRunning = 0;
- SingOneFlg = 0;
- JYDC_SuoChi_VAVLE = 1;
- JYDC_XiChi_MOTOR = 0;
- }
- else
- {
- JYDC_SetAlarmCode(JYDC_TOTAL_ALARM);
- }
- }
- else
- {
- JYDC_AutoStep = 1;
- JYDC_AutoDelay = JYDC_PARAM_CYCLE_DELAY * 10 + dwTickCount;
- CalProSP(JYDC_PROSPEED_ADDR);
- }
- }
- }
- }
- #endif
|