Skip to content

Commit fd72443

Browse files
authored
Merge e2c0565 into e6a6f2e
2 parents e6a6f2e + e2c0565 commit fd72443

21 files changed

+946
-0
lines changed

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

+181
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,187 @@ 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 the use of the [**OPC UA library**](https://github.com/arduino-libraries/Arduino_OPC_UA) designed for Opta.
1217+
1218+
1219+
![OPC UA GUI client with Opta](assets/opta-opc-ua-gui.gif)
1220+
1221+
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), created specifically for the Opta family.
1222+
1223+
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.
1224+
1225+
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.
1226+
1227+
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.
1228+
1229+
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:
1230+
1231+
- Digital Expansion with mechanical relays (D1608E)
1232+
- Digital Expansion with solid-state relays (D1608S)
1233+
- Analog Expansion (A0602)
1234+
1235+
***The OPC UA library supports a maximum of __two__ Opta expansions connected simultaneously.***
1236+
1237+
### Setting up the OPC UA Server
1238+
1239+
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 either the Arduino IDE or the Arduino CLI.
1240+
1241+
![Successful Compilation with Arduino IDE](assets/arduino-ide-compilation.png)
1242+
1243+
Run the following command to compile and upload the example if used with the Arduino CLI:
1244+
1245+
```bash
1246+
arduino-cli compile --fqbn arduino:mbed_opta:opta -v examples/opta_opcua_server -u -p /dev/ttyACM0
1247+
```
1248+
1249+
![Successful Compilation with Arduino CLI](assets/arduino-cli-compilation-upload.png)
1250+
1251+
***If you are not familiar with the __Arduino CLI tool__, you can refer to the getting started documentation found [here](https://arduino.github.io/arduino-cli/1.1/getting-started/).***
1252+
1253+
Next, connect the Opta to a network via its Ethernet port. Please make sure the network has a DHCP-enabled router or switch to assign an IP address to the device.
1254+
1255+
Use a serial monitor to check the server status and retrieve the device's IP address. You can use the Arduino IDE Serial Monitor or other programs like [**Putty**](https://www.putty.org/) to establish a serial connection.
1256+
1257+
The output will display details such as the **discovery URL**. Below is an example of the server log output on the Arduino IDE Serial Monitor:
1258+
1259+
![Server information with discovery URL - Arduino IDE](assets/opta-opc-ua-arduino-ide.gif)
1260+
1261+
With [**Putty**](https://www.putty.org/), the following serial connection shows the server information:
1262+
1263+
![Server information with discovery URL - Putty](assets/opta-opc-ua-cmd.gif)
1264+
1265+
The output information is as follows and you should see similar information:
1266+
1267+
```bash
1268+
[2024-12-11 22:19:08.000 (UTC+0000)] info/eventloop Starting the EventLoop
1269+
[2024-12-11 22:19:08.000 (UTC+0000)] warn/server AccessControl: Unconfigured AccessControl. Users have all permissions.
1270+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server AccessControl: Anonymous login is enabled
1271+
[2024-12-11 22:19:08.000 (UTC+0000)] warn/server x509 Certificate Authentication configured, but no encrypting SecurityPolicy. This can leak credentials on the network.
1272+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Arduino Opta IP: 192.168.100.191
1273+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Arduino Opta Variant: Arduino Opta WiFi
1274+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server OptaController 0 expansion modules detected.
1275+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server stack: size = 16384 | free = 15400 | used = 984 | max = 4248
1276+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server o1heap: capacity: 327520 | allocated: 66784 | peak_allocated: 68896
1277+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405ADA4 ("application_unnamed_thread"), Stack size: 4248 / 16384
1278+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405C960 ("rtx_idle"), Stack size: 328 / 896
1279+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405D338 ("lwip_tcpip"), Stack size: 792 / 1200
1280+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405DB60 ("shared_event_queue"), Stack size: 392 / 2048
1281+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405D090 ("main"), Stack size: 2224 / 32768
1282+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405C91C ("rtx_timer"), Stack size: 104 / 768
1283+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2406AE40 ("USBevt"), Stack size: 136 / 256
1284+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Thread: 0x2405D250 ("stm32_emac_thread"), Stack size: 192 / 1024
1285+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server Heap size: 10393 / 90272 bytes
1286+
[2024-12-11 22:19:08.000 (UTC+0000)] warn/server Maximum SecureChannels count not enough for the maximum Sessions count
1287+
[2024-12-11 22:19:08.000 (UTC+0000)] info/network TCP | Listening on all interfaces
1288+
[2024-12-11 22:19:08.000 (UTC+0000)] info/network TCP 604424824 | Creating listen socket for "192.168.100.191" (with local hostname "192.168.100.191") on port 4840
1289+
[2024-12-11 22:19:08.000 (UTC+0000)] info/server New DiscoveryUrl added: opc.tcp://192.168.100.191:4840
1290+
[2024-12-11 22:19:14.000 (UTC+0000)] info/server Arduino Opta IP: 192.168.100.191
1291+
```
1292+
1293+
In this example, the output displays the **IP address**:
1294+
1295+
```bash
1296+
192.168.100.191
1297+
```
1298+
1299+
The **discovery URL** is as follows, which indicates the OPC UA server is running at:
1300+
1301+
```bash
1302+
opc.tcp://192.168.100.191:4840
1303+
```
1304+
1305+
You can now connect to the OPC UA server running on Opta.
1306+
1307+
### Connecting to the OPC UA Server
1308+
1309+
Once the server is running, you can use any OPC UA compatible client to connect to the server using the discovery URL. This allows interaction with the device and any connected expansion modules.
1310+
1311+
The [**opcua-client-gui**](https://github.com/FreeOpcUa/opcua-client-gui) client will be used to connect to the OPC UA server running on Opta in this section.
1312+
1313+
### Using OPC UA GUI Client for Testing
1314+
1315+
The [**opcua-client-gui**](https://github.com/FreeOpcUa/opcua-client-gui) client can be used if you are interested in testing or further interaction with the OPC UA server. To install the tool, please use the following commands:
1316+
1317+
```bash
1318+
cd /tmp
1319+
```
1320+
1321+
```bash
1322+
git clone https://github.com/FreeOpcUa/opcua-client-gui && cd opcua-client-gui
1323+
```
1324+
1325+
```bash
1326+
python -m venv .venv
1327+
```
1328+
```bash
1329+
source .venv/bin/activate
1330+
```
1331+
1332+
```bash
1333+
python3 -m pip install --upgrade pyopenssl
1334+
```
1335+
1336+
```bash
1337+
python3 -m pip install --upgrade .
1338+
```
1339+
1340+
If you are on a Windows OS platform, please follow the next steps:
1341+
1342+
1. Install [**WinPython**](https://winpython.github.io/) and install the version including **`pyqt5`**.
1343+
1344+
2. Use `pip` to install **opcua-client**:
1345+
1346+
```bash
1347+
pip install opcua-client
1348+
```
1349+
1350+
It is recommended that the command be run within the *`WinPython Command Prompt`* downloaded with [winpython](https://winpython.github.io/).
1351+
1352+
3. Run via the script `pip` created: `YOUR_INSTALL_PATH\Python\Python35\Scripts\opcua-client.exe`
1353+
1354+
It will launch the GUI and connect to the OPC UA server running on the Opta using the discovery URL. You will be able to see similar results as in the following clip:
1355+
1356+
![OPC UA GUI client](assets/opta-opc-ua-gui.gif)
1357+
1358+
With this, Opta is ready to handle the OPC UA protocol through simple [OPC UA GUI client](https://github.com/FreeOpcUa/opcua-client-gui). The interface allows browsing, subscribing to variables, writing values, and performing other interactions.
1359+
1360+
***For more information about the simple OPC UA GUI client and dedicatd installation instruction sets, please refer to [__opcua-client-gui__ repository](https://github.com/FreeOpcUa/opcua-client-gui).***
1361+
1362+
### Memory Debugging Insight
1363+
1364+
Additional configuration is possible for developers requiring detailed heap and stack memory usage information. The `mbed_app.json` configuration file should be modified to include memory and stack statistics macros to enable this feature.
1365+
1366+
The `mbed_app.json` file is found within [**`ArduinoCore-mbed`**](https://github.com/arduino/ArduinoCore-mbed/tree/main) at:
1367+
1368+
```bash
1369+
variants/OPTA/conf/mbed_app.json
1370+
```
1371+
1372+
Or the location can be referenced [here](https://github.com/arduino/ArduinoCore-mbed/blob/main/variants/OPTA/conf/mbed_app.json).
1373+
1374+
Add the following macros to enable memory and stack statistics:
1375+
1376+
```bash
1377+
"target.macros_add": [
1378+
  ...
1379+
+  "MBED_HEAP_STATS_ENABLED=1",
1380+
+  "MBED_STACK_STATS_ENABLED=1",
1381+
+  "MBED_MEM_TRACING_ENABLED=1"
1382+
]
1383+
```
1384+
1385+
After making these changes, recompile the core library using the following commands:
1386+
1387+
```bash
1388+
cd ArduinoCore-mbed
1389+
```
1390+
1391+
```bash
1392+
./mbed-os-to-arduino -a -g OPTA:OPTA
1393+
```
1394+
12141395
## Interrupts
12151396

12161397
**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)