Macro " B " Programming: Makino Asia Pte LTD Application Department
Macro " B " Programming: Makino Asia Pte LTD Application Department
Macro " B " Programming: Makino Asia Pte LTD Application Department
1
Description
This course is designed to enable the programmer
to use the control’s powerful Macro programming
feature on milling machines
Students will lean to read and write repetitive
machining cycle
Will understand the components of the macro body
and the meaning of the macro call command like
G65, G66 and G67
2
Back to basic = Speed & Feed
3
V * 318 V * 1000
Spee = or
Dia Dia * π ( 3.1412 )
4
Chip Thickness
Feed per tooth
Depth of cut
Chip Thickness
5
Feed Per Tooth
&
Feed Per Revolution
6
Calculation of Speed & Feed
If Ball nose = 10 mm ( 2 teeth )
Cutting speed = 200 m/min ( V )
Feed per tooth = 0.1 mm ( Sz )
Answer is
Speed = 200 * 318 / 10
= 6360 ( rpm )
Feed = 6360 * 2 * 0.1
= 1272 mm/min
if feed reduce to 50% mean
F636, Sz = 0.05
7
Up Cut & Down Cut
I ma ge
No M irror
8
GROUP PROGRAM
Example
O3200 ( Main Program ) like O1000, O100
O3201 ( Sub Program )
O3202 ( Sub Program )
O3203 ( Sub Program )
9
Statement Example
Answer
#1 = 123.
#2 = #1 123.
#3 = #2 + 10 133.
10
Arithmetic Expression
Answer
if #1 = 8.
# [ #1 ] #8
if #1 = 10.
# [ 100 + #1 ] = 123. #110 = 123.
# [ 10 + #110 ] = #1 #133 = 10.
#100 = #133 + #110 #100 = 133.
#[ #133 ] = #[ #100 ] + #1 #10 = 20.
11
Arithmetic Operation Commands I
#1 = 123. #1 = #2
#1 = #2 + 10. #1 = #2 + #3
#1 = #2 - 10. #1 = #2 - #3
#1 = #2 * 10. #1 = #2 * #3
#1 = #2 / 10. #1 = #2 / #3
#1 = SIN [ 90 ] #1 = SIN [ #2 ]
#1 = COS [ 90 ] #1 = COS [ #2 ]
#1 = TAN [ 90 ] #1 = TAN [ #2 ]
#1 = ATAN [ 1 ] / [ 1 ] #1 = ATAN [ #1 ] / [ #2 ]
12
Differ Control For ATAN
( unit = degree )
13
Arithmetic Operation Commands II
Answer
If
#1 = SQRT [ #2 ] #2 = 2 #1 = 1.4142
If #1 = 12.3456 Case
#10 = 12.3758 Answer
15
Example function of “ROUND”
Example
#10 = 12.3758
Answer
#12 = 5.1236
X-[ ROUND[#10] + ROUND[#12] ] X -17.50
or
#10 = ROUND [ #10 * 1000 ] / 1000
#12 = ROUND [ #12 * 1000 ] / 1000
X-[ #10 + #12 ] X -17.50
16
Learning Activity
If #100 = 11. #101 = 25.
#102 = -1.2345 #103 = 2.3456 Answer
#104 = ABS [#102] = 1.2345
#105 = ROUND [#103] = 2.0
#106 = FIX [#102] = - 1.0
#107 = FUP [#102] = - 2.0
#108 = #100 + #101 = 36.0
#109 = #101 - #102 = 26.2345
G91 G00 X#102 move X-1.234
X#103 move X 2.346
X- [#102 + #103] move X-1.111
17
Empty Variable “ #0 “
“ #0 ” mean Empty or Vacant
“0” is a Value
Example :-
#100 = #0
Answer
#102 = 0
G90 G1 X#100 F500 Axis no move
G90 G1 X#102 F500 Axis move X0
18
Repeat Function ( IF )
Condition
IF / GOTO Statement EQ NE GT
GE LT LE
N1 IF [ #1 GT #2 ] GOTO 2
Not OK
#1 = #1 + 1
OK
GOTO 1
N2 M99
19
Repeat Function ( WHILE )
WHILE [ #1 LT #2 ] DO1
OK
#1 = #1 + 1
Not OK
END1
M99
20
Rules For DO and END
DO 1 DO 1 GOTO 1
GOTO 10 DO 2 DO 1
END 1 END 2 N1
N 10 END 1 END 1
21
Exercises 1 ( IF condition )
#1 = 1
N1 IF [ #1 10 ] GOTO 2
Answer
Process
GT
what happen
GE
#1 = #1 + 1
GOTO 1
N2 M30
22
Exercises 2 ( WHILE condition )
#1 = 0
WHILE [ #1 10 ] DO 2
Answer Process
LT
#1 = #1 + 1
END 2
M30
23
Exercises 3 ( Clear by IF )
%
O100 ( IF ) #100 = #0
#1 = 100. ( START ) #101 = #0
#102 = #0
#2 = 110. ( END )
#103 = #0
N3 IF [ #1 GT #2 ] GOTO 7 #104 = #0
# [ #1 ] = #0 #105 = #0
#1 = #1 +1 #106 = #0
GOTO 3 #107 = #0
#108 = #0
N7 M30
#109 = #0
% #110 = #0
24
Exercises 4 ( Clear by WHILE )
%
O100 ( WHILE ) #100 = #0
#1 = 100. ( START ) #101 = #0
#102 = #0
#2 = 110. ( END )
#103 = #0
WHILE [ #1 LE #2 ] DO1 #104 = #0
# [ #1 ] = #0 #105 = #0
#1 = #1 +1 #106 = #0
END1 #107 = #0
#108 = #0
M30
#109 = #0
% #110 = #0
25
Exercises 5 ( Rewrite Tool Pot )
O100 ( REWRITE TOOL POT NUMBER )
/ M57 ( TOOL NUMBER WRITR)
/ T00 ( CLEARING TOOL NUMBER ) Pot 1 = T1
/ M30 Pot 2 = T2
Pot 3 = T3
M57 Pot 4 = T4
#1 = 1 .
WHILE [ #1 LT 60 ] DO1 .
.
T#1
.
#1 = #1 + 1 .
END1 Pot 60 = T60
M30
26
Exercises 6
#101 = 1.000 (1)
#102 = 1.414 (2)
#103 = 1.732 (3)
#104 = 2.000 (4)
#105 = 2.236 (5)
#106 = 2.449 (6)
#107 = 2.646 (7)
#108 = 2.828 (8)
#109 = 3.000 (9)
#110 = 3.162 ( 10 )
Using WHILE condition and ROUND + SQRT command
27
Exercises 6 ( ROUND + SQRT )
#101 = 1.000 (1)
O100 ( SQRT ) #102 = 1.414 (2)
#103 = 1.732 (3)
#1 = 101. ( START ) #104 = 2.000 (4)
#105 = 2.236 (5)
#2 = 110. ( END ) #106 = 2.449 (6)
#107 = 2.646 (7)
#3 = 1. ( SQRT [ #3 ] ) #108 = 2.828 (8)
#109 = 3.000 (9)
WHILE [ #1 LE #2 ] DO1 #110 = 3.162 (10)
28
Exercise 7 ( Positioning )
O800 ( MAIN PROGRAM )
G90 G0 G54 X0 Y0
G43 H1 Z50. S1200 M3
G81 Z-1.5 R2. F100 L0 K0
M98 P801
G80
G91 G0 G28 Z0
M30
M99
29
Illustration ( Positioning cycle )
O801 ( LINER BOLT HOLE )
#24 = 50. ( X Position )
#25 = 30. ( Y Position )
#1 = 30. ( Angle )
#21 = 20. ( Distance )
#11 = 4. ( No Of Hole )
#30 = 0 ( Counter )
WHILE [ #30 LT #11 ] DO1
#4 = [#21* #30] * COS [#1] + #24
30
#5 = [#21* #30] * SIN [#1] + #25
#
G90 X#4 Y#5 #5 ( Y )
*
21
#30 = #30 +1
#
#1
END1
M99 #4 ( X )
30
Exercise 8 ( Drill Depth Cycle )
O800 ( MAIN PROGRAM )
G90 G0 G54 X0 Y0 R point
G43 H1 Z50. S1200 M3
Z0
G0 X10. Y-10.
M98 P803
G91 G0 G28 Z0
M30 Q
M99
d = 1mm Depth Z
31
Illustration ( Drill Depth Cycle )
O803 ( DRILL DEPTH CYCLE )
#26 = 20. ( Z = Depth )
#18 = 2. ( R = R Point )
#9 = 100. ( F = Feed Rate )
R point
#17 = 1.5 ( Q = Depth Of Cut )
#33=0 ( Set ) Z0
G90 G0 Z#18
DO1
#33 = #33 + ABS[#17] Q
IF [ #33 LT ABS[#26] ] GOTO 11
#33 = ABS[#26]
N11 G90 G1 Z-#33 F#9 d
G0 Z#18
IF [ #33 EQ #26 ] GOTO99
G0 Z [ 1-#33 ] Depth Z
END1
N99 M99
32
Type System Variable
Tool Compensation #2001 ~ #2200
Work Offset #5201 ~ #5328
Macro Alarm #3000
Clock Information #3001, #3002
Auto operation control #3003, #3004
Model Information #4000 ~ #4120
Position Information #5001 ~ #5065
33
Tool Offset ( Type A )
Offset Variable No > 200
1 #2001 - #10001
2 #2002 - #10002
99 #2099 - #10099
200 #2200 - #10200
34
Example Tool Offset ( A )
Offset Page
Use “ D “ Offset H16
G90 G10 P31 R10. H17
same
H31 10.0
#2032 = 5.2
H32 5.2
35
Tool Offset ( Type C )
Offset H D
Geometry Wear Geometry Wear
1 #2001 #2201 #2401 #2601
2 #2002 #2202 #2402 #2602
37
Example Work Offset
G90 G10 L2 P1 X- 230.0 Y- 452.032 Z- 450.123
same
#5221 = - 230.0 (X) P0 X 0.000
#5222 = - 452.032 ( Y ) Y 0.000
#5223 = - 450.123 ( Z ) Z 0.000
P1 X - 230.000
P1=G54, P2=G55, P3=G56 Y - 452.032
P4=G57, P5=G58, P6=G59 Z - 450.123
38
Model Information
Variable Code Variable Code
#4000~21 G code #4113 M code
#4102 B code #4114 Sequence no
#4107 D code #4115 Program no
#4108 E code #4119 S code
#4109 F code #4120 T code
#4111 H code #4130 G54.1 P1~48
Refer to Manual
39
G Code List
Refer to Manual
40
Position Information #5001 ~ #5066
Read during movement
42
Alarm Message #3000
#100 = #0
IF [ #100 NE #0 ] GOTO 100
#3000 = 140 ( DATA ERROR )
N100 M99
Less than 26 character
n = 1 ~ 999
43
Clock #3001~#3002
Clock 1 #3001 1 msec. ( unit )
Clock 2 #3002 1 hour ( unit )
Example 1 Example 2
G65 P9010 T20. O1000
#3002 = 0 ( initial )
O9010 G0 X10. Y10.
#3001 = 0 ( initial ) G1 X100 F500
#20 = #20 * 1000
WHILE [ #3001 LE #20 ] DO1
END1 #100 = #3002 * 60 ( min )
M99 M99
44
Date / Time #3011~#3012
#3011 Year / Month / Day
#3012 Hour / Minute / Second
Example
Date : 1987.5.20
#3011 = 19870520
Time : 4 : 17 : 05 PM
#3012 = 161705
45
Parts Counting #3901~#3902
#3901 Total number of parts
#3902 Required number of parts
O1000
#3902 = 50. ( required parts )
IF [ #3901 EQ #3902 ] GOTO 3000
GOTO 99
N3000 #3000 = 140 ( PART FINISH )
N99 M30
( Initial Total part = 0 and the counter execution when M30 occurs )
46
Single Block #3003
#3003 Single block Function
0 Not suppressed Awaited
1 Suppressed Awaited
2 Not suppressed Not Awaited
3 Suppressed Not Awaited
47
Feed hold, Override, Exact stop #3004
#3004 Feed hold Feed rate override Exact stop check
0
1
2
3
4
5
6
7
: Effective
48
Model Call A ( G66, G67 )
O1000 ( MAIN PROGRAM )
G90 G54 G0 X0 Y0
G43 H1 Z50. S1000 M3
G0 Z5.
G66 P1001 X80. Y60. Z5. F500
G0 X-150. Y35.
G0 X100. Y70. X-150. Y35.
G0 X-30. Y-140. 60
5
G67
G91 G0 G28 Z0
80
M30
56
Sequence of G66, G67
G66 P1001 X80. Y60. Z5. F500 #1 #17
#2 #18
G0 X-150. Y35.
#3 #19
G0 X100. Y70. #4 #20
G0 X-30. Y-140. #5 #21
#6 #22
G67 #7 #23
#8 #24 80.
1 - read variable G66 P1001 X Y Z F #9 500. #25 60.
2 - move position G0 X-150. Y35. #10 #26 5.
#11 #27
3 - call macro program O1001 #12 #28
4 - back to and move G0 X100. Y70. #13 #29
#14 #30
5 - call macro program O1001
#15 #31
6 - back to and move G0 X-30. Y-140. #16 #32
7 - call macro program O1001
8 - back to G67 cancelled macro
57
Sample for Macro Body
O1001 ( SUB MACRO )
IF [ #24 * #25 * #9 * #26 NE 0 ] GOTO 10
#3000 = 140 ( DATA ERROR )
N10 #31 = #4003 ( G90,G91 )
G90 G1 Z - [ ABS [ #26 ] ] F#9
G91 G1 X #24
Y #25
X- #24
Y- #25
G90 G0 Z5.
G#31 M99
58
Macro Call with “G” code
Set parameter
O9010 -- #6050
☯ G65 P9011 X10. Y10. Z5.
O9011 -- #6051 -- 102
F500 O9012 -- #6052
same O9013 -- #6053
O9014 -- #6054
☯ G102 X10. Y10. Z5. F500 O9015 -- #6055
O9016 -- #6056
O9017 -- #6057
O9018 -- #6058
O9019 -- #6059
59
Macro call with “M” code
Set parameter
Create O9020 program O9020 -- #6080 -- 6
and use M6 to call tool O9021 -- #6081 -- 90
O9022 -- #6082 -- 91
change program O9023 -- #6083 -- 60
O9024 -- #6084
☯ G65 P9021 X10. Y10. M8. O9025 -- #6085
O9026 -- #6086
same
O9027 -- #6087
O9028 -- #6088
☯ M90 X10. Y10. M8.
O9029 -- #6089
60
External Output Command
POPEN ( connection to I/O )
BPRNT ( output binary )
DPRNT ( output EIA or ISO codes )
PCLOS ( disconnection from I/O )
Command format
POPEN
DPRNT [ a #b [ c d ] ...]
PCLOS No of digits below decimal point
No of digits above decimal point
Variable
Character
Refer to Manual
61
Printout Layout
when #120 LE #1
--- OK ---
62
Model Call A ( G66, G67 )
O1000 ( MAIN PROGRAM )
G90 G54 G0 X0 Y0
G43 H1 Z50. S1000 M3
G0 Z5.
G66 P1001 X80. Y60. Z5. F500
G0 X-150. Y35.
G0 X100. Y70. X-150. Y35.
G0 X-30. Y-140. 60
5
G67
G91 G0 G28 Z0
80
M30
56
Sequence of G66, G67
G66 P1001 X80. Y60. Z5. F500 #1 #17
#2 #18
G0 X-150. Y35.
#3 #19
G0 X100. Y70. #4 #20
G0 X-30. Y-140. #5 #21
#6 #22
G67 #7 #23
#8 #24 80.
1 - read variable G66 P1001 X Y Z F #9 500. #25 60.
2 - move position G0 X-150. Y35. #10 #26 5.
#11 #27
3 - call macro program O1001 #12 #28
4 - back to and move G0 X100. Y70. #13 #29
#14 #30
5 - call macro program O1001
#15 #31
6 - back to and move G0 X-30. Y-140. #16 #32
7 - call macro program O1001
8 - back to G67 cancelled macro
57
Sample for Macro Body
O1001 ( SUB MACRO )
IF [ #24 * #25 * #9 * #26 NE 0 ] GOTO 10
#3000 = 140 ( DATA ERROR )
N10 #31 = #4003 ( G90,G91 )
G90 G1 Z - [ ABS [ #26 ] ] F#9
G91 G1 X #24
Y #25
X- #24
Y- #25
G90 G0 Z5.
G#31 M99
58
Macro Call with “G” code
Set parameter
O9010 -- #6050
☯ G65 P9011 X10. Y10. Z5.
O9011 -- #6051 -- 102
F500 O9012 -- #6052
same O9013 -- #6053
O9014 -- #6054
☯ G102 X10. Y10. Z5. F500 O9015 -- #6055
O9016 -- #6056
O9017 -- #6057
O9018 -- #6058
O9019 -- #6059
59
Macro call with “M” code
Set parameter
Create O9020 program O9020 -- #6080 -- 6
and use M6 to call tool O9021 -- #6081 -- 90
O9022 -- #6082 -- 91
change program O9023 -- #6083 -- 60
O9024 -- #6084
☯ G65 P9021 X10. Y10. M8. O9025 -- #6085
O9026 -- #6086
same
O9027 -- #6087
O9028 -- #6088
☯ M90 X10. Y10. M8.
O9029 -- #6089
60
External Output Command
POPEN ( connection to I/O )
BPRNT ( output binary )
DPRNT ( output EIA or ISO codes )
PCLOS ( disconnection from I/O )
Command format
POPEN
DPRNT [ a #b [ c d ] ...]
PCLOS No of digits below decimal point
No of digits above decimal point
Variable
Character
Refer to Manual
61
Printout Layout
when #120 LE #1
--- OK ---
62
Printout Program
POPEN --- MAKINO ---
DPRNT [ --- MAKINO --- ] CIRCLE NO 12
DPRNT [ * ]
+X 0.123 -X 0.321
DPRNT [ *** CIRCLE *** NO #18 [40]] +Y 0.213 -Y 0.132
64
Create M91 for Tool Home
O9022 ( M91 TOOL HOME #6082 )
G80 G40 M5
G91 G0 G28 Z0 M9
G49
G90 G0 G53 X-320.0 Y0
M99
65
Create M6 for Tool Change
O9020 ( M6 TOOL CHANGE #6080 )
G80 G40 M5
G91 G0 G28 Z0 M9
G49 G90
M464 ( read spindle tool number )
G04 P1
IF [ #1032 EQ #4120 ] GOTO99
T#4120
G90 G0 G53 X-600.0 Y0 M1
M6
N99 M99
66
Program Layout
O1000 ( Main Program ) T3 M6
T1 M6 G54 H3 S500 T1 ( TAP M6 )
G54 H1 S1000 T2 ( CEN DR ) M90
M90 M135 S500 ( Rigid Tap )
G81 Z-1.5 R2. F100 L0 K0 G84 Z-8. R7. F500 L0 K0
M98 P1001 M98 P1001
T2 M6 M91
G54 H2 S1500 T3 ( DR 5 ) M30
M90
G83 Z-15. R2. Q1.5 F100 L0 K0 O1001 ( Sub-Program )
M98 P1001 X50. Y50.
X-50. Y-50.
Q = Dia * 0.3 or 0.15
M99
67
Learning Activity ( 1 )
O1000 ( MANUAL SET WCS )
#110 = #5021 ( X1 )
M00
#111 = #5021 ( X2 )
Touch sensor
M00 Y4
X1 X2
M30 G54
Y3
68
Answer ( 1 )
O1000 ( MANUAL SET WCS )
#110 = #5021 ( X1 )
M00 Y4
#111 = #5021 ( X2 )
M00
X1 X2
#112 = #5022 ( Y3 )
M00 G54
#113 = #5022 ( Y4 )
#5221 = [ #110 + #111 ] / 2
Y3
#5222 = [ #112 + #113 ] / 2
M30
If G54 change to G55 or G59
How to mark the program better
69
Answer ( 1.1 )
O1000 ( MANUAL SET WCS )
#100 = 55. ( WCS ) #4 = 5221. ( M/C X )
#5 = 5222. ( M/C Y )
#110 = #5021 ( X1 ) #8 = 20.
M00 #10 = #100 - 54.
#111 = #5021 ( X2 ) #[ #4 + #8 * #10 ] = [#110+#112] / 2
M00 #[ #5 + #8 * #10 ] = [#112+#113] / 2
#112 = #5022 ( Y3 ) G91 G0 Z100.
M00
G90 G#100 X0 Y0
#113 = #5022 ( Y4 )
M30
70
DIAGRAM - II
71
Program Layout
O1000 ( MAIN PROGRAM ) O1001 ( SUB-PROGRAM )
T1 M6 G0 X40. Y-40.
G54 H1 S1000 ( END 10 ) Z#33
M90 G1 G41 Y-25. D32 F1000
#2032 = 5.5 X-25.
G65 P7000 T0 B-8.2 S1001. Q2. Y 25.
X 25.
T2 M6 Y -40.
G54 H2 S1500 ( END 8 ) G1 G40 X40. Y-40.
M90 M99
#2032 = 4.
G65 P7000 T0 B-8.2 S1001.
M91
M30
72
Macro Program ( Repeat Cycle )
O7004 ( REPEAT CYCLE ) DO1
( G65 P7000 T B S -- Q R ) #33 = #33 - ABS[#17]
#27 = #4003 ( G90, G91 ) IF [ #33 GT #2 ] GOTO 21
#26 = ABS [#26] ( Z ) #33 = #2
IF [ #19 NE #0 ] GOTO 10 N21 M98 P#19
#3000 = 10 ( S MISSING ) IF [ #33 EQ #2 ] GOTO 98
N10 END1
IF [ #17 NE #0 ] GOTO 11 N98 IF [ #18 NE #0 ] GOTO 99
#17 = 1000. ( Q ) #18 = 50. ( R )
N11 #33 = #20 ( T ) N99 G90 G0 Z [ ABS [ #18 ] ]
G#27 M99
73
Learning Activity ( 2 )
O800 ( MAIN PROGRAM )
G54 H1 S2000 F140
M90
G66 P805 T10. Z10. D5. R2. I = RPM
A2000. B140. I1400. J98. J = Feed rate
1
X10. Y-10. T
X-10. Y10.
2
G67
M91 Z0 R point 3 D
Z
M30
M99
74
Answer 2
O805 ( DRILL DEPTH CYCLE )
IF [#1*#2*#4*#5*#7*#18*#20*#26 NE 0 ] GOTO111
#3000 = 140 ( DATA ERROR )
N111 #33 = #4003
G90 G0 Z#18 S#1 M3 I = RPM
G1 Z-[ #26+#20+1 ] F#2 J = Feed rate
S#4
1
T
G1 Z-[ #26+#20+#7 ] F#5
G0 Z#18 2
G#33 M99 Z0 R point 3 D
Z
75
Learning Activity ( 3 )
O1000 ( MAIN PROGRAM )
T1 M6 U = Start WCS
G54 H1 S2000 F140 V = End WCS
M90 S = Sub Program
G65 P8001 U54. V56. S1001. K = Mirror 21 or 22
G65 P8001 U57. V59. S1001. K21. Z = Refer Point 100.
M91
M30
76
Change Parameter
#7 #6 #5 #4 #3 #2 #1 #0
#3202 PSR NE9 NE8
1 1