A User-Created Canned Cycle for Porting Tools
FANUC’s version of parametric programming, Custom Macro, enables you to create your own canned cycles tailored to whatever the application requires.
Share
Kurt Manufacturing Company
Featured Content
View MoreDMG MORI - Cincinnati
Featured Content
View MoreCNC machining centers come with a series of hole-machining canned cycles that are commanded by G81 through G89. These cycles are very helpful, but they have limitations. If a hole must be machined in a manner different than the cycles allow, then you cannot use them.
With FANUC’s version of parametric programming, Custom Macro, you can create your own canned cycles to make them do whatever you want. And with a little work, your user-created, hole-machining canned cycle can be made to work in much the same way as built-in canned cycles:
- Instate with a G code specifying how to machine the first hole.
- List the holes to be machined. Any variable can be changed for each hole.
- Use G98 and G99 to clear obstructions between holes.
- Cancel with (a user-created) G80 after the last hole.
Our example commands a porting tool, a combination tool that drills the hole and machines a (larger) hole feature, like a spot face, counterbore or special porting contour. This requires two or more feedrates and possibly two or more spindle speeds. One feedrate is used for the drilling portion and at least one other for the porting portion(s).
The example we show uses Metric mode and was created by Martin Buchan of Orlick Industries in Ontario, Canada. For his application, the X- and Y-coordinates are specified with permanent common variables (#500 and above) that have been previously calculated. Here is a portion of a main (calling) program that invokes the user-created canned cycle and machines 16 holes:
- .
- .
- G90 G00 X#578 Y#579 (Move to first hole location)
- G43 H01 Z5.0
- G123 X#578 Y#579 R-47.0 Z-70.5 A3000.0 W-72.45 B500.0 P500 G98 (Set variables and machine first hole)
- X#580 Y#581 R-40.01 Z-63.5 W-65.545
- X#582 Y#583 R-47.0 Z-70.5 W-72.51 5
- X#584 Y#585 W-72.465
- X#586 Y#587 R-40.0 Z-63.5 W-65.565
- X#588 Y#589 W-65.565
- X#590 Y#591 W-65.565
- X#592 Y#593 W-65.565
- X#594Y #595 R-47.0 Z-70.5 W-72.525
- X#596 Y#597 W-72.535
- X#598 Y#599 W-72.535
- X#600 Y#601 W-72.525
- X#602 Y#603 W-72.545
- X#604 Y#605 W-72.525
- X#606 Y#607 W-72.505
- X#608 Y#609 W-72.500
- G80
- .
- .
G123 is the user-selected G code used to invoke the canned cycle. Arguments X and Y specify the hole center coordinates. R specifies the rapid plane. Z is the position to which the drill portion of the cutting tool will machine. A is the feed rate (mm/minute) to be used for the drilling portion. W is the position to which the spot-facing portion of the cutting tool will machine. B is the feed rate to be used for the spot-facing portion. P, if included, specifies dwell time after spot facing. G98 (or G99) specifies the position to which the tool will retract after machining the hole.
Our example is pretty simple, having just two diameters to deal with. If your porting tool has more than two diameters to machine, you could add input variables for more depths and feed rates.
The cutting tool will:
- Rapid in the X- and Y-axes to the hole location
- Rapid in the Z-axis to the rapid plane
- Machine the drill portion of the hole at the drilling feed rate
- Machine the spot-facing portion of the hole at the spot-facing feed rate
- Pause if P is specified
- Rapid out of the hole to either the initial plane or rapid plane
Here is the custom macro:
- %
- O9011 (Custom macro)
- (Store local variable values from arguments into better retained common variables)
- IF [#24NE#0] THEN #101=#24 (X)
- IF [#25NE#0] THEN #102=#25 (Y)
- IF [#26NE#0] THEN #103=#26 (Z)
- IF [#23NE#0] THEN #104=#23 (W)
- IF [#18NE#0] THEN #105=#18 (R)
- IF [#1NE#0] THEN#106=#1 (A)
- IF [#2NE#0] THEN #107=#2 (B)
- IF [#16NE#0 ]THEN #108=#16 (P)
- IF [#10NE#0] THEN #109=#10 (G)
- (Motions)
- G00X#101Y#102(Move to next XY)
- IF [#500EQ1.0] GOTO 1 (Skip initial plane setting if not first hole)
- #500=1.0 (No longer first hole)
- #100=#500 (Set initial plane if first hole)
- N1 G00 Z#105 (Rapid to R plane)
- G01 Z#103 F#106 (Feed to drilling bottom Z position at feed rate A)
- Z#104 F#107 (Feed to spot-facing bottom position W at feed rate B)
- G04 X#108 (Dwell if P is specified)
- IF [#109EQ99.0] GOTO 5 (Determine retract position)
- G00 Z#100 (Retract to initial plane)
- GOTO 6
- N5 G00 Z#105 (Retract to R plane)
- N6 M99 (End of custom macro)
- %
What else must be done?
There are a few more things needed to make this custom macro behave like a built-in, hole-machining canned cycle. Parameter settings shown are for a 30 series FANUC CNC:
- Create a modal user-defined G code
- Buchan picked the number 123. Pick a number that will not conflict with built-in G codes.
- Name the custom macro program properly. User-defined G-code programs start at O9010. Buchan chose O9011.
- Set the related user-defined G-code parameter to the G-code number and specify that it is to be a modal G code. User-defined G-code parameters begin at parameter number 6050. Parameter 6051 is related to program O9011. To specify that G123 is to be a modal G code, it must be a negative value. So parameter 6051 is set to -123.
- Confirm that parameter 6007, bit three is set to zero (0). This ensures that the G66.1 method of modal custom macro call will be used (as opposed to G66).
- Confirm that parameter 6000, bit zero is set to one (1). This ensures that G67 will not generate an alarm if the CNC is not in custom macro modal call mode.
- Ensure that G80, which cancels built-in canned cycles, will also cancel user-defined canned cycles and reset the first hole condition.
- This is done by redefining G80. To do so, set the next available user-defined G-code parameter to a value of 80. In our case, this means setting parameter number 6052 to 80.
- Create and load program O9012, which is the program related to parameter number 6052:
- O9012
- G80 (Cancels built-in canned cycles)
- G67 (Cancels modal calls to custom macros)
- #500=0 (Resets first hole condition)
- M99
- #500=0 ensures that the next time the G123 custom macro is called, it will properly set the initial plane.
- Manually set the value of permanent common variable #500 to 0. This needs only to be done once.
Related Content
A Spiral Milling Custom Macro Using Constant Contouring Feedrate
Helical milling or “spiral” milling are helpful when machining a circular pocket that is much larger than the milling cutter diameter.
Read More4 Commonly Misapplied CNC Features
Misapplication of these important CNC features will result in wasted time, wasted or duplicated effort and/or wasted material.
Read More6 Ways to Streamline the Setup Process
The primary goal of a setup reduction program must be to keep setup people working at the machine during the entire setup process.
Read More5 Reasons Why You Should Know How to Write Custom Macros
Custom macros enhance what can be done in G-code programs, giving users the ability to code operations that were previously not possible.
Read MoreRead Next
Registration Now Open for the Precision Machining Technology Show (PMTS) 2025
The precision machining industry’s premier event returns to Cleveland, OH, April 1-3.
Read More5 Rules of Thumb for Buying CNC Machine Tools
Use these tips to carefully plan your machine tool purchases and to avoid regretting your decision later.
Read MoreBuilding Out a Foundation for Student Machinists
Autodesk and Haas have teamed up to produce an introductory course for students that covers the basics of CAD, CAM and CNC while providing them with a portfolio part.
Read More