Skip to content

Commit 515d8f0

Browse files
committed
Initial commit - OPC UA FW Content
1 parent a435669 commit 515d8f0

File tree

3 files changed

+123
-0
lines changed

3 files changed

+123
-0
lines changed

content/hardware/07.opta/opta-family/opta/tutorials/01.user-manual/content.md

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,129 @@ You should be able now to connect to your Opta™ using a central device. The Bl
12111211

12121212
![Bluetooth® Low Energy service and characteristic information from an Opta™ device](assets/user-manual-14.png)
12131213

1214+
## OPC Unified Architecture (OPC UA)
1215+
1216+
This section explains using the [**OPC UA library**](https://github.com/arduino-libraries/Arduino_OPC_UA) designed for Opta. The library is based on the [**Fraunhofer open62541**](https://github.com/open62541/open62541) implementation of [**OPC UA**](https://en.wikipedia.org/wiki/OPC_Unified_Architecture), tailored specifically for the Opta family.
1217+
1218+
The [**OPC Unified Architecture (OPC UA)**](https://en.wikipedia.org/wiki/OPC_Unified_Architecture) is an industrial communication protocol widely used in automation and Industrial Internet of Things (IIoT) systems. It provides a platform-independent and secure method for exchanging information between devices and systems. **OPC UA** supports features like custom data modeling, authentication, encryption, and scalable architecture, making it a preferred choice for modern industrial applications.
1219+
1220+
The [**open62541** library](https://github.com/open62541/open62541) is an open-source implementation of the **OPC UA** standard. It is lightweight, efficient, and written in C, making it ideal for embedded systems like the Opta. The library provides a flexible framework to create **OPC UA** servers and clients, ensuring compatibility with the standard while maintaining high performance.
1221+
1222+
The [**OPC UA library**](https://github.com/arduino-libraries/Arduino_OPC_UA) supports secure communication and interoperability for industrial automation applications, with the capability to automatically detect, configure, and expose up to two Arduino Opta Expansion Boards via **OPC UA**. Supported expansion boards include:
1223+
1224+
- Digital Expansion with mechanical relays (D1608E)
1225+
- Digital Expansion with solid-state relays (D1608S)
1226+
- Analog Expansion (A0602)
1227+
1228+
### Setting up the OPC UA Server
1229+
1230+
To set up the **OPC UA** server, upload the [**`opta_opcua_server`** example](https://github.com/arduino-libraries/Arduino_OPC_UA/blob/main/examples/opta_opcua_server/opta_opcua_server.ino) to your Opta. This can be done using the Arduino IDE or the Arduino CLI tool with the command:
1231+
1232+
![Successful Compilation with Arduino IDE](assets/arduino-ide-compilation.png)
1233+
1234+
```bash
1235+
arduino-cli compile --fqbn arduino:mbed_opta:opta -v examples/opta_opcua_server -u -p /dev/ttyACM0
1236+
```
1237+
1238+
![Successful Compilation with Arduino CLI](assets/arduino-cli-compilation-upload.png)
1239+
1240+
***If you are not familiar with the __Arduino CLI tool__, you can refer to the getting started found [here](https://arduino.github.io/arduino-cli/1.1/getting-started/).***
1241+
1242+
Next, connect the Opta to a network using its Ethernet port, ensuring that the network has a DHCP-enabled router or switch to assign an IP address to the device.
1243+
1244+
Open a serial monitor to verify the status of the server and retrieve the device’s IP address. The output will include information about the server, including its discovery URL. Use the following command to view the serial output:
1245+
1246+
```bash
1247+
cat /dev/ttyACM0
1248+
```
1249+
1250+
You should see output similar to the following:
1251+
1252+
```bash
1253+
[2024-06-21 02:30:19.000 (UTC+0000)] info/eventloop Starting the EventLoop
1254+
[2024-06-21 02:30:19.000 (UTC+0000)] warn/server AccessControl: Unconfigured AccessControl. Users have all permissions.
1255+
[2024-06-21 02:30:19.000 (UTC+0000)] info/server AccessControl: Anonymous login is enabled
1256+
[2024-06-21 02:30:19.000 (UTC+0000)] warn/server x509 Certificate Authentication configured, but no encrypting SecurityPolicy. This can leak credentials on the network.
1257+
[2024-06-21 02:30:19.000 (UTC+0000)] info/server Arduino Opta IP: 192.168.8.137
1258+
[2024-06-21 02:30:19.000 (UTC+0000)] info/server Arduino Opta Variant: Arduino Opta WiFi
1259+
[2024-06-21 02:30:19.000 (UTC+0000)] info/server stack: size = 16384 | free = 14936 | used = 1448 | max = 5124
1260+
[2024-06-21 02:30:19.000 (UTC+0000)] info/server o1heap: capacity: 261984 | allocated: 66784 | peak_allocated: 68896
1261+
[2024-06-21 02:30:19.000 (UTC+0000)] warn/server Maximum SecureChannels count not enough for the maximum Sessions count
1262+
[2024-06-21 02:30:19.000 (UTC+0000)] info/network TCP | Listening on all interfaces
1263+
[2024-06-21 02:30:19.000 (UTC+0000)] info/network TCP 604353888 | Creating listen socket for "127.0.0.1" (with local hostname "192.168.8.137") on port 4840
1264+
[2024-06-21 02:30:19.000 (UTC+0000)] info/server New DiscoveryUrl added: opc.tcp://192.168.8.137:4840
1265+
```
1266+
1267+
In this example, the output displays the IP address:
1268+
1269+
```bash
1270+
192.168.8.137
1271+
```
1272+
1273+
And indicate that the OPC UA server is running at:
1274+
1275+
```bash
1276+
opc.tcp://192.168.8.137:4840
1277+
```
1278+
1279+
### Connecting to the OPC UA Server
1280+
1281+
Once the server is running, use any OPC UA-compatible client to connect to the server using the IP address and port printed in the serial monitor output. This allows you to explore and interact with the device and any attached expansion boards.
1282+
1283+
### Using OPC UA GUI Client for Testing
1284+
1285+
The **opcua-client-gui** tool can be used if you are interested in testing or further interaction. To install the tool, please use the following commands:
1286+
1287+
```bash
1288+
cd /tmp
1289+
```
1290+
1291+
```bash
1292+
git clone https://github.com/FreeOpcUa/opcua-client-gui && cd opcua-client-gui
1293+
```
1294+
1295+
```bash
1296+
python -m venv .venv
1297+
```
1298+
```bash
1299+
source .venv/bin/activate
1300+
```
1301+
1302+
```bash
1303+
python3 -m pip install --upgrade pyopenssl
1304+
```
1305+
1306+
```bash
1307+
python3 -m pip install --upgrade .
1308+
```
1309+
1310+
Launch the GUI and use it to connect to the OPC UA server running on the Arduino Opta.
1311+
1312+
### Detailed Memory Debugging
1313+
1314+
Additional configuration is possible for developers requiring detailed debugging information about heap and stack memory usage. To enable this feature, the `mbed_app.json` configuration file should be modified to include memory and stack statistics macros.
1315+
1316+
Add the following macros to enable memory and stack statistics:
1317+
1318+
```bash
1319+
"target.macros_add": [
1320+
...
1321+
+ "MBED_HEAP_STATS_ENABLED=1",
1322+
+ "MBED_STACK_STATS_ENABLED=1",
1323+
+ "MBED_MEM_TRACING_ENABLED=1"
1324+
]
1325+
```
1326+
1327+
After making these changes, recompile the core library using the following commands:
1328+
1329+
```bash
1330+
cd ArduinoCore-mbed
1331+
```
1332+
1333+
```bash
1334+
./mbed-os-to-arduino -a -g OPTA:OPTA
1335+
```
1336+
12141337
## Interrupts
12151338

12161339
**Opta's analog/digital programmable inputs and user-programmable button are interrupt-capable**. An interrupt is a signal that prompts Opta's microcontroller to stop its execution and start executing a special routine known as the Interrupt Service Routine (ISR). Once the ISR finishes, the microcontroller resumes executing its previous routine.

0 commit comments

Comments
 (0)