Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: ErnieD on February 21, 2009, 04:59:47 PM

Title: Sub Programs
Post by: ErnieD on February 21, 2009, 04:59:47 PM
Hi,

   I have several 5/8 diameter shafts that have to have slots milled across them. I would like to do the slots with a sub program. I have never done a sub program and I am not really proficient in G & M code. Can someone explain where to place the sub program so that it can be called with M98. What I want to do is move to the location for the slot, call the sub program, mill the slot, end the sub program, go to the next slot and repeat until all the slots are done.

Thanks,

        ErnieD
Title: Re: Sub Programs
Post by: BClemens on February 21, 2009, 06:56:46 PM
Is an M98 a necessity? You could write a very simple G code program to do this and include it in a main one with a tool change; or just M1.

Bill C.
Title: Re: Sub Programs
Post by: Chip on February 21, 2009, 07:04:33 PM
Hi, Ernie

Hears an Example to look at.

G90 G80 G40 ;set's Mach to proper mode
G91.1 ;set's Mach to proper mode

G00 x0 y0 z0 ; First Location
M98 P12 L1 ; Subroutine Call,"P" set's file name to "O10", "L" set's repeat times

G00 x0 y1 z0 ; Second Location
M98 P12 L1 ; Subroutine Call,"P" set's file name to "O10", "L" set's repeat times

G00 x0 y0 z0 ; Start Location
M30 ; end & rewind G-code
% ; end of G-code

o12;-----------Subroutine
g91 ; INC mode set
g01 z-.0 f59
g01 z-.05 f59
g01 x-.5 y0 z0 
g01 z-.05 f59
g00 x.5 y0 z0
g01 z.1 f50
G90 ; ABS mode set
m99 ; ---- Subrutine Return
%

Chip