You are on page 1of 37

Fanuc

Fanuc Macro Programming

Fanuc (Fanuc Macro Programming)


/ (Custom Macro)
1.
2.

5 ( 5 axis CNC Tool Re-Grinding Machine) (FANUC 16M)

FANUC Operating Manual 16 M (B-62454E/04) 16
CUSTOM MACRO

/


- (Seal Precision Co) CNC.
- ()
- (CNC Parts Co.) ()
- (PTS Precision Tooling Co.)
- / (Submit Engineering Co)
- www.9engineer.com
-


2548

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 2

Fanuc (Fanuc Macro Programming)

................................................................................................................................................................. 5
1 (Variable)................................................................................................................................... 6
1.1 .................................................................................................................................. 6
1.2 ....................................................................................................................................... 6
1.3 .................................................................................................................................. 6
1.4 .................................................................................................................................. 7
1.5 .................................................................................................................................... 7
1.6 .............................................................................................................................. 7
1.7 () .................................................................................................................................... 8
2 (System Variable)............................................................................................................. 9
2.1 Interface Signal....................................................................................................................... 9
2.2 (Tool compensation values) ............................................................................... 9
2.3 Macro Alarms ...................................................................................................................................... 10
2.4 (Time information).............................................................................................................. 11
2.5 Automatic operation control ................................................................................................................ 11
2.6 Setting ............................................................................................................................................ 12
2.7 Mirror Image ........................................................................................................................................ 13
2.8 ................................................................................................................................. 13
2.9 Modal Information................................................................................................................................ 13
2.10 (Current Position) .................................................................................................... 14
2.11 (workpiece zero point offset values)............................................ 15
3 ............................................................................................................................ 16
3.1 ......................................................................................................................................... 16
3.2 ATAN......................................................................................................................................... 16
3.3 Round............................................................................................................................. 17
3.4 / .................................................................................................................... 17
3.5 ................................................................................................................................ 17
3.6 ............................................................................................................................. 17
3.7 ........................................................................................................................ 18
3.8 (Limitations)........................................................................................................................... 18
4 (Macro statement) ............................................................................................... 20
5 .............................................................................................................................. 21
5.1 GOTO......................................................................................................................................... 21
5.2 IF ................................................................................................................................................ 21
5.3 WHILE ................................................................................................................................. 22
loop (Nesting) ............................................................................................................... 22
6 ...................................................................................................................... 24
6.1 (Simple Call, G65)......................................................................................... 24
...................................................................................................................................... 24
SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 3

Fanuc (Fanuc Macro Programming)

........................................................................................................................... 25
......................................................................................................................... 25
6.2 (Modal Call, G66 G67).................................................................................................. 28
6.3 G............................................................................................................................... 29
6.4 M .............................................................................................................................. 30
6.5 M ................................................................................................ 31
6.6 T.................................................................................................. 31
7 .................................................................................................................... 33
9 ................................................................................................................................................ 34
10 ...................................................................................................................... 35
11 (Interruption Type)....................................................................................... 36

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 4

Fanuc (Fanuc Macro Programming)

CUSTOM MACRO (CNC machine)


(Control) (Fanuc) ( Option )

Macro Program NC Program


(Sub Program)

2
1. (Custom Macro Instruction G65, G66)
2. (Custom Macro Body)
1. Custom Macro Instruction (G65,G66)
G65,
G66 Macro Body
2. Custom Macro Body
(NC Program) (Oxxxx)
(Tool Path)
()
/
Macro Program (Sub Program)
Sub Program Macro Body
Main Program
O0001
:
G65 P9010 R50 L2
:
M30

Macro body
O9010
#1 = #18/2
G01 G42 X#1 Y#1 F0.3
G02 X#1 Y-#1 R#1
M99

(R = #18 )

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 5

Fanuc (Fanuc Macro Programming)

1 (Variable)
NC code (G-code)
G01 X100.0
(Macro Program)


MDI (MDI Mode) ()
1.1
# #1 , #10, #100


#[#1+#2-12]

1.2
4 #
Number
#0
#1 - #33

Type
Null
Local
Variables

#100-#149 (#199)
#500-#531 (#999)

Common
Variables

#1000 -

System
Variables

Function
()
(Local Variables)
( Null)
(Power Off), (
Argument)
(Common Variables)
(Power
off) #100 - #149 (Null) #500 - #531
#150 - #199 #532 - #999
option
(system variables)

(current position) (tool
compensation)

1.3
(Local) (Common)
0 1047 10-29 10-29 1047
P/s Alarm No.111 ()

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 6

Fanuc (Fanuc Macro Programming)

1.4

#1 = 123 #1 123.000
1.5

G01 X#1 Y#3 F#3 ;
[ ]
G01 X[#1+#2] F#3 ;

1/1000 mm (0.001)
#1 = 12.3456 ()
G00 X#1 G00 X12.346

() - #
G00 X-#1
(null) #1
= 0 , #2 = null
G00 X#1 Y#2 G00 X0 ;
1.6
(/null)
0 (#0)
1.
#1 = 0 , #2 = null G00 X#1 Y#2 G00 X0 ;
2. ()
<> (Vacant) 0 < > (vacant)
#1 = <vacant>
#1 = 0
#2 = #1
#2 = #1
#2 = <vacant>
#2 = 0
# 2 = #1*5
#2 = #1*5
#2 = 0
#2 = 0
#2 = #1 + #1
#2 = #1 + #1
#2 = 0
#2 = 0

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 7

Fanuc (Fanuc Macro Programming)

3.
<> (Vacant) 0 EQ NE
#1 = <vacant>
#1 = 0
#1 EQ #0
#1 EQ #0

#1 NE 0
#1 NE 0

#1 GE #0
#1 GE #0

#1 GT 0
#1 GT 0

01234 N12345

VARIABLE
NO.
100
101
102
103
104
105
106
107

DATA
123.456
0.000

NO.
108
109
110
111
112
113
114
115

ACTUAL POSITION (RALATIVE)


X
0.000
Z
0.000
MEM **** *** ***
[ MACRO ] [ MENU ]

18:42:15
[ OPR ]
[

DATA

Y
B

0.000
0.000
]

[(OPRT)]

DATA (null)
**** *** *** (overflow)
( 99999999) ( 0.000000001)
1.7 ()
(Program Number), (Sequence Number)
(Optional Block Skip Number)

O#1 ;
/#2 G00 X100.0 ;
N#3 Y200.0 ;

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 8

Fanuc (Fanuc Macro Programming)

2 (System Variable)
(current
position) (tool compensation values)


()
2.1 Interface Signal
(PMC)
Variable Number
Function
#1000 - #1015
16 PMC
#1032
#1000 #1015
#1032 16
#1100 - #1115
PMC #1100
#1132
#1115
#1132
#1133
(#1133) 32 PMC
( 99999999 +99999999 )
Connection Manual (B-62443E-1)
2.2 (Tool compensation values)
(Tool compensation values)
(
Geometric Compensation) (wear compensation)
(Tool Length) (cutter compensation)
200 #2001 #2400
(tool compensation) A
Compensation number
System variable
1
#10001 (#2001)
:
:
200
#10200 (#2200)
:
:
999
#10999

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 9

Fanuc (Fanuc Macro Programming)

(tool compensation) B
Compensation
Geometry compensation Wear compensation
number
1
#11001 (#2201)
#10001 (#2001)
:
:
:
200
#11200 (#2400)
#10200 (#2200)
:
:
:
999
#11999
#10999
(tool compensation) C
Tool Length compensation (H)
Cutter compensation (D)
Compensation
Geometry
Wear compensation Geometry
Wear
number
compensation
compensation compensation
1
#11001 (#2201)
#10001 (#2001)
#13001
#12001
:
:
:
:
:
200
#11201 (#2400)
#10201 (#2200)
:
:
:
:
:
999
#11999
#10999
#13999
#12999
( 200 C )
2.3 Macro Alarms
Variable Number
#3000

Function
#3000 ( 0 200)
26
3000 #3000

#3000 = 1(Tool Not Found)


alarm 3001 (Tool Not Found)

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 10

Fanuc (Fanuc Macro Programming)

2.4 (Time information)


#3001
#3002

#3011
#3012

1 (millisecond)
0 0 2147483648
1 cycle start (
) 0
9544.371767

September 28,1994 19940928
//
3:34:56 pm. (15:34:56 ) 153456

2.5 Automatic operation control



#3003
0
1
2
3
-

Single block

M-S-T function

0
single block single block
(On)
M-S-T ()
function output DEN (Distribution completion
signal) tool tool

#3004
Feed hold
0

SKP. Engineering Service / 01-8135049

Feedrate override

Email: ssuebsak@hotmail.com

Exact stop

Page 11

Fanuc (Fanuc Macro Programming)

feed hold (disabled)


1. feed hold , single block stop mode
#3003
(single block stop not perform)
2. feed hold ,
feed hold (enabled)
feed rate override (disable) feed override 100%
(feed rate override switch)
exact stop (disable)
(cutting) (Exact stop tool )
Tapping
O001;
N1 GOO G91 X#24 Y#25;
N2 Z#18
G04
N3 #3003=3 ;
N4 #3004=7 ;
N5 G01 Z#26 ;
N6 M04 ;
N7 G01 ;
Z-[ROUND[#18]+ROUND[#26] ;
G04 ;
N8 #3004=0 ;
N9 #3003=0 ;
N10 M03 ;
M99 ;

2.6 Setting
setting / (binary)
(decimal number)
#3005
#15

#14

#13

#12

#11

#10

Setting

#9

#8

FCV
#7

#6

#5

#4

#3

Setting

SEQ

#9 (FCV)
#5 (SEQ)
#2 (INI)
#1 (ISO)
#0 (TVC)

: FS15
:
:
: EIA ISO -
: / TV Check (-)

SKP. Engineering Service / 01-8135049

#2

INI

Email: ssuebsak@hotmail.com

#1

ISO

#0

TVC

Page 12

Fanuc (Fanuc Macro Programming)

2.7 Mirror Image


mirror image (axis) #3007
(binary) (decimal)
#3007
#7

8th axis
128

Setting

#6

#5

7th axis
64

6th axis
32

#4

5th axis
16

#3

4th axis
8

#2

3rd axis
4

#1

2ndaxis
2

#0

1st axis
1

0 = / 1 = 2
#3007=3 Mirror image (
)
- mirror image
#3007
#3007 (read only)
P/S Alarm WRITE PROTECTED VARIABE
2.8
Variable Number
Function
#3901

#3902
()

2.9 Modal Information
Modal

Variable Number
#4001

Function
G00, G01, G02, G03, G33 (Group 01)

#4002

G17, G18, G19 (Group 02)

#4003

G90, G91

(Group 03)

G94, G95

(Group 05)

#4006

G20, G21

(Group 06)

#4007

G40, G41, G42 (Group 07)

#4008

G43, G44, G49 (Group 08)

#4009

G73, G74, G76, G80 G89 (Group 09)

#4010

G98, G99

(Group 10)

#4011

G50, G51

(Group 11)

#4012

G65, G66, G67 (Group 12)

#4013

G96, G97

(Group 13)

#4014

G54 G59

(Group 14)

#4015

G61 G64

(Group 15)

#4016

G68, G69

(Group 16)

#4004
#4005

(Group 04)

#4022

SKP. Engineering Service / 01-8135049

(Group 22)

Email: ssuebsak@hotmail.com

Page 13

Fanuc (Fanuc Macro Programming)


Variable Number
#4102

Function
B code

#4107

D code

#4109

F code

#4111

H code

#4113

M code

#4114

Sequence number

#4115

Program number

#4119

S code

#4120

T code

#4130

P code (number of the currently selected additional workpiece


coordinate system)

#1 = #4001 #1 0, 1, 2 ,3, 33
Modal G code (
) P/S alarm
2.10 (Current Position)

Variable Number Position information Coordinate system
Tool
compensation
#5001 - #5008

(workpiece
(Block end point)
coordinate)

#5021 - #5028

(Current position)
(Machine coordinate)
#5041 - #5048

(workpiece
(Current position)
coordinate)
#5061 - #5068
Skip

(Skip signal position)


#5081 - #5088

(Tool length offset)


#5101 - #5108

Servo
- ( 1 8)
- #5081 5088
- G31 (Skip function) (block end point) #5061 #5068 G31 (block end point)
(#5001 - #5008)
- (disabled)
buffer ( Block
)
SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 14

Fanuc (Fanuc Macro Programming)

2.11 (workpiece zero point offset values)


(workpiece zero point offset values)
Variable Number Function
#5201
External workpiece zero offset
:

#5208
#5221

External workpiece zero offset


G54

#5228
#5241

G54
G55

#5248
#5261

G55
G56

#5268
#5281

G56
G57

#5288
#5301

G57
G58

#5308
#5321

G58
G59

#5328
#7001

G59
G54.1 P1

#7008
#7021

G54.1 P2

#7028
:
#7941

:
G54.1 P48

#7948
#14001

G54.1 P1

#14008
#14021

G54.1 P2

#14028
:
#19980

:
G54.1 P300

#19988

** #5201 - #5328 Option #7001 7948 (G54.1 P1


G54.1 P48 ) Option 48 #14001 19988 (G54.1 P1 G54.1 P300)
Option 300 #7001 7948
SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 15

Fanuc (Fanuc Macro Programming)

3


j, k I

Function
Format
Remarks
/
#I = #j
(Sum)
#I = #j + #k ;
#I = #j - #k ;
(Difference)
#I = #j * #k ;
(Product)
#I = #j / #k ;
(Quotient)
#I = SIN[#j] ;

Sine
#I = COS[#j] ;
Cosine
90 30
90.5
#I = TAN[#j] ;
Tangent
#I = ATAN[#j] / [#k] ;
Arctangent
(Square root)
#I = SQRT[#j] ;
(Absolute value) #I = ABS[#j] ;
(Round off)
#I = ROUND[#j] ;
#I = FIX[#j] ;
(Round down)
#I = FUP[#j] ;
(Round up)
(OR)
#I = #j OR #k ;

(XOR)
#I = #j XOR #k ;

#I = #j AND #k ;
(AND)
#I = BIN[#j] ;
BCD BIN

#I = BCD[#j] ;
PMC
BIN BCD

BCD (binary character data) ( 1, 0)


BIN (binary data) binary on off
3.1
SIN, COS, TAN ATAN
90 30 = 90.5
3.2 ATAN
ATAN ( / )
0 360

#1 = ATAN[1] / [-1] #1 = 135.0

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 16

Fanuc (Fanuc Macro Programming)

3.3 Round
( IF WHILE)

#2 1.2345
#1 = ROUND(#2) #1 = 1.0
NC statement (G-code)
= 0.0001 = 0.001 mm.

#1 = 1.2345
#2 = 2.3456
G00 G91 X-#1 ;
1.235 .
G01 X-#2 F300 ;
2.346 .
G00 X[#1+#2] ;
3.580 . ( 1.2345 + 2.3456 = 3.5801 )
1.235 + 2.346 = 3.581 .
G00 X-[ROUND[#1] + ROUND[#2]]
3.4 /
(round up / FUP) (round down / FIX) CNC

#1 = 1.2 , #2 = -1.2
#3 = FUP[#1] #3 2
#3 = FIX[#1] #3 1
#3 = FUP[#2] #3 -2
#3 = FIX[#2] #3 -1
3.5

ROUND -> RO
FIX -> FI
3.6
( * , / , AND )
( + , - , OR, XOR )

#1 = #2 + #3 * SIN[#4]
-- 1 ------- 2 ---------------- 3 --------- 1 , 2 3
SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 17

Fanuc (Fanuc Macro Programming)

3.7
( [ ] )
5 5 P/S Alarm
No.118
#1 = SIN[ [ [#2+#3]*#4+#5]*#6]
--- 1
----- 2 -------------- 3 ------------------- 4 ------------------------ 5 ----------------3.8 (Limitations)

[ ] ( )
comments

(error)
Operation Average error
a = b*c
1.55 x 10-10
a=b/c
4.66 x 10-10
a = b
1.24 x 10-9
a=b+c
2.33 x 10-10
a=bc
a = SIN[b]
5.0 x 10-9
a = COS[b]
1.8 x 10-6
a = ATAN[b] / [c]

Maximum error
4.66 x 10-10
1.88 x 10-9
3.73 x 10-9
5.32 x 10-10
1.0 x 10-8
3.6 x 10-6

error
Relative error (1)
/a
(2)
Min/b /c

Absolute error (3)


degree

(*4)

1.
2.
3.
4.

Relative error (operation)


error

TAN SIN/COS

8
#1 = 9876543210123.456
#2 = 9876543277777.777

#1 = 9876543200000.000
#2 = 9876543300000.000
#3 = #2 - #1 #3 = 100000.000
( )

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 18

Fanuc (Fanuc Macro Programming)


(low limit value)
IF [ABS[#1 - #2] LT 0.001




#2 = #1 * 1000 #1 = 0.002
#2 2 1.99999997
#3 = FIX[#2] = 2 = 1

TAN[90] P/S Alarm No.112

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 19

Fanuc (Fanuc Macro Programming)

4 (Macro statement)
(block) NC Program (Macro statement)
- ( = )
- GOTO, DO, END
- G65, G66, G67 G-Code, M-code (
)
1. NC
(single block mode) ( single block SMB
No.6000 = 1)
NC
(cutter compensation mode) ( 7)
2. NC
NC (subprogram call) M98, M T code )
O, N, L
(block) O, N, P L

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 20

Fanuc (Fanuc Macro Programming)

5
GOTO, IF
3
- GOTO
- IF

- WHILE
5.1 GOTO

1 99999 P/S Alarm No.128

GOTO n ; n = sequence number ( 1 99999)

GOTO1 ;
GOTO#10 ;
5.2 IF
IF

IF [#1 GT 10] GOTO2 ; ( #1 10 N2)


: ( )
N2 G00 G91 X10.0 ;
:

1. ( [ , ] )
2. 2 , ,


EQ

NE

GT

GE

LT

LE

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 21

Fanuc (Fanuc Macro Programming)

10
O9500
#1 = 0
#2 = 1
N1 IF[#2 GT 10] GOTO2 ; ( #2 10 N2 )
#1=#1+#2 ( #1 )
#2=#2+#1 ( #2 )
GOTO1 ( )
N2 M30; ( End of Program )
5.3 WHILE
WHILE ()
DO END END

WHILE [ ] DO m ; ( m = 1,2,3)
: END
END m;
: END
DO END 1, 2, 3 P/S Alarm No.126
loop (Nesting)
1 3 DO END loop
3 P/S Alarm No.124

1. 1,2,3
WHILE [ . ] DO1;
:
END1
WHILE [ ] DO1 ;
:
END1;

2. (Loop)
WHILE [ ] DO1;
:
WHILE [] DO2 ;
:
END1 ;
:
END2 ;

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 22

Fanuc (Fanuc Macro Programming)

3. (loop) 3
WHILE [ ] DO1;
:
WHILE [] DO2;
:
WHILE [] DO3;
:
END3 ;
:
END 2 ;
:
END1 ;

4.
WHILE [ ] DO1;
:
IF [] GOTO n ;
:
END1 ;
:
Nn

5.
IF [ ] GOTO n;
:
WHILE [] DO1 ;
:
Nn
:
END1 ;

WHILE DO END
GOTO WHILE
EQ NE (zero) (vacant)
vacant (zero)

10 ()
O0001
#1 = 0 ;
#2 = 1 ;
WHILE [#2 LE 10] DO1 ;
#1=#1+#2 ;
#2=#2+#1 ;
END1 ;
M30;

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 23

Fanuc (Fanuc Macro Programming)

6

- (G65)
- Modal (G66, G67)
- G code
- M code
- M code
- T code
(macro) (sub program)
G65 M98
- G65 () M98
- M98 NC (
G01 X100.0 M98 Pp) G65
- M98 NC single block G65
single block (block)
6.1 (Simple Call, G65)
G65 P
(argument)
G65 Pp L l <argument-specification>
: p =
l = ( 1 )
argument =

O001 ;
O9010
:
#3 = #1+#2
G65 p9010 L2 A1.0 B2.0
IF [#3 GT 360] GOTO9
:
G00 G91 X#3 ;
M30 ;
N9 M99 ;

1. G65 P
2. 1 9999 L L 1
3. (
)
4. G65 (Local Variable) M98
()

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 24

Fanuc (Fanuc Macro Programming)

(argument)
2
1 (TYPE I)
Address
A
B
C
D
E
F
H

Variable
Number
#1
#2
#3
#7
#8
#9
#11

Address
I
J
K
M
Q
R
S

Variable
Number
#4
#5
#6
#13
#17
#18
#19

Address
T
U
V
W
X
Y
Z

Variable
Number
#20
#21
#22
#23
#24
#25
#26

1 G, L, N, O, P ()
Null ()

2 (TYPE II)
A,B,C I,J,K 10 (3-Dimension)
Address
A
B
C
I1
J1
K1
I2
J2
K2
I3
J3

Variable
Number
#1
#2
#3
#4
#5
#6
#7
#8
#9
#10
#11

Address
K3
I4
J4
K4
I5
J5
K5
I6
J6
K6
I7

Variable
Number
#12
#13
#14
#15
#16
#17
#18
#19
#20
#21
#22

Address
J7
K7
I8
J8
K8
I9
J9
K9
I10
J10
K10

Variable
Number
#23
#24
#25
#26
#27
#28
#29
#30
#31
#32
#33

1. G65
2.

3.

2 2.0 0.002
4. (Nesting) 4 G65
G66 M98

1. 0 4 ()
2. ( Main Program) 0
3. () G65 G66
1

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 25

Fanuc (Fanuc Macro Programming)

4. M99 1

Main Program
(level 0)
O0001;
:
#1 = 1 ;
G65 P2 A2 ;
:
:
M30 ;
Local Variable
(level 0)
#1
1
:
:
#33

macro(level 1)
O0002 ;
:
:
G65 P3 A3
:
:
M99 ;

macro(level 2)
O0003 ;
:
:
G65 P4 A4
:
:
M99 ;

macro(level 3)
O0004 ;
:
:
G65 P5 A5
:
:
M99 ;

macro(level 4)
O0005 :
:
:
:
:
:
M99 ;

(level 1)
#1
2
:
:
#33

(level 2)
#1
3
:
:
#33

(level 3)
#1
4
:
:
#33

(level 4)
#1
5
:
:
#33

Common Variable
#100 - , #500 -

(H) (I) (A)


(B) (X,Y)

G65 P9100 Xx Yy Zz Rr Ff Ii Aa Bb Hh ;
X = X (#24)
Y = Y (#25)
Z = (#26)
R = (#18)
F = (#9)
I = (#4)
A = (#1)
B = (#2) ( )
H =

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 26

Fanuc (Fanuc Macro Programming)

( Main Program )
O0002;
G90 G92 X0 Y0 Z100.0;
G65 P9100 X100.0 Y50.0 R30.0 Z-50.0 F500 I100.0 A0 B45.0 H5;
M30;
( )
O9100;
#3=#4003;
( G 3 )
G81 Z#26 R#18 F#9 K0 ( / L0 K0 )
IF[#3 EQ 90] GOTO1;
( N1 Mode G90)
#24=#5001+#24;
( X)
#25=#5002+#25;
( Y)
N1 WHILE[#11 GT 0]DO1; ( 0 )
#5=#24+#4*COS[#1];
( X )
#6=#25+#4*SIN[#1];
( X )
G90 X#5 Y#6;
( )
#1=#1+#2
( )
#11=#11-1
( )
END1;
G#3 G80;
( G )
M99;

#3 G 3 (G-code Group 3)
#5 X
#6 Y

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 27

Fanuc (Fanuc Macro Programming)

6.2 Modal Call, G66 G67


MODAL Modus (manner) CNC Program

G66 Modal
G67

G66 Pp L l <agrument-specification>
p :
l : ( 1 )
agrument :
O0001 ;
:
G66 P9010 L2 A1.0 B2.0 ;
G00 G90 X100.0 ;
Y200.0 ;
X150.0 Y300.0 ;
G67 ;
:
M30 ;

O9010 ;
:
G00 Z-#1 ;
G01 Z-#2 F300 ;
:
:
:
:
M99 ;

G66 P
( 1 9999 )
G65
G67 modal

(Nesting)
4 G65 Modal G66
(subprogram) M98
Modal Call Nesting ( Modal )
Modal G66

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 28

Fanuc (Fanuc Macro Programming)

6.3 G
G
G65
O0001;
:
G81 X10.0 Y20.0 Z-10.0;
:
M30;
No. 6050 = 81

O9010;
:
:
:
N9 M99;

1 9999 6050 6059 G


O9010 O9019 ( G-code )
G65
81 6050 G81 O9010

Program Number
O9010
O9011
O9012
O9013
O9014
O9015
O9016
SKP. Engineering Service / 01-8135049

Parameter Number
6050
6051
6052
6053
6054
6055
6056

Email: ssuebsak@hotmail.com

Page 29

Fanuc (Fanuc Macro Programming)


O9017
O9018
O9019

6057
6058
6059

- L 1 9999
-
- (Nesting)
M T code G-code

6.4 M
M G65
O0001;
:
M50 A1.0 B2.0;
:
M30;

O9020;
:
:
:
M99;

No. 6080 = 50
6080 6089 1 99999999
9020 9029 G65

Program Number
O9020
O9021
O9022
O9023
O9024
O9025
O9026
O9027
O9028
O9029

Parameter Number
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089

- L 1 9999
-

M
G code

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 30

Fanuc (Fanuc Macro Programming)

6.5 M
M M98

O0001;
:
M03 ;
:
M30;

O9001;
:
:
:
M99;

No. 6071 = 03
1 99999999 6071 6079
O9001 O9009 (Sub Program) M98

Program Number
O9001
O9002
O9003
O9004
O9005
O9006
O9007
O9008
O9009

Parameter Number
6071
6072
6073
6074
6075
6076
6077
6078
6079

- L 1 9999
-
- M

- G code M T
M G code
6.6 T
T

O0001;
:
T23 ;
:
M30;

O9000;
:
:
:
M99;

Bit 5 No. 6001 = 1


- O9000 5 TCS
6001 1 #149 #149 = 23
SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 31

Fanuc (Fanuc Macro Programming)

- G code M T T
T code

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 32

Fanuc (Fanuc Macro Programming)

7

Buffering
(Compensation G41, G42)
2 - 3


M00, M01, M02, M30, M-code 3411 - 3420, G31

Buffer

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 33

Fanuc (Fanuc Macro Programming)

9

- MDI
-
( Sequence number)
- Single Block
- Optional Block skip
- Edit Mode
- Reset
- Feed Hold
-
( expression )

MDI
MDI


+0.0000001 +99999999
-99999999 -0.0000001
8
P/S Alarm No.003

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 34

Fanuc (Fanuc Macro Programming)

10
(Output Command to External )

- BPRINT
- DPRINT
- POPEN
- PCLOS
Reader/Puncher

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 35

Fanuc (Fanuc Macro Programming)

11 (Interruption Type)

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 36

Fanuc (Fanuc Macro Programming)





1.
2.
3.
4.
5.
6.
7.
8.

( System Analyzes )
Flow Chart
( Variable )
Loop
- ( If cause )

ASC II

Computer Programming

G-Code

lock
( lock )

SKP. Engineering Service / 01-8135049

Email: ssuebsak@hotmail.com

Page 37

You might also like