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

  1. Enter the target device IP in IP Address and the Modbus port in TCP Port.

  2. Run the scenario. The block will attempt to connect and will output Modbus Client when connected.

  3. Connect the Modbus Client output 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 Client to Modbus Read to periodically read registers from a PLC or device.

  • Use Modbus Client with Modbus Write to send control commands or update register values.

  • Pair with Logic Input or Rising Edge to trigger reads/writes only when you need them (reduce network traffic).

  • Log readings by routing numeric outputs to CSV Export or Data to JSON for later analysis.

  • Use Scope to visualize live numeric values coming from reads for quick monitoring.

  • Add a Debug Input to inspect values and troubleshoot communication during setup.

  • For alarms or notifications, pipe read results into Send Mail to send alerts when thresholds are exceeded.

πŸ› οΈ Troubleshooting

  • Connection fails: Verify the IP Address and TCP Port are 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 Input and logs to capture error details and verify parameters; adjust IP/port or consult device documentation or network administrator.

Last updated

Was this helpful?