Вы находитесь на странице: 1из 50

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Chapter One Program

It consists of several blocks, which is made up of bytes and separated by an end code of the block.
1.1 Main program
Programs are constituted of main programs and subroutine. Generally speaking, the CNC machine moves according to the
command of the main program. If there is an instruction to operate the subroutine in the course of the main program, the
subroutine continues to work. When the instruction returns to the main program issues, the main program executes again.
Main program Subroutine

Program segment 1; Program segment 1;


Program segment 2; Program segment 2;
..... ......
...... ......
...... ......
Instruction of calling a subroutine Instruction of returning to main program

1.2 Sub program


When there are some program segments featured by being fixed-sequence and recurring, they can be edited as subroutines.
The main program can call the subroutine if necessary, so as to simplify the main program. The subroutine can be
executed while the main program is running, and it can also call another subroutine.

Subroutine Subroutine Subroutine


00001; 01000; 02000;
...... ...... ......
...... ...... ......
...... ...... ......
M98 P1000; M98 P2000; .......
...... ...... ......
...... ...... M99
M30 M99;
One-layer nesting Two-layer nesting

The subroutine is allowed to be nested 4 layers.


Quick manual
▲programming a subroutine
Programming a subroutine is in accordance with the following format:
Main program
0XXX; Subroutine
.......
.......
....... contain of the subroutine
......
......
......
M99 End of the subroutine

For example:At the beginning of the subroutine, the subroutine number is defined after the address 0, ending with the
M99 instruction. For example:

For example
X...M99;

Note:
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

In order to be interchanged with other devices, the subroutine in the first block can use N0000
instead of 0000. The sequence number following N is stored in the memory as a subroutine
number.

▲Execution of the subroutine


The subroutine is called up by the main program or subroutine instruction. The format of the instruction is as follows:
M98 PXXXX LNN;
NN: number of instruction
XXXX:called subroutine number
If the number of instruction is omitted, it is considered to be one.
For example
M98. P1002L5;
Subroutine 1002 will be excuted 5 times continuously.
The M98 command can also be programmed in one block at the same time as the move command.
For example
X1000 M98 P1200 ;
At this time, after the X-axis movement is completed, the subroutine No. 1200 is executed.
The order in which subroutines are executed from the main program is shown in the following.

The calling of the subroutine in the subroutine is the same as that of the subroutine in the main program.
Note:
An alarm occurs when the subroutine number specified by the address P fails to be retrieved.

In the main program, if M99 is executed, it returns to the beginning of the main program and continues repeatedly.For
example,there is a block /M99 in the main program. If the optional block switch is turned OFF, M99 will be executed,
returning to the beginning of the main program, and repeating from the beginning.During the OFF state of the optional
block, it is repeatedly executed. When on, the M99 block is skipped and the next block is executed.
Skip switch is on

Skip switch is off

1.3 Program number


N programs can be stored in the memory, and distinguished by the program numbers consisting of address 0 and
subsequent four-digit values (the program name imported by the USB can be Chinese).The program starts with its number
and ends with M30 or M02.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Format
0XXX
0 :address character of program number .
XXXX :Program number (1~9999, leading one can be omitted)

1.4 Number and segment of the program


A program is composed of multiple segments that are separated by terminator (;), an end symbol of a block.
The sequence number can be formed by the address V and the subsequent five digits at its beginning, and the leading one
can be omitted.
Format

NXXXX
N : address character of program number.
XXXX :Sequence number (leading one can be omitted)
Explanation
The order of the sequence numbers can be arbitrary, and different in their interval. The sequence number can be inserted
in all blocks, or in important blocks. It is convenient to insert the sequence number in an important part of the program.
For example, in changing a tool, or moving the table to a new surface.

1.5 Skip optional block


When automatic operation, the block with a slash (/) at the beginning is skipped by the system when the skip switch is on.
If off, the block will be executed normally.
For example
N100 X100.0;
/N101 2100.0;
N102 X200;

In the programme mentioned above, if the skip switch is on, the N101 block will be skipped.

1.6 Bytes and addresses


It is the key to the block, consisting of the address and the value after it, and its value can be negative.
Format

X1000
X:address
1000:value

Explanation
The address is a letter in the English alphabet (A-Z), which specifies the meaning of the subsequent values. Based on the
preparation, sometimes the same address has a different meaning. In this system, the address available and its meaning are
shown in the following table.
Function Address Meaning
Program O Program number
number
Sequence N Sequence number
number
Preparation G To specify the action status (straight line, arc,
etc.)
Size of byte X Y Z A B C U V W H Axis movement instruction
R Radius of the arc
IJK Center coordinate of the Arc and intermediate
point of G12 arc .
Feed rate F Feed rate specification
Spindle S,SS Designation of spindle speed, S spindle 1, SS
function spindle 2
Tool T Designation of the tool number
function
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Accessibilit M Designation of Accessibility of machine tool


y
offset H,HX, Designation of of the offset number of each axis
number HY, HZ, HA, HB, HC and H and HZ are the same.
Pause P/X Designation of pause
Designation P To specify subroutine number
of
subroutine
number
Repeat L Repetitions of subroutine number
times
Parameter P/Q/R To fix cycle parameter

1.7 Range of the basic address and command value


Range of the basic address and command value are as follows
Function Address Millimeter input
Program number O 1~9999
Sequence number N Unlimited
Preparation G 0~99
Size of byte XYZABCUVWHQ ±999999.999
R
Feed in each minute F 0.001~15000.0
Spindle function S 0~9999
Accessibility M 0~99
Pause XP 0~999999.999S
Designation of subprogram number P 1~9999
and number of repetitions
Number of repetitions L 1~99999
offset number H,HX,HY,HZ,HA,HB,H 0~99
C

These parameters refer to the range that the CNC can command, unrelated to its actual one. For example, the system can
command the axis to move about 100m, but X-axis journey of the actual machine may be only 2m. Refer to both the
manual and the machine manual when programming the program.
1.8 End of program
The program ends with M30 or M99.

Format
M30;end of program
M99;end of Subroutine
Explanation
In the course of the execution, if the program code mentioned above occurs, the system will end and enter the reset state.
At the end of M30, the parameter M30 controls the return of the program cursor to the beginning of the program. At the
end of the subroutine, the system returns to the program that calls the subroutine to continue to execute.

Chapter Two G Code

The preparation is represented by the G code, including the G address and its subsequent values. The G code consists of
modal and non-modal.
Type
Type 1:Non-modal G code
Only valid in the block that is being executed
Type 2:Modal G code
Always valid before other G code is being executed in the same group

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

For example
G00 and G01 are the same group of modal G codes. The processing procedure is as follows:
G0OX_ ; (G00 is valid)
Y__ ;(G00 is valid)
G012_ ; (G01 is valid)
X__ ;(GO1 is valid)

2.1 List of G code


G code Grade Function

G00* 01 To position at a quick speed that is based on the parameter of GO, and
the linear and non-linear lines can be selected in the comprehensive
parameters.
G01 Refer to linear interpolation and run according to the given F
G02 Refer to clockwise circular interpolation, run according to the given F or
spiral interpolation if there is a non-planar axis
G03 refer to counterclockwise circular interpolation and others are the same as
mentioned above
G12 Refer to intermediate interpolation of arc
G04 00 Refer to delay waiting, in which parameter X is in seconds, parameter P
in leap seconds and resolution of 5 seconds
G17* 02 Refer to the selection of XY on the circular interpolation plane
G18 Refer to the selection of ZX on the circular interpolation plane
G19 Refer to the selection of YZ on the circular interpolation plane
G28 00 Refer to returning parameter (in other words, to mechanical zero),
including speed, zero return and direction of parameters
G31 Refer to skip mechanism, if the G31 input port effectively stops the
current motion, the next instruction will work
G50 Refer to lateral movement, if the input port is invalid, it will stop, the
same to G31, but you can specify the input port arbitrarily.
G51 Refer to lateral movement, the input port is effectively stopped, the same
to G31, but you can specify the input port arbitrarily.
G22 0 Refer to loop instruction
G23 Refer to loop instruction
G43 05 Refer to compensation of length of tool in the positive direction ,
unrelated to plane; it is always on Z axis or invalid
G44 Refer to compensation of length of tool in the negative direction ,
unrelated to plane; it is always on Z axis or invalid
G49* Refer to cancel of compensation of length of tool, unrelated to plane; it is
always on Z axis or invalid
G52 00 Refer to function of local coordinate
G53 Refer to coordinate positioning of the machine
G54* 06 Refer to workpiece coordinates 1
G55 Refer to workpiece coordinates 2
G56 Refer to workpiece coordinates 3
G57 Refer to workpiece coordinates 4
G58 Refer to workpiece coordinates 5
G59 Refer to workpiece coordinates 6
G73 07 Refer to processing cycle of deep hole at high speed
G74 Refer to cycle of reverse tapping on the basis of that of the encoder.
G80* Refer to cancellation of fixed cycle
G81 Refer to drilling cycle (drilling cycle)
G82 Refer to drilling cycle (empty cycle of the boring ladder )
G83 Refer to drilling cycle of the deep hole
G84 Refer to tapping cycle on the basis of that of the encoder
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

G85 Refer to cycle of boring hole


G86 Refer to drilling cycle
G88 Refer to instruction of custom drill, programmed in G88 editing in the
specific action.
G89 Refer to cycle of boring hole
G90* 08 Refer to absolute value programming
G91 Refer to incremental value programming
G92 00 Refer to the set of coordinates of the workpiece; because their
coordinates will offset when the mechanical fails to return zero,
G93 Refer to the set the coordinates of the machine. Be cautious if there are
soft limits.
G98* 9 Refer to returns of fixed cycle to the initial plane
G99 Refer to returns of fixed cycle to R point

Note:
1 The G code with the * is set as the default G code of the system, and the modal G code will be
the default one when the power is turned on.
2 The G code of the 00 group belongs to non-modal G code and is valid only in the block.
3 An alarm occurs if a G code that is not listed or not used in the G code list.
4 Several different groups of G codes can be commanded in the same block. If so, the last G code
is valid.

2.2 G00-Quick positioning


G00 is the quick positioning instruction. Current point was regarded as staring point, moving to designated location by the
speed which was indicated by speed parameter G0.

Instruction format

G00 IP__;
The IP of X, Y, Z, A, B, C, U, V, W and etc means any combination of axes. For absolute programming, it means
the end-point coordinate value of tools’ movement. For programming of incremental value, it means the tool’s
moving distance.
Semi-colon (;) mean the end of program section.

Descriptions of instruction:
▲Non-linear interpolation location
You can choose line and non-linear line in integrated parameters.
When conducting G00 instruction, each axis realize quickly location by individual and fast movement. If you designate
X-axis and Z-axis at same time, the tools’ moving will not have linear tracks in common condition. Or we can say, during
the conduction of G00, moving axis at same time, the tools’ moving will not follow linear interpolation algorithm but
choose the optimal path. Generally, this operation is used in stepping motor system.
▲Linear interpolation location
You can choose line and non-linear line in integrated parameters.
When conducting G00, G01 has same tool path, tools will realize the location in Min. times by the speed which was less
than each axis quick moving speed.
Two ways are defined in parameter(P0028).
Schematic diagram of two locating modes are shown as follows:

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Start-point
G00 linear location

End-point Non-linear location

2.3
G01-L Note:
inear 1 Fast moving speed of G00 each axis was set by parameters. The feeding speed which was designated
Interp by F was useless. Fast moving speed of G00 could be divided in four levels :100%, 75%, 50%,
olatio 25%, F0.
n
2 G00 is a modal instruction. If the next instruction is G00 too, you do not need to write it. G00 could be
G01 programmed as G0.
IP_F_:
3 When you use G00 instruction, please notice safety position of tools, in case of tools collision
IP: For
absolut
e
progra
mming,
it means absolute coordinates value. For incremental programming, it means the movement of the tool.
Feeding speed will be designated by F. F will be valid before receiving new instruction. So, you do not need to appoint
one by one.
G91 G01 X200 Y100 F200
Tool moves from (0,0) to (200,100) at speed of 200mm/min
2.4 G02/G03—Circular Interpolation
G02/G03 refers to an instruction of the circular interpolation. They control the cutting the tool along the arc on a specified
plane. What’s more, the subroutine fails to run this instruction
Format of the instruction
Arc on the XY plane

Arc on the ZY plane

Arc on the YZ plane

Item Specified Command Description


content
1 Designation G17 Arc designation on the XY plane
of the plane G18 Arc designation on the ZX plane
G19 Arc designation on the YZ plane
2 Interpolation G02 Clockwise circular interpolation (CW)
direction G03 Counterclockwise circular interpolation (CW)
3 End point or Two axes in X, Y End point in absolute coordinates
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

distance and Z
Two axes in XY2 Distance from the the coordinates of the
in the U, V and starting point to that of the end one
W or G91
4 Center point or Two axes in I,J The distance from the coordinates of the
radius and K starting point to the coordinates of the center
of the circle (I, J and K is also calculated in
increments in absolute mode)
R Radius of the arc
5 Feed rate F Tangent speed of arc feed
Instruction description
▲Direction of the circular interpolation
The clockwise (G02) and counterclockwise (GO3) means from the positive direction of the Z-axis (Y_axis, X_axis) to the
negative one on the X_Y plane (Z X plane, Y Z plane) in the right-hand rectangular coordinates, as shown below:

▲Amount of movement on an arc


To specify the end point of the arc with the address X_, Y_ orZ. The absolute value is indicated by the G90 and the
incremental value by the G91 command and the latter refers to the distance from the start point to the end point of the arc.
▲Center of the arc
The center of the arc is specified by the addresses I, J, and K, and refers to values of vector components X_, Y_, Z_, . I,
J, and K, respectively from the starting point of the arc to the center of the circle with symbols. As shown below:

End point End point End point

Start point Start point Start point

Center
Center Center
▲Radius of the arc

End point

Start point

①’s arc is less than 180°and executes G code including G91 G02 X60 Y50 R50 F300;
②’s arc is more than 180°and executes G code including G91 G02 X60 Y50 R-50 F300:
▲Feed rate
The feedrate for circular interpolation is specified by F, which is the speed of the tool along the tangential of the arc.
Note
1 When I, j and K are 0, it can be omitted.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

2 When the amount of movement (X, Y, Z) on the arcs is ignored, the end point is the same as the
starting point. If I, J, and K are used to specify the center of the circle, the specified circle is a full
one.
3 R works when the end point is the same as the start point position and an arc of 0 degrees
occurs, that is, it remains unchanged.
4 The actual movement speed of the tool differs from the specified speed within ±2%, and the
specified speed refers to the speed of the arc movement of the tool along the radius compensation.
5 When I, J, K, and R are specified at the same time, R is valid, while I, J, and K are not.
For example

The trajectories on the graph are programmed in absolute value and measured value respectively.
Absolute mode
G92 X200. 0 Y40.0 Z0 :
G90 G03 X140.0 Y100. 0 1-60.0 F300.0 ; G02 X120.0 Y60.0 1-50.0 :
Or
G92 X200.0 Y40.0 Z0 ;
G90 G03 X140. 0 Y100. 0 R60.0 F300.0 ; G02 X120. 0 Y60.0 R50.0 ;
Incremental mode
G91 G03 X-60. 0 Y60. 0 1-60.0 F300.0 ; G02 X-20. 0 Y-40. 0 1-50.0 :
orG91 G03 X-60. 0 Y60. 0 R60.0 F300.0 ; G02 X-20. 0 Y-40. 0 R50.0 ;

2.5* Spiral interpolation


Designation of circular interpolation means axis outside the plane and at the same time, the tool moves in the way of
spiral.
Instruction format
Arc on the XY plane

Arc on the ZX plane

Arc on the YZ plane

Explanation
The F command specifies the feedrate along the circumference of the arc projection, as shown in the following figure. The
feed rate of the linear axis (Z axis) refers to
Fx Length of the linear axis
Length of arc projection
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Tool path

The speed of the circumference along the arc refers to the specified speed

Note
When the feedrate F is specified, the speed of the linear axis is not allowed to exceed any limit
value.

2.6 G12—3 circular interpolation


G12 has a command of the circular interpolation in the middle. They control the cutting motion of the tool along the arc
on a specified plane.
The subroutine fails to run this instruction
Instruction format

Arc on the XY plane


G12 I J X Y
Arc on the ZX plane
G12 I K X Z
Arc on the YZ plane
G12 J K Y Z

I, J, and K are the middle points of the arc, among which the absolute point refers to below the G90 , and the relative point
to the below G91.
X,Y and Z are the middle points of the arc, among which the absolute point refers to below the G90 , and the relative
point refers to the below G91.
This instruction is mainly used for teaching programming.
The middle point is best to use the point in the middle of the arc to reduce the error. And what’s more, start point, middle
point, and end point cannot be in the same line.
2.7 G 04—delay waiting
With the instruction of delay waiting, the execution of the next block can be postponed, and the delay time refers to the
instruction one.
Instruction format
G04 X_ ;
Or
G04 P_ ;
X: Time setting of delay waiting (a decimal is available).
P:Time setting of delay waiting (a decimal is unavailable).

Instruction description
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

With the pause instruction, the execution of the next block can be deferred for a specified period of time.

Instruction byte Instruction scope Instruction unit


X 0.001~99999.999 second
P 1~99999999 0.001 second

Note
1 The X/P command unit is independent of the minimum unit of the linear or rotary axis.
2 If the P and X instructions are omitted, it can be regarded as an accurate stop.
3 Execution of the G04 command will automatically prevent pre-reading and buffering.

2.8 Function of reference point


The reference point refers to a certain specific position on the machine. If it is zero, it is the reference point of the machine
tool: if not, the set floating zero point can also be regarded as the reference point of the machine tool. You can return to the
reference point in the manual mechanical zero return, or you can make use of the G28 command to automatically return to
the 2.8.1 G28 一 Automatically return to the reference point
The automatic return to the reference point (G28) means making specified axis automatically return to the reference point
via the intermediate point. After returning to the reference point, the zero return light is on. Returning from the reference
point (G29) moves the specified axis to the specified position via the intermediate point. As shown below.
A: return to the starting point of the reference point
B: the intermediate point
C: the target point moved from the reference point
R: reference point

point

The target point

G28 refers to the automatic return to the reference point: A- >B- >R
G29 refers to moving from reference point: R- >B- >C
Command format
G28 IP_ ;
G28: command refers to automatic return to the reference point .
IP_ : the coordinates of the intermediate point through which the reference point automatically
returns, whose absolute or incremental value is spcified.

Instruction description
1 In the course of the execution of G28, the intermediate point and reference point are positioned at the speed of zero
return of the program.
2 When the machine is locked, the G28 fails to be positioned from the intermediate point to the reference point, and the
zero return light will not on.
3 G28 is generally used in automatic tool change, so in principle, the compensation amount such as tool radius and length
should be canceled in advance.
4 There are multiple axes in G28 with the order of execution of Z->XY->ABC

For example
N1 G28 X40.0 ; intermediate point(40.0)
N2. G28 Y60.0 ; intermediate point(40.0,60.0)

Note
1 After power-on, if the reference point is never not manually returned, the motion from the
intermediate point to the reference point is the same as the manual return to the reference point
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

when G28 is commanded.


2 When the workpiece coordinates are changed by the G28 command through the intermediate
point to the reference point, the intermediate point is also moved to the new coordinates.

2.9 Function of coordinates


When the machine is working, the tool moves to the specified position according to the coordinates specified by the
processing program, and the coordinate value is specified by each axis component of the coordinate axis. The following
figure shows the tool position specified by X40.0, Y50.0 and Z30.0.

The system uses one of the machine coordinates, the workpiece coordinates, and the local coordinates to specify the
position of the coordinates.
Machine zero is a fixed reference point set by the machine tool builder for the machine. The coordinates with the machine
zero as the coordinate origin are called the machine coordinates.
1 The machine coordinates are based on the fixed point on the machine tool, the reference of other coordinate systems.
Once it is established, the system saves it and is valid until it is reset.
2 The coordinates of the workpiece are based on the sub-coordinate system in the machine coordinates, and can be set and
changed.
3 The local coordinates are based on the sub-coordinates in the workpiece coordinates, and can be set and changed.
Relations of each coordinate system are as shown in the following:

Local coordinates G52

Workpiece coordinates G54-G59


Machine coordinates G53

Zero point of the machine

Reference point

Generally speaking, after the system is turned on, the user is required to reset the machine coordinates.
After manually zeroing each axis of the coordinate or returning to the reference point by G28 command, the system can
establish the machine coordinates according to the zero point of the machine. This coordinates will be saved in the system
until the user resets.

2.9.1 G53-positioning of the coordinates of the machine


The tool will move to the target position as soon as possible according to the specified coordinates of the machine.
Instruction format

G53 IP_ ;
IP_ : absolute coordinates of the target point in the coordinates of the machine
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Instruction description
1 Since the general positioning command (G00) can only specify the target point in the workpiece coordinates, if the user
wants to move the tool to a special position of the machine (such as the change position of the tool), G53 command is a
better choice.
2 G53 is a non-modal G code that is valid only in the block.
3 The G53 command must be an absolute command. If it is an incremental instruction, an alarm will take place.
Note
1 When the G53 command is specified, the compensation amount such as radius and length of
the tool is automatically cleared.
2 The G53 instruction prevents pre-read of the G code.

2.9.2 G92,G54 一 G59- Workpiece coordinates setting


The coordinates used for machining parts are called the workpiece coordinates. The workpiece coordinates are required to
be set in advance before machining, or the workpiece coordinates can be changed by moving the origin.
Three ways to set the workpiece coordinates:
1 G92 sets the workpiece coordinates;
2 To automatically set the workpiece coordinates;
3 To select the workpiece coordinates of the G54-G59.

2.9.2.1 G92-set the workpiece coordinates


Instruction format

G92 IP__ ;
IP_ :to specify the coordinates of the point in the set workpiece coordinates.

The workpiece coordinates are established by making the value of the specified coordinate (IP_) into the value of the
absolute coordinate of the point on the tool (such as the tool tip) in the set workpiece coordinates.
1 In terms of the length compensation of the tool, when the coordinates are set with G92, the value of the specified
coordinate (IP_) refers to the position before the tool compensation.
2 When it comes to the radius compensation of the tool, the compensation temporarily disappears when the G92 command
counts.
3 In general,to set the workpiece coordinates before specifying tool compensation.
For example
To set the workpiece coordinates with the tool tip as the specified point

To set the workpiece coordinates with the difficulty of the base of the tool holder as the specified point

After the coordinate system is established, the tool length compensation must be added from the reference point to the tool
tip, when the command reference point is moved to the specified position through the absolute mode,

2.9.2.2 To automatically set the workpiece coordinates


If the coordinates auto setting is selected, the system will automatically set the workpiece coordinates after returning to
the reference point manually or automatically. If a, β, and γ are the values of the parameters, respectively, the value of the
absolute coordinate of the reference point of the tool holder or the tool tip after returning to the reference point is X=a,
Y=β, Z=γ, which means setting the workpiece coordinates. This method is equivalent to performing the following

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

instruction at the reference point.

2.9.2.3 Selection of the workpiece coordinates(G54-G59)


The system provides six workpiece coordinates of G54-659. The user can set the zero offset data of each coordinate
through the system MDI panel, and then select any workpiece coordinates. When the power is turned on and the reference
point is returned, the G54 coordinate system is selected by default.

G54 refers to workpiece coordinates 1


G55 refers to workpiece coordinates 2
G56 refers to workpiece coordinates 3
G57 refers to workpiece coordinates 4
G58 refers to workpiece coordinates 5
G59 refers to workpiece coordinates 6
Instruction description
1 The six workpiece coordinates are set on the basis of the distance from the zero point of the machine to the zero point of
each coordinates (zero offset of the workpiece ), as shown in the following figure.

zero offset of the


workpiece

zero point of the machine


2 After returning to the reference point, the absolute position refers to the negative value of the zero offset of the
workpiece, as shown in the following.
zero offset of zero point of the
the workpiece machine

Workpiece coordinates

3 If the working coordinate system is selected, it is normal to set zero in the parameter. If not, all workpiece coordinates
are offset from the value of the parameter, after returning the parameter reference point.
Note
1 When the workpiece coordinate system is selected, the coordinate system is not required to be
set by G92. If so, the workpiece coordinates of 1-6 will be moved. Therefore, do not mix G92 with
G54-G59 unless the workpiece coordinates of 1-6 are to be moved.
2 Whether the relative position changes with the setting of the workpiece coordinates depends on
the setting in the parameter.

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

For example

Processing program
N10 G55 G00 X100. 0 Z20.0 ;
N20 G56 X80.5 Z25.5 ;

2.9.3 To move the workpiece coordinates with G92


Instruction format

G92 IP_ ;
IP__ :To specify the coordinates of the point in the set of workpiece coordinates.
Command explanation
To execute the G92 command in the selected workpiece coordinates (G54-659) allows all the original ones to be offset
synchronously to produce a new coordinates with the same offset.

2.9.4 to set machine coordinates(G93)


To set the machine coordinates, please be cautious when there is soft limit because the workpiece coordinates will be all
offset.
G93 IP_
For example: G93Z0;to set the Z axis with the machine coordinate of zero.

2.9.5 G52- local coordinates


When programming a processing program in the workpiece coordinates, a sub-coordinate system can be set in the
workpiece coordinates for convenience, which is called a local coordinate system.

Instruction format

G52 IP_ ; to set local coordinates


G52 IPO;to cancel local coordinates
IP__: to specify the absolute coordinates of the origin of the local coordinates in the workpiece
coordinates.
Explanation
When setting the local coordinates, the specified IP_ indicates the absolute coordinates of the origin of the local
coordinates in the workpiece coordinates, regardless of its absolute value or relative value.At the same time, the absolute
coordinates on the system also belong to the local ones. The local coordinates can be changed by specifying the new zero
point of the local coordinates with G52 in the workpieces.
If so, the local coordinates will remain valid in its workpiece coordinates until the command "G52 IP" causes the zero
point of the local coordinates to coincide with that of workpiece coordinates.
Unlike the C92 command, G52 only works in its corresponding workpiece coordinates, as shown in the following figure.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

local coordinates

workpiece coordinates
local coordinates

workpiece coordinates 6

Zero point of the machine tool Coordinates of the machine tool

Note
1 When an axis returns to the reference point automatically or manually, its zero point coincides
with the zero point of the workpiece coordinates, that is, the local coordinates are canceled, whose
effect are the same as the command G52a; (a: the axis of returning to the reference point).
2 The setting of the local coordinates will not change the workpiece coordinates and the machine
coordinates.
3 Whether to eliminate the local coordinates during reset depends on the setting of the parameters.
4 If the workpiece coordinates is set with G92, the local coordinates will be canceled. If the
coordinate values of all axes are not commanded, the local coordinates will not be canceled and
changed.
5G52 temporarily cancels radius compensation of the tool .
6After the G52 is executed, the absolute coordinates immediately display the coordinates in the
local coordinates.
|

2.9.6 G17/G18/G19- selection of the plane


To utilize the G code to select the plane of the circular interpolation and the plane for radius compensation of the tool.
Instruction format

G17.....XY plane
G18......ZX plane
G19......YZ plane

In the blocks of G17,G18 and G19 without instruction, the plane does not change.

For example
G18X_Z_;ZX plane
X_ Y_ : plane invariant (ZX plane)

In addition, the move instruction is independent of plane selection. For example, the 7-axis is not in the XY plane, so the
Z-axis movement is independent of the XY plane.

2.10 to simplify programming


2.10.1 overview
In the course of the drilling process, multiple blocks are usually used to specify several operations with a higher frequency.
The fixed cycle described in this section simplifies the programming operation by a single block with one code to
complete the drilling process.
List of the drilling preparation

G code Opening action Bottom Tool withdrawal Function


movement

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

G73 Intermittent feed 一一 Rapid feed Cycle of deep


hole processing
at high speed
G74 Cutting feed Positive Cutting feed Counter-tapping
rotation of cycle
Spindle
G80 一一 一一 一一 To cancel the
fixed cycle
G81 Cutting feed 一一 Rapid feed Drilling
G82 Cutting feed Rapid feed drilling,boring
stepped hole
G83 Intermittent feed 一一 Rapid feed Cycle of deep
hole processing
G84 Cutting feed Negative rotation Cutting feed Tapping cycle
of Spindle
G85 Cutting feed 一一 Cutting feed Boring
G86 Cutting feed Pause of the Pause of the Boring
main uranium main uranium
G88 Custom drilling 一一 Custom Drilling
G89 Cutting feed Cutting feed Boring
Instruction format

G_IP_R__Q_P_F_J_;
Address description

Specified content Address Description


Manner of hole G To select fixed cycle of G73、G74、 G80~G89
processing
Direction of hole To Fix Z direction
processing
Data of hole Axis address of To specify the position of the hole in absolute or
position non-hole incremental value, the same as the one positioned by
processing in IP G00.
Data of hole Axis address of As shown in the following figure, to make use of the
position non-hole incremental value to specify the distance from the R
processing in IP point to the bottom of the hole or the absolute value to
command the coordinates of the bottom of the hole.The
feed speed refers to the one specified by F in action 3,
and the speed of rapid feed or F code command is
determined by the manner of hole processing in action
5.
R As shown in the figure, to specify the distance from the
initial point on the plane to the R point by the
incremental value, or the coordinate of the R point with
an absolute value. The rapid feed is in both action 2 and
action 6.
Q To specify the amount of cut of G73 and G83 or that of
shift in G76 and G87 (incremental value).
P To specify the pause time at the bottom of the hole. The
relationship between time and the specified value is the
same as the G04 designation.
F To specify the rate of cutting feed the distance of G74
and G84.
J Processing axis specifies J0: X, J1: Y, J2: Z, J3: A, J4:
B, J5: B, other values or no default as Z axis
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Command explanation
▲Absolute programming and relative programming
To specify absolute programming and relative programming with G90 and G91

G90 (instruction of absolute value ) G91 (instruction of incremental value )

R point Coordinate of R R point


point

Z point Coordinate of Z Z point

▲Return to the point plane


①Command G98 refers to returning to the plane of the initial point.
②Command G99 refers to returning to the plane of the R point.
in general, the initial hole is processed with G99 and the last with G98. When the hole is processed with G99, the initial
point plane does not change.

G98 (returning to the plane of the initial point) G99 (returning to the plane of the R point)

the plane of the initial point

the plane of the R point


R point R point

Z point
Z point
.....the plane of the initial point R point plane
R point R point
Z point Z point
▲Manner of hole processing
Fixed cycle commands of hole processing available include G73, G74, G76 and G80 ~ G89, which belong to modal G
codes.
The fixed cycle command specifies all its data, including mode and direction of the hole processing, data of hole position
and of hole processing, etc., to form a block.
Once the mode and data of the hole processing are commanded,the G code (G80 and 01 G code) for the fixed cycle is
valid until canceled, so the hole processing is not required for the mode and data of each block when the same hole
processing is performed continuously. At the beginning of the fixed cycle, all the necessary hole machining data should be
specified, and therefore only the changed data is specified in the subsequent fixed cycle.
Note
The cutting speed (F command) of the command in the canned cycle will work after the fixed
cycle is canceled.
▲Cancellation of the fixed cycle
The fixed cycle can be canceled by the code of the 01 group or G80 in the same group as the fixed cycle. G code of 01
Group includes G00, G01, G02 and G03.

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

2.10.2 G73 一 processing cycle of deep hole at a high speed


The G73 cycle refers to drilling cycle of the deep hole at a high speed that performs intermittent feed until the bottom of
the hole.
Instruction format
G73 IP_ R_ Q_F_J_;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
Q :amount of feed per cutting feed
F_: rate of the cutting feed
J_ :processing axis

Command Explanation
The high-speed drilling cycle of the deep hole refers to intermittent feed along the drilling axis, and withdraws after the
bottom of the hole, which facilitates chip evacuation and increases drilling speed and accuracy.

Note
1 The amount of withdrawal can be set by parameters, and the direction of the drilling axis is
intermittently fed; to make deep hole processing easy in chip removal. The amount of withdrawal
can be set to a small amount, which can improve its efficiency. The movement is at a high speed.
2 To start the spindle before specifying G73.
3 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
processing is not performed.
4 The data Q and P of the hole processing can be commanded in the block in which the hole
processing can be performed. The data Q and P of command hole processing cannot be stored as
modal data in the block in which the hole processing is not available.
5 When it comes to the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
6 The tool offset command in the fixed cycle is invalid.
7 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.3 Counter-tapping cycle


The G74 cycle refers to a left-hand tapping cycle for machining reverse threads.
Instruction format
G74 IP_R_ P_F_J_;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)
F_:metric pitch. Range of the value : 0. 001~500. 00mm
J_ :processing axis
Command Explanation
The cycle refers to left-hand tapping, and the spindle reverses the state to launch.The spindle pauses with time P, after
reaching the bottom of the hole, and the positive rotates of spindle will withdraw, when the left-hand tapping is
completed.

Note
1In terms of the G74 counter-tapping cycle, the rate of feed speed and feed remain inactive. Even
if the "Feed Hold" button is pressed, it does not stop until the return operation ends.
2 To start the spindle before specifying G74. If the G74 and M codes are specified in the same
program, the M code is sent at the initial positioning, and the next loop is performed after its
execution ends.
3 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

processing is not performed.


4 The data Q and P of the hole processing can be commanded in the block in which the hole
processing can be performed. The data Q and P of command hole processing cannot be stored as
modal data in the block in which the hole processing is not available.
5 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
6 The tool offset command in the fixed cycle is invalid.
7 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.4 G81-drilling cycle and point drilling cycle


G81 refers to the instruction of processing cycle of a general drilling.
Instruction format
G81 IP_R_F_J_ ;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
J_ :processing axis
Command explanation
After the tool is positioned, moves quickly to point R and until to the bottom of the hole along the axis of the hole, then
the tool will quickly withdraw.

Note
1 To start the spindle before specifying G81.If the G81 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
2 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
processing is not performed.
3 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
4 The tool offset command in the fixed cycle is invalid.
5 The fixed cycle must be canceled before changing the drilling axis or processing plane.

For example
MO4 S800 ; spindle stats to rotate
G90 G99 G81 X100. Y100. Z- 20. R50. F100. ; to position, drill the hole 1 and return to R
X150, ; to position, drill the hole 2 and return to R
G98 Y150. ; to position, drill the hole 2 and return to the initial plane
G80 G00 XO. YO. Z0.; to cancel the fixed cycle and return to the starting point
M05 ; spindle ends to rotate

2.10.5 G82-Drilling cycle and boring stepped hole cycle


G82 refers to a general drilling processing cycle, and the tool returns after pausing at the bottom of the hole. Due to the
pause at the bottom of the hole, the accuracy of the hole depth can be improved in blind hole processing
Instruction format

G82 IP_ R_ Q_F_J_;


IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:the distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)
F_: rate of the cutting feed
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

J_ :processing axis

G82 (G98) G82 (G99)


Command explanation
After the tool is positioned, moves quickly to point R and until the bottom of the hole along the axis of the hole with pause
time of P, then the tool will quickly withdraw.

Note
1 To start the spindle before specifying G82.If the G82 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
2 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
processing is not performed.
3 The data Q and P can be processed by the command hole in the block where the hole processing
operation is allowed. The command hole processing data Q, P cannot be stored as modal data in
the block where hole processing is not available.
4 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
5 The tool offset command in the fixed cycle is invalid.
6 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.6 G83-processing cycle of a deep hole


The G83 refers to the processing cycle of a deep hole that performs intermittent tapping to the bottom of the hole and then
withdraw quickly.
Instruction format
G83 IP_ R_ Q_F_J_;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
Q : amount of feed per cutting feed
F_: rate of the cutting feed
J_ :processing axis

Plane of hte initial Plane of hte initial point


point

Plane of R point Plane of R point

Command explanation
According to the format command mentioned above, Q refers to the amount of each cutting feed commanded by the
incremental value. At the second time, the cutting feed works, while feed is quickly fed to the d mm from the
just-processed position. The Q value must be a positive value, even if a negative value has been commanded, the symbol
is invalid. d is set with parameters.
Note
1To start the spindle before specifying G83.If the G83 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
2 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

processing is not performed.


3 The data Q and P can be processed by the command hole in the block where the hole processing
operation is allowed. The command hole processing data Q and P cannot be stored as modal data
in the block where hole processing is not available.
4 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
5 The tool offset command in the fixed cycle is invalid.
6 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.7 G84-tapping cycle


The G84 cycle refers to a tapping cycle for processing positive spiral.
Instruction format

G84IP_R_P_F_J_ ;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)
F_:Metric pitch. Range of value; 0. 001~ 500.00mm
J_ :processing axis

Plane of the Initial point Plane of the Initial point

ve rotation of spindle Plane of R point Positive rotation of


spindle Plane of R point

Z point Z point

Negative rotation of Negative rotation of spindle


P: pause of feed P: pause of feed
spindle
Command explanation
The cycle executes the tapping one, the spindle refers to the positive rotation, and the spindle pause with time P at the
bottom of the hole ans the spindle reverses and exits, and the tapping operation is completed.

Note
1 In terms of the G84 counter-tapping cycle, the rate of feed speed and feed remain inactive. Even
if the "Feed Hold" button is pressed, it does not stop until the return operation ends.
2 To start the spindle before specifying G84.If the G84 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
3 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
processing is not performed.
4 The data Q and P can be processed by the command hole in the block where the hole processing
operation is allowed. The command hole processing data Q, P cannot be stored as modal data in
the block where hole processing is not available.
5 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
6 The tool offset command in the fixed cycle is invalid.
7 The fixed cycle must be canceled before changing the drilling axis or processing plane.

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

2.10.8 G85 一 boring cycle


G85 is used for boring, and it can be refined with G76 after that. The cycle is the same as G84, except that the spindle at
the bottom of the hole does not reverse and pause.

Instruction format

G85 IP_R_F_J ;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)

Command explanation
After the tool is positioned, it moves to the R point quickly, cuts to the bottom of the hole along the Z, exits at the cutting
speed, and finally the tool returns to the R point or the initial plane.

Note
1 To start the spindle before specifying G85.If the G85 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
2 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
processing is not performed.
3 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
4 The tool offset command in the fixed cycle is invalid.
5 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.9 G86- -boring cycle


G86 is used for boring, and it can be refined with G76 after that. The cycle is the same as G81, except that the spindle at
the bottom of the hole does not reverse and pause.
Instruction format

G86 IP_ R_F_ J. ;


IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)

Command explanation
After the tool is positioned, it moves to the R point quickly, cuts to the bottom of the hole along the Z, exits at the cutting
speed, and finally the tool returns to the R point or the initial plane and at the same time spiral launches positive rotation

Note
1 To start the spindle before specifying G86.If the G86 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
2 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

processing is not performed.


3 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
4 The tool offset command in the fixed cycle is invalid.
5 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.10 G88- custom drilling


The G88 is used for custom drilling, which improves drilling efficiency.
The specific implementation lies in custom G88 in the drilling.
Instruction format

G88 IP_ R_P_F_J_;


IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)
F_: rate of the cutting feed
J_ :processing axis

2.10.11 G89 一 boring cycle


G89 is used for boring. After being finished, the cycle is the same as G85, except a pause at the bottom of the hole.
Instruction format

G89 IP_R_P_F_J_;
IP_ (non-hole processing axis): data of hole position
IP_ (hole processing axis): the distance from the R point to the bottom of the hole (incremental
value) or the coordinates of the bottom of the hole (absolute value)
R_:The distance from the initial point of the plane to the R point (incremental value), or the
coordinate of the R point (absolute value)
P_ :pause time of the bottom of the hole (in 0.001 seconds)
F_: rate of the cutting feed
J_ :processing axis

Command explanation
G89 cycle is the same as the G85, except increasing the pause at the bottom of the hole, which can improve the processing
precision of the blind hole.

Note
1 To start the spindle before specifying G89.If the G89 and M codes are specified in the same
block, the M code is sent at the time of initial positioning, and the next loop is performed after the
execution of the M code ends.
2 In terms of the the fixed cycle, if any one or more of the X, Y, Z, and R is commanded, the hole
processing works immediately. However, when X and G04 are specified at the same time, hole
processing is not performed.
3 When it terms of the fixed cycle, the offset is made at the position of initial point of the plane, if
the offset of the tool length has been commanded.
4 The tool offset command in the fixed cycle is invalid.
5 The fixed cycle must be canceled before changing the drilling axis or processing plane.

2.10.12 G80-cancellation of the fixed cycle


G80 is used to cancel the fixed cycle.
Instruction format

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

G80;

Command explanation
It is used to cancel all data of all fixed cycles (G73, G74 and G81~G89), and then process according to the normal
operation.

2.11 Example of drilling fixed cycle (by length compensation of the tool )
▲ Size of the workpiece 1
Reference point

▲Size of the workpiece 2


#1~6 Hole 10 of drilling φ
#7~10 Hole 20 of drilling φ
#11~13 Hole 95 of drilling φ( with depth of 50mm)

turning posiiton

Position of start point

▲Selection of the tool


Value of offset number 11 is 200.0
Value of offset number 15 is 190.0

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Value of offset number 31 is 150.0

▲Processing program
N0O1 G92X0 Y0Z0; The coordinates are set at the reference point.
N0O2 G90 G00 2250. 0;
N003 G43Z0H11; Length of the tool is compensated at the initial point.
N004 S1000 M3; The spindle starts.
N005 G99 G81 X400.0 Y-350.0 Z-153.0 R-97.0 F120.0; processing hole #1 after being
positioned.
N006 Y-550.0; processing hole #2 after being positioned, returning to the plane of the R
point plane.N007
G98 Y-750.0 ; processing hole #3 after being positioned, returning to returning to the
plane of the initial point
N008 699 X1200.0 ; processing hole #4 after being positioned, returning to the plane of the R
point
N009 Y-550.0 ; processing hole #5 after being positioned, returning to the plane of the R
point point
N010 98 Y-350.0 ; processing hole #6 after being positioned, returning to the plane of the initial
point
NO11 G00XO YOM5 ; to return to the reference point and the spindle stops.
N012 C49 2250.0 ;
MO00 ; to pause the tool and change it
N013 G43 Z0 H15 ; length compensation of the tool on the plane of the initial point plane.
N014 S20 M3 ; Spindle starts.
N015 G99 G82 X550.0 Y-450.0 Z-130.0 R-97.0 P30 F70; processing hole #7 after being
positioned, returning to the plane of the R point
N016 G98 Y-650.0 ; processing hole #8 after being positioned, returning to the plane of the initial
point
N017 G99 X1050.0 ; processing hole #9 after being positioned, returning to the plane of the R
point point
N018 G98 Y-450.0 ; processing hole #10 after being positioned, returning to the plane of the
initial point
N019 G00X0 Y0 M5 ; returning to the reference point and the spindle stops.
N020 G49 Z250.0 ;
MOO : to pause the tool and change it
NO21 G43 20 H31 ; length compensation of the tool at the plane of the initial point.
N022 S10 M3 ; the spindle starts.
NO23 G85 G99 X800.0 Y-350.0 Z-153.0 R47.0 F50 ; processing hole #11 after being positioned,
returning to the R plane
N024 G91 Y-200.0 ; Y-200.0 ; processing hole #12 and #13 after being positioned, returning to
the plane of the R point
N025G00C90X0YOM5; returning to the reference point and the spindle stops.
NO26 G49 20 ; to cancel length compensation of the tool.
NO27 MO5 ; the spindle stops.
N028 M30 ; the program stops

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

2.12 G22-G23 Loop execution


This command can finish program cycle
G22L3
..
..
G23
Intermediate program loop is executed 3 times
Being nested is allowed, but limited with 4 layers.
G22L3
G22L5
..
..
G23
G23

2.13 G31 一 skip function


Linear interpolation like G01 can be performed by the movement of the command axis behind G31. In this course, if a
skip signal is input, the block stops the rest and starts executing the next. This function is mainly used to control the
termination by external signals, or to measure the size of the workpiece.
Instruction format

G31 IP_ F_ ;
G31: a skip command, featured by being non-modal, is valid only in this block
IP_: to specify the coordinates of the moving end point.
F_ :to specify the rate of the feed.
For example
▲The block after G31 refers to the incremental command
The incremental value is moved from the position where the skip signal is interrupted. At the same time, the X coordinate,
an absolute coordinate of the jump point is saved to the macro variable #1.

Actual movement
To enter the skip signal,
If not
......
G91 G31 X100.0 F100. 0 ;
G04 ;
#1 = #5041 ;
Y50.0 ;
......
2.14 G50-G51 refers to positioning movement
The positioning movement is a supplement to the G31 and can access to more inputs. Each axis moves in line with the
G1.
Instruction format
G50/G51 IP_ P_ ;
IP: moving axis.
P: input port.

For example:
G50 X10 Z100 P2 ; if the input port 2 is invalid during the movement, interrupt the movement and execute the next line.
G51 Y10 250 P20 ; if the input port 20 becomes valid during the movement, interrupt the movement and execute the next
line.

Chapter Three M Codes


3.1 M Codes
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.
TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Name Function

M00 The program is paused and press the "cycle start" program continues

M01 Quasi-stop, if the Quasi stop light is on, the program stops

M02 The program stops

M03 Spindle 1 forward

M04 Spindle 1 reverses

M05 Spindle 1 stops

M08 Coolant open

M09 Coolant off

M10 Tail stock forward

M11 Tail stock back

M12 Clamp

M13 Release

M30 The program ends and the program returns to the beginning

M54 Counter plus one

M55 The counter is cleared

M63 Spindle 2 forward

M64 Spindle 2 reverses

M65 Spindle 2 stops

M70 Wait for input port, output port or auxiliary relay invalid. Example: M70 X12 input
port; M70 Y1 output port; M70 Z1 auxiliary relay;
M71 Wait for input port, output port or auxiliary relay Valid. Example: M71 X12 input
port; M71 Y1 output port; M71 Z1 auxiliary relay;
M72 Skip when input port, output port or auxiliary relay is invalid. Example:M72 Xxx Pn
input port;, M72 Yxx Pn output port; M72 Zxx Pn auxiliary relay;
M73 Skip when input port, output port or auxiliary relay is valid Example:M73 Xxx Pn
input port;, M73 Yxx Pn output port; M73 Zxx Pn auxiliary relay;
M74 Waiting for input, output, or auxiliary relay falling edge

M75 Waiting for input, output, or auxiliary relay rising edge


M76 Absolute skip example: M76 P1

M80 Output port or auxiliary relay OFF. example: M80 Y12

M81 Output port or auxiliary relay on. Example: M81 Y12

M82 Output port or auxiliary relay gives output for a period of time, then close off.
Example: M82 Y12 P1000 (milliseconds)
M83 Output port or auxiliary relay gives output and close off when an input port is valid
Example: M83 Y12 X13
M84 Output port or auxiliary relay gives output and close off when an input port is invalid
Example: M84 Y12 X13
M98 Call subprogram. Note that the subprogram name format should be Oxxxx.nc and x is
the number
M99 Subprogram or macro return. If used in the main program, the program loops from the
beginning

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

3.2 Explanations of M codes


M01-Program selection stop
Instruction format:
M01 (or M1)
Instruction function
When start “program selection stop”, M01 instruction is valid. During the program operation, when there is M01
instruction, system will stop operating after finish current program segment.

M02- End of program


Instruction format:
M02 (or M2)
Instruction function
Conduct M02 instruction under automatic operating, after other program segments were finished, operating this
instruction and program automatic finished, cursor return to program start-point.
Using automatic count (P0003=0), counter plus 1.

M03- Spindle 1 forward revolving


Instruction format:
M03 (or M3)
Instruction function
When program conducts M03 instruction, firstly, make the forward revolving relay of spindle 1 pickup, and then control
spindle clockwise revolving by the sped which was specified by S code.

M04- Spindle 1 reverse revolving


Instruction format:
M04 (or M4)
Instruction function
Control spindle 1 reverse revolving.

M05- Spindle stop revolving


Instruction format:
M05 (or M5)
Instruction function:
Close the output of M03 or M04, make spindle 1 stop revolving.

M08/M09- Coolant
Instruction format:
M08 (or M8)
M09 (or M9)
Instruction function:
M08, coolant open
M09, coolant stop

M10/M11- Tail-stock forward/retract.


Instruction format:
M10
M11
Instruction function:
M10, tail-stock forward
M11, tail-stock return

M12/M13- Chuck clamping /releasing


Instruction format:
M12
M13

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Instruction function:
M12, chuck clamping
M13, chuck releasing

M30-end of program
Instruction format
M30
Instruction function:
Conduct M02 instruction under automatic operating, after other program segments were finished, operating this
instruction and program automatic finished, cursor return to program start-point. Spindle stopped revolving and cooling at
same time.
Using automatic count (P0003=0), counter plus 1.

M54- counter plus 1


Instruction format:
M54
Instruction function:
Work-piece counting, add numbers of work-piece.
M55 - counter rezeroing
Instruction format:
M55
Instruction function:
Rezeroing the work-piece counting number

M63 M64 M65


M63 Spindle 2 forward revolving
M64 Spindle 2 reverse revolving
M65 Spindle 2 stop

M71-waiting for input/output port invalid


Instruction format
M70 Xxx: Input port M70 Yxx: Output port
Instruction function
Xx: Code 01-99. When the specified port invalid, program will wait. When the specified port valid, program will operate
to down direction. Specify one port only per time.

M72 I/O port invalid jump


Instruction format
M72 Xxx Pn: Input port M70 Yxx Pn: Output port
Instruction function
Xx: Code 01-96.
When the specified port invalid, program will jump to N code which was specified by P.
When the specified port valid, program will operate to down direction. Specify only one port per time.

M73 I/O port valid jump


Instruction format
M73 Xxx Pn: Input port M73 Yxx Pn: Output port
Instruction function
Xx: Code 01-96.
When the specified port valid, program will jump to N code which was specified by P.
When the specified port invalid, program will operate to down direction. Specify only one port per time.

M74 waiting for I/O port falling edge


Instruction format
M74 Xxx : Input port M74 Yxx : Output port

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Instruction function
Xx: Code 01-96.
The specified port will wait for a valid signal first, and then wait for an invalid signal. Specify only one port per time.

M75 waiting for I/O port rising


Instruction format
M75 Xxx : Input port M75 Yxx : Output port
Instruction function
Xx: Code 01-96.
The specified port will wait for a valid signal first, and then wait for an invalid signal. Specify only one port per time.

M80- Output port close


Instruction format
M80 Yxx : Output port
Instruction function
Xx: Code 01-96.
Close one output port
Specify only one port per time.

M81- Output port open


Instruction format
M81 Yxx : Output port
Instruction function
Xx: Code 01-96.
Open one output port
Specify only one port per time.

M82- Output port close after a period time outputting


Instruction format
M82 Yxx Paaaa: Output port
Instruction function
Xx: Code 01-96.
Paaaa: delay time, unit: ms
Specify only one port per time.

M83- Output port close outputting after waiting for an input port valid
Instruction format
M83 Yxx Xxx: Output port
Instruction function
Xx: Code 01-96.
Example: M83, Y12, X13. Explain: Open the 12# output port, and then judge whether 13# input port valid. If the 13#
input port valid, close the output of 12#.
Specify only one port per time.

M84- Output port close outputting after waiting for an input port invalid
Instruction format
M84 Yxx Xxx: Output port
Instruction function
Xx: Code 01-96.
Example: M84, Y12, X13. Explain: Open the 12# output port, and then judge whether 13# input port valid. If the 13#
input port invalid, close the output of 12#.
Specify only one port per time.

M98/M99- call and return of the subroutine

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Instruction format
M98 P####Ln;
M99;
Command function
1. P: the subroutine calls the feature character and cannot be omitted.
2. ###: the name of the subroutine must be four numbers.
3.Ln: the number of subroutine calling refers to once when omitted, up to 9999 times.
When there is a fixed program in the program that repeats, it can be used as a subroutine, so that the execution of the
subroutine will work if necessary without repeating the programming.
The last paragraph of the subroutine must be the returns command of the subroutine, M99. When M99 command is
executed, the program returns to the main program and execute the next program of the main program command.
For example

Main program 0001


N0010 M03 S1000 ;
.....
N0080 GO X10 ;
N0090 M98 P0005 ;N0100 GOX30;

......
N0150 M30 ;
Subroutine 0005
N0010 G01 X10 F100 ;
*...
N0060GOZ30;
N0070 M99 ;
return of subroutine
to execute the main program 00001, whose flow refers to
N0010 M03 S1000 ;
****.
N0080 GO X10 ;

N0010 G01 X10 F100 ;


......
N0060 GO Z30 ;
N0100 GOX30 ;
.....
N0150 M30 ;

Chapter Four Compensation Of The Tool (H Code)


4.1 Compensation of the tool
To set the difference between the assumed length of the tool during programming and actual one to the offset memory.
When processing a workpiece, it is unnecessary to modify the program. You are only required to specify the
compensation of the length and you are allowed to use the different lengths of the tool to process the same workpiece,
which is called the length compensation of the tool.
Independent tool compensation can be specified for each axis. Its compensation codes are HX, HY, HZ, HA, HB and HC.
To get the correct compensation, you need to set the direction of the compensation. For example, the Z-axis tool tip and
the lower axis of the shaft need to compensate in the whole direction. If it is a row tool, it is generally used in the negative
direction.
The Z-axis tool compensation, HZ will automatically open the G43,without effect on other axes.

4.2 Z-axis tool compensation


(G43、G44、G49)(G43、G44、 G49) only for the Z axis.
Instruction format

G43H;G44 H_ ;

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

G43:positive offset
G44:negative offset
H:offset member

Instruction description
▲offset direction
Regardless of an absolute value instruction or an incremental value instruction, when G43 is specified, the coordinates
the end point specified by the Z movement command add the length compensation specified by the H code (in the offset
memory), and the calculation result is taken as the coordinate of the end point; when G44 is specified, the coordinate of
the end point specified by the Z-axis movement command in the program is subtracted from the length compensation
specified by the H code, and the result is used as the coordinate of the end point.
When the Z-axis movement is omitted, only the tool length compensation is moved. When the offset is negative, the
direction of movement is reversed. G43 and G44 are modal G codes and are valid until other G codes in the same group
occur.
▲ offset number
The offset number can specify Hn00 Hn99. In the panel LCD/ADI , the amount of the offset numbers Hn01-Hn99 can be
set in advance in the offset memory. The tool length compensation of the offset number Hn00 is always 0.The shape value
of the tool length compensation (n: X, Y, Z, A, B, C) allows the input range to be [-99999.999, 99999.9999].
Note
When the offset amount is changed with the offset amount, it simply becomes a new offset
amount, instead of the new amount of the offset and the amount of the compensation.
For example:
HZ01 offset amount of 20.0
HX02offset amount of -30.0
G90 H201 Z100.0 ; Z to 120.0
G90 HXO1 X100.0 ; X to 70.0
▲ To cancel the length compensation of the tool
To utilize the Hn00 to cancel the length compensation of the tool.
For example

nt of the Actual position


nsation 4 mm Offset position

Processing program (HZ1=- 4.0mm)


N1 G91 G00 X120.0 Y80.0 ; (1)
N2 Z-32.0 HZ1 ; (2)
N3 G01 Z-21.0 F1000 ; (3)
N4 G04 P2000 ; (4)
N5 G00 Z21.0 ; (5)
N6 X30.0 Y-50. 0 ; (6)

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

N7 G01 Z-41.0 ; (7)


N8 G00 Z41.0 ; (8)
N9 X50.0 Y30.0 ; (9)
N10 G01 Z-25.0 ; (10)
N11 G04 P2000 ; (11)
N12 G00 Z57.0 H0 ; (12)
N13 X- 200.0 Y-60.0 ; (13)
N14 M02 ; (14)

Chapter 5: User macro-program


5.1 Definition
User macro-program allows customers to use basic characters of program language such as variables, arithmetic operation,
logistic operation, bit manipulation, conditional transfer, cycle control, program change and etc. The application of
macro-program will make programming convenient, flexible, simple and fast. Greatly increasing the common use of
program, we just need to assign different main program for calling-in same subprogram to process same type parts.
5.2 Variables
Instruction format
#i;
Example: #1,#[#1+#2-12]
Descriptions of instruction
Variables type: according to variables number, variables could be divided in four types.
Variable No. Variable type Function
#0 Null variable This variable always be null and can’t be valued.

Local variable could be only used for storing data in macro-program, for
example, calculation result. Cut off the power, local variable will be
#1~#99 Local variable
initiated to null.

Common variable has same means in different macro-programs. When


cut off power, variable
#100~#199
Common variable #100~#199 will be initiated to null; variable’s value #500~#599 will be
#500~#599
stored. This data won’t lost under power off

#1000~ System variable Used for reading data while CNC is operating
Variable reference: If you want to use variable in program, adding address of variable number after specified instruction.
When you specifying variable by expression, locating the expression in bracket. For example: G01 X[#l+#2] F#3; G00
X-#l.
Note 1: Address O, G and N can’t cite variable, like O#100, N#120 were illegal reference;
2: Exceeding the Max. code value which was ruled by address, can’t use. For example, when #130 = 120, M#230
exceeded Max. code value.
Null variable: When the variable value was not defined, the variable is a null variable. If the variable # equal to zero, it
always be null variable which can’t be written but only read.
▲ When you citing an undefined variable (null variable), the address could be ignored.
When #1=<empty> When #1=0

G00 X100 Z#1 G00 X100 Z#1


↓ ↓
G00 X100 G00 X100 Z0

▲ Operation. Except use <Null variable > for assignment, under other condition, <Null variable> was same to “0”.

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

When #1=<null> When #1=0

#2=#1 #2=#1
↓ ↓
#2=<null> #2=0

#2=#1 * 5 #2=#1 * 5
↓ ↓

#2=0 #2=0
#2=#1+#1 #2=#1+#1
↓ ↓
#2=0 #2=0
▲ Condition expression, the <null> in EQ and NE not same to “0”
When #1=<null> When #1=0
#1 EQ #0
#1 EQ #0


True
False
#1 NE #0 #1 NE #0
↓ ↓
False False

#1 GE #0 #1 GE #0
↓ ↓
True False

#1 GT #0 #1 GT #0
↓ ↓
False False

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

4) Display of variable value: When variable displayed as null, variable value equal to null; when
variable displayed as “*****”, it means variable value overflowed.
5.3 System variable
System variable was used for reading and writing CNC inner data, such as: input port, output
port, tools offset value, current coordinate and etc. But some system variable could only be used
for reading.
Descriptions:
5.3.1 System macro-variable of interface signal
CNC has defined 96 units input signals and 96 units output signals of system macro-variable.
Micro input port: #1001~#1096 . Micro output port: #1101~#1196.
Valuing output macro-variable #1101~#1196 could change Y01~Y96 output signals status.
When the assignment was equal to “1”, connecting output signal; assignment equal to “0”, close
output signal.
But it’s invalid when output ports were not common use!
You can check the input status of input ports X01-X96 by detecting the value of input
macro-variable.
Corresponding table of input signal and system macro-variable:
Macro variables number Macro variables function Writing and reading function
#1001~#1096 Input port Only read
#1101~#1196 Output port Read and write
Input port 8bit read,#1=#1301
#1301~#1312 Only read
One time read-in X01~X08,
Output port 8bitread and write,
#1401~#1412 Read and write
#1401=0,one time Y01~Y08

Macro variables number Macro variables function Writing and reading function
#4007 Current tools number Only read
#4008 Current tools compensation number Only read
#6101~#6116 Z-axis 1~16 tools compensation Read and write
#6201~#6216 X-axis 1~16 tools compensation Read and write
5.3.2 System macro-variable of tools compensation
5.3.3 Other system variables
5.4 Arithmetic and logistic operation

Macro variables number Macro variables function Writing and reading function

#4001 Work-piece counter Read and write


#6001 Z-axis machine coordinate Only read
#6002 X-axis machine coordinate Only read
#6004 Z- axis absolute coordinate Only read
#6005 X- axis absolute coordinate Only read
The listed operations in following table could be conducted in variables.

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Expressions which were positioned at operator right hand could contain constants or variables
which were composed of functions or operators. In expression, variables #j and #k could be
valued by constants. Left variable could be valued by expression too.

Function Format Notes


Assignment #i=#j ; Assignment operation
Add #i=#j + #k ; Arithmetic operation
Subtract #i=#j - #k ; If j==i,use simplify characters(+=、-=、*=、
Multiply #i=#j * #k ; If #i = #i + #k, could be simplified as #i += #k。
Divide #i=#j / #k ;
And #i=#j & #k ; Or #i =#j AND #k ; Bit operation. This operation will force
translate floating point number to integral
Exclusive-OR #i=#j ^ #k ; Or #i =#j XOR #k ; number for conducting. Bit operation will be
Or #i=#j | #k ; Or #i =#j OR #k ;
conducted by the type of binary system of integer
Moving left #i=#j << #k ;
If j==i,could use simplified characters(&=、
Moving right #i=#j >> #k ;
^=、|=、《=、》=).
If #i = #i & #k, could be simplified as #i &= #k。

Equal to #i=#j == #k ; Or #i=#j EQ #k ;


Not equal to #i=#j != #k ; Or #i=#j NE #k ; Relational operation
GT or EQ #i=#j > #k ; Or #i=#j GT #k ; The result is 32 bit unsigned integer
GT or EQ #i=#j >= #k ; Or #i=#j GE #k ; 0 (FALSE) or 1 (TRUE)
Less than #i=#j < #k ; Or #i =#j LT #k ;
LT or EQ #i=#j <= #k ; Or #i=#j LE #k ;
Square root #i=SQRT[#j];
Absolute value #i=ABS[#j];
#i=FABS[#j];
Round-off #i=ROUND[#j];
Round up #i=FUP[#j];或 #i =CEIL[#j];
Round down #i=FIX[#j];或 #i ==FLOOR[#j];
Natural logarithm #i=LN[#j];或 #i =LOG[#j];
Exponential function #i=EXP[#j];

Sine #i=SIN[#j]; Trigonometric function. When the angle is


Anti-sine #i=ASIN[#j]; specified, 90°30' mean 90.5°.
Cosine #i=COS[#j]; Constants or expressions could replace #j。
Anti-cosine #i=ACOS[#j];
Tangent #i=TAN[#j];
Anti-tangent #i=ATAN[#j]
Descriptions:
Angles unit: The unit is(°)for functions such as SIN,COS,ASIN,ACOS,TAN and ATAN. 90°30'
will be written as 90.5°
ARCSIN # i=ASIN[#j]
▲When #j out of the range from -1 to 1, raise the alarm.
▲ Constants could replace variable #j
3) ARCCOS # i =ACOS[#j]

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

▲ Results input range:180°~0°


▲ Almost beyond the range from -1 to 1, raise the alarm.
▲Constants could replace variable #j
4) Napierian logarithm #i=LN[#j]
▲ When the anti-log(#j) was equal or less than 0, raise the alarm.
▲Constants could replace variable #j
5) Exponential function #i=EXP[#j]; constants could replace variable #j
6) Round functions
▲When the arithmetic operation or logical operation has the code of IF or While, and which
contains round functions, the round functions will round-off at first decimal.
For example: Operating #1=ROUND [#2], the position #2=1.2345, value of variable 1 is 1.0.
7) Round-up and round-down: When CNC operating numeric computation, the operated integers
absolute value greater than original absolute value, we called it as round-up. If the operated
integers absolute value less than original absolute value, we called it as round-down. Be careful
when handling negative values.
8) Divisor: In division or TAN[90], when there were values which were specified 0 as divisor,
raise the alarm.

5.5 Transfer and cycle


In program, use GOTO and IF statement could change controlled direction. There are three types
of transfer and cycle operation could be used.
▲GOTO statement(transfer with no condition)
▲IF statement(transfer with condition:IF…THEN…)
▲WHILE statement (cycle when…)

5.5.1 Transfer with no condition (GOTO statement)


Transfer to the program segment which signed sequence number. Specified sequence numbers
which were beyond 1-9999, raise the alarm. Expressions could be used to specify sequence
number.

GOTOn;
n:Sequence number (1~99999)

Instructions format
For example:
5.5.2 Condition control
GOTO1;
GOTO# 10;
▲Instructions format 1

IF[<condition expression>]GOTOn;

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

If the specified condition expression was true, transfer to program segment which has the
sequence number of n; If the specified condition expression was false, operating next program
segment.
For example:
If the value of #1 variable greater than 10, transfer to program segment which has the sequence number of N2.

If the condition is not satisfied If the condition is satisfied

Program

▲Instructions format 2
IF[Condition expression] THEN<Macro-program statement >;
If the condition is satisfied, conduct the statement which was after THEN, and only one
macro-program statement can be conducted.
For example
IF[#1 EQ #2] THEN #3=0;
If #1 and #2 have equal value, then assign 0 with variable #3;If #1 and #2 not have equal value, then sequence down an
not conduct assign statement which was following THEN.
Descriptions of instruction
Conditional expression must include conditional operator. At both sides of conditional operator,
there could be variables, constants or expressions. Expressions should be closed by bracket.
Conditional operator as follows:
Operator Meanings
EQ EQ(=)
NE NE(≠)
GT GT(>)
GE GE(≥)
LT LT(<)
LE LE(≤)
Example: Following program was used for calculating the sum of integer 1-10
O9600
#1=0; Initial value of storage and number variable
#2=1; Initial value of augend variable
N1 IF[#2 GT 10]G0T02; When augend greater than 10, transfer to N2
#1= #1+#2; Calculation summation
#2= #2+1 ; Next augend
G0T01; Transfer to N1
N2 M30; End of program.

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

5.5.3 Cycle (While statement)

Specifying a conditional expression after “WHILE”. When the specified condition is true, conduct
the program segment from Do to END; Or, it will jump to the program segment after END.

如果条件不满足 If the condition is not satisfied


如果条件满足 If the condition is satisfied
条件表达式 Conditional expression
程序 Program
▲Instructions format 1
WHILE[Conditional expression]DO m;
……
END m ;
m:Signs of conduct range specified cycle(1~1023)。

Descriptions of instruction:

If the result of expression is not equal to 0, we regard the result as true. Cycle conducting
statements from WHILE to END until the result of expression is false. When the If the result of
expression is equal to 0, jump to next program segment which was next to END statement. If the
result of expression is not integer, force translate it to integer, or it will alarm.
M is a positive integer, only used for matching statement DO and END.
For example:
……
N1 #1 = 1 ;
N2 #2 = 0 ;
N3 WHILE[#1 <= 100] DO 5 ;
N4 #2 += #1 ;(Calculating 1+2+3+……+100)
N5 #1 += 1 ;
N6 END 5;

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

……
When conducting this program, #1 means plus from 1 to 100, #2 means the summation of 1+2+3+……+100

▲Instructions format 2
DO m;
……
END m ;
m:Signs of conduct range specified cycle(1~1023)

Descriptions of instruction:
If there’s no specified “WHILE” for judging conditional statement in DO type statement, it’s
infinite cycle.
As the examples in format 1, if there’s no WHILE for judging condition, the values of #1 and #2
will infinite plus until data overflow and raising alarm.
For example:
……
N1 #1 = 1 ;
N2 #2 = 0 ;
N3 DO 5 ;
N4 #2 += #1 ;(Calculating 1+2+3+……+100)
N5 #1 += 1 ;
N6 END 5;
……
▲The mark m could be reused, using nested cycle is allowable (Max. Nested8 layers), but there
are some limits as follows:
1 DO and ENDm must be used in pairs (same m value), and DO must appeared earlier than
ENDm .
2 Two cycles can not inter-cross.
3 If you use cycle nested, marks of sub-cycle can not be same with parent-cycle.
3 GOTO statement could be transferred from interior-cycle to exterior-cycle, but can not be
transferred from exterior-cycle to interior-cycle, or the alarm will be raised when conduct to END
statement.

Chapter Six Comprehensive Example


6.1 Example of the grinder
After the process of N times, the grinding wheel is to compensate a certain distance
To define the parameters of the panel first
501 To compensate the processing times

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

502 To compensate the length


To record the number of processing with #500
Supposing that the grinding wheel is in the Z-axis direction, the number of tool should be
compensated
To set HZ1 to be the radius of the grinding wheel
Program 0001.NC
G90HZ1 ; to use offset 1 of Z-axis tool
M03S1000 ; 1to open spindle 1 IF[#500<#501] GOTO 10 ; if the number of processing
times is less than the set one, the item compensation will be ignored
#500=0; The processing technology will be cleared
#5083- =#502 Z-axis tool compensation minus each compensation
N10 Z0; from Z axis to processing position
G1X100F100 ; X axis starts processing
X10
G0Z10 ; Z axis lifts
#500+=1 Processing count is added one
MO5 to stop the spindle
M30
Tool compensation is reduced by the specified distance for each specified number of process.

6.2 to use macro operation to achieve no cumulative error


To define the parameters of the panel first
501 number of gears that consists of X axis of the split shaft and Z axis of the processing axis
G90G54
M03S100 ; to start spindle
G93X0 ; X machine coordinate is used to set as 0
#1=0 ; to clear the count of the split tooth
N10 G0Z0G1Z-10F20020
G0 Z10 ; the Z axis mentioned aove is processed one tooth
#1+=1 counter plus one
#2=#1*360. 0/#501 ; to calculate the position of the tooth
GOX#2 ; X goes to the position of the tooth
IF[#1>#501] GOTO 10 ; If the number of times fail to reach the last tooth, return to N10 to
continue
M05 ; to close spindle
M30 to end the program

6.3 Example of the punch and feeding


The example uses single-axis controller to complete feeding, processing and blanking to improve
processing efficiency.
To set parameters P0010 1
To set parameters P0011 0
To set parameters P0012 0

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

To set parameters P0013 1


To set parameters P0014 0
To set parameters P0015 0
Main program 00001.NC processing program
X1 dead point of the punch
Y1 give punch signal
Y2 to wait to be quicker
G90
G0Z0
M80 Z2; to clear the number of auxiliary relay of Z2
M71Z1; to wait for the feed to complete the auxiliary relay
M81 Y2;to wait to be quicker
G4100; to delay 0.1 seconds
M81 Y2; to set the auxiliary relay of Z2
G91
G22L10; to finish the cycle execution 10 times
Z10; to finish feeding 10mm
M82V1P500 ; to give the punch signal of 0.5 seconds
M71X1 ; to wait for the signal of dead
G23 ; loop execution
M80Y2 ; loose
G4P500 ; delay
M81Z3 ; to process for auxiliary relay and notify the feeding program
G9020 ; to return zero point
M99
Sub-A program 00002. NC feeding program
X2 detection of the suction
Y3 suction
Y4. upper and lower cylinder
Y5 left and right cylinder
M81Y4 ; the bottom of the cylinder
M81Y3 ; to open the suction
M71X2 ; feed is detected
M80Y4 ; to use cylinder
G4P500; to delay for 0.5 seconds
M81Y5 ; to advance cylinder
M7022 ;to wait for feed notification by the processing program
M81Y4 ;to stop the cylinder
G4P500 ; 0.5 seconds
M80Y3 ;less suction
G4P100 ; 0.1 seconds
M80Y4 ; to use cylinder
M81Z1 :to finish feeding

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

M71Z2 ;to wait to be quicker


M80Z1 ;to clear feed auxiliary relay
M80Y5 :to stop the cylinder
G4P500 ;to delay for 0.5 seconds
M99 ;loop execution

Sub-B program 0003. NC blanking program


X3 detection of the suction
Y6 suction
Y7 upper and lower cylinder
Y8 left and right cylinder
M71Z3 ; to wait for feed notification
M80Z3 ; to clear feed notification
M81Y7 ;cylinder
M81Y6; suction
M71X3 ;detection of the suction
M80Y7 ;to use cylinder
G4P500; 0.5 seconds
M81Y8 ; to advance cylinder
G4P500 ; to delay for 0.5 seconds
M81Y7 ; to stop the cylinder
G4P500 ; 0.5 seconds
M80Y6 ;less suction
G4P100 ; 0.1 seconds
M80Y7 ; to use cylinder
G4P500 ; 0.5 seconds
M80Y8 ;to stop the cylinder
G4P500 ;0.5 seconds
M99; loop execution

6.4 To make the halved punch by the triaxial circle


Triaxial circle makes the halved punch

to first define parameters of the panel


501 equal score
502 radius
The zero point is at the center of the circle.

Main program 00001.NC


G90G54G98HZ1
M03S1000
G0Z10
#1=0; ;the current angle

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

#10=0; ;the current number of holes


G22L#501 ; cycles
#2=COS[#1]*#502 ;the current X coordinate
#3=SIN[#1]*#502 ;the current Y coordinate
G73 X[#2]Y[#3]Z-20R0Q5J2F500 ; processing command of the deep hole G73
#10+=1;
#1=#10*360.0/#501 ; to calculate the angle of the next hole
G23 ; end of cycle
MO5
M30

6.5 To make punch by tri-axial rectangular array


to first define parameters of the panel
501 number of holes of X
502 number of holes of Y
503 X spacing
504 Y spacing
505 depth of the hole
The order of hole on the basis of the, zigzag
Main program 00001. NC
G90G54G98HZ1M03S.1000G0Z10
#2= #501-1 ;number of cycles of line, the first line does not need to loop
#3=#502-1 ;number of cycles of column, the first column does not need to loop
#4=#505 ;X-axis spacing, GOXOYO ;to the first point
G73Z[#505] ROQ5J2F500 ;fixed drilling command
G91 ;the increment counts in the below
G22L#3 ;cycles of column
G22L#2 ;cycles of line
X[#4] ; X refers to the increase of a spacing
G23 ; end of cycles of line
#4*=- 1 ; X spacing is reversed and the next line is advanced in the opposite direction
Y[#504] ;Y refers to the increase of a spacing
G23 :end of cycles of column
MO5 ;to stop the spindle
M30

Chapter Seven References


Basic methods of CNC milling machine programming
Command about coordinates and coordinates
Absolute value programming G90 and incremental value programming G91
For example: the tool is programmed with G90 and G91 command when it moves from the origin

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

to 1, 2, and 3 points in order.

G92 refers to the setting of the workpiece


coordinates

G92 refers to the setting of the workpiece


coordinates

G92 X X2 Y Y2 Z Z2
Then to set the origin of the workpiece from starting point of the tool, that is, X= -X2, Y=-Y2 and
Z= Z2.
1.1.3 selection of the workpiece coordinates G54-G59

coordinates of the
workpiece
G54 origin coordinates of the workpiece

G59 origin

offset of zero point of the workpiece

the origin of machine tool

selection of the workpiece coordinates (G54-659)

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

For example:the line of A-B-C-Dis as follows

the origin of
machine tool

the origin of

machine tool

the origin of machine


tool

the origin of workpiece


Programming as follows NO1 G54 G00 G90 X30.0 Y40.0 move quickly to the point of N02 G59
in the G54 Set G59 to the coordinates of the current workpiece N03 G00 X30.0 Y30.0 move to
B point in the G59 NO4 G52 X45.0 Y15.0 establish a local coordinates in the current workpieces
of G59 G52N05G00G90X35.0Y20.0 move to C point in the G52 N06
G53X35.0Y35.0 move to D point in the
G53 (mechanical coordinates system)....
Cognition of coordinate of the plane
selection of coordinate of the plane G17,G18,G19。

Supplement to circular interpolation command


For example1:

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Arc AB :absolute: G17G90 G02 X xb Y yb R rl F f;or G17G90 G02 X xb Y yb I(xl-xa)J(y1-ya)F f;


Increment:
G91G02 X (xb- xa)Y (yb-ya) R rl F f ;or G91G02 X(xb-xa)Y(yb-ya)I(x1- xa)J(yl-ya)F f;
For example2: to programm the arc

Large arc AB can be divided into four blocks per arc


G17 G90 G03 X0 Y25 R-25 F80G17 G90 G03 X0 Y25 I0 J25 F80G91 G03 X-25 Y25 R- 25 F8
0G91 G03 X-25 Y25 10 J25 F80
Small arc AB
G17 G90 G03 X0 Y25 R25 F80G17 G90 G03 XO Y25 I-25 J0 F80G91 G03 X-25 Y25 R25 F80
G91 G03 X-25 Y25 I-25 J0 F80
For example3: full circle programming
It is required to start from point A and implement counterclockwise circular interpolation and
finally return to point A.
G90 G03 X30 YO I-40 J0 F80 G91 G03 XO YO 1-40 J0 F80
For example4: G02/G03 to finish the space spiral feed

That is, in the instruction format of the original G02 and G03, a third axis movement command is
perpendicular to the processing plane, so that the arc feed is performed while the third axis
direction is being fed, whose composite track refers to spatial spiral.X, Y and Z are the end points
of the projected arc, and the third coordinate refers to the end point of the axis perpendicular to the

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

selected plane.

Track as shown above:


G91 G17 G03 X-30.0
Y30, 0
R30.0 210.0 F100 or : G90 G17 G03 X0 Y30.0 R30. 0
Z10,0 F100
Example of basic command programming
As shown in the figure, the outer contour of the finishing mill is positioned with the hole of φ30,
and the tool compensation is out of consideration at present.

Adjusting- tool point

G92 X150.0 Y160.0 Z120.0 create coordinates of workpiece and zero of the program
G90 G00 X100.0 Y60.0 move quickly to X=100,Y=60
2-2,0 S100 M03 move Z axis quickly to Z = -2, spindle
G01 X75.0 F100 make linear interpolation at X=75,Y= 60
X35.0 make linear interpolation at X=35, Y=60
G02 X15.0 R10. 0 make circular interpolation at X=15,Y=60
G01 Y70.0 make linear interpolation at X=15, Y=70
G03 X-15.0 R15.0 make circular interpolation at X=-15,Y=70

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.


TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

G01 Y60.0 make linear interpolation at X=-15,Y=60


G02 X-35.0 R10.0 make linear interpolation atX=-35,Y=60
G01 X-75.0 make linear interpolation at X=-75,Y-60
G09 YO make linear interpolation at X=-75,Y=0 X45.0 make
linear interpolation at X=45,Y=45
X75.0 Y20. 0 make linear interpolation at X=75,Y=20
Y65.0 make linear interpolation at X=75,Y=65,
After it,G00 X100, 0 Y60.0 quickly withdraw at the point of the tool of X=100,Y=60
Z120.0 quickly lift the tool to the point plane 7=120 of the opposit one
X150.0Y160.0 quickly withdraw at the point of the tool
MO5 M30 end the program and reset

TOPCNCWORKSHOP@OUTLOOK.COM TOPCNC WORKSHOP AUTOMATION TECHNOLOGY CO., LTD.

Вам также может понравиться