Focas

This module implements FANUC’s Focas protocol connectivity allowing the user to collect different data from a FANUC CNC machine.

This protocol implementation allows the communication to such devices and provides the user the ability to create endpoints for reading and subscribing for changes on the data provided by them.

Below you can see configuration parameters and examples on how to build a commissioning file for this protocol.

Connection Properties

host (string, required)

The device host name. It can be an IP address or a hostname.

Example: "192.168.2.114"

port (integer)

The device TCP port.

Default: 8193

connectTimeout (integer)

The connection attempt timeout (in seconds)

Default: 10

connectionStrategy (object)

If a connection attempt fails, retries will be performed with increasing delay (waiting time) in between. The following parameters control how these delays behave.

Properties of the connectionStrategy object:

initialDelay (integer)

Delay (waiting time) of the first connection retry (in milliseconds). For subsequent retries, the delay will be increased according to the parameter incrementFactor which has a default value of 2.

Default: 1000

Additional restrictions:

  • Minimum: 1000

maxDelay (integer)

Maximum delay (waiting time) to wait until the next retry (in milliseconds). The delay (waiting time) for any subsequent connection retry will not be larger than this value. Must be strictly greater than initialDelay.

Default: 30000

incrementFactor (integer)

The factor used to increment initialDelay up to maxDelay. For example if initialDelay is set to 1000 and maxDelay to 5000 the values for the delay would be 1000, 2000, 4000, 5000.

Default: 2

Additional restrictions:

  • Minimum: 2

Endpoint Properties

method (string, enum, required)

The method to run on the device

This element must be one of the following enum values:

  • cnc_sysinfo

  • cnc_statinfo2

  • cnc_rdprgnum

  • cnc_exeprgname

  • cnc_rdopnlsgnl

  • pmc_rdpmcrng

  • cnc_rdspeed

  • cnc_rdspload

  • cnc_rdgcode

  • program_download

Example: "cnc_sysinfo"

interval (integer)

The interval between reads (only for the subscribe operation)

Default: 1000

Additional restrictions:

  • Minimum: 500

cronExpression (string)

The Cron expression used to poll the endpoint. (For examples, see: https://github.com/node-cron/node-cron)

Examples: "1,2,4,5 * * * *", "1-5 * * * *", "*/2 * * * *", "* * * January,September Sunday"

slctData (integer)

Specify the data select flag (only applies for the cnc_rdopnlsgnl method)

Default: 32767

Additional restrictions:

  • Maximum: 32767

addressType (integer)

Specify the identification code corresponding to the kind of the PMC address (only applies for the pmc_rdpmcrng method)

Default: 0

Additional restrictions:

  • Maximum: 13

dataType (integer, enum)

Specify the type of the PMC data or CNC feed rate/spindle speed (only applies for the methods pmc_rdpmcrng and cnc_rdspeed), which can be byte (0), word (1), long (2), float32 (4) or float64 (5). float32 and float64 apply for 30i-B Series/0i-F/PMi-A only. For method cnc_rdspeed valid values are 0 (feed rate), 1 (spindle speed), -1 (all)

This element must be one of the following enum values:

  • -1

  • 0

  • 1

  • 2

  • 4

  • 5

Default: 0

spindleNumber (integer)

Specify spindle number to read. from 1 up to 8 for Series 30i, 0i-D/F. 1 up to 4 for Series 15/15i, 16i/18i/21i, 16i/18i/21i, 0i-A/B/C. And only number 1 for Power Mate i-D

Default: 1

Additional restrictions:

  • Minimum: 1

  • Maximum: 8

type (integer)

Specify the group of G code. Only applies for method cnc_rdgcode. Series 15i: goes from 0 to 18,24,25,27/-1/100 to 103/-2. For Series 30i, 0i-D/F, PMi-A: goes from 0 to 36/-1/100 to 103/-2

Default: -1

Additional restrictions:

  • Minimum: -2

  • Maximum: 103

block (integer)

Specify the block to be read. 0 -> previus block, 1 -> active block, 2 -> next block. Only applies for method cnc_rdgcode

Default: 1

Additional restrictions:

  • Maximum: 2

numGcd (integer)

number of G code data to be read. Only applies for method cnc_rdgcode

Default: 1

Additional restrictions:

  • Minimum: 1

addressStart (integer)

Specify the start PMC address number (only applies for the pmc_rdpmcrng method)

Default: 0

addressEnd (integer)

Specify the end PMC address number (only applies for the pmc_rdpmcrng method)

Default: 0

dataLength (integer)

Specify the data block length (only applies for the pmc_rdpmcrng method)

Default: 8

Additional restrictions:

  • Minimum: 8

Focas Methods

Available Focas methods. For full details of each method please consult the Focas documentation.

Subscribe methods

All endpoints utilizing these methods have to be defined as endpoints with the subscribe operation. The output will be provided as JSON object.

cnc_exeprgname

Reads the full path name of the program which is currently being executed in CNC.

Example output:

{
  "id": 1,
  "timestamp": 1637339279827,
  "value": {
    "name": "SAMPLE",
    "o_num": 0
  }
}

cnc_rdgcode

Reads the information of CNC about the commanded G code.

Required properties:

  • type

  • block

  • numGcd

Example output:

{
  "id": 1,
  "timestamp": 1637339824109,
  "value": {
    "code": "G01",
    "flag": 0,
    "group": 0
  }
}

cnc_rdopnlsgnl

Reads the output signal image of software operator’s panel.

Required properties:

  • slctData

Example output:

{
  "id": 1,
  "timestamp": 1637339309823,
  "value": {
    "blck_del": 0,
    "datano": 16723,
    "dry_run": 0,
    "feed_hold": 0,
    "feed_ovrd": 0,
    "hndl_ax": -1,
    "hndl_mv": 0,
    "jog_ovrd": 0,
    "machn_lock": 0,
    "mem_prtct": 0,
    "mode": 2,
    "rpd_ovrd": 0,
    "sngl_blck": 0,
    "spdl_ovrd": 0,
    "type": 32767
  }
}

cnc_rdprgnum

Reads the program number (modal O number) of the program which is currently selected in CNC.

Example output:

{
  "id": 1,
  "timestamp": 1637339187748,
  "value": {
    "data": 0,
    "mdata": 0
  }
}

cnc_rdspeed

Reads the actual feed rate and the actual rotational speed of the main spindle.

Required properties:

  • dataType

Example output:

{
  "id": 1,
  "timestamp": 1637339711053,
  "value": {
    "actf": {
      "data": 1600,
      "dec": 0,
      "disp": 0,
      "name": "F",
      "suff": "\u0000",
      "unit": 0
    },
    "acts": {
      "data": 751,
      "dec": 0,
      "disp": 1,
      "name": "S",
      "suff": " ",
      "unit": 2
    }
  }
}

cnc_rdspload

Reads the load information of the serial spindle.

Required properties:

  • spindleNumber

Example output:

{
  "id": 1,
  "timestamp": 1637339785074,
  "value": {
    "data": [
      820,
      19744,
      12615,
      23089,
      14129,
      12590,
      13104,
      0
    ],
    "datano": 1,
    "type": 32
  }
}

cnc_statinfo2

Reads the status information of CNC.

Example output:

{
  "id": 1,
  "timestamp": 1637339042705,
  "value": {
    "alarm": 0,
    "aut": 1,
    "edit": 0,
    "emergency": 0,
    "ext_opt": 0,
    "hdck": 0,
    "motion": 1,
    "mstb": 0,
    "o3dchk": 0,
    "restart": 0,
    "run": 3,
    "tmmode": 0,
    "warning": 0
  }
}

cnc_sysinfo

Reads system information such as kind of CNC system, Machining(M) or Turning(T), series and version of CNC system software and number of the controlled axes.

Example output:

{
  "id": 1,
  "timestamp": 1637339898044,
  "value": {
    "addinfo": 2,
    "axes": "03",
    "cnc_type": "31",
    "max_axis": 32,
    "mt_type": " M",
    "series": "G11Z",
    "version": "17.1"
  }
}

pmc_rdpmcrng

Reads the PMC data of the specified PMC address/range.

Required properties:

  • addressType

  • dataType

  • addressStart

  • addressEnd

  • dataLength

Example output:

{
  "id": 1,
  "timestamp": 1637341486343,
  "value": {
    "cdata": [
      100,
      51,
      34,
      44,
      34
    ],
    "datano_e": 30,
    "datano_s": 30,
    "type_a": 0,
    "type_d": 0
  }
}

Read methods

All endpoints utilizing these methods have to be defined as endpoints with the read operation since they require input provided on the request-topic (req). The output will be provided as JSON object.

For read endpoints, additionally a correlation ID (id) can be set in the payload of the request message, to ensure the correct identification of responses to specific requests.

program_download

Download the specified NC data to the controller. For this method, you will need to specify a valid G-code program (see e.g. https://en.wikipedia.org/wiki/G-code) in the message payload as string value of the value key and publish it on the endpoint’s request topic (req).

The program code string has to be formatted in a certain way to be processable by the method. To convert the program to this format the following steps have to be applied to the program code:

  1. Insert a leading line break \n; all data before that will be ignored

  2. Replace all line breaks with \n

  3. Remove all space characters

  4. Remove all semicolons

The example code:

O1234 ;
G1 F0.3 W10. ;
M30 ;
%

would be converted to the string:

\nO1234\nG1F0.3W10.\nM30\n%

The program will be downloaded to the directory which is set as “Background Folder” in the Fanuc controller.

Example output:

{
  "id": 1,
  "timestamp": 1637340781387
}

Sample Commissioning file

Download: focas-example.yml

 1description: >
 2  Sample Focas service commissioning file
 3
 4metadata:
 5  name: Sample Focas service
 6  icon: https://www.cybus.io/wp-content/uploads/2017/10/for-whom1.svg
 7  provider: cybus
 8  homepage: https://www.cybus.io
 9  version: 1.0.0
10
11parameters:
12  focasHost:
13    type: string
14    default: 192.168.2.170
15
16  focasPort:
17    type: integer
18    default: 8193
19
20  initialReconnectDelay:
21    type: integer
22    default: 1000
23
24  maxReconnectDelay:
25    type: integer
26    default: 30000
27
28  factorReconnectDelay:
29    type: integer
30    default: 2
31
32resources:
33  focasConnection:
34    type: Cybus::Connection
35    properties:
36      protocol: Focas
37      connection:
38        host: !ref focasHost
39        port: !ref focasPort
40        connectionStrategy:
41          initialDelay: !ref initialReconnectDelay
42          maxDelay: !ref maxReconnectDelay
43          incrementFactor: !ref factorReconnectDelay
44
45  subscribeExample1:
46    type: Cybus::Endpoint
47    properties:
48      protocol: Focas
49      connection: !ref focasConnection
50      subscribe:
51        method: 'cnc_statinfo2'
52        interval: 3000
53
54  readExample1:
55    type: Cybus::Endpoint
56    properties:
57      protocol: Focas
58      connection: !ref focasConnection
59      read:
60        method: 'cnc_sysinfo'