Delta Ia-Cnc Lathe PM en 20181227

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

Delta CNC Lathe Machine Solution G Command Guidelines

Industrial Automation Headquarters


Delta Electronics, Inc.
Taoyuan Technology Center
No.18, Xinglong Rd., Taoyuan District,
Taoyuan City 33068, Taiwan
TEL: 886-3-362-6301 / FAX: 886-3-371-6301

Asia EMEA
Delta Electronics (Shanghai) Co., Ltd. Headquarters: Delta Electronics (Netherlands) B.V.
No.182 Minyu Rd., Pudong Shanghai, P.R.C. Sales: [email protected]
Post code : 201209 Marketing: [email protected]
TEL: 86-21-6872-3988 / FAX: 86-21-6872-3996 Technical Support: [email protected]
Customer Service: 400-820-9595 Customer Support: [email protected]
Service: [email protected]
Delta Electronics (Japan), Inc. TEL: +31(0)40 800 3800
Tokyo Office
Industrial Automation Sales Department BENELUX: Delta Electronics (Netherlands) B.V.
2-1-14 Shibadaimon, Minato-ku De Witbogt 20, 5652 AG Eindhoven, The Netherlands
Tokyo, Japan 105-0012 Mail: [email protected]
TEL: 81-3-5733-1155 / FAX: 81-3-5733-1255 TEL: +31(0)40 800 3800

DACH: Delta Electronics (Netherlands) B.V.


Delta Electronics (Korea), Inc.
Coesterweg 45, D-59494 Soest, Germany
Seoul Office
Mail: [email protected]
1511, 219, Gasan Digital 1-Ro., Geumcheon-gu,
TEL: +49(0)2921 987 0
Seoul, 08501 South Korea
TEL: 82-2-515-5305 / FAX: 82-2-515-5302 France: Delta Electronics (France) S.A.
ZI du bois Challand 2, 15 rue des Pyrénées,
Delta Energy Systems (Singapore) Pte Ltd. Lisses, 91090 Evry Cedex, France
4 Kaki Bukit Avenue 1, #05-04, Singapore 417939 Mail: [email protected]
TEL: 65-6747-5155 / FAX: 65-6744-9228 TEL: +33(0)1 69 77 82 60
Delta Electronics (India) Pvt. Ltd. Iberia: Delta Electronics Solutions (Spain) S.L.U

Delta CNC Lathe Machine


Plot No.43, Sector 35, HSIIDC Gurgaon, Ctra. De Villaverde a Vallecas, 265 1º Dcha Ed.
PIN 122001, Haryana, India Hormigueras – P.I. de Vallecas 28031 Madrid
TEL: 91-124-4874900 / FAX : 91-124-4874945 TEL: +34(0)91 223 74 20

Solution
C/Llull, 321-329 (Edifici CINC) | 22@Barcrelona, 08019 Barcelona
Delta Electronics (Thailand) PCL.
909 Soi 9, Moo 4, Bangpoo Industrial Estate (E.P.Z), Mail: [email protected]
Pattana 1 Rd., T.Phraksa, A.Muang, TEL: +34 93 303 00 60
Samutprakarn 10280, Thailand

G Command Guidelines
Italy: Delta Electronics (Italy) S.r.l.
TEL: 66-2709-2800 / FAX : 662-709-2827 Ufficio di Milano Via Senigallia 18/2 20161 Milano (MI)
Piazza Grazioli 18 00186 Roma Italy
Delta Energy Systems (Australia) Pty Ltd. Mail: [email protected]
Unit 20-21/45 Normanby Rd., Notting Hill Vic 3168, Australia
TEL: +39 02 64672538
TEL: 61-3-9543-3720
Russia: Delta Energy System LLC
Americas Vereyskaya Plaza II, office 112 Vereyskaya str.
17 121357 Moscow Russia
Delta Electronics (Americas) Ltd.
Mail: [email protected]
Raleigh Office
TEL: +7 495 644 3240
P.O. Box 12173, 5101 Davis Drive,
Research Triangle Park, NC 27709, U.S.A. Turkey: Delta Greentech Elektronik San. Ltd. Sti. (Turkey)
TEL: 1-919-767-3813 / FAX: 1-919-767-3969 Şerifali Mah. Hendem Cad. Kule Sok. No:16-A
34775 Ümraniye – İstanbul
Delta Greentech (Brasil) S/A Mail: [email protected]
São Paulo Office
TEL: + 90 216 499 9910
Rua Itapeva, 26 – 3˚ Andar - Bela Vista
CEP: 01332-000 – São Paulo – SP - Brasil GCC: Delta Energy Systems AG (Dubai BR)
TEL: 55-11-3530-8642 / 55-11-3530-8640 P.O. Box 185668, Gate 7, 3rd Floor, Hamarain Centre
Dubai, United Arab Emirates
Delta Electronics International Mexico S.A. de C.V. Mail: [email protected]
Mexico Office TEL: +971(0)4 2690148
Vía Dr. Gustavo Baz No. 2160, Colonia La Loma,
54060 Tlalnepantla Estado de Mexico Egypt + North Africa: Delta Electronics
TEL: 52-55-2628-3015 #3050/3052 511 Cairo Business Plaza, North 90 street,
New Cairo, Cairo, Egypt
Mail: [email protected] www.deltaww.com
*We reserve the right to change the information in this guidelines without prior notice.
Preface
Thank you for purchasing this product. Before using this product, please read through this manual carefully to
ensure the correct use of the product. Please keep this manual handy for quick reference whenever needed.

This manual includes:


 G-code and command format of NC controllers
 M-code description of NC controllers
 Macros and variables of NC controllers

NC controller product features:


 Built-in 32-bit high-speed dual CPU for multi-task execution and performance improvement
 User-friendly HMI interface
 Servo Gain Auto-tuning Interface for different machine characteristics.
 CNCSoft software tools to facilitate the development of customized screen images
 Front USB interface (port) to facilitate data access, data backup, and parameters copy
 Different spindle control forms for you to choose from: communication type or analog
voltage type
 Serial I/O modules for flexible I/O configuration

How to use this manual:


You can use this manual as a reference for writing G-codes and using macro and variable syntax.
Please read through this manual before using and setting your NC controller.

DELTA technical services:


Please consult your DELTA equipment distributor or DELTA Customer Service Center if you
encounter any problems.

December, 2018 i
Safety Precautions

 Please refer to the pin assignment when connecting the wires and ensure this product is correctly
grounded.
 To avoid electric shock, do not disassemble the controller, change the wiring, or touch the power source
when power is on.

Pay attention to the following safety precautions at all times during installation, wiring, operation, maintenance,
and examination of the controller.

The symbols of “DANGER”, “WARNING”, and “STOP” indicate:

Danger. May cause severe or fatal injuries to personnel if the instructions are not followed.

Warning. May cause moderate injury to personnel, or lead to severe damage or even
malfunction of the product if the instructions are not followed.

Absolutely prohibited activities. May cause serious damage or even malfunction of the
product it the instructions are not followed.

Installation

 Comply with the methods specified in the user manual for installation, or it may cause
damage to the device.
 Do not expose this product to an environment containing vapor, corrosive gas,
inflammable gas, or other foreign matter, or it may result in electric shock or fire.

Wiring

 Connect the ground terminals to class-3 ground system. Ground resistance should not
exceed 100 Ω. Improper grounding may result in electric shock or fire.

Operation

 Correctly plan out the I/O actions with MLC Editor, or it may cause abnormal operation.
 Properly adjust the parameter settings of the machine before operation, or it may result in
abnormal operation or malfunction.
 Please ensure that the emergency stop can be activated at any time to avoid operating the
machine in the unprotected condition.

ii December, 2018
 Do not change the wiring when power is on, or it may cause electric shock or personnel
injury.
 Never use a sharp object to touch the panel, or it may make a dent in the panel and
cause abnormal operation of the controller.

Maintenance and Inspection

 Do no disassemble the panel or touch the internal parts of the controller when power is
on, or it may cause electric shock.
 Do not touch the ground terminal within 10 minutes after turning off the power, or the
residual voltage may cause electric shock.
 Turn off the power before replacing the backup battery, and recheck the system settings
afterwards.
 Do not obstruct the ventilation holes when operating the controller, or poor heat
dissipation may cause malfunction.

Wiring

 Power supply: to avoid danger, use a 24 VDC power supply for the controller and comply
with the wire specification when wiring.
 Wire selection: use stranded wires and multi-core shielded-pair wires for all signal
cables.
 Cable length: the maximum cable length for remote I/O and DMCNET is 20 m (65.62 ft);
for other signal cables, 10 m (32.81 ft).
 To control the input and output signals, an additional 24 VDC power is required for the
controller I/O and remote I/O.

Wiring of Communication Circuit

 DMCNET: the wiring materials should comply with the standard specification.
 Ensure that the wring between the controller and servo drive is secure, or it may cause
abnormal operation.

Note: the content of this manual may be revised without prior notice. Download the latest version at Delta’s
website (http://www.delta.com.tw/industrialautomation/).

December, 2018 iii


(This page is intentionally left blank.)

iv December, 2018
Table of Contents

1 G-code List
1.1 G-code list for lathe system ············································································· 1-2

2 G-code Description
2.1 G-codes for lathe system ··················································································2-3
G00: Rapid positioning ·····················································································2-4
G01: Liner interpolation ····················································································2-5
G02/G03: Circular interpolation ··········································································2-6
G04: Dwell time ······························································································2-9
G05: Parameter group change ·········································································2-10
G09: Exact stop ···························································································· 2-11
G10/G11: Data setting / cancellation ·································································2-12
G17/G18/G19: Plane designation ·····································································2-15
G21/G20: Metric / inch input ············································································2-15
G28: Return through reference point ·································································2-16
G29: Return from reference point ·····································································2-18
G30: Return to the 2nd, 3rd, or 4th reference point ··················································2-19
G31: Skip command ······················································································2-21
G32: Thread cutting ·······················································································2-22
G34: Variable lead threading ···········································································2-26
G40: Cancel tool nose radius compensation ·······················································2-28
G41/G42: Tool nose radius compensation left / right ·············································2-29
G52: Local coordinate system setting ································································2-37
G53: Machine coordinate system setting ····························································2-39
G54 - G59: Workpiece coordinate system selection ··············································2-40
G61: Exact stop mode (one-shot) ·····································································2-41
G64: Cutting mode ························································································2-41
G65: Macro call (one-shot) ··············································································2-42
G66/67: Continuous effect macro call / cancellation ··············································2-44
G71: Multiple type rough turning cycle ·······························································2-45
G72: Multiple type rough facing cycle ································································2-48
G73: Multiple type pattern repeating cycle ··························································2-51
G70: Multiple type finish turning cycle ································································2-53
G74: Multiple type face pecking cycle ································································2-55
G75: Multiple type axial pecking cycle ·······························································2-56

December, 2018
G76: Multiple type thread turning cycle ······························································2-59
G90: Axial turning cycle ··················································································2-61
G92: Threading cycle ·····················································································2-63
G94: Face turning cycle ··················································································2-66
G80: Cancel cycle ·························································································2-68
G83: Face drilling cycle ··················································································2-68
G84: Face tapping cycle ·················································································2-69
G85: Face boring cycle ··················································································2-70
G87: Side drilling cycle ···················································································2-71
G88: Side tapping cycle ··················································································2-72
G89: Side boring cycle ···················································································2-74
G90/G91: Absolute / incremental coordinates ······················································2-75
G50: Coordinate system setting / maximum spindle speed ·····································2-77
G98: Feed per minute (mm/min) ·······································································2-78
G99: Feed per revolution (mm/rev) ···································································2-78
G96: Constant speed surface control ·································································2-79
G97: Cancel constant speed surface control ·······················································2-79
Chamfer / corner rounding function ···································································2-80
Linear angle command ···················································································2-82

3 M-code Description
3.1 M-code Description ··························································································3-2
M00: Program stop (non-optional)·······································································3-3
M01: Program stop (optional) ············································································3-3
M02: End of program ·······················································································3-3
M30: End of program with return to program start position ·······································3-3
M98: Subprogram call ······················································································3-4
M99: Return from subprogram ···········································································3-4
3.2 Spindle and C-axis switching ·············································································3-5
3.2.1 Description for Spindle and C-axis switching ···············································3-5
3.2.2 Notes for Spindle and C-axis mode switching ··············································3-7

4 Macro and Variable


4.1 Variables ·······································································································4-2
4.1.1 Arguments and local variables ··································································4-3
4.1.2 Systems variables ·················································································4-3
4.1.3 Macro interface input / output ···································································4-6
4.2 Variable syntax ·······························································································4-8
4.3 Operation commands ·······················································································4-9

December, 2018
4.4 Control flow··································································································4-10
4.5 Use M-code, S-code, and T-code to call macro ····················································4-12

December, 2018
(This page is intentionally left blank.)

December, 2018
G-code list 1
This chapter provides the G-code list for you to quickly view all of the G-codes.

1.1 G-code list for lathe system ································································1-2

December, 2018 1-1


G-code List Lathe Machine Solution G Command Guidelines

1.1 G-code list for lathe system


This lathe system G-codes can be categorized into three types, which are A, B, and C. You can
use parameter P306 to switch the setting depending on your preference. Set 0 for type A, 1 for

1 type B, or 2 for type C. G-codes in this manual are written based on the type A G-codes.

A
Type
B C
Group Function description

G00 G00 G00 01 Rapid positioning

G01 G01 G01 01 Linear interpolation

G02 G02 G02 01 Clockwise (CW) circular interpolation

G03 G03 G03 01 Counterclockwise (CCW) circular interpolation

G04 G04 G04 00 Dwell time

G09 G09 G09 00 Exact stop

G10 G10 G10 00 Data setting

G11 G11 G11 00 Data cancellation

G17 G17 G17 02 X-Y plane selection

G18 G18 G18 02 Z-X plane selection

G19 G19 G19 02 Y-Z plane selection

G20 G20 G70 06 Inch input

G21 G21 G71 06 Metric input

G28 G28 G28 00 Return through reference point

G29 G29 G29 00 Return from reference point

G30 G30 G30 00 Return to the 2nd, 3rd, or 4th reference point

G31 G31 G31 00 Skip command

G32 G33 G33 01 Thread cutting

G34 G34 G34 01 Variable lead threading

G40 G40 G40 07 Cancel tool nose radius compensation

G41 G41 G41 07 Tool radius compensation left

G42 G42 G42 07 Tool radius compensation right

G50 G92 G92 00 Coordinate system setting / maximum spindle speed

G52 G52 G52 00 Local coordinate system setting

G53 G53 G53 00 Machine coordinate system setting

G54 G54 G54 12 1st workpiece coordinate system selection

G55 G55 G55 12 2nd workpiece coordinate system selection

G56 G56 G56 12 3rd workpiece coordinate system selection

G57 G57 G57 12 4th workpiece coordinate system selection

G58 G58 G58 12 5th workpiece coordinate system selection

1-2 December, 2018


Lathe Machine Solution G Command Guidelines G-code List

Type
Group Function description
A B C
G59 G59 G59 12 6th workpiece coordinate system selection

1
G61 G61 G61 13 Exact stop mode (one-shot)

G64 G64 G64 13 Cutting mode

G65 G65 G65 00 One-shot macro call

G66 G66 G66 14 Continuous effect macro call

G67 G67 G67 14 Cancel continuous effect macro call

G70 G70 G72 09 Multiple type finish turning cycle

G71 G71 G73 09 Multiple type rough turning cycle

G72 G72 G74 09 Multiple type rough facing cycle

G73 G73 G75 09 Multiple type pattern repeating cycle

G74 G74 G76 09 Multiple type face pecking cycle

G75 G75 G77 09 Multiple type axial pecking cycle

G76 G76 G78 09 Multiple type thread turning cycle

G90 G77 G20 09 Axial turning cycle

G92 G78 G21 09 Threading cycle

G94 G79 G24 09 Face turning cycle

G80 G80 G80 09 Cancel cycle

G83 G83 G83 09 Face drilling cycle

G84 G84 G84 09 Face tapping cycle

G85 G85 G85 09 Face boring cycle

G87 G87 G87 09 Side drilling cycle

G88 G88 G88 09 Side tapping cycle

G89 G89 G89 09 Side boring cycle

-- G90 G90 03 Absolute coordinates

-- G91 G91 03 Incremental coordinates

G98 G94 G94 05 Feed per minute (mm/min)

G99 G95 G95 05 Feed per revolution (mm/rev)

G96 G96 G96 17 Constant speed surface control (m/min)

G97 G97 G97 17 Constant speed surface control cancellation (rev/min)

December, 2018 1-3


G-code List Lathe Machine Solution G Command Guidelines

(This page is intentionally left blank.)

1-4 December, 2018


G-code Description 2
This chapter introduces the G-code formats supported by the NC series controllers
along with the application examples. You can learn more about G-codes in this chapter.

2.1 G-codes for lathe system ····································································2-3


G00: Rapid positioning ·······································································2-4
G01: Linear interpolation ·····································································2-5
G02/G03: Circular interpolation ····························································2-6
G04: Dwell time ················································································2-9
G05: Parameter group change ··························································· 2-10
G09: Exact stop ·············································································· 2-11
G10/G11: Data setting / cancellation ···················································· 2-12
G17/G18/G19: Plane designation ······················································· 2-15
G21/G20: Metric / inch input ······························································ 2-15
G28: Return through reference point ··················································· 2-16
G29: Return from reference point························································ 2-18
G30: Return to the 2nd, 3rd, or 4th reference point ···································· 2-19
G31: Skip command ········································································ 2-21
G32: Thread cutting ········································································· 2-22
G34: Variable lead threading······························································ 2-26
G40: Cancel tool nose radius compensation ········································· 2-28
G41/G42: Tool nose radius compensation left / right ······························· 2-29
G52: Local coordinate system setting ·················································· 2-37
G53: Machine coordinate system setting ·············································· 2-39
G54 - G59: Workpiece coordinate system selection ································ 2-40
G61: Exact stop mode ······································································ 2-41
G64: Cutting mode ·········································································· 2-41
G65: Macro call (one-shot) ································································ 2-42
G66/G67: Continuous effect macro call / cancellation ······························ 2-44
G71: Multiple type rough turning cycle ················································· 2-45
G72: Multiple type rough facing cycle ·················································· 2-48
G73: Multiple type pattern repeating cycle ············································ 2-51
G70: Multiple type finish turning cycle ·················································· 2-53
G74: Multiple type face pecking cycle ·················································· 2-55

December, 2018 2-1


G-code Description Lathe Machine Solution G Command Guidelines

G75: Multiple type axial pecking cycle ·················································· 2-56


G76: Multiple type thread turning cycle ················································ 2-59
G90: Axial turning cycle ···································································· 2-61

2
G92: Threading cycle ······································································· 2-63
G94: Face turning cycle ···································································· 2-66
G80: Cancel cycle ··········································································· 2-68
G83: Face drilling cycle ···································································· 2-68
G84: Face tapping cycle ··································································· 2-69
G85: Face boring cycle ····································································· 2-70
G87: Side drilling cycle ····································································· 2-71
G88: Side tapping cycle ···································································· 2-72
G89: Side boring cycle ····································································· 2-74
G90/G91: Absolute / incremental coordinates ········································ 2-75
G50: Coordinate system setting / maximum spindle speed ······················· 2-77
G98: Feed per minute (mm/min) ························································· 2-78
G99: Feed per revolution (mm/rev)······················································ 2-78
G96: Constant speed surface control ··················································· 2-79
G97: Cancel constant speed surface control ········································· 2-79
Chamfer / corner rounding function ····················································· 2-80
Linear angle command ····································································· 2-82

2-2 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

2.1 G-codes for lathe system


Absolute / increment command
Description: in the lathe system, you can assign absolute and incremental values for the
movements. If you assign absolute values in the command, the coordinate you
specify is based on the workpiece coordinate system origin. If you assign
incremental values in the command, the movement is the current position plus the
2
increments you specify. One block can have both absolute and incremental values
at the same time.
Absolute command Increment command
Code Corresponding axis Code Corresponding axis
X__ X axis U__ X axis
Y__ Y axis V__ Y axis
Z__ Z axis W__ Z axis
C__ C axis H__ C axis

Diameter / radius command


Description: the workpieces for machining are mainly in cylinder shapes in the lathe system,
so you can set the X-axis movement with diameter or radius values. When
assigning with diameter, the actual moving amount is 50% of the command value;
when using radius, the actual movement is the exact command value.
Use P306 to switch between diameter and radius commands:
1. Set 0 to assign with diameter (default).
2. Set 1 to assign with radius.

December, 2018 2-3


G-code Description Lathe Machine Solution G Command Guidelines

G00: Rapid positioning

Format: G00 X/U_Y/V_Z/W_ (applicable to single-axis, double-axis, and triple-axis


synchronous motion controls)

2 X/U_Y/V_Z/W_: end coordinates.

Description: G00 can move the tool center to the specified X-, Y-, and Z-coordinates.
When using G00, you can adjust the moving speed with the Rapid % key on the
secondary control panel instead of the F_ command.
Assume that the maximum speed of the X, Y, and Z axes (P316) is 15 m/min:
1. When the rapid feed rate is 100%, the axes operate at the maximum speed of
15 m/min.
2. When the rapid feed rate is 50%, the axes operate at a speed of 7.5 m/min.
3. When the rapid feed rate is 25%, the axes operate at a speed of 3.75 m/min.
4. When the rapid feed rate is 0%, the axes moving speed is determined by the
speed set in P315.
G00 is mainly used for rapid positioning instead of feed cutting. It is for applications
such as the tool moving from the machine origin to the cutting start point in rapid
traverse, or the tool retraction and positioning of X and Z axes after cutting.

[Example]

The following diagram illustrates the usage of G00. The tool moves from point A to point B in
rapid traverse.
Express with absolute values:
X100. Z100. (Point A coordinates)
G00 X50.0 Z60.0 (Point B coordinates)
Express with incremental values:
X100. Z100. (Point A coordinates)
G00 U25.0 W-40.0 (Point B incremental distance)

2-4 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G01: Linear interpolation

Format: G01 X/U_Y/V_Z/W_F_

2
X/U_Y/V_Z/W_: end coordinates.
F_: cutting feed rate in the unit of mm/min or min/rev.

Description: G01 enables the cutter to make linear interpolation from the current position to the
next command position at feed rate F. X-, Y-, and Z-coordinates represent the cutting
end point. This command is applicable to single-axis, double-axis, or triple-axis
synchronous motion control. The feed rate is set by the F parameter as well as
Rapid % on the secondary control panel. You can switch the unit with G98 (mm/min)
and G99 (min/rev).
[Example]

G98; (Set mm/min feed mode for the spindle)

G54 X0.0 Z0.0; (Program start point)

G00 X20.0; (Move to point A in rapid traverse)

G01 Z-18.0 F500; (From point A to point B)

X30.0; (From point B to point C)

X40.0 Z-26.0; (From point C to point D)

Z-41.0; (From point D to point E)

The F parameter is continuously effective, so you do not need to set it again if the cutting speed
is the same, as shown in the above program.

December, 2018 2-5


G-code Description Lathe Machine Solution G Command Guidelines

G02/G03: Circular interpolation

Format: arcs in the X-Y plane:


G17 G02 (G03) X/U_ Y/V_ R_ F_ or

2 G17 G02 (G03) X/U_ Y/V_ I_ J_ F_


Input parameter Z_ to generate a helical path in the X-Y plane.

Arcs in the Z-X plane:


G18 G02 (G03) Z/W_ X/U_ R_ F_ or
G18 G02 (G03) Z/W_ X/U_ K_ I_ F_
Input parameter Y_ to generate a helical path in the Z-X plane.

Arcs in the Y-Z plane:


G19 G02 (G03) Y/V_ Z/W_ R_ F_ or
G19 G02 (G03) Y/V_ Z/W_ J_ K_ F_
Input parameter X_ to generate a helical path in the Y-Z plane.

G02: clockwise (CW) circular interpolation


G03: counterclockwise (CCW) circular interpolation

X/U, Y/V, and Z/W: end coordinates expressed with absolute / incremental values
R: arc radius (The format expressed with R is called radius format)
I: distance from the arc start point to the arc center point in X-axis direction.
J: distance from the arc start point to the arc center point in Y-axis direction.
K: distance from the arc start point to the arc center point in Z-axis direction.
(The format expressed with I, J, and K is called center format)
F: feed cutting rate.

Description: G02 and G03 are circular interpolation commands. Since the workpiece is

three-dimensional, the circular interpolation direction (G02 or G03) varies in

different planes, as shown in the diagram below.

Definition: based on the right-handed coordinates, G02 is for clockwise direction while G03 is

for counterclockwise direction.

2-6 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Statement expressions with center format and radius format are as follows:

1. Radius format: R is the arc radius. Specify the start point, end point, and arc radius to form an
arc. There will be two arc segments as shown in the figure below. When R is a positive value,
it means the central angle ≦180°; if R is a negative value, it means the central angle > 180°.

When β > 180°, it means R is a negative value, so arc B is generated.

When α ≦ 180°, it means R is a positive value, so arc A is generated.

In the above diagram, assume that R = 50 mm and the end coordinates are (100.0 , 80.0), then:
Central angle > 180° (path B) G03 X100.0 Y80.0 R-50.0 F80
Central angle ≦ 180° (path A) G03 X100.0 Y80.0 R50.0 F80

2. Center format: I, J, and K are the relative distances from the arc start point to the circle
center, which are the incremental values from the start point to the center in the X-, Y-, and
Z-axis directions. See the figure below for description.

[Example]

Use G18 in the following example.

(1) G3 X-10. Z-5. I-R. F_ (1) G2 X10. Z5. KR. F_

(2) G2 X-10. Z5. I-R. F_ (2) G3 X-10. Z5. KR. F_

(3) G2 X10. Z-5. IR. F_ (3) G3 X10. Z-5. K-R. F_

(4) G3 X10. Z5. IR. F_ (4) G2 X-10. Z-5. K-R. F_

December, 2018 2-7


G-code Description Lathe Machine Solution G Command Guidelines

2
(1) G2 X_ Z_ K+B F_ (3) G3 X_ Z_ I+A F_

(2) G3 X_ Z_ I-A F_ (4) G2 X_ Z_ -B F_

[Example]

Description for using G01, G02, and G03.

O0003

G54 X0 Z0 S800 M3

G0 X41. Z0. Z2.

G0 X20. Z0.5

G01 Z-5. F0.12

G02 Z-15. R8. (1)

G03 Z-35. R13. (2)

G02 Z-45. R7.5 (3)

G03 X28. Z-65. R11. (4)

G01 X30. Z-73.

X40.2

M5
M30

2-8 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Instructions for G02/G03 circular interpolation:


1. After booting, the default machining plane is G18 (Z-X plane) in the lathe system.
Therefore, if the circular interpolation is in the Z-X plane, you can omit G18.

2
2. If a block has parameters I, J, K, and R at the same time, only parameter R is valid.
3. I0, J0, or K0 can be omitted.
4. If the end X-, Y-, and Z-coordinates are not specified, it means the start and end points are
the same, which cutting path will be a full circle. If the command is set in radius format,
the tool does not move.
5. The system prompts an alarm message “Arc radius error” when it is unable to form an arc
using the end coordinates and the set radius, and the deviation exceeds the value set in
machining parameter P323.
6. For a linear interpolation followed by a circular interpolation, you must use G02 or G03 to
switch the motion. To switch to linear interpolation, you must use G01.
7. If the circular interpolation command (G02/G03) has no R, I, J, and K parameters specified,
the motion path is the same as that of G01.

G04: Dwell time

Format: G04 X_ or
G04 P_

Description: this command specifies the dwell time of the current block. Parameter X sets the
dwell time and this value can be a decimal.
Parameter P also sets the dwell time but you can only input integers.

Setting range:
Setting range for dwell time (by parameter X)
Setting range 0.001 - 99999.999
Unit sec
Setting range for dwell time (by parameter P)
Setting range 1 - 99999999
Unit 0.001 sec

[Example]

G04 X1.5

G04 P1500

When you use the above two formats, their execution results are the same, the dwell time
during program execution is 1.5 seconds.

Note: you can use this command for machining a concave or drilling and this command enables the tool to

stop at the bottom and separate the chips from the workpiece.

December, 2018 2-9


G-code Description Lathe Machine Solution G Command Guidelines

G05: Parameter group change

Format: G05 P_

2
P_: parameter group number.

Description: use G05 to select the parameter group (20 groups available).
G05P_: set 1 - 20 to enable the group function; set G05P0 to cancel the parameter
group function and restore to the default settings.

You can individually set each parameter in a group. When you move the cursor to
the field, the status bar below shows its setting range. Press Enter and you can
input the values in the row. Meanwhile, the system checks whether the range is
valid; if the input value exceeds the range, the system prompts a warning window.

2-10 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G09: Exact stop

Format: G09 G01 X_ Y_

2
Description: because the tool cuts at a constant feed rate, the cutting command execution of the
next block will start before the current block execution completes. In this case,
there will be a small arc generated at the corner between motion blocks. To eliminate
this arc, you can use G09 to have the system confirm the tool position each time
it executes a motion block. Once the tool is in the right position that is consistent with
the command value, the execution for the next block starts. Therefore, there will be a
minor discontinuity between blocks when G09 is used, which improves the precision
at the cost of speed. This command is valid for cutting commands (G01, G02, and
G03) of a single block.

[Example]

Without G09
With G09

(1) G0 X0.0 Z0.0

(2) G09 G01 Z-50. F0.2 (Decelerates to stop and then starts executing the next block after the
position is confirmed.)

(3) G09 X50.0

(4) Z-50.0

(5) Tool feeding direction

December, 2018 2-11


G-code Description Lathe Machine Solution G Command Guidelines

G10/G11: Data setting / cancellation

Format: G10 L2 P_ X_ Y_ Z_ ; set the coordinate system.


G10 L10 P_X/U_Y/V_Z/W_R_Q_; set the tool length, cutter radius compensation,

2 and tool nose type.


G10 L11 P_X/U_Y/V_Z/W_R_Q_; tool wear and compensation for cutter radius wear.
G10 L20 P_X_Y_Z_; set the extension work coordinate system.
G10 L21 P_X_Y_Z_; set the software limit coordinates.
G10 L30 P_; set the spindle position offset.
G10 L1100 R_S_; set the maximum and current speed.
G10 L3100 P_; trigger the status M-code without stopping the motion.
G10 L4100 P_; cancel the status M-code without stopping the motion.
G11; cancel the data settings.

Description:
1. The format, G10 L2 Pˍ Xˍ Yˍ Zˍ, is for workpiece coordinate system data entry. When you
set 0 for P_, it means you are setting the offset coordinates of the workpiece coordinate
system; P1 - P6 correspond to G54 - G59 workpiece coordinate systems; and X, Y, and Z
specify the position of its coordinate system origin.
2. The format, G10 L10 P_ X/U_ Y/V_ Z/W_ R_ Q_, is for setting the tool length and tool
radius compensation data. P_ is the compensation number, X/U_ Y/V_ Z/W_ is the actual
tool length compensation data (U, V, and W for increment input), R_ specifies the
compensation for the tool radius, and Q_ sets the tool nose type. If you omit L10 when
setting the tool length / radius compensation, P_ will be [10000 + compensation number],
and the other commands remain unchanged.
3. The format, G10 L11 P_ X/U_ Y/V_ Z/W_ R_ Q_, sets the compensation data for tool wear
and tool radius wear. P_ sets the compensation number, X/U_ Y/V_ Z/W_ sets the actual tool
wear compensation data for each axis (U, V, and W for increment input), R_ sets the tool
radius wear compensation, and Q_ sets the tool nose type. If you omit L11 when using this
command, P_ is the compensation number, and the other commands remain unchanged.
4. In G10 L20, you can input P1- P64 for the P value to set the corresponding extension
workpiece coordinate systems.
5. G10 L21 P_: P1 sets the first set of the positive software limit;
P2 sets the first set of the negative software limit;
P3 sets the second set of the positive software limit;
P4 sets the second set of the negative software limit.
6. G10 L30 P_ sets the spindle positioning offset. P_ sets the offset angle in the unit of 0.01
degree; and G11 L30 cancels the spindle positioning offset setting (resets to Pr405 settings).

2-12 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

7. In G10 L1100 R_ S_, R_ sets the maximum rotation speed and S_ is the current rotation
speed setting. When you select DMCNET for the spindle, you can use this command to
control the analog output.

2
8. The command G10 L3100 P_ triggers the status M-code without stopping the motion;
G10 L4100 P_ cancels the status M-code without stopping the motion; and P2080 - P2111
(P_ value) correspond to M2080 - M2111.

Data entry type


L command format Argument format Data type description
Data entry for the workpiece coordinate system
L2 P_X_Y_Z_ P: 0 is the offset coordinate;
1 - 6 correspond to G54 - G59 work coordinates
Data entry for the tool length and tool radius
compensation
P: 1 - 64 correspond to 1 - 64 tool length compensation
L10 P_X_Y_Z_R_Q_ data
R: cutter radius compensation value
Q: tool nose type setting
Data entry for the tool wear and tool radius wear
compensation
L11 P_ X_Y_Z_R_Q_ P: 1 - 64 correspond to 1 - 64 tool wear data
R: tool radius wear compensation value
Q: tool nose type setting
Data entry for the workpiece coordinate system
L20 P_X_Y_Z_ P: 1 - 64 correspond to the 1st - 64th set of workpiece
coordinates
Data entry for the software limit coordinates
P: 1 is the first set of positive software limit;
L21 P_X_Y_Z_ 2 is the first set of negative software limit;
3 is the second set of positive software limit;
4 is the second set of negative software limit.
L30 P_ P_: spindle positioning offset (0.01 degree)
R: maximum rotation speed setting (rpm)
S: current rotation speed setting (rpm)
L1100 R_S_
When you select DMCNET for the spindle, you can use
this command to control the analog output.
L3100 P_ P: 2080 - 2111 represent M2080 - M2111.
L4100 P_ P: 2080 - 2111 represent M2080 - M2111.

December, 2018 2-13


G-code Description Lathe Machine Solution G Command Guidelines

[Example]
G10 L10 P1 X-50. W20. R2. Q3
or

2
G10 P10001 X-50. W20. R2. Q3

In the program above, it sets the tool No.1. The compensation for the X-axis tool length is -50.0;
the compensation for the Z-axis tool length is the original value plus 20.0; the tool radius is 2
and the tool nose type is 3.

Note:

1. G10 is a one-shot command which functions only within the block where it is specified. Compensation

amounts of the offset coordinates and the workpiece coordinate systems both refer to the origin of the

machine coordinate system. To cancel the data entry, you can execute G11.

2. When you execute L2 or L20 to change the coordinates, it functions only in the block that includes it.

When you use L10 - L13 to change the tool compensation data, you must execute the compensation

command (G41/G42) and specify the compensation data number to update the compensation value.

2-14 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G17/G18/G19: Plane designation

Format: X - Y plane: G17 {G01 - G03} X_ Y_{I_ J_ or R_}F_


Z - X plane: G18 {G01 - G03} Z_ X_{K_ I_ or R_}F_
Y - Z plane: G19 {G01 - G03} Y_ Z_{J_ K_ or R_}F_

Description: this command is for switching among the planes. If it is a triple-axis synchronous
motion, setting this command is not required. G17 - G19 can only be used in the
2
condition that allows linear interpolation, arc interpolation, or tool compensation.
The lathe system’s default plane after boot up is G18. In this case, you do not need
to set G18 additionally when selecting Z-X plane for machining.

G21/G20: Metric / inch input

Format: G21 or G20


G21: metric unit settings
G20: inch unit settings

Description: you can use this command to specify the unit in metric or inch. G21 and G20 are
only applicable to linear axes and do not affect the rotation angles of the rotation
axes. You must input this command before the program starts running; changing
the metric / inch setting is not allowed during program execution. This command
changes the numeric units relevant to the system, such as the cutting feed rate
(F value), coordinates command values, workpiece coordinate offset, tool
compensation amount, and moving distance. G21 and G20 commands are
continuously effective; once you have specified the system unit at the beginning of
the program, the program refers to this setting and uses metric or inch as the unit.
You cannot use both G21 and G20 in the same program.

December, 2018 2-15


G-code Description Lathe Machine Solution G Command Guidelines

G28: Return through reference point

Format: G28 X_ Y_ Z_ or
G28 U_ V_ W_

2 X_ Y_ Z_: intermediate point coordinates.

Description: G28 command can have the tool pass through the intermediate point and return to
the machine origin in rapid traverse (G00).

The format X_Y_Z_ refers to the intermediate point coordinates. The unspecified
axes will not pass through the intermediate point to return to the origin. If you have
set the tool radius compensation (G41 or G42), you need to cancel the setting;
otherwise, when the system is executing G28, the tool radius compensation and its
compensation distance setting are temporarily canceled when the tool goes to the
intermediate point and then returns to the machine origin without compensation.
Then, the tool radius compensation function resumes at the next motion block.
When G28 is in execution, the tool length compensation function remains effective
when the tool reaches the reference point. Next, the tool returns to the machine
origin without the tool length compensation. Then, the tool length compensation
resumes in the next motion block.

[Example]

Machine origin

B Intermediate point (20,10)

G28 X20. Z10. (Go through the intermediate point B and return to the machine origin.)

2-16 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Example]

When G28 is in execution, the increment / absolute status setting will affect the process of
returning to the machine origin. See the figure below.

Machine origin
2
B Intermediate point (10,10)

G28 X10.0 Z10.0

Machine origin

B Intermediate point (15,15)

G28 U10.0 W10.0

December, 2018 2-17


G-code Description Lathe Machine Solution G Command Guidelines

G29: Return from reference point

Format: G29 X_ Y_ Z_ or
G29 U_ V_ W_

2 X_ Y_ Z_: end of the motion in the block.

Description: G29 can have the tool move from the machine origin or any point, pass through the
intermediate point, and then go to the specified point in the block. X_Y_Z_ represents
the motion end coordinates. G29 and G28 must be used together, so the tool moves
to the intermediate point designated by G28 and then moves to the position specified
in G29 without calculating the actual moving distance from the intermediate point to
the machine origin.
If you execute G29 solely without G28 the intermediate point setting, the system will
display the alarm message and stop the motion.

[Example]

Machine origin

B (10,10) Intermediate point

G0 X5. Z5. (Move to point A)


G28 X10. Z10. (Move from point A to point B, and then go to the machine origin)
G29 X5. Z15. (Move from the machine origin to point B, and then go to point C)

2-18 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G30: Return to the 2nd, 3rd, or 4th reference point

Format: G30 P2 X_ Y_ Z_ or

G30 P3 X_ Y_ Z_ or

G30 P4 X_ Y_ Z_

P_: selection of the 2nd, 3rd, and 4th reference points.


2
X_ Y_ Z_: the intermediate point coordinates.

Description: P2, P3, and P4 commands correspond to the 2nd, 3rd, and 4th reference points
respectively, which you can set with the homing parameters P607, P608, and P609.
When you select the 2nd reference point, you can omit P2 in the command format.

X_Y_Z_ represents the intermediate point coordinates. The tool passes through
the specified intermediate point and then returns to the 2nd, 3rd, or 4th reference
point. To specify the 2nd, 3rd, and 4th reference point coordinates, you need set the
homing parameters.

G30 is mostly used for tool changing. When the command is set with absolute
values and the motion block G30 Z0.0 is executed, the Z axis returns to the
reference point (Z0.0) and then moves to the 2 nd reference point to complete the
designated motion.

You must cancel the tool compensation setting (using G40) before executing G28
and G30. If you execute G30 or G28, the block including this command will cancel
the tool radius compensation and tool length compensation. After homing to the
reference point is complete, the tool length compensation and tool radius
compensation resume in the next motion block.

B (15,15)
Intermediate point

G30 P2 X15. Z15.

Move from point A to point B, and then to P2 the 2 nd reference point.

As shown in the figure above, when you execute G30 with absolute values specified, the Z axis
first returns to the intermediate point and then goes to P2 to complete the homing procedure.

December, 2018 2-19


G-code Description Lathe Machine Solution G Command Guidelines

[Example 1]

Program example:

G30 P2 X15.0 Z15.0

G29 X20.0 Z25.0

[Example 2]

Machine origin

Program example:

G28 Xx1 Zz1

G30 P2 Xx2 Zz2


G29 Xx3 Zz3

2-20 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G31: Skip command


Format: G31 X_ Y_ Z_ F_P_

Description: you can use G31 to input an external skip signal for the specified axis that is
making a linear motion, so the execution of the motion path immediately stops and
the execution of the next block starts. This G-code is a one-shot command that is
valid in one block. G31 cannot be executed when tool radius compensation
2
(G41/G42) is functioning. Thus, cancel the tool compensation (G40) before using
this command.

Follow the instructions before using G31 Skip command:


1. You can enable the G31 high speed input 1 or 2 with the Pr46 setting.
2. If you do not assign the P_ value in G31, the system refers to the setting of Pr307 instead.
G31 selection range: 0 - 3;
0: no selection;
1: triggered by HSI 1;
2: triggered by HSI 2;
3: triggered by either HSI 1 or HSI 2
3. If you assign the P_ value in G31, the system will not refer to the setting of Pr307.
The P_ value determines which HSI to trigger. Set P1 to trigger with HSI 1, set P2 to
trigger with HSI 2, or set P3 to trigger by either HSI 1 or HSI 2.

[Example1]

G00 X5. Z5.

G01 G31 Z80.0 F0.5

X40.0

(1) Skip signal; (2) Original program path

The motion path in dotted line shows the path without the skip command input during the
process; on the other hand, if there is a skip signal input, the program stops the current block
execution once the signal is input, and the execution for the next block starts, as shown as the
path in solid line.

December, 2018 2-21


G-code Description Lathe Machine Solution G Command Guidelines

[Example 2]

2 G00 X5. Z5

G01 G31 Z25.0 F0.5

X40.0 Z50.0

(1) Skip signal; (2) Original program path

If there is no skip signal input in the process, the actual path is shown as the dotted line in the
figure above. If you input a skip signal, the actual path is shown as the solid line; the tool skips
the current point as soon as the signal is input and starts executing motions of the next block.

G32: Thread cutting

Format: G32 X/U_ Z/W_ F_ Q_

X/U_ Z/W_: end coordinates for threading.


F_: lead; the linear distance of one thread rotation.
Q_: start angle of the thread in the unit of 0.001. The default is 0.

Description: G32 is a threading command for the applications of straight threading, tapered
threading, scroll threading, and other types of thread machining.

(1) Incorrect leads; (2) Spindle Z-pulse; (3) The point for entering the thread

2-22 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Types of threads]

(1) Straight thread; (2) Tapered thread; (3) Scroll thread (face)

Note:

1. You must execute G32 Thread cutting when the spindle speed is fixed.

2. When threading, you cannot manually adjust the spindle feed rate; the spindle speed keeps at 100%.

3. If you press Feed Hold during threading, the threading motion does not stop immediately; instead,

it stops at the end of the next block that has no threading command.

4. Pressing the RESET key can stop the threading operation immediately but causing damage to the

thread.

5. If the spindle speed is 3,000 rpm and the pitch (F) is 1.5, the Z axis threading feed rate is 4,500 mm/min.

If the alarm B01D Spindle overspeed occurs, it means the feed axis speed exceeds the maximum

and you need to lower the spindle speed.

6. The lag of servo system might produce incorrect leads at the start and end points when threading.

To avoid affecting the screw thread function, the specified threading length has to be longer than the

actual required length.

December, 2018 2-23


G-code Description Lathe Machine Solution G Command Guidelines

[Example]

T0202

M3 S1000

G0 X40.

Z15.
X17.45 (1) Height for the first thread cutting

G32 Z-30. F1.5 (2) Threading

G0 X40. (3) X axis retraction using G0 command

Z15. (4) Z axis retraction using G0 command

X17.20 (1) Height for the second thread cutting

G32 Z-30. F1.5 (2)

G0 X40. (3)

Z15. (4)

X17.00 (1) Height for the third thread cutting

G32 Z-30. F1.5 (2)


G0 X40. (3)

Z15. (4)

X16.85 (1) Height for the forth thread cutting

G32 Z-30. F1.5 (2)

G0 X40. (3)

Z15. (4)

X16.8 (1) Height for the fifth thread cutting

G32 Z-30. F1.5 (2)

G0 X40. (3)

Z15. (4)

M5

M30

2-24 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Example] Multi-start threads

L (lead) = n (number of threads) x pitch

2
Main program Subprogram

T0202 O3300

M3 S1000 G32 Z-30. F3 Q#1 (Substitute A_ into Q#1, which is

G0 X45. the thread offset angle)

Z10. G0 X45.

G66 P3300 A0 Point to enter the thread (1) Z10.

X17.45 M99

X17.20

X17.00

G67

G66 P3300 A120000 Point to enter the thread

(2)

X17.45

X17.20

X17.00

G67

G66 P3300 A240000 Point to enter the thread

(3)

X17.45

X17.20

X17.00

G67

G0 X45.

Z10.

M30

December, 2018 2-25


G-code Description Lathe Machine Solution G Command Guidelines

G34: Variable lead threading

Format: G34 X/U_ Z/W_ F_K±

2
X/U_ Z/W_: end coordinates for threading
K_: the increments per threading; a negative value represents the amount of threads to
be reduced.
F_: the pitch between each thread.
Q_: start angle of the thread in the unit of 0.001. The default is 0.

Description: when G34 is applied, the system refers to the increment and decrement of lead
specified in G34 to perform variable lead threading.
Lead: linear distance of one thread rotation.
Pitch: distance between two adjacent threads.

Lead speed

1
Lead distance: d = Vo t + a𝑡 2
2

Vo: initial pitch of screw thread (F)

t: number of screw threads


a: increment in pitch per thread
rotation (K)

[Example]
1
Lead of the 1st spindle revolution d = F ∗ 1 + ∗ 𝐾 ∗ 12 = 𝐹 + 0.5𝐾
2
1
Lead of the 1st and 2nd spindle revolution d = F ∗ 2 + ∗ 𝐾 ∗ 22 = 2𝐹 + 2𝐾
2

(Lead of the 1st and 2nd spindle revolution) – (Lead of the 1st spindle revolution) = (Lead of the

2nd spindle revolution):


(2F + 2K) − (F + 0.5K) = F + 1.5K

Note:

1. You must execute G34 thread cutting when the spindle speed is fixed.

2. When threading, you cannot manually adjust the spindle feed rate; the spindle speed keeps at 100%.

3. If you press Feed Hold during threading, the threading motion does not stop immediately; instead,

it stops at the end of the next block that has no threading command.

4. Pressing the RESET key can stop the threading operation immediately but causing damage to the

thread.

5. If the spindle speed is 3,000 rpm and the pitch (F) is 1.5, the Z axis threading feed rate is 4,500 mm/min.

If the alarm B01D Spindle overspeed occurs, it means the feed axis speed exceeds the maximum

and you need to lower the spindle speed.

2-26 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

6. The lag of servo system might produce incorrect leads at the start and end points when threading.

To avoid affecting the screw thread function, the specified threading length has to be longer than the

actual required length.

[Example]
2

Main program Subprogram

T0101 // Select tool No.1 O0034

M03 S600 // Spindle rotates forward at 600 rpm G34 Z-30. K0.5 F1 // (3) Execute G34 and

G0 X50. Z5. // (1) Move to the engaged point in rapid thread to Z-30 with

traverse the increment pitch of

G66 P0034 L1 // Macro call: execute subprogram 0.5 mm per spindle

O0034 once revolution and default

X17.65 // (2) Threading depth pitch of 1 mm.

X17.45 // (2) Threading depth X50. // (4) X axis retraction


X17.25 // (2) Threading depth Z5. // Return to thread start point

X17.05 // (2) Threading depth M99 // Return to main program

G67 // End of the macro call command

G0 X50. Z5. // Retract to the safety point in rapid

traverse

M5 // Spindle stop

M30 // Program end

December, 2018 2-27


G-code Description Lathe Machine Solution G Command Guidelines

G40: Cancel tool nose radius compensation

Format: G40
or

2 G40 X_ Z_

Description: if the tool path does not need tool nose radius compensation, you can use G40
command to cancel the compensation path. The compensation command is a
status command, so it continues to function unless you cancel it.
When executing the homing command, the tool radius compensation function is
temporarily canceled while the tool is returning to the reference point. Then, the
compensation function resumes in the next motion block. Please note that the tool
radius compensation cancellation is not applicable to an arc motion path.

[Example]

(1) G0 X40. Z20. (Start point)

(2) G41 G1 X20. Z0. F0.25 (Enable tool compensation)

(3) Z-30.

(4) X40.

(5) G40 G0 X60. Z-20. (End point of tool compensation)

2-28 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G41/G42: Tool nose radius compensation left / right

Format: G00 G41 P_ or


G00 G42 P_
G41: tool radius compensation left
G42: tool radius compensation right

P_: coordinates of the target point.


2
Description: generally, there is a deviation between the actual contour and the programmed
contour when turning in an arc or a diagonal path. It is because the tool nose is
usually arc-shaped and the coordinates specified in the program are referring to the
hypothetical tool nose position. In this case, G41/G42 can compensate the tool nose
radius error based on the settings of the tool radius, tool nose type, and
compensation left / right, and can automatically calculate the compensation amount.

(1) Actual machining contour; (2) Machining contour set in the program;
(3) Tool nose center; (4) Hypothetical tool nose position

When using the tool nose radius compensation, you must specify the positive compensation
tool number, TXXXX.

December, 2018 2-29


G-code Description Lathe Machine Solution G Command Guidelines

[Compensation setting of the actual machining]

2
(1) Machining outer diameter and face; (2) Machining inner diameter

Tool nose type setting: in general, the tool nose is arc-shaped and the tool nose position varies
with the tool types, as shown in the figures below. Input the corresponding
tool nose type number in the type field of the OFS group tool register.

[Tool nose types]

(1) Tool nose No.0 and No.9 (2) Tool nose No. 1 - 4 (3) Tool nose No. 5 - 8

[Tool radius compensation and compensation for tool radius wear]

(1) Actual tool nose position; (2) Hypothetical tool nose position when calibration;

(3) R value of tool nose radius compensation; (4) Tool nose wear compensation

2-30 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Notes for tool radius compensation:

1. This compensation command can be used with G00 or G01 in the same block. However,

it has to be a motion block (tool radius compensation enabled) in order to have the compensation

2
function work.

2. This compensation command cannot be used in the block that includes G02 and G03.

To use the compensation function for an arc path, you have to first set the tool radius compensation

function for the linear motion path. When the compensation is active, canceling the tool radius

compensation in the arc path is not allowed.

3. During program editing, please specify the tool radius compensation number (e.g., T0111 and T0212).

Each tool radius compensation number corresponds to a number in the compensation data table.

4. If there is a change in the signs (+, -) of the compensation value, the compensation direction specified

in G41 and G42 will change accordingly. For example, when you assign a positive value in G41, the

compensation direction is left; when you assign a negative value, the compensation direction

becomes right. Likewise, when you assign a positive value in G42, the compensation direction is right;

when you assign a negative value, the compensation direction is left.


5. If the tool radius compensation function (continuous effective) is active and G28 or G29 is executed,

the compensation will be temporarily canceled. However, the system will reserve this state setting so

the compensation resumes in the next motion block.

6. When the tool radius compensation is executed and the tool completes the programmed path, you

must execute G40 to cancel the compensation function. The best timing to use G40 to cancel the tool

radius compensation is after the tool has disengaged from the workpiece.

December, 2018 2-31


G-code Description Lathe Machine Solution G Command Guidelines

[Example 1]

When using tool nose type 3, the machining condition with compensation is as follows.

(1) Program tool path


(2) Compensation tool path
(3) Machining contour without tool compensation;
(4) Tool nose path after compensation;
(5) Machining contour after compensation

2-32 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Example 2]
When using tool nose type 0 or 9, the machining condition with compensation is as follows.

(1) Program tool path


(2) Compensation tool path
(3) Tool center path after compensation
(4) Tool center path without compensation and machining contour with compensation
(5) Machining contour when tool compensation is disabled

When compensation is enabled, the linear moving amount and inner arc interpolation radius

must be ≧ the tool nose radius. Otherwise, there will be interference with the compensation

vector thus causing excessive cutting. When this issue occurs, the controller will stop running

and display the alarm message, as shown in the figure below.

December, 2018 2-33


G-code Description Lathe Machine Solution G Command Guidelines

The canceled moving amount of the tool radius compensation must be ≧ the tool radius.
Otherwise, there will be interference with the cutting path thus causing excessive cutting.
When this issue occurs, the controller will stop running and display the alarm message,

2
as shown in the following figure.

Canceled compensation distance (G40) < Tool nose radius R

The tool radius compensation is not operable in the following conditions:


When you execute tool compensation for the motion block following G40.
Compensation path: compensate for both the start and end points of the tool path.
The compensation motion diagram is shown as below.
Line to line Line to arc

2-34 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Types of tool radius compensation path:


For the compensation path, you must consider the included angle θ (180°>θ>90°, 0<θ<90°)
formed between each block.

2
1. If 180°>θ>90°, the tool radius motion path is inward-shaped.
2. If 0<θ<90°, the tool radius motion path is outward-shaped.
Inward angle Outward angle

Inward angle - arc to line Outward angle - arc to line

Inward angle - arc to arc Outward angle - arc to arc

December, 2018 2-35


G-code Description Lathe Machine Solution G Command Guidelines

Compensation path switch:


1. The motion path without compensation transits to the tool center motion path with
compensation.
2. When the compensation is in execution, the compensation continues to function for the

2 motion path; if you use G40 to cancel the compensation path or directly change the
compensation direction, the motion paths are shown as follows.
G40 > G41 G40 > G42

G41 > G40 G42 > G40

G41 > G42 G42 > G41

2-36 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G52: Local coordinate system setting

Format: G52 X_ Y_ Z_

2
X_ Y_ Z_: local coordinates system origin.

Description: during program editing, you can designate a sub-coordinate system based on the
workpiece coordinates for specifying the path. And this assigned sub-coordinate
system is called a local coordinate system. Set absolute values in G52 and then
you can create a local coordinate system in the current workpiece coordinate
system (G54 - G59). Please note that G52 is valid only when it is set with absolute
values instead of incremental values. Command G52 specified with zero cancels
the local coordinate system settings.

[Example1]

(A) G54 coordinate system; (A’) new G54 coordinate system

G54 X10. Z10.; Move from the origin to point (1)

G52 X20.0 Z40.0; G54 coordinate system origin shifts to point (2)

G00 X20.0 Z20.0; Move to point (3) in the new G54 coordinate system

December, 2018 2-37


G-code Description Lathe Machine Solution G Command Guidelines

[Example 2]

(A) G54 coordinate system; (A’) new G54 coordinate system;

(B) G56 coordinate system; (B’) new G56 coordinate system

G54 G00 X5. Z10.; Move from G54 coordinate system origin to point (1)

G52 X10. Z20.; G54 coordinate system origin shifts to point (2)

G00 X20. Z20.; Move to point (3) in the new G54 coordinate system

G56 G00 X10. Z40.; Move to point (4) in the new G56 coordinate system

Note:

1. When G52 command is effective and the current workpiece coordinate system converts to another

coordinate system, the shift setting of G52 is also effective after the conversion.

2. To cancel the local coordinate setting, set 0 for X, Y, Z in G52 (format: G52 X0 Y0 Z0).

2-38 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G53: Machine coordinate system setting

Format: G53 X_ Y_ Z_

2
X_ Y_ Z_: actual arrival position in the machine coordinate system.

Description: coordinates (X, Y, Z) specify the actual end point in the machine coordinate system
set in the program. Machine suppliers usually use this command to set the tool
change position, which is given based on the machine coordinates. You must set this
command in the absolute format; G53 with increment format will not be executed.
Command G53 is a one-shot G command and is valid for single block. After
machine booting and before using G53 to set the coordinate system, please
complete the homing procedure in auto or manual mode. When G53 is executed,
the tool moves in rapid traverse (G00) and both tool radius compensation and tool
length compensation are canceled automatically. The tool radius compensation
resumes at the next motion block while the tool length compensation will function
unless you set it again.
Note:

1. Command G53 functions only when specified in the absolute format. G53 set with incremental

values will not be executed; however, the status command such as G00/G01 in the same block will

remain effective and continue to function in the next block.

2. If the block contains G53 and includes an axial command, the axis moves to the specified position;

otherwise, the axis does not move.

3. When one block contains both commands G53 and G28, the command read later is effective.

If G53 is effective, the movement is made based on the machine coordinates. If G28 is effective,

the movement is made based on the absolute coordinates.

[Example]
Example 1:
G53U150.W-150. (It is in the increment format so this block is omitted.)

Example 2:
G53X50.Z-50. (Move to the actual machine coordinates X50. Z50.)

Example 3:
G1G53X100.Z-100.F1000 (Execute this block with G00 rapid traverse)
X50.Y50. (The motion in this block is changed to G01F1000.)

December, 2018 2-39


G-code Description Lathe Machine Solution G Command Guidelines

G54 - G59: Workpiece coordinate system selection

Format: G54 X_ Y_ Z_ or
G55 X_ Y_ Z_ or

2 G56 X_ Y_ Z_ or
G57 X_ Y_ Z_ or
G58 X_ Y_ Z_ or
G59 X_ Y_ Z_

Description: G54 - G59 allows you to assign any one of the 6 general coordinate systems as the
workpiece coordinate system. To create a workpiece coordinate system, you can
first move the tool from the machine origin to the program origin (X, Y). Then, input
the position data in the [OFS group] for the Workpiece coordinates system settings
(G54 - G59). Next, use the workpiece coordinate ID to set the workpiece origin.
In addition, the system also provides 64 extension workpiece coordinate systems
for selection. You can designate one by setting the P_ value within the range of
1 - 64 in G54. For example, if G54 P10 X_ Y_ Z_ is set, it means the 10th
coordinate system in the extension workpiece coordinate system is used.

[Example]

Machine origin (0, 0)

G00 G55 X20 Z10


G00 G54 X20 Z20

With the workpiece coordinate system settings, you can easily calculate and design the
programming path, and create multiple coordinate systems on the work platform for switching
among programs. As shown in the figure above, when coordinate origin is changed, you can
simply edit the workpiece coordinate data instead of creating another program to carry out
machining operations.

2-40 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G61: Exact stop mode (one-shot)

Format: G61

2
Description: G61 and G09 function the same except that G09 is a one-shot command (only
becomes effective when specified) while G61 is not. After G61 is used, each time
the system executes G01, G02, and G03, it decelerates to stop for inspection.
You can use G64 (cutting mode) to cancel G61 mode or it remains effective.
Note: the machine default is G64.

[Example]

Tool path in G61 mode

Tool path in G64 mode

G61 G91 G01 X100. F200. (Exact positioning)

Z100. (Exact positioning)

G64 (Exact positioning stops)

G64: Cutting mode

Format: G64

Description: when G64 is used and during the transition between blocks, the tool moves at a
constant speed instead of decelerating to full stop at the end of each motion block.
Normally, the initial status of the system is set to G64 cutting mode. Unlike the
motion status of G61, G64 enables the tool to cut at a constant feed rate and the
tool does not decelerate to stop between motion blocks.
However, deceleration to full stop for inspection takes place in the following
circumstances when G64 is in use:
1. The block contains a G00 command (positioning in rapid traverse)
2. The block contains a G09 command (exact stop)
3. The next block has no motion commands

December, 2018 2-41


G-code Description Lathe Machine Solution G Command Guidelines

G65: Macro call (one-shot)

Format: G65 Pˍ Lˍl

Pˍ: program number.

2 Lˍ: number of repetitions.


lˍ: independent variable.

Description: you can use G65 to call a macro program. Macro programs are used for variable
operations, MLC data input / output, control, making statement and discrepancy,
and enable the system to perform calculations and measurements.

[Example]
Main program Subprogram
N0010 O1010
N0020 G65 P1010 L2 A5.0 B3.0 N1020 #3=#1+#2
N0030 N1030
N0040 N1040
N0050 N1050 M99

After the macro program is executed, the program returns to the block following G65 command
in the main program, which means the block following G65 is executed. See the example
above, A5.0 represents variable #1, which value is 5.0. Please refer to the table below.

NC position Local variable NC position Local variable NC position Local variable


A #1 I #9 T #20
B #2 J #10 U #21
C #3 K #11 V #22
D #4 M #13 W #23
E #5 Q #17 X #24
F #6 R #18 Y #25
H #8 S #19 Z #26

2-42 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Program illustration]

O0000; (1) (2)


O0000; O0001;
… G65 P1 ...
M98P1000; ... #1 = 2;
… M98P1000; ...
M30; M99; M99;

2
(16) (3)

(4)
O2000; (5) O0002;
(15) G65 P2; ...
... #1 = 2;
M98P3000; ...
M99; (6) M99;

(7)
O3000; (8) O0003;
(14) G65 P3; ...
... #1 = 2;
M98P4000; ...
M99; (9) M99;

(10)
O4000; (11) O0004;
(13) G65 P4; ...
... #1 = 2;
... ...
M99; (12) M99;

Command G65/G66 can nest macros up to 8 layers. When using with M98 the subprogram call,
the maximum layer it can call remains 8.

December, 2018 2-43


G-code Description Lathe Machine Solution G Command Guidelines

G66/G67: Continuous effect macro call / cancellation

Format: G66 Pˍ Lˍl or


G67

2 Pˍ: program number.


Lˍ: number of repetitions.
lˍ: independent variable.

Description: functions of G66 and G65 are the same except that G65 is a one-shot command.
When G66 is used, each block will execute the macro program call unless there is
a G67 command that cancels the execution of G66. If G67 is not executed, then the
macro call command continues to function.

[Example]

Main program Subprogram

O0008
O0001
#3 = #1 + #2
G91 G00 Z#23
Z - #3
G66 P0008 L1 A2.0;
After moving, execute O0008 M99
X3.0;
After moving, execute O0008 Return to O0001
G91 G00 Z10.;

Z10.; After moving, execute O0008

G67;

X10.;

2-44 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G71: Multiple type rough turning cycle

Format: G71 Ud Re;


G71 P_ Q_ Uu Ww F_ S_ T_;

Ud: roughing depth per move in X-axis direction (users can only input radius value).
You can use machining parameter 312 to specify the default value.
Re: retraction amount (input radius value only), which default can be specified with
2
machining parameter 313.
P_: start block number for contour finish turning.
Q_: end block number for contour finish turning.
Uu: finish allowance of X axis (diameter / radius).
Ww: finish allowance of Z axis (diameter / radius).
F_: feed rate.
T_: tool number.
S_: spindle speed.

Description: when G71 is executed, the system first reads the end dimension. Next, the system
automatically calculates the outer diameter turning path of the workpiece by
referring to the parameter settings and then starts the rough turning cycle.

December, 2018 2-45


G-code Description Lathe Machine Solution G Command Guidelines

[Example]

G54 X40.0 Z5.0

M03 S1000

G71 U2. R3.

G71 P50 Q60 U0.2 W0.0 F0.2 S1000

N50 G01 X5.0 Z0.0 F0.15 (1)

Z-5. (2)

X10. (3)

G02 X20. Z-15. R10. (4)

G01 Z-20. (5)

N60 X40. (6)

M5

M30

2-46 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Workpiece position and cutting direction]

The figure above shows the workpiece position and the cutting direction corresponding to the
positive / negative U and W values; 1 - 4 represent the four quadrants respectively.
A: start point of the cycle
B: start point of the cutting path
C: end point of the cutting path

Note:

1. You can use G71 rough turning cycle to perform turning for the concave-shaped workpieces.

2. The P_ and Q_ values specifying the finish cutting sequence cannot be repeated in the program.

3. In the finish turning program, the blocks without movement commands or N, F, S, M, or T command

will be omitted.

4. If the command does not specify the cutting depth and retraction amount, the system automatically
refers to the parameter settings.

5. The tool compensation does not function when G71 rough turning cycle is used.

6. An alarm will occur if the system does not read the P_ and Q_ values that specify the contour finish

cutting sequence in G71.

7. G71 is a one-shot command.

December, 2018 2-47


G-code Description Lathe Machine Solution G Command Guidelines

G72: Multiple type rough facing cycle

Format: G72 Wd Re;


G72 P_ Q_ Uu Ww F_ S_ T_ ;

2 Wd: the cutting depth per move in Z-axis direction (set as radius), which default value
can be specified with machining parameter 312.
Re: retraction amount (set as radius), which default value can be specified with
machining parameter 313.
P_: start block number for contour finish turning.
Q_: end block number for contour finish turning.
Uu: finish allowance of X axis (set as diameter / radius).
Ww: finish allowance of Z axis (set as diameter / radius).
F_: feed rate.
T_: tool number.
S_: spindle speed.

Description: when G72 rough facing cycle is used, the system will first read the end dimension.
Then, it automatically calculates the facing path by referring to the parameter
settings and starts performing the rough facing cycle.

2-48 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Example]

Machining program:
G54 X40.0 Z5.0
M03 S1000
G01 X45. Z5. F0.2
G72 W2. R3.
G72 P50 Q60 U0.2 W0.0 F0.15
N50 G01 X40. Z-20. (1)
X30. (2)
Z-15. (3)
G03 X20. Z-5. R10. (4)
G01 X5. (5)
N60 Z0. (6)
M5
M30

December, 2018 2-49


G-code Description Lathe Machine Solution G Command Guidelines

[Workpiece position and cutting direction]

The figure above shows the workpiece position and the cutting direction with respect to the
positive / negative U and W values; 1 - 4 represent the four quadrants respectively.
A: start point of the cycle
B: start point of the cutting path
C: end point of the cutting path

Note:

1. Do not repeatedly assign the P_ and Q_ values that specify the finish cutting sequence in the

program.

2. The blocks without movement commands or N, F, S, M, or T command will be omitted.

3. When the command does not specify the cutting depth and retraction amount, the system will refer

to the parameter setting automatically.


4. The tool compensation is not operable when G72 rough facing cycle is used.

5. An alarm will occur if the system does not read the P_ and Q_ values that specify the contour finish

cutting sequence in G72.

6. G72 is a one-shot command.

2-50 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G73: Multiple type pattern repeating cycle

Format: G73 Ui Wk Rd;

G73 P_ Q_ Uu Ww F_ S_ T_;

Ui: total cutting amount in X-axis direction (set as radius), which default value can be
specified by machining parameter 345.
Wk: total cutting amount in Z-axis direction (set as radius), which default value can be
2
specified by machining parameter 346.
Rd: number of cutting, which default value can be specified by machining
parameter 347.
P_: start block number for contour finish turning.
Q_: end block number for contour finish turning.
Uu: finish allowance of X axis and the direction of allowance (set as diameter / radius).
Ww: finish allowance of Z axis and the direction of allowance (set as diameter / radius).
F_: feed rate.
S_: spindle speed.
T_: tool number.

Description: when G73 pattern repeating cycle is used, the system first reads the end
dimensions and refers to the parameter setting to automatically calculate the
turning path for the workpiece before starting the pattern repeating cycle.

[Contour machining example]

The cutting amount per time: [the total cutting amount of each axis] ÷ [value of cutting times (d-1)]
i k
X-axis direction: ( d  1) , Z-axis direction: ( d  1)

December, 2018 2-51


G-code Description Lathe Machine Solution G Command Guidelines

Note: G73 cycle command is suitable for the workpiece that has been machined (such as roughing,

forging, or casting). If the workpiece is a complete bar, using G73 may result in tool or workpiece damage

because of the excessive turning amount.

2
[Example]

In this program, a bar with diameter 42 mm is used for machining.


O0007
M3 S1600
T3
G0 X41. Z2.
G73 U10. W10. R5.
G73 P50 Q60 U0.4 W0.2 F0.25
N50 G0 X20.
G1 Z-20. F0.12
X30. Z-25.
W-5.
N60 X41.
G0 X50. Z10.
M5
M30

2-52 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G70: Multiple type finish turning cycle

Format: G70 P_ Q_;

2
P_: start block number for contour finish turning.
Q_: end block number for contour finish turning.

Description: you can use G70 for finish turning to meet the end dimension requirement after
rough turning cycles (G71, G72, and G73) are complete.

[Contour machining example]

M3 S1000

T3

G0 X41. Z2.

G71 U2. R3. (rough turning)

G71 P50 Q60 U0.2 W0.2 F0.25

N50 G0 X10. Z0.5

G1 Z-5. F0.12

G03X20. W-5. R5.

G01Z-15.,R2.

U10.Z-20.,C1.

Z-30.

X20.Z-35.

W-3.

N60 X40.2

G70 P50 Q60 (finish turning)

M5

M30

Note: once the G70 finish turning is complete, the tool returns to the start point in rapid traverse and the

blocks that follow G70 will be executed.

December, 2018 2-53


G-code Description Lathe Machine Solution G Command Guidelines

[Example]
After all rough turning cycles are complete, G70 finish turning cycles are executed.
G71 ...

2
G71 P10 Q20 ...
N10

...
N20
...
G71 ...
G71 P30 Q40 ...
N30 ...
...
...
N40 ...
...
G70 P10 Q20
G70 P30 Q40

2-54 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G74: Multiple type face pecking cycle

Format: G74 Re;

G74 X/U_ Z/W_ P△i Q△K R△d F_;

Re: Z axis retraction amount, which you can set its default with machining
parameter 348.
X/U__: X-coordinate of the cutting end point / incremental distance of X axis.
2
Z/W__: Z-coordinate of the cutting end point / incremental distance of Z axis.
P△i: the tool feeding amount of X axis per cycle; you can only specify the value in
radius. When it is an integer, the unit is 0.001 mm.
Q△k: the peck turning amount of Z-axis per time. When it is an integer, the unit is
0.001 mm.
R△d: the escape distance in X-axis direction at the bottom of cut.
F__: feed rate.

Description: G74 is mainly used in the face grooving machining. When G74 is used, the system
performs the cycle on the face based on the specified turning end coordinates,
cutting amount, tool offset, and escape distance at the bottom of cut.
After completing the turning for amount △k in Z-axis direction each time, the tool
retracts for amount e. This cycle carries on and stops when reaching the target on
Z axis (bottom). Then, the tool escapes for amount △d and returns to the start point
of Z axis in rapid traverse. Next, the tool moves for amount △i in X-axis direction
and repeats the motion mentioned above. Finally, it stops when reaching the target
on X-axis. See the following figure for motion assigned by G74:

Note: tool nose compensation is not applicable when G74 is used.

December, 2018 2-55


G-code Description Lathe Machine Solution G Command Guidelines

G75: Multiple type axial pecking cycle

Format: G75 Re;

G75 X/U_ Z/W_ P△i Q△K R△d F_;

2 Re: the retraction amount of X axis after each peck turning. You can only specify the
value in radius and set the default with machining parameter 348.
X/U__: X-coordinate of the cutting end point / incremental distance of X axis.
Z/W__: Z-coordinate of the cutting end point / incremental distance of Z axis.
P△i: the peck turning amount of X axis per time; you can only specify the value in
radius. When it is an integer, the unit is 0.001 mm.
Q△k: the tool-feeding amount of Z-axis per cycle. When it is an integer, the unit is
0.001 mm.
R△d: the escape distance in Z-axis direction at the bottom of cut.
F__: feed rate.

Description: G75 is mainly used for grooving in axial direction. When G75 is used, the system
performs auto axial pecking cycle based on the specified turning end coordinates,
cutting amount, tool offset, and escape distance at bottom of cut. After completing
the turning for amount △i, the tool retracts for amount e. This turning cycle carries
on and stops when reaching the target on X axis (bottom). Then, the tool escapes
for amount △d and returns to the start point of X axis in rapid traverse. Next, the
tool moves for amount △k in Z-axis direction and repeats the motion mentioned
above. Finally, it stops when reaching the target on Z-axis. See the following figure
for the motion assigned by G75:

2-56 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Note: tool nose compensation is not applicable when G75 is used.

December, 2018 2-57


G-code Description Lathe Machine Solution G Command Guidelines

[Example]

(1) Tool nose position

T0404

M3 S2000

G0X30.Z5. (Start point of G74 cycle)

G74 R1.

G74 X20. Z-5. P3000 Q5000 R0. F0.3

G0X20.Z5.

G74 R1.

G74 X12. Z-10. P3000 Q5000 R0. F0.3 (Start point of G74 cycle)

G0Z5.

X50.

T0505

G0 Z-18. (Start point of G75 cycle)

G75 R1.

G75 X30. Z-20. P5000 Q3000 R0. F0.3

G0Z-20.

G75 R1.

G75 X20.Z-30.P5000 Q3000R0. F0.3

G0 X50.

Z5.

M5

M30

2-58 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G76: Multiple type thread turning cycle

Format: G76 Pmra Q△dmin R_;


G76 X/U_ Z/W_ Ri Pk Q△d F_;

Pmra: m represents the times of finish turning (1 - 99) and you can define the default
value with machining parameter 381; r represents the chamfering amount (0 - 99).
Assume that L is the threading lead, the chamfering setting is 0.1*r*L, and you can
2
set the default value with machining parameter 380. a represents the tool nose
angle (threading angle), which you can specify the default by machining parameter
382 (with available options of 0°, 29°, 30°, 55°, 60°, and 80°).
For example, when you set P011160, it means the number of the finish turning
time is 1, chamfering amount is 1.1 L (L is the threading lead), and tool nose
angle is 60°.
Q△dmin: minimum cutting depth. When you input an integer, its unit is 0.001 mm and
you can set the default value with machining parameter 383.
R_: finish allowance specified with radius. You can set the default with machining
parameter 439.
X/U_: X-coordinate of the threading end point / incremental threading distance of X axis.
Z/W_: Z-coordinate of the threading end point / incremental threading distance of Z axis.
Ri: the difference when [Start screw thread radius] minus [End screw thread radius]
(set as radius value).
Pk: thread depth (set as radius value) When it is an integer, the unit is 0.001 mm.
Q△d: depth of the first cut (set as radius value) When it is an integer, the unit is
0.001 mm.
F__: thread lead; the linear distance of one thread rotation.

Description: when you set the cutting end coordinate in G76, the system performs the thread
turning cycle according to the specified turning times with the fixed amount.

December, 2018 2-59


G-code Description Lathe Machine Solution G Command Guidelines

[Thread turning]

(1) - (5) in the figure represent the tool movement sequence.

Note:

1. You must execute G76 Thread turning cycle when the spindle speed is fixed.

2. When G76 is executed, spindle speed keeps at 100%.

2-60 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G90: Axial turning cycle

Format: G90 X/U_ Z/W_ R_ F_;

2
X/U_: X-coordinate of the cutting end point / incremental distance of X axis (set as
diameter / radius).
Z/W_: Z-coordinate of the cutting end point / incremental distance of Z axis.
R_: taper amount (set as radius value with positive / negative sign). When axial linear
turning, R_ value is omitted.
F_: feed rate.

Description: when you use G90, the system performs a complete outer diameter (taper)
turning cycle.

[Contour machining example]

G90 motion analysis:


(1) Move from the start point to the assigned coordinates of X-axis according to the given taper
moving distance / direction in rapid traverse.
(2) Move to the assigned Z-axis and X-axis coordinates.
(3) Move to the start point on X axis.
(4) Return to the start point in rapid traverse.

December, 2018 2-61


G-code Description Lathe Machine Solution G Command Guidelines

The turning directions corresponding to symbol U, W, and R:

Outer diameter turning Inner diameter turning

1. U < 0, W < 0, R < 0 3. U > 0, W < 0, R < 0 at |R|≤|U/2|

2
2. U < 0, W < 0, R > 0 at |R|≤|U/2| 4. U > 0, W < 0, R > 0

Note: when you use the G90 axial turning cycle, its setting is continuously effective. To cancel or quit the

G90 command, you can use G92, G94, G80 (cycle cancel), or the Group 1 commands (G00, G01, G02,

and G03).

2-62 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G92: Threading cycle

Format: G92 X/U_ Z/W_ R_ F_ Q_;

2
X/U_: X-coordinate of the cutting end point / incremental distance of X axis (set as
diameter / radius).
Z/W_: Z-coordinate of the cutting end point / incremental distance of Z axis.
R_: taper amount (set as radius value with positive / negative sign). When axial linear
turning, R_ value is omitted.
F_: thread lead.
Q_: offset angle for threading start. If you input an integer, the unit is 0.001 degree.

Description: when you use G92, the system performs a complete outer diameter (taper)
threading cycle once.

[Contour machining example]

θ is the chamfering angle for thread turning, which can be specified by machining parameter 349.

r is the chamfering length, which can be specified by machining parameter 380.

December, 2018 2-63


G-code Description Lathe Machine Solution G Command Guidelines

G92 motion analysis:


(1) Move from the start point to the assigned X-axis coordinate according to the given taper
amount in rapid traverse.

2
(2) Perform thread turning to the specified Z-axis and X-axis coordinates.
(3) Execute chamfering command.
(4) Move to the start point on X axis in rapid traverse.
(5) Return to the start point in rapid traverse.

The turning directions corresponding to symbol U, W, and R:

Outer diameter turning Inner diameter turning

1. U < 0, W < 0, R < 0 3. U > 0, W < 0, R < 0 at |R|≤|U/2|

2. U < 0, W < 0, R > 0 at |R|≤|U/2| 4. U > 0, W < 0, R > 0

Note:

1. When you use the G92 threading cycle, its setting is continuously effective. To cancel or quit the

G92 command, you can use G90, G94, G80 (cycle cancel), or the Group 1 commands (G00, G01,

G02, G03).

2. You can set the default chamfer angle for thread turning by machining parameter 349 and set the
default chamfer length by machining parameter 380.

3. Please refer to the note for G32 thread cutting command when performing thread turning.

2-64 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

[Example]

O0010
T0202; Select tool No.2 and tool compensation No.2
M03 S2000; Spindle rotates forward at 2,000 rpm
G0 Z5.; (1) Z-axis threading start point
X30.; (2) X-axis retraction distance
G92 X17.65 Z-25.0 F1.5; (3) Threading depth: 17.65 mm; (4) length: 25 mm; (5) pitch: 1.5 mm
X17.45; Threading depth
X17.25;
X17.05;
X16.85;
X16.65;
X16.45;
X16.25;
X16.05;
X15.9;
M5; Spindle stop
G0X50.; The tool retracts to a safe distance
Z10.; The tool retracts to a safe distance
M30; Program end

December, 2018 2-65


G-code Description Lathe Machine Solution G Command Guidelines

G94: Face turning cycle

Format: G94 X/U_ Z/W_ R_ F_;

2
X/U_: X-coordinate of the cutting end point / incremental distance of X axis (set as
diameter / radius).
Z/W_: Z-coordinate of the cutting end point / incremental distance of Z axis.
R_: taper amount (set as radius value with positive / negative sign). When straight
cutting, R_ value will be omitted.
F_: feed rate.

Description: when you use G94, the system performs a complete face (taper) turning cycle.

[Contour machining example]

G94 motion analysis:

(1) Move from the start point to the assigned Z-axis coordinate according to the given taper
amount in rapid traverse.

(2) Move to the assigned Z-axis and X-axis coordinates.

(3) Move to the start point on Z axis.

(4) Return to the start point in rapid traverse.

2-66 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

The turning directions corresponding to symbol U, W, and R:


Outer diameter turning Inner diameter turning

1. U < 0, W < 0, R < 0 3. U > 0, W < 0, R < 0 at |R|≤|W|

2. U < 0, W < 0, R > 0 at |R|≤|W| 4. U > 0, W < 0, R > 0

(1) - (4) in the figures represent the sequence of the tool movement.

Note: when you use the G94 face turning cycle, its setting is continuously effective. To cancel or quit the

G94 command, you can use G90, G92, G80 (Cancel cycle), or the Group 1 commands (G00, G01, G02,

and G03).

December, 2018 2-67


G-code Description Lathe Machine Solution G Command Guidelines

G80: Cancel cycle


Format: G80;

Description: this command is for canceling the G90, G92, and G94 cycles. It can also cancel the

2 drilling cycles (G83 and G87), tapping cycles (G84 and G88), and boring cycles
(G85 and G89). In addition, you can use Group 1 commands, such as G00, G01,
G02, and G03 to cancel the cycles.

G83: Face drilling cycle

Format: G83 X(U)_ C_ Z(W)_ R_ Q_ P_ F_ K_L_M_;

X(U)_C_: hole position. (In non-turning / milling mode, if the X-coordinate of the face
drilling point is not the 0 point of the workpiece coordinates, an alarm showing
“B6A5: Turning drilling and tapping cmd error” will occur.)
Z(W)_: bottom of the hole.
R_: the reference point set as an incremental value, which the tool moves toward the
opposite direction of the workpiece.
Q_: depth of cut for each cutting feed.
P_: dwell time at the bottom of the hole in the unit of ms (input integers only).
F_: feed rate.
K_: number of repetitions for machining, which is 1 by default.
L_: machining cycle mode selection; this parameter functions the same as parameter
326 (cycle setting). When there is an L argument, the system will first refer to L;
otherwise, it refers to parameter 326.
M_: M-code call, which is usually used for clamping / unclamping control of the C axis.
Action flow of M-code call: when the tool moves to the start point, the system
executes the M-code (e.g., M80: C-axis clamping). Then, when the tool completes
drilling and retracts to point R and before pausing at the top of the hole, the system
executes M + 1 code (e.g., M81: C-axis unclamping).
Parameter 513: dwell time at the top of the hole. When the cycle command is
completed, the tool pauses at point R for the duration (unit: second) set in
parameter 513.

Description: each time the tool drills by the distance (depth) of Q, it retracts by the distance set
in parameter 324 in rapid traverse or retracts to point R according to the setting of
parameter 326. This cycle carries on and stops when the tool drills to depth Z.

Cycle parameter 326:


If bit 2 - 3 are 0, the tool does not perform peck drilling; it drills directly to the bottom.
If bit 2 - 3 are 1, the tool performs deep peck drilling, which feeding amount is Q and retracts to
point R.

2-68 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

If bit 2 - 3 are 2, the tool performs general peck drilling, which feeding amount is Q and the
escape amount is set in parameter 324.

2
G84: Face tapping cycle

Format: G84 X(U)_ C_ Z(W)_ R_ Q_ P_ F_ K_L_M_;

X(U)_ C_: tapping position. (In non-turning / milling mode, if the X-coordinate of the
face tapping point is not the 0 point of the workpiece coordinates, an alarm
showing “B6A5: Turning drilling and tapping cmd error” will occur.)
Z(W)_: bottom of the hole
R_: the reference point set as an incremental value, which is the distance from the start
point to the bottom of the hole in Z-axis direction.
P_: dwell time at bottom of the hole in the unit of ms (input integers only).
F_: Feed rate
K_: number of repeated machining time, which is 1 by default.
L_: machining cycle mode selection; this parameter functions the same as parameter
326 (cycle setting). When there is an L argument, the system will first refer to L;
otherwise, it refers to parameter 326.
M_: M-code call, which is usually used for clamping / unclamping control of the C axis.
Action flow of M-code call: when the tool moves to the start point, the system
executes the M-code (e.g., M80: C-axis clamping). Then, when the tool completes
tapping and retracts to point R and before pausing at the top of the hole, the
system executes M + 1 code (e.g., M81: C-axis unclamping).
Parameter 513: dwell time at the top of the hole. When the cycle command is
completed, the tool pauses at point R for the duration (unit: second) set in
parameter 513.

Description: the spindle first rotates one cycle to look for the Z pulse and execute positioning
once the Z pulse is found. Then, the Z axis moves to the reference point R in rapid
traverse. Next, the spindle rotates and taps to the specified bottom position, and
then retracts to R in reverse direction, and finally returns to the initial point in rapid
traverse.

Cycle parameter 326:


If bit 2 - 3 are 0, the tool does not perform peck tapping; it taps directly to the bottom.
If bit 2 - 3 are 1, the tool performs deep peck tapping, which feeding amount is Q and retracts to
point R.
If bit 2 - 3 are 2, the tool performs general peck tapping, which feeding amount is Q and the
escape amount is set in parameter 324.

December, 2018 2-69


G-code Description Lathe Machine Solution G Command Guidelines

G85: Face boring cycle

Format: G85 X(U)_ C_ Z(W)_ R_ P_ F_ K_M_;

2
X(U)_ C_: boring position. (In non-turning / milling mode, if the X-coordinate of the face
boring point is not the 0 point of the workpiece coordinates, an alarm
showing “B6A5: Turning drilling and tapping cmd error” will occur.)
Z(W)_: bottom of the hole.
R_: the reference point set as an incremental value, which is the distance from the start
point to the bottom of the hole in Z-axis direction.
P_: dwell time at the bottom of the hole in the unit of ms (input integers only).
F_: Feed rate.
K_: number of repetition for machining, which is 1 by default.
M_: M-code call, which is usually used for clamping / unclamping control of the C axis.
Action flow of M-code call: when the tool moves to the start point, the system
executes the M-code (e.g., M80: C-axis clamping). Then, when the tool completes
boring and retracts to point R and before pausing at the top of the hole, the system
executes M + 1 code (e.g., M81: C-axis unclamping).
Parameter 513: dwell time at the top of the hole. When the cycle command is
completed, the tool pauses at point R for the duration (unit: second) set in
parameter 513.

Description: G85 is usually used for machining with reamers or boring bars for the applications
that require higher precision in hole diameters. Before starting boring, the tool goes
to point R in rapid traverse. Then, the tool cuts to point Z with the set feed rate F
and retracts to R with the same speed. Finally, the tool returns to the start point
with G00 fast positioning command.

2-70 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G87: Side drilling cycle

Format: G87 Z(W)_ C_ X(U)_ R_ Q_ P_ F_ K_L_M_;

2
Z(W)_ C_: drilling position.
X(U)_: bottom of the hole.
R_: the reference point set as an incremental value, which the tool moves toward the
direction of the bottom of the hole.
Q_: depth of peck drilling for each cutting feed. When Q_ value is an integer, the unit is
0.001 mm.
P_: dwell time at the bottom of the hole in the unit of 0.001 ms (input integers only).
F_: feed rate.
K_: number of repetitions for machining, which is 1 by default.
L_: machining cycle mode selection; this parameter functions the same as parameter
326 (cycle setting). When there is an L argument, the system will first refer to L;
otherwise, it refers to parameter 326.
M_: M-code call, which is usually used for clamping / unclamping control of the C axis.
Action flow of M-code call: when the tool moves to the start point, the system
executes the M-code (e.g., M80: C-axis clamping). Then, when the tool completes
drilling and retracts to point R and before pausing at the top of the hole, the system
executes M + 1 code (e.g., M81: C-axis unclamping).
Parameter 513: dwell time at the top of the hole. When the cycle command is
completed, the tool pauses at point R for the duration (unit: second) set in
parameter 513.

Description: the tool performs peck drilling for distance (depth) Q_ and retracts by the distance set
in parameter 324 or retracts to point R based on the setting of parameter 326 in rapid
traverse. This cycle continues until the tool performs machining to the depth of Z.

Cycle parameter 326:


If bit 2 - 3 are 0, the tool does not perform peck drilling; it drills directly to the bottom.
If bit 2 - 3 are 1, the tool performs deep peck drilling, which feeding amount is Q and retracts to
point R.
If bit 2 - 3 are 2, the tool performs general peck drilling, which feeding amount is Q and the
escape amount is set in parameter 324.

December, 2018 2-71


G-code Description Lathe Machine Solution G Command Guidelines

[Example] G83 / G87

(1) Par326: bit2 - bit3 = 2 (2) Par326: bit2 - bit3 = 1 (3) Par326: bit2 - bit3 = 0

G87 X_ Z_ R_ Q_ P_ F_ G87 X_ Z_ R_ Q_ F_ G87 X_ Z_ F_

G88: Side tapping cycle

Format: G88 Z(W)_ C_ X(U)_ R_ Q_ P_ F_ K_L_M_;

Z(W)_ C_: tapping position.


X(U)_: bottom of the hole.
R_: the reference point set as an incremental value, which the tool moves toward the
bottom of the hole.
Q_: depth of tapping for each cutting feed. When Q_ value is an integer, the unit is
0.001 mm.
P_: dwell time at the bottom of the hole in the unit of 0.001 ms (input integers only).
F_: feed rate.
K_: number of repetitions for machining, which is 1 by default.
L_: machining cycle mode selection; this parameter functions the same as parameter
326 (cycle setting). When there is an L argument, the system will first refer to L;
otherwise, it refers to parameter 326.
M_: M-code call, which is usually used for clamping / unclamping control of the C axis.
Action flow of M-code call: when the tool moves to the start point, the system
executes the M-code (e.g., M80: C-axis clamping). Then, when the tool completes
tapping and retracts to point R and before pausing at the top of the hole, the
system executes M + 1 code (e.g., M81: C-axis unclamping).
Parameter 513: dwell time at the top of the hole. When the cycle command is
completed, the tool pauses at point R for the duration (unit: second) set in
parameter 513.

2-72 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Description: the spindle first rotates one cycle to look for the Z pulse and perform positioning
once the Z pulse is found. Next, the Z axis moves to the reference position R in
rapid traverse. Then, the spindle rotates and carries on tapping to the bottom of the

2
hole, reverses and retracts to point R, and finally moves to the start point in rapid
traverse.

Cycle parameter 326:


If bit 2 - 3 are 0, the tool does not perform peck tapping; it taps directly to the bottom.
If bit 2 - 3 are 1, the tool performs deep peck tapping, which feeding amount is Q and retracts to
point R.
If bit 2 - 3 are 2, the tool performs general peck tapping, which feeding amount is Q and the
escape amount is set in parameter 324.

[Example] G84 / G88

(1) Par326: bit 2 - bit 3 = 2 (2) Par326: bit 1 - bit 3 = 2 (3) Par326: bit 0 - bit 3 = 2
G88 X_ Z_ R_ Q_ P_ F_ G88 X_ Z_ R_ Q_ F_ G88 X_ Z_ F_

December, 2018 2-73


G-code Description Lathe Machine Solution G Command Guidelines

G89: Side boring cycle

Format: G85 Z(W)_ C_ X(U)_ R_ P_ F_ K_M_;

2
Z(W)_C_: boring position.
X(U)_: bottom of the hole.
R_: the reference point set as an incremental value, which is the distance from the start
point to the bottom of the hole in Z-axis direction.
P_: dwell time at the bottom of the hole in the unit of ms (input integers only).
F_: feed rate.
K_: number of repetitions for machining, which is 1 by default.
M_: M-code call, which is usually used for clamping / unclamping control of the C-axis.
Action flow of M-code call: when the tool moves to the start point, the system
executes the M-code (e.g., M80: C-axis clamping). Then, when the tool completes
boring and retracts to point R and before pausing at the top of the hole, the system
executes M + 1 code (e.g., M81: C-axis unclamping).

Description: G89 is usually used for reaming or boring applications that require higher precision
in hole radius of the workpiece to be machined. The tool first moves to point R in
rapid traverse and cuts to the depth specified with the Z value at feeding speed F.
Then, the tool retracts to point R at the same speed and finally returns to the start
point using command G00.

[Example] G85 / G89

X_ Z_ (fast positioning)

G89 X_ Z_ R_ P_ F_

2-74 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G90/G91: Absolute / incremental coordinates

Format: G90 X_ Y_ Z_

2
Description: this command is continuously effective. When you execute this command, it means
you assign all axial commands, coordinates, and angles with the absolute format.
In other words, the tool moves based on the workpiece coordinate origin. After you
send an axial movement command, the tool calculates the actual required moving
distance according to the workpiece coordinate origin.

Format: G91 X_ Y_ Z_

Description: when you set G91 the incremental command, values assigned for the axial
movements, coordinates, angles in the block are incremental. The tool makes
incremental movements or incremental rotations from the current position to the
specified position. G91 is a status command. If you use G91, G91 immediately
replaces G90.

Note:

1. The function of G90 for type A lathe system is “Axial turning cycle”.

2. G91 (incremental command) is not applicable for the type A lathe system; you need to use the format

U_, V_, W_ to input the incremental value.

[Example] command type B

Absolute command: G90 X30. Z30.

Incremental command: G91 X20. Z20.

G90 + incremental command: G90 U20. W20.

G91 + incremental command: G91 U20. W20.

December, 2018 2-75


G-code Description Lathe Machine Solution G Command Guidelines

[Example of using both G90 and G91]

G98; Feed-per-minute mode

G00 G90 G54 X0 Y0; Move to G54 (X0, Z0) in rapid traverse

G01 X10. F500; Move to point (1)

X20. Z-10; Move to point (2)

G91 Z-10.0; Move to point (3)

X10.0; Move to point (4)

G90 Z-40.0; Move to point (5)

G00 X50. Z5. ; Move to the safety position in rapid traverse

2-76 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G50: Coordinate system setting / maximum spindle speed

Format: G50 X_ Y_ Z_ (coordinate system setting)


G50 S_ (maximum spindle speed)

Description: G50 X0 Y0 Z0 command can set the current tool position as the absolute
coordinate system origin. The absolute commands in this program will refer to this
origin when calculating the position. In G50 X_ Y_ Z_, if you have specified the
2
value for X, Y, or Z, the absolute coordinates and the current position display will
update according to the G50 command. G50 S_ sets the maximum spindle speed
for retaining the precision and performance of the machine.
Note:

1. G50 coordinate system setting command continues to function unless M02/M30 is executed (program

end command).

2. Pressing the RESET key can cancel the state set in the G50 coordinate system setting.

[Example]

Machine origin

M3 S1500; Spindle rotates forward at 1,500 rpm

G0 G54 X0. Z0.; Move to the G54 coordinate system origin (1) in rapid traverse

G0 X10.; Move to point (2) in rapid traverse

G50 S1000; The maximum speed limit is 1,000 rpm; the speed reduces to

1,000 rpm

G50 X0. Z0.; The workpiece origin (2) specified in G50

G1 W-20. F0.25; Move to point (3)

U10.; Move to point (4)

G0 X30.; Move to the safety point (5) in rapid traverse

M5 ; Spindle stop

M30 ; Program end; the absolute coordinate system specified in G92

transits to G54 coordinate system

December, 2018 2-77


G-code Description Lathe Machine Solution G Command Guidelines

G98: Feed per minute (mm/min)

Format: G98 G01 X_ Y_ Z_ F_


Description: the unit for G98 Feed per minute is mm/min. This means the tool performs turning

2 each minute at speed F_. You can execute G98 command with motion blocks at the
same time as well as using G98 independently in one block. This command is
continuous effective.

G99: Feed per revolution (mm/rev)

Format: G99 G01 X_ Y_ Z_ F_


Description: the unit for G99 Feed per revolution is mm/rev. This means the tool performs
turning at speed F_ per spindle revolution. You can execute G99 command with
motion blocks at the same time as well as using G99 independently in one block.
This command is continuous effective and its format is set based on the tool
feeding calculation for the lathe system.

[Example]
M3 S1000 (Spindle rotates forward at 1,000 rpm)

G99 G01 Z-20. F0.35 (Feed 0.35 mm per rotation)

(1) Spindle rotation direction

Actual turning feed speed: 1000 rev/min * 0.35 mm/rev = 350 mm/min

2-78 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

G96: Constant speed surface control

Format: G96 S_ (m/min)

2
Description: the S_value set in G96 is the cutting speed in the unit of m/min. If you execute G96
S200, the current tool cutting speed is 200 m/min. When the surface cutting speed is
fixed, the spindle speed varies based on the command diameter coordinate (X-axis
command); the spindle speed is faster when the machining diameter is smaller while
the spindle speed is slower when the machining diameter is larger.
You can use this command to keep the consistency in workpiece surfacing.

G97: Cancel constant speed surface control

Format: G97 S_ (rev/min)

Description: the S_value set in G97 is the cutting speed in the unit of rev/min. If you execute
G97 S2000, the spindle speed keeps at 2,000 rev/min.
You can use this command for the applications that require a fixed spindle speed
when threading, drilling, and tapping.

December, 2018 2-79


G-code Description Lathe Machine Solution G Command Guidelines

Chamfer / corner rounding function

Format for chamfering: G01/G02/G03 X/U_ Z/W_ ,C_


G01/G02/G03 X/U_ Z/W_

2 Chamfer a length of C_ at the intersection between two motion blocks.

[Chamfer example 1]

G1X0.0Z0.0F0.1 (1)

X20.,C3. (2) Hypothetical intersection

W-10. (3)

X30. (4)

[Chamfer example 2]

G1X0.0Z0.0F0.1 (1)

X18.W-2.,C3. (2) Hypothetical intersection

X20.W-8. (3)

X30. (4)

2-80 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Format for corner rounding: G01/G02/G03 X/U_ Z/W_ ,R_


G01/G02/G03 X/U_ Z/W_
Perform corner rounding with the set radius R_ at the intersection between two motion blocks.

[Corner rounding example]


2
G1X0.0Z0.0F0.1 (1)

X20.,R3. (2) Hypothetical intersection point

W-10. (3)

X30. (4)

Note: chamfering and corner rounding commands must be followed by a motion block so the chamfering

and corner rounding data can be calculated.

December, 2018 2-81


G-code Description Lathe Machine Solution G Command Guidelines

Linear angle command

Format: G01 X _ (Z_) ,A_


X_ (Z_) ,A_

2 Set 1 to 2 end coordinates and the degree data in two consecutive blocks, and the controller
can calculate the corresponding coordinate data of the path, as shown in the table below.

Item Command Motion

X X1 Z Z1
1.
X X2 Z Z2,A A

X X1 Z Z1
2 ,A A1

X X3 Z Z3,A A2

X X1 Z Z1

X X2 Z Z2,R R

X X3 Z Z3

3. or use

X X1 Z Z1

,A A1,R R

X X3 Z Z3,A A2

X X1 Z Z1

X X2 Z Z2,C C

X X3 Z Z3

4. or use

X X1 Z Z1

,A A1,C C

X X3 Z Z3,A A2

2-82 December, 2018


Lathe Machine Solution G Command Guidelines G-code Description

Item Command Motion

X X1 Z Z1

X X2 Z Z2,R R1

2
X X3 Z Z3,R R2;

X X4 Z Z4

5. or use

X X1 Z Z1

,A A1,R R1

X X3 Z Z3,A A2,R R2

X X4 Z Z4

X X1 Z Z1

X X2 Z Z2,C C1

X X3 Z Z3,C C2;

X X4 Z Z4

6. or use

X X1 Z Z1

,A A1,C C1

X X3 Z Z3,A A2,C C2

X X4 Z Z4

X X1 Z Z1

X X2 Z Z2,RR

X X3 Z Z3,CC;

X X4 Z Z4

7. or use

X X1 Z Z1

,A A1,RR

X X3 Z Z3,A A2,CC

X X4 Z Z4

X X1 Z Z1

X X2 Z Z2,CC

X X3 Z Z3,RR

X X4 Z Z4

8. or use

X X1 Z Z1

,A A1,CC

X X3 Z Z3,A A2,RR

X X4 Z Z4

December, 2018 2-83


G-code Description Lathe Machine Solution G Command Guidelines

(This page is intentionally left blank.)

2-84 December, 2018


M-code Description 3
The auxiliary function M-codes are used for switching on and off the machine
functions. This chapter describes the functions of commonly used M-codes.
Please note that the actual functions of the M-codes vary with individual machines.

3.1 M-code Description ···········································································3-2


M00: Program stop (non-optional)·························································3-3
M01: Program stop (optional) ······························································3-3
M02: End of program ·········································································3-3
M30: End of program with return to program start position ·························3-3
M98: Subprogram call ········································································3-4
M99: Return from subprogram ·····························································3-4
3.2 Spindle and C-axis switching ·······························································3-5
3.2.1 Description for Spindle and C-axis switching ··································3-5
3.2.2 Notes for Spindle and C-axis mode switching ·································3-7

December, 2018 3-1


M-code Description Lathe Machine Solution G Command Guidelines

3.1 M-code Description


The M-code format is a capital M followed by numeric digits, which range is 0 - 65534.

3
The controller has some system-defined M-codes that do not require MLC coding to run and are
usually used for program control. The table below is the commonly used M-codes. Except the
system-defined codes, you need to use the MLC to specify the M-code functions.

M-code Function Note

M00 Program stop (non-optional) System-defined

M01 Program stop (optional) System-defined

M02 End of program System-defined

M03 Spindle On - clockwise MLC

M04 Spindle On - counterclockwise MLC

M05 Spindle stop MLC

M06 Tool change MLC

M08 Coolant On MLC

M09 Coolant Off MLC

M19 Spindle positioning MLC

M20 Cancel spindle positioning MLC

M29 System spindle positioning (rigid tapping and boring) MLC

M30 Program end with return to program start position System-defined

M98 Subprogram call System-defined

M99 Return from subprogram System-defined

3-2 December, 2018


Lathe Machine Solution G Command Guidelines M-code Description

M00: Program stop (non-optional)

Format: M00

3
Description: when there is an M00 command in the block, the program stops after executing this
block. To resume the program execution, re-press Cycle Start. You can use this
command to inspect the tools or workpiece appearance and dimensions when
cutting.

M01: Program stop (optional)

Format: M01
Description: when M01 is executed and functioning, its function is the same as M00 except that
M01 has to work with the Optional stop key on the secondary panel. If the
Optional stop key is disabled and there is an M01 command in the block,
the controller automatically omits M01 and continues to run the program.

M02: End of program

Format: M02
Description: M02 is usually placed at the end of a machining program to notify the controller that
the program has ended. If you place an M02 in the middle of the program, when the
controller executes M02, the program stops at M02 and regards the program as
ended; meanwhile, the cursor stops at the block of M02 command.

M30: End of program with return to program start position

Format: M30
Description: M30 is usually placed at the end of a machining program to notify the controller that
the program has ended. If you place an M30 in the middle of the program, when the
controller executes M30, the program stops at M30 and regards the program as
ended; meanwhile, the cursor returns to the program start position. M30 and M02
commands are similar. The only difference is that M02 stops the cursor at the block
that includes M02 whereas M30 returns the cursor to the beginning of the program.

December, 2018 3-3


M-code Description Lathe Machine Solution G Command Guidelines

M98: Subprogram call

Format: M98 Pˍ Lˍ

3
Description: if there are fixed or highly repetitive actions, you can write these actions into a
subprogram to simplify the whole program. The main program can call a
subprogram; and a subprogram can call another subprogram with up to eight
consecutive layers. When the controller reads an M98 command, it jumps to the
designated subprogram and executes the subprogram commands based on the set
number of call.
Pˍ: subprogram code; Lˍ: number of call for the subprogram
[Example]
Main program Subprogram
N0010 O1010
N0020 M98 P1010 N1020
N0030 N1030
N0040 N1040
N0050 N1050
N0060 N1060
N0070 N1070
N0080 N1080
N0090 N1090
N0100 N1100 M99

M99: Return from subprogram

Format: M99
Description: after M98 is used to run the subprogram, to return to the main program, you need
to use M99 to have the cursor return to the block following the block that has called
the subprogram and then carry on the execution in the main program.

[Example]

Main program Subprogram


N0010 O1010
N0020 M98 P1010 N1020
N0030 N1030
N0040 N1040
N0050 N1050
N0060 N1060
N0070 N1070
N0080 N1080
N0090 N1090
N0100 N1100 M99

3-4 December, 2018


Lathe Machine Solution G Command Guidelines M-code Description

3.2 Spindle and C-axis switching


3.2.1 Description for Spindle and C-axis switching

Description: the function of switching between the Spindle and C-axis modes are used in the
lathe / milling machining applications. Some functions are operable only in C-axis
mode, such as face and side drilling / tapping, polar coordinate interpolation, and
3
cylindrical coordinate interpolation.
Parameter settings:
1. C-axis mode setting: go to Parameter (CONFIG) > parameter 308 Channel auxiliary settings
> set 0 (select C-axis mode) for lathe system.
2. To switch from Spindle to C-axis mode, you need to set the corresponding M-code setting for
parameter 358.
3. To switch from C-axis to Spindle mode, you need to set the corresponding M-code setting for
parameter 359.
4. The channel setting for the feed axis and spindle is shown in the figure below.

M-codes for switching between C-axis and Spindle modes:


1. MLC NC (The MLC writes the values to the register and the NC reads the values in the
register.)
M-code Function Status
C-axis mode On
M1126
Spindle mode Off

December, 2018 3-5


M-code Description Lathe Machine Solution G Command Guidelines

Function description:
 When the G-code program runs the M-code for switching from the Spindle mode to C-axis
mode (M-code setting in parameter 358), the MLC sets M1126 to on to notify the NC to

3 
switch from Spindle mode to C-axis mode.
When the G-code program runs the M-code for switching from the C-axis mode to Spindle
mode (M-code setting in parameter 359), the MLC sets M1126 to off to notify the NC to
switch from C-axis mode to Spindle mode.
 Spindle mode is the default when booting (M1126 = off).

2. NC MLC (The NC writes the values to the register and the MLC reads the values in the
register.)
M-code Function Status
The NC system completes mode switching and is now in C-axis mode. On
M2239
The NC system completes mode switching and is now in Spindle mode. Off
Function description:
 When the NC is in Spindle mode and it executes the M-code (switch from Spindle to C-axis
mode) and receives the On signal of M1126, the NC starts switching the mode from Spindle to
C-axis. Once the switching is complete, M2239 is turned on and the NC is in C-axis mode.
 When the NC is in C-axis mode and it executes the M-code (switch from C-axis to Spindle
mode) and receives the Off signal of M1126, the NC starts switching the mode from C-axis to
Spindle. Once the switching is complete, M2239 is turned off and the NC is in Spindle mode.
 Spindle mode is the default when booting (M2239 = off).

[Example]
The parameter setting is as follows.
Parameter No. Description Value
The M-code for switching from the Spindle to C-axis mode in the
358 66
lathe system.
The M-code for switching from the C-axis to Spindle mode in the
359 77
lathe system.

G-code example:

M03 S1000
G00 X50. Z10.
G98 F1000
G01 Z-20.
M66 (Switch from Spindle mode to C-axis mode)
C0.
C90.
C180.
M77 (Switch from C-axis mode to Spindle mode)
M30

3-6 December, 2018


Lathe Machine Solution G Command Guidelines M-code Description

3.2.2 Notes for Spindle and C-axis mode switching

1. You can use M1126 to switch between C-axis and Spindle modes in all operation modes

3
except the Auto mode which you must use the M-codes to switch.
2. When switching from the Spindle to C-axis mode, if the first spindle has not passed
through the Z pulse, the system automatically sends M29 the positioning command.
If the first spindle is running, then the system sends M05 the spindle stop command.
3. In all operation modes, the C axis has to be static when the system switches to the
Spindle mode. If the C axis is operating and M1126 is on, the mode switching starts only
after the C axis stops.
4. In all operation modes, when the system switches from C-axis to Spindle mode and the
second spindle (dynamic tool turret) is operating, the system sends M05 the spindle stop
command to the second spindle and then starts the mode switching.

December, 2018 3-7


M-code Description Lathe Machine Solution G Command Guidelines

(This page is intentionally left blank.)

3-8 December, 2018


Macro and Variable
This chapter provides descriptions about the system variables and operation
4
commands and examples of the macro syntax.

4.1 Variables ·························································································4-2


4.1.1 Arguments and local variables ·······················································4-3
4.1.2 Systems variables ·······································································4-3
4.1.3 Macro interface input / output ·························································4-6
4.2 Variable syntax ·················································································4-8
4.3 Operation commands ·········································································4-9
4.4 Control flow ···················································································· 4-10
4.5 Use M-code, S-code, and T-code to call macro ······································ 4-12

December, 2018 4-1


Macro and Variable Lathe Machine Solution G Command Guidelines

4.1 Variables
When performing variable operation in the NC program, you can use variables to replace the

4
NC program code to batch modify the values, which makes the program editing and variable
calculation easier. A variable is formatted as a symbol "#" suffixed with a variable number.
Types of variables are as follows.
Variable type No. Function Read Write
For data storage or operation in the subprogram
Local #1 - #50 or macro program. The arguments can ★ ★
correspond to the local variables.
For data storage or operation in the subprogram
Global #51 - #250 ★ ★
or macro program.
For reading and writing the system internal data
Maintain
#1601 - #1800 during NC operation. These are non-volatile ★ ★
(non-volatile)
variables.
For reading and writing the system internal data
Extension #10001 - #10450 during NC operation. These are non-volatile ★ ★
variables.
MLC bit output #1801 - #1832 For reading the MLC signal status (MLC > NC). ★
#1801 - #1832 for bit format and #1833 - #1848
MLC word output #1833 - #1848 for word format. ★

MLC bit input #1864 - #1895 For writing the MLC signal status (NC > MLC). ★
#1864 - #1895 for bit format and #1896 - #1911
MLC word input #1896 - #1911 for word format. ★

4-2 December, 2018


Lathe Machine Solution G Command Guidelines Macro and Variable

4.1.1 Arguments and local variables

Except for the G, L, N, O and P-codes, all the other variable codes can be used as arguments.

4
When these arguments are used for G65 and G66 subprogram call, they are sent as local
variables.

#1 #2 #3 #4 #5 #6 #7 #8 #9 #10

A B C D E F G H I J

#11 #12 #13 #14 #15 #16 #17 #18 #19 #20

K L M D E F Q R S T

#21 #22 #23 #24 #25 #26

U V W X Y Z

4.1.2 Systems variables

The system variables are used for reading and writing of the system internal data during NC
operations. The MLC output and input are used for the data exchange between the NC program
and the MLC. The M-codes correspond to the bit format and D-codes correspond to the word
format.

 G-code group data

No. Function Read Write


#2000 - #2019 G-code group ★
#2020 F-code, the NC machining speed F ★
#2023 T-code, the NC tool number T ★
#2024 S-code, the NC spindle speed S ★

December, 2018 4-3


Macro and Variable Lathe Machine Solution G Command Guidelines

 The modal logic data for program execution (read-only)

No. Function

4
#2000 G04, G09, G10, G11

#2001 Interpolation mode: G00, G01, G02, and G03

#2002 Plane selection: G17, G18, and G19

#2003 Absolute / increment designation: G90 and G91

#2005 Feed rate setting: G94 and G95

#2006 Inch / metric setting: G21 and G20

#2007 Tool nose radius compensation: G40, G41, and G42


Cycle: G70, G71, G72, G73, G74, G75, G76, G77, G78, G79, G80, G83, G84, G85, G86,
#2009
G87, G88, and G89
#2010 Homing position: G98 and G99

#2012 Workpiece coordinates: G54, G55, G56, G57, G58, and G59

#2013 Cutting mode: G61 and G64

#2014 Macro call: G66 and G67

#2017 Surface cutting speed setting: G96 and G97

 Position related data


You can use variables #2100 - #2217 to read the following coordinates (read-only).
Machine coordinates Absolute coordinates
Machine
Position Relative coordinates when G31 skip of breakpoint search
coordinates
data command is triggered line
Offset between
Absolute coordinates machine coordinates
Absolute
Block end coordinates when G31 skip of breakpoint search
coordinates
command is triggered line and current
Axis
machine coordinates
#2100 #2180 #2148 #2196
X axis
#2116 #2132 #2164 #2212

#2101 #2181 #2149 #2197


Y axis
#2117 #2133 #2165 #2213

#2102 #2182 #2150 #2198


Z axis
#2118 #2134 #2166 #2214

#2103 #2183 #2151 #2199


A axis
#2119 #2135 #2167 #2215

#2104 #2184 #2152 #2200


B axis
#2120 #2136 #2168 #2216

#2105 #2185 #2153 #2201


C axis
#2121 #2137 #2169 #2217

4-4 December, 2018


Lathe Machine Solution G Command Guidelines Macro and Variable

 Workpiece coordinate data


You can use variables #3000 - #3646 to read the offset coordinates and workpiece

4
coordinates (read-only).
Workpiece coordinates Workpiece coordinates Workpiece coordinates
Position Offset G54 G55 G56
data coordinates Workpiece coordinates Workpiece coordinates Workpiece coordinates
Axis G57 G58 G59
#3001 #3002 #3003
X axis #3000
#3004 #3005 #3006

#3129 #3130 #3131


Y axis #3128
#3132 #3133 #3134

#3257 #3258 #3259


Z axis #3256
#3260 #3261 #3262

#3385 #3386 #3387


A axis #3384
#3388 #3389 #3390

#3513 #3514 #3515


B axis #3512
#3516 #3517 #3518

#3641 #3642 #3643


C axis #3640
#3644 #3645 #3646

 Others
No. Function Read Write
The variable corresponding to single block I when an arc
#2300 ★
command is executed.
The variable corresponding to single block J when an arc
#2301 ★
command is executed.
The variable corresponding to single block K when an arc
#2302 ★
command is executed.
#2303 Timer starts after system power on ★
#2304 Tool number of Spindle 1 (dual tool magazine) ★
#2305 Tool number of Spindle 2 (dual tool magazine) ★
Breakpoint search function: recently used M-codes (14 sets),
#5000 - #5013 ★
#5000 - #5013 from the latest to the oldest
Breakpoint search function: recently used T-codes (2 sets),
#5014 - #5015 ★
#5014 - #5015 from the latest to the oldest
#5016 Breakpoint search function: the last used S-code ★
System macro alarm with the value range of 1 - 1000.
#6000 ★
The messages are edited with the Screen Editor.
#6001 - #6064 X-axis tool length ★ ★
#6201 - #6264 Y-axis tool length ★ ★
#6401 - #6464 Z-axis tool length ★ ★
#6601 - #6664 X-axis tool wear ★ ★
#6801 - #6864 Y-axis tool wear ★ ★
#7001 - #7064 Z-axis tool wear ★ ★
#7201 - #7264 Tool nose radius ★ ★

December, 2018 4-5


Macro and Variable Lathe Machine Solution G Command Guidelines

No. Function Read Write


#7401 - #7464 Tool nose wear ★ ★
#7601 - #7664 Tool nose type ★ ★

4
#8600 Program timer in the unit of ms ★ ★

4.1.3 Macro interface input / output

You can use variables #1801 - #1911 to get the interface data as well as reading and writing the
MLC signal status. Variable values can be in bit or word format. For the bit-type signals, the
variables can only be 1 or 0; for the word-type signals, the variables can be any value.

 MLC bit output; read the MLC signal status (MLC > NC)

Read MLC signal status Macro output point Read MLC signal status Macro output point

#1801 M1024 #1817 M1040

#1802 M1025 #1818 M1041

#1803 M1026 #1819 M1042

#1804 M1027 #1820 M1043

#1805 M1028 #1821 M1044

#1806 M1029 #1822 M1045

#1807 M1030 #1823 M1046

#1808 M1031 #1824 M1047

#1809 M1032 #1825 M1048

#1810 M1033 #1826 M1049

#1811 M1034 #1827 M1050

#1812 M1035 #1828 M1051

#1813 M1036 #1829 M1052

#1814 M1037 #1830 M1053

#1815 M1038 #1831 M1054

#1816 M1039 #1832 M1055

4-6 December, 2018


Lathe Machine Solution G Command Guidelines Macro and Variable

 MLC word output; read the MLC signal status (MLC > NC)

Read MLC signal status Macro output register Read MLC signal status Macro output register

4
#1833 D1024 #1841 D1032

#1834 D1025 #1842 D1033

#1835 D1026 #1843 D1034

#1836 D1027 #1844 D1035

#1837 D1028 #1845 D1036

#1838 D1029 #1846 D1037

#1839 D1030 #1847 D1038

#1840 D1031 #1848 D1039

 MLC bit input; write the MLC signal status (NC > MLC)

Write MLC signal status Macro input point Write MLC signal status Macro input point

#1864 M2080 #1880 M2096

#1865 M2081 #1881 M2097

#1866 M2082 #1882 M2098

#1867 M2083 #1883 M2099

#1868 M2084 #1884 M2100

#1869 M2085 #1885 M2101

#1870 M2086 #1886 M2102

#1871 M2087 #1887 M2103

#1872 M2088 #1888 M2104

#1873 M2089 #1889 M2105

#1874 M2090 #1890 M2106

#1875 M2091 #1891 M2107

#1876 M2092 #1892 M2108

#1877 M2093 #1893 M2109

#1878 M2094 #1894 M2110

#1879 M2095 #1895 M2111

December, 2018 4-7


Macro and Variable Lathe Machine Solution G Command Guidelines

 MLC word input; write the MLC signal status (NC > MLC)

Write MLC signal status Macro input register Write MLC signal status Macro input register

4
#1896 D1336 #1904 D1344

#1897 D1337 #1905 D1345

#1898 D1338 #1906 D1346

#1899 D1339 #1907 D1347

#1900 D1340 #1908 D1348

#1901 D1341 #1909 D1349

#1902 D1342 #1910 D1350

#1903 D1343 #1911 D1351

4.2 Variable syntax

The numeric values in the NC program can be replaced by variables. This empowers the program

for better flexibility and universality as you can use the variables for mathematical operations.

(1) The allowable range for the local variables:


# i: the ith variable (when 1 ≦ i ≦ 50)

(2) Define the variable number with formula:


When calculating #[A], the range of A must be 1 ≦ A ≦ System’s maximum variable
number. The value of A must be a positive value and no smaller than 0.

#[<Calculation formula>] Description

#[#20] (Correct)

#[#20Δ3] (Correct) when Δ = + - * /

##20 (Incorrect) There are two consecutive # symbols.

#[#20] = … (Correct)

#20 =… (Correct)

#[#20 - #10] = … (Correct) Placing mathematical operators before an equal sign is not allowed.

#[- #20] = … (Correct)

(3) Place a symbol before a variable

- #<variable number> Preceding condition

Z-#20 equals Z-10.1 #20 = 10.1

G#20 equals G1 #20 = 1 (When G#20 is used, it can only be written with the program.)

4-8 December, 2018


Lathe Machine Solution G Command Guidelines Macro and Variable

(4) Using variable for definition


#20 = 10 (#20 equals 10)
#20 = #5 (#20 equals #5)
#20 = #5 + #2

(5) Conditional expression


IF[#20==1]
(#20 equals #5 + #2)

(If #20 equals 1, the condition is satisfied)


4
4.3 Operation commands
When the system executes all kinds of calculations among variables, the operation commands
can turn the calculation result into a variable, or combine and replace the result into other
variables. You can use constants to replace #i, #j, and #k.

Command Symbol Usage Definition


+ #i = #j + #k Addition
- #i = #j - #k Subtraction
Elementary * #i = #j * #k Multiplication
arithmetic / #i = #j / #k Division
= #i = #j Substitution
[ ] #i = #j * [ #p + #q ] Parentheses
SIN #i = SIN [#k] Sine
ASIN #i = ASIN [#k] Arcsine
COS #i = COS [#k] Cosine
ACOS #i = ACOS [#k] Arccosine
TAN #i = TAN [#k] Tangent
ATAN #i = ATAN [#k] Arctangent
Arctangent angle = adjacent side #m / diagonal
ATAN2 #i = ATAN2 [#m, #n]
Function side #n
ABS #i = ABS [#k] Absolute value
FIX #i = FIX [#k] Round down
FUP #i = FUP [#k] Round up
ROUND #i = ROUND[#k] Round off
SQRT #i = SQRT [#k] Square root
POW #i = POW [#m, #n] #m to the power of #n
BIT #i = BIT [#m, #n] Value of the #nth bit of a binary #m
& #i = #j & #k AND logic
Logic | #i = #j | #k OR logic
operator Λ #I = #j^#k XOR logic
! #i = ! #j NOT logic
PI PI = π Pi
Constant TRUE TRUE = 1 Return 1 when the statement is true.
FALSE FALSE = 0 Return 0 when the statement is false.

December, 2018 4-9


Macro and Variable Lathe Machine Solution G Command Guidelines

4.4 Control flow


When WHILE [statement] is true, the program will execute the block that follows WHILE and

4
repetitively execute the set of statements until the first ENDW is encountered. Otherwise, the
program jumps to the block of code following ENDW for execution.

WHILE [statement]

ENDW

Example:
WHILE[#80<=360.] (Enter the loop for repetitive execution when #80 is less than or equal to 360.)

WHILE[#60>=20.] (Enter the inner loop when #60 is greater than or equal to 20.)
#60=#60-2.
ENDW (Execute the first ENDW and the inner loop ends.)
#80=#80+15.
#50=#50-0.05

ENDW (Execute the second ENDW and the outer loop ends.)

 Branch conditions

When IF [statement] is true, the program switches the execution (GOTO) to statement N.
Otherwise, the program executes the next block of code following the IF statement, as shown in
the example below.

IF [Statement] GOTO N (Execute the IF statement, conditionally jump to statement N for

execution.)

GOTO N (When GOTO N is used independently, unconditionally jump to

statement N.)

The N in “GOTO N” must be used in the same program or an alarm will occur.


N10 #12=#10
#13=#11+2;
IF[#2=1]GOTO200;
#12=#10-#3; When #2 = 1,
#13=#11-#4; branch to N200.
N200 X#12 Z#13;
#5=#5+2;

Note: when searching the sequence number in the branch, the system searches from the start of the

program. An alarm will occur if the target number is not found. If the same sequence number

repeats in the program, the system will execute the block of code that is first found.

4-10 December, 2018


Lathe Machine Solution G Command Guidelines Macro and Variable

 Types of conditional statements:

Condition Description Example

4
TRUE; return value: #i = 1
#j > #k #j is greater than #k #i = #j > #k
FALSE; return value: #i = 0
TRUE; return value: #i = 1
#j < #k #j is less then #k #i = #j < #k
FALSE; return value: #i = 0
TRUE; return value: #i = 1
#j == #k #j is equal to #k #i = #j == #k
FALSE; return value: #i = 0
TRUE; return value: #i = 1
#j >= #k #j is greater than or equal to #k #i = #j >= #k
FALSE; return value: #i = 0
TRUE; return value: #i = 1
#j <= #k #j is less than or equal to #k #i = #j <= #k
FALSE; return value: #i = 0
TRUE; return value: #i = 1
#j != #k #j is not equal to #k #i = #j != #k
FALSE; return value: #i = 0

Example:
#100 = 1.234; (Define: #100 is 1.234)

#100 = #101; (Define: #100 equals #101)

#100 = [[#101+#102]/2.0]; (Define: #100 is #101 plus #102 and then divided by 2)

#100 = #102+2.; (Define: #100 is #102+2)

#100 = SIN[#102]; (Define: #100 is the value of SIN of #102)

X-#100 (The X-coordinate is the negative value of #100)

G1X#100Y#101; (The X-coordinate is #100; the Y-coordinate is #101)

G1X[#100]; (The X-coordinate is #100)

G1X[#100+#101]; (The X-coordinate is #100 + #101)

G2X[#100*SIN[#102]]; (The X-coordinate is #100 multiplied by SIN[#102])

G1Z#100F#102S#103; (The Z-coordinate is #100; F is #102; S is #103)

December, 2018 4-11


Macro and Variable Lathe Machine Solution G Command Guidelines

4.5 Use M-code, S-code, and T-code to call macro


(1) To use the G-code to call a macro, go to [Parameter (CONFIG)] to set the number to be

4
called. The corresponding setting is as follows.

Macro function G-code number Note


O9010 0 - 1000
O9011 0 - 1000
O9012 0 - 1000
O9013 0 - 1000
O9014 0 - 1000 Set the G-code number to 0 if not using the macro call
O9015 0 - 1000 function.

O9016 0 - 1000
O9017 0 - 1000
O9018 0 - 1000
O9019 0 - 1000

Constraint: if you use a macro to call G-codes, M-codes, or T-codes, the nested macro will not

be executed (the G-codes in this macro are treated as general G-codes).

(2) To use the M-code to call a macro, go to [Parameter (CONFIG)] to set the number to be
called. The corresponding setting is as follows.

Macro function M-code number Note

O9020 0 - 1000
O9021 0 - 1000
O9022 0 - 1000
O9023 0 - 1000
O9024 0 - 1000 Set the M-code number to 0 if not using the macro call
O9025 0 - 1000 function.

O9026 0 - 1000
O9027 0 - 1000
O9028 0 - 1000
O9029 0 - 1000

Constraint: if you use a macro to call G-codes, M-codes, or T-codes, the nested macro will not

be executed (the M-codes in this macro are treated as general M-codes).

4-12 December, 2018


Lathe Machine Solution G Command Guidelines Macro and Variable

(3) To use the T-code to call a macro, go to [Parameter (CONFIG)] to enable the function.
The setting is as follows.

4
Macro function T-code number Note
Set the T-code number to 0 if not using the macro call
0: disabled
O9000 function.
else: enabled
T-code number is defined as local variable #20.

Constraint: if you use a macro to call G-codes, M-codes, or T-codes, the nested macro will not

be executed (the T-codes in this macro are treated as general T-codes).

The variable definition is as follows.


No. Description Read Write
#1 - #50 Local variables ★ ★
#51 - #250 Global variables ★ ★
#1601 - #1800 Maintain variables (non-volatile) ★ ★
#10001 - #10450 Extension variables (non-volatile) ★ ★
MLC logic output points.
#1801 - #1832 ★
MLC > NC macro input points: M1024 - M1055 (32 points in total)
MLC data output points.
#1833 - #1848 ★
MLC > NC macro input points: D1024 - D1039 (16 points in total)
MLC logic input points.
#1864 - #1895 ★
NC > MLC macro output points: M2080 - M2111 (32 points in total)
MLC data input points.
#1896 - #1911 ★
NC > MLC macro output points: D1336 - D1351 (16 points in total)
#2000 - #2019 G-code group ★
#2020 F-code ★
#2023 T-code ★
#2024 S-code ★
#2100 - #2105 Machine coordinates of X - C axes ★
#2116 - #2121 Absolute coordinates of X - C axes ★
#2132 - #2137 End coordinates of X - C axes in single block ★
Machine coordinates of X - C axes when G31 skip command is
#2148 - #2153 ★
triggered
Absolute coordinates of X - C axes when G31 skip command is
#2164 - #2169 ★
triggered
#2180 - #2185 Relative coordinates of X - C axes ★
#2196 - #2201 Absolute coordinates of breakpoint search line (X – C axes) ★
Offset between machine coordinates of breakpoint search line and
#2212 - #2217 ★
current machine coordinates (X – C axes)
#2300 Single block I (for arc command) ★
#2301 Single block J (for arc command) ★
#2302 Single block K (for arc command) ★
#2303 Timer starts after system power on ★
#2304 Tool number of Spindle 1 (dual tool magazine) ★
#2305 Tool number of Spindle 2 (dual tool magazine) ★
#2500 Write the tool number for tool magazine 1 ★
#2501 Write the tool number for tool magazine 2 ★
#3000 X-axis offset coordinate ★

December, 2018 4-13


Macro and Variable Lathe Machine Solution G Command Guidelines

No. Description Read Write


#3001 - #3006 X-axis workpiece coordinate G54 - G59 ★
#3128 Y-axis offset coordinate ★

4
#3129 - #3134 Y-axis workpiece coordinate G54 - G59 ★
#3256 Z-axis offset coordinate ★
#3257 - #3262 Z-axis workpiece coordinate G54 - G59 ★
#3384 A-axis offset coordinate ★
#3385 - #3390 A-axis workpiece coordinate G54 - G59 ★
#3512 B-axis offset coordinate ★
#3513 - #3518 B-axis workpiece coordinate G54 - G59 ★
#3640 C-axis offset coordinate ★
#3641 - #3646 C-axis workpiece coordinate G54 - G59 ★
Breakpoint search function: recently used M-codes (14 sets),
#5000 - #5013 ★
#5000 - #5013 from the latest to the oldest
Breakpoint search function: recently used T-codes (2 sets),
#5014 and #5015 ★
#5014 - #5015 from the latest to the oldest
#5016 Breakpoint search function: the last used S-code ★
#6000 System macro alarm ★
#6001 - #6064 X-axis tool length ★ ★
#6201 - #6264 Y-axis tool length ★ ★
#6401 - #6464 Z-axis tool length ★ ★
#6601 - #6664 X-axis tool wear ★ ★
#6801 - #6864 Y-axis tool wear ★ ★
#7001 - #7064 Z-axis tool wear ★ ★
#7201 - #7264 Tool nose radius ★ ★
#7401 - #7464 Tool nose wear ★ ★
#7601 - #7664 Tool nose type ★ ★
#8600 Program timer in the unit of ms ★ ★

4-14 December, 2018


Revision History
Release date Version Chapter Revision contents
December, 2018 V1.0
(First edition)

For relevant information about [Lathe Machine Solution G Command Guidelines], please
refer to:
(1) Delta CNC Lathe Machine Solution - Operation and Maintenance Manual
(2) Delta CNC Solution – NC Series MLC Application Manual

December, 2018 1
Revision History Lathe Machine Solution G Command Guidelines

(This page is intentionally left blank.)

2 December, 2018

You might also like