#include "global.h" #if 0 void MXC_NiLongXiuCiJiCheckStart(void); void MXC_CuiQi_Start(void); void MXC_ShaChe_Output(void); void MXC_NiLongXiuCiJi_Motor(void); void MXC_NiLongXiuCiJi_XiaC(void); void MXC_Start_FenZ(void); void MXC_NiLongXiuCiJi_FenZhengProc(void); void MXC_ChuiQiProc(void); void MXC_JiaoDao(void); void MXC_ManualAction(void); void MXC_AutoAction(void); unsigned char cLFengTimer,cRFengTimer,cGuZhangStop = 0; unsigned long cShaCheTime,cLaLianLine,cGouZhenTime; unsigned char cChuiQiStep = 0,cGouZhenResetOK; unsigned short cBudaiCheckDelay = 0; unsigned char bHandWork,bPulseTatol_EN,bFirst,cInt1_OK,cStopFlag,cOneTimes,cKey_Time; long cSetEncode,cTotal,cDinWeiTime,cAddSetPulseNum,cEncodePulse,cWorkPulseNum; //故障报警 void MXC_SetAlarmCode(unsigned alarm_code) { SetAlarmCode(MXC_ALARM_ADDR,alarm_code); MXC_bAlarmStop = 1; MXC_bSaveWorkData = 1; } void MXC_InitAction(void) { MXC_XC_SongZhou = 1; MXC_XIA_ZHI_ENABLE = 0; if(MXC_MOTOR_MODE == 0) MXC_TuoDaiSongZhou = 1; else MXC_TuoDaiSongZhou = 0; if(MXC_XIA_ZHI_ENABLE) MXC_XiaZhi_MOTOR = 1; else MXC_XiaZhi_MOTOR = 0; } void MXC_NiLongXiuCiJiAction(void) { MXC_NiLongXiuCiJiCheckStart(); //启动 MXC_NiLongXiuCiJi_FenZhengProc(); //左右分针 MXC_NiLongXiuCiJi_XiaC(); //下冲 MXC_NiLongXiuCiJi_Motor(); //拖带控制 MXC_JiaoDao(); MXC_ManualAction(); MXC_AutoAction(); } void MXC_ManualAction(void) { long i; //清总产量 if(MXC_bClear) //清总产量 { MXC_bClear = 0; ClrcToTal(MXC_TOTAL_ADDR); } //当长度改变时,生产总量自动清零 if(MXC_bChangeLength) { MXC_bChangeLength = 0; i = MXC_SET_ZIPPER_LENGTH; if(cLaLianLine != i) { cLaLianLine = i; SetData32bits(MXC_ZIPPER_LENGTH_ADDR,0); ClrcToTal(MXC_TOTAL_ADDR); } } //加10 if(MXC_bAddLength) { MXC_bAddLength = 0; i = MXC_SET_REVISE_ZIPPER_LENGTH; i += 10; SetData32bits(MXC_ZIPPER_LENGTH_ADDR,i); } //减10 if(MXC_bDecLength) { MXC_bDecLength = 0; i = MXC_SET_REVISE_ZIPPER_LENGTH; i -= 10; SetData32bits(MXC_ZIPPER_LENGTH_ADDR,i); } //工作方式选择(数控定寸和勾针定寸)  if(MXC_bSetDCMode) { MXC_bSetDCMode = 0; if(!bRunning) { MXC_DC_MODE++; if(MXC_DC_MODE > 2)MXC_DC_MODE = 0; if(MXC_DC_MODE != 0) { MXC_GouZhen_VAVLE = 1; MXC_XIA_ZHI_ENABLE = 0; MXC_XiaZhi_MOTOR = 0; } } } //勾针方式选择(活动勾针和固定勾针)  if(MXC_bChangeGouZhenMode) { MXC_bChangeGouZhenMode = 0; if(!bRunning) { MXC_GOU_ZHEN_MODE++; if(MXC_GOU_ZHEN_MODE > 1)MXC_GOU_ZHEN_MODE = 0; } } //下止工作选择)  if(MXC_bChangeXiaZhiMode) { MXC_bChangeXiaZhiMode = 0; if(!bRunning) { MXC_XIA_ZHI_ENABLE++; if(MXC_XIA_ZHI_ENABLE > 1)MXC_XIA_ZHI_ENABLE = 0; if(MXC_XIA_ZHI_ENABLE) MXC_XiaZhi_MOTOR = 1; else MXC_XiaZhi_MOTOR = 0; } } if(MXC_bJiaoDao) { MXC_cJiaoDaoStep = 1; MXC_bJiaoDao = 0; } //吹气 if((MXC_ChuiQi_VAVLE == 0)) { if(MXC_DingChuPian_IN_DW) { MXC_bChuiQi = 0; MXC_cChuiQiDelay = dwTickCount + 10*MXC_PARAM_DELAY_CHUIQI_TIME; MXC_cChuiQiStep = 1; } else if(MXC_bChuiQi == 1) { MXC_bChuiQi = 0; MXC_cChuiQiDelay = 0; MXC_cChuiQiStep = 1; } } MXC_ChuiQiProc(); if(MXC_ChuiQi_VAVLE && (dwTickCount >= MXC_cChuiQiDelay)) { MXC_ChuiQi_VAVLE = 1;// MXC_XiChiChuiQi = 1; MXC_cChuiQiDelay = dwTickCount + 10 * MXC_PARAM_CHUIQI_TIME; } if(MXC_XiChiChuiQi && (dwTickCount >= MXC_cChuiQiDelay)) { MXC_XiChiChuiQi = 0; } if((bRunning) == 0) ////手动 { if(MXC_ManXiaChong_UP || MXC_bXiaChong) { if(MXC_cXiaChongStep == 0)MXC_cXiaChongStep = 1; } if(MXC_cXiaChongStep == 0) { if(MXC_bLeftFenZhen) MXC_LeftFenZhen_VAVLE = 1; else MXC_LeftFenZhen_VAVLE = 0; if(MXC_bRightFenZhen) MXC_RightFenZhen_VAVLE = 1; else MXC_RightFenZhen_VAVLE = 0; //点动下冲 if((MXC_bDotXiaChong)) { MXC_bDotXiaChong = 0; if(MXC_LeftFenZhen_IN && MXC_RighttFenZhen_IN) { if(MXC_XiaChongMotorMode == 0) { if(MXC_cXiaChongStep == 0)MXC_cXiaChongStep = 20; } else { if(MXC_cXiaChongStep == 0)MXC_cXiaChongStep = 40; } } else { MXC_SetAlarmCode(MXC_XIA_CHONG_ALARM); //下冲条件不满足 } } if(MXC_bGouZhen) { MXC_bGouZhen = 0; if((MXC_GOU_ZHEN_MODE == 0))//普通勾针(活动)过链 { MXC_cGouZhenTime = dwTickCount + 300; MXC_GouZhen_VAVLE = ~MXC_GouZhen_VAVLE; } else //固定勾针 { MXC_GuDingGouZhen = ~MXC_GuDingGouZhen; } } } if(MXC_DC_MODE != 0) //伺服定寸 { MXC_GuDingGouZhen = 1; MXC_GouZhen_VAVLE = 1; } else if((MXC_GOU_ZHEN_MODE == 0) )//普通勾针(活动)过链 { if(dwTickCount >= MXC_cGouZhenTime) MXC_GouZhen_VAVLE = 0; } else { if(MXC_XiaMode) //0普通下止,1超声下止 { if(MXC_GuoLian_IN_UP) { MXC_GuDingGouZhen = 0; } } else //刘铁方式(下拉一下就可以复位) { if(dwTickCount >= MXC_cGouZhenTime) MXC_GuDingGouZhen = 0; } } //下止动作 if(MXC_XiaZhi_IN_UP || MXC_bXiaZhi) { MXC_bXiaZhi = 0; if(MXC_XiaZhi_VAVLE) { MXC_XiaZhi_VAVLE = 0; MXC_ChaoSheng = 0; MXC_FenDai_VAVLE = 0; //分带输出 } else { if(MXC_XiaZhi_IN || MXC_XIA_ZHI_ENABLE) //下止选择 { //下止输出 MXC_cXiaZhiDelay = dwTickCount + 10 * MXC_PARAM_XIAZHI_TIME; MXC_XiaZhi_VAVLE = 1; } } } else if(MXC_XiaZhi_IN_DW) { MXC_XiaZhi_VAVLE = 0; //下止电磁阀 MXC_ChaoSheng = 0; //超声输出 MXC_FenDai_VAVLE = 0; //分带输出 } if(MXC_bChuDai) { MXC_ChuDai_VAVLE = 1; } else { MXC_ChuDai_VAVLE = 0; } } if((MXC_XiaMode != 0))//普通下止 { if(MXC_GuoLian_IN_UP|| MXC_FenDai_IN_UP)MXC_FenDai_VAVLE = 1; if(bRunning) { if(MXC_GuoLian_IN_UP && MXC_XiaZhi_VAVLE)MXC_cXiaZhiDelay = dwTickCount + 10 * MXC_PARAM_XIAZHI_DELAY_TIME; if(MXC_GuoLian_IN && MXC_XiaZhi_VAVLE) { if(!MXC_ChaoSheng && (dwTickCount >= MXC_cXiaZhiDelay)) { MXC_ChaoSheng = 1; MXC_cXiaZhiDelay = dwTickCount + (unsigned long)10 * MXC_PARAM_CHAOSHENG_TIME; } if(MXC_ChaoSheng && (dwTickCount >= MXC_cXiaZhiDelay)) { MXC_FenDai_VAVLE = 0; //分带输出 MXC_ChaoSheng = 0; //超声输出 MXC_XiaZhi_VAVLE = 0; //下止阀 } } } } else { //下止下冲电磁铁 if((MXC_XiaZhi_VAVLE != 0) && (dwTickCount >= MXC_cXiaZhiDelay)) { MXC_XiaZhi_VAVLE = 0; } } } void MXC_AutoAction(void) { unsigned long i; if(bRunning) { if(MXC_XiaZhi_IN || (!MXC_Zipper_IN)) MXC_ChuDai_VAVLE = 0; else MXC_ChuDai_VAVLE = 1; if((MXC_DC_MODE == 0) && (MXC_GOU_ZHEN_MODE == 0)) { if(MXC_GouZhen_IN_UP)MXC_cGouZhenTime = 1; } else MXC_cGouZhenTime = 1; switch(MXC_cAutoStep) { case 0: break; case 1: //左右分针要退到位,过链到位要离开 if(MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_LeftFenZhen_IN && !MXC_RighttFenZhen_IN && (dwTickCount >= MXC_cAutoDelay)) { MXC_cAutoStep = 2; MXC_cMotorStep = 1; //启动拖带 } break; case 2: //拖带已经完成 if(MXC_cMotorStep == 0) { bFirst = 1; //调试功能 if(MXC_DC_MODE != 2)MXC_cAutoStep = 3; // 调试功能 下一条 下冲 else if((!MXC_bDingWei) || MXC_bNext || MXC_ManXiaChong_UP || MXC_bXiaChong) { if(MXC_bNext) { MXC_cAutoStep = 1; MXC_bNext = 0; cInt1_OK = 0; } else { MXC_cAutoStep = 3; MXC_bDingWei = 0; } } MXC_cAutoDelay = dwTickCount + 5; //延时分针 } break; case 3: if((dwTickCount >= MXC_cAutoDelay) && MXC_cGouZhenTime) { MXC_cGouZhenTime = 0; if(MXC_cLeftFenZhenStep == 0)MXC_cLeftFenZhenStep = 1; MXC_cAutoStep = 4; } break; case 4: //左右分针都已完成 if((MXC_cLeftFenZhenStep == 0) && (MXC_cRightFenZhenStep == 0)) { MXC_cXiaChongStep = 1; //下冲电机启动 MXC_cAutoStep = 5; } break; case 5: //下冲已完成 if(MXC_cXiaChongStep == 0) { AddToTal(MXC_TOTAL_ADDR); //计数增加和保存 CalProSP(MXC_PROSPEED_ADDR); MXC_cAutoStep = 6; } break; case 6: if(MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_LeftFenZhen_IN && !MXC_RighttFenZhen_IN) { if(GetTotal(MXC_TOTAL_ADDR) >= MXC_SET_TOTAL)MXC_SetAlarmCode(MXC_TOTAL_ALARM); MXC_cAutoStep = 7; } break; case 7: if((dwTickCount >= MXC_cAutoDelay) && (MXC_Dec_IN || MXC_GOU_ZHEN_DEC_MODE || MXC_DC_MODE)) { if(SingOneFlg) { SingOneFlg = 0; } else { MXC_cAutoStep = 1; } } break; } } } // 检测是否踏了脚踏开关 void MXC_NiLongXiuCiJiCheckStart(void) { // 停止键 不能在工作,手动,停止过程中 if((!STOP_IN) && (bHandWork == 0) && (bRunning == 0) && (cStopFlag==0) // 启动 && (START_IN_UP || (MXC_bStart)) && (cKey_Time == 0) && (!MXC_Zipper_IN)) { if(MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_KaDai_IN) { bRunning = 1; MXC_bClearAlarm = 1; cKey_Time = 10; MXC_cAutoStep = 1; MXC_cMotorStep = 0; MXC_cXiaChongStep = 0; MXC_cLeftFenZhenStep = 0; MXC_cRightFenZhenStep = 0; SetAlarmCode(100,MXC_NO_ALARM); MXC_cAutoDelay = dwTickCount + (unsigned long)200; //先锁轴 cOneTimes = 0; cGouZhenTime = 1; MXC_XiaChong_MOTOR = 0; // if(MXC_XiaChongMotorMode == 1) { MXC_XC_SongZhou = 0; } if(MXC_MOTOR_MODE == 0) MXC_TuoDaiSongZhou = 0; else MXC_TuoDaiSongZhou = 1; if(MXC_bDingWei)cSetEncode = 0; bFirst = 0; } else { // user_datas[75] = 5; //页面跳转 if(MXC_KaDai_IN) SetAlarmCode(100,MXC_KA_DAI_ALARM); //卡带 else SetAlarmCode(100,MXC_START_ALARM); //起动条件不满足 } MXC_bStart = 0; } //卡带感应 if(MXC_KaDai_IN && (dwTickCount >= MXC_cKaDaiDelay)) { SetAlarmCode(MXC_ALARM_ADDR,MXC_KA_DAI_ALARM); //警告清 // user_datas[75] = 5; //页面跳转 MXC_cKaDaiDelay = dwTickCount + 2200; } if(MXC_KaDai_IN_UP) { MXC_bSaveWorkData = 1; } //停止 if((STOP_IN_UP || (MXC_bStop))) { // 不是下冲状态 if((MXC_cXiaChongStep == 0) && (bRunning == 0)) { MXC_CuiQi_Start(); if(!MXC_XiaChong_MOTOR)MXC_XC_SongZhou = 1; } if((cStopFlag == 0) && (cKey_Time == 0)) { cKey_Time = 4; if(((MXC_DC_MODE == 0) || STOP_IN_UP) && ((MXC_XiaChongMotorMode == 0) || (MXC_cXiaChongStep == 0))) { AxisDecStop(X_AXIS); } MXC_GuDingGouZhen = 0; MXC_CuiQi_Start(); if(X_DRV && !MXC_XiaChong_MOTOR && (MXC_DC_MODE == 1)) { cGuZhangStop = 1; } if((++cOneTimes >= 2) || !bRunning || !X_DRV) { cStopFlag = 1; SetAlarmCode(100,MXC_NO_ALARM); // user_datas[75] = 50; if(!X_DRV) { if(MXC_MOTOR_MODE == 0) MXC_TuoDaiSongZhou = 1; else MXC_TuoDaiSongZhou = 0; } } MXC_cKaDaiDelay = dwTickCount + 1200; MXC_cGouZhenTime = dwTickCount + (unsigned long)300; //勾针延时退 } MXC_bStop = 0; MXC_bSaveWorkData = 1; } if((MXC_cXiaChongStep == 0) && (((cStopFlag) != 0) || (MXC_KaDai_IN))) { bRunning = 0; bHandWork = 0; cStopFlag = 0; MXC_cAutoStep = 0; MXC_cMotorStep = 0; MXC_cXiaChongStep = 0; MXC_cLeftFenZhenStep = 0; MXC_cRightFenZhenStep = 0; MXC_XC_SongZhou = 0; MXC_XiaZhi_VAVLE = 0; MXC_LeftFenZhen_VAVLE = 0; MXC_RightFenZhen_VAVLE = 0; MXC_XiaChong_MOTOR = 0; MXC_ChaoSheng = 0; MXC_JiaoDao_OUT = 0; MXC_FenDai_VAVLE = 0; MXC_ChuDai_VAVLE = 0; MXC_GuDingGouZhen = 0; if(!X_DRV) { if(MXC_MOTOR_MODE == 0) MXC_TuoDaiSongZhou = 1; else MXC_TuoDaiSongZhou = 0; } if(MXC_KaDai_IN_UP)MXC_CuiQi_Start(); MXC_XC_SongZhou = 1; // 刹车 if(MXC_GOU_ZHEN_MODE != 0) //超声(固定)勾针 MXC_GuDingGouZhen = 1; if(MXC_DC_MODE != 0) { if(X_DRV)cGuZhangStop = 1; } else AxisDecStop(X_AXIS); MXC_cGouZhenTime = dwTickCount + (unsigned long)300; //勾针延时退 } } void MXC_JiaoDao(void) { if(MXC_cJiaoDaoStep == 1) { MXC_cChuiQiDelay = dwTickCount + 500; MXC_JiaoDao_OUT = 1; MXC_cJiaoDaoStep = 2; } else if((MXC_cJiaoDaoStep == 2) && (dwTickCount >= MXC_cChuiQiDelay)) { MXC_JiaoDao_OUT = 0; MXC_cJiaoDaoStep = 0; } } void MXC_CuiQi_Start(void) { //启动吹气 MXC_cChuiQiDelay = dwTickCount + (unsigned long)50 * MXC_PARAM_CHUIQI_TIME; MXC_ChuiQi_VAVLE = 1; MXC_XiChiChuiQi = 0; } void MXC_ChuiQiProc(void) { if(MXC_cChuiQiStep == 0) { } else if((MXC_cChuiQiStep == 1) && (dwTickCount >= MXC_cChuiQiDelay)) { MXC_CuiQi_Start(); MXC_cChuiQiStep = 0; } } void MXC_ShaChe_Output(void) { //启动吹气 cShaCheTime = dwTickCount + (unsigned long)120; if(MXC_XiaChongMotorMode == 0)MXC_XC_SongZhou = 1; } void MXC_Output_XiaCi(void)//下止输出 { if(MXC_XiaZhi_IN || MXC_XIA_ZHI_ENABLE) //下止选择 { //下止输出 MXC_cXiaZhiDelay = dwTickCount + 10 * MXC_PARAM_XIAZHI_TIME; MXC_XiaZhi_VAVLE = 1; } } //关下止动作 void MXC_Close_XiaCi(void) { if((MXC_XiaMode != 0))//普通下止 { if(MXC_GuoLian_IN_UP || MXC_FenDai_IN_UP) MXC_FenDai_VAVLE = 1; if(bRunning) { if(MXC_GuoLian_IN_UP && MXC_XiaZhi_VAVLE) { MXC_cXiaZhiDelay = dwTickCount + 10 * MXC_PARAM_XIAZHI_DELAY_TIME; } if(MXC_GuoLian_IN && MXC_XiaZhi_VAVLE) { if(!MXC_ChaoSheng && (dwTickCount >= MXC_cXiaZhiDelay)) { MXC_ChaoSheng = 1; MXC_cXiaZhiDelay = dwTickCount + (unsigned long)10 * MXC_PARAM_CHAOSHENG_TIME; } if(MXC_ChaoSheng && (dwTickCount >= MXC_cXiaZhiDelay)) { MXC_FenDai_VAVLE = 0; //分带输出 MXC_ChaoSheng = 0; //超声输出 MXC_XiaZhi_VAVLE = 0; //下止阀 } } } } else { //下止下冲电磁铁 if((MXC_XiaZhi_VAVLE != 0) && (dwTickCount >= MXC_cXiaZhiDelay)) { MXC_XiaZhi_VAVLE = 0; } } } unsigned long MXC_LengthCallPulse(unsigned long length) { return (length * 2000 / MXC_PARAM_DAILUN_LENGTH); } //高速输入X31/X17外部色标信号中断 void MXC_ExtiActionX31(void) { if(cSeBiaoEn && !cSeBiaoOk) { cSeBiaoOk = 1; cSeBiaoEn = 0; AxisDecStopPos(X_AXIS,MXC_PARAM_SEBIAO_DW_LENGTH); } } void MXC_NiLongXiuCiJi_Motor(void) { static long back_save_buff,gou_zhen_buff; static unsigned long zipper_length; dwRealPos = GetPos(X_AXIS); switch(MXC_cMotorStep) { case 0: break; // 过链 左分针退位 左到位 case 1: if(MXC_LeftFenZhen_Origin_IN && (!MXC_LeftFenZhen_IN) && MXC_RightFenZhen_Origin_IN && (!MXC_RighttFenZhen_IN)) { MXC_LIHE_VAVLE = 1; //离合器 gou_zhen_buff = dwRealPos; if(MXC_DC_MODE == 0) { zipper_length = MXC_SET_ZIPPER_LENGTH + MXC_SET_REVISE_ZIPPER_LENGTH + MXC_PARAM_DAOKOU_LENGTH; if((MXC_GOU_ZHEN_MODE == 0))//普通勾针(活动)过链 { if(dwZipCnt == 0) AxisMoveTwoPos(X_AXIS,MXC_PARAM_FIRST_SPEED,zipper_length,MXC_PARAM_LOW_SPEED,9999999,0); else AxisMoveTwoPos(X_AXIS,MXC_PARAM_SET_SPEED,zipper_length,MXC_PARAM_LOW_SPEED,9999999,0); if(MXC_PARAM_GZ_RESET_MODE) MXC_cMotorStep = 3; else { MXC_cMotorStep = 2; MXC_cAutoDelay = dwTickCount + MXC_PARAM_GZ_DELAY; } } else //带下止型勾针 { MXC_cMotorStep = 11; if(dwZipCnt == 0) AxisMoveTwoPos(X_AXIS,MXC_PARAM_FIRST_SPEED,zipper_length,MXC_PARAM_LOW_SPEED,9999999,0); else AxisMoveTwoPos(X_AXIS,MXC_PARAM_SET_SPEED,zipper_length,MXC_PARAM_LOW_SPEED,9999999,0); } cGuZhangStop = 0; cWorkPulseNum = 0; if(!MXC_GouZhen_VAVLE) { MXC_cMotorStep = 3; } } else if(MXC_DC_MODE == 1) { zipper_length = MXC_SET_ZIPPER_LENGTH + MXC_SET_REVISE_ZIPPER_LENGTH + MXC_PARAM_DAOKOU_LENGTH; MXC_cMotorStep = 20; MXC_GouZhen_VAVLE = 1; //定位(活动勾针)电磁阀 MXC_GuDingGouZhen = 1; //定位(活动勾针)电磁阀 if(cWorkPulseNum >= cSetEncode)MXC_cMotorStep = 0; else { AxisMovePos(X_AXIS,MXC_PARAM_SET_SPEED,zipper_length); } } else { zipper_length = MXC_SET_ZIPPER_LENGTH; if(cWorkPulseNum >= cSetEncode)MXC_cMotorStep = 0; else { back_save_buff = dwRealPos; if(dwZipCnt == 0) { cSeBiaoOk = 0; cSeBiaoEn = 1; AxisMoveTwoPos(X_AXIS,MXC_PARAM_FIRST_SPEED,zipper_length,MXC_PARAM_LOW_SPEED,9999999,0); } else AxisMoveTwoPos(X_AXIS,MXC_PARAM_SET_SPEED,zipper_length,MXC_PARAM_LOW_SPEED,9999999,0); MXC_cMotorStep = 50; MXC_cAutoDelay = dwTickCount + (unsigned long)10000; } } } break; // step2-5 活动勾针定寸 case 2: if((dwTickCount >= MXC_cAutoDelay)) { MXC_GouZhen_VAVLE = 0;//定位电磁阀 } if(!MXC_GouZhen_VAVLE && !MXC_GouZhen_IN) { MXC_cMotorStep = 3; MXC_cAutoDelay = dwTickCount + (unsigned long)10000; } break; case 3: if(MXC_PARAM_GZ_RESET_MODE) { if((dwRealPos - gou_zhen_buff + MXC_PARAM_GZ_LENGTH) >= zipper_length) { MXC_GouZhen_VAVLE = 0;//定位电磁阀 } } if(MXC_GOU_ZHEN_DEC_MODE)//数控方式 { MXC_cMotorStep = 4; MXC_cAutoDelay = dwTickCount + (unsigned long)10000; } else //感应方式 { if(!MXC_Dec_IN) { AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED); MXC_cMotorStep = 4; MXC_cAutoDelay = dwTickCount + (unsigned long)10000; } } if(MXC_GouZhen_IN) { AxisEgmStop(X_AXIS); MXC_cMotorStep = 4; MXC_LIHE_VAVLE = 0; } else if(dwTickCount >= MXC_cAutoDelay) { MXC_SetAlarmCode(MXC_NO_GOUZHEN_ALARM); } break; case 4: if(MXC_GouZhen_IN) { MXC_cMotorStep = 0; AxisEgmStop(X_AXIS); } else if((dwTickCount >= MXC_cAutoDelay)) { MXC_SetAlarmCode(MXC_NO_GOUZHEN_ALARM); } //布带对射检测 if(MXC_Zipper_IN) { MXC_cBudaiCheckDelay = dwTickCount + 3000; } else if(dwTickCount >= cBudaiCheckDelay) //没布带了 { MXC_SetAlarmCode(MXC_NO_ZIPPER_ALARM); MXC_GouZhen_VAVLE = 0; } break; case 11://以下为固定勾针方式 if(MXC_XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针 { if(dwTickCount >= MXC_cAutoDelay)MXC_GuDingGouZhen = 0; if(!MXC_GuoLian_IN) { AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED); MXC_cMotorStep = 12; MXC_cAutoDelay = dwTickCount + (unsigned long)1500; //延时检测 } } else { if(MXC_GuoLianCheckMode) { if(!MXC_GuoLian_IN) { AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED); MXC_cMotorStep = 12; MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[12]; //延时检测 } } else { if(MXC_GuoLian_IN) { AxisChangeSpeed(X_AXIS,MXC_PARAM_LOW_SPEED); MXC_cMotorStep = 12; MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[12]; //延时检测 } } } break; case 12: if(dwTickCount >= MXC_cAutoDelay) { if(MXC_GuDingGouZhen) { MXC_GuDingGouZhen = 0; MXC_cAutoDelay = dwTickCount + (unsigned long)1500; //延时检测 } else if(!MXC_GuDingGouZhen) { MXC_SetAlarmCode(MXC_GU_DING_GOUZHEN_ALARM); } } if(MXC_XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针 { if(MXC_GuoLian_IN) { MXC_GuDingGouZhen = 0; MXC_cMotorStep = 13; MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机 } } else { if(MXC_GuoLianCheckMode) { if(MXC_GuoLian_IN_UP) { MXC_GuDingGouZhen = 0; MXC_cMotorStep = 13; MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机 } } else { if(MXC_GuoLian_IN_DW) { MXC_GuDingGouZhen = 0; MXC_cMotorStep = 13; MXC_cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机 } } } break; case 13: if((dwTickCount >= MXC_cAutoDelay)) { if(MXC_XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针 { AxisEgmStop(X_AXIS); if(MXC_GuoLian_IN) { MXC_cMotorStep = 0; MXC_LIHE_VAVLE = 0; } } else { if(MXC_GuoLianCheckMode) { if(MXC_GuoLian_IN) { MXC_cMotorStep = 0; AxisEgmStop(X_AXIS); MXC_LIHE_VAVLE = 0; } } else { if(!MXC_GuoLian_IN) { MXC_cMotorStep = 0; AxisEgmStop(X_AXIS); MXC_LIHE_VAVLE = 0; } } } } if(MXC_Zipper_IN) { MXC_cBudaiCheckDelay = dwTickCount + 3000; } else if(dwTickCount >= MXC_cBudaiCheckDelay) //没布带了 { MXC_SetAlarmCode(MXC_NO_ZIPPER_ALARM); //没拉链 MXC_GouZhen_VAVLE = 0; } break; //伺服定寸 case 20: if(!X_DRV)MXC_cMotorStep = 0; //布带对射检测 if(MXC_Zipper_IN) { MXC_cBudaiCheckDelay = dwTickCount + 140; } else if(dwTickCount >= MXC_cBudaiCheckDelay) //没布带了 { MXC_SetAlarmCode(MXC_NO_ZIPPER_ALARM); //没拉链 MXC_GouZhen_VAVLE = 0; } break; case 50: if(dwZipCnt != 0) { if(MXC_SET_ZIPPER_LENGTH >= (MXC_PARAM_SEBIAO_DW_LENGTH + MXC_PARAM_SEBIAO_TQ_LENGTH)) { cSeBiaoOk = 0; cSeBiaoEn = 1; } else { if((dwRealPos - back_save_buff) >= (MXC_SET_ZIPPER_LENGTH - MXC_PARAM_SEBIAO_DW_LENGTH - MXC_PARAM_SEBIAO_TQ_LENGTH)) { cSeBiaoOk = 0; cSeBiaoEn = 1; } } } if(cSeBiaoOk) { cSeBiaoOk = 0; cSeBiaoEn = 0; MXC_cMotorStep = 51; } else { //布带对射检测 if(MXC_Zipper_IN) { MXC_cBudaiCheckDelay = dwTickCount + 140; } else if(dwTickCount >= MXC_cBudaiCheckDelay) //没布带了 { MXC_SetAlarmCode(MXC_NO_ZIPPER_ALARM); //没拉链 MXC_GouZhen_VAVLE = 0; } } break; case 51: if(!X_DRV) { MXC_cMotorStep = 0; } else if(dwTickCount >= MXC_cAutoDelay) { MXC_SetAlarmCode(MXC_NO_SEBIAO_ALARM); // } //布带对射检测 if(MXC_Zipper_IN) { MXC_cBudaiCheckDelay = dwTickCount + 140; } else if(dwTickCount >= MXC_cBudaiCheckDelay) //没布带了 { MXC_SetAlarmCode(MXC_NO_ZIPPER_ALARM); //没拉链 MXC_GouZhen_VAVLE = 0; } break; } } //下冲 void MXC_NiLongXiuCiJi_XiaC(void) { switch(MXC_cXiaChongStep) { case 0: return; break; case 1: MXC_cXiaChongStep = 2; MXC_XC_SongZhou = 0; //刹车打开 MXC_cXiaChongDelay = dwTickCount + (unsigned long)7; //刹车放开时间 //下止输出 if(bRunning)MXC_Output_XiaCi(); break; case 2: if(dwTickCount >= MXC_cXiaChongDelay) { MXC_cXiaChongStep = 3; MXC_XiaChong_MOTOR = 1; //下冲电机 MXC_cXiaChongDelay = dwTickCount + (unsigned long)ERRORTIME; //下冲最长时间 if(MXC_XiaChongMotorMode == 1) { AxisMoveTwoPos(Y_AXIS,MXC_XiaChongSpeed,2000,MXC_XiaChongLowSpeed,9999999,0); MXC_ChuiQi_VAVLE = 1; } } break; case 3: //碰到右大微动,延时停 if(MXC_XiaChong_IN_UP) { MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_XC_DELAY; MXC_cXiaChongStep = 4; MXC_LeftFenZhen_VAVLE = 0; //退左分针 MXC_RightFenZhen_VAVLE = 0; //退右分针 MXC_cGouZhenTime = dwTickCount + (unsigned long)150; //勾针延时退 MXC_GouZhen_VAVLE = 1; MXC_GuDingGouZhen = 1; } else if(dwTickCount >= MXC_cXiaChongDelay) //自动停机 { MXC_cXiaChongStep = 0; MXC_ShaChe_Output();////刹车 MXC_XiaChong_MOTOR = 0;// //下冲电机 MXC_SetAlarmCode(MXC_XC_ALARM); MXC_LeftFenZhen_VAVLE = 0; //退左分针 MXC_RightFenZhen_VAVLE = 0; //退右分针 AxisEgmStop(Y_AXIS); } break; case 4: if(dwTickCount >= MXC_cXiaChongDelay) { MXC_cXiaChongStep = 5; AxisEgmStop(Y_AXIS); MXC_XiaChong_MOTOR = 0; //延时刹车 MXC_cXiaChongDelay = dwTickCount + MXC_PARAM_SC_DELAY; } break; case 5: if((dwTickCount >= MXC_cXiaChongDelay)) { MXC_cXiaChongStep = 6; MXC_ShaChe_Output(); MXC_cXiaChongDelay = dwTickCount + (unsigned long)30; } break; case 6: if(!MXC_XiaZhi_VAVLE && !MXC_ChaoSheng && (dwTickCount >= MXC_cXiaChongDelay)) { MXC_cXiaChongStep = 0; } break; case 20: // 点动普通下冲动作 MXC_XC_SongZhou = 0; MXC_cXiaChongDelay = dwTickCount + 50; MXC_cXiaChongStep = 21; break; case 21: if((dwTickCount >= MXC_cXiaChongDelay)) { MXC_XiaChong_MOTOR = 1; MXC_cXiaChongDelay = dwTickCount + 50; MXC_cXiaChongStep = 22; } break; case 22: if((dwTickCount >= MXC_cXiaChongDelay)) { MXC_XiaChong_MOTOR = 0; MXC_XC_SongZhou = 1; if(MXC_XiaChongMotorMode) MXC_cXiaChongStep = 0; else { MXC_cXiaChongDelay = dwTickCount + 150; MXC_cXiaChongStep = 23; } } break; case 23: if((dwTickCount >= MXC_cXiaChongDelay)) { MXC_XC_SongZhou = 0; MXC_cXiaChongStep = 0; } break; case 40: // 点动电机下冲动作 MXC_XC_SongZhou = 0; MXC_cXiaChongDelay = dwTickCount + 50; MXC_cXiaChongStep = 41; break; case 41: if(!Y_DRV)AxisMovePos(Y_AXIS,20,10); MXC_cXiaChongStep = 42; break; case 42: if(!Y_DRV) { MXC_cXiaChongStep = 0; } break; } } //启动分针 void MXC_Start_FenZ(void) { } //分针 void MXC_NiLongXiuCiJi_FenZhengProc(void) { if(MXC_FenZSelect != 0) { MXC_cLeftFenZhenStep = 0; MXC_cRightFenZhenStep = 0; } //右分针 switch(MXC_cRightFenZhenStep) { case 0: break; case 1: MXC_cFenZhenRightDelay = MXC_PARAM_R_FZ_DELAY+dwTickCount; MXC_cRightFenZhenStep = 2 break; case 2: if(dwTickCount >= MXC_cFenZhenRightDelay) { MXC_cRightFenZhenStep = 3; MXC_RightFenZhen_VAVLE = 1;//右分针电磁阀 MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime; } break; case 3: //碰到右大微动,延时停 if(!MXC_RightFenZhen_Origin_IN) //右分针原点离开 { MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime; MXC_cLeftFenZhenStep = 4; }//右分针不下去 else if(dwTickCount >= MXC_cFenZhenLeftDelay) { MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM); } break; case 4: if(MXC_RighttFenZhen_IN) //插针到位 { MXC_cRightFenZhenStep = 0; MXC_cLeftFenZhenStep = 1; //左分针延时启动 } else if(dwTickCount >= MXC_cFenZhenLeftDelay) { MXC_RightFenZhen_VAVLE = 0;//右分针 cRFengTimer++; //当右分针分不到位时,左分针也要重新分针 MXC_LeftFenZhen_VAVLE = 0; MXC_cRightFenZhenStep = 0; if(cRFengTimer < 4) { MXC_cLeftFenZhenStep = 5; MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime; } else { MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM); } } break; case 5: if(MXC_RightFenZhen_Origin_IN) //退到位 { MXC_cRightFenZhenStep = 6; } else if(dwTickCount >= MXC_cFenZhenLeftDelay) { MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM); } break; case 6: { MXC_cRightFenZhenStep = 1; } break; } //左分针 switch(MXC_cLeftFenZhenStep) { case 0: break; case 1: MXC_cFenZhenLeftDelay = MXC_PARAM_L_FZ_DELAY+dwTickCount; MXC_cLeftFenZhenStep = 2; break; case 2: if(dwTickCount >= MXC_cFenZhenLeftDelay) { MXC_cLeftFenZhenStep = 3; MXC_LeftFenZhen_VAVLE = 1; //左分针电磁阀 MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime; } break; case 3: //离开左分针原点 if(!MXC_LeftFenZhen_Origin_IN) //左分针原点离开 { MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime; MXC_cLeftFenZhenStep = 4; }//左分针不下去 else if(dwTickCount >= MXC_cFenZhenLeftDelay) { MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM); } break; case 4: if(MXC_LeftFenZhen_IN) //插针到位 MXC_cLeftFenZhenStep = 0; else if(dwTickCount >= MXC_cFenZhenLeftDelay) { MXC_LeftFenZhen_VAVLE = 0;//左分针 cLFengTimer++; if(cLFengTimer < 6) { MXC_cLeftFenZhenStep = 5; MXC_cFenZhenLeftDelay = dwTickCount + FenZhengErrorTime; if((cLFengTimer%2) == 0) { MXC_RightFenZhen_VAVLE = 0; MXC_cRightFenZhenStep = 0; } } else { MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM); } } break; case 4: if(MXC_LeftFenZhen_Origin_IN) //退到位 { MXC_cLeftFenZhenStep = 5; } else if(dwTickCount >= MXC_cFenZhenRightDelay) { MXC_SetAlarmCode(MXC_FEN_ZHEN_ALARM); } break; case 5: if((cLFengTimer%2) == 0) //左边插两次都插不到,就退右边再同时插 { MXC_cRightFenZhenStep = 1; cRFengTimer = 0; MXC_cLeftFenZhenStep = 0; } else { MXC_cLeftFenZhenStep = 1; } break; } } #endif