Starrett 2900 Series Digital Indicators
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.

 

Starrett 2900 Series Digital Indicator
Kennametal
Precision Components
Koma Precision
Hurco
Paperless Parts
benchmark international advanced manufacturing trade show
CHIRON Group, one stop solution for manufacturing.
SolidCAM
DN Solutions
Paperless Parts
Kennametal

Read Next

Aerospace

5 Tips for Running a Profitable Aerospace Shop

Aerospace machining is a demanding and competitive sector of manufacturing, but this shop demonstrates five ways to find aerospace success.

Read More

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
Paperless Parts