Modbus Connect
This function block establishes a Modbus TCP connection to a Modbus server and provides a reusable client object for other blocks to communicate with industrial devices over Modbus.
π₯ Inputs
This function block does not have any inputs.
π€ Outputs
Modbus Client This output provides the active Modbus client object that other blocks can use to read or write Modbus registers.
πΉοΈ Controls
IP Address Enter the IP address of the Modbus TCP server you want to connect to. Use the device or PLC IP assigned on your network.
TCP Port Enter the Modbus TCP port. The common default is 502; change if your server uses a different port.
π― Features
Persistent connection: The block tries to establish and maintain a Modbus TCP connection so the client is available to downstream blocks.
Automatic reconnect-on-change: If the address or port changes, the block will update the connection to match the new settings.
Safe cleanup: When removed from a scenario, the block releases the connection to free network resources.
π Usage Instructions
Enter the target device IP in
IP Addressand the Modbus port inTCP Port.Run the scenario. The block will attempt to connect and will output
Modbus Clientwhen connected.Connect the
Modbus Clientoutput to blocks that perform Modbus operations (reads/writes).
π Evaluation
When evaluated, the block ensures a valid Modbus TCP connection is active (or reconnected if parameters changed) and provides the current Modbus Client through its output for other blocks to use.
π‘ Tips and Tricks
Connect
Modbus ClienttoModbus Readto periodically read registers from a PLC or device.Use
Modbus ClientwithModbus Writeto send control commands or update register values.Pair with
Logic InputorRising Edgeto trigger reads/writes only when you need them (reduce network traffic).Log readings by routing numeric outputs to
CSV ExportorData to JSONfor later analysis.Use
Scopeto visualize live numeric values coming from reads for quick monitoring.Add a
Debug Inputto inspect values and troubleshoot communication during setup.For alarms or notifications, pipe read results into
Send Mailto send alerts when thresholds are exceeded.
π οΈ Troubleshooting
Connection fails: Verify the
IP AddressandTCP Portare correct and the Modbus server is reachable from your machine (ping the device or check network routing).Firewall or network blocking: Ensure your network and local firewall allow outgoing TCP on the configured port (commonly 502).
Server offline or misconfigured: Confirm the Modbus server (PLC, gateway, or device) is powered and configured to accept Modbus TCP connections.
Multiple clients: If another application is using the same Modbus device, try stopping that application or use separate connection instances where supported.
Persistent errors: Use
Debug Inputand logs to capture error details and verify parameters; adjust IP/port or consult device documentation or network administrator.
Last updated
Was this helpful?