Advanced Search

Search Results (Searched for: )

  • finnstrom
  • finnstrom's Avatar
28 Nov 2024 22:06

LinuxCNC gcode hangs on M63 "main loop took x seconds"

Category: General LinuxCNC Questions

The main block of code is in:

change_tool.ngc
O<change_tool> sub
; X offset from pocket when moving in/out to change tool
#<pocket_x_offset>=100.0
; Amount of Z that the spindle pulls/pushes the tool when activating the tool changer
#<z_jump>=2.0
; Speed that z_jump happens
#<z_jump_speed>=2000
M70 ; Save modal state
G49 ; Cancel tool length compensation
G21 ; Move in mm
G90 ; Move in absolute
; Retract the shoe
M9
; Move to Z0 to clear table and tool rack
G53 G0 Z0
; Check if a tool is detected in the spindle
; Ignore for now
;M66 ...
#<tool_detected>=1
o100 if [#<selected_tool> NE #<tool_in_spindle>]
o110 if [#<tool_in_spindle> GT 0]
; o110 if [[#<tool_in_spindle> GT 0] AND [#<tool_detected> EQ 1]]
; Unload current tool to pocket
; Extend pocket
o<extend_pocket> call [#<tool_in_spindle>]
; Move to pocket plus X offset before moving in X
o<go_to_pocket> call [#<tool_in_spindle>] [#<pocket_x_offset>]
#<abs_pocket_z>=#<_value>
; Move down to height of the tool rack
G53 G0 Z[#<abs_pocket_z>]
; Make sure that the spindle has stopped.
M66 P35 L4 Q10
o140 if [#5399 EQ -1]
(debug, Spindle did not stop within 10 seconds)
M0
o140 endif
; Move in by X offset
G91 G0 X[-#<pocket_x_offset>]
; Check that air pressure is 100psi min

; Release the tool while simultaneously moving up
M64 P17
G4 P0.20
G91 G1 Z[#<z_jump>] F[#<z_jump_speed>]
M61 Q0
; Complete motion and move up fully
G53 G90 G0 Z0
; Re-engage tool changer
M65 P17
; Retract pocket
o<retract_pocket> call [#<tool_in_spindle>]
G4 P1
; Check that no tool is detected
; o110 elseif [[#<tool_in_spindle> GT 0] AND [#<tool_detected> EQ 0]]
; (debug, Tool is loaded but not detected)
; o110 elseif [[#<tool_in_spindle> EQ 0] AND [#<tool_detected> EQ 1]]
; (debug, Tool is not loaded but is detected)
o110 else
(debug, No tool currently loaded)
o110 endif
o120 if [#<selected_tool> GT 0]
; Extend the pocket with the new tool
o<extend_pocket> call [#<selected_tool>]
; Move directly to pocket above new tool
o<go_to_pocket> call [#<selected_tool>] [0.0]
#<abs_pocket_z>=#<_value>
; Make sure that the spindle is not running.
M66 P35 L4 Q10
o150 if [#5399 EQ -1]
(debug, Spindle did not stop within 10 seconds)
M0
o150 endif
; Activate tool release
M64 P17
; Move down to grab tool
G53 G0 Z[#<abs_pocket_z>+#<z_jump>]
; Deactivate tool release to grab tool
M63 P17
G91 G1 Z[-#<z_jump>] F[#<z_jump_speed>]
; Retract pocket and move to X offset
o<retract_pocket> call [#<selected_tool>]
G91 G0 X[#<pocket_x_offset>]
; Retract Z fully
G53 G90 G0 Z0
M61 Q[#<selected_tool>]
; Call probe routine if no tool offset exists (ie. equal zero).
o130 if [#5403 GT -1]
o<z_offset> call [#<selected_tool>]
o130 endif
o120 endif
o100 endif
; Apply the tool offset.
; Placed here because vcarce gcode output will remove tool offsets before tool change.
; Tool length offset needs to be applied even if the tool is already loaded.
G43 H[#<selected_tool>]
M72 ; Restore modal state
G43 H[#<selected_tool>]
O<change_tool> endsub [1]
M2

Two subroutines that may get called prior (but don't at first run when the spindle has no tool):

extend_pocket.ngc
O<extend_pocket> sub
#<pocket>=[#1]
M64 P[#<pocket>]
#<timeout_s>=2
o100 if [#<pocket> EQ 1]
M66 P2 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 2]
M66 P4 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 3]
M66 P6 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 4]
M66 P8 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 5]
M66 P10 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 6]
M66 P12 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 7]
M66 P14 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 8]
M66 P16 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 9]
M66 P18 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 10]
M66 P20 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 11]
M66 P22 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 12]
M66 P24 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 13]
M66 P26 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 14]
M66 P28 L3 Q[#<timeout_s>]
o100 elseif [#<pocket> EQ 15]
M66 P30 L3 Q[#<timeout_s>]
o100 endif
o110 if [#5399 EQ -1]
(debug, Paused: Pocket [#<pocket>] did not extend. Resume to set high pressure and continue.)
M0
o110 endif
M64 P20 ; Set high pressure
O<extend_pocket> endsub [1]
M2

go_to_pocket.ngc
; Do not edit values in this file
O<go_to_pocket> sub
#<pocket>=[#1]
#<x_offset>=[#2]
#<abs_pocket_z>=-72.5
G49 ; Cancel tool length compensation
G21 ; Move in mm
; Retract Z fully
G53 G90 G0 Z0
o100 if [#<pocket> EQ 1]
G53 G0 X[-68.678251+#<x_offset>] Y-60.976070 ; Pocket 1
o100 elseif [#<pocket> EQ 2]
G53 G0 X[-68.742418+#<x_offset>] Y41.849836 ; Pocket 2
o100 elseif [#<pocket> EQ 3]
G53 G0 X[-68.314084+#<x_offset>] Y148.370749 ; Pocket 3
o100 elseif [#<pocket> EQ 4]
G53 G0 X[-68.238618+#<x_offset>] Y254.000046 ; Pocket 4
o100 elseif [#<pocket> EQ 5]
G53 G0 X[-67.813618+#<x_offset>] Y357.952617 ; Pocket 5
o100 elseif [#<pocket> EQ 6]
G53 G0 X[-67.511284+#<x_offset>] Y462.964593 ; Pocket 6
o100 elseif [#<pocket> EQ 7]
G53 G0 X[-67.624618+#<x_offset>] Y566.826919 ; Pocket 7
o100 elseif [#<pocket> EQ 8]
G53 G0 X[-67.214618+#<x_offset>] Y672.035324 ; Pocket 8
o100 elseif [#<pocket> EQ 10]
G53 G0 X[-67.563784+#<x_offset>] Y881.168728 ; Pocket 10
o100 elseif [#<pocket> EQ 11]
G53 G0 X[-68.058784+#<x_offset>] Y986.224632 ; Pocket 11
o100 elseif [#<pocket> EQ 12]
G53 G0 X[-67.385451+#<x_offset>] Y1090.113870 ; Pocket 12
o100 elseif [#<pocket> EQ 13]
G53 G0 X[-67.041568+#<x_offset>] Y1196.961433 ; Pocket 13
o100 elseif [#<pocket> EQ 14]
G53 G0 X[-67.590735+#<x_offset>] Y1301.370671 ; Pocket 14
o100 elseif [#<pocket> EQ 15]
G53 G0 X[-67.744901+#<x_offset>] Y1404.963243 ; Pocket 15
o100 endif
O<go_to_pocket> endsub [#<abs_pocket_z>]
m2
Displaying 22366 - 22366 out of 22366 results.
Time to create page: 0.404 seconds
Powered by Kunena Forum