You are on page 1of 42

FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.

com

Fanuc Custom Macro B


Manual

1 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

What Is a Macro Program?


Although subprograms are useful for repeating the same operation, the custom
macro function also allows use of variables, arithmetic and logic operations, and
conditional branches for easy development of general programs such as
pocketing and user–defined canned cycles.

A machining program can call a custom macro with a simple command, just like a
subprogram, the only difference being; we can now pass information into the sub
program and manipulate it as we want.

M98 P1234 (Sub program call)

G65 P1234 A100. B-26 F0.35 (Macro program call)

SUB PROGRAM CALL


MAIN PROGRAM SUB PROGRAM
O1234; O2000
; ;
; G01 X100. F0.35
M98 P2000; Z-26.
; ;
; M99;
M30;

An ordinary machining program specifies a G code and the travel distance directly
with a numeric value; examples are G01 X100.0

With a custom macro, numeric values can be specified directly or using a variable
number e.g. #1 or #2

When a variable number is used, the variable value can be changed by a program or
using operations on the MDI panel.

MACRO PROGRAM CALL


MAIN PROGRAM MACRO PROGRAM
O1234; O2000
; ;
; G01 X#1 F#9
G65 P2000 A100. B-26. F0.35; Z#2
; ;
; M99;
M30;

2 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Variables are classified into four into four different types.

Variable Number Type of Function


Variable
#0 Always Null This variable is always null. No value can
be assigned to this variable. It is not a
value, it is nothing/empty/null.
#1 - #33 Local Local variables can only be used within a
Variables macro to hold data such as the results of
operations. When the power is turned off,
local variables are initialized to null. When a
macro is called, arguments are assigned to
local variables. These should only be used
to pass values, not for calculations
#100 - #149 (#199) Common Common variables can be shared among
#500 - #531 (#999) Variables different macro programs. When the power
is turned off, variables #100 to #149 are
initialized to null. Variables #500 to #531
hold data even when the power is turned
off. As an option, common variables #150
to #199 and #532 to #999 are also
available.

#1000 - ~ System System variables are used to read and


variables write a variety of NC data items such as
the current position and tool compensation
values.

To display the macro variables press [OFFSET] – {MACRO}

3 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Local Variables

After a G65, a P (program number) must be specified, this program is the


Macro Program number

Any other information on the G65 line is passed into the macro program as a
Local Variable

Argument specification 1

Address Variable Address Variable Address Variable


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

Addresses G, L, N, O, and P cannot be used

G G code
L Number Of Repeats
N Sequence Number
O Main Program Number
P Macro Program Number

4 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Mathematical Functions
Definition - #i=#j
This is what’s used to transfer data from one variable to another.
Example:
#1=10 and #2=12
#1= #2
Both variables now equal 12.

Sum - #i=#j+#k
This is what’s used to add variables and values.
Example:
#2=12
#1=#2+10
The value of #1 is now 22.

Difference - #i=#j-#k
This is what’s used to subtract variables and values
Example:
#2=12
#1=#2-10
The value of #1 is now 2.

Multiply - #i=#j*#k
This is what’s used to multiply variables and values
Example:
#2=12
#1=#2*10
The value of #1 is now 120.

Divide - #i=#j/#k
This is what’s used to divide variables and values
Example:
#2=20
#1=#2/10
The value of #1 is now 2.

Square Root - #i=SQRT[#j];


This is what’s used to determine the square root of variables and values
Example:
#1=16
#2=SQRT[#1]
The value of #2 is now 4

All of the above can be put together using brackets to perform larger calculations.
Example:
#1=2 and #2=5
#100=#1*[#2-3]
The value of #100 is now 4, because 2 x (5 – 3) = 4
A Fanuc control uses the BODMAS system to order how the calculations are made.
5 Hughes Armstrong Middle East
FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Formatting Functions

Absolute Function - #i=ABS[#j];


The absolute function is used to ensure that a variable is a positive value
Example:
#1= -1.234
#2=ABS[#1];
The value of #2 is now 1.234

Round Function - #i=ROUND[#j];


When the round function is used the value is rounded off at the first decimal place.
Example:
#1=1.234
#2=ROUND[#1];
The value of #2 is now 1.0

Rounding Up #i=FUP[#j]
When the absolute value of the integer produced by an operation on a number is
greater than the absolute value of the original number, such an operation is referred
to as rounding up to an integer.

Be particularly careful when handling negative numbers.

Examples:
#1=1.2
#3=FUP[#1]
The value of #3 is now 2.0

#2=–1.2.
#3=FUP[#2]
The value of #3 is now -2.0

Rounding Down - #i=FIX [#j]


When the absolute value of the integer produced by an operation on a number is
less than the absolute value of the original number, such an operation is referred to
as rounding down to an integer.

Be particularly careful when handling negative numbers.

Examples:
#1=1.2
#3=FIX[#1]
The value of #3 is now 1.0

#2=-1.2
#3=FIX[#2]
The value of #3 is now -1.0

6 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Trigonometry Functions
In Macro B programming Sine, Cosine and Tangent are applied in the same format

Sine #i=SIN[#j];
Cosine #i=COS[#j];
Tangent #i=TAN[#j];

An angle is specified in degrees.90 degrees and 30minutes is represented as 90.5

Arcsine, Arccosine and Arctangent are inverse trigonometric functions of Sine,


Cosine and Tangent and are applied as follows

Arcsine #i=ASIN[#j]/[#k];
Arccosine #i=ACOS[#j]/[#k];
Arctangent #i=ATAN[#j]/[#k];

7 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Solutions for RH Triangles

#4
#1
#2

90°
#5
#3
Known Variables Formulas For Variables To Be Found
#3=SQRT[[#1*#1]-[#2*#2]]
#1 & #2 #5=ASIN[[#2]/[#1]]
#4=90- #5
#2=SQRT[[#1*#1]-[#3*#3]]
#1 & #3 #4=ASIN[[#3]/[#1]]
#5=90- #4
#1=SQRT[[#2*#2]-[#3*#3]]
#2 & #3 #5=ATAN[[#2]/[#3]]
#4=90- #5
#2=#1*SIN[#5]
#1 & #5 #3=#1*COS[#5]
#4=90- #5
#2=#1*COS[#4]
#1 & #4 #3=#1*SIN[#5]
#5=90- #4
#1=#2/SIN[#5]
#2 & #5 #3=#2/TAN[#5]
#4=90 - #5
#1=#2/COS[#4]
#2 & #4 #3=#2*TAN[#4]
#5=90- #4
#1=#3/COS[#5]
#3 & #5 #2=#3*TAN[#5]
#4=90- #5
#1=#3/SIN[#4]
#3 & #4 #2=#3/COS[#4]
#5=90- #4

8 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Phase Test 1 (Mathematical Functions)

The formula to calculate a spindle RPM from a constant surface speed is


as follows, this formula just like any other never changes.

Spindle speed = CSS * 1000

3.142 * Diameter

Write a Macro program to automatically calculate this.

Variables required will be

#100 = For the result

A local variable to pass over the CSS into the macro (S)

A local variable to pass over the diameter (D)

Main Program Macro Program


O1234 O6666
;
; #100=?????????????????
G65 P6666 S? D?
S#100 M03
;
;
M30 M99

9 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Conditional Expressions

In a program, the flow of control can be changed using the GOTO statement and
IF statement.

Three types of branch and repetition operations are used:

Branch and Repetition GOTO statement (unconditional branch)

IF statement (conditional: IF…THEN)

WHILE statement (repetition WHILE….DO)

Operators

Operators each consist of two letters that are used to compare two values to
determine whether they are equal or one value is smaller or greater than the other
value. Note that the inequality sign cannot be used.

Operator Meaning
EQ Equal to (=)
NE Not Equal to (≠)
LT Less Than (<)
LE Less Than or Equal to (< & =)
GT Greater Than (>)
GE Greater than or Equal To (> & =)

10 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

The ‘IF’ Conditional Expression


The IF expression can be used is two ways.

 IF along with GOTO


 IF along with THEN

IF[<conditionalexpression>]GOTOn

If the specified conditional expression is satisfied, a branch to sequence number n


occurs. If the specified condition is not satisfied, the next block is executed.

If the value of variable #100 is not equal to 20, a branch to sequence number
N5 occurs.

IF[#100 NE 20] GOTO 5


If the condition If the condition
PROCESSING
is not satisfied is satisfied
N5 G00 X20.

IF[<conditionalexpression>]THEN

If the specified conditional expression is satisfied, a predetermined macro statement


is executed. Only a single macro statement is executed.

If #1 is a negative value, then the following statement is satisfied, #1 is


converted to a positive value

IF[#1LT0] THEN #1=ABS[#1];

11 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

The ‘WHILE’ Statement


WHILE[<conditionalexpression>]DO

Specify a conditional expression after WHILE. While the specified condition is


satisfied, the program from DO to END is executed. If the specified condition is not
satisfied, program execution proceeds to the block after END
A number after DO and a number after END are identification numbers for specifying
the range of execution. The numbers 1, 2, and 3 can be used.
When a number other than 1, 2, and 3 is used, P/S alarm No. 126 occurs.

The sample program below finds the total of numbers 1 to 10.


O0001;
#1=0;
#2=1;
WHILE[#2 LE 10]DO 1; The program will continue to loop
#1=#1+#2; between these two lines until the
#2=#2+1;
value of #2 becomes 11
END 1;
M30;

The identification numbers (1 to 3) in a DO–END loop can be used as many times as


desired. Note, however, when a program includes crossing repetition loops
(overlapped DO ranges), P/S alarm No. 124 occurs.

The identification numbers (1 to 3) can DO loops can be nested to a


be used as many times as required. maximum depth of three levels.

WHILE […….] DO 1;
WHILE […….] DO 1;
PROCESSING
WHILE […….] DO 2;
END 1;
WHILE […….] DO 3;

WHILE […….] DO 1; END 3;

END 2;
PROCESSING
END1
END 1;

12 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Macro Call Methods

A macro program can be called using the following methods:

Macro Call Simple Call (G65)

Modal Call (G66 G67)

Macro Call With G Code

Macro Call With M Code

Sub Program Call With M Code

Sub Program Call With T Code

Simple Macro Call G65

After a G65, a P (program number) must be specified; this program is the macro
program to be called. When repetitions are required, an L can be specified.
Any other information on a G65 line is passed into the macro program using local
variables.

G65 P9010 L5 X10 Y15 Z-10 R2

#24 #25 #26 #18

Modal Macro Call G66, G67

Once G66 is issued to specify a modal call, the macro program is called after a block
specifying axis movement is completed. This continues until G67 is issued to cancel
the modal macro call.

Main Program Macro Program


O1234 O9010
;
; G01 Z#1;
G66 P9010 A1 B2 Z#2;
G00 X200. M99;
G00 X300.
G67
;
M30

13 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Macro Call With G Code


A G code number from 1 to 9999 can be used to call a custom macro program from
O9010 to O9019. In the corresponding parameter N0.6050 to No.6059, the value of
the G code must be inserted.
For example, when parameter 6050 is set to 181,macro program O9010 can be
called with G181.

Main Program Macro Program


O1234 O9010
;
G181 A1 B2 G01 Z#1;
; Z#2;
M30 M99;

The following table shows the correspondence between program number and
parameter. If for example your macro program is O9010, enter the value of the G
code you want in parameter 6050. I.E if you want G125 to open O9010 then 6050
must be 125.

Program Number Parameter Number


O9010 6050
O9011 6051
O9012 6052
O9013 6053
O9014 6054
O9015 6055
O9016 6056
O9017 6057
O9018 6058
O9019 6059

NOTE:
Because a P value is no longer required using this method the local variable #13
becomes available and information can be passed to it by using P

14 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Macro Call With M Code


An M code number from 1 to 9999 can be used to call a custom macro program from
O9020 to O9029. In the corresponding parameter N0.6080 to No.6089, the value of
the M code must be inserted.
For example, when parameter 6080 is set to 100,macro program O9020 can be
called with M100

Main Program Macro Program


O1234 O9020
;
M100 A1 B2 G01 Z#1;
; Z#2;
M30 M99;

The following table shows the correspondence between program number and
parameter. If for example your macro program is O9020, enter the value of the M
code you want in parameter 6080. I.E if you want M125 to open O9020 then 6080
must be 125.

Program Number Parameter Number


O9020 6080
O9021 6081
O9022 6082
O9023 6083
O9024 6084
O9025 6085
O9026 6086
O9027 6087
O9028 6088
O9029 6089

NOTE:
Because a P value is no longer required using this method the local variable #13
becomes available and information can be passed to it by using P

15 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Phase Test 2 (Conditional Expressions)

Create a G-Code to enable to drill holes on various PCD’s. The depths and the
amount of holes vary.

Process
1. Move the tool to the centre point
2. Using Trigonometry calculate hole position 1
3. Drill the hole
4. Using a WHILE statement repeat steps 2 & 3 until all holes are drilled.

Variables required will be:

A local variable to pass over the size of the PCD (D)

A local variable to pass over the depth of the holes (Z)

A local variable to pass over the number of holes (K)

16 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

System Variables
System variables can be used to read and write internal NC data such as tool
compensation values and current position data.
Note however, that some system variables can only be read. System variables are
essential for automation and general–purpose program development.

A full list off all the system variables for the Fanuc T & M systems can be
found at the back of this manual

Modal Information

The image above is a screen shot of a standard Fanuc program display.


Below the axis positioning you can see the MODAL information. Modal means active
G code or active commands. Everything except the actual spindle speed in the red
ring can be read.

17 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Modal Information M Series

System Variables for Modal Information


Variable Number Function Group
#4001 G00, G01, G02, G03, G33 01
#4002 G17, G18, G19 02
#4003 G90, G91 03
#4004 04
#4005 G94, G95 05
#4006 G20, G21 06
#4007 G40, G41, G42 07
#4008 G43, G44, G49 08
#4009 G73, G74, G76, G80–G89 09
#4010 G98, G99 10
#4011 G50, G51 11
#4012 G66, G67 12
#4013 G96, G97 13
#4014 G54 - G59 14
#4015 G61 - G64 15
#4016 G68, G69 16
:
#4022 22
#4102 B Code
#4107 D Code
#4109 F Code
#4111 H Code
#4113 M Code
#4114 Sequence Number N
#4115 Program Number
#4119 S Code
#4120 T Code
#4130 P Code For Selected G54.1 Offset

Example:
When #1=#4001; is executed, the resulting value in #1 is 0, 1, 2, 3, or 33.
If the specified system variable for reading modal information corresponds to a G
code group that cannot be used, a P/S alarm is issued.

18 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Modal Information T Series

System Variables for Modal Information


Variable Number Function Group
#4001 G00, G01, G02, G03, G33 01
#4002 G96, G97 02
#4003 03
#4004 04
#4005 G98, G99 05
#4006 G20, G21 06
#4007 G40, G41, G42 07
#4008 08
#4009 G22, G23 09
#4010 G80 – G89 10
#4011 11
#4012 G66, G67 12
#4013 13
#4014 G54 - G59 14
#4015 G61 - G64 15
#4016 G18 16
:
#4022 22
#4109 F Code
#4113 M Code
#4114 Sequence Number N
#4115 Program Number
#4119 S Code
#4120 T Code

Example:
When #1=#4001; is executed, the resulting value in #1 is 0, 1, 2, 3, or 33.
If the specified system variable for reading modal information corresponds to a G
code group that cannot be used, a P/S alarm is issued.

19 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Positioning Information
Position information can be read but not written.

System Variables for Positioning Information


Variable Position Coordinate Tool Read
number information system compensation operation
value during
movement
#5001–#5008 Block end Work piece Not included Enabled
point coordinate
system
#5021–#5028 Current Machine Included Disabled
position coordinate
system
#5041–#5048 Current Work piece
position coordinate
#5061–#5068 Skip signal system Enabled
position
#5081–#5088 Tool length Disabled
offset value
#5101–#5108 Deviated servo
position

The first digit (from 1 to 8) represents an axis number.

Here the axis numbers are as follow:


X=1
Y=2
Z=3
A=4
C=5
Always follow this rule or check parameter
1022.

Example:

We can read the Z axis machine position into #100

#100 = #5023 (As 3 is the number of the Z axis on this machine)

The value stored into #100 will be 2.376

20 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Timers And Counters


Information regarding time, whether it be the actual time or time to complete
something, this can be read using system variables.

System Variables for Time Information


Variable
Function
number
#3001 This variable functions as a timer that counts in 1–millisecond increments
at all times. When the power is turned on, the value of this variable is
reset to 0. When 2147483648 milliseconds is reached, the value of this
timer returns to 0.
#3002 This variable functions as a timer that counts in 1–hour increments when
the cycle start lamp is on. This timer preserves its value even when the
power is turned off. When 9544.371767 hours is reached, the value of
this timer returns to 0
#3011 This variable can be used to read the current date (year/month/day).
Year/month/day information is converted to an apparent decimal number.
For example, September 28, 2001 is represented as 20010928.
#3012 This variable can be used to read the current time (hours/minutes/
seconds). Hours/minutes/seconds information is converted to an
apparent decimal number. For example, 34 minutes and
56 seconds after 3 p.m. is represented as 153456.

As #3001 is constantly running, if we want to use it then we must reset it first.

Example:
#3001=0;
M98 P1000 (CONTOURING CYCLE);
#500=#3001;
#500=#500/1000;

Using these functions it is possible to calculate things such as:

• The percentage of the shift the machine was actually in cycle.


• Cycle time.
• Downtime.
• Creating custom machine warming up cycles.

21 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Creating Alarms
Using system variables we can make the machine stop instantly and display a
custom message.
When a value from 0 to 200 is assigned to variable #3000, the CNC stops with an
alarm. An alarm message not longer than 26 characters can be described. The CRT
screen displays alarm numbers by adding 3000 to the value in variable #3000 along
with an alarm message.

Example:
#3000=1(TOOL LIFE EXPIRED)

22 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Creating Messages
Operator messages are a good way of letting the operator know what is going on in
the program and also any checks or inspections they need to make.
When #3006=1 (MESSAGE); is commanded in the macro, the program executes
blocks up to the immediately previous one and then stops.
A message of up to 26 characters can be displayed. The message can be cleared
with #3006=0.

Example:
#3006=1(CHECK COMPONENT SEATED)

23 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Debugging Macro Programs


The most important thing when writing a macro is to ensure it has all the necessary
information passed to it through the local variables. This information may need to be
checked. E.g. If a negative value has been entered by mistake.

Checking for inputs using #0

#0 is always null or empty, therefore we can say that if a variable is equal to #0 then
the operator has missed passing a local variable into the macro. We can then also
generate an alarm to notify the operator.

Example:

IF[#24EQ#0]THEN#3000=1(X VALUE MISSING);

Restoring Modal And Positional States

Before exiting the macro it is extremely important that the machine is in the same
position it was when it entered the macro. Also all the modal information needs to be
the same too.
Example:

#100=#4003 (Remembers G90 or G91)


G00 G91 X#24
Y#25
X- #24
Y- #25
G#100 (Restores original G90, G91 state)

M99

24 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

FULL SYSTEM VARIABLES LIST


Tool Compensation Values M Series

Tool Compensation Memory A

System Variable Number Description


#2001 - #2200 Tool compensation value
Note: Sets value in a compensation values 1-
200

#10001 - #10999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999

Tool Compensation Memory B when Parameter V15 (6000#3 =0)

System Variable Number Description


#2001 - #2200 Tool compensation value (Wear)
Note: Sets value in a compensation values 1-
200

#10001 - #10999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999
#2201 - #2400 Tool compensation value (Geometry)
Note: Sets value in a compensation values 1-
200

#11001 - #11999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999

25 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Tool Compensation Memory B when Parameter V15 (6000#3 =1)

System Variable Number Description


#2001 - #2200 Tool compensation value (Geometry)
Note: Sets value in a compensation values 1-
200

#10001 - #10999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999
#2201 - #2400 Tool compensation value (Wear)
Note: Sets value in a compensation values 1-
200

#11001 - #11999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999

Tool Compensation Memory C when Parameter V15 (6000#3 =0)

System Variable Number Description


#2001 - #2200 Tool compensation value (H code Wear)
Note: Sets value in a compensation values 1-
200

#10001 - #10999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999
#2201 - #2400 Tool compensation value (H code Geometry)
Note: Sets value in a compensation values 1-
200

#11001 - #11999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999
#12001 - #12999 Tool compensation value (D code Wear)
Note: Sets value in a compensation values 1-
999

#13001 - #13999 Tool compensation value (D code Geometry)


Note: Sets value in a compensation values 1-
999

26 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Tool Compensation Memory C when Parameter V15 (6000#3 =1)

System Variable Number Description


#2001 - #2200 Tool compensation value (H code Geometry)
Note: Sets value in a compensation values 1-
200

#10001 - #10999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999
#2201 - #2400 Tool compensation value (H code Wear)
Note: Sets value in a compensation values 1-
200

#11001 - #11999 Note: If the number of offsets is larger than 200


then the numbers to the left can be used to set
compensation values 1-999
#12001 - #12999 Tool compensation value (D code Geometry)
Note: Sets value in a compensation values 1-
999

#13001 - #13999 Tool compensation value (D code Wear)


Note: Sets value in a compensation values 1-
999

27 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Tool Compensation Values T Series

Without Tool Geometry/Wear Compensation Memory

System Variable Number Description


#2001 - #2064 X Axis compensation value
Note: Sets value in a compensation values 1-
64

#10001 - #10999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2101 - #2164 Z Axis compensation value
Note: Sets value in a compensation values 1-
64

#11001 - #11999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2201 - #2264 Tool nose radius compensation value
Note: Sets value in a compensation values 1-
64

#12001 - #12999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2301 - #2364 Virtual tip position
Note: Sets value in a compensation values 1-
64

#13001 - #13999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2401 - #2449 Y Axis compensation value
Note: Sets value in a compensation values 1-
49

#14001 - #14999 Note: If the number of offsets is larger than 49


then the numbers to the left can be used to set
compensation values 1-999

28 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

With Tool Geometry/Wear Compensation Memory

System Variable Number Description


#2001 - #2064 X Axis compensation value (Wear)
Note: Sets value in a compensation values 1-
64

#10001 - #10999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2101 - #2164 Z Axis compensation value (Wear)
Note: Sets value in a compensation values 1-
64

#11001 - #11999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2201 - #2264 Tool nose radius compensation value (Wear)
Note: Sets value in a compensation values 1-
64

#12001 - #12999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2301 - #2364 Virtual tip position
Note: Sets value in a compensation values 1-
64

#13001 - #13999 Note: If the number of offsets is larger than 64


then the numbers to the left can be used to set
compensation values 1-999
#2401 - #2449 Y Axis compensation value (Wear)
Note: Sets value in a compensation values 1-
49

#14001 - #14999 Note: If the number of offsets is larger than 49


then the numbers to the left can be used to set
compensation values 1-999
#2451 - #2499 Y Axis compensation value (Geometry)
Note: Sets value in a compensation values 1-
49

#19001 - #19999 Note: If the number of offsets is larger than 49


then the numbers to the left can be used to set
compensation values 1-999
#2701 - #2749 X Axis compensation value (Geometry)
Note: Sets value in a compensation values 1-
49

#15001 - #15999 Note: If the number of offsets is larger than 49


then the numbers to the left can be used to set
compensation values 1-999

29 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

With Tool Geometry/Wear Compensation Memory (Cont…)

#2801 - #2849 Z Axis compensation value (Geometry)


Note: Sets value in a compensation values 1-
49

#16001 - #16999 Note: If the number of offsets is larger than 49


then the numbers to the left can be used to set
compensation values 1-999
#2901 - #2964 Tool nose radius compensation value
(Geometry)
Note: Sets value in a compensation values 1-
49

#17001 - #17999 Note: If the number of offsets is larger than 49


then the numbers to the left can be used to set
compensation values 1-999

Work piece Coordinate System Shift Amount

System Variable Number Description


#2501 X-axis work piece shift amount
#2601 Z-axis work piece shift amount

Automatic operation

System Variable Number Description


#3000 Macro Alarm
#3001 Clock 1 (ms)
#3002 Clock 2 (hr)
#3003 Enable or Disable the suppression of single
block stop

Enable or Disable the waiting of the auxiliary


function completion signal
#3003 bit 0 Enable or Disable the suppression of single
block stop
#3003 bit 1 Enable or Disable the waiting of the auxiliary
function completion signal
#3004 Enable or Disable Feed Hold
Enable or Disable Feed rate Override
Enable or Disable Exact Stop Check
#3004 bit 0 Enable or Disable Feed Hold
#3004 bit 1 Enable or Disable Feed rate Override
#3004 bit 2 Enable or Disable Exact Stop Check
#3005 Read / Write setting data
#3006 Stop with a message
#3007 Status of mirror image
#3008 Restarting / not restarting a program

30 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Time

System Variable Number Description


#3011 Year / Month /Day
#3012 Hour /Minute / Second

Number of Parts

System Variable Number Description


#3901 Total number of parts
#3902 Number of parts required

Tool Compensation Memory M Series

System Variable Number Description


#3980 Tool compensation memory information

Main Program Number

System Variable Number Description


#4000 Main program number

31 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Modal Information M Series

System Variable Number Description


#4001 - #4030 Modal information on blocks that have been
specified by last minute (G Code)
#4001 = G code grp 1, #4002 = G code grp 2
#4102 Modal information on blocks that have been
specified by last minute (B Code)
#4107 Modal information on blocks that have been
specified by last minute (D Code)
#4108 Modal information on blocks that have been
specified by last minute (E Code)
#4109 Modal information on blocks that have been
specified by last minute (F Code)
#4111 Modal information on blocks that have been
specified by last minute (H Code)
#4113 Modal information on blocks that have been
specified by last minute (M Code)
#4114 Modal information on blocks that have been
specified by last minute (N sequence Number)
#4115 Modal information on blocks that have been
specified by last minute (Program Number)
#4119 Modal information on blocks that have been
specified by last minute (S Code)
#4120 Modal information on blocks that have been
specified by last minute (T Code)
#4130 Modal information on blocks that have been
specified by last minute (additional work piece
coordinate system number)
#4201 - #4230 Modal information on block currently being
executed (G Code)
#4201 = G code grp 1, #4202 = G code grp 2
#4302 Modal information on block currently being
executed (B Code)
#4307 Modal information on block currently being
executed (D Code)
#4308 Modal information on block currently being
executed (E Code)
#4309 Modal information on block currently being
executed (F Code)
#4311 Modal information on block currently being
executed (H Code)
#4313 Modal information on block currently being
executed (M Code)
#4314 Modal information on block currently being
executed (N sequence Number)
#4315 Modal information on block currently being
executed (Program Number)
#4319 Modal information on block currently being
executed (S Code)
#4320 Modal information on block currently being
executed (T Code)
#4330 Modal information on block currently being
executed (additional work piece coordinate)

32 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Modal Information M Series (Cont…)

#4401 - #4430 Modal information on interrupted blocks (G


Code)
#4401 = G code grp 1, #4402 = G code grp 2
#4502 Modal information on interrupted blocks (B
Code)
#4507 Modal information on interrupted blocks (D
Code)
#4508 Modal information on interrupted blocks (E
Code)
#4509 Modal information on interrupted blocks (F
Code)
#4511 Modal information on interrupted blocks (H
Code)
#4513 Modal information on interrupted blocks (M
Code)
#4514 Modal information on interrupted blocks (N
sequence Number)
#4515 Modal information on interrupted blocks
(Program Number)
#4519 Modal information on interrupted blocks (S
Code)
#4520 Modal information on interrupted blocks (T
Code)
#4530 Modal information on interrupted blocks
(additional work piece coordinate system
number)

33 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Modal Information T Series

System Variable Number Description


#4001 - #4030 Modal information on blocks that have been
specified by last minute (G Code)
#4001 = G code grp 1, #4002 = G code grp 2
#4108 Modal information on blocks that have been
specified by last minute (E Code)
#4109 Modal information on blocks that have been
specified by last minute (F Code)
#4113 Modal information on blocks that have been
specified by last minute (M Code)
#4114 Modal information on blocks that have been
specified by last minute (N sequence Number)
#4115 Modal information on blocks that have been
specified by last minute (Program Number)
#4119 Modal information on blocks that have been
specified by last minute (S Code)
#4120 Modal information on blocks that have been
specified by last minute (T Code)

34 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Modal Information T Series (Cont…)

#4515 Modal information on interrupted blocks


(Program Number)
#4519 Modal information on interrupted blocks (S
Code)
#4520 Modal information on interrupted blocks (T
Code)
#4530 Modal information on interrupted blocks
(additional work piece coordinate system
number)

Position Information

System Variable Number Description


#5001 - #5020 End point position of the previous block (work
piece coordinate system) Axis number 1 – 20

#100001 - #100050 Note: numbers to the left can be used for Axis
number 1 - 50
#5021 - #5040 Specified current position (machine coordinate
system) Axis number 1 – 20

#100051 - #100100 Note: numbers to the left can be used for Axis
number 1 - 50
#5041 - #5060 Specified current position (work piece
coordinate system) Axis number 1 – 20

#100101 - #100150 Note: numbers to the left can be used for Axis
number 1 - 50
#5061 - #5080 Skip position (work piece coordinate system)
Axis number 1 – 20

#100151 - #100200 Note: numbers to the left can be used for Axis
number 1 - 50

Tool Length Compensation Value M Series

System Variable Number Description


#5081 - #5100 Tool compensation value
Axis number 1 – 20

#100201 - #100250 Note: numbers to the left can be used for Axis
number 1 - 50

35 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Tool Offset Value T Series

System Variable Number Description


#5801 X-axis tool offset (Wear)
#5802 Y-axis tool offset (Wear)
#5803 Z-axis tool offset (Wear)
#5121 X-axis tool offset (Geometry)
#5122 Y-axis tool offset (Geometry)
#5123 Z-axis tool offset (Geometry)

Servo Position Deviation

System Variable Number Description


#5101 - #5120 Servo positional deviation
Axis number 1 – 20

#100251 - #100300 Note: numbers to the left can be used for Axis
number 1 - 50

Manual Handle Interruption

System Variable Number Description


#5121 - #5140 Manual Handle Interruption
Axis number 1 – 20

#100651 - #100700 Note: numbers to the left can be used for Axis
number 1 - 50

Distance To Go

System Variable Number Description


#5181 - #2040 Distance To Go
Axis number 1 – 20

#100801 - #100850 Note: numbers to the left can be used for Axis
number 1 - 50

36 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Work piece Origin Offset Value M Series

System Variable Number Description


#5201 - #5220 Common work piece origin offset value
Axis number 1 – 20
#5221 - #5240 G54 work piece origin offset value
Axis number 1 – 20
#5241 - #5260 G55 work piece origin offset value
Axis number 1 – 20
#5261 - #5280 G56 work piece origin offset value
Axis number 1 – 20
#5281 - #5300 G57 work piece origin offset value
Axis number 1 – 20
#5301 - #5320 G58 work piece origin offset value
Axis number 1 – 20
#5321 - #5340 G59 work piece origin offset value
Axis number 1 – 20
#100301 - #100350 Common work piece origin offset value
Axis number 1 – 50
#100351 - #100400 G54 work piece origin offset value
Axis number 1 – 50
#100401 - #100450 G55 work piece origin offset value
Axis number 1 – 50
#100451 - #100500 G56 work piece origin offset value
Axis number 1 – 50
#100501 - #100550 G57 work piece origin offset value
Axis number 1 – 50
#100551 - #100600 G58 work piece origin offset value
Axis number 1 – 50
#100601 - #100650 G59 work piece origin offset value
Axis number 1 – 50

37 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Extended Work piece Origin Offset Value M Series

System Variable Number Description


#7001 - #7020 G54.1 P1 work piece origin offset value
Axis number 1 – 20
#7021 - #7040 G54.1 P2 work piece origin offset value
Axis number 1 – 20
~ ~
~ ~
#7941 - #7960 G54.1 P48 work piece origin offset value
Axis number 1 – 20

#14001 - #14020 G54.1 P1 work piece origin offset value


Axis number 1 – 20
#14051 - #14100 G54.1 P2 work piece origin offset value
Axis number 1 – 20
~ ~
~ ~
#19971 - #20000 G54.1 P300 work piece origin offset value
Axis number 1 – 20

#101001 - #101050 G54.1 P1 work piece origin offset value


Axis number 1 – 50
#101051 - #101100 G54.1 P2 work piece origin offset value
Axis number 1 – 50
~ ~
~ ~
#115951 - #116000 G54.1 P300 work piece origin offset value
Axis number 1 – 50

38 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Work piece Origin Offset Value T Series

System Variable Number Description


#5201 - #5220 Common work piece origin offset value
Axis number 1 – 20
#5221 - #5240 G54 work piece origin offset value
Axis number 1 – 20
#5241 - #5260 G55 work piece origin offset value
Axis number 1 – 20
#5261 - #5280 G56 work piece origin offset value
Axis number 1 – 20
#5281 - #5300 G57 work piece origin offset value
Axis number 1 – 20
#5301 - #5320 G58 work piece origin offset value
Axis number 1 – 20
#5321 - #5340 G59 work piece origin offset value
Axis number 1 – 20
#100301 - #100350 Common work piece origin offset value
Axis number 1 – 50
#100351 - #100400 G54 work piece origin offset value
Axis number 1 – 50
#100401 - #100450 G55 work piece origin offset value
Axis number 1 – 50
#100451 - #100500 G56 work piece origin offset value
Axis number 1 – 50
#100501 - #100550 G57 work piece origin offset value
Axis number 1 – 50
#100551 - #100600 G58 work piece origin offset value
Axis number 1 – 50
#100601 - #100650 G59 work piece origin offset value
Axis number 1 – 50

39 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Extended Work piece Origin Offset Value T Series

System Variable Number Description


#7001 - #7020 G54.1 P1 work piece origin offset value
Axis number 1 – 20
#7021 - #7040 G54.1 P2 work piece origin offset value
Axis number 1 – 20
~ ~
~ ~
#7941 - #7960 G54.1 P48 work piece origin offset value
Axis number 1 – 20

#101001 - #101050 G54.1 P1 work piece origin offset value


Axis number 1 – 50
#101051 - #101100 G54.1 P2 work piece origin offset value
Axis number 1 – 50
~ ~
~ ~
#115951 - #116000 G54.1 P300 work piece origin offset value
Axis number 1 – 50

Skip Position (Detection Unit)

System Variable Number Description


#5241 - #5440 Skip Position (Detection Unit)
Axis number 1 – 20

#100701 - #100750 Note: numbers to the left can be used for Axis
number 1 - 50

40 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Rotary Table Dynamic Fixture Offset Value M Series

System Variable Number Description


#5500 Number of the standard fixture offset being
selected
#5501 - #5520 Offset value of the standard offset being
selected
Axis number 1 – 20

#117001 - #117050 Note: numbers to the left can be used for Axis
number 1 – 50
#5521 - #5540 Standard fixture offset value (1st set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117051 - #117100 number 1 – 50
#5541 - #5560 Standard fixture offset value (2nd set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117101 - #117150 number 1 – 50
#5561 - #5580 Standard fixture offset value (3rd set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117151 - #117200 number 1 - 50
#5581 - #5600 Standard fixture offset value (4th set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117201 - #117250 number 1 – 50
#5601 - #5620 Standard fixture offset value (5th set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117251 - #117300 number 1 – 50
#5621 - #5640 Standard fixture offset value (6th set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117301 - #117350 number 1 – 50
#5641 - #5660 Standard fixture offset value (7th set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117351 - #117400 number 1 – 50
#5661 - #5680 Standard fixture offset value (8th set)
Axis number 1 – 20

Note: numbers to the left can be used for Axis


#117401 - #117450 number 1 – 50

41 Hughes Armstrong Middle East


FANUC CUSTOM MACRO B PROGRAMMING MANUAL www.ha-mideast.com

Dynamic Standard Tool Compensation Value M Series

System Variable Number Description


#118051 - #118100 Dynamic standard tool compensation value
(1st set)
Axis number 1 – 50
#118101 - #118150 Dynamic standard tool compensation value
(2nd set)
Axis number 1 – 50
#118151 - #118200 Dynamic standard tool compensation value
(3rd set)
Axis number 1 – 50
#118201 - #118250 Dynamic standard tool compensation value
(4th set)
Axis number 1 – 50
#118251 - #118300 Dynamic standard tool compensation value
(5th set)
Axis number 1 – 50
#118301 - #118350 Dynamic standard tool compensation value
(6th set)
Axis number 1 – 50
#118351 - #118400 Dynamic standard tool compensation value
(7th set)
Axis number 1 – 50
#118401 - #118450 Dynamic standard tool compensation value
(8th set)
Axis number 1 – 50

System Constant

System Variable Number Description


#0, #3000 NUL
#3101 Circular Constant
π = 3.14159265358979323846
#3102 Base of Natural Logarithm
e = 2.71828182845904523536

42 Hughes Armstrong Middle East

You might also like