---
tags: notes, NADI, interenet
---
# OPC UA/DA Overview
理解OPC UA/DA過程中的簡易筆記。
## OPC
Without OPC:
```graphviz
digraph{
SCADA1[shape=box]
SCADA2[shape=box]
SCADA3[shape=box]
SCADA1->PLC1[headlabel="can bus",labelangle=80,labeldistance=3]
SCADA1->PLC2[headlabel="Modbus",labelangle=-80,labeldistance=3]
SCADA2->PLC3[headlabel="RS-485",labelangle=80,labeldistance=3]
SCADA2->PLC4[headlabel="I2C",labelangle=-70,labeldistance=2.3]
SCADA3->PLC5[headlabel="Profibus",labelangle=80,labeldistance=3]
SCADA3->PLC6[headlabel="Ethernet",labelangle=-80,labeldistance=3]
}
```
With OPC:
```graphviz
digraph{
HMI[shape=box, label="HMI\nClient"]
SCADA1[shape=box, label="SCADA1\nClient"]
SCADA2[shape=box, label="SCADA2\nClient"]
SCADA3[shape=box, label="SCADA3\nClient"]
s[label="OPC Server", shape=note]
s->PLC1
s->PLC2
s->PLC3
s->PLC4
s->PLC5
s->PLC6[label="OPC, Modbus, Profibus... etc"]
HMI->s
SCADA1->s
SCADA2->s
SCADA3->s[label=" OPC"]
}
```
使用OPC,軟體(SCADA、人機介面)開發商就不需特地為了各種不同的PLC通訊界面製作各種驅動軟體,擷取任何的資料,只需要建立OPC Client,並向OPC Server發送資料請求並擷取資料即可。而現今大多數中高端的PLC已經內建OPC Server。
### Client and Server Fundamental Interactions:
- A Client initiates communications(sending request) with a Server.
- A Server's behaviour depends on Clients.
- A server waits for incoming requests from Clients.
- Interacting like a simple web service.
### OPC Server config:
- *Channel*: protocol being used
- *Device*: device type like part number of PLC and its hierarchy path.
- *Tag*: data of interest.
- Tag name: fan speed RPM, boiler temperature, tank level, ...etc
- PLC memory address (*not sure is this is correct*)
- tag properties: mostly data type(boolean, integer, float...)
## OPC DA(1995~2009)
- Only works on same Windows Domain or Workgroup.
- Only works with Windows OS via COM/DCOM.
- Opening DCOM also open a big hole on firewall, impossible route over Internet.
- Security was not a concern dates back to when this protocol designed.
## OPC UA(2009~now)
- based solely on IP-based standards. (ex: opc.tcp://ServerIP)
- Crossing platforms.
- Established crossing LAN, WAN and Internet.
- Passing data through router and firewall.
- Security
- Key exchange from Client to Server and from Server to Client.
- Surpporting HTTPS/SSL/TCP.
- RSA data encryption.
- Not sure if it's fully open or not.
---
#### Reference:
[OPC Server & Client Data Communications – Introduction and Overview (Kepware, KEPServerEX)](https://www.youtube.com/watch?v=u6E9uAtyhow)
[【物聯網線 08】簡化工業裝置的聯網利器:Azure IoT + OPC UA](https://www.youtube.com/watch?v=aJNTX8HdK64)
[OPC Proxy by Microsoft](https://github.com/Azure/iot-edge-opc-proxy/tree/master)
[OPC Publisher by Microsoft](https://github.com/Azure/iot-edge-opc-publisher/tree/master)
[OPC Foundation Official Website](https://opcfoundation.org/)
[Open OPC UA](http://www.openopcua.org/download/download.html)
[FreeOpcUa](https://github.com/FreeOpcUa/freeopcua)