91ÊÓÆµÍøÕ¾ÎÛ

Published

Variables in Custom Macro

Choosing the appropriate type of parametric programming variable is especially important in complex applications.

Share

Leaders-In background

As with all computer programming languages, variables in FANUC’s custom macro—or any version of parametric programming—are storage registers for values. You can use them to represent just about anything.

Also as with most computer programming languages, there are different kinds of variables in custom macro. But unlike variables in most computer programming languages, you can often choose among two or more custom macro variable types for a given application. This is the source of some confusion and can lead to misusing variables.

There are five variable types in custom macro:
• Letter address arguments are used in custom macro to call G65 or G66 commands.
• Local variables range from #1 through #33 and are reset to vacant at M99 or M30.
• Common variables range from #100 through at least #149 and are reset to vacant when the machine is powered off (or M30 depending on the parameter setting).
• Permanent common variables range from #500 through at least #509 and are retained even after the machine’s power is turned off.
• System variables range from #1000 through #10000 or more, and are used to access CNC-related functions.

With the exception of letter address arguments, custom macro variables are specified with a hashtag symbol (#) and a number. So in a CNC program, #132, for example, specifies common variable number 132.

Here, we will concentrate on the appropriate use of local, common and permanent common variables. For simple custom macro applications, it may not matter which of these variable types you choose. However, there is a finite number of available variables. As application complexity or the number of related programs increases, appropriate variable-type selection becomes much more important. 

Volatility Issues
Local variables are the most volatile. They are only kept active during the execution of the program in which they are used. Common variables are less volatile, usually remaining active until the machine’s power is turned off. Permanent common variables are not volatile at all, since they are retained even after the power is turned off. Our general suggestion is to always choose the most volatile variable type that will adequately handle your application. Reserve the use of less volatile variables for times when variable volatility will cause some kind of problem.

In user-created canned-cycle applications, for example, everything happens right in the custom macro program. Consider a thread milling program. Once the program has been executed and a thread has been milled, there will no longer be a need for any of the variables used in the program. For this reason, you can/should exclusively use local variables (as long as they are not being used to represent arguments) for all of your user-created canned-cycle variable needs. While using common, or even permanent common variables, in a user-created canned-cycle custom macro program will work, doing so will reduce the number of available, less volatile variables for applications when they are needed.

With part-family applications, on the other hand, it is often necessary to share variables among programs. One program may, for instance, set a speed or feed-rate variable that will be used in another program. Since common variables are retained until the power is turned off, we recommend using them for this kind of application. And again, permanent common variables could be used, but using them in this manner would reduce the number of them available for times when they are truly needed.

By the way, if you expect to use previously developed user-created canned-cycle custom macro programs within part-family applications, you must be especially careful with common variables. If you use them within your user-created canned-cycle programs, you must take care not to overwrite any of the common variables being used for the part-family application.

Reserve the use of permanent common variables for applications that require variable values to be retained from day to day. Consider a part-counting custom macro program. The current part count must be retained even if the machine’s power is turned off. Also, some permanent common variables may already be in use, meaning you must confirm that they are available for your applications. This is especially true if your machine has certain accessories, like a spindle touch probe. 

Related Content

CNC Tech Talks

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
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
CNC Tech Talks

4 Reasons to Use Safety Commands

Safety commands help safeguard CNC applications from common programming or operation errors.

Read More
CNC Tech Talks

CNC-Related Features of Custom Macro

CNC-related features of custom macro are separated into two topics: system variables and user-defined G and M codes. This column explores both.

Read More

Read Next

Top Shops

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