91ÊÓÆµÍøÕ¾ÎÛ

Published

Custom Macro Enhancements

This parametric programming version hasn’t changed much over the years, but there have been some important updates.

Share

Leaders-In background

Custom Macro is the most popular version of parametric programming for CNC machine tools. Created by FANUC and adopted for use by several control manufacturers, it provides countless benefits to CNC users. I have demonstrated many benefits in previous columns.

Though the Custom Macro has been around for a long time, it hasn’t changed much over the years. I will highlight the most important updates, but keep in mind that if you must maintain compatibility among new and old machines, you must use only those Custom Macro features that are shared by all of your machines.

• Improved arithmetic. Newer versions of Custom Macro include more arithmetic functions than older ones. These functions include arc sine, arc cosine, improved arc tangent and power. The number of allowed nesting levels (brackets within brackets) has been increased from four to five.

• Improved conditional branching statement. Early versions of Custom Macro provide a rather simple IF statement. If the logical expression within the IF statement is evaluated as true, the only option is to specify an unconditional branch (GOTO). While the GOTO statement is often required, there are times when the true condition requires a different action—like a simple arithmetic operation command. Consider these examples:

Old way:
IF [#1 NE #0] GOTO 5
#1 = 0.25
N5 . . .

New way: 
IF [#1 EQ #0] THEN #1 = 0.25

Newer versions of Custom Macro also provide the ability to test more than one condition using the AND and OR extensions. Consider this example:

IF [[#1 EQ #0] AND [#1 LT 1.0]] THEN #1 = 0.25

Only if both conditional expressions are true will the arithmetic operation be executed.

• Referencing system variables by name. With older versions of Custom Macro, system variables are referenced by a four-digit variable number. The alarm-generating system variable, for example, is #3000, and the command
#3000 = 100 (R WORD MISSING)
will generate an alarm, and the message “MC100 - R WORD MISSING” will be displayed.

With newer versions of Custom Macro, you can additionally reference system variables by name. This makes it easier to determine what a system-variable-containing command is doing. Consider how much easier it is to understand this revised alarm-generating command:
[#_ALM] = 100 (R WORD MISSING)

You must reference the Custom Macro descriptions in your control manufacturer’s programming manual in order to find the appropriate name for each system variable (there are many). And by the way, referencing this manual is the only way to determine if your specific control model allows the new features described in this article.

• Reading parameter values. This may be the most important Custom Macro enhancement. While CNC users have had the ability to enter (write) parameters from within programs (using G10), there has been no previous way to read them.

Consider this command:
#101 = PRM [1,1]

The value of bit number one for parameter number one (a one or a zero) will be placed in common variable #101. (The value before the comma is the parameter number; the value after the comma is the bit number.)

It happens that for a FANUC 0iD control, bit one of parameter one specifies program format. For a turning center, this affects whether the format for one-line or two-line multiple repetitive cycles is required. A value of zero makes the control require two-line multiple repetitive cycles. A value of one makes it require one-line multiple repetitive cycles.

With the ability to read parameter settings and test their values with conditional branching (IF) statements, you can (among countless other things) ensure that your programs include the appropriate multiple repetitive cycle commands.

Other enhancements to Custom Macro include:

• Improved time/date. This Custom Macro function is helpful for timing events, as is required for tool-life monitoring. 

• Sub-program call using a specified letter address. Previously, only a “T” or “M” word could be used to call a sub-program. Current versions of Custom Macro allow you to specify that a sub-program be called when a letter address of your choosing is executed (though some letter addresses, like N, G and O, are not allowed).

• Abbreviating arithmetic and logic names. Programs can be shortened a little with this feature. The arithmetic function ROUND, for example, can be specified as RO. Just the first two alpha characters are required.

MMS Leaders in CNC Machining

Related Content

2 Secondary Coordinate Systems You Should Know

Coordinate systems tell a CNC machine where to position the cutting tool during the program’s execution for any purpose that requires the cutting tool to move.

Read More
Basics

How to Determine the Currently Active Work Offset Number

Determining the currently active work offset number is practical when the program zero point is changing between workpieces in a production run.

Read More
CNC Tech Talks

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
Basics

6 Variations That Kill Productivity

The act of qualifying CNC programs is largely related to eliminating variations, which can be a daunting task when you consider how many things can change from one time a job is run to the next.

Read More

Read Next

Economics

Last Chance! 2025 Top Shops Benchmarking Survey Still Open Through April 30

Don’t miss out! 91ÊÓÆµÍøÕ¾ÎÛ's Top Shops Benchmarking Survey is still open — but not for long. This is your last chance to a receive free, customized benchmarking report that includes actionable feedback across several shopfloor and business metrics. 

Read More
Basics

Machine Shop MBA

  Making Chips and 91ÊÓÆµÍøÕ¾ÎÛ are teaming up for a new podcast series called Machine Shop MBA—designed to help manufacturers measure their success against the industry’s best. Through the lens of the Top Shops benchmarking program, the series explores the KPIs that set high-performing shops apart, from machine utilization and first-pass yield to employee engagement and revenue per employee.  

Read More
Automation

AMRs Are Moving Into Manufacturing: 4 Considerations for Implementation

AMRs can provide a flexible, easy-to-use automation platform so long as manufacturers choose a suitable task and prepare their facilities.

Read More