Advertisement
Guest User

Example of slot milling func

a guest
Aug 21st, 2012
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. (120mm wooden faceplate for 4th axis)
  2.  
  3.  
  4.  
  5. o103 sub
  6. (bores hole clockwise)
  7. (parameters)
  8. (#1 = X position)
  9. (#2 = Y position)
  10. (#3 = bore diameter)
  11. (#4 = start depth)
  12. (#5 = end depth)
  13. (#6 = depth per turn)
  14.  
  15. (globals used)
  16. (#33 = tool diameter)
  17. (#35 = safety height)
  18.  
  19. #10 = [[#3-#33]/2] (effective radius = bore radius - tool radius)
  20.  
  21. g17 (set XY plane for arcs)
  22.  
  23. g0 z#33
  24.  
  25. g0 x#1 y[#2+#10]
  26.  
  27. #11 = #4
  28.  
  29. o113 while [#11 GT #5]
  30. (down toward the specified depth a bit at a time)
  31. g2 x#1 y[#2 + #10] i0 j[0 - #10] z#11
  32. #11=[#11 - #6]
  33.  
  34. o113 endwhile
  35.  
  36. (down to the actual depth)
  37. g2 x#1 y[#2 + #10] i0 j[0 - #10] z#5
  38. (full circle at the actual depth)
  39. g2 x#1 y[#2 + #10] i0 j[0 - #10]
  40.  
  41. g0 x#1 y#2
  42.  
  43. g0 z#35
  44.  
  45.  
  46. o103 endsub
  47.  
  48.  
  49. o104 sub
  50. (mills outside circle)
  51. (parameters)
  52. (#1 = X position)
  53. (#2 = Y position)
  54. (#3 = outside diameter)
  55. (#4 = start depth)
  56. (#5 = end depth)
  57. (#6 = depth per turn)
  58.  
  59. (globals used)
  60. (#33 = tool diameter)
  61. (#35 = safety height)
  62.  
  63. #10 = [[#3+#33]/2] (effective radius = radius + tool radius)
  64.  
  65. g17 (set XY plane for arcs)
  66.  
  67. g0 z#33
  68.  
  69. g0 x#1 y[#2+#10]
  70.  
  71. #11 = #4
  72.  
  73. o114 while [#11 GT #5]
  74. (down toward the specified depth a bit at a time)
  75. g3 x#1 y[#2 + #10] i0 j[0 - #10] z#11
  76. #11=[#11 - #6]
  77.  
  78. o114 endwhile
  79.  
  80. (down to the actual depth)
  81. g3 x#1 y[#2 + #10] i0 j[0 - #10] z#5
  82. (full circle at the actual depth)
  83. g3 x#1 y[#2 + #10] i0 j[0 - #10]
  84.  
  85.  
  86. g0 z#35
  87.  
  88.  
  89. o104 endsub
  90.  
  91.  
  92.  
  93.  
  94.  
  95. o105 sub
  96. (makes torpedo oval slot from X1,Y1 to X2,Y2)
  97. (parameters)
  98. (#1 = X1)
  99. (#2 = Y1)
  100. (#3 = X2)
  101. (#4 = Y2)
  102.  
  103. (#5 = slot width)
  104.  
  105. (#6 = start depth)
  106. (#7 = end depth)
  107. (#8 = depth of cut)
  108.  
  109. (globals used)
  110. (#33 = tool diameter - until this is adapted for proper g41 TC)
  111. (#35 = safety height)
  112.  
  113.  
  114. #10 = [#3-#1] (x2-x1)
  115. #11 = [#4-#2] (y2-y1)
  116.  
  117. (normalise vector)
  118. #12 = SQRT[[#10*#10]+[#11*#11]]
  119. #10 = [#10/#12]
  120. #11 = [#11/#12]
  121.  
  122. (scale vector to slot width)
  123. #13 = [[#5 - #33]/2] (slot radius - tool radius)
  124. #10 = [#10*#13]
  125. #11 = [#11*#13]
  126.  
  127. g17 (set XY plane for arcs)
  128. g40 (turn off TC for now - TODO fix for g41)
  129.  
  130. (start at X1,Y1 + right vector {yd,-xd})
  131. g0 X[#1+#11] Y[#2-#10] Z#35
  132.  
  133. #20 = #6 (current depth)
  134.  
  135. o115 while [#20 gt #7]
  136.  
  137. g2 x[#1-#11] y[#2+#10] i[0-#11] j[0+#10] z#20
  138. g1 x[#3-#11] y[#4+#10]
  139. g2 x[#3+#11] y[#4-#10] i[0+#11] j[0-#10]
  140. g1 x[#1+#11] y[#2-#10]
  141.  
  142. #20 = [#20 - #8]
  143.  
  144. o115 endwhile
  145.  
  146. (last circuit at end depth)
  147. g2 x[#1-#11] y[#2+#10] i[0-#11] j[0+#10] z#7
  148. g1 x[#3-#11] y[#4+#10]
  149. g2 x[#3+#11] y[#4-#10] i[0+#11] j[0-#10]
  150. g1 x[#1+#11] y[#2-#10]
  151. g2 x[#1-#11] y[#2+#10] i[0-#11] j[0+#10]
  152.  
  153. g0 x#1 y#2 (move clear for extraction)
  154. g0 z#35 (extract to safety height)
  155.  
  156. o105 endsub
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. (main program)
  164.  
  165.  
  166. (set globals)
  167. #33 = 3.0 (set tool diameter)
  168. #35 = 2.0 (set safety height)
  169.  
  170.  
  171. g21 g40 (set metric, TC off)
  172. f1000
  173.  
  174.  
  175. (bore center hole)
  176. o103 call [0] [0] [8] [0] [-18] [0.5]
  177.  
  178.  
  179. (outside radius)
  180. o104 call [0] [0] [120] [0] [-18] [0.5]
  181.  
  182.  
  183. (cut 12 radial slots)
  184.  
  185. #10 = 25 (inner radius)
  186. #11 = 45 (outer radius)
  187. #12 = 0 (angle of first slot)
  188.  
  189. o200 while [#12 LT 359.9]
  190.  
  191. #13 = SIN[#12]
  192. #14 = COS[#12]
  193.  
  194. o105 call [#10*#13] [#10*#14] [#11*#13] [#11*#14] [6.0] [0] [-18] [1.0]
  195.  
  196. #12 = [#12+30.0]
  197.  
  198. o200 endwhile
  199.  
  200.  
  201.  
  202. m30 (end program)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement