Calling Custom Macros Through Modal Commands

SmartCAM
  • 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
Published 06/03/2021 Calling Custom Macros Through Modal Commands

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 Mike Lynch Founder and President, CNC Concepts Inc.

Share

Leaders-In background Leaders-In logo Komo Machine, Inc. 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 More
Featured Videos
View More GROB Systems, Inc. GROB Systems, Inc. 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 More
Featured Videos
View More Phillips Corporation Phillips Corporation VISIT SITE VISIT SHOWROOM

Phillips Corporation

Featured Content
View More Mayfran International Mayfran International 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 More
Featured Videos
View More Phillips Corporation - Education Phillips Corporation - Education VISIT SITE VISIT SHOWROOM

Phillips Corporation - Education

Featured Content
View More Haitian Precision USA Haitian Precision USA 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 More
Featured Videos
View More PrecisionX Group PrecisionX Group 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 Jergens, Inc. Jergens, Inc. 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 More
Featured Videos
View More A stock photo of a woman operating a CNC machine

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

When Will We See Humanoid Robots on the Manufacturing Floor? When Will We See Humanoid Robots on the Manufacturing Floor? READ MORE 10 Tips for Dressing Your Grinding Wheel 10 Tips for Dressing Your Grinding Wheel READ MORE Continuous Improvement and New Functionality Are the Name of the Game Continuous Improvement and New Functionality Are the Name of the Game READ MORE
  • 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.

HCL CAMWorks 2026 SmartCAM Grinding Wheel Adapters Davenport Machine JTEKT FaciliWorks CMMS CONTRAX IMCO M935

Related Content

A Higbee Thread Milling Custom Macro CNC Tech Talks 3 Jan 2025

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 More Strange But True: Odd Things That Happen With CNCs CNC Tech Talks 26 Nov 2025

Strange 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 More Obscure CNC Features That Can Help (or Hurt) You CNC Tech Talks 1 May 2024

Obscure 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 More The Final CNC Tech Talk Column CNC Tech Talks 3 Dec 2024

The Final CNC Tech Talk Column

Mike Lynch signs off on his CNC Tech Talk column after 35 years.

Read More

Read Next

Adjusting Feed Rate in Circular Motion Commands with G-Codes CNC & Machine Controls

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 More Juggling Mismatches in Resolution and Least Input Increment Inspection and Measurement

Juggling 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 More Custom Macros Can Skip Holes After Replacing Broken Tools CNC & Machine Controls

Custom 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 HCL CAMWorks 2026 Loading Close Next Up
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:

  1. Your cookie settings: Please allow cookies for www.mmsonline.com
  2. You’re browsing in incognito mode. Switching out of private browsing mode may help.
  3. 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.
Close

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 Other

Industries 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 Energy

Operations 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 Submit

Welcome 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 Register

Your 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