Sumitomo
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)
Kyocera SGS
Ingersoll Cutting Tools
Iscar
Horn USA
CERATIZIT
IMCO
Specialized Plastic Packaging for Cutting Tools
Sumitomo
715 Series - 5-axis complete machining
MMS Made in the USA
SolidCAM
Techspex

Related Content

Basics

Speeding Up Splines

Moving small- to medium-batch production from outsourced, dedicated hobbing operations to in-house, CNC multitasking machines helps job shops achieve quick turnarounds and flexibility in supplying splines for the heavy-vehicle industry. Inserted disc cutters make this transition possible.

Read More
Basics

What are Harmonics in Milling?

Milling-force harmonics always exist. Understanding the source of milling harmonics and their relationship to vibration can help improve parameter selection.

Read More
Basics

4 Steps to a Cobot Culture: How Thyssenkrupp Bilstein Has Answered Staffing Shortages With Economical Automation

Safe, economical automation using collaborative robots can transform a manufacturing facility and overcome staffing shortfalls, but it takes additional investment and a systemized approach to automation in order to realize this change.

Read More
Basics

Custom Workholding Principles to Live By

Workholding solutions can take on infinite forms and all would be correct to some degree. Follow these tips to help optimize custom workholding solutions.

Read More

Read Next

Tooling

IMTS 2024: Trends & Takeaways From the Modern Machine Shop Editorial Team

The Modern Machine Shop editorial team highlights their takeaways from IMTS 2024 in a video recap.

Read More
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
Sumitomo