FoundryNet / Answers / How do you read data from a Fanuc controller with FOCAS?
Answers

How do you read data from a Fanuc controller with FOCAS?


FOCAS (Fanuc Open CNC API Specification) is the library Fanuc provides for reading and writing controller data over Ethernet. It is a C library with a long list of functions — cnc_rdspeed for spindle and feed, cnc_rdprgnum for the active program, cnc_rdalmmsg for alarms, cnc_rdparam for parameters — and it is the most direct path to a Fanuc control.

There are three practical routes. FOCAS directly gives you everything and requires the library, a licence for it, and a host that can load it. An MTConnect adapter in front of FOCAS is the common production pattern: the adapter handles the library, and you consume ordinary HTTP and XML. OPC UA is available on newer controls and avoids FOCAS entirely, at the cost of a different model to map.

The trap is not the API — it is what comes out of it. In the corpus, Fanuc spindle speed appears under 29 distinct spellings: ACT SP SPEED(RPM), ACTSPSPEED [1/min], SPRPM (1/min), Sp Rpm_min-1 and more, because the adapter author chose the label, not Fanuc. Feed rate is worse — 53 spellings, and several encode the unit in the name, so mm/min and in/min arrive under names that differ by three characters and by a factor of 25.4.

So whichever route you take, plan for the mapping layer as a first-class part of the project rather than a config file. Forge's Fanuc pack alone holds 759 deterministic mappings for exactly this reason.


Worked example

Real tags from the corpus

# Fanuc, four adapters, four spellings, one field
{"ACT SP SPEED(RPM)": 8200}
{"ACTSPSPEED [1/min]": 8200}
{"SPRPM (1/min)": 8200}
{"Sp Rpm_min-1": 8200}
{"spindle_speed_rpm": 8200}

Try it

No account, no key, no data leaving your machine

docker run -p 8000:8000 ghcr.io/foundrynet/forge-sandbox
Get an API key Canonical field reference

Related questions

Is FOCAS free?

The library is licensed by Fanuc rather than freely redistributable, which is a large part of why the MTConnect-adapter route is so common in production.

Can I read a Fanuc without FOCAS?

Yes — via an MTConnect adapter that speaks FOCAS on the machine side, or via the OPC UA server on newer controls.

Why do Fanuc tag names vary so much?

Because the adapter author picks the label, not the controller. Fanuc exposes a function call; whoever wrote the adapter decided what to call the result, and every integrator decided differently.


Keep reading

Fanuc Monitor a CNC remotely spindle_speed_rpm feed_rate
More answers like this one, and the thesis behind them — The Machine Agent, weekly. Read it →
Get the thesis behind this infrastructure — The Machine Agent, weekly.