123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008 |
- #include "global.h"
- #if XI_DONG_MACHINE
- /**************************************
- ** 函数名称:void SYYAJi(void)
- ** 函数功能:方块插稍机动作函数
- ** 输入输出说明:
- 输入:
- X0 启动开关
- X1 停止开关(做完当条停机)
- X2 紧急停机开关
- X3 左计数接近开关
- X4 右计数接近开关
- X5 注油机液位开关
- X6 注油机液压开关
- X7 铜线故障
- X10 成型故障
- X11 卡带故障(布带1)
- X12 没带故障(布带2)
- X13 送带故障(布带3)
- X14 合链上限、下限位开关(合链1)
- X15 缺牙开关(合链2)
- X16 缺牙开关(合链3)
- X17 左送料开关上限(关)
- X20 左送料下限开关(开)
- X21 右送料上限开关(关)
- X22 右送料下限开关(开)
- X23 并链机上限开关(关)
- X24 并链机下限开关(开)
- X25 接头输入
- X26
- X27
- 输出:
- Y0 蜂鸣器
- Y1 左直流电磁铁(进)
- Y2 左直流电磁铁(出)
- Y3 右直流电磁铁(进)
- Y4 右直流电磁铁(出)
- Y5 主电机
- Y6 注油机
- Y7 左、右送带电机
- Y10 压链电机
- Y11 合链电机
- Y12 合链电磁铁
- Y13 左送料电机
- Y14 右送料电机
- Y15 并链电机
- Y16
- Y017
- ***************************************/
- void SYY_Right_Action(void);
- void SYY_ZhuYou(void); //注油
- void SYY_Start(void);
- void SYY_Error_Action(void);
- void SYY_SongLiao(void); //送料动作(送丝)
- void SYY_Lelf_Action(void); //左边排牙动作
- void SYY_Right_Action(void); //右边排牙动作
- void SYY_StartZYFirst(void);
- void SYY_Stop_Action(void);
- // 左右启动计数选择,复位时6空6牙
- short SYY_cDBuff,SYY_StartZYFlag = 0,SYY_cStartPYFlag_Left,SYY_cStartPYFlag_Right,SYY_cClr_Flag,
- SYY_cHeLian,SYY_cZhuYou,SYY_cWriflash,SYY_cTatal_OK,SYY_cTestTime;
- unsigned long SYY_cTotalTength,SYY_cCountTime = 0,SYY_cJieKou,SYY_cJieDaiTotal,SYY_cJieDaiClrTotal,SYY_cJieDai_Flag,SYY_cJieDaiWeiZi,cDelayTime17;
- unsigned long SYY_cTotal;
- unsigned char SYY_cStart_Right_EN = 0,SYY_bRunning,SYY_bStop;
- void SYY_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(SYY_ALARM_ADDR,alarm_code);
- SYY_bStop = 1;
- }
- void SYYa_InitAction(void)
- {
- XGearRatio = 1;
- YGearRatio = 1;
- }
- void SYYa_Action(void)
- {
- if(SYY_StartZYFlag == 0)
- {
- SYY_cTotalTength = ((unsigned long)user_datas[98] << 16) + user_datas[97]; //累计
- //停机1小时以上
- SYY_StartZYFlag = 1;
- SYY_StartZYFirst();
- M15 = 1;
- SYY_cClr_Flag = user_datas[105];
- SYY_cJieDai_Flag = user_datas[103];
- SYY_cJieDaiTotal = user_datas[102];
- SYY_cJieDaiClrTotal = user_datas[104];
-
- }
- user_datas[121] = SYY_cJieDaiTotal;
- user_datas[122] = SYY_cJieDaiClrTotal;
- user_datas[123] = SYY_cJieDai_Flag;
- user_datas[124] = SYY_cJieDaiWeiZi;
- user_datas[125] = user_datas[68];
- user_datas[126] = user_datas[69];
- user_datas[127] = user_datas[65];
- user_datas[128] = user_datas[66];
-
- //接头检测
- if(X25_UP) //空位
- {
- SYY_cJieDaiTotal = user_datas[6] + 6;
- SYY_cJieDaiClrTotal = 0;
- SYY_cJieDai_Flag = 1;
- SETY015();
- }
- else if(X25_DW)
- {
- CLRY015();
- SYY_cJieDaiClrTotal += 6;
- SYY_cJieDai_Flag = 2;
- if(SYY_cJieDaiTotal == 0)
- {
- SYY_cJieDaiTotal = user_datas[6] + 6;
- }
- else
- {
- }
- }
-
- SYY_ZhuYou(); //注油
- SYY_Start();
- SYY_Error_Action();
- SYY_SongLiao(); //送料动作(送丝)
- SYY_Lelf_Action(); //左边排牙动作
- SYY_Right_Action(); //右边排牙动作
- //旋转电磁铁动作
- if((Y001 || Y002) && (dwTickCount >= cDelayTime6)) //左边
- {
- CLRY001();
- CLRY002();
- }
- if((Y003 || Y004) && (dwTickCount >= cDelayTime7)) //右边
- {
- CLRY003();
- CLRY004();
- }
- //合链机启动
- if(M4)
- {
- if(X024)
- {
- SETY010();
- SETY011();
- }
- else if(X023 != 0)
- {
- CLRY010();
- CLRY011();
- }
- }
- else
- {
- CLRY010();
- CLRY011();
- }
- //做完一条输出
- if(Y016 && (dwTickCount >= cDelayTime17))
- {
- CLRY016();
- }
- //排牙电机
- if(M2)
- {
- M2 = 0;
- if(Y005)
- {
- if(M7 == 0)M6 = 0; //M6 排牙控制
- }
- else if(M3 && (M0100 == 0))
- M6 = 1; //M6 排牙控制
- }
- if(M6)
- {
- if(Y005 == 0)
- {
- cDelayTime1 = dwTickCount + (unsigned long)100 * 10; //启动后延时判断出错
- cDelayTime2 = dwTickCount; //累计时间启动
- //每次启动电机时启动注油时间
- SETY006();
- cDelayTime8 = dwTickCount + (unsigned long)user_datas[2] * 1000; //注油时间 秒
- cDelayTime3 = dwTickCount + (unsigned long)6000; //延时检测油压
- }
- SETY005(); //排牙主电机
- SETY007(); //左右送布带电机
- }
- else
- {
- if(Y005)
- {
- cDelayTime1 = dwTickCount + (unsigned long)45 * 10; //关闭后延时判断出错
- }
- CLRY005(); //排牙电机
- CLRY007(); //左右送布带电机
- }
- //产量清零
- if(M9)
- {
- M9 = 0;
- ClrcToTal(97);
- SYY_cTotalTength = ((unsigned long)user_datas[98] << 16) + user_datas[97]; //累计
- M15 = 1; //M15
- user_datas[86] = 0; //小时清零
- user_datas[87] = 0; //分钟清零
- user_datas[88] = 0; //累计时间
- }
- }
- void SYY_cTotal_Time(void)
- {
- unsigned long i,ch,k;
- SYY_cTotal = (unsigned long)(user_datas[77] << 16) + (unsigned long)user_datas[76];
- //一条的长度 mm
- k = (user_datas[67]+ user_datas[64]) * user_datas[0] *157/user_datas[1]/500;
- user_datas[102] = k%0x10000;
- user_datas[103] = k/0x10000;
- i = k * SYY_cTotal; //累积长度MM
- user_datas[104] = i%0x10000;
- user_datas[105] = i/0x10000;
- if(user_datas[68] == 0)
- {
- ch = (user_datas[65]); //加已打齿数
- }
- else
- {
- ch = user_datas[64] + user_datas[68]; //空位打完
- }
- ch = ch * user_datas[0] *157/(user_datas[1]*500); //当条剩于长度
- user_datas[106] = ch%0x10000;
- user_datas[107] = ch/0x10000;
- if(ch <= k)
- i += (k - ch);
- i /= 100;
- user_datas[63] = i/0x10000; //已累计
- user_datas[62] = i%0x10000;
- i =((unsigned long)user_datas[85] << 16) + user_datas[84];
- if(SYY_cTotal >= i)
- i = 0;
- else
- {
- i = k * (i - SYY_cTotal-1);
- i += ch;
- i = i/100;
- }
- user_datas[61] = i/0x10000; //已累计
- user_datas[60] = i%0x10000;
-
- //累计时间
- if(Y005) //
- {
- user_datas[89] = SYY_cTestTime;
- SYY_cCountTime += SYY_cTestTime; //累积时间
- user_datas[88] += SYY_cTestTime; //当前生产总量累积时间
- if(SYY_cCountTime >= 1000) //大于1秒
- {
- user_datas[96] += SYY_cCountTime/1000; //1秒
- SYY_cCountTime %= 1000;
- if(user_datas[96] >= 3600) //大于1小时
- {
- i = user_datas[96]/3600; //
- user_datas[96] %= 3600;
- i += ((unsigned long)user_datas[93] << 16) + user_datas[92];//所有总生产时间
- user_datas[93] = (unsigned short)(i>>16);
- user_datas[92] = (unsigned short)(i);
- }
- }
- //累计已用时间
- if(user_datas[88] >= 60000) //1分钟
- {
- user_datas[87]++;
- user_datas[86] += user_datas[87]/60; //1小时
- user_datas[87] = user_datas[87]%60; //1小时
- user_datas[88] = user_datas[88]-60000;
- }
- //计算剩于时间
- ch = SYY_cTestTime*(user_datas[67]+ user_datas[64]); //单条所用的时间
- i = ((unsigned long)user_datas[85] << 16) + user_datas[84];
- if(SYY_cTotal >= i)
- i = 0;
- else
- {
- i -= SYY_cTotal;
- k = (ch/1000) * i; //大于1秒
- i = (ch%1000) * i; //所得MS
- k += i/1000; //总秒数
- user_datas[94] = k/3600; //所剩小时
- user_datas[95] = (k%3600)/60; //所剩小时
- }
- }
- }
- //重设数据
- void SYY_ReSetData(unsigned short cData,unsigned short cMode)
- {
- if((user_datas[65] != user_datas[66]) || (user_datas[68] != user_datas[69]))
- SYY_cStart_Right_EN = 1;
- else
- SYY_cStart_Right_EN = 0;
- if(cData == 0)
- {
- user_datas[65] = user_datas[64];
- user_datas[66] = user_datas[64];
- }
- else
- {
- user_datas[65] = 0;
- user_datas[66] = 0;
- }
- //左边
- user_datas[68] = cData;
- SYY_cStartPYFlag_Left = cMode;
- //右边
- user_datas[69] = cData;
- SYY_cStartPYFlag_Right = cMode;
-
- //接口直接跳过
- SYY_cJieDai_Flag = 0;
- SYY_cJieDaiTotal = 0;
- SYY_cJieDaiClrTotal = 0;
- SYY_cClr_Flag = 0;
- user_datas[102] = 0;
- user_datas[103] = 0;
- user_datas[104] = 0;
- user_datas[105] = 0;
-
- }
- void SYY_Start(void)
- {
- if(M0100 == 0)//首次加油已经完成
- {
- if((M0 || X00_UP) && (SYY_bRunning == 0) && M3 && (X001 == 0) && (middle_coils[11].value == 0)
- && (middle_coils[10].value == 0) && (SYY_cTotal < ((unsigned long)user_datas[84] + user_datas[85]*0x10000)))
- {
- M7 = 1; //M7 工作显示
- M4 = 1; //M4 合链控制
- M5 = 1; //M5 送丝控制
- M6 = 1; //M6 排牙控制
- user_datas[40] = 3;
- SYY_bRunning = 1;
- if(X023 == 0)
- {
- SETY010();
- SETY011();
- }
- }
- M0 = 0;
- }
- else
- {
- M0 = 0; //M0 倒时显示
- }
- if(M1 || X001 || ((middle_coils[11].value != 0) && (middle_coils[10].value != 0)))
- {
- // 普通停止是打完当条再停止
- if(M1 || (X001))
- {
- if(M6)
- SYY_bStop = 1;
- }
- else //其它故障都要立即停止
- {
- if(SYY_bRunning)SETY000();
- SYY_Stop_Action();
- SYY_bStop = 0;
- }
- M0 = 0; //M0 系统复位
- }
- if(M14) //系统复位 重新 6空位,6牙
- {
- M14 = 0;
- if(SYY_bRunning == 0)
- { if((user_datas[68] || user_datas[69]))
- {
- SYY_ReSetData(user_datas[68] + 2,1);//(6,1); //6空位,6牙
- }
- else if(user_datas[67])
- SYY_ReSetData(user_datas[67],1);//(6,1); //6空位,6牙
- else
- SYY_ReSetData(1,0);//(6,1); //6空位,6牙
- }
- }
- //故障清除
- if(M13)
- {
- if(M0088) //叠牙时直接打空位
- {
- SYY_ReSetData(user_datas[67],0); //正常空位,正常牙数
- }
- middle_coils[10].value = 0;
- middle_coils[11].value = 0;
- user_datas[100] = 0;
- CLRY000();
- }
- }
- // 停止工作
- void SYY_Stop_Action(void)
- {
- M7 = 0; //M7 工作显示
- if((X002 == 0) && (M0100 == 0))M3 = 0;//M3 注油控制
- if(SYY_bRunning)M4 = 0;; //M4 合链控制
- M5 = 0; //M5 送丝控制
- M6 = 0; //M6 排牙控制
- user_datas[40] = 2;
- SYY_bRunning = 0;
- }
- //错误停机
- void SYY_Error_Action(void)
- {
- unsigned short i;
- if(X002 == 0) //紧急停止
- {
- M0091 = 1; //M91 紧急停止警告
- user_datas[100] = 91;
- }
- else if(X02_UP)
- {
- M0091 = 0; //M91 紧急停止警告
- user_datas[100] = 0;
- }
- if(dwTickCount >= cDelayTime1)
- {
- if(X005) //液位警告
- {
- if(dwTickCount >= cDelayTime12)
- {
- M0089 = 1; //M89 液位警告
- user_datas[100] = 89;
- }
- }
- else
- {
- cDelayTime12 = dwTickCount + (unsigned long)8 * 10;
- }
- if(X007) //铜线故障
- {
- if(dwTickCount >= cDelayTime11)
- {
- M0087 = 1; //M87 铜线故障警告
- user_datas[100] = 87;
- }
- }
- else
- {
- cDelayTime11 = dwTickCount + (unsigned long)30 * 10;
- }
- if(X010 && Y005) //叠牙
- {
- M0086 = 1; //M0086 叠牙警告
- user_datas[100] = 86;
- }
- if(X011 && Y005) //卡带故障(布带1)
- {
- if(dwTickCount >= cDelayTime13)
- {
- M0080 = 1; //M0080 卡带故障(布带1)
- user_datas[100] = 80;
- }
- }
- else
- {
- cDelayTime13 = dwTickCount + (unsigned long)8 * 10;
- }
- if(X012) //没带故障(布带2)
- {
- if(dwTickCount >= cDelayTime9)
- {
- M0081 = 1; //M81 没带故障(布带2)
- user_datas[100] = 81;
- }
- }
- else
- {
- cDelayTime9 = dwTickCount + (unsigned long)5 * 10;
- }
- if(X013) //送带故障(布带3)
- {
- if(dwTickCount >= cDelayTime10)
- {
- M0082 = 1; //M82 送带故障(布带3)
- user_datas[100] = 82;
- }
- }
- else
- {
- cDelayTime10 = dwTickCount + (unsigned long)5 * 10;
- }
- if(X014) //合链上限、下限位开关(合链1)
- {
- if(dwTickCount >= cDelayTime14)
- {
- M0083 = 1; //M83 合链上限、下限位开关(合链1)
- user_datas[100] = 83;
- }
- }
- else
- {
- cDelayTime14 = dwTickCount + (unsigned long)3 * 10;
- }
- //油压不到警告
- if(Y006 && (dwTickCount >= cDelayTime3))
- {
- if(X006)
- {
- M0090 = 1; //M90 油压不到警告
- user_datas[100] = 90;
- }
- }
- //数牙出错
- if(user_datas[67]) //有空位时(条计数时才有效)
- {
- if(user_datas[65] || user_datas[66])
- {
- if(user_datas[65] >= user_datas[66])
- {
- i = user_datas[65] - user_datas[66];
- }
- else
- i = user_datas[66] - user_datas[65];
- // 正常打牙状态
- if((SYY_cClr_Flag == 0) && (i > 2) && (((i < (user_datas[64]-1)) && (SYY_cStartPYFlag_Right == 0))
- // 复位打牙状态
- ||(SYY_cStartPYFlag_Right && (i < 5))))
- {
- M0088 = 1; //M0088 数牙出错
- user_datas[100] = 88;
- }
- }
- else if((user_datas[68] || user_datas[69]))
- {
- if(user_datas[68] >= user_datas[69])
- {
- i = user_datas[68] - user_datas[69];
- }
- else
- i = user_datas[69] - user_datas[68];
- if((SYY_cClr_Flag == 0) && (i > 2) && (i != user_datas[67]))
- {
- M0088 = 1; //M0088 数牙出错
- user_datas[100] = 88;
- }
- }
- }
- }
- else
- {
- cDelayTime14 = dwTickCount + (unsigned long)3 * 10;
- cDelayTime10 = dwTickCount + (unsigned long)5 * 10;
- cDelayTime9 = dwTickCount + (unsigned long)5 * 10;
- cDelayTime13 = dwTickCount + (unsigned long)8 * 10;
- cDelayTime12 = dwTickCount + (unsigned long)8 * 10;
- cDelayTime11 = dwTickCount + (unsigned long)30 * 10;
- }
- //两边合链出错
- if((SYY_cHeLian == 0) && (X15_UP) || (X16_UP) && M4)
- {
- SYY_cHeLian = 1;
- cDelayTime5 = dwTickCount + (unsigned long)user_datas[5] * 10;
- }
- if((M4 == 0) || (X015 && X016) || ((X015 == 0)&& (X016 == 0)))
- {
- if((M4 == 0) || ((X015 == 0)&& (X016 == 0)))
- {
- SYY_cHeLian = 0;
- }
- else
- {
- if(X015 && X016)
- {
- if(X15_UP || X16_UP)
- {
- cDelayTime4 = dwTickCount + (unsigned long)40;
- if(SYY_cHeLian == 1)
- SYY_cHeLian = 2;
- }
- if((SYY_cHeLian == 2) && (dwTickCount >= cDelayTime4))
- {
- SYY_cHeLian = 3;
- SETY012();
- cDelayTime4 = dwTickCount + (unsigned long)120;
- }
- }
- else if(Y012 == 0)
- cDelayTime4 = dwTickCount + (unsigned long)40;
- }
- if(Y012 && (dwTickCount >= cDelayTime4))
- {
- CLRY012();
- }
- }
- else if((SYY_cHeLian == 1) && (dwTickCount >= cDelayTime5))
- {
- if(X015 == 0)
- {
- M0084 = 1; //M84 (合链2出错)
- user_datas[100] = 84;
- }
- else
- {
- M0085 = 1; //M85 (合链2出错)
- user_datas[100] = 85;
- }
- }
- }
- void SYY_StartZYFirst(void)
- {
- SYY_cDBuff = user_datas[4];
- M0100 = 1; //M0100 倒时显示
- cDelayTime8 = dwTickCount + (unsigned long)1000;
- SETY006();
- user_datas[40] = 1;
- cDelayTime3 = dwTickCount + (unsigned long)15000;
- M3 = 1; //M3 注油控制
- }
- void SYY_ZhuYou(void)
- {
- if(Y006)
- {
- if((dwTickCount >= cDelayTime8) || (M3 == 0))
- {
- if(M0100)
- {
- cDelayTime8 = dwTickCount + (unsigned long)1000;
- if(user_datas[4])
- {
- user_datas[4]--;
- }
- if((user_datas[4] == 0) || (M3 == 0)) //初次注油完成
- {
- M0100 = 0; //M0100
- CLRY006(); //注油机关
- user_datas[4] = SYY_cDBuff;
- cDelayTime8 = dwTickCount + (unsigned long)user_datas[3] * 60 * 1000;
- user_datas[40] = 2; //注油完成
- }
- }
- else
- {
- CLRY006(); //注油机关
- if(M3)
- cDelayTime8 = dwTickCount + (unsigned long)user_datas[3] * 60 * 1000; //间隔注油时间 分钟
- else
- cDelayTime8 = dwTickCount;
- }
- M8 = 0; //M8 清通知位
- }
- }
- else if(M3 && ((dwTickCount >= cDelayTime8) || M8) && X002)
- {
- //大于1小时,重新先注油
- if(((dwTickCount - cDelayTime8) > (3600 * 1000)) && (dwTickCount >= cDelayTime8))
- {
- SYY_StartZYFirst();
- }
- else
- {
- SETY006();
- cDelayTime8 = dwTickCount + (unsigned long)user_datas[2] * 1000; //注油时间 秒
- cDelayTime3 = dwTickCount + (unsigned long)5000; //延时检测油压
- }
- M8 = 0; //M8 清通知位
- }
- }
- void SYY_SongLiao(void)
- {
- static unsigned long cSSYASongLiao_In_Time_L = 0,cSSYASongLiao_In_Time_R = 0;
- //送丝启动
- if(M5)
- {
- //左送料(送丝)
- if(X020)
- {
- if(dwTickCount >= cSSYASongLiao_In_Time_L)
- SETY013();
- }
- else if(X017)
- {
- if(dwTickCount >= cSSYASongLiao_In_Time_L)
- CLRY013();
- }
- else
- {
- cSSYASongLiao_In_Time_L = dwTickCount + (unsigned long)100; //防干扰时间
- }
- //右送料(送丝)
- if(X022)
- {
- if(dwTickCount >= cSSYASongLiao_In_Time_R )
- SETY014();
- }
- else if(X021)
- {
- if(dwTickCount >= cSSYASongLiao_In_Time_R )
- CLRY014();
- }
- else
- {
- cSSYASongLiao_In_Time_R = dwTickCount + (unsigned long)100; //防干扰时间
- }
- }
- else
- {
- CLRY013();
- CLRY014();
- cSSYASongLiao_In_Time_L = dwTickCount + (unsigned long)100; //防干扰时间
- cSSYASongLiao_In_Time_R = dwTickCount + (unsigned long)100; //防干扰时间
- }
- }
- //左边排牙动作
- //D64 牙数设定
- //D65 左牙记录
- //D66 右空位记录
- //D67 空位设定
- //D68 左空位记录
- //D69 右空位记录
- //当在按下复位时就先打6空位,再打6牙
- void SYY_Lelf_Action(void)
- {
- unsigned long i;
- if(X03_UP)
- {
- SYY_cStart_Right_EN = 0;
- if(SYY_cJieDai_Flag == 1)
- {
- if(SYY_cJieDaiTotal)
- SYY_cJieDaiClrTotal++;
- else
- SYY_cJieDaiClrTotal = 0;
- }
- if(SYY_cJieDaiTotal && SYY_cJieDai_Flag)
- {
- SYY_cJieDaiTotal--;
- if(SYY_cJieDaiTotal == 0) //直接按空位方式走
- {
- SYY_cStartPYFlag_Left = 3;
- SYY_cStartPYFlag_Right = 3;
- user_datas[68] = SYY_cJieDaiClrTotal + user_datas[67];
- if(user_datas[67] == 0)
- {
- user_datas[68] += 10;
- }
- user_datas[69] = user_datas[68];
- if(SYY_cJieDai_Flag == 2)
- SYY_cJieDai_Flag = 0;
- CLRY002();
- SETY001();
- cDelayTime6 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
-
- //变为空位,不用铜丝
- CLRY004();
- SETY003();
- cDelayTime7 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- }
- if(user_datas[68]) //空位状态
- {
- if(SYY_cStartPYFlag_Left == 1)
- {
- SYY_cStartPYFlag_Left = 2;
- //变为空位,不用铜丝
- CLRY002();
- SETY001();
- cDelayTime6 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- user_datas[68]--;
- if(user_datas[68] == 0)
- {
- switch(SYY_cStartPYFlag_Left)
- {
- case 1:
- case 2:
- user_datas[65] = 6 ;//左边牙数
- break;
- default:
- user_datas[65] = user_datas[64] ;//左边牙数
- break;
- }
- //只有大于一条拉链时才打牙状态
- if((SYY_cJieDaiTotal >= (user_datas[65]+user_datas[67])) || (SYY_cJieDai_Flag == 0))
- {
- //变为打牙,
- CLRY001();
- SETY002();
- cDelayTime6 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- SYY_cClr_Flag = 0;
- }
- else
- {
- if(SYY_cJieDai_Flag != 0)
- user_datas[68] = user_datas[6] + 6;//SYY_cJieDaiTotal + 5 + SYY_cJieDaiClrTotal;
- user_datas[65] = 0;
- SYY_cClr_Flag = 1;
- }
- }
- }
- else if(user_datas[65]) //打齿状态
- {
-
- user_datas[65]--;
- //如果不是码装方式(空位不为0)
- if(((SYY_cJieDaiTotal + 5) < (user_datas[65] + user_datas[67]/2)) && (user_datas[67] != 0) && (SYY_cJieDai_Flag))
- {
- CLRY002();
- SETY001();
- cDelayTime6 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- user_datas[68] = SYY_cJieDaiTotal + 5;
- SYY_cClr_Flag = 1;
- }
- else if(user_datas[65] == 0)
- {
- //变为空位,
- if(user_datas[67] != 0)
- {
- CLRY002();
- SETY001();
- cDelayTime6 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
-
- }
- else //空位为0时
- {
- user_datas[65] = user_datas[64] ;//左边牙数
- }
- //产量计数
- //当两边的齿都打完时,产量加1
- if(SYY_cTatal_OK)
- {
- SYY_cTatal_OK = 0;
- if(SYY_cStartPYFlag_Left == 0)
- {
- SYY_cTotal++;
- SETY016();
- cDelayTime17 = dwTickCount + (unsigned long)100;
- }
- //按停止 或产量到
- if(SYY_bStop || (SYY_cTotal >= ((unsigned long)user_datas[84] + user_datas[85]*0x10000)))
- {
- SYY_Stop_Action();
- if(SYY_bStop == 0)
- user_datas[40] = 4;
- SYY_bStop = 0;
- }
- }
- else
- SYY_cTatal_OK = 1;
- SYY_cStartPYFlag_Left = 0;
- }
- }
- M15 = 1; //M15 清通知位
- //如叠牙或数牙导常的情况下,不能送牙
- if(M0086 || M0088 || M0080)
- {
- CLRY002();
- SETY001();
- cDelayTime6 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- //所有累计总长度
- i = SYY_cTotalTength + ((unsigned long)user_datas[63] << 16) + user_datas[62]; //累计
- user_datas[98] = i >> 16;
- user_datas[97] = (unsigned short)i; //清零时保存
- SYY_cTestTime = dwTickCount - cDelayTime2; //计算时间 (
- cDelayTime2 = dwTickCount;
- }
- else if(M15) //下一程序周期计算长度的时间
- {
- M15 = 0;
- SYY_cTotal_Time();
- }
- }
- void SYY_Right_Action(void)
- {
- if(X04_UP && (SYY_cStart_Right_EN == 0))
- {
- if(user_datas[69]) //空位状态
- {
- if(SYY_cStartPYFlag_Right == 1)
- {
- SYY_cStartPYFlag_Right = 2;
- //变为空位,不用铜丝
- CLRY004();
- SETY003();
- cDelayTime7 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- user_datas[69]--;
- if(user_datas[69] == 0)
- {
- switch(SYY_cStartPYFlag_Right)
- {
- case 1:
- case 2:
- user_datas[66] = 6 ;//左边牙数
- break;
- default:
- user_datas[66] = user_datas[64] ;//左边牙数
- break;
- }
- if(SYY_cClr_Flag) //还是变空位
- {
- user_datas[69] = user_datas[68];
- user_datas[66] = 0;
- SYY_cClr_Flag = 0;
- }
- else
- {
- //变为打牙,
- CLRY003();
- SETY004();
- cDelayTime7 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- }
- }
- else if(user_datas[66]) //打齿状态
- {
- user_datas[66]--;
- if(SYY_cClr_Flag)
- {
- user_datas[69] = user_datas[68];
- CLRY004();
- SETY003();
- cDelayTime7 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- else if(user_datas[66] == 0)
- {
- //变为空位,
- if(user_datas[67] != 0)
- {
- CLRY004();
- SETY003();
- cDelayTime7 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- else //空位为0时
- {
- user_datas[66] = user_datas[64] ;//左边牙数
- }
- //产量计数
- //当两边的齿都打完时,产量加1
- if(SYY_cTatal_OK)
- {
- SYY_cTatal_OK = 0;
- if(SYY_cStartPYFlag_Right == 0)
- {
- SYY_cTotal++;
- SETY016();
- cDelayTime17 = dwTickCount + (unsigned long)100;
- }
- SYY_cWriflash = 1;
- //按停止 或产量到
- if(SYY_bStop || (SYY_cTotal >= ((unsigned long)user_datas[84] + user_datas[85]*0x10000)))
- {
- SYY_Stop_Action();
- if(SYY_bStop == 0)
- {
- user_datas[40] = 4;
-
- }
- SYY_bStop = 0;
- }
- }
- else
- SYY_cTatal_OK = 1;
- SYY_cStartPYFlag_Right = 0;
- }
- }
- //如叠牙的情况下,不能送牙
- if(M0086 || M0088 || M0080)
- {
- CLRY004();
- SETY003();
- cDelayTime7 = dwTickCount + (unsigned long)SYY_DianCiTieOutTIME;
- }
- }
- }
- #endif
|