|
6.1. G-codes
The virtual machines in CNC Simulator Pro use default standard codes. However, please note that customized machines may have other codes and formats.
The following tables provide an overview of the various G, M, and other codes recognized by the CNC Simulator Pro interpreter. The Format column specifies the expected format for each code. If a code is written within brackets, like this [X#], it means that the code is optional and can be omitted if not needed. The # sign indicates that CNC Simulator Pro expects a number, and the $ sign indicates that it expects a text string within quotation marks.
Let's show an example:
G12[X#][Y#]Z# R# Q# S# SA# AS# RA# H#
The above G12 code accepts X and Y coordinates, but they are not mandatory and can be omitted. However, to avoid an alarm at runtime, you must specify the Z, R, Q, S, SA, AS, RA, and H codes.
G-code
|
Explanation
|
Format
|
Example
|
Machine type
|
G00
![]() |
Go rapidly (with maximum traverse rate) to the X/Y/Z position. This code is used for positioning and not for actual machining.
|
G00 [X#][Y#][Z#]
|
G00 Z100
|
All machines
|
G01
![]() |
Travel in a straight line using the programmed feed rate (F). This code is used for machining.
|
G01 [X#][Y#][Z#][F#]
|
G01 X2.5 Y4.1 F200
|
All machines
|
G02
XY-machines
![]() Lathe
![]() |
Circular/Helical Interpolation clockwise. It causes a clockwise circular movement at the programmed feed rate (F). The motion can be 2-dimensional (flat) or 3-dimensional (helical). The default plane of the circular movement is the XY-plane (G17), but other planes can be used as well (see G17-G19). The center of the arc or circle is programmed using the I, J, and K letters (R can also be used).
|
G02[X#][Y#][Z#]
[I#][J#][K#][R#][F#]
|
G02 X10 Y10 I10 J0 F200
|
All machines
|
G03
XY-machines
![]() Lathe
![]() |
Exactly like G02, but the circular motion is going counterclockwise.
|
G03[X#][Y#][Z#]
[I#][J#][K#][R#][F#]
|
G03 X10 Y10 I10 J0 F200
|
All machines
|
G04
![]() |
The dwell command specifies a period of time in milliseconds during which the axes will remain stationary. The duration is determined by the value of the P number.
|
G04 P#
|
G04 P2000 (Two seconds delay)
|
All machines
|
G09
|
The G09 code will cause the machine to come to a complete stop before executing the next move. This is a non-modal variant of G61 and does not require cancellation.
|
G09
|
|
All machines
|
G12
![]() |
Circular drilling canned cycle. Used to drill holes around the contour of a circle. R is the starting plane, and Z is the total drill depth for each hole. Q is incremental depth (peck). SA is the circle start angle (angle of the first hole, too), and AS is the angle between holes. RA is circle radius, and H specifies the number of holes to drill.
|
G12[X#][Y#]Z#
R# Q# S# SA#
AS# RA# H#
|
G12 X0 Y0 Z-20 R2 Q5 SA0 AS36 RA30 H10
|
Milling machines only
|
G15
|
Cancel polar coordinates mode. See example file 25.
|
G15
|
G15
|
Milling machines only
|
G16
|
Activated polar coordinates mode. See example file 25.
|
G16
|
G16
|
Milling machines only
|
G17
![]() |
Selects the XY plane for circular movements (see G02 and G03).
|
G17
|
G17
|
Milling machines only
|
G18
![]() |
Selects the XZ plane for circular movements (see G02 and G03)
|
G18
|
G18
|
Milling machines only
|
G19
![]() |
Selects the YZ plane for circular movements (see G02 and G03).
|
G19
|
G19
|
Milling machines only
|
G20
|
Enforce the use of inch units.
|
G20
|
G20
|
All machines
|
G21
|
Enforce the use of millimeter units.
|
G21
|
G21
|
All machines
|
G28
|
Return home command. This command will first go to the programmed position X/Y/Z and then to the Xmin Ymax Zmax of the machine axes. It can be a convenient way to end a program putting the machine table in a position to change workpiece.
|
G28[X#][Y#][Z#]
|
G28 Z10
|
Milling and turning machines only
|
G40
![]() |
Cancel cutter compensation previously activated by G41 or G42.
|
G40
|
G40
|
All machines except the 3D Printer
|
G41
![]() |
Activates left-side cutter compensation (or nose radius compensation in a lathe).
|
G41[D#][P#]
|
G41
|
All machines except the 3D Printer
|
G42
![]() |
Activates right-side cutter compensation (or nose radius compensation in a lathe).
|
G42[D#][P#]
|
G42
|
All machines except the 3D Printer
|
G43
|
Activates tool length offset compensation. (Optional, if not used, automatic tool length compensation will be used.)
|
G43[H#][P#][Z#]
|
G43 H2 Z2
|
Milling machines only
|
G49
|
Cancel tool length offset compensation (activated by G43).
|
G49
|
G49
|
Milling machines only
|
G52
|
Local zero shift. This code is used to locally shift the zeropoint from the main work offset. To reset the shift, use G52 X0 Y0 Z0.
|
G52 [X#][Y#][Z#]
|
G52 X50 Y50
|
Milling machines only
|
G53
|
Move in absolute non-compensated coordinates.
|
G53 [X#][Y#][Z#]
|
G53 X0 Y0 Z100
|
All machines
|
G54-G59
|
Fixture (work) offsets. A typical use of these G-codes is to establish a local coordinate system for each workpiece when using multiple ones. You need to setup the offsets in the Zero Points Data table in the Inventory Browser (F2).
G54 corresponds to offset registry index 0, G55 to index number 1, etc…
|
G54
|
G00 G54 X0 Y0 Z3
|
All machines
|
G54.1
|
Fixture (work) offsets. A typical use of these G-codes is to establish a local coordinate system for each workpiece when using multiple ones. You need to setup the offsets in the Zero Points Data table in the Inventory Browser (F2).
G54.1 uses the letter P to specify the offset registry index.
|
G54.1 P# (0-99)
|
G54.1 P10 (Use work offset 10)
|
All machines
|
G61
|
Exact stop mode.
In this mode, the machine will come to a complete stop after each movement to produce sharp corners. The mode is modal and can be canceled by G64.
|
G61
|
G61
|
All machines
|
G64
|
Normal stop mode (cancels G61). Sets the machine back in normal cutting mode canceling any previous programmed G61
command.
|
G64
|
G64
|
All machines
|
G65
|
Direct call of a macro. P is the macro number to be called. For more information, see Macro programming.
|
G65 P# A... B... C... etc.
|
G65 P1005 A180
|
All machines
|
G66
|
Initiates modal calling of a macro defined by P. The macro will not be called in the G66 block but rather after each tool move following the block. Cancel with G67. For more information, see Macro programming.
|
G66 P# A... B... C... etc.
|
G66 P7000
|
All machines
|
G67
|
Cancels any modal macro call initiated by G66. For more information, see Macro programming.
|
G67
|
G67
|
All machines
|
G68
|
Activates rotation of the coordinate system.
Two syntaxes are allowed.
Use G69 to cancel the rotation.
|
G68 X(center in X) Y(center in Y) R(angle)
or
G68 A(center in X) B(center in Y) R(angle)
|
G68 X50 Y50 R45
|
Milling machines
|
G69
|
Cancel the rotation of the coordinate system.
|
G69
|
G69
|
Milling machines
|
G70
|
Finishing Cycle.
After roughing, finishing can be performed with this cycle. P is the first block of finishing contour, and Q is the last block.
For more information, see: G71 Rough Turning Cycle and G70 Finishing Cycle.
|
G70 P# Q#
|
G70 P100 Q250
|
Turning machines only
|
G71
|
Rough Turning Cycle
Two block format Roughing cycle.
For more information, see: G71 Rough Turning Cycle and G70 Finishing Cycle.
|
G71 ...
|
N10 G71 U2 R1
N20 G71 P8 Q9 U0.4 W0
|
Turning machines only
|
G73
![]() |
Peck drilling canned cycle. The cycle is intended for deep drilling or chip breaking milling operations. The cycle retracts the tool to break chips. Code letter Q is used for peck size. R is the starting plane, and Z is total depth. Parameter P is used for dwell at each peck. Please note that at the end of the cycle, the return position in Z is controlled by G98 and G99.
|
G73 [X#][Y#][Z#]
[R#][Q#][P#]
|
G73 Z-20 R1 Q1 P100
|
Milling machines only
|
G74-G75
|
Generic drilling/boring/tapping canned cycle. These are used in a generic way to create compatibility with many common CNC controllers on the market. They will bring the tool to the programmed Z depth. If R is programmed, it will be used as the start plane, if not, the current Z position will be used as the start plane. All other parameters will be ignored.
|
G74 [X#][Y#][Z#][R#]
|
G74 Z-20 R1
|
Milling and turning machines only
|
G76
|
Generic drilling/boring/tapping canned cycle. See G74-G75 above.
|
G76 [X#][Y#][Z#][R#]
|
G76 Z-20 R1
|
Milling machines only
|
G76
|
Threading Cycle
For more information, see: G76 Lathe Threading Cycle
|
G76
|
G76
|
Turning machines only
|
G80
|
Cancels any canned cycle. Please note that G00 – G03 also cancels canned cycles.
|
G80
|
G80
|
Milling and turning machines only
|
G81
![]() |
Basic drilling canned cycle. R is the starting plane, and Z is total depth. Please note that at the end of the cycle, the return position in Z is controlled by G98 and G99.
|
G81 [X#][Y#][Z#][R#]
|
G81 Z-6 R2
|
Milling and turning machines only
|
G82-G89
|
Generic drilling/boring/tapping canned cycle. Same as G74-G76 above.
|
G82 [X#][Y#][Z#][R#]
|
G82 Z-20 R1
|
Milling and turning machines only
|
G90
|
Absolute programming mode. Distances given will move the tool relative to an absolute zero.
|
G90
|
G90 G00 X10 Y10
|
All machines
|
G91
|
Incremental programming mode. Distances given will move the tool relative to the current position of the tool.
|
G91
|
G91 G00 Z5
|
All machines
|
G92
|
Set Max Rmp
|
G92 S#
|
G92 S2000
|
Turning machines only
|
G92
|
Use to reposition the origin point (zero point).
|
G92[X#][Y#][Z#]
|
G92 X20 Y20 Z10
|
All machines
|
G94
|
Set feed in millimeters or inches per minute.
|
G94
|
G94
|
Milling and turning machines only
|
G95
|
Set feed per revolution mode.
|
G95
|
G95
|
Milling and turning machines only
|
G96
|
Constant surface speed control.
|
G96[S#]
|
G96 S300
|
Turning machines
|
G97
|
Cancel constant surface speed control.
|
G97
|
G97
|
Turning machines
|
G98
![]() |
Initial level returns at the end of a canned cycle.
|
G98
|
G81 G98 Z-7 R2
|
Milling and turning machines only
|
G99
![]() |
R level return at the end of a canned cycle.
|
G99
|
G81 G99 Z-7 R2
|
Milling and turning machines only
|