G67 is a G-code that is used to cancel the modal call of a macro program in CNC machines. A macro program is a set of instructions that can perform complex calculations, conditional branching, and parameter manipulation. A macro program can be called by another program using a G65 or G66 command, which are known as macro modal calls. A macro modal call means that the macro program will be executed repeatedly until it is canceled by a G67 command or another macro modal call.
Usage format
The general format of G67 is:
G67 P_ Q_
where:
P_
is the number of the macro program to be canceled. It must match the number of the macro program that was called by G65 or G66. If omitted, the last called macro program will be canceled.Q_
is an optional parameter that can be used to pass a value to the macro program before it is canceled. This can be useful for performing some final actions or calculations in the macro program.
Explanation
G67 is used to terminate the execution of a macro program that was called by G65 or G66. G65 and G66 are different in how they execute the macro program. G65 executes the macro program once and returns to the main program. G66 executes the macro program and stays in it until it is canceled by G67 or another macro modal call. G67 can be used to cancel either G65 or G66, but it is more commonly used with G66.
G67 can be placed anywhere in the main program after the macro modal call. It can also be placed inside the macro program itself, in which case it will cancel the macro program and return to the main program. G67 can also be used to cancel a macro program that was called from another macro program, as long as the P value matches the number of the macro program.
Example
Here is an example of a main program that uses G67 to cancel a macro program:
O1000 (Main program)
N10 G90 G00 X0 Y0 Z0 (Rapid move to origin)
N20 G66 P1000 Q10 (Call macro program 1000 with Q value 10)
N30 G01 X50 F500 (Linear move to X50)
N40 G67 P1000 Q20 (Cancel macro program 1000 with Q value 20)
N50 G01 Y50 (Linear move to Y50)
N60 M30 (End of program)
Here is the macro program 1000:
O1000 (Macro program)
#1 = #18 + #19 (Add current X and Y position)
#2 = #1 + #20 (Add Q value to the result)
G01 Z-#2 F100 (Drill a hole with depth equal to the result)
G00 Z0 (Rapid move to Z0)
M99 (End of macro program)
In this example, the main program calls the macro program 1000 with a Q value of 10 using G66. This means that the macro program will be executed repeatedly until it is canceled. The macro program performs a calculation based on the current X and Y position and the Q value, and drills a hole with the depth equal to the result. Then it returns to the main program and repeats the process.
The main program then moves to X50 and cancels the macro program 1000 with a Q value of 20 using G67. This means that the macro program will be executed one last time with the new Q value, and then return to the main program and not repeat. The main program then moves to Y50 and ends.
The result of this example is that four holes will be drilled at different depths, depending on the X and Y position and the Q value. The first hole will be at X0 Y0 with a depth of 10, the second hole will be at X10 Y0 with a depth of 30, the third hole will be at X20 Y0 with a depth of 50, and the fourth hole will be at X50 Y0 with a depth of 120.