123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846 |
- #include "global.h"
- #if XI_DONG_MACHINE
- //输入说明
- //输入说明
- //X000 起动
- //X001 停止
- //X002 手动钩针
- //X003 手动前导板
- //X004 手动夹胶
- //X005 手动送胶
- //X006 手动熔胶
- //X007 自动位
- //X010 单-自动
- //X011 过链接近开关
- //X012 勾针磁感
- //X013 前导板磁感
- //X014 送胶到位磁感
- //X015 退胶到位磁感(熔接磁感)
- //X016 复位微动
- //X017 机型选择(就是送胶、前导板)
- //X020 合模到位微动
- //X021 音波自动
- //X022 熔接时勾针关选择 1 先下勾针熔接,0 熔接时不下勾针
- //X023 内部时间选择,0 拔码,1 内部时间
- //输出说明
- //NEW 2006/03/22
- //输出说明
- //Y000 离合器
- //Y001 勾针阀
- //Y002 导板阀
- //Y003 夹胶阀
- //Y004 送胶阀
- //Y005 熔接(合模)
- //Y006 计数
- //Y007 拖带电机
- //Y010 释放
- //Y011 警告输出
- //Y012 压带输出
- //Y020 音波
- //Y021 音波
- //X00 起动
- #define __sw_start() (X00)
- #define __sw_start_on() (X00_UP)
- //X01 停止
- #define __sw_stop() (X01)
- #define __sw_stop_on() (X01_UP)
- //X02 手动钩针
- #define __sw_gou_zhen_on() (X02_UP)
- #define __sw_gou_zhen_off() (X02_DW)
- //X03 手动前导板
- #define __sw_dao_ban() (X03 != 0)
- #define __sw_dao_ban_on() (X03_UP)
- #define __sw_dao_ban_off() (X03_DW)
- //X04 手动夹胶
- #define __sw_jia_jiao() (X04 != 0) /* 手动夹胶状态*/
- #define __sw_jia_jiao_on() (X04_UP)
- #define __sw_jia_jiao_off() (X04_DW)
- //X05 手动送胶
- #define __sw_song_jiao() (X05)
- #define __sw_song_jiao_on() (X05_UP)
- #define __sw_song_jiao_off() (X05_DW)
- //X06 手动熔胶
- #define __sw_rong_jiao() (X06 != 0)
- #define __sw_rong_jiao_on() (X06_UP)
- #define __sw_rong_jiao_off() (X06_DW)
- //X07 自动位
- #define __sw_manual() (X07 != 0) /* 开关为手动状态*/
- #define __sw_manual_on() (X07_UP) /* 开关改为手动瞬间*/
- //X10 单-自动
- #define __x_dan_zi_dong() (X10 != 0)
- //X11 过链接近开关
- #define __x_guo_lian() (X11 != 0)
- #define __x_guo_lian_on() (X11_UP)
- #define __x_guo_lian_off() (X11_DW)
- //X12 勾针磁感
- #define __x_gou_zhen() (X12 != 0)
- //X13 前导板磁感
- #define __x_dao_ban() (X13 != 0)
- //X14 送胶到位磁感
- #define __x_song_jiao_dao_wei() (X14 != 0)
- //X15 退胶到位磁感(熔接磁感)
- #define __x_tui_jiao_dao_wei() (X15 != 0)
- //X16 复位微动
- #define __x_reset() (X16 != 0)
- #define __x_reset_on() (X16_UP)
- //X17 机型选择(就是送胶、前导板)
- //X20 合模到位微动
- #define __x_he_mo_dao_wei() (X20 != 0)
- #define __x_he_mo_dao_wei_on() (X20_UP)
- //X21 音波自动
- #define __sw_auto_yin_bo() (X21 == 0)
- //输出说明
- //NEW 2006/03/22
- //输出说明
- //Y000 离合器
- #define __y_li_he() (Y000 != 0)
- #define __y_li_he_on() (SETY000())
- #define __y_li_he_off() (CLRY000())
- //Y001 勾针阀
- #define __y_gou_zhen() (Y001 != 0)
- #define __y_gou_zhen_on() (SETY001())
- #define __y_gou_zhen_off() (CLRY001())
- //Y002 导板阀
- #define __y_dao_ban() (Y002 != 0)
- #define __y_dao_ban_on() (SETY002())
- #define __y_dao_ban_off() (CLRY002())
- //Y003 夹胶阀
- #define __y_jia_jiao() (Y003 != 0)
- #define __y_jia_jiao_on() (SETY003())
- #define __y_jia_jiao_off() (CLRY003())
- //Y004 送胶阀
- #define __y_song_jiao() (Y004 != 0)
- #define __y_song_jiao_on() (SETY004())
- #define __y_song_jiao_off() (CLRY004())
- //Y005 熔接(合模)
- #define __y_he_mo() (Y005 != 0)
- #define __y_he_mo_on() (SETY005())
- #define __y_he_mo_off() (CLRY005())
- //Y006 计数
- #define __y_ji_shu_on() (SETY006())
- #define __y_ji_shu_off() (CLRY006())
- //Y012
- #define __y_Ya_Dai() (Y012 != 0)
- #define __y_Ya_Dai_on() (SETY012())
- #define __y_Ya_Dai_off() (CLRY012())
- //Y007 拖带电机
- //Y008
- #define __yin_bo_on() (SETY015())
- #define __yin_bo_off() (CLRY015())
-
- char TBJ_GcDanYiXunHuanFlag;
- unsigned char TBJ_cSpeaker_EN,TBJ_cGuZhang_Flag;
- unsigned short TBJ_cWordTime[3],TBJ_cCountOutTime;
- unsigned long TBJ_cErrorTime1,TBJ_cErrorTime;
- void TBJ_Motor (void);
- void TBJ_InitAction(void)
- {
- XGearRatio = 1;
- YGearRatio = 1;
- }
- static void TBJ_ManualAction (void)
- {
- if(M11) //累计产量清零
- {
- M11 = 0;
- ClrcToTal(76);
- }
- if(M8)
- {
- M8 = 0;
- if(__y_Ya_Dai())
- {
- __y_Ya_Dai_off();
- }
- else
- __y_Ya_Dai_on();
- }
- if(X07_UP)
- { //自动变手动
- Y00 = 0;
- Y01 = 0;
- Y02 = 0;
- Y03 = 0;
- Y04 = 0;
- Y05 = 0;
- Y07 = 0;
- Y10 = 0;
- Y11 = 0;
- Y13 = 0;
- Y14 = 0;
- Y15 = 0;
- cStepMByte = 0;
- cStepMByte1 = 0;
- cStepMByte2 = 0;
- cStepMByte3 = 0;
- cStepMByte4 = 0;
- cStepMByte5 = 0;
- cStepMByte6 = 0;
- TBJ_bRunning = 0;
- AxisEgmStop(X_AXIS);
- SETY010();
- }
- if(__sw_gou_zhen_on() || M2) //勾针动作
- {
- M2 = 0;
- if(__y_gou_zhen())
- {
- __y_gou_zhen_off();
- }
- else if((user_datas[4] != 2) || (!__y_song_jiao()))
- __y_gou_zhen_on(); /* 钩针阀on*/
- }
- else if(__sw_gou_zhen_off())
- __y_gou_zhen_off(); /* 钩针阀off*/
- if (__sw_dao_ban_on() || M3)
- { /* 手动前导板开关ON*/
- M3 = 0;
- if(__y_dao_ban())__y_dao_ban_off();
- /* 未合模 复位 合模未到位 手动熔接*/
- else if (!__y_he_mo() && __x_reset() && !__x_he_mo_dao_wei() && !__sw_rong_jiao())
- {
- __y_dao_ban_on(); /* 导板阀 */
- }
- else //警告处理
- {
- M15 = 0; //M15
- M0091 = 1; //M91 不用记录
- SETY011(); //蜂鸣器
- if(Y005 != 0)user_datas[100] = ERY05; //Y005 无输出
- else if(X006 != 0)user_datas[100] = ERX06; //X006 有输入
- else if(X016 == 0)user_datas[100] = ERX16; //X016 有输入
- else if(X020 != 0)user_datas[100] = ERX20; //X020 有输入
- }
- }
- /* 手动前导板 机型选择(就是送胶、前导板)*/
- if ((__sw_dao_ban_off()) || (X017))__y_dao_ban_off();
- //手动夹胶
- if (__sw_jia_jiao() || M4)
- {
- M4 = 0;
- if(__y_jia_jiao())
- __y_jia_jiao_off();
- else
- __y_jia_jiao_on(); /* 夹胶阀ON*/
- }
- //手动送胶
- if (__sw_song_jiao_on() || M5)
- {
- M5 = 0;
- if(__y_song_jiao()) //关送胶
- {
- __y_song_jiao_off();
- }
- /* 未合模 复位 合模未到位 手动熔接*/
- // Y005 X016 != 0
- else if (!__y_he_mo() && __x_reset() && !__x_he_mo_dao_wei() && !__sw_rong_jiao() &&
- ((!__y_gou_zhen() && __x_gou_zhen()) || (user_datas[4] != 2)))
- {
- __y_song_jiao_on(); /* 送胶伐ON*/
- }
- else //条件不满足处理
- {
- M15 = 0; //M15
- M0091 = 1; //M91 不用记录
- SETY011(); //蜂鸣器
- if(Y005 != 0)user_datas[100] = ERY05; //Y005 无输出
- else if(X006 != 0)user_datas[100] = ERX06; //X006 有输入
- else if(X016 == 0)user_datas[100] = ERX16; //X016 有输入
- else if(X020 != 0)user_datas[100] = ERX20; //X020 有输入
- else if(__y_gou_zhen())user_datas[100] = ERY01; //Y001 有输出
- else if(!__x_gou_zhen())user_datas[100] = ERX12; //X012 有输入
- }
- }
- /* 手动前导板 机型选择(就是送胶、前导板)*/
- if (__sw_song_jiao_off() || (X017))
- __y_song_jiao_off();
- //手动熔胶 导板阀 送胶阀 离合器 退胶到位磁感(熔接磁感)
- if (X06_UP || M6)
- {
- M6 = 0;
- if(__y_he_mo())
- {
- cStepMByte3 = 0;
- __yin_bo_off(); //音波关
- __y_he_mo_off(); //退合模
- }
- else if (!__y_dao_ban() && !__y_song_jiao() &&
- (cStepMByte3 == 0) && !__y_li_he() &&
- __x_tui_jiao_dao_wei() &&
- !__x_dao_ban() && (!__x_gou_zhen() || (user_datas[4] == 2)))
- { /* 前导板磁感 勾针磁感*/
- cStepMByte3 = 1; //合模熔接开始
- /* 合模熔接*/
- TBJ_cWordTime[0] = user_datas[6]; //延时发超声时间
- TBJ_cWordTime[1] = user_datas[7]; //发超声时间
- TBJ_cWordTime[2] = user_datas[8]; //固化时间
- }
- else //不满足条件警告处理
- {
- M15 = 0; //M15
- M0091 = 1; //M91不用记录
- SETY011(); //蜂鸣器
- if(Y005 != 0)user_datas[100] = ERY05; //Y05 前导板电磁阀
- else if(Y004 != 0)user_datas[100] = ERY04; //X006 有输入
- else if(Y000 != 0)user_datas[100] = ERY00; //X016 有输入
- else if(X015 == 0)user_datas[100] = ERX15; //X020 有输入
- else if(X013 != 0)user_datas[100] = ERX13; //X020 有输入
- else if(X012 != 0)user_datas[100] = ERX12; //X020 有输入
- }
- }
- }
- /*********************************************************************************************************
- ** Function name: func_name
- ** Descriptions: 自动运行
- ** input parameters: input
- ** output parameters: NONE
- ** Returned value: NONE
- ** Created by: Huanghui
- ** Created Date: 2012-6-18
- **--------------------------------------------------------------------------------------------------------
- ** Modified by:
- ** Modified date:
- **--------------------------------------------------------------------------------------------------------
- *********************************************************************************************************/
- static void TBJ_AutoAciton (void)
- {
- TBJ_Motor();
- switch (cStepMByte)
- { //电机、离合器、导板阀、夹胶阀起动
- case 1:
- if (__x_gou_zhen() && __x_reset())
- {
- cStepMByte = 2;
- cStepMByte2 = 1;
-
- SETY003();//夹胶输出
- cDelayTime1 = dwTickCount + (unsigned long)50; //延时输出前导板 /* 夹胶阀*/
- }
- break;
- case 2:
- if((dwTickCount >= cDelayTime1) && (Y002 == 0)) /* 延时输出导板*/
- {
- if ((X003 == 0) && (X017 == 0))
- {
- SETY002();//前导板输出__y_dao_ban_on();
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- else
- __y_dao_ban_off();
- }
- //前导板出错
- if((dwTickCount >= TBJ_cErrorTime1) && Y002 && (X013 == 0))
- {
- M0081 = 1; //M81 记录
- user_datas[100] = 2; //检查过链接近开关或没有拉链
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- // 勾针己输出 并且在链上 拖带完成
- if (((X012 == 0) && X011) || (cStepMByte2 == 0) || (user_datas[4] == 1)) //送胶起动
- {
- if(user_datas[4] == 2)
- {
- if((cStepMByte2 == 0)) //压带已经有输出
- {
- if(dwTickCount >= cDelayTime1) __y_gou_zhen_off(); //下勾针
- if(__x_gou_zhen()) //勾针下到位
- {
- //前导板到位 前导板输出
- if ((X013 != 0))
- {
- cStepMByte = 3;
- if((X005 == 0) && (X017 == 0)) /* 送胶阀*/
- {
- SETY004();
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- else
- CLRY004();
- }
-
- }
- }
- else
- cDelayTime1 = dwTickCount + (unsigned long)50;
- }
- else
- {
- //前导板到位 前导板输出
- if ((X013 != 0) || ((Y002 == 0) && (user_datas[4] == 0)))
- {
- cStepMByte = 3;
- if((X005 == 0) && (X017 == 0)) /* 送胶阀*/
- {
- SETY004();
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- else
- CLRY004();
- }
- }
- }
- break;
- //送胶到位
- case 3: //送胶到位磁感
- if (X014 || (Y004 == 0))
- {
- cStepMByte = 4;
- cDelayTime1 = dwTickCount + (unsigned long)20;
- }
- else if(dwTickCount >= TBJ_cErrorTime1) //送胶到位出错
- {
- M0082 = 1; //M82 记录
- user_datas[100] = 3; //检查过链接近开关或没有拉链
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- break;
- //导板、夹胶关闭
- case 4:
- if(Y003 && dwTickCount >= cDelayTime1)
- {
- CLRY003(); //夹胶阀关
- cDelayTime1 = dwTickCount + (unsigned long)10 * user_datas[9];
- }
- //勾针起 拖带到位 勾针磁感
- if ((cStepMByte2 == 0) && !Y003 && (((Y001 != 0) && (X012 == 0)) || (user_datas[4] == 2)))
- {
- cStepMByte = 5;
- CLRY002(); //前导板关
- CLRY003(); //夹胶阀关
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- break;
- //退送胶
- case 5:
- //送胶停止
- if((X013 == 0) && (dwTickCount>= cDelayTime1))
- {
- cStepMByte = 6;
- CLRY004();/* 送胶关 M19*/
- cStepMByte2 = 6; //拖带反转
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- else if((dwTickCount >= TBJ_cErrorTime1)) //退导板出错
- {
- M0081 = 1; //M81 记录
- user_datas[100] = 2; //检查过链接近开关或没有拉链
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- break;
- case 6: //退胶到位
- if((cStepMByte2 == 0) && (Y004 == 0) && X015)
- {
- cStepMByte = 7;
- }
- else if((dwTickCount >= TBJ_cErrorTime1)) //退送胶出错
- {
- M0083 = 1; //M83 记录
- user_datas[100] = 4; //检查过链接近开关或没有拉链
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- break;
- //在自动状态
- case 7: // 单一自动 自动启动 熔接
- if(__x_dan_zi_dong() || (TBJ_GcDanYiXunHuanFlag == 0) || M6)
- {
- M6 = 0;
- if(!__sw_rong_jiao() && !__y_dao_ban() && !__y_song_jiao() && __x_tui_jiao_dao_wei() && !__x_dao_ban() &&
- ((__y_gou_zhen() && !__x_gou_zhen()) || (user_datas[4] == 2)) && __x_guo_lian())
- {
- cStepMByte = 8; //等待合模熔接完成
- cStepMByte3 = 1; //合模熔接开始
- TBJ_cWordTime[0] = user_datas[6]; //延时发超声时间
- TBJ_cWordTime[1] = user_datas[7]; //发超声时间
- TBJ_cWordTime[2] = user_datas[8]; //固化时间
- }
- }
- break;
- case 8:
- if(cStepMByte3 == 0) //合模熔接已经完成
- {
- cStepMByte = 9;
- CLRY001(); //退勾针
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- break;
- case 9: //复位到位
- if (X016)
- {
- cStepMByte = 10;
- cDelayTime1 = dwTickCount + (unsigned long) 30;
- }
- else if((dwTickCount >= TBJ_cErrorTime1)) //复位微动异常
- {
- M0084 = 1; //M84 记录
- user_datas[100] = 5;
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- break;
- case 10:
- if ((X016 != 0) && (dwTickCount >= cDelayTime1))
- {
- cStepMByte = 11;
- cDelayTime1 = dwTickCount + (unsigned long) 60;
- TBJ_cCountOutTime = 5; //计数
- SETY006();
- CLRY010(); //锁轴
- }
- else if (X016 == 0)
- {
- cStepMByte = 9;
- TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- }
- break;
- case 11:
- if (dwTickCount >= cDelayTime1)
- { // 单一循环
- if(TBJ_GcDanYiXunHuanFlag)
- {
- cStepMByte = 0;
- TBJ_bRunning = 0;
- }
- else
- cStepMByte = 1;
- AddToTal(76); //生产总量加1保存
- CalProSP(78); //计算生产速度
- }
- break;
- }
- /* if (!__sw_dao_ban() && M17 && (X017 == 0))
- __y_dao_ban_on();
- else
- __y_dao_ban_off();
- if (!__sw_jia_jiao() && M18 && (X017 == 0))
- __y_jia_jiao_on();
- else
- __y_jia_jiao_off();
- if (!__sw_song_jiao() && M19 && (X017 == 0))
- __y_song_jiao_on();
- else
- __y_song_jiao_off();
- */
- }
- // 检测是否踏了脚踏开关
- void TBJ_CheckStart (void)
- {
- static unsigned long TBJ_iKaDaiTime;
- /* 启动ON 自动启动 单一自动 */
- if ((__sw_start_on() || M0 || M7) && (TBJ_bRunning == 0))
- { // 勾针磁感 复位磁感 停止OFF 自动
- if(__x_gou_zhen() && __x_reset() && !__sw_stop() && !__sw_manual())
- {//自动启动
- TBJ_bRunning = 1; // 取反运行标志位
- cStepMByte = 1;
- TBJ_GcDanYiXunHuanFlag = 0;
- if(M7)TBJ_GcDanYiXunHuanFlag = 1;
- middle_coils[10].value = 0; //记录
- middle_coils[11].value = 0; //记录
- user_datas[100] = 0;
- M15 = 0;
- user_datas[101] = 0;
- TBJ_cSpeaker_EN = 0;
- }
- else //警告输出
- {
- M15 = 0; //M15
- M0091 = 1; //M91不用记录
- SETY011(); //蜂鸣器
- if(X007 != 0)user_datas[100] = ERX07; //X007 有输入
- else if(X001 != 0)user_datas[100] = ERX01; //X001 有输入
- else if(X016 == 0)user_datas[100] = ERX16; //X016 没输入
- else if(X012 == 0)user_datas[100] = ERX12; //没输入
- }
- M0 = 0;
- M7 = 0;
- }
- //停止
- if ((X01_UP || TBJ_bStop || M1) )
- {
- if(TBJ_bRunning && (X001 != 0))TBJ_cGuZhang_Flag = 1;
- TBJ_iKaDaiTime = dwTickCount + 1000;
- M1 = 0;
- TBJ_bStop = 0;
- Y00 = 0;
- Y01 = 0;
- Y02 = 0;
- Y03 = 0;
- Y04 = 0;
- Y05 = 0;
- Y07 = 0;
- Y10 = 0;
- Y11 = 0;
- Y12 = 0;
- Y13 = 0;
- Y14 = 0;
- Y15 = 0;
- cStepMByte = 0;
- cStepMByte1 = 0;
- cStepMByte2 = 0;
- cStepMByte3 = 0;
- cStepMByte4 = 0;
- cStepMByte5 = 0;
- cStepMByte6 = 0;
- TBJ_bRunning = 0;
- AxisEgmStop(X_AXIS);
- SETDR();
- SETY010();
- CLRY011();
- TBJ_cSpeaker_EN = 1;
- }
- if((X001 != 0) && (dwTickCount >= TBJ_iKaDaiTime) && TBJ_cGuZhang_Flag)
- {
- TBJ_cGuZhang_Flag = 0;
- M0086 = 1;
- user_datas[100] = 7;
- TBJ_cSpeaker_EN = 0;
- SETY011();
- }
- //警告退出
- if(M15)
- {
- middle_coils[10].value = 0;
- middle_coils[11].value = 0;
- user_datas[100] = 0; /* 压带出错,没法压到位*/
- M15 = 0;
- }
- }
- //贴布sm 电机控制
- void TBJ_Motor (void)
- {
- switch(cStepMByte2)
- {
- case 1: //离合器起动
- cStepMByte2 = 2;
- __y_li_he_on(); //离合启动 Y000
- if (user_datas[90] == 55)cDelayTime3 = dwTickCount + (unsigned long) 300;
- CLRDR();
- SETY007();
- CLRY010();
- MoveAction_Const_AccDec(X_AXIS,TBJ_DIR_P,user_datas[3],user_datas[2],user_datas[1],1);
- __y_Ya_Dai_off(); //压带关
- break;
- case 2: //过链接近下降沿
- if ((__x_guo_lian_off()) || ((user_datas[90] == 55) && (dwTickCount >= cDelayTime3)))
- {
- cStepMByte2 = 3;
- cDelayTime3 = dwTickCount + (unsigned long)user_datas[10]; //延时上勾针
- TBJ_cErrorTime = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- AxisChangeSpeed(X_AXIS,user_datas[2]);
- }
- break;
- case 3: //要加延时上勾针
- if(dwTickCount >= cDelayTime3)__y_gou_zhen_on(); /* 上勾针*/
- //过链接近上升沿 //拖带到
- if ((__x_guo_lian_on() || (user_datas[90] == 55)) && (dwTickCount >= cDelayTime3))
- {
- cStepMByte2 = 4;
- cDelayTime3 = dwTickCount + (unsigned long)user_datas[0];
- __y_gou_zhen_on(); /* 上勾针*/
- }
- else if (dwTickCount >= TBJ_cErrorTime)
- { //拖带警告
- M0087 = 1; //M87 记录
- user_datas[100] = 8; //检查过链接近开关或没有拉链
- M15 = 0; //M15
- user_datas[101] = 0;
- TBJ_bStop = 1;
- }
- break;
- case 4:
- if(dwTickCount >= cDelayTime3)
- {
- cStepMByte2 = 5;
- __y_li_he_off(); //关离合
- AxisEgmStop(X_AXIS);
- TBJ_cErrorTime = dwTickCount + (unsigned long) TBJ_ERRORTIME;
- if(user_datas[4])cDelayTime3 = dwTickCount + (unsigned long)40;
- }
- break;
- case 5: //勾针上到
- if (!__x_gou_zhen() && (dwTickCount >= cDelayTime3))
- {
- cStepMByte2 = 0; //拖带反转
- SETDR();
- __y_Ya_Dai_on(); //压带开
- }
- else if (dwTickCount >= TBJ_cErrorTime) //压带警告
- {
- M0080 = 1; //记录
- user_datas[100] = 1; //压带出错,没法压到位
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- break;
- case 6:
- AxisMovePosAccDec(X_AXIS, 5,80,1,1,1);
- cStepMByte2 = 7; //等拖带完成
- break;
- case 7:
- if(!X_DRV)
- {
- cStepMByte2 = 0; //拖带完成
- SETY010(); //释放电机
- }
- break;
- }
- }
- //合模超声动作
- void TBJ_HeMo (void)
- {
- switch (cStepMByte3)
- {
- case 1:
- cDelayTime4 = dwTickCount + (unsigned long)TBJ_ERRORTIME; //延时时间
- if(X022)
- {
- __y_gou_zhen_off();
- if(__x_gou_zhen())
- {
- __y_he_mo_on(); //合模
- cStepMByte3 = 2;
- }
- }
- else
- {
- __y_he_mo_on(); //合模
- cStepMByte3 = 2;
- }
- break;
- case 2:
- if(__x_he_mo_dao_wei_on())
- { /* 合模到位瞬间*/
- cStepMByte3 = 3;
- cDelayTime4 = dwTickCount + (unsigned long) TBJ_cWordTime[0] * 10; //延时时间
- }
- else if((dwTickCount >= cDelayTime4) && TBJ_bRunning) //合模到位微动异常
- {
- M0085 = 1; //M85记录
- user_datas[100] = 6; //合模出错
- M15 = 0; //M15
- user_datas[101] = 0;
- }
- break;//延时发振
- case 3:
- if(dwTickCount >= cDelayTime4)
- {
- cStepMByte3 = 4;
- cDelayTime4 = dwTickCount + (unsigned long) TBJ_cWordTime[1] * 10; //熔接时间
- if(user_datas[5] != 0) //通信方式下音波开选择
- __yin_bo_on(); //音波开
- }
- break;
- case 4:
- if (dwTickCount >= cDelayTime4)
- {
- cStepMByte3 = 5;
- cDelayTime4 = dwTickCount + (unsigned long) TBJ_cWordTime[2] * 10; //熔接时间
- __yin_bo_off(); //音波关
- }
- break;
- case 5:
- if(dwTickCount >= cDelayTime4)
- {
- cStepMByte3 = 0;
- __y_he_mo_off();
- __y_Ya_Dai_off();
- }
- break;
- }
- }
- /*********************************************************************************************************
- ** Function name: func_name
- ** Descriptions: descriptions
- ** input parameters: input
- ** output parameters: NONE
- ** Returned value: NONE
- ** Created by: Huanghui
- ** Created Date: 2012-6-18
- **--------------------------------------------------------------------------------------------------------
- ** Modified by:
- ** Modified date:
- **--------------------------------------------------------------------------------------------------------
- *********************************************************************************************************/
- void TBJ_Action (void)
- {
- static unsigned long c10msDelay = 0;
- TBJ_CheckStart(); // 调用脚踏开关检测程序
- if(dwTickCount >= c10msDelay)
- {
- c10msDelay = dwTickCount+10;
- if (TBJ_cCountOutTime > 0)
- {
- TBJ_cCountOutTime--;
- if (TBJ_cCountOutTime == 0)
- CLRY006();
- }
- if(user_datas[100] == 0)
- {
- CLRY011();
- }
- else //显示故障代码
- {
- SETY011();
- }
- }
- TBJ_HeMo (); //合模熔接动作
- // 没有按下急停按钮
- //手动状态下
- if(TBJ_bRunning && !__sw_stop())
- {
- TBJ_AutoAciton(); /* 自动运行*/
- }
- else if(__sw_stop_on() || M1)
- {
- Y00 = 0;
- Y01 = 0;
- Y02 = 0;
- Y03 = 0;
- Y04 = 0;
- Y05 = 0;
- Y07 = 0;
- Y12 = 0;
- Y13 = 0;
- Y14 = 0;
- Y15 = 0;
- cStepMByte = 0;
- cStepMByte1 = 0;
- cStepMByte2 = 0;
- cStepMByte3 = 0;
- cStepMByte4 = 0;
- cStepMByte5 = 0;
- cStepMByte6 = 0;
- TBJ_bRunning = 0;
- AxisEgmStop(X_AXIS);
- SETY010();
- }
- else if(TBJ_bRunning == 0)
- {
- TBJ_ManualAction(); /* 手动运行*/
- }
- }
- #endif
|