Skip to main content

FOCAS Adapter Script Configuration

This page covers the FOCAS-specific data sources an adapter script can read. For adapter script syntax itself — variables, operations, expressions — see the Adapter Scripts reference.

Adapter Script Configuration​

Macro Variables​

Macro variables provide access to custom data stored in the control.

Common Use Cases:

  • Custom part counters
  • Process parameters
  • Quality measurements
  • Tool life tracking
  • Automation status

Basic Configuration Example:

{
"macros": {
"custom_part_count": 510,
"tool_life_remaining": 520,
"temperature_setpoint": 530
}
}

With Path Specification:

For multi-path machines or specific path targeting:

{
"macros": {
"X1_Wear_1": 2001,
"X1_Wear_2": {
"addr": 2002,
"path": [1]
},
"X1_Wear_3": {
"addr": 2003,
"path": [1]
}
}
}

Data Mapping: Map each macro to appropriate type:

  • Part counts → Part Count / Target or Actual
  • Measurements → Sample / (appropriate subtype)
  • Status → Event or Condition

PMC (Programmable Machine Control)​

PMC allows direct access to PLC inputs and outputs within the FANUC control.

What is PMC?

  • PMC is FANUC's built-in PLC functionality
  • X-addresses = Inputs (from machine sensors, switches, relays)
  • Y-addresses = Outputs (to machine actuators, lights, relays)
  • Used for machine logic, interlocks, and automation

Common Use Cases:

  • Door interlocks
  • Collet open/close status
  • Chuck clamp/unclamp status
  • Bar feeder status
  • Coolant status
  • Stack lights
  • Key switches
  • Air cut status
  • One-cycle mode

Configuration Example:

⚠️ IMPORTANT: The addresses below are examples only. PMC addresses vary by machine model and machine tool builder. You must find the correct addresses for your specific machine in the machine manual or PMC ladder diagram.

{
"pmc": {
"X5_0_MAIN_COLLET_OPEN": "X5.0",
"X5_1_MAIN_SP_CLAMP": "X5.1",
"X5_2_MAIN_SP_UNCLAMP": "X5.2",
"X5_3_CUT_OFF_TOOL_OFF": "X5.3",
"X5_4_CUT_OFF_TOOL_ON": "X5.4",
"X9_1_DOOR_INTLOCK_MAIN": "X9.1",
"X7_0_BAR_STOCK_EMPTY": "X7.0",
"X7_3_BAR_FEED_READY": "X7.3",
"X47_6_KEY_SWITCH": "X47.6",
"Y53_5_ONE_CYCLE": "Y53.5",
"Y53_1_AUTO_CUT_OFF": "Y53.1",
"Y53_2_AIR_CUT": "Y53.2",
"Y52_3_MACRO_BUTTON": "Y52.3"
}
}

Finding PMC Addresses:

  1. Access PMC Diagnosis

    • Press SYSTEM → PMC → DIAGNOS
    • Shows real-time X (inputs) and Y (outputs)
  2. Identify Address

    • Watch PMC screen while activating machine function
    • Example: Open door → watch for bit that changes
    • Note the address (e.g., X9.1 for door interlock)
  3. Name Descriptively

    • Use clear, descriptive names
    • Include location if multi-spindle (e.g., MAIN, SUB)
    • Document what triggers the signal

Data Mapping:

  • Binary signals (0 or 1)
  • Map to Event type in MachineMetrics
  • Use for automation triggers, alerts, or dashboards

Here's an example of a fully configured PMC adapter in MachineMetrics, with the JSON showing G/Y/F addresses:

MachineMetrics Edit Data Collection Method for a FANUC FOCAS machine — "Configure your adapter" field showing PMC JSON with addresses G0070.5, Y0030.6, G0007.2, Y0025.5, Y0025.4, Y0026.6, F0000.6, F0000.7, F0002.0, F0002.6

MachineMetrics adapter JSON close-up — PMC section showing G and Y address keys mapped to their address string values (e.g., "G0070.5": "G0070.5")

After saving, go to Data Mapping to configure each PMC signal. Click any data item to open the Edit dialog:

MachineMetrics Edit Data Item dialog — Controller / PMC component; Diagnostics Preview shows G0070.5 = 1 (active); Key Name = G0070.5; Type = Register

Use the Diagnostics Preview panel to verify signal values in real time:

MachineMetrics Diagnostics Preview panel — CONTROLLER / PMC section showing G007.2 = 0 and G0070.5 = 1; System = NORMAL (green)

MachineMetrics Diagnostics Preview panel — CONTROLLER / PMC section showing Spindle Running = 1 (active), Cycle Start = 0; System = NORMAL (green)

PMC Data Types and Address Formats​

PMC registers support three configuration patterns depending on whether you need the full byte, a single bit, or a specific multi-byte data type.

PatternDescriptionExample key/value
Address stringDefault data type is BYTE — monitors the entire byte at the register address"G54": "G54"
Bit notation (Gxxxx.N)Monitors a single bit within a register; the .N suffix selects bit N"G0070.5": "G0070.5"
Extended JSON objectSpecifies an explicit data type (BYTE, WORD, or DWORD) using address and dtype keys"D124": { "address": "D124", "dtype": "DWORD" }

Valid dtype values: BYTE, WORD, DWORD

  • Monitoring the entire byte at a PMC register address — When a PMC register is configured with a plain address string, the default data type is BYTE. The adapter reads and reports the full byte value at that register. Example: "G54": "G54" tracks the byte value at G54.
  • Monitoring an individual bit in a PMC register — The Gxxxx.N notation targets bit N within the register. Example: "G0070.5": "G0070.5" tracks and reports the 5th bit of register G0070.
  • Monitoring a PMC register with a specified data type — To read D-addresses or any multi-byte register (WORD or DWORD), use the extended JSON object form with address and dtype keys. Example: "D124": { "address": "D124", "dtype": "DWORD" }.

Example adapter JSON combining all three patterns:

{
"pmc": {
"G54": "G54",
"G0070.5": "G0070.5",
"D124": { "address": "D124", "dtype": "DWORD" }
}
}
tip

Use the extended JSON object form ({ "address": "...", "dtype": "..." }) whenever you need to monitor D-addresses or any multi-byte register. Plain address strings always default to BYTE.


P-Codes (Machine Builder Data Table)​

P-codes provide access to data stored by machine tool builders in FANUC controls.

What are P-Codes?

  • P-codes are a table where machine tool builders store their custom information
  • Machine-specific: P-code addresses vary by machine make, model, and control
  • Not standardized: Never assume P-code addresses are the same across different FANUC machines
  • Used by OEMs to store custom data relevant to their machine design

Common MachineMetrics Use Case: Tool Life Tracking

While P-codes can store any machine builder data, MachineMetrics most commonly uses them to track tool life management (TLM) data.

⚠️ IMPORTANT: P-code addresses for tool life are machine-specific. You must discover the addresses for each machine using the procedure below.


How to Discover P-Code Addresses for Tool Life​

Follow these steps to identify which P-code addresses contain tool life data on your specific machine:

Step 1: Enable Parameter Write (PWE)

  1. See Enabling Parameter Write for instructions
  2. Enable PWE to allow parameter changes

Step 2: Set Parameter 9000#1 (NDP) = 1

  1. Press SYSTEM button
  2. Navigate to Parameters
  3. Search for parameter 9000
  4. Set bit #1 (NDP) = 1
    • This enables P-code variable display

Step 3: Access Macro Screen

  1. Press OFFSET hard key
  2. Press Macro screen key
  3. Press EXEC screen key
  4. You should now see P-code variables

Step 4: Output P-Code Variables to USB

  1. Press OPRT menu key
  2. Select Output or Punch
  3. Set I/O channel:
    • 17 for USB
    • 4 for Memory Card
  4. Specify output file name (e.g., PCODE.TXT)
  5. Execute output
  6. P-code variables will be saved to USB/card

Step 5: Restore Settings

  1. Set parameter 9000#1 back to 0
  2. Turn off PWE (see Parameter Safety)

Step 6: Take Photo of TLM Screen

  1. On the CNC control, navigate to the Tool Life Management (TLM) screen
  2. Take a clear photo showing:
    • Tool group numbers
    • Tool life preset values
    • Tool life count/remaining values
  3. Note which tools are in use and their current counts

Step 7: Match Values on PC/Mac

  1. Open the P-code output file from USB on your computer
  2. Search for the values from the TLM screen photo
  3. Look for clusters of values that match TLM data
  4. P-code addresses for related TLM data will be close together
  5. Document the addresses:
    • Which P-codes = Tool Life Preset
    • Which P-codes = Tool Life Count
    • Which tool groups they correspond to

Example:

If you see on TLM screen:

  • Tool Group 1: Preset = 500, Count = 350
  • Tool Group 2: Preset = 1000, Count = 750

Search P-code file for 500 and 350 (should be near each other), and 1000 and 750.

You might find:

  • P-code 12101 = 500 (Tool 1 Preset)
  • P-code 12201 = 350 (Tool 1 Count)
  • P-code 12102 = 1000 (Tool 2 Preset)
  • P-code 12202 = 750 (Tool 2 Count)

Configuration Example​

Once you've identified P-code addresses, configure them in MachineMetrics:

{
"pcodes": {
"TLM_1_PRESET": {
"addr": 12101,
"path": [1]
},
"TLM_1_COUNT": 12201,
"TLM_2_PRESET": 12102,
"TLM_2_COUNT": 12202,
"TLM_3_PRESET": 12103,
"TLM_3_COUNT": 12203,
"TLM_4_PRESET": 12104,
"TLM_4_COUNT": 12204,
"TLM_5_PRESET": 12105,
"TLM_5_COUNT": 12205
}
}

Replace the addresses (12101, 12201, etc.) with the addresses discovered from your specific machine.


Other P-Code Use Cases​

Beyond tool life, P-codes may contain:

  • Custom part counters
  • Machine-specific process parameters
  • OEM-specific automation data
  • Pallet changer status
  • Bar feeder information
  • Custom measurements or setpoints

To discover what data is in P-codes:

  • Use the same procedure above
  • Cross-reference P-code values with machine displays
  • Consult machine builder documentation
  • Contact machine OEM for P-code map

Data Mapping in MachineMetrics​

For Tool Life:

  • Preset values → Map to Target or Setpoint
  • Count/Remaining values → Map to Actual or Sample
  • Can calculate remaining life (Preset - Count)

For Other Data:

  • Map to appropriate type based on data purpose
  • Use descriptive names in JSON configuration
  • Document what each P-code represents

Complete Advanced JSON Example​

Here's a comprehensive example combining PMC, P-codes, and macros for a multi-spindle lathe with tool life management:

⚠️ IMPORTANT: These addresses are examples only. PMC addresses, P-codes, and macro numbers vary by machine model and machine tool builder. You must find the correct addresses for your specific machine in the machine manual or PMC ladder diagram.

{
"pmc": {
"X5_0_MAIN_COLLET_OPEN": "X5.0",
"X5_1_MAIN_SP_CLAMP": "X5.1",
"X5_2_MAIN_SP_UNCLAMP": "X5.2",
"X5_3_CUT_OFF_TOOL_OFF": "X5.3",
"X5_4_CUT_OFF_TOOL_ON": "X5.4",
"X9_1_DOOR_INTLOCK_MAIN": "X9.1",
"X7_0_BAR_STOCK_EMPTY": "X7.0",
"X7_3_BAR_FEED_READY": "X7.3",
"X47_6_KEY_SWITCH": "X47.6",
"Y53_5_ONE_CYCLE": "Y53.5",
"Y53_1_AUTO_CUT_OFF": "Y53.1",
"Y53_2_AIR_CUT": "Y53.2",
"Y52_3_MACRO_BUTTON": "Y52.3"
},
"pcodes": {
"TLM_1_PRESET": {
"addr": 12101,
"path": [1]
},
"TLM_1_COUNT": 12201,
"TLM_2_PRESET": 12102,
"TLM_2_COUNT": 12202,
"TLM_3_PRESET": 12103,
"TLM_3_COUNT": 12203,
"TLM_4_PRESET": 12104,
"TLM_4_COUNT": 12204,
"TLM_5_PRESET": 12105,
"TLM_5_COUNT": 12205,
"TLM_6_PRESET": 12106,
"TLM_6_COUNT": 12206,
"TLM_7_PRESET": 12107,
"TLM_7_COUNT": 12207,
"TLM_8_PRESET": 12108,
"TLM_8_COUNT": 12208,
"TLM_9_PRESET": 12109,
"TLM_9_COUNT": 12209,
"TLM_10_PRESET": 12110,
"TLM_10_COUNT": 12210
},
"macros": {
"X1_Wear_1": 2001,
"X1_Wear_2": {
"addr": 2002,
"path": [1]
},
"X1_Wear_3": {
"addr": 2003,
"path": [1]
},
"X1_Wear_4": {
"addr": 2004,
"path": [1]
},
"X1_Wear_5": {
"addr": 2005,
"path": [1]
},
"Z1_Wear_1": {
"addr": 2101,
"path": [1]
},
"Z1_Wear_2": {
"addr": 2102,
"path": [1]
},
"Z1_Wear_3": {
"addr": 2103,
"path": [1]
},
"Z1_Wear_4": {
"addr": 2104,
"path": [1]
},
"Z1_Wear_5": {
"addr": 2105,
"path": [1]
},
"X2_Wear_1": {
"addr": 2001,
"path": [2]
},
"X2_Wear_2": {
"addr": 2002,
"path": [2]
},
"X2_Wear_3": {
"addr": 2003,
"path": [2]
},
"X2_Wear_4": {
"addr": 2004,
"path": [2]
},
"X2_Wear_5": {
"addr": 2005,
"path": [2]
},
"Z2_Wear_1": {
"addr": 2101,
"path": [2]
},
"Z2_Wear_2": {
"addr": 2102,
"path": [2]
},
"Z2_Wear_3": {
"addr": 2103,
"path": [2]
},
"Z2_Wear_4": {
"addr": 2104,
"path": [2]
},
"Z2_Wear_5": {
"addr": 2105,
"path": [2]
}
}
}

This example demonstrates:

  • PMC signals for machine status (collet, chuck, bar feeder, doors)
  • P-codes for tool life management (10 tool groups)
  • Macro variables for tool wear offsets (2 paths, 5 tools per axis)
  • Path specification for multi-spindle machines

Configuration Steps:

  1. Add JSON to Machine Configuration

    • Assets → Machines → Select Machine → Edit
    • Data Collection → Adapter Configuration
    • Paste JSON into adapter script field
  2. Save and Wait for Data Collection

    • Save configuration
    • Wait 1-2 minutes for data to appear
  3. Map Data Items

    • Assets → Machines → Data Mapping
    • All new data items appear in left column
    • Map each to appropriate type:
      • PMC signals → Event
      • P-code presets → Target
      • P-code counts → Actual
      • Macro wear values → Sample
  4. Verify Data in Diagnostics

    • Navigate to machine → Diagnostics tab
    • Check that all configured items are reporting
    • Verify values match control screen

Multi-Path Machines​

Multi-path (multi-channel) machines have multiple independent machining processes.

Configuration:

{
"macros": {
"path1_parts": 501,
"path2_parts": 502,
"all_paths_status": { "addr": 600, "path": [-1] }
}
}

Data Mapping:

  • Path 2+ data items will have path number suffixed
  • Example: all_paths_status (path 1), all_paths_status2 (path 2)

Components:

  • Map data to correct path/spindle
  • Path naming may not directly correspond (e.g., A12 in data vs A2 in UI)
  • Use domain knowledge to match components correctly

Diagnostics Configuration​

Common Diagnostics:

CodeDescriptionType
200Servo Alarm StatusBitfield
308Servo Motor TemperatureNumeric (°C)
309Pulsecoder TemperatureNumeric (°C)
403Spindle TemperatureNumeric (°C)
300Servo LoadNumeric (%)

Configure diagnostics in the adapter JSON:

MachineMetrics adapter JSON — diagnostics block showing codes "202", "203", "204", "300", "301", "308", "309", "380", "381", "403" all mapped to empty string values (auto-named by code)

Bitfield Diagnostics:

  • Some diagnostics encode multiple values in bits
  • MachineMetrics automatically extracts each bit
  • Example: Diag200Bit0_X, Diag200Bit1_X, etc.

Diagnostic Key Format:

  • Diag[Code]_[Axis/Spindle][Path]
  • Example: Diag308_Z = Servo temp for Z axis
  • Example: Diag403_S2 = Spindle temp for spindle 2

After saving, go to Data Mapping and map each diagnostic item:

MachineMetrics Edit Data Item — Linear / Z2 component; Diagnostics Preview shows "Servo Temperature = 36"; Key Name = Diag308_Z2; Display Name = "Servo Temperature"; Type = Sample / Temperature

MachineMetrics Edit Data Item — Rotary / A2 component; Diagnostics Preview shows "Servo Motor Temperature = VALUE" (reading live); Key Name = Diag308_A12; Display Name = "Servo Motor Temperature"; Type = Sample / Temperature

After mapping all axes, the Data Mapping list will show all Diag308 items per axis:

MachineMetrics Data Mapping list filtered for "Diag308" — showing Diag308_C, Diag308_C2, Diag308_X, Diag308_X2, Diag308_Y, Diag308_Y2, Diag308_Z, Diag308_Z2 all mapped as Sample / Temperature for Rotary and Linear component types

Live diagnostics view in MachineMetrics:

MachineMetrics Diagnostics panel — LINEAR / Z2 axis: Actuator = NORMAL, R Phase Current = -14, Effective Current = -119, Load = 6, Servo Temperature = 36 (highlighted), Pulsecoder Temperature = 40, DC Link Voltage = 205

Mapping Tips:

  • Use descriptive display names
  • Map to correct Component/Subcomponent
  • Pay attention to multi-path naming differences
  • Refer to FANUC manuals for diagnostic code meanings

Tool Offsets​

Tool offset configuration allows tracking of tool wear and compensation values.

Configuration in MachineMetrics:

  1. Edit machine → Data Collection
  2. Enable tool offset tracking
  3. Map tool data items

MachineMetrics Machine Settings → Data Collection — Fanuc FOCAS integration shown as connected (Online) at IP 172.16.2.140; Data Collection Methods section with existing FOCAS method and "+ Add a new Data Collection Method" button

After refreshing the data items list, tool offset entries appear in Data Mapping. Open any item to configure:

MachineMetrics Edit Data Item — Tool Offsets / Tool1 component; Diagnostics Preview shows "Length Geometry = UNAVAILABLE" (reading live); Key Name = LgeoT1; Display Name = "Length Geometry"; Type = Info / Custom subtype

Use Cases:

  • Tool wear monitoring
  • Predictive tool replacement
  • Quality correlation with tool condition

Rapid Dial Address​

For tracking feed/rapid override dial position:

Purpose: Display real-time override percentage in dashboards

Finding the Rapid Dial Address:

  1. Access PMC Diagnosis

    • Press SYSTEM → PMC → DIAGNOS
    • This shows I/O monitor with X-addresses (inputs)
  2. Search for Override Dial

    • Press SEARCH → type X0 → EXECUTE
    • Rotate rapid/feed-override dial slowly (0 → 25 → 50 → 75 → 100%)
    • Watch for bits that flip when dial moves
  3. Identify the Address

    • Note full address (e.g., X010 or X10)
    • Confirm by rotating back and forth
    • Only that X-word should toggle with dial
  4. Map Each Position

    • Record binary pattern for each detent
    • Example: 0% = 0000, 25% = 0001, 50% = 0010, etc.
  5. Contact MachineMetrics

    • Provide X-address and mapping
    • We'll configure dashboard to show correct percentage