Calling Custom Macros Through Modal Commands
- Workforce Development 4 Feb 2026 How Manufacturing CEOs Are Rebuilding Strategy Amid Tariffs and Talent Gaps
- Inspection and Measurement 2 Feb 2026 How Confocal Technology Revolutionizes Optical Metrology
- Turning Tools 30 Jan 2026 Durable Tooling Cuts Cycle Times for Tough Turn-Peeling Job
- Five-Axis 28 Jan 2026 High-End Machines Deserve High-End Support: Inside DMG MORI’s Cleveland Facility
- 26 Jan 2026 Production Machining Turns 25!
- Top Shops 26 Jan 2026 Modern Machine Shop’s 2026 Top Shops Benchmarking Survey Goes Live Feb. 1
- Measurement 23 Jan 2026 Putting the "Plate" Gage to Use
- 21 Jan 2026 Troubleshooting Processes Experiencing Drift or Shift
- Basics 19 Jan 2026 Understanding the Tribology of the Tool-Workpiece Interface
- Economics 16 Jan 2026 Metalworking Index Closes 2025 With a Slight Uptick
While G65 does not enable users to simply and easily carry out Custom Macros in multiple locations, G66 and G66.1 provide modal solutions for doing so.
- CNC & Machine Controls
- Software
- CNC Tech Talks
- Basics
Mike Lynch Founder and President, CNC Concepts Inc. Share
VISIT SITE VISIT SHOWROOM Komo Machine, Inc.
Komo Machine, Inc. is a leading U.S. manufacturer of advanced, precision CNC machining systems engineered for demanding manufacturing applications. Wi...READ MORE
Featured Content
View MoreFeatured Videos
View More
VISIT SITE VISIT SHOWROOM GROB Systems, Inc.
For almost 100 years, GROB has been known worldwide for the development and manufacturing of machines and production lines. GROB is a family-owned com...READ MORE
Featured Content
View MoreFeatured Videos
View More
VISIT SITE VISIT SHOWROOM Phillips Corporation
Featured Content
View More
VISIT SITE VISIT SHOWROOM Mayfran International
Mayfran International is the world’s leading provider of quality material handling, filtration, and chip removal solutions. With an unrivaled...READ MORE
Featured Content
View MoreFeatured Videos
View More
VISIT SITE VISIT SHOWROOM Phillips Corporation - Education
Featured Content
View More
VISIT SITE VISIT SHOWROOM Haitian Precision USA
Haitian Precision USA has been selling industrial machine tools since 2000 under the Absolute Group of Companies. Absolute started by selling and s...READ MORE
Featured Content
View MoreFeatured Videos
View More
VISIT SITE VISIT SHOWROOM PrecisionX Group
PrecisionX Group is a leading custom contract manufacturer specializing in precision metal fabrication for critical-use applications across growth-ori...READ MORE
Featured Content
View More
VISIT SITE VISIT SHOWROOM Jergens, Inc.
Manufacturing Efficiency for 75 Years In 1942, Jergens Inc. opened its doors and began its journey to grow into one of the world’s largest m...READ MORE
Featured Content
View MoreFeatured Videos
View More
If you have programmed with Custom Macro, you probably know that one way to call a Custom Macro program is to use a G65 command. Users typically input this command in a main program, specifying the program number for the Custom Macro (with a P-word) and a series of letter address arguments (variables) to pass to the Custom Macro.
Consider the following command for calling a round pocket-machining Custom Macro:
Featured Content
- N050 G65 P1000 X5.0 Y5.0 Z0 D0.5 R0.75 F5.0
X and Y specify the pocket center location. Z indicates the surface where the machine will make the pocket. D is the depth and R is the pocket radius. F specifies the machining feed rate.
G65 is not modal. To machine another round pocket in a different location, the user must provide another complete G65 command (changing the related arguments, of course). FANUC CNCs have, however, two G-codes for modally calling a Custom Macro: G66 and G66.1. After instating either of them, the programmer must use G67 to cancel them.
G66
G66 does not call the Custom Macro by itself; it will only assign the local variables that correspond to the specified letter address arguments. Consider these commands:
- .
- N050 G66 P1000 Z0 D0.5 R0.75 T0.5 F5.0
- N055 G00 X5.0 Y5.0
- N060 X10.0
- N065 Y10.0
- N070 X5.0
- N075 G67
- .
Line N050 sets local variable #26 to the value of Z, #7 to the value of D, #18 to R, #20 to T and #9 to F. But, again, this line does not call Custom Macro O1000.
In the next command (N055), which must be a motion command (usually G00 or G01), the CNC will move to the commanded position and then call Custom Macro O1000. Local variables assigned in the G66 command will be available for use in the Custom Macro, but there is no way to update them after executing the G66 command. The CNC will continue to move into position and call the Custom Macro in subsequent motion commands until it reaches the G67 (N075) command.
Here is an example of the round pocket Custom Macro when using G66:
- O1001 (Custom Macro called by G66)
- #32=#5001 (Attain current X absolute position)
- Z[#26+0.1] (Move to approach position)
- G01 Z[#26-#7] F[#9/2] (Plunge into pocket)
- G02 X[#32+#18-#20/2] R[[#18-#20/2]/2] F#9
- I-[#18-#20/2]
- X#32 R[[##18-#20/2]/2]
- G00 Z[#26+0.1]
- M99
G66.1
Like G66, a G66.1 command will specify the Custom Macro number and set local variables to the value of letter address arguments. Also like G66, a G67 command must eventually be specified to cancel the modal calling. But unlike G66, G66.1 will call the Custom Macro. Consider these commands:
- .
- N050 G66.1 P1001 X5.0 Y5.0 Z0 D0.5 R0.75 T0.5 F5.0
- N055 X10.0
- N060 Y10.0
- N065 X5.0
- N070 G67
- .
Now, line N050 will machine the first pocket. In each subsequent command which is not a motion command, the CNC will reset the local variables and call the Custom Macro again. In line N055, the value of local variable #24 (X) becomes 10.0. Assuming the programmer wrote the Custom Macro correctly, a motion command in the Custom Macro will move the tool to this position before the machine begins creating the pocket.
The advantage of G66.1 over G66 is that any of the letter address arguments can change during any of the times the user calls the Custom Macro. If the depth of the pocket changes for the pocket N060 machines, for instance, the programmer can include the letter address D in line N060.
Creating Custom Macros using G66.1 is more involved than G66. Since the values of all the local variables return to vacant at the M99 command that ends the Custom Macro, users must store these values in common variables that are not lost until the power is turned off.
Consider this Custom Macro program using G66.1:
- O1001 (Custom Macro called by G66.1)
- (Change values for arguments included in the calling command)
- IF [#24 NE #0] THEN #100 = #24
- IF [#25 NE #0] THEN #101 = #25
- IF [#26 NE #0] THEN #102 = #26
- IF [#7 NE #0] THEN #103 = #7
- IF [#18 NE #0] THEN #104 = #18
- IF [#20 NE #0] THEN #105 = #20
- IF [#9 NE #0] THEN #106 = #9
- G00 X#100 Y#101 (Move to pocket center)
- Z[#102+0.1] (Move to approach position)
- G01 Z[#102-#103] F[#106/2] (Plunge into pocket)
- G02 X[#100+#104-#105/2] R[[#104-#105/2]/2] F#106
- I-[#104-#105/2]
- X#100 R[[#104-#105/2]/2]
- G00 Z[#102+0.1]
- M99
Which Custom Macro Command Is Better? G66 or G66.1?
While it requires more programming work, G66.1 provides more flexibility than G66. Namely, the programmer can change any argument in any of the commands between the G66.1 and the G67 command. In our example, this means the pocket’s X/Y position, radius, depth, Z-surface location or feed rate. In this sense, a Custom Macro called with G66.1 behaves almost exactly like any hole-machining canned cycle, like G81.
On the other hand, if you are sure there will be no need to change things after specifying the initial set of arguments, using G66 may be more suited to your application, since G66 is so much easier to use.
Related Content
A Higbee Thread Milling Custom Macro
Higbee threads provide a full thread form at the very start of the thread. The sharp edge is removed during the machining process.
Read MoreStrange But True: Odd Things That Happen With CNCs
These oddities in the way a CNC naturally behaves can help explain some rather unusual situations that may occur during machining.
Read MoreObscure CNC Features That Can Help (or Hurt) You
You cannot begin to take advantage of an available feature if you do not know it exists. Conversely, you will not know how to avoid CNC features that may be detrimental to your process.
Read MoreThe Final CNC Tech Talk Column
Mike Lynch signs off on his CNC Tech Talk column after 35 years.
Read MoreRead Next
Adjusting Feed Rate in Circular Motion Commands with G-Codes
While it is possible to calculate by hand adjustments to feed rate for circular milling operations, cutter radius compensation CNC programs streamline this process.
Read MoreJuggling Mismatches in Resolution and Least Input Increment
While CNC machining and turning systems of the past only had resolutions and least input increments equal to the displayed decimal places, new systems support more precise inputs.
Read MoreCustom Macros Can Skip Holes After Replacing Broken Tools
Using “vacant” local variables enables CNC machinists to create custom macros that can target multiple types of machining work.
Read More
Loading Why am I seeing this?
The page you’re on features premium MMS editorial content.
To continue enjoying the articles, videos and podcasts from the MMS editorial team, please key in your name and email address, as well as your company and title info. Doing so unlocks MMS’ premium web content on this device.
Why does the gate appear repeatedly for me? If the gate continues to show up on premium content after you’ve already provided your information, it could be for one of these reasons:
- Your cookie settings: Please allow cookies for www.mmsonline.com
- You’re browsing in incognito mode. Switching out of private browsing mode may help.
- You are viewing on a different device or browser. Your login is connected to the browser and device on which you originally unlocked MMS’ premium web content.
Welcome! You’ve unlocked premium content.
If you have time, please tell us a little more about yourself.
Country
Select a country United States of America Canada Mexico OtherIndustries Served
Aerospace/Aviation Appliance Automotive/Transportation Die/Mold Computers / Electrical / Electronics Industrial Machinery & Equipment Medical/Dental Military/Defense Offroad/Construction/Agricultural Oil & Gas Pumps & Valves Renewable EnergyOperations Performed
3DP/Additive Manufacturing CAD/CAM CNC Operations Drilling EDM Five-Axis Machining Gear Cutting & Rolling Grinding High Speed Machining Inspection Laser Cutting Micro Machining Milling Multitasking Machines Robotics & Automation Titanium Machining Turning Waterjet Machining SubmitWelcome to Modern Machine Shop!
Unlimited access to our free premium content requires a little more information from you.
First Name Last Name Job Title Company Email Also, please subscribe me to the MMS Extra and MMS The Shop e-newsletters! Registering RegisterYour email address will be used to communicate with you about Modern Machine Shop subscription offers, related products and services. Refer to our Privacy Policy for more information. Wondering why you’re seeing this? Read more here.
Từ khóa » G66 Cnc
-
How Does G66 Work? - CNC Concepts, Inc.
-
G66 - CNC Machining - Practical Machinist
-
G66 Macro Modal Call Simplify Your Programming CNC ... - YouTube
-
G66 Macro Parameters - CNC Zone
-
2 Modal Paramacro Call (g66) | Rockwell Automation 8520-MUM 9 ...
-
Make Your Own G81 Drilling Cycle Through Fanuc Macro And G66 ...
-
G Codes For Machining Centers - Carbide Depot
-
G-Code Lists - MS-Tech Corporation
-
Complete List Of CNC G Codes
-
Basic Knowledge Of NC Macro Program
-
MATRIX 5.7" KCG057QV1DB-G66 MODULE TFT LCD KYOCERA
-
CNC Programming Using Fanuc Custom MacroB S K Sinha McGraw ...