XDTieBuJi.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  1. #include "global.h"
  2. #if XI_DONG_MACHINE
  3. //输入说明
  4. //输入说明
  5. //X000 起动
  6. //X001 停止
  7. //X002 手动钩针
  8. //X003 手动前导板
  9. //X004 手动夹胶
  10. //X005 手动送胶
  11. //X006 手动熔胶
  12. //X007 自动位
  13. //X010 单-自动
  14. //X011 过链接近开关
  15. //X012 勾针磁感
  16. //X013 前导板磁感
  17. //X014 送胶到位磁感
  18. //X015 退胶到位磁感(熔接磁感)
  19. //X016 复位微动
  20. //X017 机型选择(就是送胶、前导板)
  21. //X020 合模到位微动
  22. //X021 音波自动
  23. //X022 熔接时勾针关选择 1 先下勾针熔接,0 熔接时不下勾针
  24. //X023 内部时间选择,0 拔码,1 内部时间
  25. //输出说明
  26. //NEW 2006/03/22
  27. //输出说明
  28. //Y000 离合器
  29. //Y001 勾针阀
  30. //Y002 导板阀
  31. //Y003 夹胶阀
  32. //Y004 送胶阀
  33. //Y005 熔接(合模)
  34. //Y006 计数
  35. //Y007 拖带电机
  36. //Y010    释放
  37. //Y011 警告输出
  38. //Y012 压带输出
  39. //Y020 音波
  40. //Y021 音波
  41. //X00 起动
  42. #define __sw_start() (X00)
  43. #define __sw_start_on() (X00_UP)
  44. //X01 停止
  45. #define __sw_stop() (X01)
  46. #define __sw_stop_on() (X01_UP)
  47. //X02 手动钩针
  48. #define __sw_gou_zhen_on() (X02_UP)
  49. #define __sw_gou_zhen_off() (X02_DW)
  50. //X03 手动前导板
  51. #define __sw_dao_ban() (X03 != 0)
  52. #define __sw_dao_ban_on() (X03_UP)
  53. #define __sw_dao_ban_off() (X03_DW)
  54. //X04 手动夹胶
  55. #define __sw_jia_jiao() (X04 != 0) /* 手动夹胶状态*/
  56. #define __sw_jia_jiao_on() (X04_UP)
  57. #define __sw_jia_jiao_off() (X04_DW)
  58. //X05 手动送胶
  59. #define __sw_song_jiao() (X05)
  60. #define __sw_song_jiao_on() (X05_UP)
  61. #define __sw_song_jiao_off() (X05_DW)
  62. //X06 手动熔胶
  63. #define __sw_rong_jiao() (X06 != 0)
  64. #define __sw_rong_jiao_on() (X06_UP)
  65. #define __sw_rong_jiao_off() (X06_DW)
  66. //X07 自动位
  67. #define __sw_manual() (X07 != 0) /* 开关为手动状态*/
  68. #define __sw_manual_on() (X07_UP) /* 开关改为手动瞬间*/
  69. //X10 单-自动
  70. #define __x_dan_zi_dong() (X10 != 0)
  71. //X11 过链接近开关
  72. #define __x_guo_lian() (X11 != 0)
  73. #define __x_guo_lian_on() (X11_UP)
  74. #define __x_guo_lian_off() (X11_DW)
  75. //X12 勾针磁感
  76. #define __x_gou_zhen() (X12 != 0)
  77. //X13 前导板磁感
  78. #define __x_dao_ban() (X13 != 0)
  79. //X14 送胶到位磁感
  80. #define __x_song_jiao_dao_wei() (X14 != 0)
  81. //X15 退胶到位磁感(熔接磁感)
  82. #define __x_tui_jiao_dao_wei() (X15 != 0)
  83. //X16 复位微动
  84. #define __x_reset() (X16 != 0)
  85. #define __x_reset_on() (X16_UP)
  86. //X17 机型选择(就是送胶、前导板)
  87. //X20 合模到位微动
  88. #define __x_he_mo_dao_wei() (X20 != 0)
  89. #define __x_he_mo_dao_wei_on() (X20_UP)
  90. //X21 音波自动
  91. #define __sw_auto_yin_bo() (X21 == 0)
  92. //输出说明
  93. //NEW 2006/03/22
  94. //输出说明
  95. //Y000 离合器
  96. #define __y_li_he() (Y000 != 0)
  97. #define __y_li_he_on() (SETY000())
  98. #define __y_li_he_off() (CLRY000())
  99. //Y001 勾针阀
  100. #define __y_gou_zhen() (Y001 != 0)
  101. #define __y_gou_zhen_on() (SETY001())
  102. #define __y_gou_zhen_off() (CLRY001())
  103. //Y002 导板阀
  104. #define __y_dao_ban() (Y002 != 0)
  105. #define __y_dao_ban_on() (SETY002())
  106. #define __y_dao_ban_off() (CLRY002())
  107. //Y003 夹胶阀
  108. #define __y_jia_jiao() (Y003 != 0)
  109. #define __y_jia_jiao_on() (SETY003())
  110. #define __y_jia_jiao_off() (CLRY003())
  111. //Y004 送胶阀
  112. #define __y_song_jiao() (Y004 != 0)
  113. #define __y_song_jiao_on() (SETY004())
  114. #define __y_song_jiao_off() (CLRY004())
  115. //Y005 熔接(合模)
  116. #define __y_he_mo() (Y005 != 0)
  117. #define __y_he_mo_on() (SETY005())
  118. #define __y_he_mo_off() (CLRY005())
  119. //Y006 计数
  120. #define __y_ji_shu_on() (SETY006())
  121. #define __y_ji_shu_off() (CLRY006())
  122. //Y012
  123. #define __y_Ya_Dai() (Y012 != 0)
  124. #define __y_Ya_Dai_on() (SETY012())
  125. #define __y_Ya_Dai_off() (CLRY012())
  126. //Y007 拖带电机
  127. //Y008   
  128. #define __yin_bo_on() (SETY015())
  129. #define __yin_bo_off() (CLRY015())
  130. char TBJ_GcDanYiXunHuanFlag;
  131. unsigned char TBJ_cSpeaker_EN,TBJ_cGuZhang_Flag;
  132. unsigned short TBJ_cWordTime[3],TBJ_cCountOutTime;
  133. unsigned long TBJ_cErrorTime1,TBJ_cErrorTime;
  134. void TBJ_Motor (void);
  135. void TBJ_InitAction(void)
  136. {
  137. XGearRatio = 1;
  138. YGearRatio = 1;
  139. }
  140. static void TBJ_ManualAction (void)
  141. {
  142. if(M11) //累计产量清零
  143. {
  144. M11 = 0;
  145. ClrcToTal(76);
  146. }
  147. if(M8)
  148. {
  149. M8 = 0;
  150. if(__y_Ya_Dai())
  151. {
  152. __y_Ya_Dai_off();
  153. }
  154. else
  155. __y_Ya_Dai_on();
  156. }
  157. if(X07_UP)
  158. { //自动变手动
  159. Y00 = 0;
  160. Y01 = 0;
  161. Y02 = 0;
  162. Y03 = 0;
  163. Y04 = 0;
  164. Y05 = 0;
  165. Y07 = 0;
  166. Y10 = 0;
  167. Y11 = 0;
  168. Y13 = 0;
  169. Y14 = 0;
  170. Y15 = 0;
  171. cStepMByte = 0;
  172. cStepMByte1 = 0;
  173. cStepMByte2 = 0;
  174. cStepMByte3 = 0;
  175. cStepMByte4 = 0;
  176. cStepMByte5 = 0;
  177. cStepMByte6 = 0;
  178. TBJ_bRunning = 0;
  179. AxisEgmStop(X_AXIS);
  180. SETY010();
  181. }
  182. if(__sw_gou_zhen_on() || M2) //勾针动作
  183. {
  184. M2 = 0;
  185. if(__y_gou_zhen())
  186. {
  187. __y_gou_zhen_off();
  188. }
  189. else if((user_datas[4] != 2) || (!__y_song_jiao()))
  190. __y_gou_zhen_on(); /* 钩针阀on*/
  191. }
  192. else if(__sw_gou_zhen_off())
  193. __y_gou_zhen_off(); /* 钩针阀off*/
  194. if (__sw_dao_ban_on() || M3)
  195. { /* 手动前导板开关ON*/
  196. M3 = 0;
  197. if(__y_dao_ban())__y_dao_ban_off();
  198. /* 未合模 复位 合模未到位 手动熔接*/
  199. else if (!__y_he_mo() && __x_reset() && !__x_he_mo_dao_wei() && !__sw_rong_jiao())
  200. {
  201. __y_dao_ban_on(); /* 导板阀 */
  202. }
  203. else //警告处理
  204. {
  205. M15 = 0; //M15
  206. M0091 = 1; //M91 不用记录
  207. SETY011(); //蜂鸣器
  208. if(Y005 != 0)user_datas[100] = ERY05; //Y005 无输出
  209. else if(X006 != 0)user_datas[100] = ERX06; //X006 有输入
  210. else if(X016 == 0)user_datas[100] = ERX16; //X016 有输入
  211. else if(X020 != 0)user_datas[100] = ERX20; //X020 有输入
  212. }
  213. }
  214. /* 手动前导板 机型选择(就是送胶、前导板)*/
  215. if ((__sw_dao_ban_off()) || (X017))__y_dao_ban_off();
  216. //手动夹胶
  217. if (__sw_jia_jiao() || M4)
  218. {
  219. M4 = 0;
  220. if(__y_jia_jiao())
  221. __y_jia_jiao_off();
  222. else
  223. __y_jia_jiao_on(); /* 夹胶阀ON*/
  224. }
  225. //手动送胶
  226. if (__sw_song_jiao_on() || M5)
  227. {
  228. M5 = 0;
  229. if(__y_song_jiao()) //关送胶
  230. {
  231. __y_song_jiao_off();
  232. }
  233. /* 未合模 复位 合模未到位 手动熔接*/
  234. // Y005 X016 != 0
  235. else if (!__y_he_mo() && __x_reset() && !__x_he_mo_dao_wei() && !__sw_rong_jiao() &&
  236. ((!__y_gou_zhen() && __x_gou_zhen()) || (user_datas[4] != 2)))
  237. {
  238. __y_song_jiao_on(); /* 送胶伐ON*/
  239. }
  240. else //条件不满足处理
  241. {
  242. M15 = 0; //M15
  243. M0091 = 1; //M91 不用记录
  244. SETY011(); //蜂鸣器
  245. if(Y005 != 0)user_datas[100] = ERY05; //Y005 无输出
  246. else if(X006 != 0)user_datas[100] = ERX06; //X006 有输入
  247. else if(X016 == 0)user_datas[100] = ERX16; //X016 有输入
  248. else if(X020 != 0)user_datas[100] = ERX20; //X020 有输入
  249. else if(__y_gou_zhen())user_datas[100] = ERY01; //Y001 有输出
  250. else if(!__x_gou_zhen())user_datas[100] = ERX12; //X012 有输入
  251. }
  252. }
  253. /* 手动前导板 机型选择(就是送胶、前导板)*/
  254. if (__sw_song_jiao_off() || (X017))
  255. __y_song_jiao_off();
  256. //手动熔胶 导板阀 送胶阀 离合器 退胶到位磁感(熔接磁感)
  257. if (X06_UP || M6)
  258. {
  259. M6 = 0;
  260. if(__y_he_mo())
  261. {
  262. cStepMByte3 = 0;
  263. __yin_bo_off(); //音波关
  264. __y_he_mo_off(); //退合模
  265. }
  266. else if (!__y_dao_ban() && !__y_song_jiao() &&
  267. (cStepMByte3 == 0) && !__y_li_he() &&
  268. __x_tui_jiao_dao_wei() &&
  269. !__x_dao_ban() && (!__x_gou_zhen() || (user_datas[4] == 2)))
  270. { /* 前导板磁感 勾针磁感*/
  271. cStepMByte3 = 1; //合模熔接开始
  272. /* 合模熔接*/
  273. TBJ_cWordTime[0] = user_datas[6]; //延时发超声时间
  274. TBJ_cWordTime[1] = user_datas[7]; //发超声时间
  275. TBJ_cWordTime[2] = user_datas[8]; //固化时间
  276. }
  277. else //不满足条件警告处理
  278. {
  279. M15 = 0; //M15
  280. M0091 = 1; //M91不用记录
  281. SETY011(); //蜂鸣器
  282. if(Y005 != 0)user_datas[100] = ERY05; //Y05 前导板电磁阀
  283. else if(Y004 != 0)user_datas[100] = ERY04; //X006 有输入
  284. else if(Y000 != 0)user_datas[100] = ERY00; //X016 有输入
  285. else if(X015 == 0)user_datas[100] = ERX15; //X020 有输入
  286. else if(X013 != 0)user_datas[100] = ERX13; //X020 有输入
  287. else if(X012 != 0)user_datas[100] = ERX12; //X020 有输入
  288. }
  289. }
  290. }
  291. /*********************************************************************************************************
  292. ** Function name: func_name
  293. ** Descriptions: 自动运行
  294. ** input parameters: input
  295. ** output parameters: NONE
  296. ** Returned value: NONE
  297. ** Created by: Huanghui
  298. ** Created Date: 2012-6-18
  299. **--------------------------------------------------------------------------------------------------------
  300. ** Modified by:
  301. ** Modified date:
  302. **--------------------------------------------------------------------------------------------------------
  303. *********************************************************************************************************/
  304. static void TBJ_AutoAciton (void)
  305. {
  306. TBJ_Motor();
  307. switch (cStepMByte)
  308. { //电机、离合器、导板阀、夹胶阀起动
  309. case 1:
  310. if (__x_gou_zhen() && __x_reset())
  311. {
  312. cStepMByte = 2;
  313. cStepMByte2 = 1;
  314. SETY003();//夹胶输出
  315. cDelayTime1 = dwTickCount + (unsigned long)50; //延时输出前导板 /* 夹胶阀*/
  316. }
  317. break;
  318. case 2:
  319. if((dwTickCount >= cDelayTime1) && (Y002 == 0)) /* 延时输出导板*/
  320. {
  321. if ((X003 == 0) && (X017 == 0))
  322. {
  323. SETY002();//前导板输出__y_dao_ban_on();
  324. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  325. }
  326. else
  327. __y_dao_ban_off();
  328. }
  329. //前导板出错
  330. if((dwTickCount >= TBJ_cErrorTime1) && Y002 && (X013 == 0))
  331. {
  332. M0081 = 1; //M81 记录
  333. user_datas[100] = 2; //检查过链接近开关或没有拉链
  334. M15 = 0; //M15
  335. user_datas[101] = 0;
  336. }
  337. // 勾针己输出 并且在链上 拖带完成
  338. if (((X012 == 0) && X011) || (cStepMByte2 == 0) || (user_datas[4] == 1)) //送胶起动
  339. {
  340. if(user_datas[4] == 2)
  341. {
  342. if((cStepMByte2 == 0)) //压带已经有输出
  343. {
  344. if(dwTickCount >= cDelayTime1) __y_gou_zhen_off(); //下勾针
  345. if(__x_gou_zhen()) //勾针下到位
  346. {
  347. //前导板到位 前导板输出
  348. if ((X013 != 0))
  349. {
  350. cStepMByte = 3;
  351. if((X005 == 0) && (X017 == 0)) /* 送胶阀*/
  352. {
  353. SETY004();
  354. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  355. }
  356. else
  357. CLRY004();
  358. }
  359. }
  360. }
  361. else
  362. cDelayTime1 = dwTickCount + (unsigned long)50;
  363. }
  364. else
  365. {
  366. //前导板到位 前导板输出
  367. if ((X013 != 0) || ((Y002 == 0) && (user_datas[4] == 0)))
  368. {
  369. cStepMByte = 3;
  370. if((X005 == 0) && (X017 == 0)) /* 送胶阀*/
  371. {
  372. SETY004();
  373. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  374. }
  375. else
  376. CLRY004();
  377. }
  378. }
  379. }
  380. break;
  381. //送胶到位
  382. case 3: //送胶到位磁感
  383. if (X014 || (Y004 == 0))
  384. {
  385. cStepMByte = 4;
  386. cDelayTime1 = dwTickCount + (unsigned long)20;
  387. }
  388. else if(dwTickCount >= TBJ_cErrorTime1) //送胶到位出错
  389. {
  390. M0082 = 1; //M82 记录
  391. user_datas[100] = 3; //检查过链接近开关或没有拉链
  392. M15 = 0; //M15
  393. user_datas[101] = 0;
  394. }
  395. break;
  396. //导板、夹胶关闭
  397. case 4:
  398. if(Y003 && dwTickCount >= cDelayTime1)
  399. {
  400. CLRY003(); //夹胶阀关
  401. cDelayTime1 = dwTickCount + (unsigned long)10 * user_datas[9];
  402. }
  403. //勾针起 拖带到位 勾针磁感
  404. if ((cStepMByte2 == 0) && !Y003 && (((Y001 != 0) && (X012 == 0)) || (user_datas[4] == 2)))
  405. {
  406. cStepMByte = 5;
  407. CLRY002(); //前导板关
  408. CLRY003(); //夹胶阀关
  409. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  410. }
  411. break;
  412. //退送胶
  413. case 5:
  414. //送胶停止
  415. if((X013 == 0) && (dwTickCount>= cDelayTime1))
  416. {
  417. cStepMByte = 6;
  418. CLRY004();/* 送胶关 M19*/
  419. cStepMByte2 = 6; //拖带反转
  420. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  421. }
  422. else if((dwTickCount >= TBJ_cErrorTime1)) //退导板出错
  423. {
  424. M0081 = 1; //M81 记录
  425. user_datas[100] = 2; //检查过链接近开关或没有拉链
  426. M15 = 0; //M15
  427. user_datas[101] = 0;
  428. }
  429. break;
  430. case 6: //退胶到位
  431. if((cStepMByte2 == 0) && (Y004 == 0) && X015)
  432. {
  433. cStepMByte = 7;
  434. }
  435. else if((dwTickCount >= TBJ_cErrorTime1)) //退送胶出错
  436. {
  437. M0083 = 1; //M83 记录
  438. user_datas[100] = 4; //检查过链接近开关或没有拉链
  439. M15 = 0; //M15
  440. user_datas[101] = 0;
  441. }
  442. break;
  443. //在自动状态
  444. case 7: // 单一自动   自动启动 熔接
  445. if(__x_dan_zi_dong() || (TBJ_GcDanYiXunHuanFlag == 0) || M6)
  446. {
  447. M6 = 0;
  448. if(!__sw_rong_jiao() && !__y_dao_ban() && !__y_song_jiao() && __x_tui_jiao_dao_wei() && !__x_dao_ban() &&
  449. ((__y_gou_zhen() && !__x_gou_zhen()) || (user_datas[4] == 2)) && __x_guo_lian())
  450. {
  451. cStepMByte = 8; //等待合模熔接完成
  452. cStepMByte3 = 1; //合模熔接开始
  453. TBJ_cWordTime[0] = user_datas[6]; //延时发超声时间
  454. TBJ_cWordTime[1] = user_datas[7]; //发超声时间
  455. TBJ_cWordTime[2] = user_datas[8]; //固化时间
  456. }
  457. }
  458. break;
  459. case 8:
  460. if(cStepMByte3 == 0) //合模熔接已经完成
  461. {
  462. cStepMByte = 9;
  463. CLRY001(); //退勾针
  464. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  465. }
  466. break;
  467. case 9: //复位到位
  468. if (X016)
  469. {
  470. cStepMByte = 10;
  471. cDelayTime1 = dwTickCount + (unsigned long) 30;
  472. }
  473. else if((dwTickCount >= TBJ_cErrorTime1)) //复位微动异常
  474. {
  475. M0084 = 1; //M84 记录
  476. user_datas[100] = 5;
  477. M15 = 0; //M15
  478. user_datas[101] = 0;
  479. }
  480. break;
  481. case 10:
  482. if ((X016 != 0) && (dwTickCount >= cDelayTime1))
  483. {
  484. cStepMByte = 11;
  485. cDelayTime1 = dwTickCount + (unsigned long) 60;
  486. TBJ_cCountOutTime = 5; //计数
  487. SETY006();
  488. CLRY010(); //锁轴
  489. }
  490. else if (X016 == 0)
  491. {
  492. cStepMByte = 9;
  493. TBJ_cErrorTime1 = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  494. }
  495. break;
  496. case 11:
  497. if (dwTickCount >= cDelayTime1)
  498. { // 单一循环
  499. if(TBJ_GcDanYiXunHuanFlag)
  500. {
  501. cStepMByte = 0;
  502. TBJ_bRunning = 0;
  503. }
  504. else
  505. cStepMByte = 1;
  506. AddToTal(76); //生产总量加1保存
  507. CalProSP(78); //计算生产速度
  508. }
  509. break;
  510. }
  511. /* if (!__sw_dao_ban() && M17 && (X017 == 0))
  512. __y_dao_ban_on();
  513. else
  514. __y_dao_ban_off();
  515. if (!__sw_jia_jiao() && M18 && (X017 == 0))
  516. __y_jia_jiao_on();
  517. else
  518. __y_jia_jiao_off();
  519. if (!__sw_song_jiao() && M19 && (X017 == 0))
  520. __y_song_jiao_on();
  521. else
  522. __y_song_jiao_off();
  523. */
  524. }
  525. // 检测是否踏了脚踏开关
  526. void TBJ_CheckStart (void)
  527. {
  528. static unsigned long TBJ_iKaDaiTime;
  529. /* 启动ON 自动启动 单一自动  */
  530. if ((__sw_start_on() || M0 || M7) && (TBJ_bRunning == 0))
  531. { // 勾针磁感 复位磁感 停止OFF 自动
  532. if(__x_gou_zhen() && __x_reset() && !__sw_stop() && !__sw_manual())
  533. {//自动启动
  534. TBJ_bRunning = 1; // 取反运行标志位
  535. cStepMByte = 1;
  536. TBJ_GcDanYiXunHuanFlag = 0;
  537. if(M7)TBJ_GcDanYiXunHuanFlag = 1;
  538. middle_coils[10].value = 0; //记录
  539. middle_coils[11].value = 0; //记录
  540. user_datas[100] = 0;
  541. M15 = 0;
  542. user_datas[101] = 0;
  543. TBJ_cSpeaker_EN = 0;
  544. }
  545. else //警告输出
  546. {
  547. M15 = 0; //M15
  548. M0091 = 1; //M91不用记录
  549. SETY011(); //蜂鸣器
  550. if(X007 != 0)user_datas[100] = ERX07; //X007 有输入
  551. else if(X001 != 0)user_datas[100] = ERX01; //X001 有输入
  552. else if(X016 == 0)user_datas[100] = ERX16; //X016 没输入
  553. else if(X012 == 0)user_datas[100] = ERX12; //没输入
  554. }
  555. M0 = 0;
  556. M7 = 0;
  557. }
  558. //停止
  559. if ((X01_UP || TBJ_bStop || M1) )
  560. {
  561. if(TBJ_bRunning && (X001 != 0))TBJ_cGuZhang_Flag = 1;
  562. TBJ_iKaDaiTime = dwTickCount + 1000;
  563. M1 = 0;
  564. TBJ_bStop = 0;
  565. Y00 = 0;
  566. Y01 = 0;
  567. Y02 = 0;
  568. Y03 = 0;
  569. Y04 = 0;
  570. Y05 = 0;
  571. Y07 = 0;
  572. Y10 = 0;
  573. Y11 = 0;
  574. Y12 = 0;
  575. Y13 = 0;
  576. Y14 = 0;
  577. Y15 = 0;
  578. cStepMByte = 0;
  579. cStepMByte1 = 0;
  580. cStepMByte2 = 0;
  581. cStepMByte3 = 0;
  582. cStepMByte4 = 0;
  583. cStepMByte5 = 0;
  584. cStepMByte6 = 0;
  585. TBJ_bRunning = 0;
  586. AxisEgmStop(X_AXIS);
  587. SETDR();
  588. SETY010();
  589. CLRY011();
  590. TBJ_cSpeaker_EN = 1;
  591. }
  592. if((X001 != 0) && (dwTickCount >= TBJ_iKaDaiTime) && TBJ_cGuZhang_Flag)
  593. {
  594. TBJ_cGuZhang_Flag = 0;
  595. M0086 = 1;
  596. user_datas[100] = 7;
  597. TBJ_cSpeaker_EN = 0;
  598. SETY011();
  599. }
  600. //警告退出
  601. if(M15)
  602. {
  603. middle_coils[10].value = 0;
  604. middle_coils[11].value = 0;
  605. user_datas[100] = 0; /* 压带出错,没法压到位*/
  606. M15 = 0;
  607. }
  608. }
  609. //贴布sm 电机控制
  610. void TBJ_Motor (void)
  611. {
  612. switch(cStepMByte2)
  613. {
  614. case 1: //离合器起动
  615. cStepMByte2 = 2;
  616. __y_li_he_on(); //离合启动 Y000
  617. if (user_datas[90] == 55)cDelayTime3 = dwTickCount + (unsigned long) 300;
  618. CLRDR();
  619. SETY007();
  620. CLRY010();
  621. MoveAction_Const_AccDec(X_AXIS,TBJ_DIR_P,user_datas[3],user_datas[2],user_datas[1],1);
  622. __y_Ya_Dai_off(); //压带关
  623. break;
  624. case 2: //过链接近下降沿
  625. if ((__x_guo_lian_off()) || ((user_datas[90] == 55) && (dwTickCount >= cDelayTime3)))
  626. {
  627. cStepMByte2 = 3;
  628. cDelayTime3 = dwTickCount + (unsigned long)user_datas[10]; //延时上勾针
  629. TBJ_cErrorTime = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  630. AxisChangeSpeed(X_AXIS,user_datas[2]);
  631. }
  632. break;
  633. case 3: //要加延时上勾针
  634. if(dwTickCount >= cDelayTime3)__y_gou_zhen_on(); /* 上勾针*/
  635. //过链接近上升沿 //拖带到
  636. if ((__x_guo_lian_on() || (user_datas[90] == 55)) && (dwTickCount >= cDelayTime3))
  637. {
  638. cStepMByte2 = 4;
  639. cDelayTime3 = dwTickCount + (unsigned long)user_datas[0];
  640. __y_gou_zhen_on(); /* 上勾针*/
  641. }
  642. else if (dwTickCount >= TBJ_cErrorTime)
  643. { //拖带警告
  644. M0087 = 1; //M87 记录
  645. user_datas[100] = 8; //检查过链接近开关或没有拉链
  646. M15 = 0; //M15
  647. user_datas[101] = 0;
  648. TBJ_bStop = 1;
  649. }
  650. break;
  651. case 4:
  652. if(dwTickCount >= cDelayTime3)
  653. {
  654. cStepMByte2 = 5;
  655. __y_li_he_off(); //关离合
  656. AxisEgmStop(X_AXIS);
  657. TBJ_cErrorTime = dwTickCount + (unsigned long) TBJ_ERRORTIME;
  658. if(user_datas[4])cDelayTime3 = dwTickCount + (unsigned long)40;
  659. }
  660. break;
  661. case 5: //勾针上到
  662. if (!__x_gou_zhen() && (dwTickCount >= cDelayTime3))
  663. {
  664. cStepMByte2 = 0; //拖带反转
  665. SETDR();
  666. __y_Ya_Dai_on(); //压带开
  667. }
  668. else if (dwTickCount >= TBJ_cErrorTime) //压带警告
  669. {
  670. M0080 = 1; //记录
  671. user_datas[100] = 1; //压带出错,没法压到位
  672. M15 = 0; //M15
  673. user_datas[101] = 0;
  674. }
  675. break;
  676. case 6:
  677. AxisMovePosAccDec(X_AXIS, 5,80,1,1,1);
  678. cStepMByte2 = 7; //等拖带完成
  679. break;
  680. case 7:
  681. if(!X_DRV)
  682. {
  683. cStepMByte2 = 0; //拖带完成
  684. SETY010(); //释放电机
  685. }
  686. break;
  687. }
  688. }
  689. //合模超声动作
  690. void TBJ_HeMo (void)
  691. {
  692. switch (cStepMByte3)
  693. {
  694. case 1:
  695. cDelayTime4 = dwTickCount + (unsigned long)TBJ_ERRORTIME; //延时时间
  696. if(X022)
  697. {
  698. __y_gou_zhen_off();
  699. if(__x_gou_zhen())
  700. {
  701. __y_he_mo_on(); //合模
  702. cStepMByte3 = 2;
  703. }
  704. }
  705. else
  706. {
  707. __y_he_mo_on(); //合模
  708. cStepMByte3 = 2;
  709. }
  710. break;
  711. case 2:
  712. if(__x_he_mo_dao_wei_on())
  713. { /* 合模到位瞬间*/
  714. cStepMByte3 = 3;
  715. cDelayTime4 = dwTickCount + (unsigned long) TBJ_cWordTime[0] * 10; //延时时间
  716. }
  717. else if((dwTickCount >= cDelayTime4) && TBJ_bRunning) //合模到位微动异常
  718. {
  719. M0085 = 1; //M85记录
  720. user_datas[100] = 6; //合模出错
  721. M15 = 0; //M15
  722. user_datas[101] = 0;
  723. }
  724. break;//延时发振
  725. case 3:
  726. if(dwTickCount >= cDelayTime4)
  727. {
  728. cStepMByte3 = 4;
  729. cDelayTime4 = dwTickCount + (unsigned long) TBJ_cWordTime[1] * 10; //熔接时间
  730. if(user_datas[5] != 0) //通信方式下音波开选择
  731. __yin_bo_on(); //音波开
  732. }
  733. break;
  734. case 4:
  735. if (dwTickCount >= cDelayTime4)
  736. {
  737. cStepMByte3 = 5;
  738. cDelayTime4 = dwTickCount + (unsigned long) TBJ_cWordTime[2] * 10; //熔接时间
  739. __yin_bo_off(); //音波关
  740. }
  741. break;
  742. case 5:
  743. if(dwTickCount >= cDelayTime4)
  744. {
  745. cStepMByte3 = 0;
  746. __y_he_mo_off();
  747. __y_Ya_Dai_off();
  748. }
  749. break;
  750. }
  751. }
  752. /*********************************************************************************************************
  753. ** Function name: func_name
  754. ** Descriptions: descriptions
  755. ** input parameters: input
  756. ** output parameters: NONE
  757. ** Returned value: NONE
  758. ** Created by: Huanghui
  759. ** Created Date: 2012-6-18
  760. **--------------------------------------------------------------------------------------------------------
  761. ** Modified by:
  762. ** Modified date:
  763. **--------------------------------------------------------------------------------------------------------
  764. *********************************************************************************************************/
  765. void TBJ_Action (void)
  766. {
  767. static unsigned long c10msDelay = 0;
  768. TBJ_CheckStart(); // 调用脚踏开关检测程序
  769. if(dwTickCount >= c10msDelay)
  770. {
  771. c10msDelay = dwTickCount+10;
  772. if (TBJ_cCountOutTime > 0)
  773. {
  774. TBJ_cCountOutTime--;
  775. if (TBJ_cCountOutTime == 0)
  776. CLRY006();
  777. }
  778. if(user_datas[100] == 0)
  779. {
  780. CLRY011();
  781. }
  782. else //显示故障代码
  783. {
  784. SETY011();
  785. }
  786. }
  787. TBJ_HeMo (); //合模熔接动作
  788. // 没有按下急停按钮
  789. //手动状态下
  790. if(TBJ_bRunning && !__sw_stop())
  791. {
  792. TBJ_AutoAciton(); /* 自动运行*/
  793. }
  794. else if(__sw_stop_on() || M1)
  795. {
  796. Y00 = 0;
  797. Y01 = 0;
  798. Y02 = 0;
  799. Y03 = 0;
  800. Y04 = 0;
  801. Y05 = 0;
  802. Y07 = 0;
  803. Y12 = 0;
  804. Y13 = 0;
  805. Y14 = 0;
  806. Y15 = 0;
  807. cStepMByte = 0;
  808. cStepMByte1 = 0;
  809. cStepMByte2 = 0;
  810. cStepMByte3 = 0;
  811. cStepMByte4 = 0;
  812. cStepMByte5 = 0;
  813. cStepMByte6 = 0;
  814. TBJ_bRunning = 0;
  815. AxisEgmStop(X_AXIS);
  816. SETY010();
  817. }
  818. else if(TBJ_bRunning == 0)
  819. {
  820. TBJ_ManualAction(); /* 手动运行*/
  821. }
  822. }
  823. #endif