Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Sawdust on December 03, 2020, 05:23:13 PM

Title: Nested Subroutine hangs after 1 iteration
Post by: Sawdust on December 03, 2020, 05:23:13 PM
I'm running Mach 3 on a DIY machine.Can anyone tell me why the program hangs after the first time through subroutine O125? Also Mach 3 does not display the M99 at the bottom of the subroutine.

#1=-0.1
#2=1
#3=0
#4=60
G20 G40 G80 G90 G00
Z1.1
G1 F60
G1Z[#2]
(Calling sub O125)
M98 P125 Q5 (Repeat 5 times)
G00 Z1
G0A0
M30 (end program)

O124 (this is a sub)
G1 X0Z[#2] F60
#2=[#2+#1] (Step decrease Z by value of #1)
G1 Z1
G1 X6
M99

O125 (this is a sub)
(Call Sub O124)
M98 P124 Q5
#3=[#3+#4] (increase #3 by 60)
G0A[#3] (Rotate A axis 60 degrees)
M99
Title: Re: Nested Subroutine hangs after 1 iteration
Post by: Graham Waterworth on December 03, 2020, 05:30:35 PM
You are probably missing an end of line at the end of the code try starting and ending the code with a %

%
#1=-0.1
#2=1
#3=0
#4=60
G20 G40 G80 G90 G00
Z1.1
G1 F60
G1Z[#2]
(Calling sub O125)
M98 P125 Q5 (Repeat 5 times)
G00 Z1
G0A0
M30 (end program)

O124 (this is a sub)
G1 X0Z[#2] F60
#2=[#2+#1] (Step decrease Z by value of #1)
G1 Z1
G1 X6
M99

O125 (this is a sub)
(Call Sub O124)
M98 P124 Q5
#3=[#3+#4] (increase #3 by 60)
G0A[#3] (Rotate A axis 60 degrees)
M99
%
Title: Re: Nested Subroutine hangs after 1 iteration
Post by: Sawdust on December 03, 2020, 09:28:09 PM
Doh :-\ Sometimes I can't see the forest for the trees.

Thanks