123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494 |
- #include "global.h"
- #if HONG_YE_MACHINE
- //免修齿
- //输入说明
- //X000 启动
- //X001 停止
- //X002 手动下冲
- //X003 勾针到位接近开关
- //X004 减速信号
- //X005 卡带、数量到
- //X006 左分针退到位
- //X007 左分针到位信号
- //STOP_IN0 下冲原位
- //STOP_IN1 右分针退到位
- //STOP_IN2 右分针到位信号
- //
- //STOP_IN3 左大微动(吹气信号)
- //STOP_IN4 有链检测(数控定寸时的光电开关,不用是请接电源的GND)
- //STOP_IN5 色标信号
- //STOP_IN6 下止选择(有触摸屏时不用接)
- //STOP_IN7 发超声信号
- //X020 分带信号
- //X021 过链(固定勾针)接近开关
- //X022 0普通勾针方式,1勾针固定方式
- //输出说明
- //输出说明
- //Y000 离合器(离合器方式时才接线)
- //Y001 刹车
- //Y002 吹气电磁阀
- //Y003 下止电磁阀
- //Y004 左分针电磁阀
- //Y005 勾针/储带
- //Y006 右分针电磁阀
- //Y007 下冲电机/
- //Y010 超声输出/
- //Y011 计数(不用触摸屏用)
- //Y012 拖带电机(步进型不用接)
- //Y013 分带电磁阀
- //Y014 储带
- //Y015 固定勾针
- //Y017 拖带步进松轴/伺服电机使能
- //步进驱动 板
- //PU+ PU+
- //PU- PU-
- //MF+ 24V
- //MF- Y17
- /*
- D[0] 下止电磁阀输出时间
- D[1] 吹气时间
- D[2] 超声时间
- D[3] 延时刹车
- D[4] 刹车时间
- D[5] 延时停下冲电机
- D[6] 起动速度
- D[7] 加速度
- D[8] 最高速度
- D[9] 空位最低速度
- D[10] 定位时间(慢速长度)
- D[11] 动作配置 {D11->0 0普通下止,1超声下止;D11->1 0刹车不释放,1释放,
- }
- D[12] 延时上勾针
- D[13] 模具长度(刀口长度)
- D[14] 拖带轮长度
- D[15] 拉链长度低位
- D[16] 拉链长度高位
- D[17] 修正长度低位
- D[18] 修正长度高位
- D[19] 勾针伺服选择
- D[20] 下止选择{0 选择,1 不下止}
- D[21] 勾针定寸时的减速方式(0勾针减速信号,1长度自动减速同用)
- D[22] 产量设定低位
- D[23] 产量设定高位
- D[24] 勾针方式选择 D24 0普通勾针方式,1勾针固定方式
- D[25] 固定勾针方式时感应信号(0, 空位时亮,空位时灭)
- D[26] 延时发超声
- D[27] 下冲电机配置(0,普通电机,1 步进电机)
- D[28] 下冲电机的起动速度
- D[29] 下冲电机的最高速度
- D[30] 拖带电机配置(0 步进 1 伺服)
- D[31] 延时吹气
- D[32] 勾针定寸方式第一条的最高速度
- */
- void MXC_NiLongXiuCiJiCheckStart(void);
- void CuiQi_Start(void);
- void ShaChe_Output(void);
- void Output_XiaCi(void);
- void Close_XiaCi(void);
- void NiLongXiuCiJi_Motor(void);
- void NiLongXiuCiJi_XiaC(void);
- void Start_FenZ(void);
- void NiLongXiuCiJi_FenZhengProc(void);
- void ChuiQiProc(void);
- void 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,cHMI_Test;
- long cSetEncode,cTotal,cDinWeiTime,cAddSetPulseNum,cEncodePulse,cWorkPulseNum;
- void MXC_InitAction(void)
- {
- MXC_XC_SongZhou = 1;
- XIA_ZHI_ENABLE = 0;
-
- if(MOTOR_MODE == 0)
- MXC_TuoDaiSongZhou = 1;
- else
- MXC_TuoDaiSongZhou = 0;
- if(XIA_ZHI_ENABLE)
- MXC_XiaZhi_MOTOR = 1;
- else
- MXC_XiaZhi_MOTOR = 0;
- }
- void MXC_NiLongXiuCiJiAction(void)
- {
- MXC_NiLongXiuCiJiCheckStart(); //启动
- NiLongXiuCiJi_FenZhengProc(); //左右分针
- NiLongXiuCiJi_XiaC(); //下冲
- NiLongXiuCiJi_Motor(); //拖带控制
- JiaoDao();
- MXC_ManualAction();
- MXC_AutoAction();
- /* if(cHMI_Test == 0)
- {
- if(user_datas[100] < 32)
- {
- if(user_datas[75] == 6) //输入
- {
- user_datas[100] += 48;
- }
- else if(user_datas[75] == 7) //输出
- user_datas[100] += 32;
- }
- } */
- }
- void MXC_ManualAction(void)
- {
- long i;
- //清总产量
- if(MXC_bClear) //清总产量
- {
- MXC_bClear = 0;
- ClrcToTal(76);
- }
- //当长度改变时,生产总量自动清零
- if(MXC_bChangeLength)
- {
- MXC_bChangeLength = 0;
- i = SET_ZIPPER_LENGTH;
- if(cLaLianLine != i)
- {
- cLaLianLine = i;
- SetZipperLength(17,0);
- ClrcToTal(76);
- }
- }
- //加10
- if(MXC_bAddLength)
- {
- MXC_bAddLength = 0;
- i = SET_REVISE_ZIPPER_LENGTH;
- i += 10;
- SetZipperLength(17,i);
- }
- //减10
- if(MXC_bDecLength)
- {
- MXC_bDecLength = 0;
- i = SET_REVISE_ZIPPER_LENGTH;
- i -= 10;
- SetZipperLength(17,i);
- }
- //工作方式选择(数控定寸和勾针定寸)
- if(MXC_bSetDCMode)
- {
- MXC_bSetDCMode = 0;
- if(!bRunning)
- {
- DC_MODE++;
- if(DC_MODE > 2)DC_MODE = 0;
-
- if(DC_MODE != 0)
- {
- MXC_GouZhen_VAVLE = 1;
- XIA_ZHI_ENABLE = 0;
- MXC_XiaZhi_MOTOR = 0;
- }
- }
- }
- //勾针方式选择(活动勾针和固定勾针)
- if(MXC_bChangeGouZhenMode)
- {
- MXC_bChangeGouZhenMode = 0;
- if(!bRunning)
- {
- GOU_ZHEN_MODE++;
- if(GOU_ZHEN_MODE > 1)GOU_ZHEN_MODE = 0;
- }
- }
- //下止工作选择)
- if(MXC_bChangeXiaZhiMode)
- {
- MXC_bChangeXiaZhiMode = 0;
- if(!bRunning)
- {
- XIA_ZHI_ENABLE++;
- if(XIA_ZHI_ENABLE > 1)XIA_ZHI_ENABLE = 0;
-
- if(XIA_ZHI_ENABLE)
- MXC_XiaZhi_MOTOR = 1;
- else
- MXC_XiaZhi_MOTOR = 0;
- }
- }
- if(MXC_bJiaoDao)
- {
- cJiaoDaoStep = 1;
- MXC_bJiaoDao = 0;
- }
- //吹气
- if((MXC_ChuiQi_VAVLE == 0))
- {
- if(MXC_DingChuPian_IN_DW)
- {
- MXC_bChuiQi = 0;
- cChuiQiDelay = dwTickCount + 10*PARAM_DELAY_CHUIQI_TIME;
- cChuiQiStep = 1;
- }
- else if(MXC_bChuiQi == 1)
- {
- MXC_bChuiQi = 0;
- cChuiQiDelay = 0;
- cChuiQiStep = 1;
- }
- }
- ChuiQiProc();
- if(MXC_ChuiQi_VAVLE && (dwTickCount >= cChuiQiDelay))
- {
- MXC_ChuiQi_VAVLE = 1;//
- MXC_XiChiChuiQi = 1;
- cChuiQiDelay = dwTickCount + 10 * PARAM_CHUIQI_TIME;
- }
- if(MXC_XiChiChuiQi && (dwTickCount >= cChuiQiDelay))
- {
- MXC_XiChiChuiQi = 0;
- }
- //刹车方式
- if(ShaCheMode)
- {
- if(MXC_XC_SongZhou && (dwTickCount >= cShaCheTime) && (XiaCongMotorMode == 0)) MXC_XC_SongZhou = 0;
- }
-
- if((bRunning) == 0) ////手动
- {
-
- if(DC_MODE != 0) //伺服定寸
- {
-
- MXC_GuDingGouZhen = 1;
- MXC_GouZhen_VAVLE = 1;
- }
- else if((GouZMode == 0) )//普通勾针(活动)过链
- {
- if(dwTickCount >= cGouZhenTime)
- MXC_GouZhen_VAVLE = 0;
- }
- else
- {
- if(XiaMode) //0普通下止,1超声下止
- {
- if(MXC_GuoLian_IN_UP)
- {
- MXC_GuDingGouZhen = 0;
- }
- }
- else //刘铁方式(下拉一下就可以复位)
- {
- if(MXC_GuDingGouZhen && (dwTickCount >= 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
- Output_XiaCi();
- }
- else if(MXC_XiaZhi_IN_DW)
- {
- MXC_XiaZhi_VAVLE = 0; //下止电磁阀
- MXC_ChaoSheng = 0; //超声输出
- MXC_FenDai_VAVLE = 0; //分带输出
- }
- Close_XiaCi();
-
- if(MXC_bChuDai)
- {
- MXC_ChuDai_VAVLE = 1;
- }
- else
- {
- MXC_ChuDai_VAVLE = 0;
- }
-
- if((!STOP_IN) && (MXC_ManXiaChong_UP || (MXC_bXiaChong)) && (bHandWork == 0))//加模到位 2006.7.31
- {
- MXC_bXiaChong = 0;//cMidleCoil[0] &= ~((1<<3));
- cAutoStep = 1;
- MXC_XiaChong_MOTOR = 0;
- bHandWork = 1;
- }
-
- switch(cAutoStep)
- {
- case 1: //先启动分针
- Start_FenZ();
- cAutoStep = 2;
- break;
- case 2://左右分针都已完成
- if((cLeftFenZhenStep == 0) && (cRightFenZhenStep == 0))
- {
- cXiaChongStep = 1; //下冲电机启动
- cAutoStep = 3;
- }
- break;
- case 3: //下冲已完成
- if(cXiaChongStep == 0)
- {
- MXC_LeftFenZhen_VAVLE = 0;
- MXC_RightFenZhen_VAVLE = 0;
- cAutoStep = 4;
- cAutoDelay = dwTickCount + 50;
- }
- break;
- case 4:
- if(dwTickCount >= cAutoDelay)
- {
- cAutoStep = 5;
- }
- break;
- case 5:
- if((dwTickCount >= cGouZhenTime))
- {
- bHandWork = 0;
- cAutoStep = 0;
- if(DC_MODE == 0)
- {
- MXC_GouZhen_VAVLE = 0;
- }
- }
- break;
-
- }
- if(bHandWork == 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_bGouZhen)
- {
- MXC_bGouZhen = 0;//cMidleCoil[0] &= ~((1<<9));
- cGouZhenTime = dwTickCount + (unsigned long)300; //勾针延时退
- if((GouZMode == 0))//普通勾针(活动)过链
- {
- if(MXC_GouZhen_VAVLE)
- MXC_GouZhen_VAVLE = 0;
- else
- {
- MXC_GouZhen_VAVLE = 1;
- }
- }
- else //固定勾针
- {
- if(MXC_GuDingGouZhen)
- MXC_GuDingGouZhen = 0;
- else
- {
- MXC_GuDingGouZhen = 1;
- }
- }
- }
- //点动下冲
- if((MXC_bDotXiaChong))
- {
- MXC_bDotXiaChong = 0;
- if(MXC_LeftFenZhen_IN && MXC_RighttFenZhen_IN)
- {
- MXC_bDotXiaChongDisplay = 1;
- MXC_XiaChong_MOTOR = 1;//下冲电机
- bPulseTatol_EN = 1;
- if(XiaCongMotorMode == 0)
- cAutoDelay = dwTickCount + 50;
- else
- {
- MXC_XC_SongZhou = 0;
- cAutoDelay = dwTickCount + 65;
- AxisContinueMove(X_AXIS,PARAM_LOW_SPEED,0);
-
- }
- }
- else
- {
- SetAlarmCode(100,MXC_XIA_CHONG_ALARM); //下冲条件不满足
- // user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
- }
- if((!MXC_XiaChong_MOTOR) && (dwTickCount >= cAutoDelay) && (MXC_bDotXiaChongDisplay))
- {
- MXC_XiaChong_MOTOR = 1; //下冲电机
- }
- if((MXC_XiaChong_MOTOR) && (dwTickCount >= cAutoDelay) && (MXC_bDotXiaChongDisplay))
- {
- bPulseTatol_EN = 0;
- AxisDecStop(X_AXIS);
- MXC_XiaChong_MOTOR = 0; //下冲电机
- MXC_bDotXiaChongDisplay = 0;
- ShaChe_Output();//
- }
- }
- else
- {
- MXC_bLeftFenZhen = 0;MXC_bRightFenZhen = 0;MXC_bDotXiaChong = 0;MXC_bDotXiaChongDisplay = 0;MXC_bGouZhen = 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((DC_MODE == 0) && (GouZMode == 0))
- {
- if(MXC_GouZhen_IN_UP)cGouZhenTime = 1;
- }
- else
- cGouZhenTime = 1;
-
- switch(cAutoStep)
- {
- case 0:
- break;
- case 1:
- //左右分针要退到位,过链到位要离开
- if(MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_LeftFenZhen_IN && !MXC_RighttFenZhen_IN && (dwTickCount >= cAutoDelay))
- {
- cAutoStep = 2;
- cMotorStep = 1; //启动拖带
- }
- break;
- case 2:
- //拖带已经完成
- if(cMotorStep == 0)
- {
- bFirst = 1;
- //调试功能
- if(DC_MODE != 2)cAutoStep = 3;
-
- // 调试功能 下一条 下冲
- else if((!MXC_bDingWei) || MXC_bNext || MXC_ManXiaChong_UP || MXC_bXiaChong)
- {
- if(MXC_bNext)
- {
- cAutoStep = 1;
- MXC_bNext = 0;
- cInt1_OK = 0;
-
- }
- else
- {
- cAutoStep = 3;
- MXC_bDingWei = 0;
- }
- }
- cAutoDelay = dwTickCount + 5; //延时分针
- }
- break;
- case 3:
- if((dwTickCount >= cAutoDelay) && cGouZhenTime)
- {
- cGouZhenTime = 0;
- cAutoStep = 4;
- Start_FenZ();
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 1; //下冲电机
- }
- }
- break;
- case 4:
- //左右分针都已完成
- if((cLeftFenZhenStep == 0) && (cRightFenZhenStep == 0))
- {
- cXiaChongStep = 1; //下冲电机启动
- cAutoStep = 5;
- AddToTal(76); //计数增加和保存
- CalProSP(78);
- }
- break;
- case 5: //下冲已完成
- if(cXiaChongStep == 0)
- {
- cAutoStep = 6;
- cAutoDelay = dwTickCount + (unsigned long)15; //延时检测退到位
- }
- break;
- case 6:
- if(dwTickCount >= cAutoDelay)
- {
- if(MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_LeftFenZhen_IN && !MXC_RighttFenZhen_IN)
- {
- cAutoDelay = dwTickCount + (unsigned long)15; //延时检测退到位
- cAutoStep = 7;
- i = SET_TOTAL;
- if(cTotal >= i)
- {
- cStopFlag = 1;
- SetAlarmCode(100,MXC_FEN_ZHEN_ALARM);//分针不成功
- // user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
- }
- }
- break;
- case 7:
- if((dwTickCount >= cAutoDelay) && (MXC_Dec_IN || user_datas[21] || DC_MODE))
- {
- if(cOneTimes == 0)
- {
- cAutoStep = 1;
- }
- else
- {
- cStopFlag = 1;
- }
- }
- break;
- case 8:
- if((dwTickCount >= cAutoDelay))
- {
- if(DC_MODE == 0)
- {
- cAutoStep = 9;
- }
- else
- {
- if(cOneTimes == 0)
- {
- cAutoStep = 1;
- }
- else
- {
- cStopFlag = 1;
- }
- }
- }
- break;
- case 9:
- if((dwTickCount >= cGouZhenTime) && (MXC_Dec_IN == 1))
- {
- MXC_GouZhen_VAVLE = 0;
-
- if(cOneTimes == 0)
- {
- cAutoStep = 1;
- }
- else
- {
- cStopFlag = 1;
- }
- }
- break;
-
- }
- }
- }
- // 检测是否踏了脚踏开关
- void MXC_NiLongXiuCiJiCheckStart(void)
- {
- // 停止键 不能在工作,手动,停止过程中
- if((!STOP_IN) && (bHandWork == 0) && (bRunning == 0) && (cStopFlag==0)
- // 启动
- && (START_IN_UP || (MXC_bStart)) && (cKey_Time == 0) && (!MXC_GuoLian_IN))
- {
- if(MXC_LeftFenZhen_Origin_IN && MXC_RightFenZhen_Origin_IN && !MXC_KaDai_IN)
- {
- bRunning = 1;
- MXC_bClearAlarm = 1;
- cKey_Time = 10;
- cAutoStep = 1;
- cMotorStep = 0;
- cXiaChongStep = 0;
- cLeftFenZhenStep = 0;
- cRightFenZhenStep = 0;
- SetAlarmCode(100,MXC_NO_ALARM);
- cAutoDelay = dwTickCount + (unsigned long)200; //先锁轴
-
- cOneTimes = 0;
- cGouZhenTime = 1;
- MXC_XiaChong_MOTOR = 0; //
- if(XiaCongMotorMode == 1)
- {
- MXC_XC_SongZhou = 0;
- }
-
- if(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 >= cKaDaiDelay))
- {
- SetAlarmCode(100,MXC_KA_DAI_ALARM); //警告清
- // user_datas[75] = 5; //页面跳转
- cKaDaiDelay = dwTickCount + 2200;
- }
- if(MXC_KaDai_IN_UP)
- {
- MXC_bSaveWorkData = 1;
- }
- //停止
- if((STOP_IN_UP || (MXC_bStop)))
- {
- // 不是下冲状态
- if((cXiaChongStep == 0) && (bRunning == 0))
- {
- CuiQi_Start();
- if(!MXC_XiaChong_MOTOR)MXC_XC_SongZhou = 1;
- }
-
- if((cStopFlag == 0) && (cKey_Time == 0))
- {
- cKey_Time = 4;
- if(((DC_MODE == 0) || STOP_IN_UP) && ((XiaCongMotorMode == 0) || (cXiaChongStep == 0)))
- {
- AxisDecStop(X_AXIS);
- }
- MXC_GuDingGouZhen = 0;
-
-
-
- CuiQi_Start();
- if(X_DRV && !MXC_XiaChong_MOTOR && (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(MOTOR_MODE == 0)
- MXC_TuoDaiSongZhou = 1;
- else
- MXC_TuoDaiSongZhou = 0;
- }
-
- }
- cKaDaiDelay = dwTickCount + 1200;
- cGouZhenTime = dwTickCount + (unsigned long)300; //勾针延时退
- }
- MXC_bStop = 0;
- MXC_bSaveWorkData = 1;
- }
- if((cXiaChongStep == 0) && (((cStopFlag) != 0) || (MXC_KaDai_IN)))
- {
- bRunning = 0;
- bHandWork = 0;
-
- cStopFlag = 0;
- cAutoStep = 0;
- cMotorStep = 0;
- cXiaChongStep = 0;
- cLeftFenZhenStep = 0;
- 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(MOTOR_MODE == 0)
- MXC_TuoDaiSongZhou = 1;
- else
- MXC_TuoDaiSongZhou = 0;
- }
- if(MXC_KaDai_IN_UP)CuiQi_Start();
-
- MXC_XC_SongZhou = 1; // 刹车
-
- if(GouZMode != 0) //超声(固定)勾针
- MXC_GuDingGouZhen = 1;
- if(DC_MODE != 0)
- {
- if(X_DRV)cGuZhangStop = 1;
- }
- else
- AxisDecStop(X_AXIS);
-
- cGouZhenTime = dwTickCount + (unsigned long)300; //勾针延时退
- }
- }
- void JiaoDao(void)
- {
- if(cJiaoDaoStep == 1)
- {
- cChuiQiDelay = dwTickCount + 500;
- MXC_JiaoDao_OUT = 1;
- cJiaoDaoStep = 2;
- }
- else if((cJiaoDaoStep == 2) && (dwTickCount >= cChuiQiDelay))
- {
- MXC_JiaoDao_OUT = 0;
- cJiaoDaoStep = 0;
- }
- }
- void CuiQi_Start(void)
- {
- //启动吹气
- cChuiQiDelay = dwTickCount + (unsigned long)50 * PARAM_CHUIQI_TIME;
- MXC_ChuiQi_VAVLE = 1;
- MXC_XiChiChuiQi = 0;
- }
- void ChuiQiProc(void)
- {
- if(cChuiQiStep == 0)
- {
- }
- else if((cChuiQiStep == 1) && (dwTickCount >= cChuiQiDelay))
- {
- CuiQi_Start();
- cChuiQiStep = 0;
- }
- }
- void ShaChe_Output(void)
- {
- //启动吹气
- cShaCheTime = dwTickCount + (unsigned long)120;
- if(XiaCongMotorMode == 0)MXC_XC_SongZhou = 1;
- }
- void Output_XiaCi(void)//下止输出
- {
- if(MXC_XiaZhi_IN || (XIA_ZHI_ENABLE && cHMI_Test)) //下止选择
- {
- //下止输出
- cXiaZhiDelay = dwTickCount + 10 * PARAM_XIAZHI_TIME;
- MXC_XiaZhi_VAVLE = 1;
- }
- }
- //关下止动作
- void Close_XiaCi(void)
- {
- if((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)
- {
- cXiaZhiDelay = dwTickCount + 10 * PARAM_XIAZHI_DELAY_TIME;
- }
- if(MXC_GuoLian_IN && MXC_XiaZhi_VAVLE)
- {
- if(!MXC_ChaoSheng && (dwTickCount >= cXiaZhiDelay))
- {
- MXC_ChaoSheng = 1;
- cXiaZhiDelay = dwTickCount + (unsigned long)10 * PARAM_CHAOSHENG_TIME;
- }
- if(MXC_ChaoSheng && (dwTickCount >= cXiaZhiDelay))
- {
- MXC_FenDai_VAVLE = 0; //分带输出
- MXC_ChaoSheng = 0; //超声输出
- MXC_XiaZhi_VAVLE = 0; //下止阀
- }
- }
- }
- }
- else
- {
- //下止下冲电磁铁
- if((MXC_XiaZhi_VAVLE != 0) && (dwTickCount >= cXiaZhiDelay))
- {
- MXC_XiaZhi_VAVLE = 0;
- }
- }
- }
- unsigned long LengthCallPulse(unsigned long length)
- {
- return (length * 2000 / PARAM_DAILUN_LENGTH);
- }
- void NiLongXiuCiJi_Motor(void)
- {
- unsigned long ch;
- switch(cMotorStep)
- {
- case 0:
- return;
- break;
- // 过链 左分针退位 左到位
- case 1: if(MXC_LeftFenZhen_Origin_IN && (!MXC_LeftFenZhen_IN) && MXC_RightFenZhen_Origin_IN && (!MXC_RighttFenZhen_IN))
- {
- cAutoDelay = dwTickCount + (unsigned long)35; //延时检测
- MXC_LIHE_VAVLE = 1; //离合器
-
- //计算长度脉冲
- // 拉链长度
- ch = SET_ZIPPER_LENGTH;
- if(DC_MODE != 2)
- {
- ch += SET_REVISE_ZIPPER_LENGTH;
- ch += PARAM_DAOKOU_LENGTH;//模具长度(刀口长度)
- }
-
- cSetEncode = LengthCallPulse(ch);
-
- //慢速长度
- ch = LengthCallPulse(PARAM_LOWSPEED_LENGTH);
-
- //色标的定位长度
- cDinWeiTime = LengthCallPulse(PARAM_SEBIAO_DW_LENGTH);
- //色标提前检测距离
- cAddSetPulseNum = LengthCallPulse(PARAM_SEBIAO_TQ_LENGTH);
- cEncodePulse = 0;
- cInt1_OK = 0;
-
- if(DC_MODE == 0)
- {
- if((GouZMode == 0))//普通勾针(活动)过链
- {
- cMotorStep = 2;
-
- if(bFirst == 0)
- AxisMoveTwoPos(X_AXIS,PARAM_FIRST_SPEED,cSetEncode - ch,PARAM_LOW_SPEED,9999999,0);
- else
- AxisMoveTwoPos(X_AXIS,PARAM_SET_SPEED,cSetEncode - ch,PARAM_LOW_SPEED,9999999,0);
- }
- else //带下止型勾针
- {
- cMotorStep = 11;
- if(bFirst == 0)
- AxisMoveTwoPos(X_AXIS,PARAM_FIRST_SPEED,cSetEncode - ch,PARAM_LOW_SPEED,9999999,0);
- else
- AxisMoveTwoPos(X_AXIS,PARAM_SET_SPEED,cSetEncode - ch,PARAM_LOW_SPEED,9999999,0);
- cAutoDelay = dwTickCount + (unsigned long)70; //延时检测
- }
-
- cGuZhangStop = 0;
- cWorkPulseNum = 0;
-
- if(!MXC_GouZhen_VAVLE)
- {
- cMotorStep = 3;
- }
- }
- else if(DC_MODE == 1)
- {
- cMotorStep = 20;
- MXC_GouZhen_VAVLE = 1; //定位(活动勾针)电磁阀
- MXC_GuDingGouZhen = 1; //定位(活动勾针)电磁阀
- cAutoDelay = dwTickCount + 130; //要检测对射
-
- if(cWorkPulseNum >= cSetEncode)cMotorStep = 0;
- else
- {
- AxisMovePos(X_AXIS,PARAM_SET_SPEED,cSetEncode);
- }
- }
- else
- {
- if(cWorkPulseNum >= cSetEncode)cMotorStep = 0;
- else
- {
- AxisMoveTwoPos(X_AXIS,PARAM_SET_SPEED,cSetEncode - ch,PARAM_LOW_SPEED,9999999,0);
- }
- }
- }
- break;
- // step2-5 活动勾针定寸
- case 2:if((dwTickCount >= cAutoDelay))
- {
- MXC_GouZhen_VAVLE = 0;//定位电磁阀
- }
- if(!MXC_GouZhen_VAVLE && !MXC_GouZhen_IN)
- {
- if(!PWM_RUN_STATE)
- TuoDaiStartPWM(cStepNum);
- cStepMode = 1; //加速模式
- cMotorStep = 3;
- cAutoDelay = dwTickCount + (unsigned long)10000;
- }
- break;
- case 3:
- if(cStepNum > (cLowSpeadLimit + 1))
- {
- cAutoDelay = dwTickCount + (unsigned long)10000;
- }
- //减速信号方式 数控减速方式
- if(((IN04 != 0) && (user_datas[21] == 0)) || ((cPulseStepDEC >= cPulseCount) && (user_datas[21] == 1)))
- {
- user_datas[126] = cPulseCount;
- cSPDec = 3;
- cStepNum = cLowSpeadLimit+1;
- cPulseCount = cPulseStepDEC;
- cStepMode = 2; //减速模式
- cMotorStep = 4;
- cAutoDelay = dwTickCount + (unsigned long)10000;
- }
- if((MXC_GouZhen_IN)) //X003 到位信号也要停
- {
- cStepMode = 2; //减速模式
- cMotorStep = 4;
- CLRQ00; //离合器断开
- StopPWM(); //PWMTCR = 0x02; //在设置之前,先将定时器复位
- }
- else if((dwTickCount >= cAutoDelay) && (cStepNum <= cLowSpeadLimit))
- {
- cStopFlag = 1;
- user_datas[100] = 7; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
- break;
- case 4:
- if(MXC_GouZhen_IN)
- {
- cMotorStep = 0;
- StopPWM();//PWMTCR = 0x02; //在设置之前,先将定时器复位
-
- }
- else if((dwTickCount >= cAutoDelay))
- {
- cStopFlag = 1;
- user_datas[100] = 7; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
-
- /*
- //布带对射检测
- if(X14)
- {
- cBudaiCheckDelay = dwTickCount + 30000;
- }
- else if(dwTickCount >= cBudaiCheckDelay) //没布带了
- {
- cStopFlag = 1;
- user_datas[100] = 7; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_GouZhen_VAVLE = 0;
- MXC_bSaveWorkData = 1;
- }
- */
- break;
- //以下为固定勾针方式
-
- case 11:
- if(XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针
- {
- if(dwTickCount >= cAutoDelay)MXC_GuDingGouZhen = 0;
- if(!X21)
- {
- cSPDec =1; //减速度
- cStepMode = 2; //减速模式
- cMotorStep = 12;
- cAutoDelay = dwTickCount + (unsigned long)1500; //延时检测
- }
- }
- else
- { bFlag = X21;
- if(GuoLianCheckMode)
- bFlag = ~bFlag;
- if(bFlag)
- {
- cStepMode = 2; //减速模式
- cMotorStep = 12;
- cAutoDelay = dwTickCount + (unsigned long)user_datas[12]; //延时检测
- }
- }
- break;
- case 12:
- if(dwTickCount >= cAutoDelay)
- {
- if(Y15)
- {
- MXC_GuDingGouZhen = 0;
- cAutoDelay = dwTickCount + (unsigned long)1500; //延时检测
- }
- else if(!Y15)
- {
- cStopFlag = 1;
- user_datas[100] = 7; //没链停机
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
- }
- if(XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针
- {
- if(!IN21)
- {
- MXC_GuDingGouZhen = 0;
- cMotorStep = 13;
- cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机
- }
-
- }
- else
- {
- if(GuoLianCheckMode)
- bFlag = X21_UP;
- else
- bFlag = X21_DW;
- if(bFlag)
- {
- MXC_GuDingGouZhen = 0;
- cMotorStep = 13;
- cAutoDelay = dwTickCount + (unsigned long)user_datas[10]; //延时停电机
- }
- }
- break;
- case 13:
- if((dwTickCount >= cAutoDelay))
- {
- if(XiaMode == 0) //0 普通下止 1 超声下止 当超声下时勾针
- {
- StopPWM();
- if(X21)
- {
- cMotorStep = 0;
- CLRQ00;
- }
- }
- else
- {
- if(GuoLianCheckMode)
- bFlag = !X21;
- else
- bFlag = X21;
- if(!bFlag)
- {
- cMotorStep = 0;
- StopPWM();
- CLRQ00;
- }
- }
- }
- if(MXC_Zipper_IN)
- {
- cBudaiCheckDelay = dwTickCount + 30000;
- }
- else if(dwTickCount >= cBudaiCheckDelay) //没布带了
- {
- cStopFlag = 1;
- SetAlarmCode(100,MXC_NO_ZIPPER_ALARM); //没拉链
- // user_datas[75] = 5; //页面跳转
- MXC_GouZhen_VAVLE = 0;
- MXC_bSaveWorkData = 1;
- }
- break;
-
- //伺服定寸
- case 20:
- if(!X_DRV)cMotorStep = 0;
-
- //布带对射检测
- if(MXC_Zipper_IN)
- {
- cAutoDelay = dwTickCount + 140;
- }
- else if(dwTickCount >= cAutoDelay) //没布带了
- {
- cStopFlag = 1;
- SetAlarmCode(100,MXC_NO_ZIPPER_ALARM); //没拉链
- // user_datas[75] = 5; //页面跳转
- MXC_GouZhen_VAVLE = 0;
- MXC_bSaveWorkData = 1;
- }
-
- break;
- case 50:
- cStopFlag = 1;
- SetAlarmCode(100,MXC_NO_SEBIAO_ALARM); //
- // user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
- }
- //下冲
- void NiLongXiuCiJi_XiaC(void)
- {
- if(bRunning)
- Close_XiaCi();
- switch(cXiaChongStep)
- {
- case 0:
- return;
- break;
- case 1:
- cXiaChongStep = 2;
- MXC_XC_SongZhou = 0;//cMidleCoil[2] &= ~Q01;//CLRY001; //刹车打开
- cDelayTime4 = dwTickCount + (unsigned long)7; //刹车放开时间
- //下止输出
- if(bRunning)
- Output_XiaCi();
- break;
- case 2:
- if(dwTickCount >= cDelayTime4)
- {
- bPulseTatol_EN = 1;
- cXiaChongStep = 3;
- MXC_XiaChong_MOTOR = 1;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- cDelayTime4 = dwTickCount + (unsigned long)ERRORTIME; //下冲最长时间
- cPulseCount = 0;
- cGuZhangStop = 0;
- if(XiaCongMotorMode == 1)
- {
- cStepMode = 4; //计脉冲模式
- cPulseCount = 2020;
-
- cSPDec = 3;
- cPulseStepCount = 0;
-
- cStepSet = user_datas[29];
- cPulseStepDEC = cStepSet * cSPDec + 250;
- cSPAdd = 12;//user_datas[30];
- cStepNum = user_datas[28];
- cLowSpeadLimit = cStepNum + 3;
- StartPWM(cStepNum);
- MXC_ChuiQi_VAVLE = 1;
- }
- }
- break;
- case 3: //碰到右大微动,延时停
- if((X10_UP))
- {
- cDelayTime4 = dwTickCount + (unsigned long)user_datas[5];//cSetPara[5];
- cXiaChongStep = 4;
- MXC_LeftFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q04;//CLRY004; //退左分针
- MXC_RightFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q06;//CLRY006; //退右分针
- cStepMode = 2; //减速模式
- cGouZhenTime = dwTickCount + (unsigned long)150; //勾针延时退
- MXC_GouZhen_VAVLE = 1;
- MXC_GuDingGouZhen = 1;
-
- }
- else if(dwTickCount >= cDelayTime4) //自动停机
- {
- bPulseTatol_EN = 0;
- StopPWM();
- cXiaChongStep = 0;
- cStopFlag = 1;
- ShaChe_Output();//MXC_XC_SongZhou = 1;//cMidleCoil[2] |= Q01;//SETY001; //刹车
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] &= ~Q00;//CLRY000; //下冲电机
- user_datas[100] = 5; //下冲异常
- user_datas[75] = 5; //页面跳转
- MXC_LeftFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q04;//CLRY004; //退左分针
- MXC_RightFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q06;//CLRY006; //退右分针
- MXC_bSaveWorkData = 1;
- }
-
- // if(X14_DW)
- // {
-
- // }
- break;
- case 4:
- // if(cStepNum <= cLowSpeadLimit)
- // StopPWM();
- if(dwTickCount >= cDelayTime4)
- {
- cXiaChongStep = 5;
- bPulseTatol_EN = 0;
- cWorkPulseNum = 0;
- StopPWM();
- MXC_XiaChong_MOTOR = 0; //延时刹车
- cDelayTime4 = dwTickCount + (unsigned long)user_datas[3];//cSetPara[3];
- }
- break;
- case 5:
- if((dwTickCount >= cDelayTime4))
- {
- cXiaChongStep = 6;
- ShaChe_Output();//MXC_XC_SongZhou = 1;//cMidleCoil[2] |= Q01;//SETY001;
- cDelayTime4 = dwTickCount + (unsigned long)30;
- }
- break;
- case 6:
- if(!X17 && !MXC_XiaZhi_VAVLE && !MXC_ChaoSheng && (dwTickCount >= cDelayTime4))
- {
- cXiaChongStep = 0;
- }
- break;
- }
- }
- //启动分针
- void Start_FenZ(void)
- {
- cDelayTime5 = dwTickCount + 30;
- cLeftFenZhenStep = 1;
- cRightFenZhenStep = 0;
- cRFengTimer = 0;
- cLFengTimer = 0;
- }
- #define FenZhengErrorTime 5000
- //分针
- void NiLongXiuCiJi_FenZhengProc(void)
- {
- if(FenZSelect != 0)
- {
- cLeftFenZhenStep = 0;
- cRightFenZhenStep = 0;
- }
- //右分针
- switch(cLeftFenZhenStep)
- {
- case 0:
- break;
- case 1:
- if(dwTickCount >= cDelayTime5)
- {
- cLeftFenZhenStep = 2;
- MXC_RightFenZhen_VAVLE = 1;//cMidleCoil[2] |= Q06;//SETY006; //右分针电磁阀
- cDelayTime5 = dwTickCount + (unsigned long)FenZhengErrorTime;
- }
- break;
- case 2: //碰到右大微动,延时停
- if(!MXC_RightFenZhen_Origin_IN) //右分针原点离开
- {
- cDelayTime5 = dwTickCount + 500;
- cLeftFenZhenStep = 3;
- // cRightFenZhenStep = 1; //左分针延时启动
- cDelayTime6 = dwTickCount + (unsigned long)20;
- }//右分针不下去
- else if(dwTickCount >= cDelayTime5)
- {
- cStopFlag = 1;
- user_datas[100] = 4; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- }
- }
- break;
- case 3:
- if(MXC_RighttFenZhen_IN) //插针到位
- {
- cLeftFenZhenStep = 0;
- cRightFenZhenStep = 1; //左分针延时启动
- }
- else if(dwTickCount >= cDelayTime5)
- {
- MXC_RightFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q06;//CLRY006; //右分针
- cRFengTimer++;
- //当右分针分不到位时,左分针也要重新分针
- MXC_LeftFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q04;//CLRY004;
- cRightFenZhenStep = 0;
- if(cRFengTimer < 4)
- {
- cLeftFenZhenStep = 4;
- cDelayTime5 = dwTickCount + FenZhengErrorTime;
- }
- else
- {
- cStopFlag = 1;
- user_datas[100] = 4; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- }
- }
- }
- break;
- case 4:
- if(MXC_RightFenZhen_Origin_IN) //退到位
- {
- cLeftFenZhenStep = 5;
- cDelayTime5 = dwTickCount + 150;
- }
- else if(dwTickCount >= cDelayTime5)
- {
- cStopFlag = 1;
- user_datas[100] = 4; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- }
- }
- break;
- case 5:
- if(dwTickCount >= cDelayTime5)
- {
- cDelayTime5 = dwTickCount + 30;
- cLeftFenZhenStep = 1;
- }
- break;
- }
- //左分针
- switch(cRightFenZhenStep)
- {
- case 0:
- break;
- case 1:
- if(dwTickCount >= cDelayTime6)
- {
- cRightFenZhenStep = 2;
- MXC_LeftFenZhen_VAVLE = 1;//cMidleCoil[2] |= Q04;//SETY004; //左分针电磁阀
- cDelayTime6 = dwTickCount + (unsigned long)FenZhengErrorTime;
- }
- break;
- case 2: //碰到右大微动,延时停
- if(!MXC_LeftFenZhen_Origin_IN) //右分针原点离开
- {
- cDelayTime6 = dwTickCount + 500;
- cRightFenZhenStep = 3;
- }//左分针不下去
- else if(dwTickCount >= cDelayTime6)
- {
- cStopFlag = 1;
- user_datas[100] = 4; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- }
- }
- break;
- case 3:
- if(MXC_LeftFenZhen_IN) //插针到位
- cRightFenZhenStep = 0;
- else if(dwTickCount >= cDelayTime6)
- {
- MXC_LeftFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q04;//CLRY004; //左分针
- cLFengTimer++;
- if(cLFengTimer < 6)
- {
- cRightFenZhenStep = 4;
- cDelayTime6 = dwTickCount + FenZhengErrorTime;
- if((cLFengTimer%2) == 0)
- {
- MXC_RightFenZhen_VAVLE = 0;//cMidleCoil[2] &= ~Q06;//CLRY006;
- cLeftFenZhenStep = 0;
- }
- }
- else
- {
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- }
- cStopFlag = 1;
- user_datas[100] = 4; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- }
- }
- break;
- case 4:
- if(MXC_LeftFenZhen_Origin_IN) //退到位
- {
- cRightFenZhenStep = 5;
- cDelayTime6 = dwTickCount + 150;
- }
- else if(dwTickCount >= cDelayTime6)
- {
- cStopFlag = 1;
- user_datas[100] = 4; //分针不成功
- user_datas[75] = 5; //页面跳转
- MXC_bSaveWorkData = 1;
- if(XiaCongMotorMode == 1)
- {
- MXC_XiaChong_MOTOR = 0;//cMidleCoil[2] |= Q00;//SETY000; //下冲电机
- }
- }
- break;
- case 5:
- if(dwTickCount >= 36)
- {
- cDelayTime6 = dwTickCount + 30;
- if((cLFengTimer%2) == 0) //左边插两次都插不到,就退右边再同时插
- {
- cDelayTime5 = dwTickCount + 30;
- cLeftFenZhenStep = 1;
- cRFengTimer = 0;
- cRightFenZhenStep = 0;
- }
- else
- {
- cRightFenZhenStep = 1;
- }
- }
- break;
- }
- }
- #endif
|