0% found this document useful (0 votes)
647 views3 pages

Fanuc CNC Macro Programming

Fanuc's Custom Macro B enables parametric programming with variables, arithmetic operations, and control statements for CNC programming. Key features include local and common variables, various arithmetic functions, conditional branches, loops, and system variables. Common macro commands like G65 and M98 facilitate macro calls and subprogram management.

Uploaded by

saisandhiya31
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
647 views3 pages

Fanuc CNC Macro Programming

Fanuc's Custom Macro B enables parametric programming with variables, arithmetic operations, and control statements for CNC programming. Key features include local and common variables, various arithmetic functions, conditional branches, loops, and system variables. Common macro commands like G65 and M98 facilitate macro calls and subprogram management.

Uploaded by

saisandhiya31
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Fanuc CNC Macro Programming (Custom Macro

B) Codes
Fanuc's Custom Macro B is a powerful programming feature that allows for
parametric programming, variables, logic operations, and complex calculations in
CNC programs. Here are the key elements:

Variables
 #1-#33 - Local variables (volatile)
 #100-#199 - Common variables (retain values after power off)
 #500-#999 - Persistent common variables (retain values after power off)
 #1000+ - System variables (read-only)

Arithmetic Operations
text
#i = <expression> (Assignment)
+ (Addition)
- (Subtraction)
* (Multiplication)
/ (Division)
MOD (Modulo)
SIN (Sine)
COS (Cosine)
TAN (Tangent)
ATAN (Arctangent)
SQRT (Square root)
ABS (Absolute value)
ROUND (Rounding)
FIX (Truncate)
FUP (Round up)

Control Statements
Conditional Branches
text
IF [<conditional expression>] GOTO n
IF [<conditional expression>] THEN <assignment>
Loops
text
WHILE [<condition>] DO m
...
END m

Comparison Operators
text
EQ (Equal to)
NE (Not equal to)
GT (Greater than)
GE (Greater than or equal to)
LT (Less than)
LE (Less than or equal to)

System Variables (Examples)


 #3000 - Alarm generation
 #3001-#3006 - Clock/time data
 #4001-#4120 - Modal information
 #5001-#5104 - Tool offset values
 #5221-#5315 - Work coordinate system offsets

Common Macro Commands


text
G65 - Macro call with arguments
G66 - Modal macro call
G67 - Cancel modal macro call
M98 - Subprogram call
M99 - Subprogram end/return

Example Programs
Simple Hole Pattern Macro
text
O9010 (HOLE PATTERN MACRO)
#1=#1+1 (COUNTER)
#2=#5001+#1*#7 (X POSITION)
#3=#5002+#1*#8 (Y POSITION)
G90 G00 X#2 Y#3
G81 Z-#9 R1.0 F#17
M99

Conditional Example
text
IF [#20 LE 0] GOTO 100
WHILE [#1 LT #20] DO 1
G01 X[#1*#5] Y[#1*#6] F#9
#1=#1+1
END 1
N100 M99

Tool Life Management


text
IF [#4120 EQ 0] GOTO 100
#100=#100+1 (INCREMENT TOOL LIFE COUNTER)
IF [#100 LT #101] GOTO 200 (TOOL LIFE OK)
#3000=1 (TOOL LIFE EXPIRED)
N200 M99
N100 #3000=2 (NO TOOL SELECTED)

You might also like