100% found this document useful (1 vote)
26 views51 pages

Macro Call Functions in CNC Programming

Uploaded by

dhgb16021988
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
26 views51 pages

Macro Call Functions in CNC Programming

Uploaded by

dhgb16021988
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

13 PROGRAM SUPPORT FUNCTIONS

13-12 Macro Call Function: G65, G66, G66.1, G67

13-12-1 User macros


Macroprogram call, data calculation, data input to/output from a personal computer, data control,
judgment, branching, and various other instructions can be used with variables commands to
perform measurements and other operations.

Main program Macroprogram

………. ……….

Macro call instruction

M30 M99

MEP164

A macroprogram is a subprogram which is created using variables, calculation instructions,


control instructions, etc. to have special control features.
These special control features (macroprograms) can be used by calling them from the main
program as required. These calls use macro call instructions.

Detailed description
 When command G66 is entered, the designated user macro subprogram willbe called every
time after execution of the move commands within a block until G67 (cancellation) is entered.
 Command codes G66 and G67 must reside in the same programm in pairs.

Note: In order that it may function correctly, do not give a command of macro call in one block
together with any one of the following commands (described in this chapter):
 Hole machining pattern cycle
 Fixed cycle
 Subprogram control

13-64
PROGRAM SUPPORT FUNCTIONS 13
13-12-2 Macro call instructions
Two types of macro call instructions are provided: single-call instructions used to call only at the
designated block, and modal call instructions used to call at each block within a macro call mode.
Modal call instructions are further divided into type A and type B.

1. Single call

Main program Subprogram (O 01)

O01
to subprogram

G65P01L1 <argument>

M99

to main program

The designated user macro subprogram ends with M99.


Instruction G65 calls the designated user macro subprogram only once.

Format:
G65 <__> L__ <argument>

Repeat times

Program name (When omitted, calling program


will be repeated.)
Alternatively,

G65 P__ L__ <argument>

Repeat times

Program No. (When P is omitted, calling program


will be repeated.)

<Argument>
When argument is to be delivered to the user macro subprogram as a local variable, designate
the required data with the respective addresses. (Argument designation is not available for a
user macro subprogram written in MAZATROL language.)
In such a case, the argument can have a sign and a decimal point, irrespective of the address.
Arguments can be specified using method I or II, as shown below.

13-65
13 PROGRAM SUPPORT FUNCTIONS

A. Argument specification I
Format: A_B_C_  X_Y_Z_
Detailed description
- An argument can be specified using all addresses, except G, L, N, O, and P.
- Except for I, J, and K, addresses does not need be specified in an alphabetical order.
- Addresses I, J, and K must be specified in an alphabetical order.
I_J_K_ ... Correct
J_I_K_ ... Wrong
- Addresses whose specification is not required can be omitted.
- The relationship between addresses that can be specified using argument specification I, and
variables numbers in a user macro unit, is shown in the following table:

Relationship between address and variables number Call commands and usable addresses
Address specified using Variable in macro-
G65, G66 G66.1
method I program
A #1  
B #2  
C #3  
D #7  
E #8  
F #9  
G #10 × ×*
H #11  
I #4  
J #5  
K #6  
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  
: Usable ×: Unusable *: Usable in G66.1 modal

13-66
PROGRAM SUPPORT FUNCTIONS 13
B. Argument specification II
Format: A_B_C_I_J_K_I_J_K_
Detailed description
- Up to a maximum of 10 sets of arguments that each consist of addresses I, J, and K, as well as
A, B, and C, can be specified.
- If identical addresses overlap, specify them in the required order.
- Addresses whose specification is not required can be omitted.
- The relationship between addresses that can be specified using argument specification II, and
variables numbers in a user macro unit, is shown in the following table:

Argument specification Variables in macro- Argument specification Variables in macro-


II addresses programs II addresses programs
A #1 K5 #18
B #2 I6 #19
C #3 J6 #20
I1 #4 K6 #21
J1 #5 I7 #22
K1 #6 J7 #23
I2 #7 K7 #24
J2 #8 I8 #25
K2 #9 J8 #26
I3 #10 K8 #27
J3 #11 I9 #28
K3 #12 J9 #29
I4 #13 K9 #30
J4 #14 I10 #31
K4 #15 J10 #32
I5 #16 K10 #33
J5 #17

Note: In the table above, the numerals 1 through 10 have been added to addresses I, J, and
J just to denote the order of arrangement of the designated sets of arguments: these
numerals are not included in actual instructions.

C. Combined use of argument specification I and II


When both method I and method II are used to specify arguments, only the latter of two
arguments which have an address corresponding to the same variable will become valid.
Example: Call command G65 A1.1 B–2.2 D3.3 I4.4 I7.7
Variables
#1: 1.1
#2: –2.2
#3:
#4: 4.4
#5:
#6:
#7: 7.7
If two arguments (D3.3 and I7.7) are designated for the variable of #7, only the latter
argument (I7.7) will be used.

13-67
13 PROGRAM SUPPORT FUNCTIONS

2. Modal call, type A (Move command call)

Subprogram
Main program
O01
to subprogram

G66P01L1 <argument>
M99

to main program

G67
to subprogram

For a block that has a move command code between G66 and G67, the designated user macro
subprogram is executed after that move command has been executed. The subprogram is
executed an 1 number of times for the first call, or once for subsequent calls.
For modal call of type A, the methods of specifying <argument> are the same as used for single
call.

Format:
G66 <__> L__ <argument>

Repeat times

Program name

Alternatively,

G66 P__ L__ <argument>

Repeat times

Program No.

Detailed description
- When command G66 is entered, the designated user macro subprogram will be called every
time after execution of the move commands within a block until command G67 (cancellation) is
entered.
- Command codes G66 and G67 must reside in the same program in pairs.
Entry of a G67 command without a G66 command results in an alarm 857 INCORRECT USER
MACRO G67 PROG.

13-68
PROGRAM SUPPORT FUNCTIONS 13
Example: Drilling cycle

Main program

N1 G90 G54 G0 X0Y0Z0


Subprogram
N2 G91 G00 X-50.Y-50.Z-200.
N3 G66 P9010 R-10.Z-30.F100 O9010
N4 X-50. Y-50. To subprogram after axis motion N10 G00 Z#18M03
N5 X-50. To subprogram after axis motion N20 G09 G01 Z#26F#9
N6 G67 N30 G00 Z-[#18+#26]
 Return M99

–150. –100. –50.


W
X
N2 N1
N3
N10 Argument R
N4 –50
N5
N20 N30
–100 Argument Z

Y
Argument F
Z-axis movement
To subprogram

Note 1: The designated subprogram is executed after the axis commands in the main program
have been executed.
Note 2: No subprograms are executed for the G67 block and its successors.

3. Modal call, type B (Block-to-block call)


The designated user macro subprogram is called unconditionally for each of the command
blocks present between G66.1 and G67. Execution of the macro program is repeated as
specified with L for the first call, and only once for each of subsequent calls.

Format:
G66.1 <__> L__ <argument>

Repeat times

Program name

Alternatively,

G66.1 P__ L__ <argument>

Repeat times

Program No.

Detailed description
- During the G66.1 mode, only the codes O, N, and G in each of the read command blocks are
executed. No other codes in those blocks are executed; codes other than O, N, and G are
handled as arguments. However, only the last G-code and the N-codes following a code other
than O or N become arguments.

13-69
13 PROGRAM SUPPORT FUNCTIONS

- All significant blocks in the G66.1 mode are regarded as preceded by the command G65P_.
For example, the block of
N100G01G90X100. Y200. F400R1000
in the G66.1P1000 mode is handled as equivalent to
N100G65P1000G01G90X100. Y200. F400R1000.
Note: Call is executed even for the G66.1 command block of the G66.1 mode, with the
relationship between the addresses of the arguments and the variables numbers
being the same as for G65 (single call).
- The data range of the G, L, P, and N commands that you can set as new variables using the
G66.1 mode is the same as the data range of usual NC commands.
- Sequence number N, modal G-codes, and O are all updated as modal information.

4. G-code macro call


The user macro subprograms of the required program number can be called just by setting
G-codes.

Format:
G×× <argument>

G-code which calls macro-subprogram

Detailed description
- The instruction shown above performs the same function as those of the instructions listed
below. Which of these listed instructions will apply is determined by the parameter data to be
set for each G-code.
M98P
G65P <argument>
G66P <argument>
G66.1P <argument>
- Use parameters to set the relationship between G ×× (macro call G-code) and P (program
number of the macro to be called).
- Of G00 through G255, up to a maximum of 10 command codes can be used with this
instruction unless the uses of these codes are clearly predefined by EIA/ISO Standards, such
as G00, G01, G02, etc.
- The command code cannot be included in user macro subprograms that have been called
using G-codes.

13-70
PROGRAM SUPPORT FUNCTIONS 13
5. Auxiliary command macro call (M-, S-, T-, or B-code macro call)
The user macro subprograms of the required program number can be called just by setting M-,
S-, T-, or B-codes.

Format:
Mm (or Ss, Tt and Bb)

M (or S, T and B) code which calls macro-subprogram

Detailed description (The following description also applies to S-, T-, and B-codes.)
- The instruction shown above performs the same function as those of the instructions listed
below. Which of these listed instructions will apply is determined by the parameter data to be
set for each M-code.
M98P
G65PMm
G66PMm
G66.1PMm
- Use parameter to set the relationship between Mm (macro call M-code) and P (program
number of the macro to be called).
Up to a maximum of 10 M-codes, ranging from M00 to M95, can be registered. Do not register
the M-codes that are fundamentally required for your machine, nor M0, M1, M2, M30, and M96
through M99.
- If registered auxiliary command codes are set in the user macro subprograms that have been
called using M-codes, macro calls will not occur since those special auxiliary command codes
will be handled as usual ones (M-, S-, T-, or B-codes).

6. Differences in usage between commands M98, G65, etc.


- Arguments can be designated for G65, but cannot be designated for M98.
- Sequence numbers can be designated for M98, but cannot be designated for G65, G66, or
G66.1.
- Command M98 executes a subprogram after M98 block commands other than M, P, H, and L
have been executed, whereas G65 just branches the program into a subprogram without doing
anything.
- Single-block stop will occur if the block of command M98 has addresses other than O, N, P, H,
and L. For G65, however, single-block stop will not occur.
- The level of local variables is fixed for M98, but for G65 does change according to the depth of
nesting. (For example, #1s, if present before and after M98, always mean the same, but if
present before and after G65, they have different meanings.)
- Command M98 can have up to a maximum of 15 levels of call multiplexity when combined with
G65, G66, or G66.1, whereas the maximum available number of levels for command G65 is
four when it is combined with G66 or G66.1.

13-71
13 PROGRAM SUPPORT FUNCTIONS

7. Multiplexity of macro call commands


The maximum available number of levels of macro subprogram call is four, whether it is single or
modal. Arguments in macro call instructions become valid only within the level of the called
macro. Since the multiplexity of macro call is of up to a maximum of four levels, arguments can
be included in a program as local variables each time a macro call is made.
Note 1: When a G65, G66, or G66.1 macro call or an auxiliary command macro call is made,
nesting will be regarded as single-level and thus the level of local variables will also
increase by 1.
Note 2: For modal call of type A, the designated user macro subprogram is called each time a
move command is executed. If, however, multiple G66s are present, the next user
macro subprogram will be called even for the move commands in the macro each time
axis movement is done.
Note 3: User macro subprograms are cancelled in a reverse order to that in which they have
been arranged.
Example:

Main program User macroprogram operation


Macro p1
G66Pp1
(p1 call-out)
Zz1 x1 w1 x2 M99
After z1 execution

G66Pp2
Macro p1

(p2 call-out)
Zz2 x1 w1 x2 M99
After z2 execution

G67
(p2 cancel)
Macro p2 Macro p2 Macro p2

Macro p1

(p1 call-out)
Zz3 x1 w1 x2 M99
After z3 execution

G67
(p1 cancel)
Zz4
Zz5

13-72
PROGRAM SUPPORT FUNCTIONS 13
8. User macro call based on interruption
Outline
Prior creation of special user macros for interrupt processing allows the user macros to be
executed during automatic operation when a user macro interrupt signal is input. After the user
macro has been executed, the program can also be returned to the interrupted program block
and then started from this block.
Detailed description
 Format for selecting the user macro branching destination

M96<_>L_ (or M96P_L_) (Branching mode on)
 When user macroprogram interruption signal is input
 during this space, the branch into the specified user
M97 (Branching mode off) macroprogram will be applied.

 It depends upon the specifications of the machine whether user macro interrupt signal is
available or not.
 If a user macro interrupt signal is input during execution of an axis movement block, the user
macroprogram will be executed immediately by interrupting the movement without holding
(storing) the remaining motion amount.
 User macro interrupts can be processed even when the number of levels of macro call
multiplexity during the occurrence of an interrupt is four. The local variables’ level of the user
macros used for interruption is the same as the level of the user macros existing during the
occurrence of an interrupt.

Interruption branch
Interruption return

O2000 O2100 O5100



M96P5100
G1X_
Interruption G1Y_

G65P2100 Interruption

M97

M99 M99 M99

(Level 3) (Level 4)

Local variable Local variable

13-73
13 PROGRAM SUPPORT FUNCTIONS

13-12-3 Variables
Of all types of variables available for the NC unit, only local variables, common variables, and
part of system variables are retained even after power-off.

1. Multiplexing of variables
Under user macro specifications, variables can have their identifiers (identification numbers)
either transformed into variables, which is referred to as multiplexing, or replaced with
<expression>.
For <expression>, only one arithmetic expression (for either multiplication, division, addition, or
subtraction) can be used.
Example 1: Multiplexing variables
#1=10 #10=20 #20=30 From #1 = 10, #[#[#1]] = #[#10] will result.
#5=#[#[#1]] From #10 = 20, #[#10] = #20 will result. Therefore #5 = #20, i.e. #5
= 30 will result.
#1=10 #10=20 #20=30 From #1 = 10, #[#[#1]] = #[#10] will result.
#5=1000 From #10 = 20, #[#10] = #20 will result. Therefore #20 = #5, i.e.
#[#[#1]]=#5 #20 = 1000 will result.
Example 2: Replacing variables identifiers with <expression>
#10=5
#[#10+1]=1000 #6 = 1000 will result.
#[#10–1]=–1000 #4 = –1000 will result.
#[#103]=100 #15 = 100 will result.
#[#10/2]=100 #2 = –100 will result.

2. Undefined variables
Under user macro specifications, variables remaining unused after power-on or local variables
that are not argument-specified by G65, G66, or G66.1 can be used as <empty>. Also, variables
can be forcibly made into <empty>.
Variable #0 is always used as <empty> one, and this variable cannot be defined on the left side
of the expression.

A. Arithmetic expression
#1=#0................. #1 = <empty>
#2=#0+1 ............ #2 = 1
#3=1+#0 ............ #3 = 1
#4=#010 .......... #4 = 0
#5=#0+#0 .......... #5 = 0
Note: Be careful that <empty> is handled the same as 0 during processing of expressions.
<empty> + <empty> = 0
<empty> + <constant> = constant
<constant> + <empty> = constant

B. Applying variables
Application of an undefined variable alone causes even the address to be ignored.
If #1 = <empty>
G0X#1Y1000 is equivalent to G0Y1000, and
G0X[#1+10]Y1000 is equivalent to G0X10Y1000.

13-74
PROGRAM SUPPORT FUNCTIONS 13
C. Conditional expression
Only for EQ and NE, does <empty> differ from 0 in meaning.

If #101 = <empty> If #101 = 0


#101EQ#0 <empty> = <empty> holds. #101EQ#0 0 = <empty> does not hold.
#101NE0 <empty>  0 holds. #101NE0 0  0 does not hold.
#101GE#0 <empty>  <empty> holds. #101GE#0 0  <empty> holds.
#101GT0 <empty> > 0 does not hold. #101GT0 0 > 0 does not hold.

Hold-conditions and not-hold-conditions list


(For conditional expressions including undefined variables)

Right side EQ NE GT LT GE LE
Left side Empty Constant Empty Constant Empty Constant Empty Constant Empty Constant Empty Constant
Empty H H H H H
Constant H H H

H: Holds (The conditional expression holds.)


Blank: The conditional expression does not hold.

13-75
13 PROGRAM SUPPORT FUNCTIONS

13-12-4 Types of variables

1. Common variables (#100 to #199, and #500 to #999)


Common variables refer to the variables to be used in common at any position. The identifiers of
common variables which can be used are from #100 to #199, or from #500 to #999.

2. Local variables (#1 to #33)


Local variables refer to variables that can be defined as <argument> when calling a macro
subprogram, or those which can be used locally within the main program or a subprogram. There
is no relationship between macros. Thus, these variables can be overlapped on each other, but
up to a maximum of four levels of overlapping.

G65Pp1L1 <argument>

where p1 : Program number


1 : Number of repeat times
<Argument> must be: Aa1 Bb1 Cc1  Zz1.
The following represents the relationship between the address specified by <argument> and the
local variables number used in the user macro unit:

Call commands Call commands


Argument Local Argument Local
G65 address variable G65 address variable
G66.1 G66.1
G66 G66
  A #1   R #18
  B #2   S #19
  C #3   T #20
  D #7   U #21
  E #8   V #22
  F #9   W #23
× ×* G #10   X #24
  H #11   Y #25
  I #4   Z #26
  J #5 – #27
  K #6 – #28
× ×* L #12 – #29
  M #13 – #30
× ×* N #14 – #31
× × O #15 – #32
× ×* P #16 – #33
  Q #17

Argument addresses marked as × in the table above cannot be used. Only during the G66.1
mode, however, can argument addresses marked with an asterisk (*) in this table be additionally
used. Also, the dash sign (–) indicates that no address is crosskeyed to the local variables
number.

13-76
PROGRAM SUPPORT FUNCTIONS 13
1. Local variables for a subprogram can be defined by specifying <argument> when calling a
macro.

Main program Subprogram (O9900)

To subprogram #5=#4010
G65P9900A60.S100.F800 G91G01 X[#19COS[#1]]
Y[#19SIN[#1]]F#9
M02 M99

Control of move and


others after referring
to local variables.
Local variable setting by argument A (#1)=60.000

F (#9)=800
Local variable
data table S (#19)=100.000

2. Within a subprogram, local variables can be freely used.

Main program Subprogram (O1)

#30=FUP[#2/#5/2]
To subprogram
#5=#2/#30/2
M98H100L#30
G65P1A100.B50.J10.F500
X#1
M99
N100G1X#1F#9
Y#5
X–#1
Example of face milling X#5
M99

Local variables can


be changed in the
Local variable set by argument subprogram
B

A (#1) 100.000
B (#2) 50.000
J
F (#9) 500
Local variable
J (#5) 10.000  8.333
data table
A (#30)  3.

In the sample program for face-milling that is shown above, although the argument J has initially
been programmed as a machining pitch of 10 mm, it has been changed into 8.333 mm to ensure
equal-pitched machining.
Also, local variable #30 contains the calculated data about the number of times of reciprocal
machining.

13-77
13 PROGRAM SUPPORT FUNCTIONS

3. Local variables can be used for each of the four levels of macro call separately. For the
main program (macro level 0), separate local variables are also provided. The local
variables of level 0, however, cannot be designated with arguments.

Main (Level 0) O1 (Macro level 1) O10 (Macro level 2) O100 (Macro level 3)

#1=0.1#2=0.2#3=0.3

P65P1A1.B2.C3. G65P10A10.B20.C30. G65P100A100.B200.

M02 M99 M99 M99

Local variable (0) Local variable (1) Local variable (2) Local variable (3)
#1 0.100 A(#1) 1.000 A(#1) 10.000 A(#1) 100.000
#2 0.200 B(#2) 2.000 B(#2) 20.000 B(#2) 200.000
#3 0.300 C(#3) 3.000 C(#3) 30.000 C(#3)
D(#7) D(#7)

Z(#26) Z(#26) Z(#26)

#33 #33 #33 #33

How the local variables are currently being used is displayed on the screen.

 For further details, refer to the corresponding section in PART 3 of the


Operating Manual.

13-78
PROGRAM SUPPORT FUNCTIONS 13
3. Macro interface input system variables (#1000 to #1035)
You can check the status of an interface input signal by reading the value of the appropriate
variables number (#1000 to #1035).
The read value of the variables number is either 1 (contact closed) or 0 (contact open). You can
also check the status of all input signals of the variables from #1000 to #1031 by reading the
value of variables number 1032. Variables from #1000 to #1035 can only be read; they cannot
be placed on the left side of an arithmetic expression.

System variable Points Interface input signal System variable Points Interface input signal
#1000 1 Register R72, bit 0 #1016 1 Register R73, bit 0
#1001 1 Register R72, bit 1 #1017 1 Register R73, bit 1
#1002 1 Register R72, bit 2 #1018 1 Register R73, bit 2
#1003 1 Register R72, bit 3 #1019 1 Register R73, bit 3
#1004 1 Register R72, bit 4 #1020 1 Register R73, bit 4
#1005 1 Register R72, bit 5 #1021 1 Register R73, bit 5
#1006 1 Register R72, bit 6 #1022 1 Register R73, bit 6
#1007 1 Register R72, bit 7 #1023 1 Register R73, bit 7
#1008 1 Register R72, bit 8 #1024 1 Register R73, bit 8
#1009 1 Register R72, bit 9 #1025 1 Register R73, bit 9
#1010 1 Register R72, bit 10 #1026 1 Register R73, bit 10
#1011 1 Register R72, bit 11 #1027 1 Register R73, bit 11
#1012 1 Register R72, bit 12 #1028 1 Register R73, bit 12
#1013 1 Register R72, bit 13 #1029 1 Register R73, bit 13
#1014 1 Register R72, bit 14 #1030 1 Register R73, bit 14
#1015 1 Register R72, bit 15 #1031 1 Register R73, bit 15

System variable Points Interface input signal


#1032 32 Register R72 and R73
#1033 32 Register R74 and R75
#1034 32 Register R76 and R77
#1035 32 Register R78 and R79

Note: The following interface input signals are used exclusively in the NC system operation
(cannot be used for other purposes).

Interface input signal Description


Register R72, bit 0 Touch sensor mounted in the spindle
Register R72, bit 4 X- and Y-axis machine lock ON
Register R72, bit 5 M-, S-, T-code lock ON
Register R72, bit 6 Z-axis machine lock ON

13-79
13 PROGRAM SUPPORT FUNCTIONS

4. Macro interface output system variables (#1100 to #1135)


You can send an interface output signal by assigning a value to the appropriate variables
number (#1100 to #1135).
All output signals can take either 0 or 1.
You can also send all output signals of the variables from #1100 to #1131 at the same time by
assigning a value to variables number 1132. In addition to the data writing for offsetting the
#1100 to #1135 output signals, the reading of the output signal status can be done.

System variable Points Interface output signal System variable Points Interface output signal
#1100 1 Register R172, bit 0 #1116 1 Register R173, bit 0
#1101 1 Register R172, bit 1 #1117 1 Register R173, bit 1
#1102 1 Register R172, bit 2 #1118 1 Register R173, bit 2
#1103 1 Register R172, bit 3 #1119 1 Register R173, bit 3
#1104 1 Register R172, bit 4 #1120 1 Register R173, bit 4
#1105 1 Register R172, bit 5 #1121 1 Register R173, bit 5
#1106 1 Register R172, bit 6 #1122 1 Register R173, bit 6
#1107 1 Register R172, bit 7 #1123 1 Register R173, bit 7
#1108 1 Register R172, bit 8 #1124 1 Register R173, bit 8
#1109 1 Register R172, bit 9 #1125 1 Register R173, bit 9
#1110 1 Register R172, bit 10 #1126 1 Register R173, bit 10
#1111 1 Register R172, bit 11 #1127 1 Register R173, bit 11
#1112 1 Register R172, bit 12 #1128 1 Register R173, bit 12
#1113 1 Register R172, bit 13 #1129 1 Register R173, bit 13
#1114 1 Register R172, bit 14 #1130 1 Register R173, bit 14
#1115 1 Register R172, bit 15 #1131 1 Register R173, bit 15

System variable Points Interface output signal


#1132 32 Register R172 and R173
#1133 32 Register R174 and R175
#1134 32 Register R176 and R177
#1135 32 Register R178 and R179

Note 1: Data of the system variables from #1100 to #1135 is saved according to the logical
level (1 or 0) of the signal that has been lastly sent. The saved data is cleared by
power-on/off automatically.
Note 2: The following applies if a data other than 1 or 0 is assigned to the variables from #1100
to #1131:
<empty> is regarded as equal to 0.
Data other than 0 and <empty> is regarded as equal to 1.
Data less than 0.00000001, however, is regarded as undefined.

13-80
PROGRAM SUPPORT FUNCTIONS 13

(R72, R73) #1032 #1132 (R172, R173)


Input signal Output signal
#1000 #1100

#1001 #1101

#1002 #1102
Read Read
#1003 #1103
only and write

#1028 #1128

#1029 #1129
Macro- #1130
#1030
instruction
#1031 #1131

32 bit (R74, R75) (R174, R175) 32 bit


#1033 #1133
(R76, R77) (R176, R177)
#1034 #1134
(R78, R79) (R178, R179)
#1035 #1135

5. Tool offset
 : Available × : Unavailable
Range of variable Nos. Type A Type B Type C
#100001 - #10001 -  Length Geom.  Geom. offset
#100000+n #10000+n #2001 - #2000+n  offset Z
#110001 - #11001 -  Length Wear  Wear comp.
#110000+n #11000+n #2201 - #2200+n × comp. Z
#160001 - #16001 -
#160000+n #16000+n  Dia. Geom.  Geom. offset
#2401 - #2400+n × offset ACT-
*(#120001 - *(#12001 -
#120000+n) #12000+n)
#170001 - #17001 -
#170000+n #17000+n  Dia. Wear  Wear comp.
#2601 - #2600+n × comp. ACT-
*(#130001 - *(#13001 -
#130000+n) #13000+n)
#120001 - #12001 -  Geom. offset
× ×
#120000+n #12000+n X
#130001 - #13001 -  Wear comp.
× ×
#130000+n #13000+n X
#140001 - #14001 -  Geom. offset
× ×
#140000+n #14000+n Y
#150001 - #15001 -  Wear comp.
× ×
#150000+n #15000+n Y

n: Number of tools available (according to the specification of the machine)


Variable numbers Maximum of n
*: The numbers of variables used for tool offset depend upon a
#100001 - #174000 4000 parameter:
#10001 - #17999 999 F96 bit 0 = 0: #16001 - #16000+n, and #17001 - #17000+n
#2001 - #2800 200 = 1: #12001 - #12000+n, and #13001 - #13000+n

Note : Set bit 0 of parameter F96 to “0” to use the TOOL OFFSET type C data.

13-81
13 PROGRAM SUPPORT FUNCTIONS

Using variables numbers, you can read tool data or assign data.
Usable variables numbers are of the order of either #10000 or #2000. For the order of #2000,
however, only up to 200 sets of tool offsets can be used.
The last three digits of a variables number denote a tool offset number.
As with other variables, tool offset data is to contain the decimal point. The decimal point must
therefore be included if you want to set data that has decimal digits.

Program example Common variables Tool offset data


After
execution
#101=1000 #101=1000.0
#10001=#101
#102=#10001 H1=1000.000
#102=1000.0

Example : Tool offset data measuring

G28Z0T01 Return to zero point


M06 Tool change (for T01) #1
#1=#5003 Starting point memory
G00Z–500. Rapid traverse to safe position G00
H1
G31Z–100.F100 Measurement with skip feed
#10001=#5063–#1 Measuring distance calculation G31
#5063
 and tool offset data setting

Sensor

Note : The example shown above does not allow for any skip sensor signal delay. Also,
#5003 denotes the position of the starting point of the Z-axis, and #5063 denotes the
skip coordinate of the Z-axis, that is, the position at which a skip signal was input during
execution of G31.

6. Workpiece coordinate system offset


Using variables numbers from 5201 to 5336, you can read workpiece coordinate system offset
data or assign data.
Note: The number of controllable axes depends on the machine specifications.

Axis No. 16th


1st axis 2nd axis 3rd axis Remarks
Data name axis
An external data input/output optional
SHIFT #5201 #5202 #5203 #5216
spec. is required.
G54 #5221 #5222 #5223 #5236
G55 #5241 #5242 #5243 #5256
G56 #5261 #5262 #5263 #5276 A workpiece coordinate system offset
G57 #5281 #5282 #5283 #5296 feature is required.
G58 #5301 #5302 #5303 #5316
G59 #5321 #5322 #5323 #5336

13-82
PROGRAM SUPPORT FUNCTIONS 13

(Example 1) N1
M
N1 G28X0Y0Z0 –90.
N2 #5221=–20.#5222=–20.
N3
N3 G90G00G54X0Y0 –10.
W1 N11 –20.
W1
N10 #5221=–90.#5222=–10. Workpiece coordinate
system of G54 specified
N11 G90G00G54X0Y0
by N10
Workpiece coordinate system of
G54 specified by N2
M02

(Example 2)
Fundamental machine coordinate system
Coordinate shift
M
Coordinate
system G55
before G54
change
W2 (G55)
N100 #5221=#5221+#5201 W1 (G54)
#5222=#5222+#5202
#5241=#5241+#5201
#5242=#5242+#5202
#5201=0 #5202=0 Fundamental machine coordinate system

Coordinate M
system after G55
G54
change

W2 (G55)
W1 (G54)

MEP166

The example 2 shown above applies only when coordinate shift data is to be added to the offset
data of a workpiece coordinate system (G54 or G55) without changing the position of the
workpiece coordinate system.
[Additional workpiece coordinate system offset]
Variables numbered 70001 to 75996 can be used to read or assign additional workpiece
coordinate system offsetting dimensions. The variable number for the k-th axis origin of the “Pn”
coordinate system can be calculated as follows:
70000 + (n – 1) × 20 + k
Note: The total number of controllable axes depends on the machine specifications.

Axis No. 1st 2nd 3rd 4th 16th


Remarks
Data name axis axis axis axis axis

G54.1P1 #70001 #70002 #70003 #70004 #70016


Only available with
G54.1P2 #70021 #70022 #70023 #70024 #70036 the optional function
for additional
G54.1P299 #75961 #75962 #75963 #75964 #75976 coordinate system
offset.
G54.1P300 #75981 #75982 #75983 #75984 #75996

13-83
13 PROGRAM SUPPORT FUNCTIONS

Alternatively, variables numbered 7001 to 7956 can be used to read or assign additional work-
piece coordinate system offsetting dimensions. The variable number for the k-th axis origin of the
“Pn” coordinate system can be calculated as follows:
7000 + (n – 1) × 20 + k
Note: The total number of controllable axes depends on the machine specifications.

Axis No. 1st 2nd 3rd 4th 16th


Remarks
Data name axis axis axis axis axis
G54.1P1 #7001 #7002 #7003 #7004 #7016
G54.1P2 #7021 #7022 #7023 #7024 #7036 Only available with
the optional function
G54.1P3 #7041 #7042 #7043 #7044 #7056
for additional coordi-
nate system offset.
G54.1P48 #7941 #7942 #7943 #7944 #7956

7. NC alarm (#3000)
The NC unit can be forced into an alarm status using variables number 3000.

#3000 = 70 (CALL#PROGRAMMER#TEL#530)

Alarm No. Alarm message

The setting range for the alarm No. is from 1 to 6999.


The maximum available length of the alarm message is 31 characters.
Note: The type of alarm message displayed on the screen depends on the designated alarm
number, as indicated in the following table.

Designated alarm No. Displayed alarm No. Displayed alarm message


1 to 20 [Designated alarm No.] + 979 Message preset for the displayed alarm No. *1
21 to 6999 [Designated alarm No.] + 3000 Designated alarm message as it is *2

*1 Refers to alarm Nos. 980 to 999 whose messages are preset as indicated in Alarm List.
*2 Display of a message as it is set in the macro statement.

Program ex. 1 (Command for display


of “980 MACRO USER ALARM 1” on
condition of #1=0)


IF[#1NE0]GOTO100 980 MACRO USER ALARM 1
Operation stop by
#3000=1
NC alarm
N100

Program ex. 2 (Command for display of


“3021#ORIGINAL#ALARM#1” on condition
of #2=0)


IF[#2NE0]GOTO200 Operation stop
3021#ORIGINAL#ALARM#1
#3000=21(#ORIGINAL#ALARM#1) by NC alarm
N200

13-84
PROGRAM SUPPORT FUNCTIONS 13
8. Integrated time
Using variables #3001 and #3002, you can read the integrated time existing during automatic
operation or assign data.

Type Variable No. Unit Data at power-on Initialization Counting


Integrated time 1 3001 Same as at Data is assigned Always during power-on
ms
Integrated time 2 3002 power-off in variables. During auto-starting

11
The integrated time is cleared to 0 after having reached about 3.6 × 10 ms.

O9010

To subprogram #3001=0
WHILE[#3001LE#20]DO1
G65P9010T (Allowable time [ms])

END1
M99

Local variable Execution of blocks from DO1 to END1


is repeated until the allowable time has
T#20______ elapsed, and then the control jumps to
Into local variable #20 the end block of M99.

Using variables #3040 to #3044, moreover, it is possible to read various types of cumulative time
data displayed in the ACCUMULATED TIME window. TOTAL TIME denotes the cumulative time
for which the power has been turned on.

Variable Data at
Item Unit Initialization Counting
No. power-on
POWER ON 3040 Power being turned on
AUTO OPE. 3041 Automatic operation (from start to end)
Same as at Automatic operation (with the start button lamp
AUTO CUT. 3042 ms —
power-off lighting)
TOTAL CUT. 3043 Execution of G1, G2 or G3 commands
TOTAL TIME 3044 Power being turned on

Note 1: Variable #3001 can be used to replace POWER ON item in the ACCUMULATED TIME
window with the desired value, on condition that bit 7 of parameter F151 is set to 0.
According to the parameter setting, variable #3001 is processed as shown below in
relation to POWER ON item.
Effect of writing data into #3001 on
F151 bit 7 Value of #3001 at power-on
POWER ON item
0 Replacement by the written value Same as at power-off
1 No effect Reset to zero (0)

Note 2: Variable #3002 can be used to replace the AUTO CUT. item in the ACCUMULATED
TIME window with the desired value.
Note 3: #3040, #3041, #3042, #3043 and #3044 are read-only variables.

 See the section on the DIAGNOSIS (USER) - ALARM display in PART 3 of


the Operating Manual for more information on the respective data items.

13-85
13 PROGRAM SUPPORT FUNCTIONS

9. Validation/invalidation of single-block stop or auxiliary-function finish signal wait (#3003)


Assigning one of the values listed in the table below to variables number 3003 allows single-
block stop to be made invalid at subsequent blocks or the program to be advanced to the next
block without ever having to wait for the arrival of an auxiliary-function code (M, S, T, or B)
execution finish signal (FIN).

#3003 Single block stop Auxiliary-function completion signal


0 Effective Wait
1 Ineffective Wait
2 Effective No wait
3 Ineffective No wait

Note: Variable #3003 is cleared to 0 by resetting.

10. Validation/invalidation of feed hold, feed rate override, or G09 (#3004)


Feed hold, feed rate override, or G09 can be made valid or invalid for subsequent blocks by
assigning one of the values listed in the table below to variables number 3004.

#3004 Bit 0 Bit 1 Bit 2


Contents (Value) Feed hold Feed rate override G09 check
0 Effective Effective Effective
1 Ineffective Effective Effective
2 Effective Ineffective Effective
3 Ineffective Ineffective Effective
4 Effective Effective Ineffective
5 Ineffective Effective Ineffective
6 Effective Ineffective Ineffective
7 Ineffective Ineffective Ineffective

Note 1: Variable #3004 is cleared to 0 by resetting.


Note 2: Each of the listed bits makes the function valid if 0, or invalid if 1.

11. Program stop (#3006)


Use of variables number 3006 allows the program to be stopped after execution of the im-
mediately preceding block.

Format:
#3006 = 1 (CHECK OPERAT)

Character string to be displayed

Additional setting of a character string (in 31 characters at maximum) in parentheses allows the
required stop message to be displayed on the monitor.
It depends upon the setting of bit 3 of parameter F37 when the stop message is cleared from the
screen.
 F37 bit 3 = 0: The message does not disappear till completion of automatic operation.
 F37 bit 3 = 1: The message disappears when the execution of the next block is started.
Note 1: Always set “1” on the right-hand side of equation; otherwise (e.g. #3006 = 2) the oper-
ation will not be stopped, nor the message displayed.

13-86
PROGRAM SUPPORT FUNCTIONS 13
Note 2: A block of #3006 does not cause the operation to be stopped, nor the message to be
displayed when the program is executed on the TOOL PATH CHECK display. As for
running on the VIRTUAL MACHINING display, operation is stopped at a block of
#3006, but the message does not appear.
Note 3: Only use one-byte characters to specify the message in parentheses; otherwise the
message may not be displayed exactly as specified.

12. Mirror image (#3007)


The mirror image status of each axis at one particular time can be checked by reading variables
number 3007.
Variable #3007 has its each bit crosskeyed to an axis, and these bits indicate that:
If 0, the mirror image is invalid.
If 1, the mirror image is valid.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Axis no. 6 5 4 3 2 1

13. G-command modal status


The G-command modal status in a pre-read block can be checked using variables numbers from
4001 to 4027. For variables numbers from #4201 to #4227, the modal status of the block being
executed can be checked in a similar manner to that described above.
Variable Nos.
Block Block Function
pre-read executed
#4001 #4201 Interpolation mode G0-G3 : 0-3, G2.1 : 2.1, G3.1 : 3.1
#4002 #4202 Plane selection G17 : 17, G18 : 18, G19 : 19
#4003 #4203 Absolute/Incremental programming G90/91 : 90/91
#4004 #4204 Pre-move stroke check G22 : 22, G23 : 23
#4005 #4205 Feed specification G94 : 94, G95 : 95
#4006 #4206 Inch/metric selection G20/21 : 20/21
#4007 #4207 Tool radius compensation G40 : 40, G41 : 41, G42 : 42
#4008 #4208 Tool length offset G43/44 : 43/44, G49 : 49
#4009 #4209 Fixed cycle G80 : 80, G273/274 : 273/274, G276 : 276, G81-G89 : 81-89
#4010 #4210 Returning level G98 : 98, G99 : 99
#4011 #4211 Scaling OFF/ON G50/51 : 50/51
#4012 #4212 Workpiece coordinate system G54-G59 : 54-59, G54.1 : 54.1
#4013 #4213 Mode of machining (feed) G61-64 : 61-64, G61.1 : 61.1, G61.4 : 61.4
#4014 #4214 Macro modal call G66 : 66, G66.1 : 66.1, G67 : 67
#4015 #4215 Shaping function G40.1 : 40.1, G41.1 : 41.1, G42.1 : 42.1
#4016 #4216 Programmed coordinate conversion ON/OFF G68/69 : 68/69
#4017 #4217
#4018 #4218
Mirror image by G-codes (5-surf. machining)
#4019 #4219
G17.1-17.9 : 17.1-17.9, G50.1 : 50.1, G51.1 : 51.1
#4020 #4220
#4021 #4221
#4022 #4222
#4023 #4223
#4024 #4224
#4025 #4225
#4026 #4226 Polar coordinate interpolation ON/OFF G12.1/13.1 : 12.1/13.1
#4027 #4227 Dynamic offsetting II G54.2 : 54.2

13-87
13 PROGRAM SUPPORT FUNCTIONS

14. Other modal information


Modal information about factors other than the G-command modal status in the previous block
can be checked using variables numbers from 4101 to 4132. For variables numbers from #4301
to #4330, the modal information of the block being executed can be checked in a similar manner
to that described above.
Moreover, use #4501 to #4530 in an interruption macroprogram to read various modal infor-
mation items at the moment of macro interruption.

Variable Nos. Variable Nos.


Previous Block Macro Modal information Previous Block Macro Modal information
block executed interrupt. block executed interrupt.
#4101 #4301 #4501 #4115 #4315 #4515 Program No.O
#4102 #4302 #4502 No. 2 miscell. function #4116 #4316 #4516
#4103 #4303 #4503 #4117 #4317 #4517
#4104 #4304 #4504 #4118 #4318 #4518
#4105 #4305 #4505 #4119 #4319 #4519 Spindle functionS
#4106 #4306 #4506 #4120 #4320 #4520 Tool functionT
#4107 #4307 #4507 Radius comp. No.D Addt. workp. coord. system
#4108 #4308 #4508 #4130 #4330 #4530 G54-G59: 0,
G54.1P1-P300: 1-300
#4109 #4309 #4509 Rate of feedF
#4110 #4310 #4510 Surface type
#4111 #4311 #4511 Length offset No.H #4131 Upper: 0, 0°/180°: 1,
#4112 #4312 #4512 90°/270°: 2

#4113 #4313 #4513 Miscel. functionM Machining surface


#4132 Upper: 5, 0°: 6, 90°: 7,
#4114 #4314 #4514 Sequence No.N 180°: 8, 270°: 9

Note 1: Use the variable #4315 from the second block of the program. If it is used in the first
block, the reading of the program number is not successful.
Note 2: The variables #4115 and #4315 are only effective for programs whose ID-number or
name consists of numerals only. During execution of a program whose name contains
even one single character other than numerals, the reading in question remains zero
(0).
Note 3: Do not use #4501 to #4530 elsewhere than in an interruption macroprogram; otherwise
an alarm will be caused (846 DESIGNATED NUMBER NOT FOUND).
Example : Given below is an example to show the difference between variables #4113 and
#4313 (for checking modal information about M-codes) in the information that is
obtained in the parallel flow of actual execution and internal pre-reading (analysis) for
automatic operation.
Previous block (#4113) Block being executed (#4313)
: :
N001 M3 N001 M3
N002  In execution N002  In execution
N003 N003
: :
N006 M200 N006 M200
N007 #100=#4113  In analysis N007 #100=#4313  In analysis
N008 N008

Reading the information about M-codes Reading the information about M-codes
(M200) at the block previous to the cur- (M3) at the block being executed.
rently analyzed one.

13-88
PROGRAM SUPPORT FUNCTIONS 13
15. Position information
Using variables numbers from #5001 to #5116, you can check the ending-point coordinates of
the previous block, machine coordinates, workpiece coordinates, skip coordinates, tool position
offset coordinates, and servo deviations.

Position information End point Tool


Servo
coordinates Machine Workpiece Skip position
deviation
of previous coordinate coordinate coordinate offset
Axis No. amount
block coordinates
1 #5001 #5021 #5041 #5061 #5081 #5101
2 #5002 #5022 #5042 #5062 #5082 #5102
3 #5003 #5023 #5043 #5063 #5083 #5103

16 #5016 #5036 #5056 #5076 #5096 #5116


Remarks
Possible Impossible Impossible Possible Impossible Possible
(Reading during move)

Note: The number of controllable axes depends on the machine specifications.

1. The ending-point coordinates and skip coordinates read will be those related to the
workpiece coordinate system.
2. Ending-point coordinates, skip coordinates, and servo deviations can be checked even
during movement. Machine coordinates, workpiece coordinates, and tool position offset
coordinates must be checked only after movement has stopped.

Fundamental machine coordinate system M

Workpiece coordinate system W

G00

G01

Read
command
End point
coordinates

W Workpiece
coordinate system

Workpiece
coordinates
Machine
coordinate system
Machine M
coordinates

MEP167

13-89
13 PROGRAM SUPPORT FUNCTIONS

3. Skip coordinates denote the position at which a skip signal has turned on at the block of
G31. If the skip signal has not turned on, skip coordinates will denote the corresponding
ending-point position.

Read
command

Skip coordinate value

Gauge, etc.

MEP168

4. The ending-point position denotes the tool tip position which does not allow for any tool
offsets, whereas machine coordinates, workpiece coordinates, and skip coordinates denote
the tool reference-point position which allows for tool offsets.

Skip signal

F (Speed)
W
Workpiece
coordinate system
Workpiece
Skip signal input coordinates
coordinates Machine
M coordinate system

Machine coordinates
Mark : Read after confirmation of stop.
Mark : Can be read during move. MEP169

The input coordinates of a skip signal denote the position within the workpiece coordinate
system. The coordinates stored in variables from #5061 to #5066 are those existing when
skip signals were input during movement of the machine. These coordinates can therefore
be read at any time after that.

 See Chapter 15 for further details.

13-90
PROGRAM SUPPORT FUNCTIONS 13
Example 1: Workpiece position measurement:
The following shows an example of measuring the distance from a reference
measurement point to the workpiece end:

Argument (Local variable)


O9031

F (#9) 200 N1 #180=#4003


X (#24) 100.000 N2 #30=#5001#31=#5002
Y (#25) 100.000
N3 G91G01Z#26F#9
Z (#26) –10.000
N4 G31X#24Y#25F#9
N5 G90G00X#30Y#31
G65P9031X100.Y100.Z-10.F200
N6 #101=#30–#5061#102=#31–#5062
To subprogram
N7 #103=SQR[#101?#101+#102?#102]
N8 G91G01Z–#26
N9 IF[#180EQ91]GOTO11
(Common variable) N10 G90
N11 M99
Skip signal input #101 87.245
#102 87.245
Start point #103 123.383
N4
Z N3 #102
N8 #103
N5
Y
#101
X

#101 X-axis measuring amount N1 Modal data storage of G90/G91


#102 Y-axis measuring amount N2 X, Y starting point data storage
#103 Measuring line linear amount N3 Z-axis entry
#5001 X-axis measuring start point N4 X, Y measuring (Stop at skip input)
#5002 Y-axis measuring start point N5 Return to X, Y starting point
#5061 X-axis skip input point N6 X, Y measuring incremental data calculation
#5062 Y-axis skip input point N7 Measuring line linear amount calculation
N8 Z-axis escape
N9, N10 Modal return of G90/G91
N11 Return from subprogram

13-91
13 PROGRAM SUPPORT FUNCTIONS

Example 2: Skip signal input coordinates reading:

–150 –75 –25 Y


–X X

N1 G91G28X0Y0
N2 G90G00X0Y0 –50
N3 X0Y–100.
N4 G31X–150.Y–50.F80 –75
N5 #111=#5061 #112=#5062
N6 G00Y0 –100
N7 G31X0
N8 #121=#5061 #122=#5062
N9 M02 –Y
Skip signal
MEP171

#111 = –75. +  #112 = –75. + 


#121 = –25. +  #122 = –75. + 
where  denotes an error due to response delay.

 See Chapter 15 for further details.

Variable #122 denotes the skip signal input coordinate of N4 since N7 does not have a Y-
command code.

16. TNo. (#51999) and Number of index (#3020) of the spindle tool
Variables numbered 51999 and 3020 can be used to read the tool number, and the number of
tool data index, of the tool mounted in the spindle. The number of index can be used, instead of
TNo., in reading the tool data of a particular tool with the aid of macro variables.

System variable Description


#51999 Tool number of the spindle tool
#3020 Number of tool data index of the spindle tool

Note 1: These system variables are read-only variables.


Note 2: During tool path checking operation both variables (#51999 and #3020) store data with
mere reference to the “TNo.” programmed in a T-code and, therefore, remain zero (0)
when the program concerned has no T-codes used.

17. Number of tool data index (#3022 and #3023)


Variables numbered 3022 and 3023 can be used to read the number of tool data index of any
desired tool.
Variables Description
#3022 Designation of the required tool (for writing only).
Use the integral and decimal parts respectively for specifying the required tool
with its number and suffix.
#3022 = . ΔΔ
: Tool number (TNo.)
ΔΔ: Suffix
#3023 Number of index of the specified tool (for reading only).
Use this variable to read out the index line number of the tool specified by the
variable #3022.
The reading in #3023 is zero (0) if there is no corresponding tool registered in
the memory.

13-92
PROGRAM SUPPORT FUNCTIONS 13
Example:
TNo. #3022 setting Reading in #3023
1 A 1.01 21
2 B 2.02 24
3 C 3.03 40
4 A 4.61 31
5 B 5.62 34
6 C 6.63 35
7 H 7.08 15
8 V 8.22 18
9 Z 9.26 19
: : : :
: : : :
Failure – 0

Note: The number of tool data index undergoes changes by an exchange of data sets using
the [TOOL DATA MOVE] menu function on the TOOL DATA display. It is necessary,
therefore, to obtain the number of tool data index in order to correctly fetch a tool’s
information item from the TOOL DATA display with the aid of system variables.

18. MAZATROL tool data


Using variables tabulated below, MAZATROL tool data can be read or written, as required.
Variables from #60001 ............. Tool quantity: 999 (maximum)
Variables from #600001 ........... Tool quantity: 4000 (maximum)
The maximum applicable tool quantity depends on the machine specifications.
(n = Number of index of the tool)
System variables MAZATROL tool data
#60001 to #60000+n #600001 to #600000+n Tool length
#61001 to #61000+n #610001 to #610000+n Tool diameter
#62001 to #62000+n #620001 to #620000+n Tool life flag (1: ON, 0: OFF)
#63001 to #63000+n #630001 to #630000+n Tool damage flag (1: ON, 0: OFF)
#64001 to #64000+n #640001 to #640000+n Wear compensation X
#65001 to #65000+n #650001 to #650000+n Wear compensation Y
#66001 to #66000+n #660001 to #660000+n Wear compensation Z
#67001 to #67000+n #670001 to #670000+n Group number

Note 1: During tool path check, tool data can be read but cannot be written.
Note 2: Tool life flags (variables numbers of the order of #62000 or #620000) and tool damage
flags (likewise, the order of #63000 or #630000) can take either 1 or 0 as their logical
states (1 for ON, 0 for OFF).
Note 3: Tool life flags (variables numbers of the order of #62000 or #620000) only refer to tool
life management according to the tool’s application time.

13-93
13 PROGRAM SUPPORT FUNCTIONS

19. EIA/ISO tool data


Using variables numbers tabulated below, EIA/ISO tool data (tool life management data) can be
read or updated, as required.
Variables from #40001 ............. Tool quantity: 960 (maximum)
Variables from #400001 ........... Tool quantity: 4000 (maximum)
The maximum applicable tool quantity depends on the machine specifications.
(n = Number of index of the tool)
System variables Corresponding data
#40001 to #40000+n #400001 to #400000+n Length offset data No. or Length offset amount
#41001 to #41000+n #410001 to #410000+n Radius compensation data No. or compensation amount
#42001 to #42000+n #420001 to #420000+n Tool life flag (1: ON, 0: OFF)
#43001 to #43000+n #430001 to #430000+n Tool damage flag (1: ON, 0: OFF)
#44001 to #44000+n #440001 to #440000+n Tool data flag (See the table below.)
#45001 to #45000+n #450001 to #450000+n Tool application time (s)
#46001 to #46000+n #460001 to #460000+n Tool life time (s)
#47001 to #47000+n #470001 to #470000+n Tool application quantity
#48001 to #48000+n #480001 to #480000+n Tool life quantity
Tool life flag
0: No expiration of serviceable life
1: Expiration in terms of application quantity
#49001 to #49000+n #490001 to #490000+n 2: Expiration in terms of application time
4: Expiration in terms of X-axis werar amount
8: Expiration in terms of Y-axis werar amount
16: Expiration in terms of Z-axis werar amount

Note 1: During tool path check, tool data can be read but cannot be written.
Note 2: Tool life flags (variables numbers of the order of #42000 or #420000) and tool damage
flags (likewise, the order of #43000 or #430000) can take either 1 or 0 as their logical
states (1 for ON, 0 for OFF).
Note 3: The identification between number and amount of tool length offset or radius compen-
sation is made by referring to the tool data flag.

Tool data flag bit 0 bit 1 bit 2 bit 3


Length offset data No. 0 0 – –
Length offset amount 0 1 – –
Radius comp. data No. – – 0 0
Radius comp. amount – – 0 1

20. Date and time (Year-month-day and hour-minute-second)


Variables numbered 3011 and 3012 can be used to read date and time data.
Variable Nos. Description
#3011 Date (Year-month-day)
#3012 Time (Hour-minute-second)

Example: If the date is December 15, 1995 and the time is 16:45:10, data is set as follows in
the corresponding system variables:
#3011 = 951215
#3012 = 164510.

13-94
PROGRAM SUPPORT FUNCTIONS 13
21. Total number of machined parts and the number of parts required
Variables numbered 3901 and 3902 can be used to read or assign the total number of machined
parts and the number of parts required.
Variable Nos. Description
#3901 Total number of machined parts
#3902 Number of parts required

Note 1: These variables must be integers from 0 to 9999.


Note 2: Data reading and writing by these variables is surely suppressed during tool path
checking.

22. Setting and using variables names


Any variables name can be assigned to each of common variables #500 through #519. The
variables name, however, must be of seven alphanumerics or less that begin with a letter of the
alphabet.

Format:
SETVNn [NAME1, NAME2, .....]
Starting number of the variable to be named
Name of #n (Variables name)
Name of #n + 1 (Varaibles name)

Each variables name must be separated using the comma (,).


Detailed description
- Once a variables name has been set, it remains valid even after power-off.
- Variables in a program can be called using the variables names. The variable to be called must,
however, be enclosed in brackets ([ ]).
Example: G01X[#POINT1]
[#TIMES]=25
- Variables names can be checked on the USER PARAMETER No. 1 display. The names
assigned to variables #500 to #519 are displayed at F47 to F66.
Example: Program SETVN500[ABC,EFG]
On the display
F46 0
F47 ABC  Variables name assigned to #500
F48 EFG  Variables name assigned to #501
F49  Variables name assigned to #502
F50

23. Contents of the S12 parameter (#3200 and #3212)


Variables numbered 3200 and 3212 can be used to read the settings of particular S parameters.
Use #3200 beforehand to specify the desired axis.
#3200 setting Description
1 to 16 Axis number

Example: #3200 = 1;
Designation of the first significant axis setting (normally: X) within the system.
Variable Nos. S parameter
#3212 S12

13-95
13 PROGRAM SUPPORT FUNCTIONS

Note 1: #3200 is initialized (to “1”) by NC-resetting.


Note 2: It is not necessary to repeat writing into #3200 next time the reading with #3212 is to be
done for the same axis.
Note 3: Read #3200 as required to check its last setting.
Note 4: The setting for #3200 is not checked for the appropriateness (as to whether the
designated axis is preset properly) at the block of #3200, but results in an alarm (809
ILLEGAL NUMBER INPUT) being caused at the reading block of #3212 when the
setting is found inappropriate.

24. Workpiece setup error correction values


Using variables tabulated below, it is possible to read and write the values used for workpiece
setup error correction.
Common No. 1 No. 2 No. 3 No. 4 No. 5 No. 6 No. 7
x #5801 #5811 #5821 #5831 #5841 #5851 #5861 #5871
y #5802 #5812 #5822 #5832 #5842 #5852 #5862 #5872
z #5803 #5813 #5823 #5833 #5843 #5853 #5863 #5873
a — #5814 #5824 #5834 #5844 #5854 #5864 #5874
b — #5815 #5825 #5835 #5845 #5855 #5865 #5875
c — #5816 #5826 #5836 #5846 #5856 #5866 #5876
Rotat. axis coord. 1 #5807 #5817 #5827 #5837 #5847 #5857 #5867 #5877
Rotat. axis coord. 2 #5808 #5818 #5828 #5838 #5848 #5858 #5868 #5878

Use #5800 to read the number (1 to 7) of the currently selected data set for workpiece setup
error correction.
Note: An attempt to overwrite the system variable #5800 will only lead to an alarm (1821
UNWRITABLE SYSTEM VARIABLE).

25. Settings in an indexing unit (#550610 to #550620)


Using variables tabulated below, it is possible to read the setting items of an indexing unit
(INDEX) in a MAZATROL program.
These variables always read the settings of the currently active indexing unit (executed last), and
zero (0) is read for a blank setting item.

Variables Name Register R Unit


R610 (low-order)
#550610 TURN POS X 0.0001 mm or 0.00001 in
R611 (high-order)
R612 (low-order)
#550612 TURN POS Y 0.0001 mm or 0.00001 in
R613 (high-order)
R614 (low-order)
#550614 TURN POS Z 0.0001 mm or 0.00001 in
R615 (high-order)
R618 (low-order)
#550618 ANGLE B 0.0001°
R619 (high-order)
R620 (low-order)
#550620 ANGLE C 0.0001°
R621 (high-order)

Note : These system variables are read-only variables.

13-96
PROGRAM SUPPORT FUNCTIONS 13
26. Work number of the main program (#4000)
Use variable #4000 to read the work number of the main program. The reading can also occur in
the same manner during execution on the TOOL PATH CHECK display.

Main program Subprogram


[Link] [Link]

O0010; O1000;

#100=#4000 “10” is read out as the work No. of


M98P1000; the main program.

M99;
M30

Note 1: Only 8-digit natural numbers (1 to 99999999) can be read as they are. The reading is
always “–1” if there is any character other than arabic numerals (0 to 9) in the work
number.
Note 2: The reading cannot be done appropriately (is always “–1”) in the mode of tape
operation and MDI.
Note 3: This system variable is a read-only one.
Note 4: In the case of program chain (by M998) the work number of the main program chained
can be read as appropriate.

Main program Main program


[Link] [Link]

O0010; O0020;

#100=#4000 “20” is read out as the work No. of


the main program.
M998S20;
Subprogram
Program chain M998P2000; [Link]

O2000;
M30 “20” is read out as the
#100=#4000
work No. of the main
program.
M99;

13-97
13 PROGRAM SUPPORT FUNCTIONS

13-12-5 Arithmetic operation commands


Various operations can be carried out between variables using the following format.
#i = <expression>
where <expression> must consist of a constant(s), a variable(s), a function(s), or an operator(s).
In the table given below, constants can be used instead of #j and/or #k.

[1] Definition/replacement of
#i=#j Definition/replacement
variables
[2] Additional-type operations #i=#j+#k Addition
#i=#j–#k Subtraction
#i=#jOR#k Logical additon (For each of 32 bits)
#i=#jXOR#k Exclusive OR (For each of 32 bits)
[3] Multiplicative-type #i=#j#k Multiplication
operations #i=#j/#k Division
#i=#jMOD#k Surplus
#i=#jAND#k Logical product (For each of 32 bits)
[4] Functions #i=SIN[#k] Sine
#i=COS[#k] Cosine
#i=TAN[#k] Tangent (tanq is used as sinq/cosq.)
#i=ATAN[#j] Arc-tangent (Either ATAN or ATN can be used.)
#i=ACOS[#j] Arc-cosine
#i=SQRT[#k] Square root (Either SQRT or SQR is available.)
#i=ABS[#k] Absolute value
#i=BIN[#k] BINARY conversion from BCD
#i=BCD[#k] BCD conversion from BINARY
#i=ROUND[#k] Rounding to the nearest whole number (Either ROUND or
RND is available.)
#i=FIX[#k] Cutting away any decimal digits
#i=FUP[#k] Counting any decimal digits as 1s
#i=LN[#k] Natural logarithm
#i=EXP[#k] Exponent with the base of e (= 2.718 ...)

Note 1: In principle, data without a decimal point is handled as data that has a decimal point.
(Example: 1 = 1.000)
Note 2: Offsets from variable #10001, workpiece coordinate system offsets from variable
#5201, and other data become data that has a decimal point. If data without a decimal
point is defined using these variables numbers, therefore, a decimal point will also be
assigned to the data.
Example:
Common variable

#101=1000
#101 1000
#10001=#101 Execution #102 1.000
#102=#10001

Note 3: The <expression> after a function must be enclosed in brackets ([ ]).

1. Operation priority
Higher priority is given to functions, multiplicative operations, and additive operations, in that
order.
#101=#111+#112SIN[#113]
[1] Function
[2] Multiplicative
[3] Additional

13-98
PROGRAM SUPPORT FUNCTIONS 13
2. Specifying an operational priority level
The part to which the first level of operation priority is to be given can be enclosed in brackets
([ ]). Up to five sets of brackets, including those of functions, can be used for one expression.
#101=SQRT[[[#111–#112]SIN[#113]+#114]#15]

One fold
Two fold
Three fold

3. Examples of operation instructions

[1] Main program and G65 P100 A10 B20. #1 10.000


argument #101=100.000 #2 20.000
specification #102=200.000 #101 100.000
#102 200.000
[2] Definition, #1=1000 #1 1000.000
replacement #2=1000. #2 1000.000
= #3=#101 #3 100.000
Data of common variables
#4=#102 #4 200.000
#5=#5081 #5 –10.000 Offset amount
[3] Addition, #11=#1+1000 #11 2000.000
subtraction #12=#2–50. #12 950.000
+– #13=#101+#1 #13 1100.000
#14=#5081–3. #14 –13.000
#15=#5081+#102 #15 190.000
[4] Logical addition #3=100 #3 = 01100100
OR #4=#3OR14 14 = 00001110
#4 = 01101110 = 110
[5] Exclusive OR #3=100 #3 = 01100100
XOR #4=#3XOR14 14 = 00001110
#4 = 01101010 = 106
[6] Multiplication, #21=100100 #21 10000.000
Division #22=100.100 #22 10000.000
/ #23=100100. #23 10000.000
#24=100.100. #24 10000.000
#25=100/100 #25 1.000
#26=100./100 #26 1.000
#27=100/100. #27 1.000
#28=100./100. #28 1.000
#29=#5081#101 #29 –1000.000
#30=#5081/#102 #30 –0.050
[7] Surplus #31=#19MOD#20 #19 48
= = 5 surplus 3
MOD #20 9
[8] Logical product #9=100 #9 = 01100100
AND #10=#9AND15 15 = 00001111
#10 = 00000100 = 4
[9] Sine #501=SIN[60] #501 0.866
SIN #502=SIN[60.] #502 0.866
#503=1000SIN[60] #503 866.025
#504=1000SIN[60.] #504 866.025
#505=1000.SIN[60] #505 866.025
#506=1000.SIN[60.] #506 866.025
Note: SIN[60] is equal to SIN[60.].
[10] Cosine #541=COS[45] #541 0.707
COS #542=COS[45.] #542 0.707
#543=1000COS[45] #543 707.107
#544=1000COS[45.] #544 707.107
#545=1000.COS[45] #545 707.107
#546=1000.COS[45.] #546 707.107
Note: COS[45] is equal to COS[45.].

13-99
13 PROGRAM SUPPORT FUNCTIONS

[11] Tangent #551=TAN[60] #551 1.732


TAN #552=TAN[60.] #552 1.732
#553=1000TAN[60] #553 1732.051
#554=1000TAN[60.] #554 1732.051
#555=1000.TAN[60] #555 1732.051
#556=1000.TAN[60.] #556 1732.051
Note: TAN[60] is equal to TAN[60.].
[12] Arc-tangent #561=ATAN[173205/100000] #561 60.000
ATAN #562=ATAN[173.205/100.] #562 60.000
#563=ATAN[1.732] #563 59.999
[13] Arc-cosine #521=ACOS[100000/141421] #521 45.000
ACOS #522=ACOS[100./141.421] #522 45.000
#523=ACOS[1000/1414.213] #523 45.000
#524=ACOS[10./14.142] #524 44.999
#525=ACOS[0.707] #525 45.009
[14] Square root #571=SQRT[1000] #571 31.623
SQRT #572=SQRT[1000.] #572 31.623
#573=SQRT[10.10.+20.20.] #573 22.361
#574=SQRT[#14#14+#15#15] #574 190.444
Note: For enhanced accuracy, perform
operations within [ ] as far as possible.
[15] Absolute value #576=–1000 #576 –1000.000
ABS #577=ABS[#576] #577 1000.000
#3=70.
#4=–50.
#580= ABS[#4–#3] #580 120.000
[16] BIN, BCD #1=100
#11=BIN[#1] #11 64
#12=BCD[#1] #12 256
[17] Rounding into the #21=ROUND[14/3] #21 5
nearest whole #22=ROUND[14./3] #22 5
number #23=ROUND[14/3.] #23 5
ROUND #24=ROUND[14./3.] #24 5
#25=ROUND[–14/3] #25 –5
#26=ROUND[–14./3] #26 –5
#27=ROUND[–14/3.] #27 –5
#28=ROUND[–14./3.] #28 –5
[18] Cutting away any #21=FIX[14/3] #21 4.000
decimal digits #22=FIX[14./3] #22 4.000
FIX #23=FIX[14/3.] #23 4.000
#24=FIX[14./3.] #24 4.000
#25=FIX[–14/3] #25 –4.000
#26=FIX[–14./3] #26 –4.000
#27=FIX[–14/3.] #27 –4.000
#28=FIX[–14./3.] #28 –4.000
[19] Counting any #21=FUP[14/3] #21 5.000
decimal digits as 1s #22=FUP[14./3] #22 5.000
FUP #23=FUP[14/3.] #23 5.000
#24=FUP[14./3.] #24 5.000
#25=FUP[–14/3] #25 –5.000
#26=FUP[–14./3] #26 –5.000
#27=FUP[–14/3.] #27 –5.000
#28=FUP[–14./3.] #28 –5.000
[20] Natural logarithm #101=LN[5] #101 1.609
LN #102=LN[0.5] #102 –0.693
#103=LN[–5] Alarm 860 CALCULATION IMPOSSIBLE
[21] Exponent #104=EXP[2] #104 7.389
EXP #105=EXP[1] #105 2.718
#106=EXP[–2] #106 0.135

13-100
PROGRAM SUPPORT FUNCTIONS 13
4. Operation accuracy
The errors listed in the table below are generated by one arithmetic operation, and the error rate
increases each time an operation is performed.

Operation format Mean error Max. error Kind of error

a=b+c  
2.33 × 10–10 5.32 × 10–10 Min. ,
a=b–c c b
a=bc 1.55 × 10–10 4.66 × 10–10
a = b/c 4.66 × 10–10 1.86 × 10–9

Relative error
a
a= b 1.24 × 10–9 3.73 × 10–9
a = sin b
5.0 × 10–9 1.0 × 10–8
a = cos b Absolute error  degree
a = tan–1 b/c 1.8 × 10–6 3.6 × 10–6

Note: The function TAN (Tangent) is calculated as SIN/COS (Sine/Cosine).

5. Notes on deterioration of accuracy

A. Addition/subtraction
As for additional-type operations, if an absolute value is subtracted from the other, the relative
–8
error cannot be reduced below 10 .
For example, when the true values (such values, by the way, cannot be substitued directly) of
#10 and #20 are as follows:
#10 = 2345678988888.888
#20 = 2345678901234.567
then #10 – #20 = 87654.321 would not result from calculation of #10 – #20. This is because,
since the effective number of digits of the variable is eight (decimal), the approximate values of
#10 and #20 are:
#10 = 2345679000000.000
#20 = 2345678900000.000
More strictly, internal binary values slightly differ from these values. Actually therefore, a
significant error results as follows:
#10 – #20 = 100000.000.

B. Logical relationship
As for EQ, NE, GT, LT, GE and LE, the processing is executed in a similar manner to addition
and substraction, so be careful to errors. For example, to judge whether #10 is equal to #20 of
the above example, the conditional expression
IF [#10EQ#20]
is not appropriate due to the errors. In such a case, therefore, give a macro-instruction as shown
below to allow for an acceptable tolerance in the judgement on the equality of two values.
IF [ABS[#10 – #20] LT200000]

C. Trigonometric functions
For trigonometric functions, although the absolute error is guaranteed, the relative error is not
–8
below 10 . Be careful, therefore, when carrying out multiplication, or division after trigonometric
function operations.

13-101
13 PROGRAM SUPPORT FUNCTIONS

13-12-6 Control commands


The flow of a program can be controlled using IF  GOTO  and WHILE DO  commands.

1. Branching
Format: IF [conditional expression] GOTO n
where n is a sequence number in the same program.
The branching will occur to the block headed by sequence number ‘n’ if the condition holds, or if
the condition does not hold, the next block will be executed.
An independent setting of GOTO statement without IF [conditional expression] will perform
unconditional branching to the specified block.

The [conditional expression] consists of the following six types:

#i EQ #j = (#i is equal to #j.)


#I NE #j  (#i is not equal to #j.)
#i GT #j > (#i is larger than #j.)
#I LT #j < (#i is smaller than #j.)
#I GE #j  (#i is equal to #j, or larger than #j.)
#I LE #j  (#i is equal to #j, or smaller than #j.)

For GOTO n, n must be a sequence number within the same program. If the sequence number
does not exist in that program, an alarm 843 DESIGNATED SNo. NOT FOUND will occur. An
expression or a variable can be used instead of #i, #j, or n.
Sequence number designation Nn must be set at the beginning of the destination block.
Otherwise, an alarm 843 DESIGNATED SNo. NOT FOUND will result. If, however, the block
begins with “/” and Nn follows, the program can be branched into that sequence number.

N10 #22=#20 #23=#21 Branching to N100


IF[#2EQ1] GOTO100 if #2 = 1. Search Search
for
#22=#20–#3 for N10
#23=#21–#4 N100 to be
con-
N100 X#22 Y#23 tinued
#1=#1+1 back to
the
head

Note: During search for the branching destination sequence number, if the area from the
block after “IF ...” to the program end (% code) is searched (forward search) in vain,
then the area from the head down to the block before “IF ...” will be searched next
(backward search). It will therefore take more time to execute backward search
(searching in the opposite direction to the flow of the program) than to execute forward
search.

13-102
PROGRAM SUPPORT FUNCTIONS 13
2. Looping

Format:
WHILE [Condition expression] DOm (m = 1, 2, 3  127)

ENDm

The area from the next block to the ENDm block loops while the conditional expression holds. If
the conditional expression does not hold, control will be tansferred to the block after ENDm. In
the format shown above, DOm can precede WHILE.
You must always use WHILE [conditional expression] DOm and ENDm in pairs. If you omit
WHILE [conditional expression], the area from DOm to ENDm will endlessly loop. In DOm, m (1
to 127) identifies the number of looping. (DO1, DO2, DO3, and so on up to DO127)
The maximum available number of degrees of multiplicity is 27.

[1] Same identifying No. can be used repeatedly. [2] The identifying No. of WHILE  DOm is arbitrary.

WHILE  DO1 WHILE  DO1

END1
Usable

END1 WHILE  DO3

END3

Usable
WHILE  DO1 WHILE  DO2

END2
Usable

END1 WHILE  DO1

END1

[3] Up to 27 levels of WHILE  DOm can be used. [4] The total number of levels of WHILE  DOm must not
m can be 1 to 127, independent of the depth of nesting. exceed 27.

WHILE  DO1
WHILE  DO1 DO1
WHILE  DO2
WHILE  DO2 DO2 
 WHILE  DO27
 

WHILE  DO27 DO27 WHILE  DO28
Usable
END28 Unusable
END27

END27
END2

END2
END1
END1

Note: For nesting, m once used cannot be used again.

13-103
13 PROGRAM SUPPORT FUNCTIONS

[5] WHILE  DOm must precede ENDm. [6] WHILE  DOm must correspond to ENDm one-to-one in the
same program.

WHILE  DO1
END1

Unusable WHILE  DO1


Unusable
WHILE  DO1 END1

[7] WHILE  DOm must not overlap. [8] Outward branching from the range of WHILE  DOm is
possible.
WHILE  DO1
WHILE  DO1

Unusable WHILE  DO2


IF  GOTOn

END1
Usable END1

END2
Nn

[9] Branching into WHILE  DOm is not allowed. [10] Subprogram can be called using M98, G65, G66, etc. from
the midway of WHILE  DOm.
WHILE  DO1
IF  GOTOn Main program Subprogram
Unusable
IF  GOTOn
WHILE  DO1 WHILE  DO2
WHILE  DO1 END1
Unusable
G65 P100
Usable END2
WHILE  DO1 To sub-
Nn program
END1
Nn M99
M02
END1
END1

[11] The looping can be independently programmed in a [12] If WHILE and END are not included in pairs in subprogram
subprogram which is called using G65/G66 from the (including macro subprogram), an alarm will result at M99.
midway of WHILE  DOm. Up to 27 levels of nesting for
Main program Subprogram
both programs can be done.

Main program Subprogram


G65 P100 WHILE  DO1
WHILE  DO1 WHILE  DO1

M02 M99
G65 P100
Usable END1
To sub-
END1 program
Alarm 868 DO-END MIS-MATCH
M99

13-104
PROGRAM SUPPORT FUNCTIONS 13
13-12-7 External output commands (Output via RS-232C)

1. Overview
In addition to standard user macros, the types of macros listed below are provided as external
output commands. These external output macros can be used to output character data or the
numerical data in variables to an external unit via an RS-232C interface. The data are outputted
in a data length of 7 bits with an even-parity bit added.

A. Types and functions of external output macros


POPEN Setup processing for data output
PCLOS Termination processing of data output
BPRNT Printout of character data or binary printout of variable data
DPRNT Printout of character data or numerical printout of variable data on a digit-by-digit
basis

B. Programming order

POPEN Open command

BPRNT DPRNT Data output commands

PCLOS Close command

2. Open command POPEN


Programming format: POPEN
Detailed description
- The command code POPEN must be included before a series of data output command codes.
- The control code for DC2 and the percentage code % are output from the NC unit to an
external output unit.
- Once POPEN has been set, it will remain valid until PCLOS is set.

3. Close command PCLOS


Programming format: PCLOS
Detailed description
- The command code PCLOS must be included after all data output command codes.
- The control code for DC4 and the percentage code % are outputted from the NC unit to an
external output unit.
- This command must be used together with POPEN. This command code must be included only
after POPEN.
- This command must be set at the end of the program even after data output has been aborted
using, for example, the NC reset switch.

13-105
13 PROGRAM SUPPORT FUNCTIONS

4. Data output command BPRNT


Programming format:
BPRNT[1#v1[c1]2#v2[c2]]

Effective digits after decimal point Variable value


c
Variable number × 10
Character string

Detailed description
- The command BPRNT can be used to output characters or to output variable data in binary
form.
- The designated character string is outputted directly in the ISO coded format. Alphanumerics
(A to Z, and 0 to 9) and/or special characters (+, –, , /) can be used. Of these characters, only
the asterisk () is outputted as a space code.
- Since all variables are saved as those having a decimal point, the necessary number of
decimal digits must be enclosed in brackets ([ ]).
All variables are handled as data of four bytes (32 bits), and each byte is outputted as binary
data in the order of the most significant byte first. Minus data is processed as the complement
for that data.
Example 1: If three digits are specified for 12.3456, then
3
[12.346 × 10 ] = 12346 (0000303A)
will be outputted as binary data.
Example 2: If no digits are specified for –100.0, then
–100 (FFFFFF9C)
will be outputted as binary data.
- After the specified data has been outputted, the EOB (End Of Block) code is outputted in the
format of the appropriate ISO code.
- Variables containing <empty> are interpreted as 0s.

5. Data output command DPRNT


Programming format:
DPRNT[1#v1[d1 c1]2#v2[c2]]
Effective digits below decimal point
Effective digits above decimal point c+d8
Variable number
Character string
Detailed description
- Output of character data or decimal output of variable data is performed in the format of ISO
codes.
- The designated character string is outputted directly in the ISO coded format.
Alphanumerics (A to Z, and 0 to 9) and/or special characters (+, –, , /) can be used. Of these
characters, only the asterisk () is outputted as a space code.
- Of the data contained in a variable, the necessary number of digits above the decimal point and
that of digits below the decimal point must each be enclosed in brackets ([ ]). The variable
data will then have its total specified number of digits, including the decimal point, outputted in
the ISO coded format in the order of the most significant digit first. No trailing zeros will be left
out in that case.

13-106
PROGRAM SUPPORT FUNCTIONS 13
13-12-8 External output command (Output onto the local disk)

1. Overview
External output macros can also be used to output data in text file format into the predetermined
directory on the local disk.

2. Related parameters
- DPR14: Selection of an output destination port
Set DPR14 to “4” (Output onto the local disk) under OTHER on the DATA I/O PARAMETER
display.
- DPR15: Number of lines in feed section
Set the required number of lines to be fed.
- DPR8: Output file size
Use this parameter to specify the maximum permissible output file size.
Maximum permissible file size: DPR8 × 100 (KB)
A command for outputting a greater file will cause the alarm 1420 FILE SIZE LIMIT
EXCEEDED.
However, the file size limit is 100 KB if the value in DPR8 is 0.

Note: Output of a file of smaller size than the limit, however, may not be possible due to a
shortage of available area on the local disk.
The DATA I/O PARAMETER display can be selected by tapping the [DATA I/O PARAM.] menu
item on the DATA I/O display.

 For further details of the parameters, refer to the separate Parameter List/
Alarm List/M-code List.

3. Output file
The text file will be automatically outputted with a particular file name into the predetermined
directory.
Output directory: c:\ymw\M8Y\data\MC_sdg\print\
Output file name: [Link]
(A file of this name will be automatically created, if required, or the text data
will be added to the current contents of the file.)

13-107
13 PROGRAM SUPPORT FUNCTIONS

File contents:
Given below on the right is an example of text file contents created by the execution of the
program shown on the left under the particular parameter settings.

[Program] [Output example]


[Link]
G28XYZ

POPEN %
DPRNT[OOOOOOOOOOOO] OOOOOOOOOOOO
DPRNT[XXXXXXXXXXXX] XXXXXXXXXXXX
DPRNT[IIIIIIIIIIII] IIIIIIIIIIII
PCLOS %

G0X100.Y100.Z100.
M30

[Parameter]
DPR14: 4
DPR15: No setting

4. Related alarms
The alarm given for text file output is described below.

No. Message Argument 1 Argument 2 Argument 3


887 TAPE I/O ERROR –100 File open error 0 0
–111 File write error 0 0
–112 File size too great 0 0

13-108
PROGRAM SUPPORT FUNCTIONS 13
13-12-9 Precautions
Use of user macro commands allows a machining program to be created by combining arithmetic
operation, judgment, branchining, or other macro commands with conventional NC commands
such as move commands, M-, S-, T-commands, etc. The statement defined by these macro
commands and that of conventional NC commands are taken as a macro statement and an NC
execute statement, respectively. The treatment of a macro statement has no direct rerations with
machine control. Its treatment as short as possible is effective for shortening machining time.
Parallel processing of the NC execute statement and the macro statement becomes possible
according to the setting of bit 6 of parameter F93.
(It becomes possible to process all macro statements in batch form by setting the parameter bit
to OFF when machining the workpiece, or to execute the macro statements block-by-block by
setting the parameter bit to ON when checking the program. Therefore, set the parameter bit
according to your requirements.)
Sample program
N1 G91G28X0Y0Z0
N2 G92X0Y0Z0
N3 G00X–100.Y–100.
N4 #101=100.COS[210.] Macro statements
N5 #102=100.SIN[210.]
N6 G01X#101Y#102F800
A macro statement refers to a statement that consists of the following blocks:
- Arithmetic operation command block (compassing the equal sign =)
- Control command block (compassing GOTO, DO  END, etc.)
- Macro call command block (compassing macro call or cancellation G-code commands G65,
G66, G66.1, or G67)
An NC execute statement refers to a non-macro statement.

13-109
13 PROGRAM SUPPORT FUNCTIONS

The flow of processing of these two types of statements is shown below.

N1 N2 N3 N4 N5 N6 N7
Program analysis

Macroprogram statement N4 N5
Parameter treatment
OFF N2 N3 N6 N7
Next command
NC statement
treatment N1 N2 N3 N6
In execution

N1 N2 N3 N4 N5 N6 N7
Program analysis

N4 N5
Macroprogram statement
Parameter treatment
ON N2 N3 N4 N7
Next command
NC statement
treatment N1 N2 N3 N6
In execution

Machining program data is displayed as follows:


N4, N5 and N6 are treated in parallel with NC
execution sentence of N3, and N6 is displayed as
Parameter (In execution) N3 G00X–100.Y–100. next command because it is NC execution
OFF (Next command) N6 G01X#101Y#102F800 sentence. When N4, N5, and N6 are analized
during NC execution sentence of N3, machine
control continues.
N4 is treated in parallel with the control of NC
execution sentence of N3, and is displayed as
(In execution) N3 G00X–100.Y–100. next command.
Parameter
After N3 is completed, N5 and N6 are analized so
ON (Next command) N4 #101=100.COS[210.] the machine control is forced to wait by the
analyzing time of N5 and N6 before N6 can be
executed.

13-110
PROGRAM SUPPORT FUNCTIONS 13
13-12-10 Specific examples of programming using user macros
The following three examples of programming are shown here:
Example 1: SIN curve
Example 2: Bolt-hole circle
Example 3: Grid

Example 1: SIN curve

Y (sin )

G65 Pp1 Aa1 Bb1 Cc1 Ff1 100.

A: Initial value 0°
B: Final value 360° X
C: R of RSIN
0 90. 180. 270. 360.
F: Feed rate

–100.

MEP172

Main program O9910 (Subprogram)

 WHILE[#1LE#2]DO1
G65P9910A0B360.C100.F100
To subprogram #10=#3SIN[#1]
 Note
G90G1X#1Y#10F#9
#1=#1+10.
END1
#1 = 0 M99
Local variable set
in argument #2 = 360.000
#3 = 100.000
#9 = 100.000
Note: G90G01X#1Y[#3SIN[#1]]F#9
makes one block command available.

13-111
13 PROGRAM SUPPORT FUNCTIONS

Example 2: Bolt-hole circle


After hole data has been defined using fixed-cycle machining commands G72 to
G89, hole positions are to be designated using macro commands.

Main program –X x1
W

a1 : Start angle
G81Z–100.R50.F300 b1 : Hole quantity a1
To sub y1
G65P9920Aa1Bb1Rr1Xx1Yy1 r1 : Radius
program
x1 : X-axis center position
y1 : Y-axis center position –Y

MEP173

O9920
O9920 (Subprogram)

#101=0 0  #101 #101 = Hole count


#102=#4003 G90,G91 - Read-in
#103=#5001  #102 #102 = G90 or G91
Note
#104=#5002 Preceding coordinate
#111=#1 read-in
X  #103 #103 = X-axis present position
Y  #104 #104 = Y-axis present position
WHILE[#101LT#2]DO1 Start angle  #111 #111 = Start angle

#120=#24+#18COS[#111]
Note
#121=#25+#18SIN[#111] No
#101  Hole END
quantity
#122=#120 #123=#121
IF[#102EQ90]GOTO100 Yes

RadiusCOS [#111] #120 = Hole position X coordinate


#122=#120–#103
#123=#121–#104
Note + center coordinate X  #120 #121 = Hole position Y coordinate
RadiusSIN [#111] #122 = X-axis absolute value
#103=#120 + center coordinate Y  #121 #123 = Y-axis absolute value
#104=#121
#120  #122
#121  #123
N100 X#122Y#123
#101=#101+1 Note Yes Mode judge G90, G91
#111=#1+360.#101/#2
#102 = 90

END1 No
M99
#120 – #103  #122 #122 = X-axis incremental value
#121 – #104  #123 #123 = Y-axis incremental value
#120  #103 X-axis present position renewal
#121  #104 Y-axis present position renewal

Note: N100X#122Y#123 Drilling command


The processing time can be reduced by
one-block reduced programming.
#101+1  #101 Hole number count-up
Y
360°#101/Hole quantity
#111 = + #1  #111 #111 = Hole position angle

#111 =

13-112
PROGRAM SUPPORT FUNCTIONS 13

–X –500. W
G28X Y Z
T1 M06
G90 G43 Z100. H01
G54 G00 X0 Y0
To subprogram
G81 Z-100. R3. F100 M03
G65 P9920X-500. Y-500. A0 B8R100.
G65 P9920X-500. Y-500. A30. B8R200.
G65 P9920X-500. Y-500. A60. B8R300. 100.
–500.

200.
300.

–Y

MEP174

Example 3: Grid
After hole data has been defined using fixed-cycle machining commands G72 to
G89, hole positions are to be designated using macro call commands.

G81 Zz1 Rr1 Ff1 –X x1


G65Pp1 Xx1 Yy1 Ii1 Jj1 Aa1 Bb1
i1 W
X : X-axis hole position
Y : Y-axis hole position y1
I : X-axis distance j1
J : Y-axis distance
A : X direction hole quantity Subprogram is
shown on the
B : Y direction hole quantity
next page.
–Y

MEP175

G28X Y Z 100. 100. 100.


W
T1 M06 –X
G90 G43 Z100. H01
G54 G00 X0 Y0 –75.
G81 Z–100. R3. F100M03
G65P9930 X0 Y0 I100. J–75. A5B3
–75.

To subprogram –Y
G84 Z–90. R3. F250M03
G65P9930 X0 Y0 I–100. J–75. A5B3
–X

–100.

–Z

MEP176

13-113
13 PROGRAM SUPPORT FUNCTIONS

O9930 (Subprogram) O9930

Start point X coordinate  #101 #101 = X-axis start point


Start point Y coordinate  #102 #102 = Y-axis start point
#101=#24 Y-axis direction distance  #104 #104 = Y direction distance
#102=#25 X-axis hole quantity  #105 #105 = X-axis hole quanty
#104=#10
Y-axis hole quantity –1  #106 #106 = Y-axis hole quantity – 1
#105=#1
Note 0  #110 #110 = Y direction line count
#106=#2–1
#110=0 0  #111 #111 = Even/odd times judge
#111=0 0  #112 #112 = X-axis drilling direction
#112=0 reverse switch
N2

0  #113 #113 = X-axis distance initial


N2 #113=0 X direction distance  #103 #103 = X direction distance
Note
#103=#9

No
#105 > 0 N X direction hole drilling
WHILE[#105GT0]DO1 100 completion check
#101=#101+#113 Yes
#105=#105–1 Note
X#101Y#102 #101 + #113  #101 X coordinates renewal
#105 –1  #105 X direction hole quantity – 1

IF[#112EQ1]GOTO10
IF[#111NE1]GOTO10 X#101 Y#102 Drilling command

#103=0–#103 Yes X-axis drilling direction reverse


Note
#112=1 #112 = 1 switch check

N10 #113=#103 No
END1 For even times (#111 = 0), X
No distance is same as command.
N100 #106=#106–1 #111 = 1 For odd times (#111 = 1), X-axis
#112=0 drilling direction reverse switch on
Note Yes
#110=#110+1
0 – #103  #103
IF[#106LT0]GOTO200
1  #112
#105=#1
N10
#102=#102+#104
Note
#111=#110 #103  #113 X-axis drilling distance reset

#111=#111AND1 N
100
GOTO2
#106 – 1  #106 Y-axis hole quantity – 1
N200 M99 0  #112 X-axis drilling direction reverse switch off
#110 + 1  #110 Y direction line count-up

Y direction hole drilling


Yes
completion check
#106 < 0
END
No

#1  #105 X-axis hole quantity reset


Note: #102 + #104  #102 Y coordinates renewal
The processing time can be reduced by one- #110  #111
block reduced programming. Even times = 0
#111AND 1  #111
Odd times = 1

13-114

You might also like