M2 / (Alert, ) doesn't finish movement

More
4 years 6 months ago #239347 by moh
Hi,
I've made a macro (sub) which checks if tools are broken, by measuring height on a toolsetter.

After measuring and calculating tool length, i run a G0 motion command to retract the tool, and then an IF statement where I check if the tool length is wrong. If it is wrong I end the program using M2 or (Alert, Message) .

However the G0 retract motion is not executed. I feel like the M2 and (Alert, ) commands don't wait for the motion command to finish.
Is this expected behavior, and is there anything i can do to ensure the motion commands finishes before ending the program?


o<tool_check> sub

; Move to probe position
o301 if [EXISTS[#<_ini[TOOL_PROBE_POSITION]X>] EQ 0]
(ABORT, Missing <_ini[TOOL_PROBE_POSITION]X> in ini file)
M2
o301 endif
g53 g0 X #<_ini[TOOL_PROBE_POSITION]X>
g53 g0 Z #<_ini[TOOL_PROBE_POSITION]Z>

; Cancel current offsets
G59 ; Switch to G59 coordinate system (used for tool probing)
G49 ; Cancel tool length compensation

; Probe Tool
M64 P #<_ini[PINS]ENABLE_TOOLSETTER>
G91
G38.2 F500 Z-115 ; Probe along Z
#<tool_length_offset> = [#5063 - #<_ini[TOOL_PROBE_POSITION]REFZ>] ; Tool length offset = ref-z - probe-z (#5063)
G90
M65 P #<_ini[PINS]ENABLE_TOOLSETTER>

; Move Clear
G53 G0 Z0 

; Return offsets
G54 ; Switch to G54 coordinate system
G43

; Evaluate tool length
o302 if [ [ [#5403 - #<tool_length_offset>] LT -0.1] or [ [#5403 - #<tool_length_offset>] GT 0.1] ]
(print, Tool length: #<tool_length_offset> != Tool table: #5403)
(ABORT, Measured tool length does not match tool table)
m2 ; Not neede when using ABORT
o302 endif
(print, Tool length: #<tool_length_offset> == Tool table: #5403)

o<tool_check> endsub
M2

Please Log in to join the conversation.

More
4 years 6 months ago #239350 by andypugh
This might not be the problem, but should:
Code:
; Move Clear G0 Z0

be
Code:
; Move Clear G53 G0 Z0

Please Log in to join the conversation.

More
4 years 6 months ago #239421 by moh
It's actually already like that, its just in a sub command, and i copied it wrong to the forum.
I fixed the first post to show this.

Please Log in to join the conversation.

More
4 years 6 months ago #239429 by MaHa
Did you try already to retract from the toolsetter before turning it off with M65?

Please Log in to join the conversation.

Time to create page: 0.098 seconds
Powered by Kunena Forum