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

  • finnstrom
  • finnstrom's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
28 Nov 2024 13:31 #315465 by finnstrom
I swapped in my own M6 toolchange code which (mostly) works just fine. Right before grabbing the tool, it runs a command to synchronize grabbing the tool with moving the spindle down slightly:
; Deactivate tool release to grab tool
M63 P17
G91 G1 Z[-#<z_jump>] F[#<z_jump_speed>]

However, on the first (and only first) tool change operation, and on exactly every new program loaded, the gcode just stops running right when it's about to grab the tool. It doesn't toggle machine power, it doesn't stop or pause the program, it just sits there with the "play" button pressed as if it's running. The only message I see on the terminal (even when running verbose) is:
task: main loop took 0.110972 seconds

My workaround is to move the spindle up, retract the tool, and to run the exact same program again, and everything works as it should.Any idea on how to debug this? Or tips on where in LinuxCNC source to add some more debug output around the M63 operation? I'm running 2.9.1 on a system built from LinuxCNC LiveCD. The problem persists in both Axis and QtDragon.

Thanks
 

Please Log in or Create an account to join the conversation.

More
28 Nov 2024 17:58 #315479 by Aciera
Can you post your entire M6 remap code?

Please Log in or Create an account to join the conversation.

  • finnstrom
  • finnstrom's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
28 Nov 2024 22:06 #315491 by finnstrom
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

Please Log in or Create an account to join the conversation.

More
29 Nov 2024 07:31 #315517 by Aciera
Not sure. You have another subroutine call 'retract_pocket' after the G91 move in question. Maybe try stopping the read ahead before it ingests that and enter a debug line to make sure the Z and F word are what you expect them to be:
; Deactivate tool release to grab tool
 M63 P17
(DEBUG, Z-#<z_jump>  F#<z_jump_speed>)
 G91 G1 Z[-#<z_jump>] F[#<z_jump_speed>]
 M66 E0 L0 (queuebuster to stop read ahead here)
 ; Retract pocket and move to X offset
 o<retract_pocket> call [#<selected_tool>]

Please Log in or Create an account to join the conversation.

  • finnstrom
  • finnstrom's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
06 Dec 2024 05:07 #316072 by finnstrom
Thanks for the tip. Unfortunately I got the same result, and with the values looking good.

Finn

Please Log in or Create an account to join the conversation.

Time to create page: 0.057 seconds
Powered by Kunena Forum