Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: a3dcreator on June 13, 2017, 11:22:52 AM

Title: subroutines?
Post by: a3dcreator on June 13, 2017, 11:22:52 AM
anyone know where the subroutine files go?
like what folder? i found one in:
C:\Mach4Hobby\Subroutines\O0001

but when I call the command from the MDI it says it cant find it.

is this only supported in mach4 industrial?

i can do a subRoutine if i build it into the same gcode file. But not by saving it in the subroutines folder like  the manual says.

thanks.
Title: Re: subroutines?
Post by: joeaverage on June 13, 2017, 02:48:52 PM
Hi,
I thought a subroutine O********* was actually part of the running Gcode program. If Mach had to go 'find' it wouldn't
you have to provide a path and filename?

Those Gcode jobs I have that do use subroutines  are included/part of the Gcode file and they run fine.

Craig
Title: Re: subroutines?
Post by: a3dcreator on June 13, 2017, 03:05:07 PM
clcik on this link and look at page 61.
it says there :

"
There are limitations to this method; mainly the subprogram must be pasted into every program that it
is to be called from. Mach also allows a subprogram to be called from an external file. This way,
multiple programs can call the same subprogram, without having the program in the main file. If a
change needs to be made to the subprogram it only needs to be done in one file, not every file in which
the sub is called. If the control does not find the program number in the current file it will then search
for it in the Mach4\Subroutines directory. This time it will be searching filenames. The files in this
directory should be named with the program number as follows:
"
Title: Re: subroutines?
Post by: a3dcreator on June 13, 2017, 03:05:42 PM
sorry forgot the link. here it is

http://www.machsupport.com/wp-content/uploads/2014/05/Mach4%20Mill%20GCode%20Manual.pdf
Title: Re: subroutines?
Post by: smurph on June 13, 2017, 06:05:07 PM
The files in the subroutine folder can contain only one subroutine each.  And the subroutine must have a a proper O line at the top that matches the base file name.  There is no limit to the number of subroutines that you can put in this folder as long as they are unique subroutine numbers. 

Steve
Title: Re: subroutines?
Post by: a3dcreator on June 13, 2017, 07:11:43 PM
yes so I have 1 file called O0001
it only has one subroutine.

but when i call this in the MDI:
M98 P0001

it tells me it cant find the file.

my file is saved here.
C:\Mach4Hobby\Subroutines\O0001

without the .txt extension.

but mach tells me it cant find the file.

the contents of O0001 are very simple:

%
O0001
(test)
G91 X1
M99
%

I wonder what could be going wrong.
Title: Re: subroutines?
Post by: smurph on June 13, 2017, 07:43:50 PM
Because the P word of the M98 call converts 0001 to the numeric value of 1.  So don't use leading zeros in the sub name (and file name) and it will all be good.  e.g. It will find O1 in a filed called O1 in the Subroutines directory.

Steve
Title: Re: subroutines?
Post by: a3dcreator on June 13, 2017, 07:53:36 PM
omg..
that just makes sense. lmao
I will try that tonight. Thank you so much!
Title: Re: subroutines?
Post by: eurohoppel on July 15, 2017, 09:41:14 AM
Hi,
i work with the subroutines since mach3 on the begining on mach4 too but since i have installed the new develop version for test it´s gone!

i allways get the error : File "C:\Mach4Hobby\Subroutines\Sub program test\subtest.tap", Line 28: Feature not licensed !!!

Is it now an feature in the industrial version so we have to pay extra?  :o :(

I have tryed out: uninstall mach4 and install mach4 new ( the official version ion the downloadpage) . I figured out, on the license that the PC ID has changed. But i haven´t changed the computer or  anything esle on my machine!

I can do what i want but the funktionality of M98 M99 is gone!

What´s happend? any ideas?
thanks for your help!
Title: Re: subroutines?
Post by: a3dcreator on July 15, 2017, 09:50:09 AM
are you using arguments in your subroutines?
you can only run subroutines without arguments in mach4 Hobby.
Title: Re: subroutines?
Post by: eurohoppel on July 15, 2017, 10:13:20 AM
Hi,
For my Test i used the original subroutine Test how you can find under the mach4/subroutine folder!
And normaly this should work!?!
Title: Re: subroutines?
Post by: smurph on July 15, 2017, 02:50:19 PM
Nothing has changed.  Subroutines work in Hobby with M98 and M99, just not with G65 and G66.  Also, conditional G code is an industrial feature that is not in hobby.  What you are seeing is the WHILE (line 28) in the embedded subroutine causing the "feature not licensed". 

Perhaps the example is not the best.  I will make it so that it works in hobby by taking out the WHILE loop. 

Steve
Title: Re: subroutines?
Post by: eurohoppel on July 15, 2017, 06:28:28 PM
Hi Steve,
thanks for your information! It works!
At my test´s with the new develop version i had no own program by my hand at this moment and i always tried with the "subrotine test" so the stone becomes to run.  ;)
Sorry!

Best regards
Uwe