Do You Have What it Takes to be a MMS Top Shop?
Published

Understanding Custom Macro Version A

Custom macro B is the more powerful and desirable version of custom macro. However, there are still control models that can be equipped with custom macro version A, so never assume that a given machine you plan to purchase will be (or can be) equipped with custom macro B.

Share

 

Custom macro B is the more powerful and desirable version of custom macro. However, there are still control models that can be equipped with custom macro version A, so never assume that a given machine you plan to purchase will be (or can be) equipped with custom macro B.  
 
One limitation of custom macro A is that you cannot use a decimal point in custom macro commands. All values must be expressed as integers. If you know the fixed format for certain CNC words, this isn’t too bad.
 
For example, if you’re working in the Imperial (inch) system and want to express an X word of 10.0 inches, the fixed format (with no decimal point) for most machines is X100000. Whenever performing calculations, or providing input data, you must use integers.
 
With custom macro B, a G65 is used to call a custom macro. This is not the case with version A in which case a G65 simply specifies that the command is custom macro. An H word specifies what kind of command is being given.
 
This gets a bit confusing, because every kind of arithmetic and logic command has its own H word—and unless you have all the H-word values memorized, you can’t simply scan a custom macro A program and tell what is happening. Three letter addresses—P, Q and R—are used within G65 commands to further clarify what is actually happening. Here are some examples showing the basic arithmetic functions:
 
Equal (H01): custom macro B: #101=1 – custom macro A: G65 H01 P#101 Q1
Add (H02): custom macro B: #101=4+1 – custom macro A: G65 H02 P#101 Q4 R1
Subtract (H03): custom macro B: #101=4-1 – custom macro A: G65 H03 P#101 Q4 R1
Multiply (H04) custom macro B: #101=4*2 – custom macro A: G65 H04 P#101 Q4 R2
Divide (H05) custom macro B: #101=4/2 – custom macro A: G65 H05 P#101 Q4 R2
 
Note that only one arithmetic operation can be performed per command, meaning some expressions must be divided into multiple commands. Consider the following command given in custom macro B format:
 
#101 = 6 * [4+5]
 
This requires two commands in custom macro A:
 
G65 H02 P#101 Q4 R5 (Add four to five)
G65 H04 P#102 Q6 R#101 (Multiply 6 times 9)
 
Custom macro A programs are tedious to write and interpret. I always recommend writing the custom macro in version B first, then converting it to version A.
 
Here is a more complete example. This custom macro will machine a bolt pattern of holes. First let’s look at the main (calling) program:
 
O0008 (Main program)
N005 G54 G90 S800 M03 T02 (Select coordinate system, absolute mode, start spindle, get next tool ready)
N010 G00 X3.0 Y2.5 (Rapid to center of bolt hole pattern)
N015 G43 H01 Z.1 (Instate tool length compensation, rapid up to workpiece)
(Set input data)
G65 H01 P#121 Q30000 (X center)
G65 H01 P#122 Q25000 (Y center)
G65 H01 P#123 Q0 (Z surface)
G65 H01 P#124 Q17500 (Bolt radius)
G65 H01 P#125 Q7500 (Hole depth)
G65 H01 P#126 Q45 (Starting angle)
G65 H01 P#127 Q8 (Number of holes)
G65 H01 P#128 Q500 (Feedrate)
(Call custom macro)
N020 M98 P1008 (Machine entire bolt hole pattern with drilling cycle)
N025G91 G28 Z0
N030 M30
 
Notice that every input variable (argument) must be specified in a separate equality command.
 
Now, here is the custom macro. We’ve placed the equivalent custom macro B command in parentheses after each version A command:
 
O1008 (Custom macro to machine bolt hole circle)
G65 H01 P#101 Q1 (#101 = 1)
G65 H01 P#102 Q#126 (#102 = #126)
G65 H05 P#103 Q360 R#127 (#103 = 360 / #127)
G65 H02 P#104 Q#123 R1000 (#104 = #123 + 0.1)
G65 H03 P#105 Q#123 R#125 (#105 = #123 - #125)
N1 G65 H83 P99 Q#101 R#127 (N1 IF [#101 GT #127] GOTO 99)
G65 H32 P#110 Q#124 R#102 (#110 = #124 * COS[#102])
G65 H02 P#110 Q#110 R#121 (#110 = #110 + #121)
G65 H31 P#111 Q#124 R#102 (#111 = #124 * SIN[#102])
G65 H02 P#111 Q#111 R#122 (#111 = #111 + #122)
G81 X#110 Y#111 R#104 Z#105 F#128 (Same in custom macro B)
G80 (Same in custom macro B)
G65 H02 P#101 Q#101 R1 (#101 = #101 + 1)
G65 H02 P#102 Q#102 R#103 (#102 = #102 + #103)
G65 H80 P1 (GOTO 1)
N99 M99 (End of custom macro)
Kennametal
Koma Precision
Paperless Parts
Hurco
To any Measurement Question there is an Answer
SolidCAM
OASIS Inspection Systems
DN Solutions
CHIRON Group, one stop solution for manufacturing.
Paperless Parts
OASIS Inspection Systems
Mazak Multi-Tasking: Your Parts Multiplier.

Related Content

Basics

Understanding Errors In Hand-Held Measuring Instruments

Different instruments (and different operators) are prone to different errors.

Read More

8 Ways to Increase Productivity on the Manufacturing Floor

When it comes to machine shop productivity, continuous improvement depends on efficient employees, equipment and processes. 

Read More
Turn/Mill

A New Milling 101: Milling Forces and Formulas

The forces involved in the milling process can be quantified, thus allowing mathematical tools to predict and control these forces. Formulas for calculating these forces accurately make it possible to optimize the quality of milling operations.

Read More
Basics

Choosing The Right Grinding Wheel

Understanding grinding wheel fundamentals will help you choose the right wheel for the job.

Read More

Read Next

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
Large Part Machining

The Cut Scene: The Finer Details of Large-Format Machining

Small details and features can have an outsized impact on large parts, such as Barbco’s collapsible utility drill head.

Read More
Meet us at booth 338190 - CHIRON Group