Macros add capabilities and flexibility to the control that are not possible with standard G-code. Some possible uses are: families of parts, custom canned cycles, complex motions, and driving optional devices. The possibilities are almost endless.
A Macro is any routine/subprogram that you can run multiple times. A macro statement can assign a value to a variable, read a value from a variable, evaluate an expression, conditionally or unconditionally branch to another point within a program, or conditionally repeat some section of a program.
Here are a few examples of the applications for Macros. The examples are outlines and not complete macro programs.
Tools For Immediate, On-Table Fixturing - You can semi-automate many setup procedures to assist the machinist. You can reserve tools for immediate situations that you did not anticipate in your application design. For instance, suppose a company uses a standard clamp with a standard bolt hole pattern. If you discovered, after setup, that a fixture needs an additional clamp, and suppose that you programmed macro subprogram 2000 to drill the bolt pattern of the clamp, then you only need this two-step procedure to add the clamp to the fixture:
Jog the machine to the X, Y, and Z coordinates and angle where you want to place the clamp. Read the position coordinates from the machine display.
Execute this command in MDI mode:G65 P2000 Xnnn Ynnn Znnn Annn ;
where nnn are the coordinates determined in Step a). Here, macro 2000 (P2000) does the work since it was designed to drill the clamp bolt hole pattern at the specified angle of A. Essentially, this is a custom canned cycle.
Simple Patterns That Are Repeated - You can define and store repeated patterns with macros. For example:
Bolt hole patterns
Angular patterns, any number of holes, at any angle, with any spacing
Specialty milling such as soft jaws
Matrix Patterns, (e.g. 12 across and 15 down)
Fly-cutting a surface, (e.g. 12 inches by 5 inches using a 3 inch fly cutter)
Automatic Offset Setting Based On The Program - With macros, coordinate offsets can be set in each program so that setup procedures become easier and less error-prone (macro variables #2001-2800).
Probing - Using a probe enhances the capabilities of the machine, some examples are:
Profiling of a part to determine unknown dimensions for machining.
Tool calibration for offset and wear values.
Inspection prior to machining to determine material allowance on castings.
Inspection after machining to determine parallelism and flatness values as well as location.