Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: birdbrain on July 26, 2008, 04:23:30 AM

Title: How can I use subprograms in the subroutines folder?
Post by: birdbrain on July 26, 2008, 04:23:30 AM
In the Mach3 directory tree there is a folder called "subroutines".
If I store subroutine files in this folder how can I use the subprograms that they contain in my other programs???
This would be very useful to know as I have a number of standard subroutines that I use in various program files.
Title: Re: How can I use subprograms in the subroutines folder?
Post by: jimpinder on July 26, 2008, 03:05:37 PM
M98 (nameofsubroutine.tap) - where the subroutine is in the folder.
Title: Re: How can I use subprograms in the subroutines folder?
Post by: Hans1904 on May 18, 2009, 10:09:12 AM

Posts: 1


View Profile Email Personal Message (Online)
   
   
Re: Plugin to use with cnc4pc modio pcb
« Reply #2 on: May 18, 2009, 09:07:44 AM »
   Reply with quote Modify message Remove message
I am working with a Mach 3-controlled machine, trying to get subroutines to work. Am familiar with the usual Fanuc or
Haas formats, but cannot get a main program to pick up the subroutine. Sub is in the "subroutine" folder under Mach 3
folder, as specified. Have tried tried renaming the sub with or without an "O" in its name (It has an "O1000" in its 1st line)
and "%" by itself on first and last line. Any suggestions?
Title: Re: How can I use subprograms in the subroutines folder?
Post by: Hood on May 18, 2009, 11:36:04 AM
Page 10.8.7 of the UsingMachMill manual details how to use Subs, is that not working for you?
Hood
Title: Re: How can I use subprograms in the subroutines folder?
Post by: Hans1904 on May 18, 2009, 04:53:14 PM
No, the methods given in the manual ,10.8.7, were not working. I got in touch with "Chip," who had posted and actually is located in
Gainesville, FL, USA, where I am. He said to place the subs at the end o the main program, in the same file, after the M30 and separated by a % on a line by itself. That does work, and is fine with me, but don't know why the manual does not refer to this.
I am quite familiar with the Haas VF controls (work with one every day), and they do this, too, as one way of using subs. They refer to
it as a "local" subprogram and call it from the main program with M97. Very convenient, but wouldn't know Mach 3 does this without the forum contacts. Now, I couold really use something like a GOTO command as used in Fanuc controls. Thanks.
Title: Re: How can I use subprograms in the subroutines folder?
Post by: Hood on May 18, 2009, 05:49:44 PM
Pg 5.5.4 shows that method if I am not misunderstanding, there are also a few other examples in the manual, however the M98(yourfilename.tap) should also work as well, certainly seems to here although I very rarely, if ever use subs.

What does the GoTo command you want actually do?
Hood
Title: Re: How can I use subprograms in the subroutines folder?
Post by: Chip on May 18, 2009, 06:46:01 PM
Hi, Brian

The reference "Hood" posted will work just fine, Give this a try.

; M98 import test 3.txt

G90
M98 (Gcode test.tap) ; File must be in C:\Mach3\Subroutines folder
M30
%

; This File must be in C:\Mach3\Subroutines folder.
; Gcode test.tap

G00 z-.5
G01X1
Y1
X0
Y0
Z0
M99
%

Chip
Title: Re: How can I use subprograms in the subroutines folder?
Post by: vmax549 on May 18, 2009, 06:57:08 PM
GUYS in certain versions the M89 call to the sub folder is broken. I just tried it again here(V.020) and it does not work.

AS is IF the m98 sees the m99 in the sub file, mach errors (and does NOT show the error) with looping with no sub in effect.

AND IF you take out the M99 it will run the sub BUT it will NOT return to the M98 call(;-)

Catch 22(;-)

HANS Mach DOES NOT have provisions for conditional OR redirection in Gcode.

(;-) TP
Title: Re: How can I use subprograms in the subroutines folder?
Post by: MachineMaster on May 18, 2009, 09:39:03 PM
I use IF, THEN, WHILE & GOTO by putting then in VB in a macro.
Title: Re: How can I use subprograms in the subroutines folder?
Post by: Chip on May 19, 2009, 02:31:47 AM
Hi, Terry

I checked ver's 3.042.020 to 3.042.027 and the only issue with the code above was I needed an extra M30 at the bottom of code to get code to rewind in Mach sometimes. 3.043.000 seemed just fine with one M30.

Chip
Title: Re: How can I use subprograms in the subroutines folder?
Post by: vmax549 on May 19, 2009, 10:38:38 AM
HIYA Chip ,

here the m98 call for the sub just stalls out and sits and waits. It never gets to load the sub. IF I remove the M99 from the sub it will then load the sub and run the sub but will NOT return to the main program.(;-)

AND it should have errored out with SUB in effect with NO RETURN but did not

V.019 runs just fine  Anything above that is hit and miss here.

IF it requires more than 1" M30" there IS a problem lurking(;-) It is just coming out deferently on your computer(;-)


(;-) TP
Title: Re: How can I use subprograms in the subroutines folder?
Post by: simpson36 on May 27, 2009, 10:51:56 AM
An interesting anomoly I discovered in subroutines is that there has to be a return at the end of the M99 line of Mach is unhappy. This behavior was with imbedded subs, but may also be true for extrenal subs.

There is a recent version of Mach that would skip the next line of code in the main program after returning from a sub, so watch out for that . . . I think it may have been .26 but the Changelog has the info.