FANUC 16M Macros: Configuring Protected Program Inputs

Jason IP2 min read
FanucOther TopicTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Use common variables when a FANUC 16M main program must supply values to a write-protected subprogram. Local variables do not carry from the main program into a separately called program; common variables do. For explicit macro arguments, use a G65 call and read the corresponding local variables inside the macro.

Choose the correct macro variable scope

Variable class Evidence-supported range Use in this application
Local Below #100 Use only within the active program context. A value assigned to #1 in the main program is not available as #1 in another subprogram or macro.
Common #100 through #499 Assign a value in the main program and read the same variable in the called program.
Nonvolatile Above #500 Retains its value after control power is cycled.
System Application-dependent Exposes CNC state such as I/O, offsets, axis positions, and probe-trigger positions; the supplied evidence describes these variables as not user-assignable.

The evidence does not define the treatment of exactly #500. Verify that boundary on the specific control before using it. It also does not document which individual system variables are available on the installed machine.

Pass shared values through common variables

  1. Assign the required inputs to common variables such as #101 in the editable main program.
  2. Call the protected subprogram or macro.
  3. Read #101 from the called program and use it without editing the protected program.
  4. Verify the result using a harmless test value before running the machining cycle.

This method suits protected routines for repeated features such as pockets, keys, flat-bottom holes, spring pockets, and bolt circles. Keep operator-entered values in the editable main program while retaining the machining logic in the protected program.

Pass arguments with a G65 macro call

G65 provides an alternative when each call should supply its own arguments. The supplied example calls macro program O9250 and passes three values:

G65 P9250 A1.0 B3.4 C5.123

For this documented example, the called macro receives A as #1 with value 1.0, B as #2 with value 3.4, and C as #3 with value 5.123. The evidence does not provide a complete address-to-variable assignment table, so verify other letter mappings on the applicable FANUC documentation before using them.

Select a call strategy and verify it

Use common variables when operators need an editable input area at the top of a main program. Use G65 when inputs belong to one explicit macro invocation. A G66 modal call was also reported as an operator-preferred arrangement, but the evidence supplies neither its syntax nor its cancellation procedure; confirm both before applying it.

For either method, prove the data path independently of cutting: assign distinct values, call the protected routine, and confirm that it reads the intended variables. This separates variable-scope errors from machining-logic errors.

FAQ

Why can my FANUC 16M subprogram not read #1 from the main program?

#1 is a local variable. A value assigned to it in the main program does not carry into another subprogram or macro; use a common variable such as #101 or pass the value as a G65 argument.

Which FANUC macro variables carry values into another program?

The supplied evidence identifies #100 through #499 as common variables. Assign the variable in the main program, call the protected program, and read the same variable number there.

How do I pass A, B, and C values with G65?

Use a call such as G65 P9250 A1.0 B3.4 C5.123. In the supplied example, macro O9250 reads those arguments as #1, #2, and #3 respectively.

Back to blog