CNC Macro Programming & Software

June 10, 2025

Radonix CNC Macro Programming & Software

In the world of CNC machining, we often talk about the software that happens before the machine: CAD for design and CAM for generating toolpaths.

But what if you could teach your CNC machine to think for itself? What if you could give it the power to perform calculations, make decisions based on real-time data, and execute complex, variable tasks with a single, simple command?

This is the power of CNC Macro Programming. It’s a capability that transforms your machine’s controller from a simple G-code interpreter into a true, on-board computer.

It’s not a separate piece of software you install, but a powerful, native scripting language built directly into an advanced CNC controller.

Understanding and leveraging macro programming is what separates basic machine operation from high-level manufacturing automation.

As a developer of the intelligent control systems that provide this capability, Radonix is here to demystify the world of CNC macros.

This guide will explore what macro programming is, how it works, its game-changing applications, and why a modern controller is the essential key to unlocking its full potential.

What is CNC Macro Programming? It’s Logic, Not Just Lines

At its core, a standard G-code program is a static, linear list of instructions: move here, turn on the spindle, move there, turn off the coolant. It’s predictable and unchanging.

CNC Macro Programming (also known as Parametric Programming) introduces dynamic logic. It allows you to use variables, perform mathematical calculations, and use conditional statements (IF/THEN/ELSE) and loops (WHILE/DO) directly within your CNC program.

Think of it this way:

  • Standard G-Code: A fixed recipe that you must follow exactly every time.
  • Macro Program: A master recipe that can adjust itself based on the ingredients you have. You can tell it “make this for 10 people instead of 4,” and it automatically recalculates all the ingredient quantities.

This capability is most commonly associated with the Macro B syntax, popularized by Fanuc and now the de facto industry standard for this type of programming.

The Building Blocks of a Macro Program

Macro programming introduces several fundamental programming concepts directly into the G-code environment.

1. Variables: The Heart of a Macro

Variables are placeholders that can store numbers. Instead of writing G01 X100.0, you can write G01 X#101, where #101 is a variable that holds the value 100.0. This simple change is the key to everything.

CNC controllers have several types of variables:

  • Local Variables (#1#33): These are temporary, like scratch paper. They are most often used to pass arguments (parameters) into a macro when it is called.
  • Common Variables (#100#199, #500#999): These are persistent. The values stored in them are retained even after the program ends or the power is cycled. They are perfect for storing important data like part counters, setup information, or wear offsets that need to be remembered.
  • System Variables (#1000+): These are special, read-only variables that give you direct access to the machine’s live data. You can read the current machine position (#5041 for X), the active tool’s length offset, the current spindle speed, and much more. This allows your macro program to be aware of the machine’s state.

2. Mathematical Operations

Your macro program can function as a powerful calculator. You can perform addition, subtraction, multiplication, division, and even complex trigonometric functions like sine (SIN), cosine (COS), and square root (SQRT).

Example: #101 = #100 * (SIN[#30] / 2.0)*

3. Conditional Logic and Branching (The “Brain”)

This is where the magic happens. Your program can now make decisions.

  • IF [condition] GOTO n: This is the fundamental logic statement. If the condition is true, the program jumps to a specific sequence number (N-block). For example, IF [#100 GE 10] GOTO 500 means “If variable #100 is greater than or equal to 10, then jump to line N500.”
  • IF [condition] THEN …: Some controllers support this more modern structure.

4. Looping (Iteration)

Loops allow you to repeat a block of code multiple times without having to write it out over and over.

  • WHILE [condition] DO n … END n: This is the most powerful looping structure. The block of code between DO n and END n will continue to execute as long as the condition in the WHILE statement is true. This is perfect for creating custom pecking cycles or incrementally cutting a deep pocket.

How to Call and Use a Macro

You execute a macro program using a special G-code:

  • G65 P… A… B… C…: This is the standard command for a “modal macro call.”
    • P: Specifies the program number of the macro you want to run (e.g., P9010).
    • A, B, C…: These are the arguments you pass to the macro. The value of A is automatically placed in local variable #1, B in #2, C in #3, and so on.

The “Software” Aspect: Where Do You Write Macros?

The term “CNC macro programming software” can be misleading. You don’t download a special application called “Macro Programmer.” The “software” is actually a combination of two things:

  1. A Text Editor: For simple macros, programmers write them directly in the text editor built into the CNC controller’s interface. For more complex and well-structured macros, they are written on a PC using a standard text editor (like Notepad++, VS Code) or a dedicated G-code editor (like CIMCO Edit) and then transferred to the machine over the network.
  2. The CNC Controller’s Macro Engine: This is the most important part. The controller itself is the “software” that interprets and executes the macro logic. The power, speed, and flexibility of this engine determine how complex and useful your macros can be. A basic controller might have limited macro capabilities or execute them slowly, while an advanced controller will have a full-featured, high-speed macro engine.

Game-Changing Applications: What Can You Actually DO With Macros?

Once you understand the building blocks, you can create incredibly powerful automation routines.

  • Automated Probing Cycles: This is the number one application and a massive time-saver. You can write macros that use a touch probe to:
    • Automatically find the exact center of a boss or a bore.
    • Find the precise location of a part’s corner.
    • Measure the Z-height of the raw material. The macro then takes these measured positions and automatically calculates and sets the work offsets (G54, G55, etc.), eliminating hours of manual setup time and ensuring perfect, repeatable accuracy.
  • Family of Parts Programming: Imagine you manufacture a part that comes in 10 different sizes. Instead of having 10 different G-code programs, you can write a single macro program. The operator simply calls the macro with the desired length, width, and diameter as arguments (G65 P1000 L200.0 W75.0 D25.0), and the macro calculates all the necessary toolpaths on the fly.
  • Custom Canned Cycles: Does your shop have a unique cutting process that you perform often? You can create your own custom canned cycle as a macro program. You can even assign it to a custom G-code (e.g., G200) on capable controllers, making it as easy to use as a built-in cycle like G71 or G81.
  • In-Process Gauging and Tool Wear Compensation: A macro can command a probe to measure a critical feature after it has been machined. If the macro detects that the feature is drifting out of tolerance (due to tool wear), it can automatically calculate a correction and update the tool’s wear offset, ensuring the next part is back in spec. This is a powerful form of adaptive machining.

The Radonix Advantage: A Superior Engine for Macro Programming

The power and potential of macro programming are entirely dependent on the capability of the CNC controller. A modern, PC-based controller like a Radonix system provides a vastly superior environment for developing and executing macros compared to older, dedicated hardware.

1. High-Speed Processing Power

Executing macro logic—especially complex calculations inside a WHILE loop—requires significant computational power. Older controllers can get bogged down, causing the machine to pause or stutter while it “thinks.” The PC-based architecture of Radonix controllers leverages powerful, modern CPUs that can execute complex macro logic in milliseconds. This ensures smooth, uninterrupted machine motion, even when running the most demanding parametric programs.

2. Full, Standard Macro B Compatibility

The Radonix macro engine is built on the industry-standard Macro B syntax. This means that thousands of existing macro programs, including the widely available and powerful probing cycles from manufacturers like Renishaw, can run on a Radonix controller. You get proven, powerful functionality right out of the box.

3. PC-Based Flexibility and Ease of Use

Developing and managing macros is far easier on a Radonix system.

  • Easy File Management: The familiar PC interface and network connectivity mean you can drag and drop your macro programs onto the controller, organize them in folders, and edit them with ease. This is a world away from the clunky interfaces of older systems.
  • Large, Graphical Interface for Debugging: Trying to debug a complex macro on a small, text-only screen is a nightmare. The large, high-resolution display on a Radonix system allows you to clearly view your code, monitor the values of multiple variables simultaneously, and trace the program’s flow, drastically cutting down on development and troubleshooting time.

4. Advanced Integration for Industry 4.0

The open nature of a Radonix PC-based controller unlocks possibilities that are impossible on a closed-box system. Your macro programs can be configured to:

  • Write data (part counts, cycle times, measurements) to a log file on a network server for production monitoring.
  • Read parameters from an external file to configure a job.
  • Trigger other network events, creating a truly connected and intelligent manufacturing cell.

Conclusion: Stop Just Instructing, Start Programming

CNC macro programming is the bridge from simple instruction-following to on-machine intelligence. It’s about creating reusable, flexible, and automated routines that save time, reduce errors, and unlock a new level of capability from the machines you already own.

While the “software” is a simple text editor, the power lies entirely within the controller’s macro engine. To truly leverage parametric programming, you need a controller with the processing power to handle complex logic, the flexibility to make development easy, and the compatibility to run industry-standard routines.

Stop thinking about what your machine can do. Start thinking about what you can teach it to do.

If you’re ready to unlock the full potential of on-machine automation and parametric programming, you need a controller with an engine built for the task. Contact Radonix today to learn how our advanced macro capabilities and powerful PC-based platform can revolutionize your manufacturing process.

Contact Us:

Radonix CNC Control Card – Hardware, Software, and Interface