【教學】透過FsBP OPC UA Server讀寫 Marco變數

回覆文章
EJ
新兵
新兵
文章: 9
註冊時間: 2024-10-01, 23:54

【教學】透過FsBP OPC UA Server讀寫 Marco變數

文章 EJ »

一、基本說明

本章節將說明如何使用 UA Expert 工具,讀取與寫入伺服器端的 Macro 變數,以達成訊號交握的基本應用。透過此教學,使用者將能了解 OPC UA 通訊環境下,如何以 UA Expert 作為用戶端介面,進行變數監控與控制操作,並驗證資料互通的正確性與即時性。

二、事前準備

1. 安裝UA Expert。

[1] 下載網址:https://www.unified-automation.com/prod ... xpert.html

[2] 安裝並啟動應用程式。

2. 於FsBP OPC UA Server APP 設定以下內容。

[1] 打開FsBP OPC UA Server APP。

[2] 切換至Basic settings頁面。

[3] 點選【Edit】。

[4] 設定以下內容。

*注意:此功能務必設定並使用此頁面的帳號密碼才能使用。

20250421011.png
20250421011.png (18.9 KiB) 已瀏覽 1494 次

[5] 點選【Save】。

[6] 點選【確定】,重啟FsBP OPC UA Server APP。

20250421012.png
20250421012.png (7.88 KiB) 已瀏覽 1494 次

三、建立連線

1. 開啟 UA Expert。

2. 新增連線 Add Server。

[1] 路徑:Project > Servers >右鍵>Add。

[2] 輸入 Endpoint URL(手動新增)。
  • 找到 Custom Discovery。
  • 雙擊「Double click to Add Server」。
  • Enter URL輸入:opc.tcp://<FIELD system BOX IP>:4840/OPCUAServer。
  • 按下【OK】。
20250417007.png
20250417007.png (2.47 KiB) 已瀏覽 1494 次

3. 驗證設定 Authentication Settings。

[1] 展開opc.tcp://<FIELD system BOX IP>:4840/OPCUAServer。

[2] 點選「Aes256_Sha256_RsaPss – Sign & Encrypt」。

[3] 輸入 Username。

[4] 勾選 Store。

[5] 輸入Password。

[6] 點選【OK】。


若出現「Connect Error」視窗,請點選Ignore。

20250417008.png
20250417008.png (11.24 KiB) 已瀏覽 1494 次

4. 信任伺服器憑證(若使用加密模式)

[1] 若 Server 使用安全憑證,會出現「Certificate Validation」視窗。

20250417009.png
20250417009.png (99.91 KiB) 已瀏覽 1494 次

[2] 點選【Trust Server Certificate】。

20250417010.png
20250417010.png (33.16 KiB) 已瀏覽 1494 次

[3] 點選【Continue】。


5. 連線伺服器

[1] 路徑:Project>Servers。

[2] 找到:OPC UA Server@<FIELD system BOX IP>

[3] 右鍵點選【Connect】。

若出現「Connect Error」視窗,請點選【Ignore】。

20250417011.png
20250417011.png (11.24 KiB) 已瀏覽 1494 次

四、讀取Marco變數

1.打開API視窗

[1] 至Address Space區塊。

[2] 展開節點:CommonDatabase>欲操作機台>Methods。

[3] 右鍵點選「get_marco_variable」節點。

[4] 點選【Call】。

[5] 輸入相關內容。

20250421013.png
20250421013.png (35.52 KiB) 已瀏覽 1494 次

[6] 點選Call。

2. 顯示結果

Output Arguments和Result的部分會顯示API呼叫結果。

五、寫入Marco變數

1.打開API視窗

[1] 至Address Space區塊。

[2] 展開節點:CommonDatabase>欲操作機台>Methods。

[3] 右鍵點選「set_marco_variable」節點。

[4] 點選Call。

[5] 輸入相關內容。

20250421014.png
20250421014.png (65.39 KiB) 已瀏覽 1494 次

2. 顯示結果

Output Arguments和Result的部分會顯示API呼叫結果。
回覆文章