Workpiece Zero CNC Macro for G54

CNC Macro for FANUC OM

It’s a simple macro associated with an M20 m-code. It store actual absolute machine position into the G54 X and Y value. The M21 macro code that will calculate the Z with the tool lenght and set the G54 Z value.

The M20 Program is as follow;
%
9021(ZERO G54 XY)
#2501=#5021
#2601=#5022
M99
%
And the M21 for teaching Z;
%
9022(ZERO G54 Z)
IF[#4120GE21] GOTO10
IF[#4120EQ0] GOTO10
#500=#[2200 + #4120]
#2701=#5023-#500
#3000=1 (G54 Z TEACH SUCCESS)
M99
N10 #3000=99 (TOOL NUMBER MISSING )
M99 %
M25 code that you can use to teach tool height,
Touch the tool measuring device and input an M25Tnn in MDI. the macro does the math of current tool height minus current machine position and store the result in the Tool Height Offset page.
%
9025 (TOOL TEACH)
#500=[2200+#4120]
#[#500]=#5023
M99
%
To unlock 9000+ program, bit 5 of parameter #0010 must be set to 0; #0010= 10010001 9000 Protect on #0010= 10000001 9000 Protect off .
Parameter #230 & up tells which program number are associated with which M code, be careful not to delete your tool change program which is usually 9020. #230=M6=9020 #231=M20=9021 etc… If you have no idea what these are, what they do and how to play with your machine parameter, I would strongly advise not to change anything in your controller.

For more information on the use of macros see the following post:

Leave a Reply