# MTConnect to OPC UA

> PLCGateway reads MTConnect agents and serves their data items from its own OPC UA server, so MES and SCADA systems that speak OPC UA can use machine tools that only offer MTConnect.

Machine tools often come with MTConnect, while the plant's MES, SCADA or historian expects OPC UA. PLCGateway reads the agent over HTTP, keeps the selected data items as tags and offers each tag as an OPC UA variable with data-change subscriptions.

Several machines of one agent, and several agents, are gathered under one OPC UA endpoint. PLCs read with other drivers appear next to them, which gives the IT side a single connection for the whole shop.

- **Source:** [MTConnect](https://plcgateway.com/protocols/mtconnect.md) (`mtconnect`)
- **Connection:** HTTP · MTConnect agent (e.g. port 5000)
- **Target:** [OPC UA](https://plcgateway.com/connect.md)
- **Writing:** read only
- **Included in:** PLCGateway Connect, PLCGateway SCADA, PLCGateway Embedded

## Set it up in five steps

1. Make sure the machine's MTConnect agent is reachable (for example http://machine:5000).
2. Add an MTConnect device with the agent URL and, if needed, the device name.
3. Browse the data items and add the ones you need as tags.
4. Open Gateway → OPC UA and choose the security modes and whether clients sign in anonymously or with user name and password.
5. Connect your OPC UA client (UaExpert, an MES, a SCADA) to opc.tcp://<gateway>:4840 and browse Objects → PLCGateway.

## Example: node ids in the OPC UA server

A device with the id mazak1 and these tags appears in the address space as shown below. Names and values are examples.

| Tag | Address | Example value |
|---|---|---|
| `Availability` | `avail` | AVAILABLE |
| `Execution` | `execution` | ACTIVE |
| `PartCount` | `PartCountAct` | 128 |
| `XPosition` | `Xact` | 124.375 mm |

**OPC UA node ids**

```
opc.tcp://<gateway>:4840
Objects / PLCGateway / mazak1
ns=1;s=mazak1.Availability  = "AVAILABLE"
ns=1;s=mazak1.Execution     = "ACTIVE"
ns=1;s=mazak1.PartCount     = 128
ns=1;s=mazak1.XPosition     = 124.375
```

Every tag is a variable under Objects / PLCGateway / device in namespace 1; clients read it, write it and subscribe to its changes.

## The OPC UA server in PLCGateway

Every tag becomes a variable in PLCGateway's built-in OPC UA server, so MES, ERP, SCADA and historians use one standard endpoint instead of each controller's own protocol. Clients browse the devices and tags, read, write and subscribe to value changes.

The server offers the security modes None, Sign and SignAndEncrypt with automatically generated certificates; clients sign in anonymously or with user name and password.

- One endpoint (opc.tcp, port 4840) for all devices and protocols
- A folder per device and a variable per tag, with description and unit
- Subscriptions with data-change notifications; writing only where the tag allows it
- Client certificates are approved in the web interface

![OPC UA server settings: endpoint, security policies and users](https://plcgateway.com/assets/img/shots/opcua-1600.webp)

## Controllers and devices

- [MTConnect](https://plcgateway.com/protocols/mtconnect.md)
- [CNC machines with MTConnect](https://plcgateway.com/controllers/mtconnect-machines.md)
- [Haas Automation](https://plcgateway.com/controllers/haas.md)

## Questions and answers

### Is this the OPC UA companion specification for MTConnect?

No. PLCGateway offers the data items you select as plain OPC UA variables in a folder per machine, which every OPC UA client can read without a special information model.

### How are conditions represented?

A condition becomes a text variable with the value Normal, Warning: … or Fault: …, so it can be shown, logged and used for alarms.

### How fresh are the values?

The agent's current document is read at the scan interval of the device, and OPC UA clients receive a notification when a value changes.

## Related solutions

- [MTConnect to MQTT](https://plcgateway.com/solutions/mtconnect-to-mqtt.md)
- [CNC OEE with MTConnect](https://plcgateway.com/solutions/mtconnect-oee.md)
- [FANUC FOCAS to OPC UA](https://plcgateway.com/solutions/fanuc-focas-to-opc-ua.md)
- [Haas CNC to OPC UA](https://plcgateway.com/solutions/haas-to-opc-ua.md)
- [Siemens S7 to OPC UA](https://plcgateway.com/solutions/siemens-s7-to-opc-ua.md)
- [Modbus to OPC UA](https://plcgateway.com/solutions/modbus-to-opc-ua.md)
- [All protocols](https://plcgateway.com/protocols.md)

_Product and model names are trademarks of their owners. They are named only to show which equipment the drivers communicate with; PLCGateway is not affiliated with these companies._

---
Source: https://plcgateway.com/solutions/mtconnect-to-opc-ua
