📖CNC Macro Programming

Macro B Variables & Parametric Equations


What is Macro B Programming?

Standard G-code is linear and static. To machine families of parts, write custom pockets, or perform complex logic, we use Fanuc Macro B variables.

NOTE

Macro B variables are prefixed with a # symbol and are classified into local (#1-#33), common (#100-#199), and system variables (#5000+).

Macro Calculations & Variables

In this lesson, we define the parameters of a rectangular contour:

  • #100 = Width of the pocket in X (3.000″)
  • #101 = Length of the pocket in Y (2.000″)
  • #102 = Depth of Cut (0.250″)
  • Dynamic Coordinate Offsets

    Instead of hardcoding positions, the G-code commands compute coordinates dynamically:

  • G01 X#100 F20.0 engages the tool to the parameter width.
  • Changing #100 updates the toolpath envelope instantly without rewriting lines of G-code!
  • Live Blueprint Preview
    XY
    X: 0.000Y: 0.000Z: 0.100
    ACTIVE LESSON PROGRAMISO FORMAT
    10
    #100 = 3.000 (X Pocket Width)
    20
    #101 = 2.000 (Y Pocket Length)
    30
    #102 = 0.250 (Depth of Cut)
    40
    G90 G17 G20 (Absolute Mode)
    50
    G00 X0.00 Y0.00 Z0.100 (Rapid to Start)
    60
    G01 Z-#102 F10.0 (Engage Z depth)
    70
    G01 X#100 F20.0 (Cut Width X)
    80
    G01 Y#101 (Cut Length Y)
    90
    G01 X0.00 (Return to X0)
    100
    G01 Y0.00 (Return to Y0)
    110
    G00 Z0.100 (Retract Z)
    120
    M30 (Program End)