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

CENTURY STAR HNC-21T

TURNING CNC system

PROGRAMMING MANUAL

Wuhan Huazhong Numerical Control Co., Ltd


HNC-21T Programming Manual

I
HNC-21T Programming Manual

CHAPTER 1 INTRODUCTION

In this chapter you will see explanation on how HNC-21T


turning machine system works.
1.1 Introduction of CNC programming

1.1.1 How to define a part program


CNC programming languages is a descriptive language that is
specially designed for CNC system, in which ISO (International
Standard Organization) code has widely being used.
The CNC program will be changed into motion of machinery.
And the mostly used programs saving media are paper belt and
magnetic disc.

1.1.2 Preparation of part program


As shown in Fig.1.1.1.,we can use either an traditional method to
program a part or a CAD/CAM software (as widely used
MasterCAM ) to program a part.

Fig.1.1.1 Preparation of a part program


2
HNC-21T Programming Manual

1.2 Introduction of CNC machine

1.2.1 Coordinate system of machine


To simplify programming and keep compatibility, a set of
uniformed standard is worked out to name the axis and direction of
machine coordinate. The linear feed is defined as X Y Z, called basic
coordinate axis. The co-relations among X, Y, Z are decided by right
hand rule, as shown in Fig. 1.2.1. In the figure, thumb points X
direction, fore finger points Y direction, while long finger Z direction.
+Y +B +Z
+X +Y +Z
+Y +X
+X
+C +A
+Z +A +B
+Y
+C
+X
+Z

Fig.1.2.1 M achine axis

The circular feeding axes run around X, Y and Z are defined as A,


B, C. According to right hand rule thumb points +X, +Y, +Z while fore
finger and long finger point circular feed +A +B +C.
The motion of CNC machine comes from spinning spindle with
tool or rotary table with part. The above-mentioned positive direction
of axis is on the assumption that the tool feeds relative to part while it
stops. If the part moves, we use to express relative movement
relation. This means the part moves reverse to tool movement, which
is

+X =-X , +Y =-Y , +Z =-Z


+A =-A , +B =-B , +C =-C
And the negative directions of the two are also reversed.
The direction of machine axes decides the type of the machine and the
distribution of component. To the turning machine,

3
HNC-21T Programming Manual

Z axis is the spindle axis. Move alone the Z direction will


enlarge the distance between the part and the cutter
X axis is vertical to Z axis and the movement to the carriage.
Move alone the Z direction will enlarge the distance between
the part and the cutter
Y (imaginary) axis follows the right hand rule.

Fig.1.2.2 Coordinates and directions of a turning machine

1.2.2 Machine coordinate system, machine coordinate zero and


reference point
Machine coordinate system is preset coordinate system, machine
coordinate zero is preset zero and is also called machine zero. The zero
is preset after the machine is designed, assembled and tested.
The machine zero is not known while the CNC system is
power-on. To establish a coordinate system properly, a machine
reference point (beginning point for measurement) is preset between
the axis movement ranges. While starting the machine, manual or
mechanical return to reference point is needed to establish a coordinate
system.

4
HNC-21T Programming Manual

The machine reference point can coincide with the machine zero or not,
the distance between machine reference point and machine zero is
defined through parameter selection.
After the machine returns to reference point the machine zero, all the
coordinate reference points are known, and the CNC machine
coordinate system is established.
The maximum and minimum limitation switches decide the
mechanical stroke of every coordinate axis.
The valid strokes of machine coordinate axes, defined by machine
builders, are determined through software limitation. Machine zero
(OM), machine reference point (OM) and the mechanical stroke of
machine coordinate system are shown in Fig.1.2.3.

Available
Z mechanical strokes
area
Z valid strokes

X mechanical strokes
Z plus X Valid strokes

Staring
switch

Fig.1.2.3 Machine zero OM and reference point Om

1.2.3 Part coordinate system, program zero and tool positioning


When programming, the program editor select a certain point as
zero in the part to establish a coordinate system, the point is called
program zero. The part coordinate system is valid until a new system
is set.
Simple programming, less calculation and less part error are the

5
HNC-21T Programming Manual

governing principles of selection of part coordinate system.


Generally, the program zero should be the preset zero in
coordinate system noted part; zero should be the central line or the
center of the circle in symmetric part or circular part.
Tool positioning assures the place of zero in the machine
coordinate system. So the tool positioning point is the initial point of
the machining program, it can coincide with program point or
anywhere that is easy to positioning. Coordinate relation must be kept
between program zero and tool positioning point. Therefore, CNC
could change any program zero related coordinate value into machine
zero related coordinate value.
Before machining, G92 is used to create part coordinate;
G54~G59 are used to select part coordinate

6
HNC-21T Programming Manual

CHAPTER 2 THE STRUCTURE OF PART

The part program refers to a set of commands and data


transmitted to CNC system. A part program is composed of several
program sections, which follows certain structure and language rules,
while program section includes some command letters. Fig.2.1
illustrates this.
program
Program

%1000
%1000
N01 G91 G00 X50 Y60
N01 G91 G00 X50 Y60
Program
N10 G01 X100 Y500 F150 S300 M03
N10 G01 X100 Y500 F150 S300 M03section
N......
Program block
N......M02
N200
N200 M02 command
Command character

Fig.2.1 Structure of program

2.1 Formation of command character

A command character includes address code (command code)


and data group with codes (size letter) or without codes (G code).
Different command characters and followed data determine the
characters of command.
The main command codes used in CNC are shown in Table 2.1

Table 2.1 Command codes list


Function Address Character
Part program % Program number
number %1~4294967295
Program section N Program section number
N0~4294967295

7
HNC-21T Programming Manual

Preparation G Order (line, circle, est.) G00-99


function
X Y Z Axis movement order 99999.999
A B C
Size number U V W
R Parameter of circle radius and
fixed cycle
I J K Coordinate value of circle center
and parameter of fixed cycle
Feeding speed F Feeding speed command
F0~24000
Spindle function S Spindle speed command
S0~9999
Tool function T Tool number command
T0~99
Auxiliary M Machine switch on/off selection
function M0~99
Compensation H D Tool compensation number
number selection 00~99
Dwell P X Dwell time selection
Program number P Subprogram number selection
selection P1~4294967295
Times L Times of subprogram and fixed
cycle.
Parametesr P Q R Parameters of fixed cycle
Chamfer C,R
2.2 Formation of program block

A program block describes a CNC command line.


The Format of program block shows the sentence rules of
functional character in every program section. See Fig.2.2.1.

8
HNC-21T Programming Manual

Program block

N.. G.. X.. F.. M.. S..

Spindle function letter


Auxiliary functionfunction
Process function letter
Size letter
Auxiliary functionfunction
Program block number

Fig.2.2.1 Formation of program blocik

2.3 Structure of program

A part program begins with a beginning mark and finishes with


an end mark.
The part program is executed according part program input
command but not according to program number. It is suggestive that
the program be written in rising number of program section.
The structure of “Century Star” HNC-21T CNC program,
Beginning mark %/O %/O after program number
Program end M02 or M30
Note mark In “( )” or after “;”.

9
HNC-21T Programming Manual

CHAPTER 3 PROGRAM COMMAND SYSTEM OF HNC-21T

3.1 Auxiliary function M code

Auxiliary function, combining address M and one or two digits, is


mainly used to control the part program and on/off of machine’s
auxiliary function.
M function includes mode call function and none mode call
function.
None mode call Only available in the local program section
Mode call A group of M codes that can be cancelled by another
newly defined code in the same group.
M code function group initiates a default function (see Fig.3.1)
while the system is power on
And M code function also can be divided into before M code
function and after M code function.
Front M code function Executed before programmed axis
movement
Back M code function Executed after programmed axis
movement

“Century Star” HNC-21T CNC program M code function is


shown in Tab.3.1 is default ,

Tab.3.1 M code function


Code Mode Function Code Mode Function
M00 None Program stop M03 Mode Spindle run
mode forward on
M02 Non Program end M04 Mode Spindle run
e mode backward on
M30 None Program end M05 Mode Spindle stop
mode and return to M06 None mode Tool change
start
M98 None Subprogram M07 Mode Coolant on
mode call
10
HNC-21T Programming Manual

M99 None Subprogram M09 Mode Coolant off


mode end
M00, M02, M30, M98, M99 control part program and are preset
CNC auxiliary that have no relation with PLC designed by
machine builder
Other M codes, controlling machine auxiliary functions, are not
defined with CNC system but with PLC. Therefore, different
machine builders could choose different PLC (the Table 3.1 shows
the standard PLC program) printed in the machine specifications.

3.1.1 CNC inherent auxiliary function

(1) Program dwell M00


M00 can stop program, so the operator could measure tool and
part, adjust part and change speed manually.
On dwell the spindle of the machine and coolant stop but the
current mode information is preserved. Rest program could be
executed by pushing “Cycle start” buttons
M00 is after none mode M function.

(2) Program end M02


M02 is in the end of the last program block.
When M02 is executed, spindle of the machine, feed and coolant
stop, and the machining program are in the end.
After M02 is executed, it needs recalling of it to re-use the
program or push F4 in auto menu (see HNC-21T Operation Manual)
and then push Cycle start on operation panel.
M02 is back none mode M function.

(3) Program finish and return to beginning of part program M30


Similar to M02, M30 can also make program back to beginning
of the part program (%).

After M30 is executed, it needs pushing Cycle start on


operation panel to reuse the program.

11
HNC-21T Programming Manual

(4) Subprogram call M98 and return from subprogram M99


M98 is subprogram call.
M99 is subprogram end and return to main program.

(i) Formation of subprogram


%****

M99
At beginning of the subprogram a number must be set to show the
entrance address of the subprogram. At the end of the subprogram
M99 is used to return to main program after execution of subprogram.
(ii) Formation of subprogram call
M98 P_ L_
P Number of subprogram called
L Times of called
Note Subprogram can be called with parameter. See Appendix
1.
G65 and M98 have the same function and parameter.

3.1.2 Auxiliary function of PLC


(1) Spindle control M03 M04 M05
M03 starts spindle to run CW at the speed of program set. M04
starts spindle to run CCW at the speed of program set. M05 stops
spindle.
M03, M04 are M function before mode M05 is M function after
mode and default function.
M03 M04 M05 can be cancelled each other.

(2) Tool change M06


M06 is used to select cutter during machining.
It makes carriage run and select T code defined cutter.
M06 is after mode call M function.

12
HNC-21T Programming Manual

(3) Coolant on/off M07/M09


M07 can open the coolant pipe.
M09 can close the coolant pipe.
M07 is M function before mode M09 is after none mode and is
default function.
3.2 Spindle function S, feed function F and tool function T

3.2.1 Spindle function S


Spindle function controls the speed of spindle; the value after it is
the speed of spindle (r/min).
S is mode command; it is only available when the spindle is
adjustable.
Spindle speed programmed by S code can be adjusted by fold
switch in control panel.

3.2.2 Feed speed F


F means the compound speed of tool when the part is machined;
the unit of F is decided by G94 (per minute mm/min) or G95 (per
revolution mm/r).
Below is the calculation between feed per revolution and feed per
minute,
fm=fr S
fm feed per revolution (mm/min )
fr feed per minute (mm/r )
S spindle speed (r/min)
When G01 G02 or G03 are valid F command works until a new
F command is defined. When G00 is valid the speed of rapid
positioning, independent to F, is the maximum speed of every axis.
By pushing “Fold ” button, Fold override can be used for F.
When tapping cycles G76 G82 and thread cutting G32 are
executed, fold switch is unavailable and the feeding fold is fixed at
100 .
[Note]: A spindle encoder is needed when feed per revolution is
available.

13
HNC-21T Programming Manual

3.2.3 Tool function T


T is used to choose tool, the four-digit number after the T code is
the tool number. The tool number is specifies by the machine builder.
See the machine specifications
T command can run the carriage and select a cutter.
If there are both T command and tool command in the same
progrqm block, the T command should be executed first.
T command calls the compensation value in the tool
compensation memory at the same time.
See Item 3.3.5.
3.3 Auxiliary function G code

G code of auxiliary function is made up of one or two digits after


letter G. It can perform some operation like tool and part’s track,
machine coordinate and plane selection, tool compensation and
coordinate offset.
G code function refers to as mode code and none mode code. .
none mode code it is only available in certain program section
and it is cancelled at the end of program section
mode code a group of cancelable G code. The G code is
available after it is defined till a new G code is defined.
M code function group initiates a default function while the CNC
system is power on.
The G codes with different address parameter can be used
without order in the same program block. For example, G90, G17 and
G01 could be used in the same program block.
G code list of HNC-21T CNC system is shown in Table 3.2,
Table 3.2 G-code list
G Group Function Parameter
code address letter
G00 Rapid position X Z

G01 01 Linear interpolation See above

14
HNC-21T Programming Manual

G02 Circular interpolation CW X Z I K R

G03 Circular interpolation CCW See above

G04 00 Dwell P
G20 Inch input
G21 08 Mm input
G28 00 Return to reference point X Z
G29 Return from reference point See above
G32 01 Thread cutting X Z R, E, P, F
G40 Tool radius compensation
cancel
G41 09 Tool compensation, left D
G42 Tool compensation, right D
G52 00 Local coordinate system X Z
selection
G54
G55
G56 11 Zero offset
G57
G58
G59
G65 Macro simple call P A Z
G71 Inner/outer diameter cutting
compound cycle
G72 06 Surface cutting compound X, Z, U, W, C, P, Q,
cycle R, E
G73 Closed-loop cutting
compound cycle
G76 Thread cutting compound
cycle
G80 Inner/outer diameter cutting X Z I K C, P, R,
fixed cycle E
G81 01 Surface cutting fixed cycle

15
HNC-21T Programming Manual

G82 lThread cutting fixed cycle


G90 13 Absolute programming
G91 Incremental programming
G92 00 Part coordinates selection X Z
G94 14 Feed per minute
G95 Feed per revolution
G36 16 Diameter programming
G37 Radius programming
Note
1 The G codes in 00group are none mode while in other
groups are mode code.
2 is default.

16
HNC-21T Programming Manual

3.3.1 Unit selection


(1) Size unit selection G20 G21
Format G20
G21
Description
G20 Inch input
G21 Metric input
The two size units of linear axis and circular axis are shown in
Tab.3.3,
Table 3.3 Inputting size types and units
Linear axis Circular axis
Inch system (G20) Inch Degree
Metric system (G21) Mm Degree
G20 and G21 are mutually cancelable mode function. G21 is
default.
(2) Selection of feeding unit G94 G95
Formation G94 [ F_ ]
G95 [ F_ ]
Description
G94 Feeding per minute
G95 Feeding per revolution
G94 is feeding per minute. To linear axis, the F unit of G20,G21,
can be mm/min or in/min , to circular axis, the unit of F is degree/min.
G95 is feeding rate per revolution, it means the tool feeding value
of spindle per revolution. F unit of G20, G21, can be mm/min or in/r.
It works with a spindle encoder.

G94 G95 are mutually cancelable mode command; G94 is


default.

17
HNC-21T Programming Manual

3.3.2 Command of coordinate and coordinate system

(1) Absolute programming G90 and relative programming


G91
Format G90
G91
Description
G90 Absolute programming
Every program value in programming axis is relative to
program zero.
G91 Relative programming
Every program value in programming axis is relative to the former
palace, it is the distance moved in the imaginary axis.
G90 G91 are mutually cancelable mode function. G90 is default.
Example 1: Fig.3.3.1
Programming with G90 G91 The tool must move from 0 to
point 1,2 and 3.
Y
G90 programming G91 programming
45
2
N X Y N X Y
25 N01 X20 Y15 N01 X20 Y15
3
15 N02 X40 Y45 N02 X20 Y30
1
X N03 X60 Y25 N03 X20 Y-20
O 20 40 60

Fig.3.3.1 G90, G91 Programming

Suitable method could simplify programming procedure.


Absolute programming is simpler when the size of part is expressed
with a fixed base while relative programming is simpler when the size
of part is expressed with the distance between tips of contour.
G90 and G91 can be use in the same program block, attention
must be paid ton their order.

18
HNC-21T Programming Manual

(2) Selection of part coordinate G92


Format G92 X_Z_
Description
X Z Directional distance between coordinate zero and
beginning of the tool
After G92 command establishes part coordinate system by setting
relative position of beginning of tool (tool positioning point) and
coordinate system zero, relative programming command is the
coordinate value in the coordinate system.
Example 2: G92 programming in establishment of part coordinate
is shown in Fig. 3.3.2.

X Tool beginning G92 X20.0 Z30.0


20.0

Z
Program zero 30.0

Fig. 3.3.2 Part coordinate establishment

The program block can only establish part coordinate system, the
tool does not move.
G92 is none mode command and always in the first line of part
program.

(3) Zero offset G54~G59


G54
G55
 
G56
Format  
G57
G58
 
G59

19
HNC-21T Programming Manual

Description
G54~G59 are 6 preset coordinates in system (shown in Fig.
3.3.3), which can be selected at requirement.
The zero value (part zero offset) of the 6 preset part coordinates
in the coordinate system can be MDI function and system auto
memory.
After the coordinate system is selected, the value commands of
absolute programming in follow-up program section are relative to
coordinate zero.
G54~G59 are mutually cancelable mode function. G54 is default.

Z
Z

G54 part program


G54 zero Y
G59part program
G59 zero Y

X Machine zero
Part zero offset
X

Fig.3.3.3 Part coordinate selection(G54~G59)

Example 3: Part coordinate programming is shown in 3.3.4. The


tool is required to move from preset palace to A, then from A to B.

X
30 B Current point A B
X
%1000
40 A
G59 O 30 Z N01 G54 G00 G90 X40 Z30
N02 G59
G54 O 30 Z N03 G00 X30 Z30
Machine zero

Fig.3.3.4 Part coordinate programming

20
HNC-21T Programming Manual

Note
Before this command is used, zero value of every coordinate
system in machine coordinate system should be input manually (MDI).

(4) Local coordinate selection G52


Format G52 X_Z_
Description
X Z Zero of local coordinate in part coordinate system.
Sub-coordinate (local coordinate system) can be established with
G52 in all part coordinate systems (G92, G54~G59) as shown in
Fig.3.3.5
In program blocks involving G52, the value in absolute
programming is the coordinate value in local coordinate system.
After the local coordinate system is selected, part coordinate
system and machine coordinate system are unchangeably preserved.
coordinate IP
Local coordinate
IP
Local t coordinate
Part coordinate
IP
Local coordinate
Part zero offset Part coordinate

Part coordinate

Machine coordinate zero Machine

Fig.3.3.5 Selection of local coordinate G52

G52 is none mode command.

(5) Radius and diameter programming


The parts for turning machine are always cylindrical, so the value
for X axis have two manner radius and diameter.
For example, diameter programming G91 X-100.00 refers to tool
move 50mm alone X axis G90 X100 refers to tool move to
100mm alone X axis.
Format
G36
G37
21
HNC-21T Programming Manual

Description
G36 diameter programming
G37 radius programming
Note See Appendix 2.

3.3.3 Feed control command

(1) Rapid positioning G00


Format G00 X_Z_
Description
X Z In G90 the end of rapid positioning is in the part
coordinate. In G91 the end point is the movement distance
relative to the beginning point.
G00 makes tool move from present position to the position preset
by program sections at the preset speed to every axis.
In G00 the rapid speed is preset by machine parameter rapid
speed to every axis but not by F .
G00 is generally used in rapid positioning before machining or
rapid tool discharge after machining.
Rapid speed can be modified by rapid override switch in the
control panel.
G00 is none mode code and can be cancelled with G01, G02,
G03 or G32.

Note
Because every axis moves at its differently preset speed in
executing G00, the axes do not get to the destination simultaneously.
So the track of the tool may not be a straight
Line. The operator should be cautious to avoid collision of part
and tool. It is commonly be used to move axis Z to a safety height and
then do G00.
Example 4 In programming with G00, the tool is needed to
move from A to B rapidly shown in Fig. 3.3.6.

22
HNC-21T Programming Manual

X Actual path From A to B rapidly


C B Absolute programming
45
A G90 G00 X45 Z90
15 Programmi Incremental programming
Z
O G91 G00 X30 Z70
20 50 90

Fig. 3.3.6 G00 programmingg

When X has the same rapid speed with Y, the rapid positioning
route from A to B is a broken line A C B.

(2) Linear feed and chamfering G01


Linear feed
Format G01 X _Z_F_
Description
X Z In G90 the linear feed destination is the value in the
part coordinate; in G90 it is the distance moving
from beginning to destination.
F_ Compound feeding speed.
G01 commands the tool move from present position to
the position preset by program section in linear manner (the
simultaneous control axis track) at the compound speed
preset by F.
G01 is mode code cancelled with G00 G02 G03 or G32.

Example 5: In G01 programming, tool is required to move from


A to B in a straight line.
X
Linear feed from A to B
Actual path B
45 Absolute programming
A G90 G01 X45 Z90 F800
15 Programming pathZ Incremental programming:
O G91 G01 X30 Z70 F800
20 90

Fig. 3.3.7 G01 programming

23
HNC-21T Programming Manual

Chamfer
Chamfer function controls inserting linear chamfer and circular
chamfer between two programming blocks, it can only be used in auto
mode.
In appointed linear interpolation (G01) or circular interpolation
(G02 G03) program block end
input C__ insert chamfer program block
input R__ insert circular chamfer program block.
The number behind C is the distance from chamfer beginning and
end to the imaginary cross point, the number behind R is the radius of
circular chamfer.
The imaginary cross point is the cross point of adjacent program
blocks before end chamfer.
X 530.0 O0020
270.0

C3 G92 X26 Z530


G91 G01 Z-250 R6
R6 X60 Z-10 C3
Z-270
∅86 C M02
B
∅26 Z
O 250

Fig.3.3.8 Chamfer control


Example 6: Inserting linear chamfer and circular chamfer
between two programming blocks with G01, as shown in
Fig.3.3.8.
Note
(1) The second straight line begins with B but not C. In
incremental programming, the distance moving from B
should be appointed
(2) Chamfer control can not be used in thread cutting program
block

24
HNC-21T Programming Manual

(3) When preset moving value of axes X and Z is smaller than the
appointed R or C the system will give a alarm.

(3) Circular feedG02/G03

G02  I_ K_ 
Format  X_ Z_  F_
G03  R_ 
Description
G02 Circular interpolation CW (shown in Fig. 3.3.9)
G03 Circular interpolation CCW (shown in Fig. 3.3.9)
X, Z In G90, the arc destination is the value in the part
coordinate system; in G91, it is the distance moved
from beginning to arc destination;
I, J, K The offset value (difference of coordinate value of
circle center and the beginning of the arc, shown in
Fig. 3.3.10) of circle center relative to beginning
point of arc is defined incrementally in G90/G91;
R When the arc angle is less than 180 the radius of
the arc is positive, otherwise it is negative;
F Compound speed of two axes programmed.

X X destination (X, Z)
G03
O Z
G02

Beginning
I
O G18 Z center K

Fig.3.3.9 G02 and G03 selection Fig.3.3.10 I J K selection

Example 6 G02 programming with arc a and arc b in Fig.


3.3.11.

25
HNC-21T Programming Manual

X
b Four arc programming methods

(i) Circle a
R30
G91 G02 X30 Z30 R30 F300
destination G91 G02 X30 Z30 I0 K30 F300
a a G90 G02 X30 Z0 R30 F300
G90 G02 X30 Z0 I0 K30 F300
R30 (ii) Circle b
G91 G02 X30 Z30 R−30 F300
Z G91 G02 X30 Z30 I30 K0 F300
beginning O G90 G02 X30 Z0 R−30 F300
G90 G02 X30 Z0 I30 K0 F300
Fig.3.3.11(a) Circular programming

Example 7: The whole-circle programming in G02/G03 is shown


in Fig. 3.3.11(b).

i A circle CW from A
R30 G90 G02 X0 Z30 I0 K-30 F300
Z
G91 G02 X0 Z0 I0 K-30 F300
O A (ii) A circle CCW from B
G90 G03 X−30 Z0 I30 K0 F300
G91 G03 X0 Z0 I30 K0 F300
B

Fig.3.3.11(b) Whole circle programming

Note
CW and CCW directions are the circular directions
vertical to the coordinate axis of plane where the are in.
Whole-circle programming can use I, J, and K, but can
not use R.
R is valid only when I, J, and K are used in programming
at the same time.

(4) Thread cutting G32


Format G32 X__Z__R__E__P__F__

26
HNC-21T Programming Manual

Description
X, Z The end of the thread is the coordinate value in part
coordinate in G90; it is the movement relative to the
thread beginning in G91.
F The thread guidance (spindle feed per revolution) is the
tool feed relative to part.
R, E the withdraw length of the thread. R for Z and R for X.
The recess for off run will not be used when using R and
E. The withdraw function will not be used when omitting
R and E.
P Spindle angle from spindle basic pulse to thread cutting
start
G32 can work on cylindrical thread, taper thread and end face
thread. Fig.3.3.12 shows the parameters of thread cutting.
X

X
Z
δ1
0 Z

Fig.3.3.12 Thread cutting parameter


It is suggested that 1 and 2 are given at the beginning of the
thread cutting.

Note
(1) The feed override cannot be used during thread cutting
(2) It is very dangerous to stop thread cutting when the spindle is
still running, so the feed keep cannot be used in thread

27
HNC-21T Programming Manual

cutting. .After pressing feed keep, the tool will stop after
thread cutting
(3) Both rough cutting and finish cutting work along the same
track repeatedly, during which the speed of the spindle must
be constant, or the thread guidance will change.
Example 8 : Fig.3.3.13 shows the cylindrical thread
programming.
Given that
F=0.4inch 1=0.3inch; 2=0.15inch cutting depth=0.1inch
cutting for twice and it is inch diameter programming.

O1000
X
M03
G20 G00 G91 X-6.2
6.2 G32 Z-7.45 F0.4
δ2 δ1 G00 X6.2
Z7.45
O X-6.4
Z G32 Z-7.45 F0.4
7
G00 X6.2
Z7.45
M02
Fig.3.3.13 G32 programming

3. 3.4 Return to reference point

(1) Return to reference point G28


Format G28 X_Z_
Description
X Z The middle point through which is passed when
return to reference point, (none reference
point) is the value of middle point in part
coordinate; in G90; is the distance moved
from start to the middle pointing in G91.
G28 makes all the axes programmed move to their middle
point rapidly, and then return to reference point.
G28 is commonly be used to change or cancel mechanical error.

28
HNC-21T Programming Manual

Before it is executed, tool radius compensation and tool length


compensation should be cancelled.
In G28 programming section, the axis movement command can
be created and the coordinate value of middle point is memorized for
using G29
After power is on and that return to reference point manually is
not available, return from middle point has the same function with
return to reference point manually when defining G28. Under this
condition the direction from middle point return to reference is the
direction selected for “direction return to reference point.

(2) Auto return from reference point G29


Format G29 X _Z_
Description
X Z In using G90 return to positioning end is the
coordinate value of positioning end in the part
coordinate; in G91 the positioning end is the
distance moving from positioning end to the
middle point of G28.

G29 can program all the axes move rapidly to the preset
destination by passing through middle point defined by G28. And it is
generally used after G28.
G29 can be used only in the program section that is specified.

29
HNC-21T Programming Manual

X R
A B C
B
70 Middle point

A
50
G91 G28 X20 Z100
G29 X-40 Z50
30 C

Z
O 30 130 180

Fig3.3.14 G28/G29 programming

This example tells the operator that the actual length from middle
point to reference point shall not be calculated.

3.3.5 Tool compensation


Tool compensation includes tool offset, grinding and tool radius
compensation.
Note Tool offset and grinding compensation is defined by T code
but not by G code. It is specified for the reader’s convenience.

Tool offset and grinding compensation


As shown in Fig.3.3.15 in programming coordinates are
established according to a standard tool position A. When the tool
moves to the machining place tool position B is offset, the established
coordinates cannot be used. And the tool will be grinded during usage.
So the offset and grinded tool value should be compensated.

Standard tool

X grinded compensation Machining


tool
B
X offset compansation
A X
Z offset compansation Z

Fig.3.3.15 Tool compansation and grinding compensation

30
HNC-21T Programming Manual

Note the perfect tool head programming of HNC system.


Tool compensation function is defined by T code, the rest
four-digit number is tool number and tool compensation number. See
below,
TXX + XX
Tool number Tool compensation number
The compensation number is the address of tool compensation
memory in which there are tool offset compensation value of axis X
and Z, tool grinding compensation value of axis X and Z and tool
radius compensation value and tool position.
T pluses compensation number starts compensation function, 0
compensation number and 00compensation value means cancellation
of the compensation.
One tool can correspond several compensation number/value.
As shown in Fig.3.3.17, if tool track has X and Z direction
compensation value, the destination position in program block pluses
or reduces compensation value defined by T code is the destination
position of tool track.
Compensation track

Compensation vector

Programming track
Programming track with T code

Fig.3.3.17 Tool track after offset and grinding compensation

Example 11: Fig.3.3.18 shows the establishment and


cancellation of offset and grinding compensation.

31
HNC-21T Programming Manual

X
100
G90 G01
Tool compensation
track X50 Z100 T0202
Z200
50 X100 Z250 T0200
Programming track M02

Z
100 200 250

Fig.3.3.18 Tool offset and grinding compensation programming

(3) Tool radius compenstionG40 G41 G42

G 40
  G 00
Format G 41   X_Z_
G 42 G 01

Description
G40 Tool radius compensation cancelled
G41 Tool compensation, left (left side of tool path) shown
in Fig.3.3.19
G42 Tool compensation, right (right side of tool path)
shown in Fig.3.3.19
X, Z Parameter G00/G01 is the end where tool
compensation is preset or cancelled
Note G40, G41 and G42 are mutually cancelable mode code.

32
HNC-21T Programming Manual

X
Z
G42 on the right
side of the part

G41 on the left


side of the part

Fig.3.3.19 Right/left tool compensation


Note
(1) G41/G42 has no parameters, its compensation number (tool
radius compensation value) is defined by T code.
(2) The establishment and cancellation of tool radius
compensation is G00 or G01 but not G02 or G03.
Turning machine tool blade position code is defined for easy
compensation.
The tool blade position code is the perfect relation between tool
head and tool center. See Fig.3.3.20.

6
1 2

5 0 7 Z
P

C
4 3

Fig.3.3.20 Tool blade position code

33
HNC-21T Programming Manual

Example 12 Establish coordinates as shown in Fig.3.3.21


according to the arrow’s direction.

X
%1008
20
C G92 X−10 Z−10
R10
G90 T0202 M03 S900
A B G42 G00 X10 Z4
10
G01 Z20 F500
Z G03 X20 Z30 R10
-10
10 20 30 35 G01 Z40
G00 G40 X35
-10 M02
Tool positioning

Fig.3.3.21 tool blade radius compensation programming

Note
(1) Before machining move the tool to positioning point (relative
to programming zero (−10 −10)) manually
(2) The narrow line in figure is programming contour, the dotted
line is the actual path of the tool center.

3.3.6 Dwell G04


Format G04 P_
Description
P Dwell time (/s)
Until the feed speed of the program sections before G04 reduces
to zero the dwell can be operate.
The dwell should be operated before the program section
involving G04 is executed.

G04 is none mode code used in the program block that is specified.
G04 makes the tool a short dwell to acquire a smooth and perfect
machining surface. It can accomplish cutting, boring and corner track
control.

34
HNC-21T Programming Manual

3.3.7 Simple cycle


There are three simple cycles,
G80 inner/outer diameter cutting cycle
G81 surface cutting cycle
G82 thread cutting cycle.
Simple cutting cycle are always performed with a program block
with G code.
Note In the table below,
U W---relative value G91
X Z---absolute value G90
R ---rapid feed
F ---feed at F speed.

(1) Inner/outer cutting cycle G80


cylindrical inner/outer cutting cycle
Format G80 X__Z__F__
Description
X Z value of cutting destination C in part coordinate in
absolute programming
The directional distance from destination C to cycle
start point A, its code is decided by the direction of
1and 2.
The command works out the track A→B→C→D→A as shown in
Fig.3.3.22.
X Z W
4R A
D
Tool withdraw Cycle start
3F 1R U/2
Cuttting 2F Cutting start
Cend B X/2

Fig.3.3.22 Cylindrical inner/outer cutting cycle

35
HNC-21T Programming Manual

Example 13 Diameter programming and machining according to


the narrow pointed direction,
O0002;
N030 G80 G91 X-8.00 Z-66.000 F40.0
N031 X-16.0 Z-66.0
N032 X-24.0 Z-66.0
N033 X-32.0 Z-66.0
M02;

X
66

4
8 12
16

Row part

0 Z
part

Fig.3.3.23 Cylindrical inner/outer cutting cycle programming

Cylindrical inner/outer cutting cycle


Format G80 X__Z__ I___F__
Description
X Z value of cutting destination C in part coordinate in
absolute programming
The directional distance from destination C to cycle
start point A, its code is decided by the direction of
1and 2.
I The radius difference of cutting start B and cutting end
C, the code is difference code.
The command works out the track A→B→C→D→A as shown in
Fig.3.3.24.

36
HNC-21T Programming Manual

X Z W

D 4R A
3F 1R U/2
C 2F
B I
X/2

Fig.3.3.24 Cylindrical inner/outer cutting cycle

(2) Surface cutting cycle G81


surface plane cutting cycle
Format G81 X__Z__F__
X Z W
1R A
B
Cutting start Cycle start
2F 4R U/2
Cutting end 3F Withdraw
C D X/2

Fig.3.3.25 Surface plane cutting cycle

Note
X Z value of cutting destination C in part coordinate in
absolute programming
The directional distance from destination C to cycle
start point A, its code is decided by the direction of
1and 2.
The command works out the track A→B→C→D→A as shown in
Fig.3.3.25.

37
HNC-21T Programming Manual

Cylinder surface plane cutting cycle


Format G81 X__Z__ K__F__
Description
X Z value of cutting destination C in part coordinate in
absolute programming
The directional distance from destination C to cycle
start point A, its code is decided by the direction of
1and 2.
K Z direction distance from cutting start B to cutting end C
The command works out the track A→B→C→D→A as shown in
Fig.3.3.26.
X B 1(R)
A
2(F) 4(R) U/2
C 3(F) D
K
Z W X/2

Fig.3.3.26 Cylinder surface plane cutting cycle

(3) Thread cutting cycle G82


linear thread cutting cycle
Format G82 X__Z__R__E__C__P__F__
Description
X Z value of cutting destination C in part coordinate in
absolute programming
The directional distance from destination C to cycle
start point A, its code is decided by the direction of
1and 2.
F thread guidance

38
HNC-21T Programming Manual

R, E cutting withdraw directional value, R is withdraw in Z


direction, E is withdraw in X direction, R and E can be
omitted , meaning no withdraw.
P the spindle corner( default value 0) from spindle basic
pulse to the cutting start in single head thread cutting
the spindle corner of distance between start and end of
adjacent thread head in multi-head thread cutting.
C thread head numb 0 or 1 is sing head thread.
The command works out the track A→B→C→D→A as shown in
Fig.3.3.27.

X
Z W
E
4(R) A
D 1(R) U/2
3(R)
E
C 2(F) B
R X/2

Fig.3.3.27 Linear thread cutting cycle

Note
Thread cutting cycle, same to G32, works in feed keep; it stops
after all the movements.
Tapered thread cutting cycle
Format G82 X__Z__ I__R__E__C__P__F__
Description
X Z value of cutting destination C in part coordinate in
absolute programming
The directional distance from destination C to cycle
start point A, its code is decided by the direction of

39
HNC-21T Programming Manual

1and 2.
I the radius difference of thread start B to thread end C.
F thread guidance
R, E cutting withdraw directional value, R is withdraw in Z
direction, E is withdraw in X direction, R and E can be
omitted , meaning no withdraw.
C thread head numb 0 or 1 is sing head thread.
P the spindle corner( default value 0) from spindle basic
pulse to the cutting start in single head thread cutting
the spindle corner of distance between start and end of
adjacent thread head in multi-head thread cutting.
The command works out the track A→B→C→D→A as shown in
Fig.3.3.27.

X Z W

D
E A
C U/2
R B I
X/2

Fig.3.3.28 Tapered thread cutting cycle


3.3.8 Fixed cycle,
G71 inner/outer fixed cutting cycle
G72 surface rough cutting cycle
G73 closed contour fixed cycle
G76 thread cutting fixed cycle.

(1) Inner/outer fixed cutting cycle G71


Format
G71 U( ∆ d) R(e) P(ns) Q(nf) X( ∆ U) Z( ∆ W) F(f) S(s) T(t)
Description

40
HNC-21T Programming Manual

The command works out A→A'→B'→B rough track as


shown in Fig.3.3.29.
d cutting depth(cutting value ) without code decided by
vector AA
e withdraw per time
ns the first program block(AA') number of finish track ;
nf the last program block(B'B') number of finish track .
U X direction finish residual
W Z direction finish residual
F S T available at G71 in rough cutting; available between
ns to nf in finish.

A C
R
B
R
(F)
B' 45° ∆d
F

Programming
track
A′ ∆U/2
∆W

Fig.3.3.29 Inner/outer fixed cutting cycle G71

Cutting feed direction is parallel to Z axis in G71 X(∆U) and


Z(∆W)’s code are shown in Fig.3.3.30., (+) refers to move alone the
axis positively, (-) refers to move alone the axis negatively.
Note
(1) G71 command should have P and Q address or it cannot be
used.
(2) ns program block must have G00/G01 command to run from
A to A' and the program block should not have movement
of Z direction.

41
HNC-21T Programming Manual

(3) G02/G03 can be used in program blocks from ns to nf.


Command can be used, but subprogram should not be
included.
B A A 2B
X(+)Z(+) X(+) Z(-)

A A
Z

A A

X(-) Z(+) A A X(-) Z(-) B


B

Fig.3.3.30 Symbol of X(∆U)和Z(∆W) in fixed cycle G71

Example 14 Machining program in Fig.3.3.31: makes the contour


from A’ to B cycle start is at A(250 370) cutting depth
is 8mm The withdraw is 2mm the finish residual of X
direction is 0.1mm the finish residual of Z direction is
0.2mm.
X
B A
250

G F
160

E D
100
C A'
50

0 50 100 170 230 350 370 Z

Fig.3.3.31 G71 Programming


(1) Absolute programming
O1000
G92 X250 Z370;
G90 G71 U8 R2 P100 Q200 X0.1 Z0.2 F100 M03;
N100 G00 X50 Z370; from A to A'
G01 X50 Z350; from A’ to C

42
HNC-21T Programming Manual

X100 Z230; from C to D


X100 Z170; from D to E
X160 Z170; from E to F
X160 Z100; from F to G
N200 X250 Z50; from G to B
G00 X250 Z370; from B to A
M02;
(2) Relative programming
O1000
G92 X250 Z370;
G91 G71 U8 R2 P100 Q200 X0.1 Z0.2 F100 M03;
N100 G00 X-200 Z0; from A to A'
G01 Z-20; from A’ to C
X50 Z-120; from C to D
Z-60; from D to E
X60 from E to F
Z-70; from F to G
N200 X90 Z-50; from G to B
G00 Z220; from B to A
M02;

(2) Surface rough turning compound cycle G72


Format
G72 W( ∆ d) R(e) P(ns) Q(nf) X( ∆ U) Z( ∆ W) F(f) S(s) T(t)
Description
Compared with G71, its direction is parallel to the X-axis.
Fig.3.3.32 shows the finish turning track A→A'→B'→B.
d cutting depth(cutting value ) without code decided by
vector AA
e withdraw length per time
ns the first program block(AA') number of finish track ;
nf the last program block(B'B') number of finish track .
U X direction finish residual
W Z direction finish residual
F S T available at G71 in rough cutting; available between

43
HNC-21T Programming Manual

ns to nf in finish cutting .
∆d
C
A′
A

(F) Tool path


(R)

45°
Programming path
∆U/2
B
∆W

Fig.3.3.32 Surface rough turning compound cycle G72


Cutting feed direction is parallel to Z axis in G72 X(∆U) and
Z(∆W)’s code are shown in Fig.3.3.33., (+) refers to move alone the
axis positively, (-) refers to move alone the axis negatively.
X
B B

Z X(-) Z(+) X(-) Z(-)

A A
A' A'

A' A A A'

X(+) Z(+) X(+) Z(-)

B B

Fig.3.3.33 Symbol of X(∆U) and Z(∆W) in fixed cycle G71

44
HNC-21T Programming Manual

Note
(1) G72 command should have P and Q address or it can not
beused.
(2) ns program block must have G00/G01 command to run from
A to A' and the program block should not have movement
of Z direction.
(3) G02/G03 can be used in program blocks from ns to nf.
Command can be used, but subprogram should not be
included.
Example 15 Machining program in Fig.3.3.34: makes the contour
from A’ to B cycle start is at A(250 370) cutting depth
is 8mm The withdraw is 2mm the finish residual of X
direction is 0.1mm the finish residual of Z direction is
0.2mm.

X
A
250 A

C D
160
E F
100
G B
50
Z
0 50 100 170 230 300 370

Fig.3.3.34 G72 programming


(1) Absolute programming
O1000
G92 X250 Z370

G90 G72 W4 R2 P100 Q200 X0.1 Z0.2 F300 M03


N100 G00 X250 Z50; form A to A
G01 X160 Z100; form A to C
X160 Z170; form C to D

45
HNC-21T Programming Manual

X100 Z170; form D to E


X100 Z230; form E to F
G03 X50 Z300 R120; form F to G
N200 G01 X50 Z370; form G to B
G00 X250 Z370; form B to A
M02;
(2) Relative programming
O1000
G92 X250 Z350
G91 G72 W4 R2 P100 Q200 X0.1 Z0.2 F80 M03
N100 G00 Z-320; form A to A
G01 X-90 Z50; form A to C
Z70; form C to D
X-60; form D to E
Z60; form E to F
G03 X-50 Z70 R120; form F to G
N200 G01 Z70; form G to B
G00 X200; form B to A
M02;

(3) Closed-loop turning compound cycle G73[½ð1]


Format
G73 U( ∆ I) W( ∆ K) R(d) P(ns) Q(nf) X( ∆ U) Z( ∆ W) F_S_ T_
Description
The turning closed-track is shown in Fig.3.3.35, the tool
feeds close to the part and forms the part contour. The finish
track is A→A'→B'→B.
It is used to the finish turning for forged and cast row parts.

46
HNC-21T Programming Manual

Fig.3.3.35 Closed-loop turning compound cycle G73

∆ I residual of rough turning in axis X


∆ k residual of rough turning in axis Z
d rough turning times
e withdraw per time
ns the first program block(AA') number of finish track ;
nf the last program block(B'B') number of finish track .
U X direction finish residual
W Z direction finish residual
F S T available at G71 in rough cutting; available between
ns to nf in finish.

Note
I and K are rough feed rough times are d every turning
feed of X and Z are I/d and K/d
P and Q command in G73 make the cycle. Attention must be paid
on the positive and negative marks of U, W I and
K.
Example 16 Machining program in Fig.3.3.36:makes the contour
from A’ to B cycle start is at A(200 250) cutting depth
is 8mm, the rough residual in axis X and Z are 14mm and
14mm, the rough times are 3. The finish residual of X

47
HNC-21T Programming Manual

direction is 0.6mm; the finish residual of Z direction is


0.3mm.

X I+ u

( K+ W)
100
80

20

40
0
Z

R35

25 15
10 8
58

Fig.3.3.36 G73 Programming


O0010
G92 X200 Z250
G00 X120 Z85
G73 U14 W14 R3 P40 Q80 X0.6 Z0.3 F0.3 S100;
N40 G00 X20 Z58;
G01 X20 Z43;
X40 Z35;
G02 X80 Z10 R35;
N80 G01 X100 Z0;
M02

(4) Thread cutting compound cycle G76 [½ð2]

Format
G76C(m)R(r)E(e)A(a)X(U)Z(W)I(i)K(k)U(d)V( ∆ dmin)Q( ∆ d)P(p)F(L);
Description
Fig. 3.3.37 shows the turning track of thread cutting
compound cycle G76. The single side turning and

48
HNC-21T Programming Manual

parameters are shown in Fig. 3.3.38.


m finish times (1~99) mode
r thread Z direction withdraw length (00~99) mode
e thread X direction withdraw length (00~99) mode
tool angle (two-digital number) mode
one of 80° 60° 55° 30° 29° and 0°
U W thread end coordinate in absolute programming
The directional distance from thread end to cycle
start A in incremental programming
∆ dmin Min.cutting depth
When cutting depth (∆d n − ∆d n − 1) is smaller than
∆ dmin it is cutting depth
d finish residual
i radius difference on two ends of thread
if i=0 it is straight thread (cylindrical thread ) cutting
k thread height
decide by the radius in axis X
∆ d first cutting depth (radius)
p the spindle’s angle at the starting point to the spindle’s Z
plus;
L thread guidance (the same to G32)

E (R) A

(R)

U/2
(F)

e (F) d
X
D B
i
K
r W C

Fig.3.3.37 Thread cutting compound cycle G76 [½ð3]

49
HNC-21T Programming Manual

d
1st
k
2nd
dvn

nth
d

Fig.3.3.38 G76 cycle single side cutting and parameters


Note
Positive and negative marks must be noticed when X(U) and Z(W)
executing cycle cutting in G76.
G76 single side cutting reduces the force applied to the tool, the first
cutting depth is ∆ d, the number n time depth is ∆d n .

In Fig.3.3.37 the cutting speed from C to D is decide by F code, the


other tracks are fast feed.
Example 17 Thread cutting compound cycle.
G76 R01C1.0A60X606.4Z250K36.80 U2 V1 Q18.00 F6.0;

(4) Specifications of compound cycle


The program block defined by address P in G71 G72 and G73
should be the preparing function [½ð4]G00 or G01 in 01 or the
system will give a alarm.
G71 G72 and G73 can not be used in MDI mode, but G76 can be
used.
M98 and M99 can not be used between the program addressed by
P and Q in the G71,G72 and G73.

50
HNC-21T Programming Manual

3.4 Customer macro

HNC-21T CNC system provides the customer with macro


function simulating to the advanced language. Customer can conduct
mathematic calculation, logic calculation and function compound
calculation in the system. Furthermore circulation sentence, sub
sentence and subprogram call can be used to make compound program
and simplify calculation process in programming.

3.4.1 Variable and constant

(1) Variable
#0 #49 Local variables
#50 #199 System variables
#200 #249 0 layers local variables
#250 #299 1 layers local variables
#300 #349 2 layers local variables
#350 #399 3 layers local variables
#400 #449 4 layers local variables
#450 #499 5 layers local variables
#500 #549 6 layers local variables
#550 #599 7 layers local variables
#600 #699 Tool length memoryH0 H99
#700 #799 Tool length memory D0 D99
#800 #899 Tool life memory
#1000 Current position of machine #1001 Currentpositionofmachine #1002 Current position of

X Y machineZ

#1003 Current position of machine #1004 Currentpositionof machineB #1005 Current position of

A machineC

#1006 Current position of machine #1007 Currentposition ofmachineV #1008 Current position of

U machineW

#1009 “Diameterprogramming” #1010 Positionofmachine #1011 Positionofmachine

programmedX programmedY

51
HNC-21T Programming Manual

#1012 Position of machine #1013 Position of machine programmed #1014 Position of machine

programmedZ A programmed B

#1015 Position of machine #1016 Position of machine programmed #1017 Position of machine

programmedC U programmedV

#1018 Position of machine #1019 Keep #1020 Position of part

programmedW programmedX

#1021 Position of part programmed #1022 Positionofpart programmed Z #1023 Position of part

Y programmedA

#1024 Position of part programmed #1025 Positionofpart programmedC #1026 Position of part

B programmedU

#1027 Position of part programmed #1028 Positionofpart programmedW #1029 Keep

#1030 Currentzeroof the partX #1031 Currentzeroof the partY #1032 Current zero of the

partZ

#1033 Current zero of the part #1034 Currentzeroof the partB #1035 Current zero of the

A partC

#1036 Current zero of thepartU #1037 Currentzeroof the partV #1038 Current zero of the

partW

#1039 “Coordinate axes #1040 G54 ZeroX #1041 G54 ZeroY

establish”

#1042 G54 ZeroZ #1043 G54 ZeroA #1044 G54 ZeroB

#1045 G54 ZeroC #1046 G54 ZeroU #1047 G54 ZeroV

#1048 G54ZeroW #1049 Keep #1050 G55ZeroX

#1051 G55ZeroY #1052 G55ZeroZ #1053 G55 ZeroA

#1054 G55 ZeroB #1055 G55 ZeroC #1056 G55 ZeroU

#1057 G55 ZeroV #1058 G55ZeroW #1059 Keep

#1060 G56 ZeroX #1061 G56 ZeroY #1062 G56 ZeroZ

#1063 G56 ZeroA #1064 G56 ZeroB #1065 G56ZeroC

#1066 G56 ZeroU #1067 G56 ZeroV #1068 G56 ZeroW

52
HNC-21T Programming Manual

#1069 Keep #1070 G57ZeroX #1071 G57ZeroY

#1072 G57ZeroZ #1073 G57ZeroA #1074 G57ZeroB

#1075 G57ZeroC #1076 G57ZeroU #1077 G57 ZeroV

#1078 G57ZeroW #1079 Keep #1080 G58ZeroX

#1081 G58ZeroY #1082 G58ZeroZ #1083 G58ZeroA

#1084 G58ZeroB #1085 G58 ZeroC #1086 G58 Zero U

#1087 G58ZeroV #1088 G58 ZeroW #1089 Keep

#1090 G59ZeroX #1091 G59 ZeroY #1092 G59ZeroZ

#1093 G59ZeroA #1094 G59 ZeroB #1095 G59ZeroC

#1096 G59ZeroU #1097 G59 ZeroV #1098 G59ZeroW

#1099 Keep #1100 Positionofbroken pointX #1101 Positionofbroken pointY

#1102 Positionofbroken pointZ #1103 Positionofbroken pointA #1104 Positionofbroken pointB

#1105 Positionofbroken pointC #1106 Positionofbroken pointU #1107 Positionofbroken pointV

#1108 Positionofbroken pointW #1109 Establishmentof #1110 G28 Positionofmiddle

coordinateaxis pointX”

#1111 “G28PositionofmiddlepointY” #1112 G28Positionofmiddle pointZ” #1113 G28Positionofmiddle

pointA”

#1114 “G28PositionofmiddlepointB” #1115 G28Positionofmiddle pointC” #1116 G28Positionofmiddle

pointU”

#1117 “G28PositionofmiddlepointV” #1118 G28PositionofmiddlepointW” #1119 “G28Shield letter”

#1120 Positionof imaginary pointX #1121 Positionofimaginary pointY #1122 Positionofimaginary pointZ

#1123 Positionofimaginary pointA #1124 Positionofimaginary pointB #1125 Positionofimaginary pointC

#1126 Positionofimaginary pointU #1127 Positionofimaginary pointV #1128 Positionofimaginary

pointW

#1129 Imaginary shieldletter #1130 Circularcenter(axis1) #1131 Circularcenter(axis2)

#1132 Circularangle #1133 Imaginary letterofcircularaxis #1134 Keep

#1135 Scalingcenter(axis1) #1136 Scalingcenter(axis2) #1137 Scalingcenter(axis3)”

#1138 Scalingratio #1139 Shieldletterofscalingaxis #1140 Axischange code1

#1141 Axischange code 2 #1142 Axischange code3 #1143 Keep

53
HNC-21T Programming Manual

#1144 Toollength #1145 Toollength #1146 Currentplane1

compensationnumber compensation number

#1147 Currentplane2 #1148 Shieldletterofimaginary axis #1149 Feedspeedselection

#1150 Modevalueof Gcode 0 #1151 Modevalueof Gcode 1 #1152 Modevalueof Gcode 2

#1153 Modevalueof Gcode 3 #1154 Modevalueof Gcode4 #1155 Modevalueof Gcode 5

#1156 Modevalueof Gcode 6 #1157 Modevalueof Gcode 7 #1158 Modevalueof Gcode 8

#1159 Modevalueof Gcode 9 #1160 “ModevalueofGcode 10” #1161 “ModevalueofGcode11”

#1162 “ModevalueofGcode12” #1163 “ModevalueofGcode13” #1164 “ModevalueofGcode14”

#1165 “ModevalueofGcode #1166 “ModevalueofGcode 16” #1167 “ModevalueofGcode17”

Modevalueof Gcode 15”

#1168 “ModevalueofGcode18” #1169 “ModevalueofGcode19” #1170 ResidualCACHE

#1171 PreparedCACHE #1172 Residualbuffer #1173 preparedbuffer

#1174 Keep #1175 Keep #1176 Keep

#1177 Keep #1178 Keep #1179 Keep

#1180 Keep #1181 Keep #1182 Keep

#1183 Keep #1184 Keep #1185 Keep

#1186 Keep #1187 Keep #1188 Keep

#1189 Keep #1190 Customer-definedinput #1191 Customer-definedoutput

#1192 Customer-definedinputshield #1193 Keep #1194 Keep

#2000 #2600 compound cycle data area

#2000 contour points

#2001~2100 contour type (0 G00, 1:G01, 2:G02, 3:G03)

#2101~2200 contour point X(diameter/radius)

#2201~2300 contour point Z

#2301~2400 contour point R

#2401~2500 contour point I

#2501~2600 contour point J

(2) Constant
PI

54
HNC-21T Programming Manual

TRUE True condition


FALSE False condition

3.4.2 Symbols and equations

(1) Mathematic symbols


+ - * /

(2) Conditional symbols


EQ = NE GT
GE LT LE

(3) Logic symbols


AND OR NOT

(4) Functions
SIN COS TAN ATAN ATAN2
ABS INT SIGN SQRT EXP

(5) Equations
The equations are composed of constants, symbols and variables.
For example 175/SQRT[2] * COS[55 * PI/180 ]
#3*6 GT 14

3.4.3 Valuation equations


Formation Variable=constant or equation
Valuation refers to enable a variable value of constant or
equation.
For example #2 = 175/SQRT[2] * COS[55 * PI/180 ]
#3 = 124.0

3.4.4 Condition judgment IF ELSE ENDIF


Format (i) IF Conditional expression s

ELSE

ENDIF
Format (ii) IF Conditional expression

55
HNC-21T Programming Manual

ENDIF
3.4.5 Circulation WHILE ENDW
WIIILE Conditional expression

ENDW
Uses of conditional sentences are illustrated in the examples of
macro programming.
Uses of circulation sentences are illustrated in the examples of
macro programming.

Example 18: Fig.3.3.39 shows the macro programming of Z=X2/8


between [0 16].
X

16

Z
0 32

Fig.3.3.39 Macro programming

%8002
#10=0 X coordinate
#11=0 Z coordinate4
N10 G92 X0.0 Z0.0
M03 S600
WHILE #10 LE 16
G90 G01 X[#10] Z[#11] F500
#10=#10+0.08
#11=#10*#10/8
ENDW

56
HNC-21T Programming Manual

G00 Z0 M05
G00 X0
M30

57
HNC-21T Programming Manual

Diameter Programming Conditions


Item Conditions
Z axis command Not related to diameter and radius

X axis command Diameter command

Selection of coordinate Diameter command

Circular interpolation radius Radius command

command
R I K

X axis direction feed speed Radius transfer/rpm

Radius transfer/min

X axis position display Diameter display

58
HNC-21T Programming Manual

APPENDIX 1 HNC-21T Fixed Cycle Macro

(1) Accomplishment of turning cycle and transmission of


subprogram call
Fixed cycle in HNC-21T system is accomplished by macro, and
the fixed cycle is mode code.
Because the CNC system supplier defines the fixed cycle
differently, the customer can define the fixed cycle in their
conveniences
A pack of source code stticcy will be given for free to customer
with the CNC system assembled by HCNC.
For reader’s convinces parameter transmission of macro and
subprogram call for HNC-21T is introduced below.
When the macro is called with G (subprogram or fixed cycle) the
system will copy the letter segments in program section to local
variables #0-#25 in the macro. At the same time the system can copy
the absolute axis value (machine absolute coordinate value) of nine
channels to local variables #30-#38 in the macro.
In calling subprogram the mode value of the system cannot not be
saved meaning that subprogram can modify the system mode and keep
it; in calling fixed cycle the system mode cannot be modified.
The table below shoes corresponding name of macro transmission
of the local variables #0~#38

Local variables Letter name or variables transmitted


in macro in macro calling
#0 A
#1 B
#2 C
#3 D
#4 E
#5 F
#6 G

59
HNC-21T Programming Manual

#7 H
#8 I
#9 J
#10 K
#11 L
#12 M
#13 N
#14 O
#15 P
#16 Q
#17 R
#18 S
#19 T
#20 U
#21 V
#22 W
#23 X
#24 Y
#25 Z
#26 Mode value of Z-plane in fixed mode
#27 Unavailable
#28 Unavailable
#29 Unavailable
#30 Absolute coordinate of 0- axis when
subprogram called
#31 Absolute coordinate of 1- axis when
subprogram called
#32 Absolute coordinate of 2- axis when
subprogram called
#33 Absolute coordinate of 3- axis when
subprogram called
#34 Absolute coordinate of 4- axis when

60
HNC-21T Programming Manual

subprogram called
#35 Absolute coordinate of 5- axis when
subprogram called
#36 Absolute coordinate of 6- axis when
subprogram called
#37 Absolute coordinate of 7- axis when
subprogram called
#38 Absolute coordinate of 8- axis when
subprogram called

Every local variable can be recognized with AR[]as a defined or


not, a incremental or a absolute.

The format of macro called is,


AR[#Variable number]
Return
0 Not defined
90 Defined as absolute G90
91 Defined as relative G91
Example In main program O1000’s calling subprogram O9990
the value of I, K are set, subprogram O9990 can call the value of I, K
through local variables #8, #10
%1000
G92 X0Y0Z0
M98 P9990 I20 J30 K40
M30
%9990
IF [AR[#8] EQ 0] OR [AR[#9] EQ 0] OR [AR[#10] EQ 0]
; If value of I, K is not defined
M99 ; Return
ENDIF
N10 G91 ; Incremental programming

IF AR[#8] EQ 90 ; If I is absolute G90


61
HNC-21T Programming Manual

#8=#8-#30 ; Change I into incremental, #30 is absolute


coordinate in X axis
ENDIF

M99
HNC-21T CNC system has nine layers of subprogram can be
used. Every layer of subprogram has its independent local variables, at
most 50. Current local variables are #0-#49 the first layer local
variables are #200-#249, the second layer local variables are
#250-#299 the third layer local variables are #300-#349 and so on.
The definition of local variables is dependent on number of layers
in the last subprogram, for example,
o0099
g92 X0 Z0
N100 #10=98
M98 P100
M30

o100
N200 #10=100 ; The local variable of #10 in subprogram
containing N100 is #210 in the first layer
M98 P110
M99

o110
N300 #10=200 ; The local variable of subprogram
containing N100 is #260 in the second layer
; The local variable of #10 in subprogram containing N100
is #210 in the first layer

M99

62
HNC-21T Programming Manual

For the further understanding of macro in HNC-21T system a


none perfect circle CNC program is shown below,
O1000
G92 X0 Z0
M98 P2 X-50 Y0 R50 ; Macre call for
machining circle
M30

O2
; Circle machining program, center is (X,Z), radius is R
; X -> #23 Y -> #24 R -> #17
IF [AR[#17] EQ 0] OR [#17 EQ 0] ; If R is not defined
M99
ENDIF

IF [ AR[#23] EQ 0 ] OR [ AR[#24] EQ 0 ] ; If center is not


defined
M99
ENDIF

#46=#1163 ; Recording #1163 of 13th group mode codes,


G90 or G91?

G91 G64 ; Using relative programming G91


IF [ AR[#23] EQ 90 ] ;If X is absolute programming
#23=#23-#30 ; To relative programming
ENDIF

IF [ AR[#24] EQ 90 ] ; If Yis absolute programming


#24 = #24-#31 ; To relative programming
ENDIF

63
HNC-21T Programming Manual

#0=#23+#17*COS[0];
#1=#25+#17*SIN[0];
G01 X[#0] Z[#1];

#10=1
WHILE [#10 LE 100] ; 100 little line segments form a
circle
#0 = #17*[ COS[#10*2*PI/100]-COS[[#10-1]*2*PI/100] ]
#1 = #17*[ SIN[#10*2*PI/100]-SIN[[#10-1]*2*PI/100] ]
G01 X[#0] Z[#1]
#10=#10+1
ENDW

G[#46] ; return to mode


M99

(2) Accomplishment of turning fixed cycle macro


The source codes of fixed cycle macro in HNC-21Tsystem are shown
below,

%0000
;" fixed cycle macro: G73,G74,G76,G80,G81,G82;
; _____________________________________________________________
%0080
; the source codes of inner/outer diameter cutting cycle G80
; before call the program, run spindle with M03 or M04

#40 = #1152
IF [AR[#25] EQ 0] OR [AR[#23] EQ 0]
; if X and Z are not defined
M99 ; return
ENDIF

N10 G90 ; absolute macro programming


IF AR[#23] EQ 91 ; if X is incremental G91

64
HNC-21T Programming Manual

#23=#23+#30 ; change X to absolute


; #30 is value of X when calling the
program
ENDIF

IF AR[#25] EQ 91 ; if Z is incremental G91


#25=#25+#32 ; change Z to absolute
; #32 is absolute coordinate value of
Z when calling the program

ENDIF

IF AR[#8] EQ 0 ;if I is not defined


#8 = 0; ; I=0
ENDIF

IF #1009 EQ 0
#41 = 2 ;radius programming
ELSE
#41 = 1 ;diameter programming
ENDIF
g01 X[#30*2/#41] Z[#32]

#42=[#23+#8]*2/[#41]
N20 g00 X[#42]Z[#32] ;move to turning point
#42=[#23]*2/[#41]
N30 G01 Z[#25]X[#42]

#42=[#30]*2/[#41]
N40 G01 X[#42] ;turning
N50 G00 Z[#32] ;return to the initial point

G[#40]

M99

65
HNC-21T Programming Manual

; _____________________________________________________________
%0081
; the source codes of surface cutting cycle G81
; before call the program, run the spindle with M03 or M04
#40=#1152
IF [AR[#25] EQ 0] OR [AR[#23] EQ 0]
; if X and Z are not defined
M99 ; return
ENDIF

N10 G90 ; absolute macro programming


IF AR[#23] EQ 91 ; if X is incremental G91
#23=#23+#30 ; change X to absolute
; #30 is the value of X when calling the
programming
ENDIF

IF AR[#25] EQ 91 ;if Z is incremental G91


#25=#25+#32 ; change Z to absolute
; #32 is the absolute coordinate value
of Z when calling the programming

ENDIF

IF AR[#10] EQ 0 ; if K is not defined


#10 = 0 ; K=0
ENDIF

IF #1009 EQ 0 ;
#41 = 2 ;radius programming
ELSE
#41 = 1 ;diameter programming
ENDIF
G90g01 X[#30*2/#41] Z[#32]

N20 G00 X[#30*2/#41] Z[#25+#10] ;move to turning point

66
HNC-21T Programming Manual

#42=[#23]*2/[#41] ;
N30 G01 X[#42]Z[#25]
N40 G01 Z[#32] ;turning
#42=[#30]*2/[#41] ;
N50 G00 X[#42] ;return to initial point

G[#40]

M99

; _____________________________________________________________
%0082
; the source codes of thread cutting cycle G82
; before call the program run the spindle with M03 or M04

#40=#1152
IF [AR[#25] EQ 0] OR [AR[#23] EQ 0]
; if X and Z are not defined
M99 ; return
ENDIF

IF AR[#5] EQ 0 ; if pitch F is not defined M99


; return
ENDIF

N10 G90 ; absolute macro programming

IF AR[#23] EQ 91 ; if X is incremental G91


#23=#23+#30 ; change X to absolute
; #30 is the absolute coordinate
value of X
ENDIF

IF AR[#25] EQ 91 ; if Z is incremental G91


#25=#25+#32 ; change Z to absolute
; #32 is the absolute coordinate

67
HNC-21T Programming Manual

ENDIF

IF AR[#8] EQ 0 ; if I is not defined


#8 = 0;
ENDIF

IF AR[#4] EQ 0 ; if the withdraw length E in X


direction is not defined
#4 = 0 ;
ENDIF

IF AR[#17] EQ 0 ; if the withdraw length R in Z


direction is not defined
#17 = 0;
ENDIF

IF AR[#2] EQ 0 ; if the thread head number is not


defined
#2 = 1 ; single head
ENDIF

IF [[#2 LT 2] or [#2 GT 99]]


#2 = 1;
ENDIF

IF AR[#15] EQ 0 ; if the gap angle is not defined


#15 = 0 ; value is 0
ENDIF

#28 = 0;
IF [#2 EQ 1]
#28 = #15 ; initial angle
#15 = 0
ENDIF

IF #1009 EQ 0 ;

68
HNC-21T Programming Manual

#41 = 2 ;radius programming


ELSE
#41 = 1 ;diameter programming
ENDIF
G90g01 X[#30*2/#41] Z[#32]

WHILE [#2 GE 1]
#42=[#23+#8]*2/[#41] ;
N20 G00 X[#42] Z[#32] ;move to turning point
#42=[#23]*2/[#41] ;
N30 G32 X[#42] Z[#25] E[#4] R[#17] P[#28] F[#5]
#42=[#30]*2/[#41] ;
N40 G01 X[#42] Z[#25+#17] ;turning
N50 G00 Z[#32] ;return to initial point

#2 = #2 -1
#28 = #28 +#15;
ENDW

G[#40]

M99

; _____________________________________________________________
%0071
; the source codes of inner/outer compound cycle G71
; before call the program, run the spindle with M03 or M04

IF [AR[#20] EQ 0] OR [AR[#17] EQ 0]
; if the cutting depth and tool
withdraw length R are not define
M99 ; return
ENDIF

IF [AR[#23] EQ 0] OR [AR[#25] EQ 0] ; if X and Z re not defined


M99 ; return

69
HNC-21T Programming Manual

ENDIF

IF [#20 LE 0] OR [#17 LE 0] ; if U and R are less than 0


M99 ; return
ENDIF

#49 = #1152 ;keep G


IF #1009 EQ 0 ;
#41 = 2 ;radius programming
ELSE
#41 = 1 ;diameter programming
ENDIF
G90g01 X[#30*2/#41] Z[#32]

#0=0
#1=#2000 ;number of the points
IF #1 LE 1 ;if the number of point is less than
1,return
M99;
ENDIF

#2=[#20+#17]*2/[#41] ;per tool feed U+R


IF [#30*2/#41] GT #2101 ;feed direction judge X>
#2=-#2
ENDIF

#3=[#17]*2/[#41] ;per tool withdraw length R in X


direction
IF [#23 LT 0] ;tool withdraw direction judge:
negative
#3=-#17
ENDIF

#4=#17 ;tool withdraw length in Z


direction
IF [#25] LT 0 ;tool withdraw direction judge:

70
HNC-21T Programming Manual

Z<0
#4=-#17 ;tool withdraw direction is
negative
ENDIF

#5=[#30+#23]*2/[#41] ;current absolute coordinate of X


#12=#32+#25 ; current absolute coordinate of Z
N20 G00 G90 X[#5] Z[#12] ;move to C
#5 = #5 + #2 ;next position in X
#40 = 1;
IF [#[2100+#1] GE #[2101]] ;
#40 = -1 ; reduce X
ELSE
#40 = 1 ;plus X
ENDIF
IF [#5 GT [#[2100+#1]+[#23]*2/#41]] AND [#40 EQ [-1]]
; the difference between the first
X and current X
#5 = #[2100+#1]+[#23]*2/#41
ELSE
IF [#5 LT [#[2100+#1]+[#23]*2/#41]] AND [#40 EQ 1]
#5 = #[2100+#1]+[#23]*2/#41
ENDIF
ENDIF

WHILE [[#1] GT 1]
#6=#[2100+#1]+[#23]*2/#41 ;the absolute coordinate of last X
#7=#[2200+#1]+#25 ;the absolute coordinate of last Z
#8=#[2100+#1-1]+[#23]*2/#41 ; the absolute coordinate of next
X
#9=#[2200+#1-1]+#25 ; the absolute coordinate of next
Z
WHILE [[[#5 GE #8] AND [#5 LE #6]] OR [[#5 LE #8] AND [#5 GE #6]] ]
; X is within the two points with
cross point
#10=#[2000+#1]

71
HNC-21T Programming Manual

IF #10 LT 2 ; straight line


IF #6 EQ #8
#11=#7
ELSE
#11 = #7+[#9-#7]*[#5-#6]/[#8-#6] ; cross point Z
ENDIF
ELSE ;circular arc
#43=#8*#41/2+[#[2400+#1]]
#44=#9+#[2500+#1]
#45=[#[2300+#1]] ;R
#47=[#5*#41/2]-#43
#46=[#45*#45]-[#47*#47]
IF [#46 LT 0]
#46 = 0
ENDIF
; x0=x2+i;
; z0=z2+k;
; *result=z0-sqrt(r*r-(y-x0)*(y-x0));
IF #10 EQ 2 ;CW
#11 = #44+[#40*SQRT[#46]] ; cross point Z
ELSE
; *result=z0+sqrt(r*r-(y-x0)*(y-x0));
#11 = #44-[#40*SQRT[#46]]
ENDIF
ENDIF

G00 X[#5] ;move to turning point


G01 Z[#11] ;turning till to cross point
#5 = #5 + #3 ; next position in X
#11 = #11 + #4 ; next position in Z
G00 X[#5] Z[#11] ;tool withdraw
G00 Z[#12] ;return

#5 = #5 + #2 ;X move
ENDW
#1 = #1 -1;

72
HNC-21T Programming Manual

ENDW

;last absolute turning track[with finish residual]


#0=1
WHILE #0 LE #2000
#10=#[2000+#0]
#11=#[2100+#0]+[#23]*2/[#41] ;consider finish residual in X
;diameter programming
#12=#[2200+#0] + [#25] ;plus finish residual in Z
#13=#[2300+#0]
IF #10 LT 2 ;straight line
G[#10] X[#11] Z[#12]
ELSE ; circular arc
G[#10] X[#11] Z[#12] R[#13]
ENDIF
#0=[#0]+1
ENDW

#5 = [#30]*2/[#41] ; consider diameter programming at


initial X
G00 X[#5] Z[#32] ; return to initial point
G[#49] ; G90G91 mode resume

M99

; _____________________________________________________________
%0072
; the source codes of surface rough cutting compound cycle G72
; before call the program run spindle with M03 or M04

IF [AR[#22] EQ 0] OR [AR[#17] EQ 0] ;cutting depth and tool


withdraw length are not defined
M99 ;return
ENDIF

IF [AR[#23] EQ 0] OR [AR[#25] EQ 0] ;if X and Z are not defined

73
HNC-21T Programming Manual

M99 ;return
ENDIF

IF [#22 LE 0] OR [#17 LE 0]
M99 ;if W and R are less than 0,
return
ENDIF

#49 = #1152
IF [#1009 EQ 0]
#41 = 2 ;radius programming
ELSE
#41 = 1 ;diameter programming
ENDIF
G90g01 X[#30*2/#41] Z[#32]

#0=0
#1=#2000 ;number of points
IF #1 LE 1 ;if the number≤1 return
M99
ENDIF

#2=[#22+#17] ;per tool feed W+R


IF #32 GT #2201 ;tool feed direction judge Z>
#2=-#2
ENDIF

#3=[#17]*2/[#41] ;tool withdraw length in X


direction R
IF [#23 LT 0] ;tool withdraw direction judge:
X<0 时
#3=-#17 ; tool withdraw direction is
negative
ENDIF

#4=#17 ; tool withdraw length in Z

74
HNC-21T Programming Manual

IF #25 LT 0 ; tool withdraw direction


judge: Z<0
#4=-#17 ; tool withdraw direction is
negative
ENDIF

#5=[#30+#23]*2/[#41] ;absolute coordinate of X


#12=#32+#25 ; absolute coordinate of Z
N20 G00 G90 X[#5] Z[#12] ;move to C
#12 = #12 + #2 ;move to next position in Z
#40 = 1;
IF [#[2200+#1] GE #[2201]]
#40 = -1; ;reduce Z
ELSE
#40 = 1; ;plus Z
ENDIF
IF [#12 GT [#[2200+#1]+[#25]]] AND [#40 EQ [-1]]
;distance between the first Z
and current Z
#12 = #[2200+#1]+[#25]
ELSE
IF [#12 LT [#[2200+#1]+[#25]]] AND [#40 EQ 1]
#12 = #[2200+#1]+[#25]
ENDIF
ENDIF

WHILE [[#1] GT 1]
#6=#[2100+#1]+[#23]*2/#41 ;the absolute coordinate of last X
#7=#[2200+#1]+#25 ;the absolute coordinate of
last Z
#8=#[2100+#1-1]+[#23]*2/#41 ; the absolute coordinate of
next X
#9=#[2200+#1-1]+#25 ; the absolute coordinate of
next Z
WHILE [ [[#12 GE #9] AND [#12 LE #7]] OR [[#12 LE #9] AND [#12
GE #7]] ] ;Z is within the two points

75
HNC-21T Programming Manual

with cross point #10=#[2000+#1]


IF #10 LT 2 ;straight line
IF #7 EQ #9
#11=#6
ELSE
;*result = x1+(x2-x1)*(y-z1)/(z2-z1);
#11=#6+[#8-#6]*[#12-#7]/[#9-#7]
ENDIF ;cross point X
ELSE ;circular arc
#43=#8+[#[2400+#1]*2/#41]
#44=#9+#[2500+#1]
#45=#[2300+#1] ;R
#46=[#45*#45]-[[#12-#44]*[#12-#44]]
IF [#46 LT 0]
#46 =0;
ENDIF
; x0=x2+i;
; z0=z2+k;
; *result=x0+sqrt(r*r-(y-z0)*(y-z0));
IF #10 EQ 2 ;CW with cross point X
#11=#43-[#40*SQRT[#46]*2/#41]
ELSE
; *result=x0-sqrt(r*r-(y-z0)*(y-z0));
#11 = #43+[#40*SQRT[#46]*2/#41]
ENDIF
ENDIF

G00 Z[#12] ;move to turning point


G01 X[#11] ;move to cross point #12
= #12 + #4 ;the next position of Z
#11 = #11 + #3 ; the next position of X
G00 X[#11] Z[#12] ;tool withdraw
G00 X[#5] ;return

#12 = #12 + #2 ;move X


ENDW

76
HNC-21T Programming Manual

#1 = #1 -1;
ENDW

;the last absolute turning along the track


#0=1
WHILE #0 LE #2000
#10=#[2000+#0]
#11=#[2100+#0] + [#23]*2/[#41]
#12=#[2200+#0] + [#25]
#13=#[2300+#0]
IF #10 LT 2 ;straight line
G[#10] X[#11] Z[#12]
ELSE
G[#10] X[#11] Z[#12] R[#13]
ENDIF
#0=[#0]+1
ENDW

#5 = [#30]*2/[#41] ;consider diameter


programming at initial X
G00 X[#5] Z[#32] ;return to initial point
G[#49]

M99

; _____________________________________________________________
%0073
; the source codes of closed contour cycle G73
; before call the program the run spindle with M03 or M04

IF [AR[#22] EQ 0] OR [AR[#17] EQ 0] OR [AR[#20] EQ 0]


;if cutting depth U and W cycle time R are
not defined
M99 ;return
ENDIF

77
HNC-21T Programming Manual

IF [AR[#23] EQ 0] OR [AR[#25] EQ 0] ;if X and Z are not defined


M99 ;return
ENDIF

IF #17 LE 0
M99 ;if R is less then 0, return
ENDIF

#49 = #1152
IF #1009 EQ 0
#41 = 2 ;radius programming
ELSE
#41 = 1 ;diameter programming
ENDIF
G90g01 X[#30*2/#41] Z[#32]

#0=#17
#1=1
#2=[#30+#23+#20]*2/#41 ;current coordinate of X: A1
#3=#32+#25+#22 ; current coordinate of Z: A1

G90
G00 X[#2] Z[#3] ;move to A1

WHILE #0 GT 0
WHILE #1 LE #2000
#4=[[#20*2/#41]/#17] ;feed length in X direction
#5=[#22/#17] ; feed length in Z direction
#6=#[2100+#1]+[#23]*2/[#41]+[#4*#0] ;next coordinate of X
#7=#[2200+#1]+#25+[#5*#0] ; next coordinate of Z
#8=#[2000+#1] ;G
#9=#[2300+#1] ;R
IF #8 LT 2 ;straight line
G[#8] X[#6] Z[#7]
ELSE
G[#8] X[#6] Z[#7] R[#9]

78
HNC-21T Programming Manual

ENDIF
#1=#1+1
ENDW
#2=#2-[[#20*2/#41]/#17];
#3=#3-[#22/#17]
G00 X[#2] Z[#3] ;move to next starting point
#1=1
#0=#0-1
ENDW

#0=1
WHILE #0 LE #2000 ;last time
#9=#[2000+#0]
#10=#[2300+#0]
#6=#[2100+#0]+[#23]*2/[#41]; ;next X with finish residual
#7=#[2200+#0]+[#25] ; next Z with finish residual
IF #9 LT 2 ;straight line
G[#9] X[#6] Z[#7]
ELSE
G[#9] X[#6] Z[#7] R[#10]
ENDIF
#0=#0+1
ENDW

#5 = [#30]*2/[#41] ; consider diameter


programming at initial X
G00 X[#5] Z[#32] ;return to initial point
G[#49]

M99

; _____________________________________________________________
%0076
the source codes of thread cutting compound cycle G76
before call the program, run spindle with M03 or M04

79
HNC-21T Programming Manual

IF [AR[#0] EQ 0] ;if tool angle A is not defined


M99 ;return
ENDIF

IF [AR[#23] EQ 0] OR [AR[#25] EQ 0] ;if X and Z are not defined


M99 ;return
ENDIF

IF [AR[#10] EQ 0] ;if K is not defined


M99 ;return
ENDIF

IF [AR[#20] EQ 0] OR [AR[#21] EQ 0] OR [AR[#16] EQ 0]


;if U, V and Q are not defined
M99 ;return
ENDIF

IF [AR[#5] EQ 0] ; if F is not defined, return


M99
ENDIF

IF [AR[#17] EQ 0] ;if withdraw length R is not


defined
#17 = 0 ;withdraw length is 0
ENDIF

;IF [#17 GT 99] OR [#17 LT 0] ; if withdraw length R ›99 or


‹0
; M99 ;return
;ENDIF

IF [AR[#2] EQ 0] ;if finish times C is not


defined
#2 = 1 ; finish time is 0
ENDIF

80
HNC-21T Programming Manual

IF [#2 GT 99] OR [#2 LT 0] ; if finish times R ›99 or ‹0


M99 ;return
ENDIF

IF [AR[#8] EQ 0] ;if thread taper I is not


defined
#8 = 0 ;I=0
ENDIF

IF [#0 LT 10] OR [#0 GT 80] ; if tool angle A ›80 or ‹10


M99 return
ENDIF

IF AR[#4] EQ 0 ; if withdraw length E in X is


not defined
#4 = #10;
ENDIF

IF AR[#15] EQ 0 ; if multi-head pitch is not


defined
#15 = 0 ;0
ENDIF

IF [#1009 EQ 0]
#39 = 2 ;radius programming
ELSE
#39 = 1 ;diameter programming
ENDIF
G90g01 X[#30*2/#39] Z[#32]

N10 G90 ;absolute macro programming

IF AR[#23] EQ 91 ; if X is incremental G91


#23=#23+#30 ;change X to absolute
;#30 is the absolute coordinate of
X when calling the program

81
HNC-21T Programming Manual

ENDIF

IF AR[#25] EQ 91 ;if Z is incremental G91


#25=#25+#32 ;change Z to absolute incremental
;#32 is the absolute coordinate of
Z when calling the program
ENDIF

IF[#30 GT #23] ;feed direction decide


#27 = -1
ELSE
#27 = 1
ENDIF
IF[#32 GT #25]
#28 = -1
ELSE
#28 = 1
ENDIF

#47=INT[[#10/#16]*[#10/#16]] ;calculate N
#48=1
#49=#47
#1=#0/2*PI/180
;K<Q*sqrt(n)
WHILE #49 GT 1
#40=#16*[SQRT[#48]] ;cutting depth in X direction
#41=#16*[SQRT[#48-1]]
IF [#40-#41] LT #21 ;if per cutting feed is less than
V
#40=#41+#21 ;define as V
#47=0
#42=#40*[TAN[#1]] ; cutting depth in Z direction
WHILE #40 LT #10
#38=[#30+[#27]*[#40]]*2/#39
G90 G00 X[#38] Z[#32+[#28]*#42] ;move alone the gear

82
HNC-21T Programming Manual

#38=[#23+#8+#10+#20+[#27]*[#40]]*2/#39
G00 X[#38] ;move to starting
point of the thread
#38=[#23+#10+#20+[#27]*[#40]]*2/#39
G32 X[#38] Z[#25+[#28]*#42] E[#4] P[#15] R[#17] F[#5]
;cutting thread
G00 X[[#30]*2/#39] Z[#32] ;return to A
#40=#40+#21
#42=#40*[TAN[#1]] ;cutting depth in
Z direction
ENDW

#40=#10
#47=0
#42=#40*[TAN[#1]] ; cutting depth in
Z direction
WHILE #47 LT #2 ;finish cutting
#38=[#30+[#27]*[#40]]*2/#39
G90 G00 X[#38] Z[#32+[#28]*#42] ;move alone the gear
#38=[#23+#8+#10+#20+[#27]*[#40]]*2/#39
G00 X[#38] ; move to starting
point of the thread
#38=[#23+#10+#20+[#27]*[#40]]*2/#39
G32 X[#38] Z[#25+[#28]*#42] E[#4] P[#15] R[#17] F[#5]
;thread cutting
G00 X[[#30]*2/#39] Z[#32] ;return to A
#47=#47+1
ENDW
M99
ENDIF
#42=#40*[TAN[#1]] ; cutting depth in
Z direction

#38=[#30+[#27]*[#40]]*2/#39
G90 G00 X[#38] Z[#32+[#28]*#42] ;move alone the
gear

83
HNC-21T Programming Manual

#38=[#23+#8+#10+#20+[#27]*[#40]]*2/#39
G00 X[#38] ;move to starting
point of the thread
#38=[#23+#10+#20+[#27]*[#40]]*2/#39
G32 X[#38] Z[#25+[#28]*#42] E[#4] P[#15] R[#17] F[#5]
;cutting thread
G00 X[[#30]*2/#39] Z[#32] ;return to A
#48=#48+1
#49=#49-1
ENDW

M99

84
Page: 46
[½ð1]

Page: 48
[½ð2]

Page: 49
[½ð3]

Page: 50
[½ð4]

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