Instructions
3. Machining the same shape in different locations. Sub programs can be short and simple
or very long and intricate.
EMC2 uses “o” codes (this is the letter o, it is not Zero) for programming sub programs.
Sub programs should be written in a g91 incremental format. If g90 was used the sub
program would only run in a single location; however, you could use g90 if you reset
your home position with a g92 before calling up your sub program. This would be a
better choice for long complex sub programs that would be difficult to read if written in
incremental movements. Your choice.
This would be a typical sub program:
o200 sub (the starting code for the sub program within the main program. The word
sub is required)
g91 g01 z-.3 f15.0
g00 z.300
x.25
g01 z-.3
g00 z.3
y.25
g01 z-.3
g00 z.3
x-.25
g01 z-.3
g00 z.3
o200 endsub (the ending code for the sub program within the sub program will locate
the cutter in the exact same spot it was before the sub program was run)
This would be a typical main program that calls a sub program:
In the main program body you will move the cutter to the starting position for the shape
or operation that you want to machine. Then you will call up the sub program using an o-
code. Your program will look something like this:
%
(Program Name)
o200 sub (It’s best to have a standard format and my suggestion is to always enter all
your sub programs at the beginning of your program.)
g91 g01 z-.3 f15.0
g00 z.300
x.25
g01 z-.3
65