Guest User

Tool_change.ngc

a guest
Nov 19th, 2026
25
0
27 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. o<tool_change> sub
  2.  
  3. M73 (auto-restore modal settings on return)
  4.  
  5. (MSG, Tool change: loaded tool = [#<_current_tool>])
  6. (MSG, Tool change: selected tool = [#<_selected_tool>])
  7.  
  8. (print, Tool_change: loaded tool = #<_current_tool>)
  9. (print, Tool_change: selected tool = #<_selected_tool>)
  10.  
  11. ; unload previous tool - if next tool is also in spindle 1, then have to actually unload it first, so second parameter for tool_put_move is 0;
  12. o100 if [#<_current_tool> GT 0]
  13. o101 if [#<_current_tool> LE 7 AND #<_selected_tool> GE 51 AND #<_selected_tool> LE 84]
  14. ; #4000 = #<_current_tool> (save the number of tool currently in spindle)
  15. ; (MSG, Tool change: current tool remains in spindle)
  16. o<tool_put_move> call [#<_current_tool>] [1]
  17. o101 else
  18. (MSG, Tool change: tool put move started)
  19. o<tool_put_move> call [#<_current_tool>] [0]
  20. o101 endif
  21. o100 endif
  22.  
  23. ; go to new tool
  24.  
  25. o200 if [#<_selected_tool> EQ 0]
  26. G04 P0.2
  27. o200 elseif [#<_selected_tool> EQ #4000]
  28.  
  29. M66 P05 L3 Q1 (check if carousel is out and does not interfere with spindle)
  30. o201 if [#5399 NE 1]
  31. (MSG, Carousel is not out, will try to do that, main 1)
  32. M64 P06 (move carousel out)
  33. G04 P0.2
  34. M65 P06
  35. M66 P05 L3 Q4 (check if carousel is out and does not interfere with spindle)
  36. o2011 if [#5399 EQ -1]
  37. (MSG, Carousel is not out, cycle paused)
  38. M0
  39. o2011 endif
  40. o201 else
  41. G04 P0.1
  42. o201 endif
  43.  
  44. M66 P01 L0 (check if spindle is down)
  45.  
  46. o202 if [#5399 NE 1]
  47. (MSG, Spindle is not down, will try to do that, main 1)
  48. M64 P01 (lower the spindle)
  49. M64 P04 (lower the spindle)
  50. G04 P0.2
  51. M65 P01
  52. M65 P04
  53. M66 P01 L3 Q10 (make sure that spindle is down)
  54.  
  55. o2021 if [#5399 EQ -1]
  56. (MSG, Spindle is not down, cycle paused)
  57. M0
  58. o2021 endif
  59.  
  60. o202 else
  61. G04 P0.1
  62. o202 endif
  63.  
  64. o200 else
  65. (MSG, Tool change: tool get move started)
  66. #4000 = 0
  67. o<tool_get_move> call [#<_selected_tool>]
  68. o200 endif
  69.  
  70. ; just to be sure - check if carousel is out and chip guard is down
  71.  
  72. M66 P05 L0 (check if carousel is out and does not interfere with spindle)
  73. o301 if [#5399 NE 1]
  74. (MSG, Carousel is not out, will try to do that, main 2)
  75. M64 P06 (move carousel out)
  76. G04 P0.2
  77. M65 P06
  78. M66 P05 L3 Q4 (check if carousel is out and does not interfere with spindle)
  79. o3011 if [#5399 EQ -1]
  80. (MSG, Carousel is not out, cycle paused)
  81. M0
  82. o3011 endif
  83. o301 else
  84. G04 P0.1
  85. o301 endif
  86.  
  87. ;M66 P03 L0 (check if chip guard is down)
  88. ;o302 if [#5399 NE 0]
  89. ; (MSG, Chip guard not down, will try to lower)
  90. ; M64 P08
  91. ; G04 P0.2
  92. ; M65 P08
  93. ; G04 P1
  94. ; M66 P03 L0 (make sure that chip guard is down)
  95. ;o3021 if [#5399 NE 0]
  96. ; (MSG, chip guard is not down, cycle paused)
  97. ; M0
  98. ;o3021 endif
  99. ;o302 endif
  100.  
  101. ; succeed by returning a positive value
  102. o<tool_change> endsub [1]
  103. m2
  104.  
Advertisement
Add Comment
Please, Sign In to add comment