Aitrtech
Published

Modal Custom Macros

These commands can fully emulate canned cycles to perform repetitive CNC machine operations like hole making.

Share

Think of how hole-making canned cycles work. You provide one command (like G81) that sets the initial variables (XY position, rapid plane, hole-bottom position and feed rate), and the CNC machines the first hole. Each subsequent command will machine another hole. You need only provide the information that changes for each additional hole, like the new XY position. Once you have listed the last hole, you specify a G80 command to cancel the canned cycle.

The G66.1 custom macro calling word lets you do the same thing with your own user-created canned-cycle custom macro programs. You can even create a user-defined G code to call it and modify the function of G80 to cancel it it (although we don’t show how to do this in this short article).

G66.1 will accomplish three things:

1. It will set local variables based on the included letter-address arguments.

2. It will execute the program specified by the P word included in the G66.1 command.

3. It will cause each subsequent command to repeat steps one and two until a G67 word is executed (canceling the modal custom macro calling state).

When the custom-macro-ending M99 word is executed, however, all local variables will be set back to vacant (null). If they are to be retained for the next (modal) command, your custom macro program must transfer local variables to more permanent common variables.

Here is a full example that uses this technique for a thread-milling custom macro:
 

Consider this calling program:
O0022 (Main program)
N005 G90 G54 S500 M03
N010 G00 X0 Y0
N015 G43 H01 Z1.0
N020 G66.1 P1007 X2.0 Y2.0 Z0.75 T1.0 Q0.125 M3.0 A1.0 F5.0 B1.0 (Call custom macro, mill first thread)
N025 X9.0 (Call custom macro, mill second thread)
N030 Y8.0 (Call custom macro, mill third thread)
N035 X2.0 (Call custom macro, mill fourth thread)
N040 G67
N045 G91 G28 Z0
N050 M30

In line N020, the CNC will set the local variables #24, #25, #26, #20, #17, #13, #1, #9 and #2 to the settings for letter address arguments X, Y, Z, T, Q, M, A, F and B, respectively. It will then execute program O1007 (shown below). It will do the same for line N025, machining the second hole, and two more times for lines N030 and N035. The G67 in line N040 cancels the modal calling state.

In lines N025, N030, and N035, only one local variable (per command) is being assigned. Special care must be given in program O1007 so as not to lose the values of other important arguments. The first 18 commands or so show how:

O1007 (Taper thread milling program)
(Make arguments more permanent)
IF[#24 NE #0] THEN #121 = #24 (X)
IF[#25 NE #0] THEN #122 = #25 (Y)
IF[#26 NE #0] THEN #123 = #26 (Z)
IF[#20 NE #0] THEN #124 = #20 (T)
IF[#17 NE #0] THEN #125 = #17 (Q)
IF[#13 NE #0] THEN #126 = #13 (M)
IF[#1 NE #0] THEN #127 = #1 (A)
IF[#9 NE #0] THEN #128 = #9 (F)
IF[#2 NE #0] THEN #129 = #2 (B)
(Re-assign local variables)
#24 = #121
#25 = #122
#26 = #123
#20 = #124
#17 = #125
#13 = #126
#1 = #127
#9 = #128
#2 = #129
(Reset T and M as radius values)
#20 = #20 / 2 
#13 = #13 / 2 
IF[#2 EQ 1.0] GOTO 20 
(Calculations for top to bottom)
#101 = #24 - #1 + #20 
#102 = #24 + #1 - #20
#103 = #25 + #13 - #20 
#104 = #25 + #13 - #1 
#105 = -[#26 + #17/4]
#106 = #105 - #17/2 
#107 = #106 - #17/2 
#108 = #107 - #17/4 
#109 = #1 - #20
#110 = #13 - #20 
#111 = #25 - #13 + #20
#112 = 2
GOTO 60
(Calculations for bottom to top)
N20 #101 = #24 + #1 - #20 
#102 = #24 - #1 + #20
#103 = #25 + #13 - #20 
#104 = #25 + #13 - #1
#105 = -[#26 - #17/4] 
#106 = #105 + #17/2 
#107 = #106 + #17/2 
#108 = #107 + #17/4 
#109 = #1 - #20 
#110 = #13 - #20
#111 = #25 - #13 + #20 

In this way, creating modal custom macros that fully emulate canned cycles can help you easily perform repetitive machining operations.

 

The World According To
UPM Additive Solutions
Airtech
Acquire
Koma Precision
DN Solutions
Techspex
SolidCAM
JTEKT
QualiChem Metalworking Fluids
More blasting. Less part handling.
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
Basics

4 Commonly Misapplied CNC Features

Misapplication of these important CNC features will result in wasted time, wasted or duplicated effort and/or wasted material.

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

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

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
Software

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
3D printing machine trainings