> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/hypersim/configure-ios/communication-protocol-ios/modbus-master/connect-the-hardware.md).

# Connect the Hardware

## In TCP mode

### Connect devices using standard Ethernet cables

Modbus communication operates over **Ethernet (TCP/IP)** and uses the simulator’s **built‑in LAN ports**. To establish a connection between the master and Modbus slaves, simply connect the devices using **standard Ethernet cables**.

### Set IP addresses and subnets

For reliable Modbus communication, all devices must follow standard IP networking practices:

* The master and all slaves must be located on the same IP subnet unless routing has been explicitly configured.
* Each physical device must have a **unique IP address** to avoid conflicts.
* A single device may host multiple **logical Modbus slaves**, each configured with a different **Unit ID**.

**The master will use the IP address of the simulator’s LAN port connected to the Modbus TCP network.** This is the source IP address from which Modbus requests originate.

Example of valid subnet configuration:

* Master: `192.168.10.10 / 255.255.255.0`
* Slave 1: `192.168.10.20 / 255.255.255.0`
* Slave 2: `192.168.10.30 / 255.255.255.0`

### Set the Modbus communication port

Modbus TCP uses a **standardized default TCP port: 502**.

In most cases, both the master and slaves should use port 502. However, some devices allow custom port assignments. When using a non‑standard port:

* Ensure no firewall or network security rule blocks the selected TCP port.
* The master must be configured to connect to the correct port on each slave.
* Each slave must be configured to listen on the corresponding port.

Multiple slaves can share the same port number (e.g., all listening on port 502) as long as:

* Their **IP addresses are different**, or
* They run as **logical slaves** on the same device and are differentiated by their **Unit IDs**.

## In RTU mode

### Connect devices using standard serial cables

Modbus RTU operates over serial links, typically **RS‑485 (2‑wire or 4‑wire half‑duplex)** or **RS‑232 (point‑to‑point)**, using the simulator’s built‑in serial port or a supported PCIe serial interface (RS‑232/422/485).

* Use appropriate **shielded serial cables** for the selected physical layer.
* For **RS‑232**, connect **TX/RX/GND** between the simulator and a single slave device.
* For **RS‑485**, connect the **A/B differential pair** (and **GND** reference when available) across all devices on the bus.

### Set serial line parameters

For reliable Modbus RTU communication, all devices on the bus must use **identical serial settings**:

* **Baud rate:** e.g., 9 600, 19 200, 38 400, 115 200 bps (as supported by all devices)
* **Data bits / Parity / Stop bits:** typically **8‑E‑1** or **8‑N‑1** (must match across devices)
* **Timeouts:** configure master request timeout and inter‑character/ inter‑frame timing according to the selected baud rate

Modbus RTU uses **binary framing** and a **CRC‑16** for error detection. Proper timing gaps between frames are required; ensure the master and slaves respect the inter‑character and inter‑frame spacing.

### Addressing

Modbus RTU does **not** use IP addresses or TCP ports. Each slave on the serial bus must have a **unique slave address (Unit ID 1–247)**.

* The **master** transmits requests to a specific slave address; only that slave responds.
* Do **not** reuse a slave address on the same bus segment.

**Example addressing on one RS‑485 bus:**

* Master (simulator serial port)
* Slave 1: **Address 1**
* Slave 2: **Address 2**
* Slave 3: **Address 3**

### RS‑485 bus wiring, termination, and biasing

For multi‑drop RS‑485 installations:

* **Topology:** Use a **daisy‑chain** (bus) layout; avoid star wiring.
* **Termination:** Place **120 Ω** termination resistors at the **two ends** of the main bus.
* **Biasing (failsafe):** Provide **pull‑up/pull‑down bias resistors** on the A/B lines so the bus rests at a known logic level when idle (some interfaces include built‑in bias; enable only one set per bus).
* **Grounding:** Where feasible, connect a **signal reference (GND)** to reduce common‑mode voltage; follow site grounding practices and device manuals.
* **Cable:** Use **twisted‑pair, shielded** cable rated for RS‑485.

### Selecting data rates and timeouts

Higher baud rates reduce latency but tighten timing margins and cabling constraints. Choose the **highest common baud rate** supported by all devices and set master **request timeout** accordingly (accounting for frame length and slave processing time).

* If communication errors occur, **lower the baud rate** or **increase timeouts**.
* Ensure the master respects **silent intervals** between frames.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/hypersim/configure-ios/communication-protocol-ios/modbus-master/connect-the-hardware.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
