Hello Guest it is March 19, 2024, 03:07:34 AM

Author Topic: Is it possible to call one GCODE file from another?  (Read 1656 times)

0 Members and 1 Guest are viewing this topic.

Is it possible to call one GCODE file from another?
« on: April 14, 2019, 12:31:00 PM »
I have a few operations that I perform regularly on different parts. I would like to know if I can create a GCODE file to perform an operation then call that GCODE file.

Basically I create a hole for a countersunk 1/4" cap head bolt. Can I create a GCODE file that just creates this countersunk hole. Lets call the file BoltHole.NC

Then I have a file called CutPart.NC.

The in CutPart.NC can I call BoltHole.NC file? If so what would the command look like?
Re: Is it possible to call one GCODE file from another?
« Reply #1 on: April 14, 2019, 05:41:19 PM »
Hi,
not directly.

Gcode does not have a required instruction to call another file.
The M98 call however calls a subroutine. The subroutine code must be included in the currently loaded file.
That would mean that each job that you wanted to have this particular op included would have to have a copy
of the code to do the op. That would mean also that if you wanted to change the parameters of the op you would have
to change it in each and every Gcode job which used it. Not ideal.

May I suggest that instead of maing a separate Gcode file BoltHole.NC that you instead have the code included in a macro,
m150 say. Note that the macro code is stored in the macros folder of your profile and therefore any of your Gcode jobs
running under your profile can call m150 at will. Additionally if you wanted to change the parameters of the countersink
you need only change if in one file, namely m150.mcs

You could have multiple macros for different ops.
m150     countersink 1/4 cap head
m151     countersink 5/16 cap head
m152     countersink 3/8 cap head
etc.

Then in your main Gcode job CutPart.NC and you wanted to countersink for a quarter cap head at the current
location you would put a line m150.

Presumably the machine would have to do an m6 to get another tool or drill. Thus it would on entry need to save
the current location, THEN do the m6, THEN return to the saved location, THEN drill the countersink, THEN do another
m6 to restore the original tool, THEN return to the saved location, THEN m150 can return to CutPart.NC .

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Is it possible to call one GCODE file from another?
« Reply #2 on: April 15, 2019, 08:14:17 AM »
The subroutine doesn't have to be in the current G Code file.  It can be placed in the Subroutines folder in the Mach4 directory; then the m98 call will:  go get the code, run it, and on m99 return to the current G Code file.
You could also use Variables in the G Code Subroutine to make adjustments to certain parameters. 
Chad Byrd

Offline reuelt

*
  •  520 520
    • View Profile
Re: Is it possible to call one GCODE file from another?
« Reply #3 on: April 15, 2019, 08:32:48 AM »
I have a few operations that I perform regularly on different parts. I would like to know if I can create a GCODE file to perform an operation then call that GCODE file.

Basically I create a hole for a countersunk 1/4" cap head bolt. Can I create a GCODE file that just creates this countersunk hole. Lets call the file BoltHole.NC

Then I have a file called CutPart.NC.

The in CutPart.NC can I call BoltHole.NC file? If so what would the command look like?

Mach 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:
Format: O____
Note the letter “O” followed by four numbers, and no file extension; O1234 not O1234.txt.
The file must end with M99.

Format: M98 P____ Q__ L__
P specifies the number of the program file to be called. This is a four digit integer number. When the M98 is read Mach scans the current file for a block containing the program number in the following form: Format: O1234

"the gift of God is eternal life through Jesus Christ our Lord"
Re: Is it possible to call one GCODE file from another?
« Reply #4 on: April 15, 2019, 09:02:53 AM »
I've been using the subroutines local to the file, and cutting and pasting them into each file, but as mentioned. Also making a macro would help as well.

Currently for the countersunk bolt hole, I move to a point with the bottom of the bit 1/8" above the top of the material centered on the hole, Then call my sub routine, Which stores current tool, switches to new tool, mills hole, switches back to original tool, returns to position 1/8" above material, centered on hole, does next operation.

When I have a lot of holes to do I have to remember to load the correct tool first or it keeps swapping tools  ::). I usually try to do the holes first before any cutting. Then often times I can use them to mount the part, and don't need to worry about tabs or onion skinning.