Mach4 Lathe G Code and M Code Reference
Mach4 Lathe G Code and M Code Reference
Code Reference
Chapter 1: Introduction
G-Code is a special programming language that is interpreted by Computer Numerical Control
(CNC) machines to create motion and other tasks. It is a language that can be quite complex at
times and can vary from machine to machine. The basics, however, are much simpler than it first
appears and for the most part follows an industry adopted standard. Mach4 has made a large leap
closer to this standard.
An important point to remember when reading this manual: In describing motion of a machine it
will always be described as tool movement relative to the work piece. In many machines the work
piece will move in more axes than the tool; however the program will always define tool movement
around the work piece. Axes directions follow the right hand rule, see figure A.
Glossary
Block A single line of G-Code
Format
In writing G-Code programs there are some rules to be aware of as well as some general formatting
guidelines that should be followed or at least considered.
The first part of any program should be a safe start up block. This line of code is used to make sure
that some modes are disabled and others are set to their most common setting. An example safe
start block would look like this:
This block of code tells the machine that we want to be in rapid mode and using absolute position
in the ZX plane of fixture offset 1. At the same time we want to cancel tool nose radius
compensation and make sure any active canned cycles are cancelled.
It is recommended that this safe start block be used at the start of the program and also before or
immediately following every tool change. It is common to restart a program from a tool change,
having the safe start line there can greatly reduce the chance of a machine not acting as expected,
the results of which can be aggravating at best and a crash at worst. The safe start block shown
here is just an example. Every machine and every programmer are a little different and each will
have their own start up block.
Jumping to the end of the program there is not a lot required. Typically there will be a couple blocks
of code to return the X and Z axes to a safe position. Shutting off the spindle and coolant or any
other accessories is also a good idea here. The final block in a program is a program end code,
most commonly M30 but there are other options. Make sure this final block is followed by an end of
block. It is easy to forget this last EOB in a program for Mach because it is just a carriage return
and not always readily apparent. One way to make sure that there is always an EOB on your
program end block is to follow it with %. Like this:
M30
%
This percent sign is a familiar symbol to CNC programmers in industry; however any symbol or
character can be used as it will not be read by the control because of the program end before it. If
there is no EOB following the percent sign it will not show up in the program when loaded into
Mach.
In between the start and end is the body of the program. There are a few rules here. Each block of
code will contain a combination of words. Multiple G-Codes can be specified in a single block,
however if more than one from the same modal group is specified the last one in the block will be
valid, with the exception of group 00. Modal G-Codes stay active until another from the same group
is called. For example; G01 is modal so it is not necessary to put it in consecutive blocks. Once
active every successive positioning block will be in the G1 mode unless another code from group
one is called (G00, G02, G03, etc.). All G-Codes not in group 0 behave this way.
Only one M-Code can be specified in a single block. Same holds true for all other words.
Generally leading zeroes are not required in G-Code. For example G01 and G1 are the same. The
same holds true for M-Codes, position commands, feedrates, etc. When specifying values for
position, feedrate, variables, etc., it is good practice to always use a decimal point and trailing zero,
instead of X1 use X1.0. Although the decimal point is not required (in Mach X1 = X1.0) it is HIGHLY
recommended.
G04 0 Dwell N
G20 6 Inch Y
G21 6 Millimeter Y
G32 1 Threading* N
T1 M6 Tool change
Example: Program a feed move from X1.0, Z3.0 to X10.0, Z-1.0 at a feedrate of 15.0 UPM.
T1 M6 Tool change
Next is to specify the radius or the center point of the arc, only one or the other, not both.
To specify the radius, use R and input the actual radius of the desired arc, see Format 2.
When an arc is created knowing only start and end points and a radius there are two
possible solutions, an arc with a sweep less than 180° and one with sweep greater than
180°. The sign of the radius value, positive or negative, determines which arc will be cut,
see figure 2-2. A positive value for R cuts an arc with sweep less than 180°. A negative
value for R cuts an arc with sweep greater than 180°.
A more accurate and reliable way to define an arc is by specifying the center point, this is
done with addresses I, and K, see Format 1. The center point must be defined in the
current plane. I and K correspond to X and Z respectively. Mach has two settings for how I
and K should be specified, absolute and incremental. This setting can be changed by G-
Code, G90.1 and G91.1, or in the general tab in the Mach configuration. If arc center mode
is set to incremental then I and K are the distance and direction from the start point to the
center point of the arc, I is a radius value. If arc center mode is set to absolute then I and
K are the absolute position of the arc center point in the current user coordinate system, I
is a diameter value.
Example: Program an arc centered at X1.0, Z-0.2 in the ZX plane with radius 0.2. Start point at
X1.0, Z0.0 and sweep 90 degrees counter clockwise. Feedrate 0.006 UPR. (Arc center mode set to
incremental)
Format 1:
G0 G54 G18 G40 G80 Safe start line
Format 2:
Lathes with Y axis capability can also make arc moves in other planes. The function of G02 and
G03 remains the same, but the format changes slightly to accommodate the additional axis and
plane options. For specifying the arc center position use J for the Y axis component.
Example: Program a helix with radius 1.0 and center point 0.0, 0.0 in the X,Y plane, start point 0.0,
.5, height 1.0 with initial Z at 0.0. Feedrate 10.0 UPM. Arc sweep should be 270° clockwise. See
figure 2-2 for the tool path.
G04 – Dwell
A dwell is simply a pause in the program. The duration of the dwell is specified by P in seconds. No
machine movement will take place during a dwell. No auxiliary codes will be turned off, i.e. if the
spindle is on it will stay on, coolant will stay on, etc.
Example: Program a stepped shaft, first diameter is 1.0 inch for 2.0 inch length, second diameter is
1.5 inch for 2 inch length. Make sharp corners at X1.5, Z-2.0. Feedrate 0.008 IPR.
Figure 9-1 shows what this shaft would look like, slightly exaggerated.
Starting with fixture offset setting the G10 block will look like the following:
Format (Absolute): G10 L2 P__ X__ Y__ Z__ A__ B__ C__
L selects the function of the G10 block, different values will have different functions. L2 is the
designation for fixture offset setting. The value of P specifies which offset is being set. For the basic
6 fixture offsets P values are as follows:
54 1
55 2
56 3
57 4
58 5
59 6
All values do not need to be specified, only the ones to be set. If, for example, a Z is not
programmed it simply will not be changed in the fixture offset.
When specified in absolute mode (X, Y, Z, C) the values in the G10 line will be directly input into
the fixture offset. When specified in incremental mode (U, V, W, H) the values will be added to the
desired fixture offset. This is a major difference in functionality and care should be taken to make
sure the correct arguments are used for the desired effect.
Example: Set G56 fixture offset to X-8.0, Y-3.0, Z-5.0, C45.0 in a program.
G0 G54 G18 G40 G80 Safe start line
G10 L2 P3 X-8.0 Y-3.0 Z-5.0 C45.0 Set G56 fixture offset values
Additional fixture offsets, G54.1 Pxx, can also be set using G10. Setting of these offsets is the
same, except it is done using L20. The legacy additional fixture offsets (see fixture offset section of
this manual for more details) can still be set with G10. The following table shows the additional
fixture offset P number and its corresponding G10 P number as well as the legacy offsets. Note that
G54.1 P1 is the same offset as G59 P7, so G10 L20 P1 and G10 L2 P7 both set the same offset
values.
G54.1 P__ G10 L20 P__ Legacy G59 P__ Legacy G10 L2 P__
1 1 7 7
2 2 8 8
3 3 9 9
- - - -
- - - -
- - - -
G10 L20 P5 X3.0 Y3.4 Z-10.0 Set G54.1 P5 fixture offset values
Work shift and head shift can also be set with G10. Work shift is set using G10 L2 P0. Head shift is
set using G10 L20 P0. Notice the L20 for head shift. All other values are set in the same format as
the other fixture offsets.
Tool offset setting requires just as much care as setting of fixture offsets. G90 and G91 affect the
setting of offset values in the same way. Specifying in absolute causes the current value to be over
written with the value in the G10 block, while incremental adds the value from the G10 block to the
current value.
For tool geometry offsets:
Again, not all values are required, if omitted that value simply will not be set. L1 specifies tool
geometry offset setting, L3 specifies tool wear offset setting, P is again the offset number to be set
(offset #1 = P1, offset #2 = P2, etc.). The remaining arguments specify the type and value of
offset to be set.
X(U) X offset
Y(V) Y offset
Z(W) Z offset
Example: Set X value of tool offset #5 to -5.0. Add .05 to Z axis wear offset #2.
All arc and circular motion will take place on a single plane. Direction of motion, clockwise or
counterclockwise, is as viewed from the normal direction, see figure 17-2.
Canned drill cycles also require the selection of a plane. In this case all hole positions will be
located in the selected plane and the normal axis will be the drilling axis. For example in the XY
plane the Z axis is the drilling axis.
This is not a modal code and will only be active in the block in which it is specified. Following the
G28 are the axes to be sent home. For example, to send the Z axis back to the home position
program: G28 Z0. The value specified with the axis letter specifies the intermediate point.
Reading through the program there is a safe start up block that sets the machine to absolute
position mode. The next line causes the machine to move to the point X1, Z1. in the coordinate
system set by the G54 fixture offset. Now for the G28 block. This line of code, G28 Z0, gives
instructions to send the Z axis to the home position via the point Z0. The motion will be as follows:
First the Z axis will plunge to the point Z0 then return to home. If not intended this motion could
result in a broken tool or scrapped part. To avoid this unintended motion the common
programming format is as follows:
G91 G28 Z0
In this case the intermediate point is an incremental move of 0 inches resulting in no motion before
the Z axis returns home.
G30 – 2nd, 3rd, 4th Zero Return
G30 functions the same way as G28, moving the machine to a zero return point via an
intermediate point. However, instead of sending the machine to the home position, G30 movement
ends at a user definable 2nd, 3rd, or 4th zero return point, specified by P2, P3, or P4 respectively. If
P is omitted the 2nd zero return point is selected. This is handy for tool changers that are not
located at the home position or any number of other applications.
The position values in the # variables can be set in a program or in MDI mode.
The machine will move toward the specified end point, at the same time it is looking for the probe
input to be activated. When the probe input is activated the current position is recorded to #
variables according to the table below and motion is stopped. The recorded position can then be
used to calculate tool offsets, work offsets, measure parts, etc.
X 5061 5071
Y 5062 5072
Z 5063 5073
A 5064 5074
B 5065 5075
C 5066 5076
G32 – Threading
Equal lead straight, tapered and scroll threads can be cut using the thread cutting command.
Spindle speed feedback from an encoder, index pulse, tachometer or other device is required for
this operation. The syncing of the feed axis to the spindle speed creates an accurate thread;
however, axis acceleration can cause variations in the thread lead especially at the start and end
of the thread. To compensate, program a slightly longer thread to give the axis time to accelerate.
The amount of extra thread length will vary based on machine specifications. Changes in spindle
speed and feedrate will impact thread quality and accuracy. Using constant surface speed mode
can also result in variations in thread lead when cutting tapered or scroll threads, use G97 constant
RPM mode instead. During the threading move the spindle speed and feedrate overrides will be
disabled and the machine will run at 100%. Feed hold will be delayed. If pressed, the machine will
stop at the end of the threading move.
The G32 threading cycle is a single linear move synced to the spindle speed. F specifies the lead or
pitch of the thread. For example a 20 TPI thread would have a pitch of .05 inches, so program F.05.
By default the movement is basic linear move with synced feedrate. By default the lead is assumed
to be along the major axis of the current plane selection; for G17 XY plane lead is along the X axis,
G18 ZX plane is along the Z axis, G19 is along the Y axis. Machine builders and advanced users
have the added option to create custom M-Codes to specify the feed vector to create custom
threads. Address Q specifies the start angle of the thread. This can be used for creating threads
timed to a feature of the part or for cutting threads with multiple starts. This feature requires
position feedback from the spindle, the accuracy of the feedback will determine the accuracy of the
start angle. Not all machines will have this capability.
Threads can also be cut with a taper by adding the proper end point.
For detailed information see the cutter compensation section of this manual, chapter 6.
G50 – Minimum and Maximum Spindle Speed
In the G96 constant surface speed (CSS) mode the spindle RPM will vary based on current X
position. The spindle speed will increase as the diameter gets smaller and decrease as the
diameter gets bigger. Machining in this mode can produce superior finishes and accuracy.
However, some setups can only handle a certain RPM range. Castings, or similar near net shape
stock, is a prime example of this. An unbalanced part can create harsh vibration when spun over a
certain RPM. In cases like these the maximum RPM can be limited using G50 while still being able
to take advantage of the benefits of CSS mode.
In this format S specifies the maximum spindle speed. It is also possible to specify a minimum
spindle speed using Q.
Specify the axis to be scaled and the desired scale factor. For example:
When scaling is active position moves will be calculated by multiplying the commanded position by
the scale factor. In the example above the scale factor on the X axis is set to 2, then a move to X5.
is commanded. The actual end position of this move will be 5 * 2 = 10. So the X axis moves to 10.
Exercise caution when using scaling, the results can be unpredictable depending on program
complexity. For example if G52 X2 Y4 is programmed followed by an arc move in the XY plane, the
arc will NOT be scaled 2x in the X axis and 4x in the Y axis to obtain an ellipse. The start and end
positions will be as expected, but the motion from one to the other may not be. Check and double
check the tool path display before running the program.
To activate a local coordinate system with G52 use the above format. Setting of a local coordinate
system is just like setting a fixture offset. In the G52 block specify the desired axes to set, and the
value of the shift. For example (see figure 52-1 for the tool path):
… Body of program
In the example above, the last two positioning moves are made in the machine coordinate system.
These two blocks could be the same for every program in this machine.
Previous version of Mach use G59 P7, P8 and so on. These legacy offsets can still be used in place
of the G54.1. G59 P7 = G54.1 P1, G59 P8 = G54.1 P2, and so on. G54.1 is more consistent with
industry machines.
Please see the fixture offset section of this manual for more detail on setting up fixture offsets.
Axis # Variable
X 5440
Y 5441
Z 5442
A 5443
B 5444
C 5445
When unidirectional approach is used in a drill cycle the Z axis motion is not affected. G76 and G87
boring cycles have a tool shift that is also not affected by the G60 unidirectional approach.
P–Three part word each section will be divided as (m) (r) (a) in their respective order.
(r) = The amount of chamfer for the machine to pull out of the thread. The r value will be multiplied
by the pitch to calculate the position to start pulling out. An r value of 05 (0.5) will cause the thread
to pull out in half a pitch.
Example: 2 Spring passes, retract in 1 pitch, 60 degree thread would be represented as: P021060
K–Cutting method
K = 2: Flank in-feed constant depth removal for each pass (each pass same as first pass)
K = 3: Alternate flank in-feed constant depth removal for each pass (each pass same as first pass)
P–Height of thread
F–Lead of thread
Example: Thread a UNC 0.50-13” rod held in the spindle, 0.75” length of thread.
Example: Program an arc centered at 1.0, 0.0 in the XY plane with radius 2. Start point at 3.0,0.0
and sweep 90 degrees counter clockwise. Program two times, once in incremental arc center mode
and once in absolute arc center mode.
Using the above format specify a value for the desired axis. When G92 is specified the position
DRO’s are updated to the values specified. The local coordinate system setting will be cancelled
when a G92.1 is specified or the system is reset.
G92 X1.0 Y2.0 Z3.0 Set local coordinate system, current position X1, Y2, Z3
G92 was used for fixture offset setting before fixture offsets were available. It is recommended that
the fixture offsets be used instead of using G92. The offset amount of the G92 setting is not
immediately known by the user, because of this the results can be unpredictable when fixture
offsets and G92 are combined.
When inverse time feed is active an F word is required in every block of code containing a feed
move.
There are two sets of hole machining canned cycles available for use, the standard lathe set and an
advanced set. In the standard set the drilling direction is set by the code called, the current plane
selection does not determine the drilling axis. For the face machining cycles the Z axis will always
be the drilling axis and for side machining cycles the X axis will always be the drilling axis. In the
advanced cycles the current plane selection determines the drilling axis.
For the advanced cycles positioning will take place in the active plane, and the drilling operation
will be on the normal axis. For example in G17 (XY Plane) hole position will be on the XY plane and
the drilling axis will be Z. In G18 (ZX Plane) positioning will be on the ZX plane and the drilling axis
will be Y. Specifying G19 (YZ Plane) selects the X axis for the drilling axis and positioning will be on
the YZ plane. For the purposes of this manual all advanced cycle examples and definitions will be in
the XY plane (G17).
When the canned cycle is complete the machine will return to a final position in the drilling axis,
either the initial point or the R point as determined by the G98.1/G99.1 setting.
Axis positions can be programed in the absolute or incremental modes; specify X, Y, Z, C for
absolute and U, V, W, H for incremental. All active machine axes are allowed for positioning, some
axes have been left out of examples for clarity.
Absolute:
Xxn
G80
Incremental:
Uun
G80
cc Number of the desired canned cycle (i.e. 83, 84, 85, etc).
ll Number of repetitions
ff Feedrate
Please note that not all arguments will appear in all cycles, and there are a couple special cases
that will be discussed.
Drilling
G83 – Face Drilling
The face drilling cycle allows drilling holes in the face of a part; the Z axis is always the drilling axis.
Shallow holes can be straight drilled, or with the addition of address Q deep holes can be peck
drilled. For straight drilling cycle use format 1, for deep hole peck drilling cycle use format 2. See
figure 83-1 for a graphic of the tool motion.
X – Position of hole
R – Retract plane
Q – Peck depth
P – Dwell time
L – Number of repetitions
F – Feedrate
Example: Spot drill hole A from figure 102 and then drill to depth.
G83 G99.1 X0.0 Z-1.0 R0.25 Q0.20 F0.008 Drill cycle start
Z – Position of hole
R – Retract plane
Q – Peck depth
P – Dwell time
L – Number of repetitions
F – Feedrate
Example: Spot drill holes C from figure 102 and then drill to depth.
G87 G99.1 Z1.97 C0.0 X2.30 R3.0 F0.01 Drill cycle start
G87 G99.1 Z-1.97 C0.0 X1.50 R3.0 Q0.20 F0.008 Drill cycle start
Tapping
G84 – Face Tapping
A cycle for creating threaded holes in the face of a part using a tap; the Z axis is always the
tapping axis. For the tapping cycle the spindle is started in the clockwise direction. When the
bottom of the hole is reached the spindle reverses for retraction. Changes to feedrate or spindle
speed mid cycle can be damaging to the tool and work piece, for this reason the feedrate and
spindle speed overrides are disabled. The machine will run at 100% override for the duration of the
cycle. Feed hold is also disabled during the cycle. If feed hold is pressed motion will stop when the
tool reaches the retract point.
Tapping requires synchronization of the spindle speed and feed rate to create the correct thread
form. The feedrate can be programmed in either feed per minute mode, G98, or feed per revolution
mode, G99. In the feed per rev mode the commanded feedrate will be simply the pitch of the
thread. Metric threads are classified with the thread pitch, i.e. M8x1.25mm thread has a 1.25mm
pitch. Unified threads are classified by threads per inch which requires a bit of calculation to get
the pitch, don’t worry it’s easy. Simply divide 1 inch by the TPI. For a ¼-20 fastener we would
calculate 1/20 = .05, this is the pitch. The catch is, to use feed per rev requires some form of rpm
feedback from the machine, not every machine will have this. For the machines without feedback
the tapping cycle can be programmed in feed per min mode (G98). This method requires a little
more math to obtain the correct feedrate based on spindle rpm and pitch of the thread. The
equation looks like this: RPM*Pitch=IPM. To tap that ¼-20 hole at 1500 RPM we first need to
calculate the pitch, remember 1/TPI = Pitch, so 1/20=.05. Now we calculate the feed per min as
1500 * .05=75 IPM. It is important to note that if the spindle speed is changed, the feed per minute
must also be changed to match. For this reason, if the machine is capable of feed per rev
programming use it.
X – Position of hole
R – Retract plane
P – Dwell time
L – Number of repetitions
F – Feedrate
Example:
Create the program to tap hole A shown in figure 102 to a depth of .500 with a ¼-20 tap using
feed/min.
Boring
G85 – Face Boring
Boring a hole provides superior size and position accuracy as well as much finer finishes. Generally
a boring bar is used of either an adjustable or non-adjustable type. When the boring cycle is
activated the machine will drill down to the desired depth at the specified feedrate. The retract
move will be at twice the programmed feedrate. The G85 cycle is for boring holes in the face of a
part, the Z axis will always be the drilling axis.
X – Position of hole
R – Retract plane
P – Dwell time
L – Number of repetitions
F – Feedrate
Z – Position of hole
R – Retract plane
P – Dwell time
L – Number of repetitions
F – Feedrate
G89 G99.1 Z1.97 C0.0 X2.00 R3.0 F0.003 Bore cycle start
There are two G-Codes used to enable cutter compensation. G41 offsets the tool to the left of the
tool path and G42 offsets the tool to the right of the tool path. This is only true for positive
diameter offset values. If negative offset is specified the offset direction will be reversed, see figure
41-1. There are two ways to call the offset value with G41 and G42.
Use D to call a diameter offset from a specific tool offset number. For example, D2 will use the
diameter offset value of tool offset number 2. An alternative is to use P. The value specified with P
will be the actual offset value. For example, P.05 will offset the tool path .05 to the left or right.
Cutter compensation only works on the two in plane axes, so for G17 (XY plane) the X and Y axes
are affected by the comp, G18 ZX and G19 YZ.
There are two types of milling, which style is used determines how the tool should be
compensated. The two types are climb milling and conventional milling, see figure 41-1.
Conventional milling is the standard in manual machines, but with CNC it is possible and
recommended to climb mill when possible. This manual will assume the tool will always be climb
milling. With that assumption if G41 is used for outside features, the profile of a part, then a
positive offset will make the part bigger and a negative offset will make the part smaller. For inside
features, a hole, G42 will make the hole bigger with a positive offset and smaller with a negative
offset, see figure 41-2. This method tends to make the offset values more intuitive for the operator.
If conventional milling is used, this description will be reversed.
Cutter comp should be enabled on a linear lead-in move; an error will be produced if cutter comp is
enabled in a block with an arc. If there is a value other than zero in the offset then this lead-in
move may not be parallel to the programmed path, see figure 41-1, 41-6 and 41-7. The end point
of the start block is the point at a 90° angle to the movement in the next block and at the offset
distance. See figure 41-3 for examples. This linear move must be longer than the offset amount, if
it is not there will be an error. Also, if there are any segments of the tool path shorter than the
offset amount a gouge is likely, see figure 41-4. The tool path display in Mach will display the
actual tool path with comp, check to make sure there are no gouges or abnormalities before
running a part.
Figure 41-4 shows three tool paths generated by the same program with different cutter
compensation offset values. The gouge is created when an offset value greater than the step of .10
is input. When this happens the compensated tool path over laps and is reversed, causing a gouge.
Another example of this is in small grooves as shown in figure 41-5.
Cutter compensation is cancelled by specifying G40 in the program, or when the control is reset.
When G40 is specified it should be on a lead-out move following the same rules as when
compensation is enabled. The path will be determined as shown in figure 41-3. Errors will occur if
the lead-out distance is smaller than the offset amount or if G40 is specified on a block containing
an arc move.
M-Code Descriptions
M00 – Mandatory Program Stop
To pause a program at any point specify an M00. All motion will be halted and the spindle stopped.
To resume operation press the cycle start button. A message can be included to display on the
screen as well: M00 (This message will be displayed)
P specifies the number of the program 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
Note that the letter “O” is used to specify the program number 1234, NOT the number “0”.
Program execution will continue with the block following the O number. For this method the
subprogram should be below the end of the current program:
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:
Format: O____
Note the letter “O” followed by four numbers, and no file extension; O1234 not O1234.txt. When
the program is loaded this file will be found and loaded into the memory, the tool path display will
reflect what is in the subprogram. When running the file the M98 block will be read and program
execution will continue with the first block of the subprogram file.
The arguments Q and L are optional. Q specifies the sequence number in the subprogram to start
at. If Q is omitted then execution will start at the beginning of the sub program; see figure 198-1. L
is the number of repetitions. For example, if L=2 the subprogram is run two times before
execution of the main program continues. If L is omitted the program will run only once.
M99 specified in a subprogram will return to the main program at the block immediately following
the M98 subprogram call. The addition of a P in the M99 block will return to a desired sequence
number in the main program. See figure 199-1.
Custom M-Codes
Every machine is a little different and has different functions and options. Custom M-Codes allow
the user to create simple programming calls for complex processes, activating or deactivating
outputs, reading inputs, performing math, or whatever else the user and machine could require.
These M-Codes are programmed in Lua and placed in the macros folder under each profile. Every
profile can have its own unique set of M-Codes. The file name must be the macro to be called. For
example to make a tool change macro, M6, add a Lua script with the filename M6.mcs to the
macros folder in the desired profile. When an M6 is called in a program or in MDI the macro will be
executed.