CNCSimulator Pro

user guide
×
Menu
Index

6.1. G codes

These are the default standard codes that are used in our normal virtual machines. Please note that customized machines may have other codes and formats.
 
The following tables will give a brief explanation to the various G, M and other codes recognized by the CNCSimulator interpreter. In the Format column, you will see the format expected by the program. If a code is written within brackets like this [X#] it means that the code is non obligatory and can be omitted if not needed. The # sign means that the CNCSimulator expects a number and the $ sign means that it is expecting a text string within quotation marks.
 
Let's show an example:
G12[X#][Y#]Z#R#Q#S#SA#AS#RA#H#
 
This means that the code G12 accepts X and Y coordinates but they are not obligatory and can be omitted. On the other hand, you must specify the Z,R,Q,S,SA,AS,RA and H codes to avoid an alarm at runtime.
 
G-code
(codes valid from V1.0.6.5)
 
Explanation
Format
Example
 
Machine type
 
G00
Go rapidly (with maximum traverse rate) to the X/Y/Z position. This code is used for position 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 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
Dwell in milliseconds. This will keep the axes unmoving for the period of time specified by the P number.
 
G04 P#
 
G04 P2000 (Two seconds delay)
 
All machines
 
G09
 
Will force the machine to do a full stop before continuing with the next move. This is a non-modal variant of G61 and hence does not have to be cancelled.
 
G09
 
 
All machines
 
G12
Circular drilling canned cycle. Use to drill holes around the contour of a circle. R is starting plane and Z is total drill depth for each hole. Q is incremental depth (peck). SA is circle start angle (angle of first hole too) and AS is 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
 
G17
Selects the XY plane for circular movements (see G02 and G03).
 
G17
 
G17
 
Milling machines only
 
 
Selects the XZ plane for circular movements (see G02 and G03)
 
G18
 
G18
 
Milling machines only
 
 
 
 
 
Selects the YZ plane for circular movements (see G02 and G03).
 
G19
 
G19
 
Milling machines only
 
G20
 
Enforce use of inches  units.
G20
 
G20
 
 
All machines
 
G21
 
Enforce 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 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 compensation (activated by G43).
 
G49
 
G49
 
 
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 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.
 
G61
 
G61
 
 
All machines
 
G64
 
Normal stop mode (cancels G61)
 
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 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 model macro call initiated by G66. For more information, see Macro programming.
 
G67
 
 
All machines
 
G68
 
Activates rotation of the coordinate system.
 
Two syntax 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)
 
 
Milling machines
 
G69
 
Cancel the rotation of the coordinate system.
 
G69
 
 
Milling machines
 
G70
 
Finishing Cycle.
 
After roughing, finishing can be performed with this cycle. P is first block of finishing contour and Q is the last block.
 
 
G70 [P#][Q#]
 
G70  P100 Q250
 
Turning machines only
 
G71
 
Rough Turning Cycle
 
Two block format Roughing cycle.
 
 
G71
 
G71
 
 
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 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#]
 
 
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 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
 
Use to reposition the origin point (zero point).
 
G92[X#][Y#][Z#]
 
G92 X20 Y20 Z10
 
All machines
 
G94
 
 
Set feed in millimeter or inch 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 return 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