Tuesday, February 26, 2019

[CNC Programming Examples] Fanuc Macro Programming

  Thanh A Tran       Tuesday, February 26, 2019
Fanuc Macro Programming

Fanuc Lathe Custom Macro for Peck Drilling

Fanuc Peck Drilling Macro

Move the tool beforehand along the X- and Z-axes to the position where a drilling cycle starts. Specify Z or W for the depth of a hole, K for the depth of a cut, and F for the cutting feedrate to drill the hole.
Following Custom Macro works on Fanuc cnc controls like FANUC Series 30i/31i/32i-MODEL A

Programming

G65 P9100 Z K F
OR
G65 P9100 W K F
Parameter Description
Z Hole depth (absolute programming)
W Hole depth (incremental programming)
K Cutting amount per cycle
F Cutting feedrate



Custom Macro

Main Program

G50 X100.0 Z200.0 ;
G00 X0 Z102.0 S1000 M03 ;
G65 P9100 Z50.0 K20.0 F0.3 ;
G00 X100.0 Z200.0 M05 ;
M30

Macro program

O9100;
#1=0; (Clear the data for the depth of the current hole.)
#2=0; (Clear the data for the depth of the preceding hole.)
IF [#23 NE #0] GOTO 1; (If incremental programming, specifies the jump to N1.)
IF [#26 EQ #0] GOTO 8; (If neither Z nor W is specified, an error occurs.)
#23=#5002-#26;         (Calculates the depth of a hole.)
N1 #1=#1+#6;           (Calculates the depth of the current hole.)
IF [#1 LE #23] GOTO 2; (Determines whether the hole to be cut is too deep?)
#1=#23;                (Clamps at the depth of the current hole.)
N2 G00 W-#2;           (Moves the tool to the depth of the preceding hole at the cutting feedrate.)
G01 W- [#1-#2] F#9;    (Drills the hole.)
G00 W#1;               (Moves the tool to the drilling start point.)
IF [#1 GE #23] GOTO 9; (Checks whether drilling is completed.)
#2=#1;                 (Stores the depth of the current hole.)
N9 M99
N8 #3000=1;            (NOT Z OR U COMMAND Issues an alarm.)


Make your own G81 Drilling Cycle through Fanuc Macro and G66 Modal Call

This is a complete Fanuc Macro which works same as Fanuc G81 Drilling Cycle.

G66 Modal Call

Once Fanuc G66 is issued to specify a modal call a macro is called after a block specifying movement along axes is executed. This continues until G67 is issued to cancel a modal call.

Macro Call Parameters

G65 P9110 X x Y y Z z R r F f L l ;
X: X coordinate of the hole (absolute only) . . . (#24)
Y: Y coordinate of the hole (absolute only) . . . (#25)
Z: Coordinates of position Z (absolute only). . . (#26)
R: Coordinates of position R (absolute only). . . (#18)
F : Cutting feedrate . . . . . . . . . . . . . . . . . . . .. . . (#9)
L: Repetition count

Program Example

O0001;
G28 G91 X0 Y0 Z0;
G92 X0 Y0 Z50.0;
G00 G90 X100.0 Y50.0;
G66 P9110 Z–20.0 R5.0 F500;
G90 X20.0 Y20.0;
X50.0;
Y50.0;
X70.0 Y80.0;
G67;
M30;

Drilling Macro

O9110;
#1=#4001;   (Stores G00/G01)
#3=#4003;   (Stores G90/G91)
#4=#4109;   (Stores the cutting feedrate)
#5=#5003;   (Stores Z coordinate at the start of drilling)
G00 G90 Z#18;   (Positioning at position R)
G01 Z#26 F#9;   (Cutting feed to position Z)
IF[#4010 EQ 98]GOTO 1;  (Return to position I)
G00 Z#18;   (Positioning at position R)
GOTO 2;
N1 G00 Z#5;   (Positioning at position I)
N2 G#1 G#3 F#4;  (Restores modal information)
M99;

Fanuc Bolt Hole Circle Custom Macro (BHC)

 

Drawing/Image



CNC Program

/*Parameters
G65 P9100 Xx Yy Zz Rr Ff Ii Aa Bb Hh
X: X coordinate of the center of the circle (#24)
Y: Y coordinate of the center of the circle (#25)
Z: Hole depth (#26)
R: Coordinates of an approach point (#18)
F: Cutting feedrate (#9)
I: Radius of the circle (#4)
A: Drilling start angle (#1)
B: Incremental angle (Clockwise when negative value) (#2)
H: Number of holes (#11)
*/

O9100
#3=#4003
G81 Z#26 R#18 F#9 K0
IF[#3 EQ 90]GOTO 1
#24=#5001+#24
#25=#5002+#25
N1 WHILE[#11 GT 0]DO 1
#5=#24+#4*COS[#1]
#6=#25+#4*SIN[#1]
G90 X#5 Y#6
#1=#1+#2
#11=#11-1
END 1
G#3 G80
M99

/*Fanuc Bolt Hole Macro Example
Example macro call to drill 5 holes at intervals of 45 degrees
after a start angle of 0 degrees
on the circumference of a circle with radius 4”.
The absolute center of the circle is (10”, 5”).*/
O0002
G90 G92 X0 Y0 Z4.0
G65 P9100 X10.0 Y5.0 R1.0 Z-2.0 F20 I4.0 A0 B45.0 H5
M30



G65 Macro for Internal Elipse

 

Drawing/Image


CNC Program

T1 M6
G0 G90 G40 G21 G17 G94 G80
G54 X0 Y0 S? M3
G43 Z5 H?
G1 Z-? F?
#20 = 2 ; Incremental degree calculation
#21 = 0 ; Start Angle
#22 = 30 ; Y Axis Radius
#23 = 50 ; X Axis Radius
G41 X#23 D? ; Compensation motion to right side of internal pocket
N10 #21 = [#21 + #20] ; Angular Count
#24 = SIN[#21] ; Incremental Y axis calculation
#25 = COS[#21] ; Incremental X axis calculation
#24 = [#24*#22] ; Absolute Y calculation
#25 = [#25*#23] ; Absolute X calculation
X#25 Y#24 ; Movement in X & Y axis
IF [#21 LT 360] GOTO 10 ; Restart if less than 360 degree motion
IF [#21 GT 360] GOTO 20 ; If final angle becomes greater than 360 degrees recalculate
IF [#21 EQ 360] GOTO 30 ; Finish if total angle is equal to 360 degree
N20 #21 = 360
GOTO 10
N30 G40 X0
G0 G90 Z100 M30

G65 Macro for an Increasing Radius

Drawing/Image


CNC Program

;A = #1 (Start Angle 0 degrees)
;B = #2 (Start Radius)
;C = #3 (Increment angle for accuracy calculations.)
;I = #4 (Finish Angle)
;J = #5 (Finish radius)
;K = #6 (Milling feed)

O2222
T5 M6
G0 G90 G40 G21 G17 G94 G80
G54 X35 Y0 S500 M3
G43 Z100 H?
Z5
G1 Z-0.5 F200
G65 P8999 A0 B35 C0.01 I70 J37 K500
G0 G90 Z100 M30

O8999
#7 = #4 / #3 ;1) Total no. of moves 70 / 0.01
#8 = [[#5 - #2] / #7] ;2) Increase in radius 37-35/7000
N1 #2 = #2 + #8 ;3) Next Radius i.e. 35+inc. radius.
#1 = #1 + #3 ;4) Increase in angle
#9 = #2 * COS [ #1 ] ;5) New X axis position
#10 = #2 * SIN [ #1 ] ;6) New Y axis position
G1 X#9 Y#10 F#6 ;7) Feed move to new positions
;8) If new angle is less than finish angle go to line N1.
IF [#1 LT #4] GOTO 1
G0 Z10
M99

G65 Macro for Internal Helical

CNC Program

T? M6 (THREADMILL)
G0 G90 G40 G21 G17 G94 G80
G54 X? Y? S? M3 (Move to bore centre)
G43 Z? H?
;
G65 P1002 A? B? D?
(A = THREAD DIAMETER)
(B = PITCH)
(D = RADIUS OFFSET NUMBER)
M30

O1002
#11=[[#1*0.8]/2]
#12=[[#1/2]-#11]
;
G91 Y#12
G41 X#11 D#7
G3 X-#11 Y#11 R#11 Z#2/4
J-[#1/2] Z#2
X-#11 Y-#11 R#11 Z#2/4
G1 G40 X#11
G0 G90 Z100
M99

G65 Macro for a Counterbore

 

CNC Program

T? M6 (ENDMILL)
G0 G90 G40 G21 G17 G94 G80
G54 X? Y? S? M3 (Move to bore centre)
G43 Z? H?
;
G65 P1001 A? D?
(A = C/BORE DIAMETER)
(D = RADIUS OFFSET NUMBER)
M30

O1001
#11=[[#1*0.8]/2]
#12=[[#1/2]-#11]
G91 Y#12
G41 X#11 D#7
G3 X-#11 Y#11 R#11
J-[#1/2]
X-#11 Y-#11 R#11
G1 G40 X#11
G0 G90 Z100
M99
 
 
 
 


***********************************
logoblog

Thanks for reading [CNC Programming Examples] Fanuc Macro Programming

Previous
« Prev Post

No comments:

Post a Comment

Loading...