Guest User

Untitled

a guest
Jun 15th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.36 KB | None | 0 0
  1. ; ; FANUC
  2. ; -----
  3. ;
  4. @init_post
  5. global string tool_diameter_f
  6. global numeric flag1 flag2 m_feed_flag peck drilling dely colent f_drill tapping boring r_boring f_boring delay
  7.  
  8. ; Non GPPL variables
  9. num_user_procs = 1
  10. line_labels = FALSE ; Jump to N...
  11.  
  12. ; GPPL variables
  13. pre_processor = 'FANUC'
  14. numeric_def_f = '5.3'
  15. integer_def_f = '5.0(p)'
  16. gcode_f = '2.0(p)'
  17. mcode_f = '2.0(p)'
  18. xpos_f = '5.3'
  19. ypos_f = '5.3'
  20. zpos_f = '5.3'
  21. feed_f = '4.3(p)'
  22. tool_diameter_f = '5.3/1'
  23. blknum_f = '5.0(p)'
  24. blknum_gen = false
  25. blknum_exist = true
  26. blknum = 1
  27. blknum_delta = 1
  28. blknum_max = 32000
  29. ; trace 'all':5
  30. endp
  31.  
  32. ;-------------------
  33.  
  34. @start_of_file
  35. ; before tools definition
  36. {'%'}
  37. {nl, 'O'program_number, ' (', g_file_name, ')'}
  38. {nl, '( MCV-OP )', ' (',DATE ')'}
  39. if rotate_used then
  40. gcode = 69
  41. {nb, 'G'gcode}
  42. endif
  43. if mirror_used then
  44. {nb, 'G50.1 X0 Y0'}
  45. endif
  46. {nb, '(SUBROUTINES: O'first_proc_number, ' .. O'last_proc_number, ')'}
  47. flag2 = 0
  48. endp
  49.  
  50. ;-------------------
  51.  
  52. @start_program
  53. ; after tools definition
  54. {nb, 'G80 G49 G40'}
  55. ; call @home_number
  56. endp
  57.  
  58. ;-------------------
  59.  
  60. @end_program
  61. ; {nb, 'M98 P9010'}
  62. {nb, 'M30'}
  63. endp
  64.  
  65. ;-------------------
  66.  
  67. @end_of_file
  68. {nl, '%'}
  69. endp
  70.  
  71. ;-------------------
  72.  
  73. @relative_mode
  74. gcode = 91
  75. {nb, 'G'gcode, ' '}
  76. skipline = FALSE
  77. endp
  78.  
  79. ;-------------------
  80.  
  81. @absolute_mode
  82. gcode = 90
  83. {nb, 'G'gcode, ' '}
  84. skipline = FALSE
  85. endp
  86.  
  87. ;-------------------
  88.  
  89. @machine_plane
  90. if machine_plane eq XY
  91. gcode = 17
  92. endif
  93. if machine_plane eq YZ
  94. gcode = 18
  95. endif
  96. if machine_plane eq ZX
  97. gcode = 19
  98. endif
  99. {nb, 'G'gcode}
  100. endp
  101.  
  102. ;-------------------
  103.  
  104. @call_proc
  105. if active(parm1) then
  106. gcode = 65
  107. {nb, 'G'gcode, ' P'label}
  108. {' A'parm1, [' B'parm2], [' C'parm3]}
  109. else
  110. {nb, 'M98 P'label}
  111. endif
  112. if proc_count gt 1 then
  113. {' L'proc_count}
  114. endif
  115. {[' ('message, ')']}
  116. endp
  117.  
  118. ;-------------------
  119.  
  120. @proc
  121. {nl, 'O'label}
  122. endp
  123.  
  124. ;-------------------
  125.  
  126. @end_proc
  127. if dely eq 1
  128. {' G64 '}
  129. endif
  130. {nb, 'M99'}
  131. endp
  132.  
  133. ;----------------
  134.  
  135. @loop
  136. local integer var_num
  137.  
  138. var_num = loop_level + 20
  139. {nb, '#', var_num, ' = 0'}
  140. {nb, 'WHILE [#', var_num, ' LT ', loop_count, '] DO ', loop_level}
  141. endp
  142.  
  143. ;----------------
  144.  
  145. @end_loop
  146. local integer var_num
  147.  
  148. var_num = loop_level + 20
  149. {nb '#', var_num, ' = #', var_num, ' + 1'}
  150. {nb 'G'home_number}
  151. {nb 'END ', loop_level}
  152. endp
  153.  
  154. ;----------------
  155.  
  156. @def_tool
  157. ;;; {nb, '(G10 L12 P', (tool_number+50), ' R'tool_offset, ')'}
  158. endp
  159.  
  160. ;-------------------
  161.  
  162. @rapid_move
  163. {nb}
  164. gcode = 0
  165. if change(gcode) then
  166. {'G'gcode}
  167. else
  168. {' '}
  169. endif
  170. {[' X'xpos], [' Y'ypos], [' Z'zpos]}
  171. ; if flag1 eq 1
  172. ; {' S'spin:'5.0(p)',' M03'}
  173. ; {nb, 'M08'}
  174. ; endif
  175. ; flag1 = 0
  176. endp
  177.  
  178. ;-------------------
  179.  
  180. @line
  181. {nb}
  182. gcode = 1
  183. if change(gcode) then
  184. {'G'gcode}
  185. else
  186. {' '}
  187. endif
  188. {[' X'xpos], [' Y'ypos], [' Z'zpos]}
  189. if m_feed_flag eq 1
  190. m_feed_flag = 0
  191. { ' F'feed}
  192. else
  193. { [' F'feed]}
  194. endif
  195. endp
  196.  
  197. ;-------------------
  198.  
  199. @arc
  200. {nb}
  201.  
  202. if arc_direction eq CCW then
  203. gcode = 3
  204. else ; CW
  205. gcode = 2
  206. endif
  207. if change(gcode) then
  208. {'G'gcode}
  209. else
  210. {' '}
  211. endif
  212. {[' X'xpos] [' Y'ypos] [' Z'zpos]}
  213.  
  214. if arc_size eq 360 then
  215. if arc_plane eq XY then
  216. {' I'xcenter_rel, ' J'ycenter_rel}
  217. endif
  218. if arc_plane eq YZ then
  219. {' J'xcenter_rel, ' K'ycenter_rel}
  220. endif
  221. if arc_plane eq ZX then
  222. {' K'xcenter_rel, ' I'ycenter_rel}
  223. endif
  224. else
  225. if arc_size >= 180 then
  226. radius = -radius
  227. endif
  228. {' R'radius}
  229. endif
  230. if m_feed_flag eq 1
  231. m_feed_flag = 0
  232. { ' F'feed}
  233. else
  234. { [' F'feed]}
  235. endif
  236.  
  237. endp
  238.  
  239. ;-------------------
  240.  
  241. @compensation
  242. if side eq COMP_LEFT then
  243. gcode = 41
  244. endif
  245. if side eq COMP_RIGHT then
  246. gcode = 42
  247. endif
  248. if side eq COMP_OFF then
  249. gcode = 40
  250. endif
  251. {nb, 'G'gcode, ' '}
  252. skipline = FALSE
  253. endp
  254.  
  255. ;-------------------
  256.  
  257. @delay
  258. gcode = 4
  259. {nb 'G'gcode, ' P'delay_period:integer_def_f}
  260. endp
  261.  
  262. ;-------------------
  263.  
  264. @change_ref_point
  265. ; Given in absolute mode
  266. gcode = 10
  267. {nb, 'G'gcode, 'G91 L2 P'home_number ' X'xhome, ' Y'yhome, ' Z'zhome}
  268. {nb,'G90'}
  269. endp
  270.  
  271. ;-------------------
  272.  
  273. @home_number
  274. gcode = 53 + home_number
  275. {nb, 'G'gcode}
  276. flag2 = 1
  277. endp
  278.  
  279. ;-------------------
  280.  
  281. @rotate
  282. ; Not exist in FANUC 6M
  283. if rotate_cancel then
  284. gcode = 69
  285. {nb, 'G'gcode}
  286. else
  287. gcode = 68
  288. {nb, 'G'gcode, ' X0 Y0 G91 R'angle}
  289. {nb, 'G90'}
  290. endif
  291. endp
  292.  
  293. ;-------------------
  294.  
  295. @fourth_axis
  296. gcode = 0
  297. {nb, 'G'gcode, ' A'angle}
  298. endp
  299.  
  300. ;-------------------
  301.  
  302. @change_tool
  303. if flag2 eq 0
  304. call @home_number
  305. endif
  306. flag2 = 1
  307. local logical save_blknum_gen
  308.  
  309. ; {nb, 'M98 P9011'}
  310. {nb, 'G91 G28 Z0'}
  311. {nb, 'G90'}
  312.  
  313. ; if tool_number gt 20 and tool_number lt 40
  314. ; tool_number = (tool_number - 20)
  315. ; endif
  316. ; if tool_number gt 40 and tool_number lt 60
  317. ; tool_number = (tool_number - 40)
  318. ; endif
  319. ; if tool_number gt 60 and tool_number lt 80
  320. ; tool_number = (tool_number - 60)
  321. ; endif
  322.  
  323. {nb, 'M01'}
  324. blknum_gen = true
  325. {nb, 'M6 T'tool_number}
  326. blknum_gen = FALSE
  327. if tool_type eq 0 then
  328. {nb, '( TOOL -'tool_number, '- DRILL DIA 'tool_diameter, ' MM )'}
  329. endif
  330. if tool_type eq 1 then
  331. {nb, '( TOOL -'tool_number, '- ROUGH DIA 'tool_diameter, ' MM )'}
  332. endif
  333. if tool_type eq 2 then
  334. {nb, '(TOOL -'tool_number, '- MILL DIA 'tool_diameter, ' R'corner_radius,' MM )'}
  335. endif
  336. {nb, 'G90 G00 G40 G'(53 + home_number)}
  337. label = first_user_proc
  338. save_blknum_gen = blknum_gen
  339. gcode = 43
  340. {nb, 'G'gcode, ' H'tool_number, ' D'(tool_number+30), ' '}
  341. blknum_gen = save_blknum_gen
  342. xpos = xnext
  343. ypos = ynext
  344. zpos = znext
  345. skipline = FALSE
  346. call @rapid_move
  347. tool_direction = CCW
  348. call @start_tool
  349. if colent eq 0
  350. {nb, 'M8'}
  351. endif
  352. if colent eq 17
  353. {nb, 'M17'}
  354. endif
  355. if colent eq 18
  356. {nb, 'M18'}
  357. endif
  358.  
  359.  
  360. endp
  361.  
  362. ;-------------------
  363.  
  364. @message
  365. {nb, '(', message, ')'}
  366. endp
  367.  
  368. ;-------------------
  369.  
  370. @drill
  371. call @rapid_move
  372.  
  373. if drill_type eq drilling then
  374. gcode = 81
  375. endif
  376. if drill_type eq f_drill then
  377. gcode = 82
  378. endif
  379. if drill_type eq peck then
  380. gcode = 83
  381. endif
  382. if drill_type eq tapping then
  383. gcode = 84
  384. endif
  385. if drill_type eq boring then
  386. gcode = 85
  387. endif
  388. if drill_type eq r_boring then
  389. gcode = 86
  390. endif
  391. if drill_type eq f_boring then
  392. gcode = 89
  393. endif
  394. if drill_type eq tapping then
  395. {nb,'M29 S'spin:integer_def_f}
  396. endif
  397. {nb,'G98 G'gcode, ' Z'drill_lower_z, ' R'drill_upper_z}
  398. if drill_type eq peck then
  399. {' Q'down_step}
  400. endif
  401. if drill_type eq f_drill or drill_type eq tapping then
  402. {' P'delay:integer_def_f}
  403. endif
  404. {' F'feed}
  405.  
  406. endp
  407.  
  408. ;-------------------
  409.  
  410. @drill_point
  411. if not first_drill then
  412. {nb, ' ', [' X'xpos], [' Y'ypos], [' Z'zpos]}
  413. endif
  414. endp
  415.  
  416. ;-------------------
  417.  
  418. @mirror
  419. if mirror_type eq MIRROR_OFF then
  420. {nb, 'G50.1 X0 Y0'}
  421. else
  422. {nb, 'G51.1 '}
  423. if mirror_type eq MIRROR_X then
  424. {'X1 Y0'}
  425. endif
  426. if mirror_type eq MIRROR_Y then
  427. {'X0 Y1'}
  428. endif
  429. if mirror_type eq MIRROR_XY then
  430. {'X1 Y1'}
  431. endif
  432. endif
  433. endp
  434.  
  435. ;-------------------
  436.  
  437. @end_drill
  438. gcode = 80
  439. {nb, 'G'gcode}
  440. endp
  441.  
  442. ;-------------------
  443.  
  444. @halt_program
  445. {' M0'}
  446. endp
  447.  
  448. ;--------------------
  449.  
  450. @round_comp
  451. ; NOP
  452. endp
  453.  
  454. ;--------------------
  455.  
  456. @start_of_job
  457.  
  458. if dely eq 1
  459. {nb, 'G61'}
  460. endif
  461. ; flag1 = 1
  462. endp
  463.  
  464. ;--------------------
  465.  
  466. @end_of_job
  467. ; NOP
  468. endp
  469.  
  470. ;--------------------
  471.  
  472. @assign_axis
  473. ; TBD
  474. endp
  475.  
  476. ; =======================
  477. ; USER DEFINED PROCEDURES
  478. ; =======================
  479.  
  480. @call_simple_proc
  481. active(message) = FALSE
  482. active(parm1) = FALSE
  483. active(parm2) = FALSE
  484. active(parm3) = FALSE
  485. proc_count = 1
  486. call @call_proc
  487. endp
  488.  
  489. ;-------------------
  490.  
  491. @start_tool
  492. if tool_direction eq CW then
  493. mcode = 4
  494. else ; CCW
  495. mcode = 3
  496. endif
  497. {' S'spin:integer_def_f, ' M'mcode}
  498. endp
  499.  
  500.  
  501. ;-------------------
  502.  
  503. @m_feed_spin
  504. ; if tool_direction eq CW then
  505. ; mcode = 4
  506. ; else ; CCW
  507. ; mcode = 3
  508. ; endif
  509. ; if change(spin)
  510. ; {nb,'S'spin:integer_def_f, ' M'mcode}
  511. ; endif
  512. m_feed_flag = 1
  513. endp
  514.  
  515. ;-------------------
  516.  
  517. @stop_tool
  518. ; {' M5'}
  519. endp
Advertisement
Add Comment
Please, Sign In to add comment