123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842 |
- #include "global.h"
- #if JIN_LONG_MACHINE == 1
- unsigned short Prv_SQJCOUNT,Prv_XQJCOUNT;
- void TBJ_InitAction(void);
- void TBJ_Action(void);
- void TBJ_ChuiQi(void);
- void TBJ_ChaoShengHeMo(void);
- void TBJ_SetAlarmCode(unsigned alarm_code); //等待调用
- void TBJ_StartStopAction(void);
- void TBJ_AutoRunStep(void);
- void TBJ_Motor(void);
- void TBJ_SongJiao(void);
- void TBJ_STOP_Action(void);
- void TBJ_ChuiQi_Stop(void);
- void TBJ_QJCount(void);
- void TBJ_QieJiao_Proc(void);
- void TBJ_XCReset_Proc(void);
- void TBJ_SFHeMo_Proc(void);
- void TBJ_ChaoShengHeMo_SF(void);
- void TBJ_QJCQ_Stop(void);
- void TBJ_Action(void)
- {
- //步骤显示
- DISPLAY_DATA0 = dwYRealPos_com;//TBJ_XC_RstStep;//TBJ_Auto_Step;
- DISPLAY_DATA1 = dwYRealPos;//TBJ_Motor_Step;
- DISPLAY_DATA2 = TBJ_HMCS_Step;
- DISPLAY_DATA3 = TBJ_HeMo_Step;//TBJ_SJ_FJ_Step;
- DISPLAY_DATA4 = TBJ_Auto_Step;//TBJ_XC_CS_LOCAL;//servo_y.IO_TO_COM;//TBJ_STOP_Step;
- DISPLAY_DATA5 = TBJ_FIRST_CS_Y_LOCAL;//TBJ_Motor_Step;//GetTarr(Y_AXIS);//dwXRealPos;
- DISPLAY_DATA6 = TBJ_CS_Y_Local;
- DISPLAY_DATA7 = TBJ_GH_Y_Local;
- CTHL_bServo_Com_Y=servo_y.IO_TO_COM;
- dwXRealPos = GetPos(X_AXIS);
- dwYRealPos = GetPos(Y_AXIS);
- dwYRealPos_com=get_encode_value(Y_AXIS)/4;//减速比
- TBJ_ManualAction();
- //TBJ_ChaoShengHeMo();
- TBJ_ChaoShengHeMo_SF();
- TBJ_StartStopAction();
- TBJ_AutoRunStep();
- TBJ_Motor();
- TBJ_SongJiao();
- TBJ_STOP_Action();
- TBJ_ChuiQi_Stop();
- TBJ_QJCQ_Stop();
- TBJ_QJCount();
-
- servo_com_run();
-
- TBJ_QieJiao_Proc();
- TBJ_XCReset_Proc();
- TBJ_SFHeMo_Proc();
- }
- void TBJ_QJCount(void)
- {
- if(TBJ_SQJGY_IN_UP)
- {
- TBJ_PARAM_SQJCOUNT++;
- }
- if(TBJ_XQJGY_IN_UP)
- {
- TBJ_PARAM_XQJCOUNT++;
- }
- }
- //故障报警
- void TBJ_SetAlarmCode(unsigned alarm_code)
- {
- SetAlarmCode(TBJ_ALARM_ADDR, alarm_code);
- TBJ_bAlarmStop = 1;
- }
- void TBJ_InitAction(void)
- {
- float buff_pulse, buff_dist;
- //电机脉冲与距离比例计算
- buff_pulse = TBJ_PARAM_CYCLE_PULSE; //电机走一圈所需的脉冲
- buff_dist = TBJ_PARAM_CYCLE_LENGTH; //电机走一圈长度
- XGearRatio = buff_pulse / buff_dist; //可根据距离换算所需脉冲,反之一样
-
- buff_pulse = TBJ_PARAM_YCYCLE_PULSE; //电机走一圈所需的脉冲
- buff_dist = TBJ_PARAM_YCYCLE_LENGTH; //电机走一圈长度
- YGearRatio= buff_pulse / buff_dist; //可根据距离换算所需脉冲,反之一样
- TBJ_CHENGXU_UPDATE = 1; //便于屏幕判断程序有无更新
- SetDirReverse(X_AXIS, 1);
- //传递伺服齿轮比参数
- set_com_servo_param(Y_AXIS,TBJ_PARAM_YCYCLE_PULSE,TBJ_PARAM_YCYCLE_LENGTH);
- SetServoComUse(X_AXIS,0);//X轴正常模式。
- SetServoComUse(Y_AXIS,1);//Y轴伺服扭矩通讯。
- ReadServoAlarm_Enable(Y_AXIS,1);
- ReadServoEncode_Enable(Y_AXIS,1);
-
- SetEnReverse(X_AXIS, 1);
- SetEnReverse(Y_AXIS, 0);
- //电机松轴
- SetEn(X_AXIS, TBJ_MOTOR_DISEN);
- SetEn(Y_AXIS, TBJ_MOTOR_DISEN);
-
- SetAlarmCode(TBJ_ALARM_ADDR, TBJ_NO_ALARM); //警告要清除
-
- TBJ_Hemo_flag=0;
- TBJ_XC_Reset_flag=1;
- if(TBJ_PARAM_XCRest_MODE)TBJ_bXCRest=1;
- }
- //吹气
- void TBJ_ChuiQi(void)
- {
- if (!TBJ_CQ_VAVLE)
- {
- TBJ_CQ_VAVLE = 1;
- TBJ_CQ_Delay = dwTickCount + TBJ_PARAM_ChuiQi_TIME;
- }
- }
- //停止吹气
- void TBJ_ChuiQi_Stop(void)
- {
- if (TBJ_CQ_VAVLE && dwTickCount >= TBJ_CQ_Delay)// && dwTickCount >= TBJ_CS_Delay)
- TBJ_CQ_VAVLE = 0;
- }
- //切胶吹气
- void TBJ_QJCQ_Start(void)
- {
- if (!TBJ_QJCQ_VAVLE)
- {
- TBJ_QJCQ_VAVLE = 1;
- TBJ_QJCQ_Delay = dwTickCount + TBJ_PARAM_QJCQ_TIME;
- }
- }
- //停止吹气
- void TBJ_QJCQ_Stop(void)
- {
- if (TBJ_QJCQ_VAVLE && dwTickCount >= TBJ_QJCQ_Delay)// && dwTickCount >= TBJ_CS_Delay)
- TBJ_QJCQ_VAVLE = 0;
- }
- //红外算出来的时间重新赋值
- void TBJ_ResetCsTime(void)
- {
- if (TBJ_PARAM_CS_MODE == 0)
- user_datas[33] = user_datas[57];
- else
- user_datas[6] = user_datas[57];
- }
- //超声时间选择
- unsigned short TBJ_Choose_CSTime(void)
- {
- if (TBJ_PARAM_CS_MODE == 0) //超声模式 0为透明胶 1为布胶
- return TBJ_PARAM_TMJ_CS_TIME; //透明胶超声时间
- else
- return TBJ_PARAM_BJ_CS_TIME; //布胶超声时间
- }
- //固化时间选择
- unsigned short TBJ_Choose_COLDTime(void)
- {
- if (TBJ_PARAM_CS_MODE == 0)
- return TBJ_PARAM_TMJ_GH_TIME; //透明胶固化时间
- else
- return TBJ_PARAM_BJ_GH_TIME; //布胶固化时间
- }
- //手动动作
- void TBJ_ManualAction(void)
- {
- #if 1
- if (!TBJ_bRunning)
- {
- //屏幕按钮手动钩针
- if (TBJ_bGZ)
- {
- TBJ_bGZ = 0;
- if (TBJ_GZ_VAVLE)
- TBJ_GZ_VAVLE = 0;
- else
- TBJ_GZ_VAVLE = 1;
- }
- //手动分胶
- if (TBJ_bFJ &&((TBJ_PARAM_SGZSelect) //单钩针模式下的判断
- || ((TBJ_PARAM_SGZSelect == 0) && !TBJ_GZ_LIMIT_IN )) //双钩针模式下的判断
- &&TBJ_Y_ORIGIN_IN //上模在原点
- && (TBJ_FJ_VAVLE || (!TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN)) //未进分胶,送胶不能输出,进完分胶后,无视送胶状态,可退分胶
- )
- {
- TBJ_bFJ = 0;
- if (TBJ_FJ_VAVLE)
- TBJ_FJ_VAVLE = 0;
- else
- TBJ_FJ_VAVLE = 1;
- }
- else if (TBJ_bFJ)
- {
- TBJ_bFJ = 0;
- if (!((TBJ_PARAM_SGZSelect) || ((TBJ_PARAM_SGZSelect == 0) && !TBJ_GZ_LIMIT_IN)))
- TBJ_SetAlarmCode(34); //E34 手动分胶停止,钩针未退位;
- else if (!TBJ_Y_ORIGIN_IN)//上摸不在原点
- TBJ_SetAlarmCode(36); //E36 手动分胶停止,下冲气缸未退位或X14下冲到位感应异常
- else if (TBJ_SJ_LIMIT_IN)
- TBJ_SetAlarmCode(38); //E38 手动分胶停止,送胶阀未退回,或X16送胶到位感应异常
- else if (!TBJ_SJ_ORIGIN_IN)
- TBJ_SetAlarmCode(39); //E39 手动分胶停止,送胶阀未退回,或X17退胶到位感应异常
- }
- //手动切胶
- if(TBJ_bQJ)
- {
- if(TBJ_SJ_ORIGIN_IN)TBJ_QJ_Step=1;
- else
- TBJ_SetAlarmCode(TBJ_QJ_SJNORIGIN_ALARM); //E43 手动切胶,送胶不在原位
- TBJ_bQJ=0;
- }
- //手动送胶
- if (((TBJ_bSJ && !TBJ_SJ_VAVLE))) //按钮按下 送胶阀未输出 进行送胶
- { //手动送胶 || (按钮送胶 && 送胶阀没输出)&& (!1二次拖带的情况下考虑钩针阀没有输出)
- if ((TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN) ) //单钩针模式,钩针与送胶阀错位,不用考虑相撞,双钩针模式下的判断,钩针钩住拖带后退,可能会与送胶阀产生碰撞
- && (TBJ_FJ_LIMIT_IN ^ TBJ_FJ_ORIGIN_IN) && TBJ_SJ_ORIGIN_IN //判断分胶阀有无出错,只能到位或原位 送胶阀后感应亮
- && TBJ_Y_ORIGIN_IN //上模原点 超声未打开
- && !TBJ_GZ_VAVLE) //考虑钩针有无退回
- {
- TBJ_SJ_FJ_Step=20;
- TBJ_bSJ = 0;
- }
- else if (TBJ_bSJ) //送胶失败,发送警告
- {
- TBJ_bSJ = 0;
- if (!(TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN)))
- TBJ_SetAlarmCode(40); //E40 手动送胶停止,双钩针模式下钩针未退回
- else if (!(TBJ_FJ_LIMIT_IN ^ TBJ_FJ_ORIGIN_IN))
- TBJ_SetAlarmCode(41); //E41 手动送胶停止,分胶阀处于异常状态,X12,X13前后感应灯同亮或同灭
- else if (!TBJ_SJ_VAVLE && !TBJ_SJ_ORIGIN_IN)
- TBJ_SetAlarmCode(42); //E42 手动送胶停止,X17送胶后感应异常
- else if (!TBJ_Y_ORIGIN_IN)
- TBJ_SetAlarmCode(44); //E44 手动送胶停止,下冲气缸未退回,或X14 下冲到位感应异常
- if (TBJ_SJ_VAVLE)
- TBJ_SJ_VAVLE = 0;
- }
- }
- else if (((TBJ_bSJ && TBJ_SJ_VAVLE))) //送胶阀已输出,进行退胶
- {
- TBJ_SJ_FJ_Step=25;
- TBJ_bSJ = 0;
- }
- //手动合模
- if (TBJ_bHM&&TBJ_Hemo_flag==0)//&& !TBJ_SM_VAVLE) //屏幕按钮按下 || 上模没输出 && 手动合模输入
- {
- if ( !TBJ_XC_Reset_flag&&TBJ_FJ_ORIGIN_IN && !TBJ_FJ_LIMIT_IN //分胶阀感应判断
- && ((!TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN) || TBJ_PARAM_SongJiaoMode) //送胶阀原点,或者滚筒模式 //送胶阀感应判断
- && !TBJ_FJ_VAVLE && !TBJ_SJ_VAVLE && !TBJ_CS_OUT //分胶阀,送胶阀、超声未动作 //分胶阀判断 送胶阀判断 超声判断
- && ((TBJ_PARAM_SGZSelect) || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN)))//双钩钩针在原点、或单钩针 //双钩针模式需考虑钩针有无输出
- {
- if(TBJ_PARAM_XiaChong_MODE==0)
- {
- TBJ_SM_VAVLE = 1;//气缸合模
- TBJ_Hand_Hemo_flag=1;
- }
- else
- {
- TBJ_HeMo_Step=1;//伺服合模
- TBJ_GZ_VAVLE = 0;//钩针
- TBJ_FJ_VAVLE = 0; //分胶
- TBJ_DZ_VAVLE=0;//顶针
- TBJ_SJ_VAVLE=0;//送胶
- TBJ_HeMo_Delay=dwTickCount+100;
- set_servo_postotarr_limit(Y_AXIS,SERVO_PARAM_TRARR_BD_LIMITMIN,
- TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- }
- if (TBJ_PARAM_XiaMo_Mode == 0)TBJ_XM_VAVLE = 1; //下模活动
- TBJ_bHM = 0;
- }
- else
- {
- TBJ_bHM = 0;
- if (!TBJ_FJ_ORIGIN_IN)
- TBJ_SetAlarmCode(46); //E46 手动合模停止,分胶阀未退位,或 X13分胶后感应异常
- else if (TBJ_FJ_LIMIT_IN)
- TBJ_SetAlarmCode(47); //E47 手动合模停止,分胶阀未退位,或 X12分胶前感应异常
- else if (TBJ_SJ_LIMIT_IN)
- TBJ_SetAlarmCode(48); //E48 手动合模停止,送胶阀未退位,或 X16送胶前感应异常
- else if (!TBJ_SJ_ORIGIN_IN)
- TBJ_SetAlarmCode(49); //E49 手动合模停止,送胶阀未退位,或 X17分胶后感应异常
- else if (TBJ_CS_OUT)
- TBJ_SetAlarmCode(50); //E50 手动合模停止,超声未关闭
- else if(TBJ_XC_Reset_flag)
- TBJ_SetAlarmCode(TBJ_XC_NO_REST); //E09 下冲电机未复位
- }
- }
- else if (TBJ_bHM&&TBJ_Hemo_flag)// && TBJ_SM_VAVLE) //屏幕按钮按下 && 上模已输出 && 手动合模没输入
- {
- if(TBJ_PARAM_XiaChong_MODE==0)TBJ_SM_VAVLE = 0; //上模退回
- else
- {
- TBJ_HeMo_Step=20;//伺服合模
- SetPos(Y_AXIS,dwYRealPos_com);
- Set_Ctrlmode_trans(Y_AXIS,POS_MODE);
- TBJ_HeMo_Delay=dwTickCount+100;
- }
- if (TBJ_PARAM_XiaMo_Mode == 0)TBJ_XM_VAVLE = 0; //下模退回 //双钩针模式下 或下模活动模式
- TBJ_bHM = 0;
- }
- //合模后吹气一次
- if (TBJ_SM_LIMIT_IN&&TBJ_Hand_Hemo_flag) //合模到位
- {
- TBJ_ChuiQi(); //启动吹气
- TBJ_Hand_Hemo_flag = 0;
- }
- //连续超声
- if(TBJ_bCS)
- {
- if ((!TBJ_FJ_LIMIT_IN && TBJ_FJ_ORIGIN_IN ) //分胶阀判断
- && ( !TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN || TBJ_PARAM_SongJiaoMode)) //送胶阀判断
- {
- if (TBJ_bCS && !TBJ_bCS_FLAG) //按钮已按下,超声未开始
- {
- TBJ_bCS_FLAG = 1; //cMidleCoil[0] |= (1<<10); //M10
- TBJ_CS_OUT = 1; //发超声
- TBJ_CS_Delay = dwTickCount + TBJ_Choose_CSTime(); //限长时间1.5
- }
- }
- TBJ_bCS=0;
- }
- if(TBJ_bCS_FLAG&&dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_bCS_FLAG=0;
- TBJ_bCS_FLAG = 0; //超声标志位清零
- TBJ_CS_OUT = 0; //关闭超声
- TBJ_ChuiQi(); //开启吹气
- }
- //合模+超声
- if(TBJ_bSC&& !TBJ_bSC_FLAG)
- {
- TBJ_bSC=0;
- if (!TBJ_XC_Reset_flag&&(!TBJ_FJ_VAVLE && !TBJ_FJ_LIMIT_IN && TBJ_FJ_ORIGIN_IN || TBJ_PARAM_FenJiaoSelect) //分胶阀判断
- && (!TBJ_SJ_VAVLE && !TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN || TBJ_PARAM_SongJiaoMode) //送胶阀判断
- && (dwTickCount >= TBJ_CS_Delay))
- {
- if ((TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN)))
- {
- TBJ_bSC_FLAG = 1;
- TBJ_HMCS_Step = 1; //整个合模超声过程
- TBJ_GZ_VAVLE = 0;//钩针
- TBJ_FJ_VAVLE = 0; //分胶
- TBJ_DZ_VAVLE=0;//顶针
- TBJ_SJ_VAVLE=0;//送胶
- set_servo_postotarr_limit(Y_AXIS,SERVO_PARAM_TRARR_BD_LIMITMIN,
- TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- }
- }
- else
- {
- if (TBJ_FJ_VAVLE)
- TBJ_SetAlarmCode(57); //E57 手动上超停止,分胶阀未退回
- else if (TBJ_FJ_LIMIT_IN)
- TBJ_SetAlarmCode(58); //E58 手动上超停止,分胶阀未退回,或X12分胶前感应异常
- else if (!TBJ_PARAM_FenJiaoSelect && !TBJ_FJ_ORIGIN_IN)
- TBJ_SetAlarmCode(59); //E59 手动上超停止,分胶阀未退回,或X13分胶后感应异常
- else if (TBJ_PARAM_SongJiaoMode == 0)
- {
- if (TBJ_SJ_VAVLE)
- TBJ_SetAlarmCode(60); //E60 手动上超停止,送胶阀未退回
- if (TBJ_SJ_LIMIT_IN)
- TBJ_SetAlarmCode(61); //E61 手动上超停止,送胶阀未退回,或X16送胶到位感应异常
- if (!TBJ_SJ_ORIGIN_IN)
- TBJ_SetAlarmCode(62); //E62 手动上超停止,送胶阀未退回,或X17退胶到位感应异常
- }
- else if(TBJ_XC_Reset_flag)
- TBJ_SetAlarmCode(TBJ_XC_NO_REST); //E50 手动合模停止,超声未关闭
- }
- }
- //手动夹胶(压带)
- if (TBJ_bJJ)
- {
- if (TBJ_JJ_VAVLE)
- TBJ_JJ_VAVLE = 0;
- else
- TBJ_JJ_VAVLE = 1;
- TBJ_bJJ = 0;
- }
- //手动压带
- if (TBJ_bYD)
- {
- if (TBJ_YD_VAVLE)
- TBJ_YD_VAVLE = 0;
- else
- TBJ_YD_VAVLE = 1;
- TBJ_bYD = 0;
- }
- //顶针
- if (TBJ_bDZ)
- {
- if (TBJ_DZ_VAVLE)
- TBJ_DZ_VAVLE = 0;
- else
- TBJ_DZ_VAVLE = 1;
- TBJ_bDZ = 0;
- }
- //松带
- if (TBJ_bSD)
- {
- if (TBJ_SD_VAVLE)
- TBJ_SD_VAVLE = 0;
- else
- TBJ_SD_VAVLE = 1;
- TBJ_bSD = 0;
- }
- //风扇
- if (TBJ_bFS)
- {
- if (TBJ_LQFS_OUT){
- SetEn(X_AXIS, TBJ_MOTOR_DISEN);
- SetEn(Y_AXIS, TBJ_MOTOR_DISEN);
- TBJ_XC_Reset_flag=1;
- TBJ_LQFS_OUT = 0;
- }
- else
- {
- SetEn(X_AXIS, TBJ_MOTOR_EN);
- SetEn(Y_AXIS, TBJ_MOTOR_EN);
- TBJ_LQFS_OUT = 1;
- }
- TBJ_bFS = 0;
- }
- //手动拖带
- if(TBJ_bMotor_N)
- {
- SetEn(X_AXIS, TBJ_MOTOR_EN);
- if(!X_DRV)
- {
- AxisContinueMoveAcc(X_AXIS,1000,DIR_N,1000,1000,10,12);
- }
- }
- else if(TBJ_bMotor_P)
- {
- SetEn(X_AXIS, TBJ_MOTOR_EN);
- if(TBJ_GZ_LIMIT_IN)
- {
- TBJ_bMotor_N=0;
- AxisEgmStop(X_AXIS);
- }
- if(!X_DRV&&!TBJ_GZ_LIMIT_IN)
- {
- AxisContinueMoveAcc(X_AXIS,1000,DIR_P,1000,1000,10,12);
- }
- }
- else
- {
- if(X_DRV)
- {
- AxisEgmStop(X_AXIS);
- }
- }
- //手动下冲
- if(TBJ_bYMotor_N)
- {
- SetEn(Y_AXIS, TBJ_MOTOR_EN);
- if(TBJ_Y_ORIGIN_IN)AxisEgmStop(Y_AXIS);
- if(!Y_DRV&&!TBJ_Y_ORIGIN_IN)
- {
- AxisContinueMoveAcc(Y_AXIS,800,DIR_N,800,800,10,12);
- }
- }
- else if(TBJ_bYMotor_P)
- {
- SetEn(Y_AXIS, TBJ_MOTOR_EN);
- if(TBJ_Y_RUNING_IN)AxisEgmStop(Y_AXIS);
- if(!Y_DRV&&TBJ_FJ_ORIGIN_IN&&TBJ_SJ_ORIGIN_IN&&!TBJ_Y_RUNING_IN)
- {
- AxisContinueMoveAcc(Y_AXIS,800,DIR_P,800,1000,10,12);
- }
- }
- else
- {
- if(Y_DRV&&!TBJ_bXCResting&&TBJ_HMCS_Step==0&&TBJ_HeMo_Step==0)
- {
- AxisEgmStop(Y_AXIS);
- }
- }
- //复位下冲
- if(TBJ_bXCRest&&GetServoComState(Y_AXIS))
- {
- TBJ_bXCRest=0;
- TBJ_bXCResting=1;
- TBJ_XC_RstStep=1;
- TBJ_GZ_VAVLE = 0;//钩针
- TBJ_FJ_VAVLE = 0; //分胶
- TBJ_DZ_VAVLE=0;//顶针
- TBJ_SJ_VAVLE=0;//送胶
- SetEn(Y_AXIS, TBJ_MOTOR_EN);
- TBJ_XCRst_Delay=dwTickCount+100;
- Set_Ctrlmode_trans(Y_AXIS,POS_MODE);
- set_servo_postotarr_limit(Y_AXIS,SERVO_PARAM_TRARR_BD_LIMITMIN,TBJ_PARAM_SFZSY_SPEED,TBJ_PARAM_SFZSY_SPEED,SERVO_TARR_CW);
- }
- }
- #endif
- }
- //伺服合模处理
- void TBJ_SFHeMo_Proc(void)
- {
- switch(TBJ_HeMo_Step)
- {
- case 1:
- if(dwTickCount>=TBJ_HeMo_Delay)
- {
- TBJ_LENTH=TBJ_PARAM_Y_Work_Local-dwYRealPos;
- AxisMovePosAccDec(Y_AXIS, TBJ_PARAM_Y_HIGH_SPEED,TBJ_LENTH,1000,1000,20,20,10);
- TBJ_HeMo_Step++;
- }
- break;
- case 2:
- if(!Y_DRV)
- {
- TBJ_HeMo_Step=3;
- Set_Ctrlmode_trans(Y_AXIS,TARR_MODE);
- TBJ_HeMo_Delay=dwTickCount+100;
- }
- break;
- case 3:
- if(dwTickCount>=TBJ_HeMo_Delay)
- {
- TBJ_HeMo_Step=0;
- TBJ_Hemo_flag=1;
- SetPos(Y_AXIS,dwYRealPos_com);
- }
- break;
- case 20:
- if(dwTickCount>=TBJ_HeMo_Delay)
- {
- TBJ_LENTH=dwYRealPos-0;
- AxisMovePosAccDec(Y_AXIS, TBJ_PARAM_Y_HIGH_SPEED, -TBJ_LENTH, 1000,
- 1000, 20, 20, 10);
- TBJ_HeMo_Step++;
- }
- break;
- case 21:
- if(!Y_DRV)
- {
- TBJ_HeMo_Step=0;
- TBJ_Hemo_flag=0;
- TBJ_ChuiQi(); //启动吹气
- }
- break;
- }
- }
- //下冲复位处理
- void TBJ_XCReset_Proc(void)
- {
- switch(TBJ_XC_RstStep)
- {
- case 1:
- if(TBJ_XC_Reset_flag)
- {
- AxisDisableSoftwarelmt(Y_AXIS);
- if(TBJ_Y_ORIGIN_IN&&dwTickCount>=TBJ_XCRst_Delay)
- {
- TBJ_XC_RstStep=4;
- AxisContinueMove(Y_AXIS,200,DIR_P);
- }
- else
- {
- TBJ_XC_RstStep++;
- AxisContinueMove(Y_AXIS,800,DIR_N);
- }
- }
- else
- {
- TBJ_XC_RstStep=14;
- SetPos(Y_AXIS,dwYRealPos_com);
- }
- break;
- case 2:
- if(TBJ_Y_ORIGIN_IN)
- {
- TBJ_XC_RstStep++;
- AxisEgmStop(Y_AXIS);
- TBJ_XCRst_Delay=dwTickCount+10;
- }
- break;
- case 3:
- if(dwTickCount>=TBJ_XCRst_Delay)
- {
- TBJ_XC_RstStep++;
- AxisContinueMove(Y_AXIS,200,DIR_P);
- }
- break;
- case 4:
- if(!TBJ_Y_ORIGIN_IN)
- {
- TBJ_XC_RstStep++;
- AxisEgmStop(Y_AXIS);
- TBJ_XCRst_Delay=dwTickCount+10;
- }
- break;
- case 5:
- TBJ_XC_RstStep++;
- AxisMovePosAccDec(Y_AXIS,800,10,800,800,10,10,0);
- break;
- case 6:
- if(dwTickCount>=TBJ_XCRst_Delay&&!Y_DRV)
- {
- TBJ_XC_RstStep++;
- AxisContinueMove(Y_AXIS,200,DIR_N);
- }
- break;
- case 7:
- if(TBJ_Y_ORIGIN_IN)
- {
- TBJ_XC_RstStep++;
- AxisEgmStop(Y_AXIS);
- TBJ_XCRst_Delay=dwTickCount+10;
- }
- break;
- case 8:
- if(dwTickCount>=TBJ_XCRst_Delay&&!Y_DRV)
- {
- TBJ_XC_RstStep++;
- //AxisMovePos(Y_AXIS,400,-10);
- AxisMovePosAccDec(Y_AXIS,400,-10,400,400,10,10,0);
- }
- break;
- case 9:
- if(!Y_DRV)
- {
- /*if(TBJ_PARAM_SFXC_MODE)
- {
- if(get_tarr_set(Y_AXIS)!=2)//伺服配置转矩限制失败
- {
- TBJ_XC_RstStep=0;
- SetEn(Y_AXIS, MOTOR_DISEN);//设置扭矩做准备
- TBJ_XC_Reset_flag=1;
- TBJ_SetAlarmCode(65);//伺服转矩配置失败
- }
- }*/
- TBJ_XC_RstStep++;
- TBJ_XCRst_Delay=dwTickCount+100;
- }
- break;
- case 10:
- if(dwTickCount>=TBJ_XCRst_Delay&&!Y_DRV)
- {
-
- SetPos(Y_AXIS, 0);
- axis_set_com_pos(Y_AXIS,0);
- //if(TBJ_PARAM_SFXC_MODE==0)
- {
- TBJ_XC_RstStep=0;
- TBJ_bXCResting=0;
- TBJ_XC_Reset_flag=0;
- AxisEnableSoftwarelmt(Y_AXIS,TBJ_PARAM_Y_SOFT_PLIMIT,0);
- }
- /*else
- {
- TBJ_XC_RstStep++;
- TBJ_XCRst_Delay=dwTickCount+10;
- }*/
- }
- break;
- case 11:
- if(dwTickCount>=TBJ_XCRst_Delay)
- {
- TBJ_XC_RstStep++;
- Set_Ctrlmode_trans(Y_AXIS,TARR_MODE);
- TBJ_XCRst_Delay=dwTickCount+100;
- }
- break;
- case 12://扭矩到达
- if (dwTickCount >= TBJ_XCRst_Delay)
- {
- TBJ_XC_RstStep ++;
- TBJ_XCRst_Delay = dwTickCount + 500;
- }
- break;
- case 13://扭矩到达并维持10ms
- if (!(GetTarr(Y_AXIS)))
- {
- if((dwTickCount >= TBJ_XCRst_Delay))
- {
- TBJ_XC_RstStep++;
- TBJ_PARAM_Y_Work_Local= dwYRealPos_com-30;
- TBJ_PARAM_Y_SOFT_PLIMIT=dwYRealPos_com-20;
- //AxisEnableSoftwarelmt(Y_AXIS,TBJ_PARAM_Y_SOFT_PLIMIT,0);
- SetPos(Y_AXIS,dwYRealPos_com);
- Set_Ctrlmode_trans(Y_AXIS,POS_MODE);
- TBJ_XCRst_Delay = dwTickCount + 10;
- }
- }
- else
- {
- TBJ_XCRst_Delay = dwTickCount + 100;
- }
- break;
- case 14://扭矩到达
- if(dwTickCount>=TBJ_XCRst_Delay)
- {
- TBJ_XC_RstStep ++;
- AxisMovePosAccDec(Y_AXIS, TBJ_PARAM_Y_HIGH_SPEED, -dwYRealPos, 1000,
- 1000, 20, 20, 10) ;
- }
- break;
- case 15://扭矩到达
- if(!Y_DRV)
- {
- TBJ_XCRst_Delay = dwTickCount + 100;
- TBJ_XC_RstStep = 16;
- }
- break;
- case 16://扭矩到达
- if(dwTickCount>=TBJ_XCRst_Delay)
- {
- if(TBJ_Y_ORIGIN_IN)
- {
- TBJ_XC_RstStep = 0;
- TBJ_bXCResting=0;
- TBJ_XC_Reset_flag=0;
- }
- else
- {
- TBJ_XC_RstStep = 1;
- TBJ_bXCResting=1;
- TBJ_XC_Reset_flag=1;
- }
- }
- break;
- }
- }
- //送胶动作
- void TBJ_SongJiao(void)
- {
- #if 1
- if (TBJ_bStop)
- return;
- switch (TBJ_SJ_FJ_Step)
- {
- case 0:
- break;
- case 1:
- TBJ_SJ_FJ_Step = 2;
- TBJ_SJ_Delay = dwTickCount + TBJ_PARAM_FJ_DELAY;
- break;
- case 2:
- if (dwTickCount >= TBJ_SJ_Delay)
- {
- TBJ_SJ_FJ_Step = 3;
- TBJ_FJ_VAVLE = 1; //分胶阀输出
- //TBJ_JJ_VAVLE = 1; //夹胶阀输出
- TBJ_JJ_VAVLE = 0; //2024-0903
- TBJ_FJ_Delay = dwTickCount + 1; //分胶阀输出时间
- TBJ_SJ_ErrorTime = dwTickCount + ERRORTIME; //分胶阀输出容错时间
- }
- break;
- case 3:
- if (TBJ_FJ_LIMIT_IN )
- {
- TBJ_SJ_FJ_Step = 4;
- TBJ_SJ_VAVLE = 1; //送胶输出
- TBJ_SJ_ErrorTime = dwTickCount + ERRORTIME;
- TBJ_FJ_Delay = dwTickCount + TBJ_PARAM_SJ_TIME;
- }
- else if (dwTickCount > TBJ_SJ_ErrorTime)
- {
- TBJ_SetAlarmCode(10); //E10 分胶未到位或 X12分胶前感应异常,无法送胶
- }
- break;
- case 4:
- TBJ_SJ_FJ_Step = 5;
- /*
- if ((TBJ_PARAM_SGZSelect || (TBJ_Motor_Step == 0)) && (dwTickCount >= TBJ_SJ_Delay))
- {
- if (TBJ_FJ_LIMIT_IN && TBJ_FJ_VAVLE)
- {
- TBJ_SJ_FJ_Step = 5;
- TBJ_SJ_VAVLE = 1; //送胶输出
- TBJ_SJ_ErrorTime = dwTickCount + ERRORTIME;
- TBJ_FJ_Delay = dwTickCount + TBJ_PARAM_SJ_TIME;
- }
- else if (dwTickCount > TBJ_SJ_ErrorTime)
- {
- TBJ_SetAlarmCode(10); //E10 分胶未到位或 X12分胶前感应异常,无法送胶
- }
- }*/
- break;
- case 5:
- if (TBJ_SJ_LIMIT_IN_UP || (TBJ_PARAM_SongJiaoMode && (dwTickCount > TBJ_FJ_Delay)))
- {
- TBJ_SJ_FJ_Step = 6;
- TBJ_FJ_Delay = dwTickCount + 20;
- }
- else if (dwTickCount > TBJ_SJ_ErrorTime)
- {
- TBJ_SetAlarmCode(4); //E04 送胶不到位或 X07送胶前感应异常
- }
- break;
- case 6:
- if ((dwTickCount >= TBJ_FJ_Delay) && (!X_DRV || TBJ_GUO_LIAN_IN_UP))
- {
- TBJ_SJ_FJ_Step = 7;
- TBJ_QJ_Step=1;
- TBJ_FJ_VAVLE = 0; //关分胶
- //TBJ_JJ_VAVLE = 0; //关夹胶
- TBJ_JJ_VAVLE=1;//2024-0903
- TBJ_FJ_Delay = dwTickCount + 10;
- TBJ_SJ_ErrorTime = dwTickCount + ERRORTIME;
- }
- break;
- case 7:
- if (!TBJ_FJ_LIMIT_IN && (dwTickCount >= TBJ_FJ_Delay) )
- {
- TBJ_SJ_FJ_Step = 8;
- if (TBJ_PARAM_SongJiaoMode == 0)TBJ_SJ_VAVLE = 0; //气缸送胶先退,滚轮送胶先不退或是触摸屏手动退送胶
- TBJ_SJ_ErrorTime = dwTickCount + ERRORTIME;
- }
- else if (dwTickCount >= TBJ_SJ_ErrorTime)
- {
- TBJ_SetAlarmCode(6); //E06 退分胶不到位警告或 X13分胶后感应异常
- }
- break;
- case 8:
- if ((TBJ_PARAM_SongJiaoMode)||(!TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN))
- {
- TBJ_SJ_FJ_Step = 0;
- TBJ_JJ_VAVLE=0;//2024-0903
- }
- else if (dwTickCount >= TBJ_SJ_ErrorTime)
- {
- TBJ_SetAlarmCode(5); //E05 退胶不到位警告 或 X16、X17送胶前后感应异常
- }
- break;
- //手动送胶
- case 20://手动送胶
- TBJ_JJ_VAVLE = 0; //压胶阀输出
- TBJ_SJ_Delay = dwTickCount + 70; //延迟70ms输出送胶阀
- TBJ_SJ_FJ_Step = 21;
- break;
- case 21:
- if (dwTickCount >= TBJ_SJ_Delay)
- {
- TBJ_SJ_VAVLE = 1; //压胶阀输出
- TBJ_SJ_FJ_Step = 22;
- }
- break;
- case 22:
- if (TBJ_SJ_LIMIT_IN)
- {
- //TBJ_JJ_VAVLE = 1; //压胶阀输出
- TBJ_SJ_FJ_Step = 23;
- TBJ_FJ_Delay = dwTickCount + 100;
- }
- break;
- case 23:
- if (dwTickCount>=TBJ_FJ_Delay)
- {
- TBJ_JJ_VAVLE = 1; //压胶阀输出
- TBJ_SJ_FJ_Step = 0;
- TBJ_FJ_Delay = dwTickCount + 50;
- }
- break;
-
- case 25://手动退送胶
- TBJ_JJ_VAVLE = 1; //压胶阀输出
- TBJ_SJ_Delay = dwTickCount + 50; //延迟120ms退回送胶阀
- TBJ_SJ_FJ_Step = 26;
- break;
- case 26:
- if (dwTickCount >= TBJ_SJ_Delay)
- {
- TBJ_SJ_VAVLE = 0; //压胶阀输出
- TBJ_SJ_FJ_Step = 27;
- TBJ_QJ_Step=1;
- }
- break;
- case 27:
- if (TBJ_SJ_ORIGIN_IN)
- {
- //判断是否使用切胶
- //TBJ_YD_VAVLE = 0; //压胶阀输出
- //TBJ_SJ_FJ_Step = 0;
- //TBJ_QJ_Step=1;
- TBJ_SJ_FJ_Step = 28;
- TBJ_SJ_Delay = dwTickCount + 50; //延迟120ms退回送胶阀
- }
- break;
- case 28:
- if (TBJ_QJ_Step==0&& (dwTickCount >= TBJ_SJ_Delay))
- {
- TBJ_JJ_VAVLE = 0;
- TBJ_SJ_FJ_Step = 0;
- }
- break;
- }
- #endif
- }
- //切胶处理
- void TBJ_QieJiao_Proc(void)
- {
- switch (TBJ_QJ_Step)
- {
- case 1:
- if(TBJ_SJ_ORIGIN_IN)
- {
- TBJ_QJ_Step=2;
- TBJ_QJ_VAVLE=1;
- TBJ_QieJiao_Delay=dwTickCount+ERRORTIME;
- }
- break;
- case 2:
- if(TBJ_QJ_LIMIT_IN)
- {
- TBJ_QJ_Step=3;
- TBJ_QJCQ_Start();
- TBJ_QieJiao_Delay=dwTickCount+10;
- }
- else if(dwTickCount>=TBJ_QieJiao_Delay)
- {
- TBJ_SetAlarmCode(TBJ_QJLIMIT_ALARM); //E15 切胶到位异常,检查X11
- }
- break;
- case 3:
- TBJ_QJ_Step=0;
- TBJ_QJ_VAVLE=0;
- break;
- }
-
- }
- //合模超声动作
- void TBJ_ChaoShengHeMo(void)
- {
- #if 1
- unsigned short cs_time;
- switch (TBJ_HMCS_Step)
- {
- case 0:
- break;
- case 1:
- if (!TBJ_FJ_VAVLE && (!TBJ_SJ_VAVLE || TBJ_PARAM_SongJiaoMode) //输出阀判断
- && !TBJ_FJ_LIMIT_IN && TBJ_FJ_ORIGIN_IN //分胶阀位置判断
- && (!TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN || (TBJ_PARAM_SongJiaoMode == 1)) //送胶阀位置判断
- && (TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN))) //钩针阀判断
- {
- TBJ_SM_VAVLE = 1; // 下冲
- TBJ_SFHM_Step=1;
- if ((TBJ_PARAM_XiaMo_Mode == 0) && (TBJ_PARAM_SGZSelect != 0))
- TBJ_XM_VAVLE = 1;
- TBJ_HMCS_Step = 2;
- TBJ_SM_ErrorTime = dwTickCount + (unsigned long)ERRORTIME; //上模下冲容错时间
- }
- else if (!TBJ_bRunning)
- TBJ_HMCS_Step = 0;
- break;
- case 2:
- if (TBJ_SM_LIMIT_IN && ((TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN)) || TBJ_PARAM_XiaMo_Mode)) //1 下模不动
- {
- TBJ_CS_Delay = dwTickCount + TBJ_PARAM_CS_DELAY; //延时超声
- TBJ_HMCS_Step = 3;
- if (TBJ_PARAM_TuiGouZhen_Mode == 1) //0 先超声后下勾针,1 先下勾针后超声
- TBJ_GZ_VAVLE = 0;
- }
- else if ((dwTickCount >= TBJ_SM_ErrorTime) && !TBJ_SM_LIMIT_IN)
- {
- TBJ_SetAlarmCode(26); //E26 超声停止,合模不到位或 X03下冲到位感应异常
- }
- else if ((dwTickCount >= TBJ_SM_ErrorTime) && (TBJ_GZ_LIMIT_IN))
- {
- TBJ_SetAlarmCode(27); //E27 超声停止,钩针不到位或 TBJ_GZ_ORIGIN_IN钩针复位感应异常
- }
- break;
- case 3:
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_bCS = 0;
- TBJ_CS_OUT = 1; //超声打开
- cs_time = TBJ_Choose_CSTime();
- if (cs_time > 1500)
- cs_time = 1500; //超声时间上限为1.5 S
- TBJ_CS_Delay = dwTickCount + cs_time;
- TBJ_HMCS_Step = 4;
- }
- TBJ_SJ_VAVLE = 0;
- break;
- case 4:
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_HMCS_Step = 5;
- TBJ_CS_OUT = 0;
- TBJ_CS_Delay = dwTickCount + (TBJ_Choose_COLDTime() / 3); //固化一半时间
- }
- break;
- case 5:
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_HMCS_Step = 6;
- TBJ_ChuiQi();
- TBJ_GZ_VAVLE = 0;
- TBJ_CS_Delay = dwTickCount + (TBJ_Choose_COLDTime()*2 / 3);
- }
- break;
- case 6:
- if (dwTickCount >= TBJ_CS_Delay)
- {
- if (TBJ_PARAM_HONGWAI_GanYin != 0)
- {
- //重新算温度
- cs_time = user_datas[55];
- if (user_datas[39] == 0)
- user_datas[39] = 1;
- //测温值 降时间阀值
- if ((cs_time >= user_datas[37]) && (cs_time >= user_datas[58]))
- {
- cs_time = (cs_time - user_datas[58]) / user_datas[39];
- cs_time *= user_datas[38];
- if (cs_time > 3)
- cs_time = 3;
- if ((user_datas[59] + cs_time) < 4)
- user_datas[59] += cs_time;
- else if (user_datas[59] < 4)
- {
- cs_time = 3 - user_datas[59];
- user_datas[59] = 3;
- }
- else
- cs_time = 0;
- }
- else
- cs_time = 0;
- user_datas[57] = TBJ_Choose_CSTime();
- user_datas[57] -= cs_time;
- TBJ_ResetCsTime();
- }
- user_datas[56] = user_datas[55];
- if (user_datas[56] > user_datas[58])
- user_datas[58] = user_datas[55];
- TBJ_SM_VAVLE = 0;
- TBJ_XM_VAVLE = 0;
- TBJ_HMCS_Step = 0;
- TBJ_CS_Delay = dwTickCount + 350;
- }
- break;
- }
- #endif
- }
- //合模超声动作,伺服合模
- void TBJ_ChaoShengHeMo_SF(void)
- {
- #if 1
- unsigned short cs_time;
- static unsigned char JLXL_flag=0,JLXL_flag1=0;
- switch (TBJ_HMCS_Step)
- {
- case 0:
- break;
- case 1://走位置
- if (!TBJ_FJ_VAVLE && (!TBJ_SJ_VAVLE || TBJ_PARAM_SongJiaoMode) //输出阀判断
- && !TBJ_FJ_LIMIT_IN && TBJ_FJ_ORIGIN_IN //分胶阀位置判断
- && (!TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN || (TBJ_PARAM_SongJiaoMode == 1)) //送胶阀位置判断
- ) //钩针阀判断
- {
- if(TBJ_PARAM_TuiGouZhen_Mode)//先下钩针
- {
- TBJ_GZ_VAVLE=0;
- TBJ_CS_Delay = dwTickCount + TBJ_PARAM_GZREBACK_TIME;
- TBJ_HMCS_Step = 2;
- }
- else//先超声
- {
- TBJ_HMCS_Step = 3;
- TBJ_CS_Delay = dwTickCount + 0;
- }
- }
- else if (!TBJ_bRunning)
- TBJ_HMCS_Step = 0;
- break;
- case 2://转扭矩
- if(dwTickCount>=TBJ_CS_Delay)
- {
- TBJ_DZ_VAVLE=0;
- TBJ_HMCS_Step = 3;
- TBJ_CS_Delay = dwTickCount+10;
- }
- break;
- case 3://转扭矩
- if(dwTickCount>=TBJ_CS_Delay)
- {
- if(TBJ_PARAM_SFXC_MODE&&TEST1<1) //自适应模式第一条走扭矩
- {
- TBJ_LENTH=100-dwYRealPos;
- AxisMovePosAccDec(Y_AXIS, TBJ_PARAM_Y_HIGH_SPEED, TBJ_LENTH, 1000,
- 1000, 20, 20, 10);
- }
- else
- {
- TBJ_LENTH=TBJ_PARAM_Y_Work_Local-dwYRealPos;
- AxisMovePosAccDec(Y_AXIS, TBJ_PARAM_Y_HIGH_SPEED, TBJ_LENTH, 1000,
- 1000, 20, 20, 10);
- }
- TBJ_HMCS_Step = 4;
- }
- break;
- case 4://转扭矩
- if (!Y_DRV)
- {
- TBJ_HMCS_Step = 5;
- Set_Ctrlmode_trans(Y_AXIS,TARR_MODE);
- TBJ_CS_Delay = dwTickCount + 10;
- if (TBJ_PARAM_TuiGouZhen_Mode == 1)TBJ_GZ_VAVLE = 0;//0 先超声后下勾针,1 先下勾针后超声
- }
- break;
- case 5://扭矩到达
- if (!GetTarr(Y_AXIS))
- {
- if(dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_HMCS_Step = 6;
- TBJ_CS_Delay = dwTickCount + 10;
- }
- }
- else
- {
- TBJ_CS_Delay = dwTickCount + 10;
- }
- break;
- case 6://扭矩到达并维持10ms
- if (!GetTarr(Y_AXIS)&&(dwTickCount >= TBJ_CS_Delay))
- {
- //获取Y轴位置
- if(TBJ_PARAM_SFXC_MODE&&TEST1<1)
- TBJ_CS_Delay = dwTickCount + 200; //延时超声
- else
- TBJ_CS_Delay = dwTickCount + TBJ_PARAM_CS_DELAY; //延时超声
- TBJ_HMCS_Step = 7;
- }
- break;
- case 7:
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_CS_Y_Local=dwYRealPos_com;
- if(TEST1<=1)TBJ_FIRST_CS_Y_LOCAL=dwYRealPos_com;
- if(abs(TBJ_FIRST_CS_Y_LOCAL-TBJ_CS_Y_Local)<=3)
- {
- TBJ_bCS = 0;
- TBJ_CS_OUT = 1; //超声打开
- cs_time = TBJ_Choose_CSTime();
- if (cs_time > 1500)
- cs_time = 1500; //超声时间上限为1.5 S
- TBJ_CS_Delay = dwTickCount + cs_time;
- if(TBJ_PARAM_CS_MODE)
- TBJ_HeMo_JLXL_Delay=dwTickCount+TBJ_PARAM_JL_BD_DELAY;
- else
- TBJ_HeMo_JLXL_Delay=dwTickCount+TBJ_PARAM_JL_TM_DELAY;
- JLXL_flag=1;
- TBJ_HMCS_Step = 8;
- }
- else
- {
- TBJ_HMCS_Step = 10;
- TBJ_CS_Delay = dwTickCount + 100;
- }
- }
- break;
- case 8:
- if(dwTickCount>=TBJ_HeMo_JLXL_Delay&&JLXL_flag)
- {
- JLXL_flag=0;
- JLXL_flag1=1;
- if(TBJ_PARAM_CS_MODE)TBJ_NJ_SEL=SERVO_PARAM_TRARR_BD_LIMITMAX;
- else TBJ_NJ_SEL=SERVO_PARAM_TRARR_TM_LIMITMAX;
-
- set_servo_postotarr_limit(Y_AXIS,TBJ_NJ_SEL,TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- if(TBJ_PARAM_CS_MODE)
- TBJ_HeMo_JLXL_Delay=dwTickCount+TBJ_PARAM_XL_BD_DELAY;
- else
- TBJ_HeMo_JLXL_Delay=dwTickCount+TBJ_PARAM_XL_TM_DELAY;
- }
- if(dwTickCount>=TBJ_HeMo_JLXL_Delay&&JLXL_flag1)
- {
- JLXL_flag1=0;
- if(TBJ_PARAM_CS_MODE)TBJ_NJ_SEL=SERVO_PARAM_TRARR_BD_LIMITMIN;
- else TBJ_NJ_SEL=SERVO_PARAM_TRARR_TM_LIMITMIN;
- set_servo_postotarr_limit(Y_AXIS,TBJ_NJ_SEL,TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- }
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_HMCS_Step = 9;
- TBJ_GH_Y_Local=dwYRealPos_com;
- TBJ_CS_OUT = 0;
- TBJ_CS_Delay = dwTickCount + (TBJ_Choose_COLDTime() / 3); //固化一半时间
- if(JLXL_flag)
- {
- if(TBJ_PARAM_CS_MODE)TBJ_NJ_SEL=SERVO_PARAM_TRARR_BD_LIMITMAX;
- else TBJ_NJ_SEL=SERVO_PARAM_TRARR_TM_LIMITMAX;
- set_servo_postotarr_limit(Y_AXIS,TBJ_NJ_SEL,TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- if(TBJ_PARAM_CS_MODE)
- TBJ_HeMo_JLXL_Delay=dwTickCount+TBJ_PARAM_XL_BD_DELAY;
- else
- TBJ_HeMo_JLXL_Delay=dwTickCount+TBJ_PARAM_XL_TM_DELAY;
- JLXL_flag1=1;
- }
- }
- break;
- case 9:
- if(dwTickCount>=TBJ_HeMo_JLXL_Delay&&JLXL_flag1)
- {
- JLXL_flag1=0;
- if(TBJ_PARAM_CS_MODE)TBJ_NJ_SEL=SERVO_PARAM_TRARR_BD_LIMITMIN;
- else TBJ_NJ_SEL=SERVO_PARAM_TRARR_TM_LIMITMIN;
- set_servo_postotarr_limit(Y_AXIS,TBJ_NJ_SEL,TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- }
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_HMCS_Step = 10;
- TBJ_ChuiQi();
- TBJ_GZ_VAVLE = 0;
- TBJ_CS_Delay = dwTickCount + (TBJ_Choose_COLDTime()*2 / 3);
- }
- break;
- case 10:
- if(dwTickCount>=TBJ_HeMo_JLXL_Delay&&JLXL_flag1)
- {
- JLXL_flag1=0;
- if(TBJ_PARAM_CS_MODE)TBJ_NJ_SEL=SERVO_PARAM_TRARR_BD_LIMITMIN;
- else TBJ_NJ_SEL=SERVO_PARAM_TRARR_TM_LIMITMIN;
- set_servo_postotarr_limit(Y_AXIS,TBJ_NJ_SEL,TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- }
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_XM_VAVLE = 0;
- TBJ_HMCS_Step = 11;
- SetPos(Y_AXIS,dwYRealPos_com);
- Set_Ctrlmode_trans(Y_AXIS,POS_MODE);
- TBJ_XC_CS_LOCAL=dwYRealPos_com;
- if(TEST1<1)
- {
- TBJ_PARAM_Y_Work_Local= dwYRealPos_com-25;
- TBJ_PARAM_Y_SOFT_PLIMIT=dwYRealPos_com-15;
- AxisEnableSoftwarelmt(Y_AXIS,TBJ_PARAM_Y_SOFT_PLIMIT,0);
- }
- TBJ_CS_Delay = dwTickCount + 10;
- }
- break;
- case 11:
- if (dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_LENTH=dwYRealPos-0;
- TBJ_CS_Delay = dwTickCount+1500;
- AxisMovePosAccDec(Y_AXIS, TBJ_PARAM_Y_HIGH_SPEED, -TBJ_LENTH, 1000,
- 1000, 20, 20, 10);
- TBJ_HMCS_Step = 12;
- }
- break;
- case 12:
- if (TBJ_Y_ORIGIN_IN)
- {
- TBJ_GZ_VAVLE=0;
- TBJ_YD_VAVLE=0;
- TBJ_DZ_VAVLE=0;
- TBJ_HMCS_Step = 0;
- TBJ_bSC_FLAG=0;
- }
- else if(dwTickCount >= TBJ_CS_Delay)
- {
- TBJ_SetAlarmCode(TBJ_NO_YORIGIN_ALARM);//E19 超声结束后伺服未复位到原点
- }
- break;
- }
- #endif
- }
- //启动停止故障停止动作
- void TBJ_StartStopAction(void)
- {
- #if 1
- //告警灯
- if(GetAlarmCode(TBJ_ALARM_ADDR)==0)
- {
- TBJ_LED_R_OUT=0;
- TBJ_LED_Y_OUT=0;
- TBJ_LED_G_OUT=0;
- if(TBJ_bRunning)TBJ_LED_G_OUT=1;
- else TBJ_LED_Y_OUT=1;
- }
- else
- {
- TBJ_LED_R_OUT=1;
- TBJ_LED_Y_OUT=0;
- TBJ_LED_G_OUT=0;
- }
- //卡带感应
- if(TBJ_KADAI_IN)
- {
- TBJ_SetAlarmCode(TBJ_KADAI_ALARM);
- }
- else
- {
- if(GetAlarmCode(TBJ_ALARM_ADDR) == TBJ_KADAI_ALARM)SetAlarmCode(TBJ_ALARM_ADDR,0);
- }
- if(GetAlarm(Y_AXIS)==1)
- {
- TBJ_SetAlarmCode(TBJ_SERVO_ALARM);
- }
- else
- {
- if(GetAlarmCode(TBJ_ALARM_ADDR) == TBJ_SERVO_ALARM)SetAlarmCode(TBJ_ALARM_ADDR,0);
- }
- if ((TBJ_START_IN_UP || TBJ_bStart||TBJ_bSingle||TBJ_HandWork) && !TBJ_bRunning && (TBJ_Auto_Step == 0))
- {
- if (GetTotal(TBJ_TOTAL_ADDR) >= TBJ_SET_TOTAL)
- TBJ_SetAlarmCode(TBJ_TOTAL_ALARM);
- else if(!(GetServoComState(Y_AXIS)))
- TBJ_SetAlarmCode(TBJ_SERVO_COM_ALARM);
- else
- {
- if(TBJ_XC_Reset_flag||!TBJ_Y_ORIGIN_IN)
- {
- TBJ_bXCRest=0;
- TBJ_bXCResting=1;
- TBJ_XC_RstStep=1;
- SetEn(Y_AXIS, TBJ_MOTOR_EN);
- Set_Ctrlmode_trans(Y_AXIS,POS_MODE);
- set_servo_postotarr_limit(Y_AXIS,SERVO_PARAM_TRARR_BD_LIMITMIN,
- TBJ_PARAM_SFZSY_SPEED,TBJ_PARAM_SFZSY_SPEED,SERVO_TARR_CW);
- }
- SetEn(X_AXIS, TBJ_MOTOR_EN);
- TBJ_Auto_Delay = dwTickCount + 100;
- TBJ_Auto_Step = 1;
- TBJ_bRunning = 1;
- TBJ_Auto_Delay = 0;
- TBJ_PARAM_SQJCOUNT=0;
- TBJ_PARAM_XQJCOUNT=0;
- TBJ_SD_VAVLE=1;
- TBJ_GZ_VAVLE = 0;//钩针
- TBJ_FJ_VAVLE = 0; //分胶
- TBJ_DZ_VAVLE=0;//顶针
- TBJ_SJ_VAVLE=0;//送胶
- TBJ_YD_VAVLE=0;
- if(TBJ_bSingle)TBJ_bSingleOne=1;
- if(TBJ_HandWork)
- {
- TBJ_HandWorking=1;
- TBJ_bSingleOne=1;
- }
- }
- TBJ_HandWork=0;
- TBJ_bStart = 0;
- TBJ_bSingle=0;
- TBJ_bSC_FLAG=0;
- TBJ_LLPL_flag=0;
- }
- if (TBJ_STOP_IN_UP || TBJ_bStop)
- {
- /*当自动步骤达到4,已完成送胶动作,将本次贴胶动作做完*/
- if (TBJ_bRunning && !TBJ_bSingleOne)
- {
- TBJ_bStop = 0;
- TBJ_bSingleOne = 1;
- }
- else
- {
- TBJ_bStart = 0;
- TBJ_bRunning = 0;
- TBJ_bSingleOne=0;
- TBJ_HandWorking=0;
- TBJ_bAlarmStop = 0;
- TBJ_bStop = 0;
- TBJ_HMCS_Step = 0;
- TBJ_Auto_Step = 0;
- TBJ_SJ_FJ_Step = 0;
- TBJ_Motor_Step = 0;
- TBJ_bXCResting=0;
- TBJ_XC_RstStep=0;
- TBJ_QJ_Step=0;
- TBJ_HeMo_Step=0;
- TBJ_QJ_Step=0;
- AxisEgmStop(X_AXIS); //刹停电机
- SetEn(X_AXIS, TBJ_MOTOR_DISEN); //松轴
- AxisEgmStop(Y_AXIS); //刹停电机
- if(GetAlarm(Y_AXIS)==1)SetClr(Y_AXIS, 1);
- //SetEn(Y_AXIS, TBJ_MOTOR_DISEN); //松轴
- TBJ_GZ_VAVLE = 0; //Y01钩针
- TBJ_FJ_VAVLE = 0; //Y02分胶
- TBJ_SM_VAVLE = 0; //Y03上模(下冲)
- TBJ_CS_OUT = 0; //Y10超声
- TBJ_MOTOR_OUT = 0; //Y11拖带电机
- TBJ_XM_VAVLE = 0; //Y12下模
- TBJ_DZ_VAVLE=0;
- TBJ_YD_VAVLE=0;
- //TBJ_SD_VAVLE=0;
- if (TBJ_PARAM_SHENGJIAO == 1)
- TBJ_STOP_Step = 1; //停机节省布胶动作
- else
- {
- TBJ_JJ_VAVLE = 0; //Y05压带
- TBJ_SJ_VAVLE = 0; //Y04送胶退回
- }
- TBJ_bSC_FLAG=0;
- TBJ_XC_RstStep=0;
- TBJ_bXCResting=0;
- }
- }
- if (TBJ_bAlarmStop)
- {
- TBJ_bAlarmStop = 0;
- AxisEgmStop(X_AXIS);
- TBJ_Auto_Step = 0;
- TBJ_HMCS_Step = 0;
- TBJ_Motor_Step = 0;
- TBJ_SJ_FJ_Step = 0;
- TBJ_bRunning = 0;
- SingOneFlg = 0;
- SetEn(X_AXIS, TBJ_MOTOR_DISEN); //松轴
- }
- #endif
- }
- void TBJ_STOP_Action(void)
- {
- #if 1
- switch (TBJ_STOP_Step)
- {
- case 0:
- break;
- case 1:
- {
- TBJ_JJ_VAVLE = 0;
- TBJ_STOP_Delay = dwTickCount + 50;
- TBJ_STOP_Step = 2;
- }
- break;
- case 2:
- if (dwTickCount >= TBJ_STOP_Delay)
- {
- TBJ_SJ_VAVLE = 0;
- TBJ_STOP_Step = 3;
- }
- break;
- case 3:
- if (TBJ_SJ_ORIGIN_IN)
- {
- TBJ_JJ_VAVLE = 0;
- TBJ_STOP_Step = 0;
- }
- break;
- }
- #endif
- }
- //电机动作
- void TBJ_Motor(void) //
- {
- #if 1
- switch (TBJ_Motor_Step)
- {
- case 0:
- //AxisDecStop(X_AXIS); //上钩针后减速停,保证拉链到位
- break;
- case 1:
- TBJ_Motor_Step = 2;
- SetPos(X_AXIS, 0);
- TBJ_DJ_ErrorTime = dwTickCount + TBJ_PARAM_DJ_AUTO_STOP_TIME; //电机容错时间
- if(TBJ_PARAM_DEC_MODE)
- {
- if (TEST1 > 1 )
- {
- //第三条,开始走数控长度
- AxisMovePosAccDecNotStop(X_AXIS, TBJ_PARAM_HIGH_SPEED, TBJ_SAVE_POS - TNJ_PARAM_TD_LENGTH - 200,
- TBJ_PARAM_MOTOR_START_SPEED, TBJ_PARAM_NULL_SPEED, TBJ_PARAM_MOTOR_ADD, TBJ_PARAM_MOTOR_ADD, 0);
- }
- else
- {
- AxisContinueMoveAcc(X_AXIS, TBJ_PARAM_HIGH_SPEED*2/3, TBJ_DIR_P, TBJ_PARAM_MOTOR_START_SPEED,
- TBJ_PARAM_NULL_SPEED, TBJ_PARAM_MOTOR_ADD, TBJ_PARAM_MOTOR_ADD);
- }
- }
- else
- {
- AxisContinueMoveAcc(X_AXIS, TBJ_PARAM_HIGH_SPEED, TBJ_DIR_P, TBJ_PARAM_MOTOR_START_SPEED,
- TBJ_PARAM_NULL_SPEED, TBJ_PARAM_MOTOR_ADD, TBJ_PARAM_MOTOR_ADD);
- }
- break;
- case 2:
- if (TEST1 > 1 && TBJ_PARAM_DEC_MODE)
- {
- if (!TBJ_GUO_LIAN_IN)
- {
- TBJ_Motor_Step = 3;
- TBJ_Motor_Delay = dwTickCount + 10; //防震时间
- TBJ_DJ_ErrorTime = dwTickCount + ERRORTIME;
- if(dwXRealPos<(TBJ_SAVE_POS - TNJ_PARAM_TD_LENGTH - 600))
- AxisContinueMoveChangeSpeed(X_AXIS,TBJ_PARAM_NULL_SPEED,1000,20,20);
- }
- if ((TBJ_PARAM_LL_PRETECT_LENGTH > 0) && (GetPos(X_AXIS) >= TBJ_SAVE_POS + TBJ_PARAM_LL_PRETECT_LENGTH))
- {
- TBJ_SetAlarmCode(8); //E8 拉链长度异常,超过拉链保护长度
- }
- }
- else
- {
- if (!TBJ_GUO_LIAN_IN )
- {
- TBJ_Motor_Step = 3;
- TBJ_Motor_Delay = dwTickCount + 10; //防震时间
- TBJ_DJ_ErrorTime = dwTickCount + ERRORTIME;
- AxisContinueMoveChangeSpeed(X_AXIS,TBJ_PARAM_NULL_SPEED,1000,20,20);
- }
- }
- if ((dwTickCount > TBJ_DJ_ErrorTime) && (TBJ_PARAM_DJ_AUTO_STOP_TIME ))
- {
- TBJ_SetAlarmCode(24); //E24 拉拉链时间过长,可能由以下原因:①超出保护时间,请检查保护时间是否设置过短②电机是否启动,速度是否过慢③拉链过紧,电机没拉动
- }
- break;
- case 3: //防震
- if (TBJ_GUO_LIAN_IN)
- {
- TBJ_Motor_Step = 2;
- }
- if (dwTickCount >= TBJ_Motor_Delay)
- {
- TBJ_Motor_Step = 4;
- }
- break;
- case 4:
- if (TBJ_GUO_LIAN_IN || (TBJ_TEST_MODE && (dwTickCount > TBJ_TEST_TIME))) //过链上升沿
- {
- if (TBJ_PARAM_TWOTD_SELECT == 0)
- {
- TBJ_Motor_Step = 5;
- TBJ_DJ_ErrorTime = dwTickCount + 5000; //电机容错时间
- AxisMovePosAccDec(X_AXIS, TBJ_PARAM_NULL_SPEED, TNJ_PARAM_TD_LENGTH, TBJ_PARAM_NULL_SPEED,
- 1000, 50, 50, 20); //普通拖带,根据脉冲走一定距离
- TBJ_GZ_Delay = dwTickCount + TBJ_PARAM_GZ_DELAY; //钩针延时输出
- }
- else//二次拖带是,双钩针带缺口,防止撞送带增加的,要等送胶到位后,才能下钩针
- {
- AxisMovePosAccDec(X_AXIS, TBJ_PARAM_NULL_SPEED, TBJ_PARAM_TWOTD_LENGTH, TBJ_PARAM_NULL_SPEED,
- 1000,50, 50, 0); //二次拖带,根据脉冲走不同距离
- TBJ_Motor_Step = 40;
- }
- }
- else if (dwTickCount > TBJ_DJ_ErrorTime) //一直处于空位,没拉链警告
- {
- TBJ_SetAlarmCode(1); //E01 没拉链警告 请检查 X15 过链接近开关
- }
- break;
- case 40:
- if (!X_DRV) //轴停
- {
- TBJ_GZ_VAVLE = 1; //输出钩针
- if (!TBJ_SJ_VAVLE&&TBJ_SJ_LIMIT_IN) //分胶送胶已完成
- {
- TBJ_Motor_Delay = dwTickCount + 10; //二次拖带电机延时输出
- TBJ_Motor_Step = 41;
- }
- }
- break;
- case 41:
- if (dwTickCount > TBJ_Motor_Delay) //二次拖带电机延时已过
- {
- TBJ_Motor_Step = 5;
- TBJ_DJ_ErrorTime = dwTickCount + 500; //电机容错时间
- AxisMovePosAccDec(X_AXIS, TBJ_PARAM_NULL_SPEED, TNJ_PARAM_TD_LENGTH, 1000,
- 1000, 20, 20, 0); //根据脉冲走一定距离
- }
- break;
- case 5:
- if (dwTickCount > TBJ_GZ_Delay)
- {
- TBJ_GZ_VAVLE = 1; //上钩针
- }
- if(TBJ_PARAM_SGZSelect==0)//双钩针模式
- {
- if(TBJ_GZ_LIMIT_IN)
- {
- TBJ_LLPL_flag=0;
- AxisEgmStop(X_AXIS); //急停电机
- TBJ_Motor_Step = 6;
- TBJ_DZ_VAVLE=1;
- TBJ_Motor_Delay = dwTickCount + 10; //延时压带
- if(GetAlarmCode(TBJ_ALARM_ADDR)==TBJ_LLPL_ALARM)
- SetAlarmCode(TBJ_ALARM_ADDR, 0);
- }
- else if (dwTickCount >= TBJ_DJ_ErrorTime)
- {
- if(TEST1<2||TBJ_LLPL_flag)
- {
- TBJ_SetAlarmCode(25); //E25 钩针未到位或 TBJ_TD_LIMIT_IN 钩针到位感应异常警告,电机停止
- }
- else
- {
- TBJ_LLPL_flag++;
- SetAlarmCode(TBJ_ALARM_ADDR, TBJ_LLPL_ALARM);
- }
- }
- }
- else //单钩针模式
- {
- if(!X_DRV)
- {
- TBJ_GZ_VAVLE = 1; //上钩针
- TBJ_Motor_Step = 0; //单钩针方式便完成电机动作
- }
- else if (dwTickCount >= TBJ_DJ_ErrorTime)
- {
- TBJ_SetAlarmCode(25); //E25 钩针未到位或 TBJ_TD_LIMIT_IN 钩针到位感应异常警告,电机停止
- }
- }
- break;
- /*以下为双钩针模式进行*/
- case 6:
- if (dwTickCount > TBJ_Motor_Delay)
- {
- TBJ_Motor_Step = 7;
- TBJ_YD_VAVLE = 1; //压带输出
- TBJ_Motor_Delay = dwTickCount + TBJ_PARAM_YD_TIME; //压带输出延时退勾针
- }
- break;
- case 7:
- if (dwTickCount > TBJ_Motor_Delay) //过了钩针延时
- {
- //TBJ_GZ_VAVLE = 0; //钩针退出
- TBJ_Motor_Step = 0;
- TBJ_DJ_ErrorTime = dwTickCount + ERRORTIME; //钩针退回容错时间
- }
- break;
- case 8:
- if (!TBJ_GZ_LIMIT_IN) //钩针返回原位感应
- {
- TBJ_Motor_Step = 0; //完成双钩针模式
- }
- else if (dwTickCount > TBJ_DJ_ErrorTime) //钩针长时间不退回
- {
- TBJ_SetAlarmCode(2); //E02 退勾针不到位或 TBJ_GZ_ORIGIN_IN 钩针复位感应异常,当前程序处于电机第七步
- }
- break;
- //电机退链
- case 20:
- //SetEn(X_AXIS, TBJ_MOTOR_EN); //锁轴
- //SetPos(X_AXIS, 0); //设当前位置pos为0
- TBJ_Motor_Step = 21;
- TBJ_Motor_Delay = dwTickCount + 5; //电机延时启动,等待锁轴
- if (TBJ_PARAM_DJ_FANZHUAN == 0) //电机如果没有选择反转退链,则关闭该步骤
- TBJ_Motor_Step = 0;
- break;
- case 21:
- if (dwTickCount > TBJ_Motor_Delay) //锁轴完成
- {
- TBJ_Motor_Step = 22;
- AxisMovePosAccDec(X_AXIS, TBJ_PARAM_NULL_SPEED, -TBJ_TUILIAN_LENGTH, TBJ_PARAM_NULL_SPEED,
- TBJ_PARAM_NULL_SPEED, 20, 20, 0); //根据脉冲走一定距离
- }
- break;
- case 22:
- //if (!X_DRV) //电机移动到退链长度
- {
- TBJ_Motor_Step = 0;
- if (TBJ_FJBACKMode)
- TBJ_FJ_VAVLE = 0; //二次拖带退分胶
- }
- break;
- }
- #endif
- }
- int TBJ_QieJiao_Check(void)
- {
- switch(TBJ_PARAM_QJCheck_MODE)
- {
- case 0://不检测
- return 1;
- break;
- case 1://信号检测
- if(TBJ_XQJGY_IN)
- {
- TBJ_SetAlarmCode(TBJ_NoJiao_W);
- return 0;
- }
- else
- {
- return 1;
- }
- break;
- case 2://码盘检测
- if((TEST1>5)&&((TBJ_PARAM_SQJCOUNT<TBJ_PARAM_SET_SQJCOUNT)&&TBJ_PARAM_SET_SQJCOUNT
- ||(TBJ_PARAM_XQJCOUNT<TBJ_PARAM_SET_XQJCOUNT)&&(TBJ_PARAM_SET_XQJCOUNT)))
- {
- if(TBJ_PARAM_SQJCOUNT<TBJ_PARAM_SET_SQJCOUNT)
- TBJ_SetAlarmCode(TBJ_NoSJiao_W); //E63 上胶已用完,请补充胶 或检查X01上胶感应信号
- else
- TBJ_SetAlarmCode(TBJ_NoXJiao_W); //E64 下胶已用完,请补充胶,或检查X00下胶感应信号
- return 0;
- }
- else
- {
- TBJ_PARAM_SQJCOUNT=0;
- TBJ_PARAM_XQJCOUNT=0;
- return 1;
- }
- break;
- }
- return 0;
- }
- //自动运行动作
- void TBJ_AutoRunStep(void)
- {
- #if 1
- if (TBJ_bRunning)
- {
- switch (TBJ_Auto_Step)
- {
- case 0:
- break;
- case 1:
- if(TBJ_Y_ORIGIN_IN&&TBJ_XC_Reset_flag==0&&(dwTickCount > TBJ_Auto_Delay))
- {
- TBJ_Auto_Step = 2;
- TBJ_Auto_Delay = dwTickCount + 1;
- TEST1 = 0; //当前为第一条拉链
- TBJ_SAVE_POS = 0; //用来保存第二条长度,置零
- }
- break;
- case 2: //第一条时
- if (dwTickCount > TBJ_Auto_Delay&&TBJ_Y_ORIGIN_IN)
- {
- if(TBJ_PARAM_CS_MODE)TBJ_NJ_SEL=SERVO_PARAM_TRARR_BD_LIMITMIN;
- else TBJ_NJ_SEL=SERVO_PARAM_TRARR_TM_LIMITMIN;
- set_servo_postotarr_limit(Y_AXIS,TBJ_NJ_SEL,TBJ_PARAM_Y_LOW_SPEED,TBJ_PARAM_Y_LOW_SPEED,SERVO_TARR_CW);
- Set_Ctrlmode_trans(Y_AXIS,POS_MODE);
- if(TBJ_QieJiao_Check())//缺胶检测
- {
-
- TBJ_Auto_Step = 3;
- TBJ_SJ_FJ_Step = 1; //开始分胶送胶,送胶分胶需电机动作完成后才能完成
- SetPos(X_AXIS, 0);
- if(!TBJ_HandWorking)
- {
- if(TBJ_PARAM_SGZSelect)//单钩针
- {
- if (!TBJ_GZ_VAVLE)TBJ_Motor_Step = 1; //开始电机动作
- else TBJ_SetAlarmCode(QD_GZOut_W); //E18 钩针阀未退回,无法启动
- }
- else//双钩针
- {
- if(!TBJ_GZ_LIMIT_IN)TBJ_Motor_Step = 1; //开始电机动作
- else TBJ_SetAlarmCode(QD_GZOut_W); //E18 钩针阀未退回,无法启动
- }
- }
- }
- }
- break;
- case 3:
- if ((TBJ_SJ_FJ_Step == 0) && (TBJ_Motor_Step == 0))
- {
- TBJ_Auto_Step = 4;
- if (TEST1 == 1) //第二条拉链
- TBJ_SAVE_POS = GetPos(X_AXIS); //保存第二条拉链的长度数据
- if (TBJ_PARAM_DJ_FANZHUAN == 1&&!TBJ_HandWorking)
- TBJ_Motor_Step = 20;
- if(TBJ_HandWorking)
- {
- TBJ_GZ_VAVLE=1;
- }
- TBJ_Auto_Delay = dwTickCount + 1000; //延迟执行超声合模动作
- }
- break;
- case 4:
- if ((!TBJ_FJ_LIMIT_IN && TBJ_FJ_ORIGIN_IN) //分胶没输出 到位没感应 原位有感应 没有分胶阀则不考虑前面条件
- && ((!TBJ_SJ_LIMIT_IN && TBJ_SJ_ORIGIN_IN) || TBJ_PARAM_SongJiaoMode) //送胶没输出 到位没感应 原位有感应 滚轮送胶则不考虑前面条件
- && (TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&TBJ_GZ_LIMIT_IN))) //双钩针模式需要考虑钩针退回原位 拖带到位感应不亮 单钩针模式不考虑
- {
- if (TBJ_Motor_Step == 0) //反转完成
- {
- TBJ_Auto_Step = 5;
- TBJ_HMCS_Step = 1; //执行合模超声动作
- }
- }
- else if (dwTickCount >= TBJ_Auto_Delay&&!TBJ_HandWorking)
- {
- if (TBJ_FJ_LIMIT_IN)
- TBJ_SetAlarmCode(29); //E29 自动停止,分胶未退位或分胶前感应异常
- else if (!TBJ_FJ_ORIGIN_IN )
- TBJ_SetAlarmCode(30); //E30 自动停止,分胶未退位或分胶后感应异常
- else if (TBJ_SJ_LIMIT_IN && !TBJ_PARAM_SongJiaoMode)
- TBJ_SetAlarmCode(32); //E32 自动停止,送胶未退位或送胶前感应异常
- else if (!TBJ_SJ_ORIGIN_IN && !TBJ_PARAM_SongJiaoMode)
- TBJ_SetAlarmCode(33); //E33 自动停止,送胶未退位或送胶后感应异常
- else if(!(TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&TBJ_GZ_LIMIT_IN)))
- {
- TBJ_SetAlarmCode(QD_GZDaoWei_W); //E03 钩针未退位或 X20 钩针到位感应异常警告,无法启动
- }
- }
- break;
- case 5:
- if (TBJ_HMCS_Step == 0)
- {
- TBJ_Auto_Step = 6;
- TBJ_GZ_VAVLE = 0; //退钩针
- CalProSP(TBJ_SPEED_ADDR); //计算生产速度
- AddToTal(TBJ_TOTAL_ADDR); //产量增加
- }
- break;
- case 6:
- if (TBJ_Y_ORIGIN_IN && //上模已离开
- ((TBJ_PARAM_SGZSelect || ((TBJ_PARAM_SGZSelect == 0) &&!TBJ_GZ_LIMIT_IN)) //双钩针模式,钩针已回到原位,拖带到位感应不亮(该感应需要上钩针配合,不亮代表无钩针配合)
- || ((TBJ_PARAM_XiaMo_Mode == 0) && !TBJ_GZ_LIMIT_IN) //下模不动模式,钩针与上下模位置错开,不相互影响,不需要回到原位
- || ((TBJ_PARAM_XiaMo_Mode == 1) && TBJ_PARAM_SGZSelect))) //下模活动模式,单钩针模式,钩针与上下模位置错开
- {
- TBJ_Auto_Step = 7;
- TBJ_CQ_VAVLE = 1;
- TBJ_CQ_Delay = dwTickCount + 100;
- TBJ_Auto_Delay = dwTickCount + TBJ_PARAM_KAIMO_TD_DELAY + 20; //开模后延时拖带,45为下限时间
- }
- break;
- case 7:
- if (dwTickCount > TBJ_Auto_Delay)
- {
- if (GetTotal(TBJ_TOTAL_ADDR) >= TBJ_SET_TOTAL)
- {
- TBJ_SetAlarmCode(TBJ_TOTAL_ALARM);
- TBJ_Auto_Step = 0;
- TBJ_bRunning = 0;
- TBJ_bSingleOne=0;
- TBJ_HandWorking=0;
- }
- else if(TBJ_bSingleOne||TBJ_HandWorking)
- {
- TBJ_bSingleOne=0;
- TBJ_HandWorking=0;
- TBJ_Auto_Step = 0;
- TBJ_bRunning = 0;
- }
- else
- {
- TBJ_Auto_Step = 2;
- }
- TEST1++;
- if (TEST1 > 10)
- TEST1 = 10;
- }
- break;
- }
- }
- #endif
- }
- #endif
|