Precision cleaning solvents
Published

Variables in Custom Macro

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

Share

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. 

high-performance systems for efficient parts cleaning
Cleaning questions ask Kyzen
Cleaning Technologies Group
Echoflex modular ultrasonic cleaning machines
Pickelx one step metal prep
Precision Cleaning Solvents
vacuum vapor degreasers
Techspex
More blasting. Less part handling.
SolidCAM
DN Solutions
715 Series - 5-axis complete machining

Related Content

Tips for Designing CNC Programs That Help Operators

The way a G-code program is formatted directly affects the productivity of the CNC people who use them. Design CNC programs that make CNC setup people and operators’ jobs easier.

Read More
CNC Tech Talks

3 Mistakes That Cause CNC Programs to Fail

Despite enhancements to manufacturing technology, there are still issues today that can cause programs to fail. These failures can cause lost time, scrapped parts, damaged machines and even injured operators.

Read More
CNC Tech Talks

The Best Point of Reference for Program Zero Assignment Entries

Correctly specified program zero assignment and coordinate position values enable the CNC to determine how far to move the cutting tool during each positioning motion.

Read More
CNC Tech Talks

6 Ways to Streamline the Setup Process

The primary goal of a setup reduction program must be to keep setup people working at the machine during the entire setup process.

Read More

Read Next

Sponsored

Increasing Productivity with Digitalization and AI

Job shops are implementing automation and digitalization into workflows to eliminate set up time and increase repeatability in production.

Read More
Workforce Development

Inside Machineosaurus: Unique Job Shop with Dinosaur-Named CNC Machines, Four-Day Workweek & High-Precision Machining

Take a tour of Machineosaurus, a Massachusetts machine shop where every CNC machine is named after a dinosaur! 

Read More
Sponsored

The Future of High Feed Milling in Modern Manufacturing

Achieve higher metal removal rates and enhanced predictability with ISCAR’s advanced high-feed milling tools — optimized for today’s competitive global market.

Read More
Precision cleaning solvents