For part family applications, one way to provide arguments (input variables) for the custom macro is to list them right at the beginning of the custom macro program. We normally use common variable (#100 series) along with a nice documenting message to explain the meaning of the variable. Consider, for example, this part family custom macro:
O0003 (Spacer ring)
#101=4.5 (HOLE DIA)
#102=6.0 (OUTSIDE DIA)
#103=5.25 (BOLT CIRCLE DIA)
#104=1.0 (THICKNESS)
#105=0.125 (SLOT DEPTH)
N005 T01 M06 (1/2 end mill)
(Constants for milling operation)
#110=#102/2 + 0.35 (Outside clearance)
#111=#101/2 - 0.35 (Inside clearance)
N010 G54 G90 S800 M03 T02
N015 G00 X0 Y-#110
N020 G43 H01 Z-#105
N025 G01 Y-#111 F4.0
N030 G00 Z0.1
N035 X#110 Y0
N040 Z-#105
N045 G01 X#111
N050 G00 Z0.1
N055 X0 Y#110
N060 Z-#105
N065 G01 Y#111
N070 G00 Z0.1
N075 X-#110 Y0
N080 Z-#105
N085 G01 X-#111
N090 G00 Z0.1
N195 G91 G28 Z0 M19
N100 M01
N105 T02 M06 (1/4 drill)
#112=#103/2 (Bolt circle radius)
N110 G54 G90 S1300 M03 T01
N115 G00 X0 Y-#112
N120 G43 H02 Z0.1
N125G81R-[#105-.1]Z-[#104+0.11]F3.5 G98
N130 X#112 Y0
N135 X0 Y#112
N140 X-#112 Y0
N145 G80
N150 G91 G28 Z0 M19
N155 M30
All of the arguments needed for the program are specified right at the beginning with common variables - and the accompanying message makes it clear as to what each argument represents. Again, this is a common method for getting arguments into a part family custom macro.
Consider adding one more criteria to this application. What if the workpiece material varies from job to job. Maybe sometimes this workpiece is made from aluminum - other times it is made from steel - yet other times it is made from brass, or copper, or nickel. You could of course, add some additional arguments to specify feeds and speeds for each tool, but these values would have to be changed every time a new material is to be machined. Here is another way to handle this problem.
We can set up a series of special cutting conditions custom macros (actually called as subprograms) that specify all cutting conditions needed for the material. For example, this might be the custom macro for steel:
O1001 (Cutting conditions for steel workpiece)
#121=800 (Speed for end mill)
#122=4.0 (Feedrate for end mill)
#123=1300 (Speed for drill)
#124=3.5 (Feedrate for drill)
M99
And here is the custom macro for an aluminum workpiece:
O1002 (Cutting conditions for aluminum workpiece)
#121=2800 (Speed for end mill)
#122=12.0 (Feedrate for end mill)
#123=3400 (Speed for drill)
#124=14.0 (Feedrate for drill)
M99
You can easily create as many cutting conditions custom macros as you have materials to machine. The main program, of course, must be modified to reflect this new criteria:
O0003 (Spacer ring)
#101=4.5 (HOLE DIA)
#102=6.0 (OUTSIDE DIA)
#103=5.25 (BOLT CIRCLE DIA)
#104=1.0 (THICKNESS)
#105=0.125 (SLOT DEPTH)
(O1001: STEEL, O1002: ALUMINUM, O1003: BRASS)
M98 P1001 (Get cutting conditions for steel workpiece)
N005 T01 M06 (1/2 end mill)
(Constants for milling operation)
#110=#102/2 + 0.35 (Outside clearance)
#111=#101/2 - 0.35 (Inside clearance)
N010 G54 G90 S#121 M03 T02
N015 G00 X0 Y-#110
N020 G43 H01 Z-#105
N025 G01 Y-#111 F#122
N030 G00 Z0.1
N035 X#110 Y0
N040 Z-#105
N045 G01 X#111
N050 G00 Z0.1
N055 X0 Y#110
N060 Z-#105
N065 G01 Y#111
N070 G00 Z0.1
N075 X-#110 Y0
N080 Z-#105
N085 G01 X-#111
N090 G00 Z0.1
N195 G91 G28 Z0 M19
N100 M01
N105 T02 M06 (1/4 drill)
#112=#103/2 (Bolt circle radius)
N110 G54 G90 S#123 M03 T01
N115 G00 X0 Y-#112
N120 G43 H02 Z0.1
N125G81R-[#105-.1]Z-[#104+0.11] F#124 G98
N130 X#112 Y0
N135 X0 Y#112
N140 X-#112 Y0
N145 G80
N150 G91 G28 Z0 M19
N155 M30
Comentários