For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connecting a FANUC CNC via FOCAS

How to read machine status, program, spindle, and feed data from a FANUC CNC control with the FOCAS connector and map it into an ISA-95 style MQTT topic hierarchy.

This guide shows you how to read machine status, program, spindle, and feed data from a FANUC CNC control with the Connectware FOCAS connector and map it into an ISA-95 style MQTT topic hierarchy. FOCAS is FANUC's library-based interface for accessing CNC data over Ethernet (FOCAS1/FOCAS2) and is available for common FANUC series such as the 30i/31i/32i and 0i series. The data collected here (run state, executed program, feed rate, spindle speed, and spindle load) is the typical input for machine monitoring, OEE dashboards, and condition monitoring applications. In more detail, the following topics are covered:

  • Understanding how the FOCAS connector addresses data through driver methods

  • Choosing the driver methods and polling intervals

  • Mapping the data into an ISA-95 style MQTT topic hierarchy

  • Reading data on demand with the request/response pattern

  • Verifying data in the Data Explorer

This guide focuses on reading data from the machine. The connector can also write NC programs to the controller with the program_download method. For the complete method catalog, see the FOCAS connector reference.

A complete example file is available at the end of this guide.

Prerequisites

To follow this guide, you will need the following:

  • A running instance of Cybus Connectware.

  • A FANUC CNC control that is reachable over Ethernet from Connectware. The machine requires the FOCAS Ethernet function, which is an option on many machines. Your machine tool builder or FANUC can confirm whether it is installed on your control and provide the FANUC FOCAS documentation. The FOCAS interface listens on TCP port 8193 by default.

  • Access to the Admin UI with sufficient user permissions.

  • Basic knowledge of MQTT and the Connectware services concept (for example, service commissioning files, connections, and endpoints).

How the FOCAS Connector Addresses Data

Connectors such as Modbus/TCP or S7 address individual registers or variables. The FOCAS connector works differently: it provides a set of driver methods, and each method corresponds to a function of the FOCAS library that returns related CNC data as one structured JSON object. For example, cnc_statinfo2 returns the automatic mode, run state, motion, alarm, and emergency stop information in a single result, and cnc_rdspeed returns the actual feed rate and the actual spindle speed together. You do not assemble memory addresses yourself; the driver maps each method to the underlying CNC data internally. The exception is pmc_rdpmcrng, which reads a Programmable Machine Controller (PMC) address range that you specify.

An endpoint combines one method with one mode of operation:

  • Subscribe: Connectware calls the method in a fixed interval, or on a cron schedule, and publishes the result. This is the right mode for continuous monitoring and is the main pattern in this guide.

  • Read: Connectware exposes a request/response pattern over MQTT. A message on the endpoint's request topic triggers one method call, and the result is published on the response topic. This is the right mode for data that you only need on demand.

Some methods require additional properties on the endpoint, for example the spindle number for cnc_rdspload or the data type selection for cnc_rdspeed. For all endpoint properties, see Focas Endpoint Properties.

Choosing the FOCAS Methods

This guide polls a set of methods that cover the most common machine monitoring needs. The polling interval is a trade-off between data freshness and load on the control: fast-changing process values get short intervals, while static information gets long ones. The minimum polling interval is 500 ms.

Method
Data
Poll interval

cnc_sysinfo

Static system information such as the CNC type, series, version, and axis count

60000 ms

cnc_statinfo2

Status information such as mode, run state, motion, alarm, and emergency stop

3000 ms

cnc_exeprgname

Full path name of the program which is currently being executed

5000 ms

cnc_rdspeed

Actual feed rate and actual rotational speed of the main spindle

2000 ms

cnc_rdspload

Load information of the serial spindle

2000 ms

The connector provides further methods, for example cnc_rdprgnum for the selected program number, cnc_rdgcode for the commanded G code, cnc_rdopnlsgnl for the signals of the software operator's panel, and pmc_rdpmcrng for PMC data. For the full list with example outputs, see FOCAS Methods.

Writing the Service Commissioning File

The service commissioning file contains all connection and mapping details. Do not worry about copying the snippets together into one file, the complete example file is available at the end of this guide.

Description and Metadata

These sections contain general information about the service commissioning file. Only the metadata name is required.

Parameters and Definitions

We define the network address of the machine as parameters, so you can set them when you install the service. The default FOCAS port is 8193.

The MQTT topics in this guide follow an ISA-95 style equipment hierarchy (<enterprise>/<site>/<area>/<line>/<work-cell>). We define the prefix once in the definitions section and reuse it in every mapping with !sub.

Cybus::Connection

The connection resource establishes the connection to the FOCAS Ethernet interface of the CNC. FOCAS does not use a username or password; the host and port are sufficient. If a connection attempt fails, the connector retries with an increasing delay that you can tune with the connectionStrategy property. For all connection properties, see Focas Connection Properties.

Cybus::Endpoint

Each endpoint polls one driver method. The method property selects the driver method, and interval sets the polling frequency in milliseconds according to the table in Choosing the FOCAS Methods. Two of the endpoints carry method-specific properties: dataType: -1 makes cnc_rdspeed return the feed rate and the spindle speed in one call, and spindleNumber selects the spindle that cnc_rdspload reads.

Cybus::Mapping

The mapping publishes each endpoint on a topic of the ISA-95 hierarchy.

With this mapping, the machine status is published on the topic enterprise/hamburg/machining/line-1/cnc-02/machine/status, and every other method result follows the same pattern.

Reading Data on Demand

Data that you only need occasionally does not have to be polled. An endpoint with the read operation subscribes to a request topic ending in req and publishes the result on the corresponding response topic ending in res:

Publish a message on the request topic to trigger one method call. You can include a correlation id in the request payload to match responses to specific requests; the response carries the same id.

Installing the Service Commissioning File

  1. Install the service commissioning file. See Installing Services.

  2. Enable the service. See Enabling Services.

Result: The service is enabled. Connectware connects to the FOCAS interface of the CNC and starts polling the configured methods.

Verifying the Data

Open the Data Explorer and subscribe to enterprise/hamburg/machining/line-1/cnc-02/#. Each topic carries a JSON object with a timestamp and a value key, where the value holds the result object of the driver method. For example, the feed rate and spindle speed:

A few plausibility checks for the first readings:

  • The name on the program/name topic matches the program shown on the CNC display.

  • On the machine/status topic, the run value changes when you start or stop a program, and alarm and emergency are 0 during normal operation.

  • On the process/speed topic, the acts.data value (spindle speed S) is 0 while the spindle is stopped, and the actf.data value (feed rate F) follows the commanded feed while machining.

If the connection does not reach the Connected state, verify that the FOCAS Ethernet function is installed and configured on the CNC, that the host address is correct, and that the port (8193 by default) is reachable from Connectware. The connector retries failed connection attempts automatically according to its connectionStrategy settings.

Service Commissioning File Example

Disclaimer: FANUC and FOCAS are trademarks or registered trademarks of FANUC Corporation.

Last updated

Was this helpful?