Hello Guest it is September 25, 2020, 04:32:35 PM

Author Topic: subroutine problems  (Read 1265 times)

0 Members and 1 Guest are viewing this topic.

subroutine problems
« on: November 25, 2016, 06:13:39 PM »
I'm hoping someone can help me with a subroutine.  I never use them, but now that I have built a plasma table, I can see that I may be using them a lot in the future.

I'm running Mach 3 on winxp.  For some reason, it errors out if I put an M99 at the end of my subroutine, but doesn't if I use M17.  At any rate, it is supposed to be cutting two rectangles.  It only cuts one and I can't figure out why. 

Here's my code with comments on what I think is happening.  Hopefully someone can correct me.

%
N001 O0001 (MAIN PROGRAM)
N002 G90 (ABSOLUTE POSITIONING MODE)
N003 G0X0Y0Z0 (RAPID POSITION)
N004 G01 X.875 Y.500 F83 (FEED AT 83 IPM)
N005 M98 P0002 (CALL SUBROUTINE 2)
N006 G0 X2.875 (RAPID POSITION)
N007 M98 P0002 (CALL SUBROUTINE 2)
N008 M99

O0002 (SUBROUTINE 2)
G91 (INCREMENTAL POSITIONING MODE)
M3 (TORCH ON)
G04 P1 (DWELL FOR 1 SECOND)
G01 Y-.043 F83 (FEED AT 83 IPM)
X-.060 (FEED AT 83 IPM)
Y3.043 (FEED AT 83 IPM)
X.120 (FEED AT 83 IPM)
Y-3.043 (FEED AT 83 IPM)
X-.060 (FEED AT 83 IPM)
Y.043 (FEED AT 83 IPM)
Z1 (FEED AT 83 IPM)
M5 (TORCH OFF)
G90 (ABSOLUTE POSITIONING MODE)
M17
%
Re: subroutine problems
« Reply #1 on: November 26, 2016, 11:06:03 AM »
Not an expert but:

at N008
N008 M30

then at end of sub

M99

Also, at every sub call I add L1 or however many loops to be called


HTH
Re: subroutine problems
« Reply #2 on: November 26, 2016, 05:43:00 PM »
Thanks for the help!

Here's my modified code:

%
N001 O0001 (MAIN PROGRAM)
N002 G90 (ABSOLUTE POSITIONING MODE)
N003 G0X0Y0Z0 (RAPID POSITION)
N004 G01 X.875 Y.500 F83 (FEED AT 83 IPM)
N005 M98 P0002 (CALL SUBROUTINE 2)
M99
N006 G0 X2.875 (RAPID POSITION)
N007 M98 P0002 (CALL SUBROUTINE 2)
N008 M30

O0002 (SUBROUTINE 2)
G91 (INCREMENTAL POSITIONING MODE)
M3 (TORCH ON)
G04 P1 (DWELL FOR 1 SECOND)
G01 Y-.043 F83 (FEED AT 83 IPM)
X-.060 (FEED AT 83 IPM)
Y3.043 (FEED AT 83 IPM)
X.120 (FEED AT 83 IPM)
Y-3.043 (FEED AT 83 IPM)
X-.060 (FEED AT 83 IPM)
Y.043 (FEED AT 83 IPM)
Z1 (FEED AT 83 IPM)
M5 (TORCH OFF)
G90 (ABSOLUTE POSITIONING MODE)
M99
%


When I tried to run it, it gives me the following error:

"Return called with no sub in effect...looping"

Thoughts?

Re: subroutine problems
« Reply #3 on: November 26, 2016, 05:59:09 PM »
try:

%
N001 O0001 (MAIN PROGRAM)
N002 G90 (ABSOLUTE POSITIONING MODE)
N003 G0X0Y0Z0 (RAPID POSITION)
N004 G01 X.875 Y.500 F83 (FEED AT 83 IPM)
N005 M98 P0002 (CALL SUBROUTINE 2)
N006 G0 X2.875 (RAPID POSITION)
N007 M98 P0002  (CALL SUBROUTINE 2)
N008 M30


O0002 (SUBROUTINE 2)
G91 (INCREMENTAL POSITIONING MODE)
M3 (TORCH ON)
G04 P1 (DWELL FOR 1 SECOND)
G01 Y-.043 F83 (FEED AT 83 IPM)
X-.060 (FEED AT 83 IPM)
Y3.043 (FEED AT 83 IPM)
X.120 (FEED AT 83 IPM)
Y-3.043 (FEED AT 83 IPM)
X-.060 (FEED AT 83 IPM)
Y.043 (FEED AT 83 IPM)
Z1 (FEED AT 83 IPM)
M5 (TORCH OFF)
G90 (ABSOLUTE POSITIONING MODE)
M99
%
Re: subroutine problems
« Reply #4 on: November 26, 2016, 10:50:29 PM »
That fixed it.  Had an extra M99 in there for some reason.  Thanks for the help!