G-Code Manual: Drufelcnc, 2020

Download as pdf or txt
Download as pdf or txt
You are on page 1of 31

G-code manual

DrufelCNC, 2020
Content

Annotation .................................................................................................................. 4

G00 - Accelerated movement...................................................................................... 5

G01 - Linear interpolation ........................................................................................... 5

G02 - Circular interpolation ......................................................................................... 9

G03 - Circular interpolation ......................................................................................... 9

G04 - Pause ............................................................................................................... 15

G10 - Enable data entry mode................................................................................... 15

G17 - XY plane selection ............................................................................................ 17


G18 - XZ plane selection ............................................................................................ 17
G19 -YZ plane selection ............................................................................................. 17

G20 - Input inch data................................................................................................. 21

G21 - Enter metric data ............................................................................................. 21

G31 - Movement of axes to a given position ............................................................. 21

G38.n - Straight probe ............................................................................................... 23

G50 - Scale mode ...................................................................................................... 23


G51 - Scale mode ...................................................................................................... 23

G53 - Disabling the offset of the origin of the coordinate system ............................. 25

G68 - Rotate coordinate system ................................................................................ 25

G69 - Cancel Rotation ............................................................................................... 26

G80 - Cancel Canned Cycle ........................................................................................ 27

G81 - Simple Drilling Cycle ........................................................................................ 27

G82 - Drilling Cycle with Dwell .................................................................................. 28

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 2


G90 - Absolute positioning mode. ............................................................................. 29

G90.1 - Absolute distance mode for I , J and K offsets. .............................................. 29

G91 - Relative positioning mode. .............................................................................. 30

G91.1 - Incremental distance mode for I, J and K offsets........................................... 30

G98 - Canned Cycle Return or Feed Rate Modes ....................................................... 31


G99 - Canned Cycle Return or Feed Rate Modes ....................................................... 31

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 3


Annotation

This document is a G code user guide. These G-codes can be used in the DrufelCNC
software. G-code is a programming language for numerically controlled machines
and machine tools.

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 4


G00 - Accelerated movement.

Code G00 is used for faster movement. Accelerated movement is necessary for quick
movement.
The speed of the tool is too high and inconsistent!
The use of the G00 code reduces the overall processing time.

G01 - Linear interpolation

Code G01 is designed to perform tool movement in a straight line at a given speed.
The main difference between the G01 code and the G00 is that with linear
interpolation, the tool moves at a given speed. Movement speed is indicated by the F
command. Conventionally, a frame for linear interpolation is written as follows:

G01 Xn.n Yn.n Zn.n F n.n


G01 Xn.n Yn.n Zn.n An.n Bn.n Cn.n Fn.n

Consider the following simple program:

X0Y0 - zero position


G00X0Y0Z-5 - lowering the cutter along the z axis by -5mm
G01X30Y50F50 - moving the tool to a point (30; 50) with a working feed speed of 50
mm / min
G00X30Y50Z10 - raising the cutter along the z axis by 10mm

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 5


Let's complicate the program a bit. Let's write a program cutting a polygon.

G00Z10 ;raise the cutter to a safe position from the workpiece


G00X0Y0 ;zero position
G01X0Y0Z-5F50 ;lowering the cutter along the axis on z by -5 with a working feed
speed of 50 mm / min
G01X30Y50F50 ; moving the tool to a point (30; 50) with a working feed speed of 50
mm / min
G01X30Y100 ;moving the tool to a point (30; 100)
G01X0Y150 ;moving the tool to a point (0; 150)
G00X0Y150Z10 ;raising the cutter along the axis by z by 10
G00X0Y0 ;move to zero position

The speed value can be set once. You can also shorten your code. Short code will
look like this:

G00Z10
G00X0Y0
G01Z-5F50

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 6


G01X30Y50
G01Y100
G01X0Y150
G00Z10
G00X0Y0

Let's try to write a program for a more complex figure:

G00F300 ;for G00 commands we set the speed to 300


G01F300 ;for G01 commands we set the speed to 300
M03S24000 ;turn on the spindle at a speed of 24000 rpm
G00Z3 ;raise the cutter to a safe position
G00X25.325Y47.45 ;moving the tool to a point (25.325; 47.45)
Z-0.03 ;axis milling cutter axis z -0.03
X31.275Y29.275 ;move tool to point
X50.675Y29.325 ;moving the tool to a point
X34.95Y18.125 ;move the tool to a point
X41Y0 ;move tool to point
X25.325Y11.25 ;move tool to point
X9.625Y0 ;move tool to point
X15.675Y18.125 ;move tool to point
X-0.05Y29.325 ;move the tool to a point
X19.35Y29.275 ;moving the tool to a point
X25.325Y47.45 ;move the tool to a point
G00Z3 ;raising the cutter along the axis by z by 3
M05 ;spindle shutdown
G00X0Y0 ;move to zero position

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 7


DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 8
G02, G03 - Circular interpolation

Codes G02 and G03 are designed to perform circular interpolation. G02 command is
used to move in an arc clockwise, and G03 - counterclockwise.

The direction of movement is determined when we look at the tool from the spindle
side, in the negative direction of the Z axis. As with linear interpolation, in the
circular interpolation block, you must specify the feedrate F.

There are two ways to form a circular interpolation frame:


 setting the center of the circle using I, J, K;
 setting the radius of the circle with R.

Arc with I, J, K
For a complete description of the arc, it is not enough to specify only the coordinates
of its end point. You must also specify the coordinates of the center.

I, J, K are used to determine the center of the arc

Using I, J, and K, you specify the relative (incremental) distances from the starting
point of the arc to its center.

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 9


You must specify a positive value for I and a negative value for J

You must specify a positive value for I and a positive value for J

Arc with R

A simpler way to specify the center of the arc is based on applying the address R
(radius). To unambiguously determine the shape of the arc, you must specify the
corresponding sign in front of the numerical value of the radius R. For an arc that is
greater than 180 °, the value of R will be negative. For an arc that is less than 180 °,
the R value will be positive.

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 10


Since the arc is less than 180 ° (its center is located outside the chord), then R will
have a positive value

Since the arc is greater than 180 ° (its center is located inside the chord), then R will
have a negative value

Using G02 and G03


Let's see how circular interpolation works, using an example. The following fragment
of the control program moves the tool along an arc with a radius of 8 mm from point
A (0; 0) to point B (8; 8) with a working feed speed of 80 mm / min.

G01X0Y0
G02 X8.0 Y8.0 I8.0 J0.0 F80

Since the center of the arc is at a distance of 8 mm along the X axis and 0 mm along
the Y axis relative to the starting point A, then I will be 8.0, and J is 0. The resulting
arc is only a quarter of the full circle. Let's try to describe the whole circle gradually.

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 11


Moving along an arc with R = 8 from point A (0; 0) to point B (8; 8)

The next frame moves the tool from point B (B1) to point B2. Since the feedrate does
not change, there is no need to re-specify the data F-word.
Since the center of the arc is at a distance of 0 mm along the X axis and 8 mm along
the Y axis relative to point B, then I will be 0, and J will be -8. Thus, we were able to
create a displacement along an arc from point A to point B2 using two frames.
Currently, most CNC systems allow you to perform an operation to describe the full
circle in two or even one frame. Therefore, the movement from point A to point C
can be written as follows:

G01X0Y0
G02 X8.0 Y8.0 I8.0 J0.0 F80
G02 X16.0 Y0.0 I-8.0 J0.0

Modern CNC systems allow the description of such an arc in one block
G01X-8Y0
G02 X-8.0 Y0.0 I8.0 J0.0

Full circle description in one frame is also possible.


DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 12
Spiral.

If the XY plane (G17) is activated and the Z word is programmed in the circular
interpolation block, then a spiral forms in the XY plane. The direction of the arc or
spiral in the XY plane can be determined visually.

An example of a spiral:

G01F800
G01X0Y0Z0
G02X0Y0Z-10I38J38
G02Z-20I38J38
G02Z-30I38J38
G02Z-40I38J38
G02Z-50I38J38
G02Z-60I38J38
G02Z-70I38J38
G02Z-80I38J38
G01X10Y10

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 13


An example of a finished program:

G00X0Y0 ;zero position


M3 S6000 ;turn on the spindle at a speed of 6000 rpm
G00Z5 ;raise the cutter to a safe position
G01X14.1421Y-14.1421 ;moving a tool to a point
G01Z-0.5F700 ;moving a tool to a point at a speed of 700
G02X14.1421Y14.1421R-20 ;using the G02 command using R
G01X40.0Y-14.1421 ;moving a tool to a point
G03X40.0Y14.1421R-20 ;using the G02 command using R
G01x14.1421y-14.1421 ;move the tool to a point
G00Z5 ;raising the cutter along the axis by z by 3
M5 ;spindle shutdown
G00X0Y0 ;move to zero position

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 14


G04 - Pause

Command G04 is used to delay control program execution or pause. This modeless
code is used in conjunction with the S- or P-address, which indicates the length of
the exposure time. Usually this time is from 0.001 to 99999.999 seconds.

Code G04, S- or P-address are programmed together in a single block that does not
contain any movements.

If P is used to determine the holding time, then the decimal point cannot be
programmed. Address P determines the holding time in milliseconds, and S in
seconds.

Example:
G04 S1.5 ;shutter speed 1.5 seconds;
G04 P200 ;shutter speed 200 milliseconds.

G10 - Enable data entry mode.

Set new coordinates for the origin

Format: G10 X10 Y10 Z10 A B C

The preparatory function G10 is modal and remains active until it is canceled by code
G11, G53.

Let's look at an example:


G00X0Y0
M3 S6000
G00Z5
G00X45Y45
G01X65Y45
G01X65Y65
G01X45Y65
G01X45Y45
M5
G00X0Y0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 15


Add a line: G10 X10 Y30

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 16


G17, G18, G19 - Plane selection

In CNC programming, there are 3 G-codes for selecting a plane during NC


programming, which are used to define two axes: X, Y or Z. The plane selection is
modal and is valid for everyone until you enter a different circular plane command.

The 3 Plane selection G-Codes are:


G17 for XY Plane
G18 for XZ Plane
G19 for YZ Plane

XY plane selection with G17 code.

The XY G17 plane selection code is set by default and sets the plane to the circular
interpolation mode G02 and G03.

In the circular interpolation blocks, the words X, Y, Z, I and J. are valid. The word K is
not valid. If the Z word is programmed in a circular interpolation block, then a spiral
forms in the XY plane. The direction of the arc or spiral in the XY plane can be
determined visually: Positive direction X - to the right side, positive direction Y - up.
The XY plane has a right-handed coordinate system. In G17, the endpoint of the arc is
defined in the block by the words X and Y. The center point of the arc is defined in
the block by the words I and J.
G17 is activated by default. Code G17 is canceled by codes G18 and G19.

Example:
G17
G00X0Y0
M3 S6000
G00Z5
G01X14.1421Y-14.1421

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 17


G01Z-0.5F700
G02X14.1421Y14.1421R-20
G01X40.0Y-14.1421
G03X40.0Y14.1421R-20
G01X14.1421Y-14.1421
G00Z5
M5
G00X0Y0

XZ plane selection. Code G18

XZ plane selection code G18 sets the plane to circular interpolation mode G02 and
G03. In the circular interpolation blocks, the words X, Y, Z, I and J. are valid. The word
J is not valid. If the word Y is programmed in a circular interpolation block, a spiral
forms in the XZ plane. The direction of the arc or spiral in the XZ plane can be
determined visually: The positive X direction is to the right, the positive Z direction is
up. The XZ plane has a right-handed coordinate system.
Code G18 is canceled by codes G17 and G19.

Example:
G18
G00X0Z0
M3 S6000
G00z5
G01X14.1421Z-14.1421
DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 18
G01Y-0.5F700
G02X14.1421Z14.1421R-20
G01X40.0Z-14.1421
G03X40.0Z14.1421R-20
G01x14.1421Z-14.1421
G00Y5
M5
G00X0Y0

YZ plane selection. Code G19

The YZ plane selection code G19 sets the plane to circular interpolation mode G02
and G03. In circular interpolation blocks, the words X, Y, Z, I, and K are valid. Word I
is not valid. If the word X is programmed in a circular interpolation block, then a
spiral forms in the YZ plane. The direction of the arc or spiral in the YZ plane can be
determined visually: The positive direction Y is to the right, the positive direction Z is
up. The YZ plane has a right-handed coordinate system. In G19, the end point of the
arc is defined in the block by the words Y and Z. The center point of the arc is defined
in the block by the words J and K. Code G19 is canceled by codes G17 and G18.

Example:
G19
G00Y0Z0
M3 S6000
DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 19
G00X5
G01Y14.1421Z-14.1421
G01X-0.5F700
G02Y14.1421Z14.1421R-20
G01Y40.0Z-14.1421
G03Y40.0Z14.1421R-20
G01Y14.1421Z-14.1421
G00X5
M5
G00Y0Z0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 20


G20 G21

G20 - Input inch data


Code G20 activates the mode of working with inch data. While this mode is in effect,
all input data is perceived as inch. It is recommended that in all programs that are
written in inch sizes, put the G20 command at the beginning of the program, so that
if the program that was running before, the metric mode was in effect, ensure that
the correct format is selected.
The command is modal and is valid until canceled by the G21 command.

G21 - Enter metric data


Code G21 activates the metric data mode. While this mode is in effect, all input data
is perceived as metric. It is recommended that in all programs that are written in
metric sizes, put the G21 command at the beginning of the program, so that if the
inch program was in effect before, ensure that the correct format is selected.

G31 - Movement of axes to a given position

The G31 or G31.x command allows you to move the axes to the specified position.
Using command G31 G31 or G31.x requires an encoder.
Movement by command G31 or G31.x is performed either until the specified position
is reached, or until the signal of the additionally installed encoder (skip signal) is
received.

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 21


You can use the X, Y, Z or A axis and specify the end point for that axis. You can
assign any feedrate you want, otherwise the last commanded feedrate will be used.

The probing command will be executed until the probe hits or a certain distance is
covered.
In DrufelCNC, you can use G31, G31.0, G31.1, G31.2, G31.3, G31.4, G31.5, G31.6,
G31.7, G31.8, G31.9 (provided that these sensors are enabled and configured).

G31 - Probe
G31.1 - Probe 1
G31.2 - Probe 2
G31.3 - Probe 3
G31.4 - Probe 4
G31.5 - Probe 5
G31.6 - Probe 6
G31.7 - Probe 7
G31.8 - Probe 8
G31.9 - Probe 9

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 22


G38.n - Straight probe

G38.n Straight probe

G38.2 - Probe towards the workpiece, contact stop, signal error in case of
malfunction
G38.3 - probe towards the workpiece, stop on contact
G38.4 - removal of the probe from the workpiece, stop on loss of contact, error in
case of failure
G38.5 - probe from the workpiece, stop on loss of contact

G50, G51 - Scale mode

The G51 command allows you to use the scale mode in numerical control systems.
For each axis, it is possible to specify a scaling factor.
Command format: G51 X Y Z I J K
I - scale for X
J - scale for Y
K - scale for Z
X Y Z - coordinates of the center of scaling

Command format: G51 X Y Z A B C P


P - scale for axes X Y Z A B C
X Y Z A B C - coordinates of the center of scaling
DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 23
The G50 command allows you to cancel the scaling mode with numerical control
systems (CNC) of machines.

Consider an example of using the G50 and G51 commands below:


First, create a simple square program.

Scale the shape by adding the line G51X0Y0I2I2. Total result:

G00Z5
G00X0Y0
M3 S6000
G00Z0
G51X0Y0I3J4
G00X15Y15
G01X25Y15
G01X25Y25
G01X15Y25
G01X15Y15
M5
G00Z5
G00X0Y0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 24


G53 - Disabling the offset of the origin of the coordinate system

The G53 command is used to disable the offset of the origin of the coordinate
system.
When the G53 command is executed, the working coordinate offsets are temporarily
canceled and the machine coordinate system is used.
The G53 command is a safe way to return to the initial position of the machine.
The offset values of the origin of the coordinate system are stored in tables.
The G53 command is not modal, acting only in the frame in which it is assigned.

G68 - Rotate coordinate system

The G68 command is used to perform rotation (rotation) of the coordinate system by
a certain angle.
Command format: G68 X__ Y__ Z__ R

The choice of coordinates depends on the selected plane (G17, G18, G19). X and Y
and Z are the coordinates of the point relative to which the coordinate system will be

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 25


rotated, and R - determines the value of the angle of rotation. If X Y is not specified,
then X Y Z are equal to the previous position.

G69 - Cancel Rotation

G69 command is used to cancel the rotation of the coordinate system by a certain
angle.

Example using the G68 and G69 commands:


First, create a simple square program.

G00Z5
G00X0Y0
M3 S6000
G00Z0
G68 R45.0
G00X15Y15
G01X25Y15
G01X25Y25
G01X15Y25
G01X15Y15
M5
G00Z5
G00X0Y0

Rotate the shape 45 degrees, add the line G68 R45.0. Total result:

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 26


G80 - Cancel Canned Cycle

G80 - code cancel of the constant cycle.

G81 - Simple Drilling Cycle

Code G81 is for calling a standard drilling cycle. The following frame shows a typical
format for this loop:

G81 Х10.0 Y15.3 Z-3.0 R0.5 F50.

X and Y determine the coordinates of the holes to be machined. Z indicates the final
drilling depth, and R is used to establish the retraction plane.

G00X0Y0
M3 S6000
G00Z5
G81X10Y10Z-6R1
G01X20Y10
G01X30Y10
G81X40Y10Z-7R2
G01X50Y10
G80
M5
G00X0Y0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 27


G82 - Drilling Cycle with Dwell

Code G82 is for calling a pause drilling cycle. The following frame shows a typical
format for this loop:

G82 Х10.0 Y15.3 Z-3.0 R0.5 P1000 F50.

X and Y determine the coordinates of the production holes. Z indicates the time of
the drilling depth, the address of the waiting time at the bottom of the hole. The
exposure time is indicated in milliseconds.
The G82 command is often used to drill blind holes, since the programmed waiting
time provides better chip removal from the bottom of the hole.

G00X0Y0
M3 S6000
G00Z5
G82X10Y10Z-6R1P700
G01X20Y10
G01X30Y10
G82X40Y10Z-7R2P1000
G01X50Y10
G80
M5
G00X0Y0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 28


G90 - Absolute positioning mode.
In the absolute positioning mode G90, the actuators are moved relative to the zero
point of the working coordinate system G54-G59 (it is programmed where the tool
should move). The G90 code is canceled using the relative positioning code G91.

G90.1 - Absolute distance mode for I , J and K offsets.


G90.1 is the absolute distance mode for offsets I, J & K. When G90.1, I and J are valid,
both must be indicated with G2 / 3 for the XY plane or J and K for the XZ plane,
otherwise this is an error.
Example:
G90.1
G01X10Y10
G02X20Y20I15J15
G00X0Y0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 29


G91 - Relative positioning mode.
In the relative (incremental) positioning mode G91, the position of the actuator,
which it occupied before moving to the next reference point, is each time taken as
the zero position (it is programmed how long the tool should move). Code G91 is
canceled by absolute position code G90.

G91.1 - Incremental distance mode for I, J and K offsets


G91.1 - distance increment mode for offsets I, J & K. G91.1 Returns I, J & K to their
default behavior. G91.1 is active by default.
Example:
G91.1
G01X10Y10
G02X20Y20I5J5
G00X0Y0

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 30


G98, G99 - Canned Cycle Return or Feed Rate Modes

G98 - take back to the position in which the axis was located immediately before the
start of this series of one or more continuous continuous cycles.

G98 specifies a reset. G98 causes the tool to move to the position where it started
the cycle.

G99 specifies the return to the reference point or safe retraction zone. G99 causes
the tool to move to the point defined by the R parameter in the block with the hard
cycle function.

DrufelCNC - software for controlling CNC machines. Read more: https://drufelcnc.com 31

You might also like