M6 remap did not return a value
24 Mar 2024 21:39 #296651
by greg23_78
M6 remap did not return a value was created by greg23_78
When I tried to improve my M6 remap using If Elseif Else Endif Example, I got the error message "the M6 remap procedure toolchange did not return a value".
for resume
-Spindle position
-if tool in spindle = 0 Do ...
-Elseif tool in spindle > 0 Do ...
-Elseif selected tool = 0 D0 ...
-Else DO nothing
below is the modified code:
I ran this remap and it performed the first condition, but did not implement the tool number in the spindle (remaining at 0). How can I resolve this error message?
for resume
-Spindle position
-if tool in spindle = 0 Do ...
-Elseif tool in spindle > 0 Do ...
-Elseif selected tool = 0 D0 ...
-Else DO nothing
below is the modified code:
o<toolchange> sub
; Check to make sure z axis is homed
M66 P8 L0
o001 if [#5399 LT 0]
(abort, z axis is not homed)
o001 endif
G53 G0 Z 635 ;Move Z to load position
M66 P9 L3 Q1 (wait HIGH to the Z toolchange position)
o002 if [#5399 LT 0]
(abort, Z is not in position)
o002 endif
M66 P12 L3 Q10 ;(wait vfd is ready)
M64 P6 ; sensor position activate
M4 S6 ;(turn spindle cw S50 tr/min)
G4 P2 ; Wait 2 seconds
M66 P7 L1 Q20 ;(wait falling edge to the proximity sensor of the spindle)
M5 ;(stop spindle)
M66 P7 L3 Q1 ;(If proximity sensor is not high abort)
o003 if [#5399 LT 0]
(abort, spindle is not oriented)
o003 endif
M65 P6 ; sensor position deactivate
; only unload the tool if there is a tool in the spindle
; This assumes that the carousel is already aligned correctly.
; It is important to unload the tool before shutting down the machine.
;--------------------------------------------------------------------------------------- Select_tool > 0 And tool_in_spindle > 0---------------------------------------------
o100 if [#<tool_in_spindle> GT 0]
o110 if [#<tool_in_spindle> NE #<current_pocket>]
M68 E0 Q#<tool_in_spindle> ;set the carousel to move to the right pocket
M64 P0 ;Enable Carousel
G4 P2 ; Wait 2 seconds
M66 P0 L3 Q120 ; wait for carousel-ready = true
o111 if [#5399 LT 0]
(abort, carousel not finished)
o111 endif
M65 P0 ;Disable carousel enable
o110 endif
M64 P1 ; Extend tool changer arm
G4 P3 ; Wait 3 seconds
M66 P2 L3 Q5 ; wait for carousel-extended = true
o112 if [#5399 LT 0]
(abort, carousel not extended)
o112 endif
M66 P1 L3 Q5 ; wait for carousel-retracted = false
o114 if [#5399 GT 0]
(abort, carousel still retracted)
o114 endif
M64 P3 ;Release tool
M66 P5 L3 Q5 ; wait for tool-released = true
o116 if [#5399 LT 0]
(abort, tool not released)
o116 endif
M64 P2 ;down tool changer arm
M66 P4 L3 Q8 ; wait for carousel-up = true
o117 if [#5399 LT 0]
(abort, carousel not extended)
o117 endif
M66 P3 L3 Q5 ; wait for carousel-down = false
o118 if [#5399 GT 0]
(abort, carousel still retracted)
o118 endif
M68 E0 Q#<selected_pocket> ;set the carousel to move to the right pocket
M64 P0 ;Enable Carousel
M66 P0 L3 Q120 ; wait for carousel-ready = true
o119 if [#5399 LT 0]
(abort, carousel not finished)
o119 endif
M65 P0 ;Disable carousel enable
M64 P3 ;Release tool
M66 P5 L3 Q5 ; wait for tool-released = true
o120 if [#5399 LT 0]
(abort, tool not released)
o120 endif
M64 P5 ;Turn on air blast
G4 P2 ;Wait 2 seconds
M65 P5 ;Turn off air blast
M65 P2 ;down tool changer arm
M66 P3 L3 Q8 ; wait for carousel-down = true
o121 if [#5399 LT 0]
(abort, carousel not extended)
o121 endif
M66 P4 L3 Q5 ; wait for carousel-up = false
o122 if [#5399 GT 0]
(abort, carousel still retracted)
o122 endif
M65 P3 ;Clamp tool (turn unclamp off)
G4 P2 ; Wait 2 seconds
M66 P6 L3 Q5 ;Verify that tool is clamped
o123 if [#5399 LT 0]
(abort, tool not clamped)
o123 endif
M65 P1 ;Retract tool changer arm
G4 P1 ; Wait 5 seconds
M66 P1 L3 Q5 ; wait for carousel-retracted = true
o124 if [#5399 LT 0]
(abort, carousel not retracted)
o124 endif
M66 P2 L3 Q5 ; wait for carousel-extended = false
o125 if [#5399 GT 0]
(abort, carousel still extended)
o125 endif
;--------------------------------------------------------------------------------------- Select_tool > 0 And tool_in_spindle = 0---------------------------------------------
o100 elseif [#<tool_in_spindle> LE 0]
M68 E0 Q#<selected_pocket> ;set the carousel to move to the right pocket
M64 P0 ;Enable Carousel
G4 P2 ; Wait 2 seconds
M66 P0 L3 Q120 ; wait for carousel-ready = true
o201 if [#5399 LT 0]
(abort, carousel not finished)
o201 endif
M65 P0 ;Disable carousel enable
M64 P2 ;Down tool changer arm, might already be down
M66 P4 L3 Q8 ; wait for carousel-up = true
o202 if [#5399 LT 0]
(abort, carousel not extended)
o202 endif
M66 P3 L3 Q5 ; wait for carousel-down = false
o203 if [#5399 GT 0]
(abort, carousel still retracted)
o203 endif
M64 P1 ;Extend carousel, might already be extended
G4 P2 ; Wait 2 seconds
M66 P2 L3 Q8 ; wait for carousel-extended = true
o204 if [#5399 LT 0]
(abort, carousel not extended)
o204 endif
M66 P1 L3 Q5 ; wait for carousel-retracted = false
o205 if [#5399 GT 0]
(abort, carousel still retracted)
o205 endif
M64 P3 ;Release tool
M66 P5 L3 Q5 ; wait for tool-released = true
o206 if [#5399 LT 0]
(abort, tool not released)
o206 endif
M64 P5 ;Turn on air blast
G4 P2 ;Wait 2 seconds
M65 P5 ;Turn off air blast
M65 P2 ;down tool changer arm
M66 P3 L3 Q8 ; wait for carousel-down = true
o207 if [#5399 LT 0]
(abort, carousel not extended)
o207 endif
M66 P4 L3 Q5 ; wait for carousel-up = false
o208 if [#5399 GT 0]
(abort, carousel still retracted)
o209 endif
M65 P3 ;Clamp tool (turn unclamp off)
G4 P2 ; Wait 2 seconds
M66 P6 L3 Q5 ;Verify that tool is clamped
o210 if [#5399 LT 0]
(abort, tool not clamped)
o210 endif
M65 P1 ;Retract tool changer arm
G4 P1 ; Wait 5 seconds
M66 P1 L3 Q5 ; wait for carousel-retracted = true
o211 if [#5399 LT 0]
(abort, carousel not retracted)
o211 endif
M66 P2 L3 Q5 ; wait for carousel-extended = false
o212 if [#5399 GT 0]
(abort, carousel still extended)
o212 endif
;--------------------------------------------------------------------------------------- Select_tool = 0 And tool_in_spindle > 0---------------------------------------------
o100 elseif [#<selected_tool> EQ 0]
o310 if [#<tool_in_spindle> NE #<current_pocket>]
M68 E0 Q#<tool_in_spindle> ;set the carousel to move to the right pocket
M64 P0 ;Enable Carousel
G4 P2 ; Wait 2 seconds
M66 P0 L3 Q120 ; wait for carousel-ready = true
o301 if [#5399 LT 0]
(abort, carousel not finished)
o301 endif
M65 P0 ;Disable carousel enable
o310 endif
M64 P1 ; Extend tool changer arm
G4 P3 ; Wait 3 seconds
M66 P2 L3 Q5 ; wait for carousel-extended = true
o311 if [#5399 LT 0]
(abort, carousel not extended)
o311 endif
M66 P1 L3 Q5 ; wait for carousel-retracted = false
o312 if [#5399 GT 0]
(abort, carousel still retracted)
o312 endif
M64 P3 ;Release tool
M66 P5 L3 Q5 ; wait for tool-released = true
o313 if [#5399 LT 0]
(abort, tool not released)
o313 endif
M64 P2 ;down tool changer arm
M65 P1 ;Retract tool changer arm
G4 P1 ; Wait 5 seconds
M66 P1 L3 Q5 ; wait for carousel-retracted = true
o314 if [#5399 LT 0]
(abort, carousel not retracted)
o314 endif
M66 P2 L3 Q5 ; wait for carousel-extended = false
o315 if [#5399 GT 0]
(abort, carousel still extended)
o315 endif
M65 P2
o100 else
M2
o100 endif
M2
o<toolchange> endsub
I ran this remap and it performed the first condition, but did not implement the tool number in the spindle (remaining at 0). How can I resolve this error message?
Please Log in or Create an account to join the conversation.
29 Mar 2024 09:53 #297081
by andypugh
Replied by andypugh on topic M6 remap did not return a value
I think that the problem might be with the use of M2 inside the subroutine. I think that this is will stop execution.
Your remapped G-code routine should run to an endsub, and should probably return a value to indicate to calling code whether it succeeded or not.
If you look at the G-code snippets here: linuxcnc.org/docs/stable/html/remap/remap.html they typically look like O endsub [1]
In this example the [1] is the return value.
So, get rid of the M2 commands (use an (abort, ...) instead and add a return value.
Your remapped G-code routine should run to an endsub, and should probably return a value to indicate to calling code whether it succeeded or not.
If you look at the G-code snippets here: linuxcnc.org/docs/stable/html/remap/remap.html they typically look like O
In this example the [1] is the return value.
So, get rid of the M2 commands (use an (abort, ...) instead and add a return value.
Please Log in or Create an account to join the conversation.
Time to create page: 0.114 seconds