This procedure creates an Input with OPC to collect data that will then be used to write to Modbus. So, FairCom Edge will work as a converter between those protocols.
Requirements:
- Ensure the FairCom server is installed and running.
- Verify that the Modbus service is enabled in the FairCom Edge server.
- Edit the
services.jsonfile in theconfigfolder. - Locate the
"integrationServices"object of the service for the desired platform. - Set
"enabled"totrue.-
Windows
"integrationServices": [ { "serviceName": "modbus", "serviceLibrary": "modbusservice.dll", "schemaName": "modbus", "enabled": true }, -
Unix/Linux
"integrationServices": [ { "serviceName": "modbus", "serviceLibrary": "libmodbusservice.so", "schemaName": "modbus", "enabled": true }, -
MAC
"integrationServices": { "serviceName": "modbus", "serviceLibrary": "modbusservice.dylib", "schemaName": "modbus", "enabled": true }
-
Windows
- Save any changes. Restart FairCom Edge Server.
- Confirm server access by running the FairCom Control Center. The typical URL is https://localhost:8443/.
Launch the OPC UA server simulator
- Open a command prompt and find the server in <faircom>/server/opc/test/open62541_v0.30/<OS version folder>/.
- Run the program called server_ctt to emulate an OPC UA device and answer OPC UA requests.
- Leave the OPC UA server running.
Create a session
- Start the FairCom Control Center.
- Sign in with the username and password. FairCom's default username is ADMIN (case-insensitive) and the password is ADMIN (case-sensitive).
Note When you log into the FairCom Control Center, a session is automatically created. Any request submitted in the API Console will have the "authToken" property automatically populated with that session's auth token. If you aren't following this tutorial inside the FairCom Control Center, you must first execute the createSession action and set the "authToken" property manually.
Create an Integration Table for OPC UA data
This procedure creates an Integration Table named opctable in the faircom database. The Integration Table automatically creates the create_ts, error and source_payload JSON fields.
- Navigate to the Code tab from the sidebar menu and select API Console.
- Copy and paste the following code into the API Console request:
{ "action": "createIntegrationTable", "params": { "tableName": "opctable" }, "authToken": "replaceWithAuthTokenFromCreateSession" }
- Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
Note
"errorCode"with a value of0indicates success."errorCode"with a non-zero value indicates a failure. See Errors and contact FairCom for more information about an error.
Create a Tag to this Integration Table
This procedure creates one tag related to the opctable. It represents the property the_answer in the source_payload field of opctable. The tag is also assigned to a user-defined field (the_answer) and its value is automatically synchronized with the source_payload property value.
- Copy and paste the following code into the API Console request:
{ "action": "createTag", "params": { "tagName": "theanswer", "tableName": "opctable", "tagDataType": "number", "sourcePayloadPath": "the_answer", "sourceFieldName": "the_answer", "sourceFieldType": "float", "sourceFieldLength": 8 }, "authToken": "replaceWithAuthTokenFromCreateSession" }
- Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
Capture OPC UA data as JSON records in the database
This procedure creates an input named opcdata. The opcdata input reads OPC UA data and stores it in the JSON format in the source_payload field of opctable.
- Navigate to the Code tab from the sidebar menu and select API Console.
- Copy and paste the following code into the API Console request:
{ "action": "createInput", "params": { "inputName": "opcdata", "serviceName": "opcua", "dataCollectionIntervalMilliseconds": 5000, "settings": { "opcServerUrl": "opc.tcp://localhost:4840", "propertyMapList": [ { "tagName": "theanswer", "opcNamespace": 1, "opcNodeName": "the.answer" } ] }, "tableName": "opctable" }, "authToken": "replaceWithAuthTokenFromCreateSession" }
- Click the Run button.
- Observe the response in the Output section and ensure the action is completed successfully.
View the captured OPC UA data in the opctable table
- Click on the
opctabletable. - Click on any record and look at the
{} Payload. - Observe the JSON contents of the field:
{ "create_ts": "2026-11-03T23:23:15.726000000Z", "the_answer": 42 }
Start the Modbus Server simulator
- Open a new command prompt. Navigate to the simulator in <FairCom Folder>/server/modbus/test/<OS folder>/diagslave.<#.##>/<OS version folder>/.
- Run the following script at the command prompt to start the Modbus simulator that will answer Modbus TCP requests.
diagslaveTCP.sh (or diagslaveTCP.bat on Windows)
Write data to the Modbus Server simulator
Define an integration (createOutput) to read data from table opctable and write it to the Modbus Server. Paste the following code into the API Console request. This command will read opctable tag theanswer and write its value to modbus at address 1600.
{ "action": "createOutput", "params": { "outputName": "opc_to_modbus", "serviceName": "modbus", "tableName": "opctable", "settings": { "modbusProtocol": "TCP", "modbusServer": "127.0.0.1", "modbusServerPort": 502, "modbusDataAddressType": "oneBased", "propertyMapList": [ { "tagName": "theanswer", "modbusDataAddress": 1600, "modbusDataAccess": "holdingregister", "modbusSlave": 5, "modbusDataType": "int16SignedAB" } ] } }, "authToken": "replaceWithAuthTokenFromCreateSession" }
Verify that FairCom is writing the correct data to Modbus
Read data at Modbus address 1600
- Open a new command prompt.
- Navigate to the Modbus client simulator in <FairCom Folder>/server/modbus/test/<OS folder>/modpoll-<#.##>/<OS version folder>/.
- Paste this command into the prompt:
modpoll -m tcp -p 502 -r 1600 -c 1 -1 -a 5 127.0.0.1
- The command should return
[1600]: 42.
Change OPC data and observe that Modbus will receive a new value
- Open a command prompt and find the OPC client in <faircom>/server/opc/test/open62541_v0.30/<OS version folder>/.
- Run the program called client to connect to
server_cttand increment the defined OPC UA variable by2. - Read Modbus data again to see the new value.
modpoll -m tcp -p 502 -r 1600 -c 1 -1 -a 5 127.0.0.1
- The command should return
[1600]: 44,showing that the data changed at the OPC-UA server was written to the Modbus Server.