> 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-slave/configure-modbus-slave.md).

# Configure Modbus Slave

When working with communication protocols, it is recommended to begin by configuring the protocol through the **I/O Interfaces** section in <code class="expression">space.vars.Software</code> before proceeding with other steps.

## Configure the Modbus slave I/O interface

{% stepper %}
{% step %}

### Add a new I/O interface

1. In the **HYPERSIM** tab, click **I/O Interface** in the **Sensors & I/Os** section to open the **I/O Interface Configuration** window.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-881ca3164b1b5fa2d589ecb145163b15e7af8f64%2FDR-hyp-io-interface.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Right‑click **Modbus Slave** and select **Add**. Keep the default name or enter a custom one. If multiple **Modbus Slave** are added, each one must have a unique name.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-9fe49aa2826947acc2b1e929c7b6824120020b7b%2FDR-hyp-modsl-add.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure the general settings

Click the newly added **Modbus Slave** in the **I/O Interface Configuration** window and configure the general settings.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-5fd7d6316a208d09448ca876c2189ab49bdf2704%2FDR-hyp-modsl-gen.png?alt=media" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="165">Parameter</th><th>Value (Description)</th></tr></thead><tbody><tr><td><strong>Use an RT core for asynchronous computation</strong></td><td><strong>Checked:</strong> The driver reserves a dedicated real‑time CPU core for its communication tasks, allowing it to handle a larger number of Modbus slaves efficiently.<br><strong>Unchecked:</strong> The communication system runs on core 0 alongside the operating system.</td></tr><tr><td><strong>Enable verbose mode</strong></td><td><strong>Checked:</strong> Displays the full configuration during model loading for debugging.<br><strong>Unchecked:</strong> Only standard log messages are shown.</td></tr><tr><td><strong>Enable virtual mode</strong></td><td><strong>Checked:</strong> Allows the model to execute even if the I/O interface does not match the hardware configuration. All connections are initialized, but the interface performs no communication. Useful for troubleshooting without hardware or preparing models for future systems.<br><strong>Unchecked:</strong> The interface operates normally and requires compatible hardware.</td></tr></tbody></table>
{% endstep %}

{% step %}

### Manage slaves: add, remove, rename, or reorder

Click **Slaves** and use:

* **+** icon to add slaves
* **–** icon to remove slaves
* **Arrow** icons to reorder slaves

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-8c88f877e52f06a6ebf9f4f3db473e13468e669e%2FDR-hyp-modsl-slave.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

### Configure the slave(s) settings

Click a slave under the **Slaves** folder to configure its settings. Repeat this step for each additional slave.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-665404a35d0eb3f74b776710cfcf0b59401e9514%2FDR-hyp-modsl-settings.png?alt=media" alt=""><figcaption></figcaption></figure>

{% tabs %}
{% tab title="TCP mode" %}

<table><thead><tr><th width="140">Parameter</th><th>Value (Description)</th></tr></thead><tbody><tr><td><strong>Mode</strong></td><td>Select the Modbus communication mode: <strong>TCP</strong> or <strong>RTU</strong>.</td></tr><tr><td><strong>Slave ID</strong></td><td>ID of the Modbus slave. Must be unique for each slave.</td></tr><tr><td><strong>NIC name</strong></td><td>Network interface name. Select the correct interface based on your <strong>System Description Document</strong> or Linux <code>ifconfig</code> command. For local testing on the same simulator, use the loopback interface <strong>lo</strong>.</td></tr><tr><td><strong>IP address</strong></td><td>IP address assigned to the Modbus slave. For local testing on the same simulator, use <strong>127.0.0.1</strong>.</td></tr><tr><td><strong>TCP port</strong></td><td>TCP port on which the Modbus slave listens for incoming connections from the master.</td></tr><tr><td><strong>Cycle rate (ms)</strong></td><td>Interval (in milliseconds) at which the model writes data to the slave’s outputs (coils and holding registers). When both the model and the master may modify outputs, this value must be <strong>greater than the model time step</strong>, otherwise master write operations will not be reflected in the model.</td></tr><tr><td><strong>Byte ordering</strong></td><td>Defines how 32‑bit values are encoded across two Modbus registers. For <strong>FLOAT32</strong>, the default <strong>ABCD</strong> ordering corresponds to IEEE‑754. Supported orders include <strong>ABCD</strong>, <strong>BADC</strong>, <strong>CDAB</strong>, and <strong>DCBA</strong>.</td></tr><tr><td><strong>Permit read/write requests with address gaps</strong></td><td><strong>Checked:</strong> From the lowest to the highest configured address, this option automatically creates any missing coils, discrete inputs, holding registers, or input registers and initializes them with a value of 0.<br><strong>Unchecked:</strong> The interface behaves normally.</td></tr><tr><td><strong>Advanced fault injection options</strong></td><td><p><strong>Checked:</strong> Provides options allowing the simulation of network and device‑level failures during runtime:</p><ul><li><strong>Enable slave failure:</strong> When <strong>checked</strong>, the <strong>Slave failure</strong> connectable point is exposed, allowing<br>to enable or disable slave failure directly <strong>from the model</strong> during execution.</li><li><strong>Enable slave delay:</strong> When <strong>checked</strong>, the <strong>Slave delay enable</strong>, <strong>Slave delay (ms)</strong>, <strong>Number of delayed replies</strong>, <strong>Remaining delayed replies</strong>, and <strong>Slave delay active</strong> connectable points are exposed, allowing to control delay behavior <strong>from the model</strong> during execution.</li></ul><p><strong>Unchecked:</strong> Advanced fault injection features are disabled.</p></td></tr></tbody></table>
{% endtab %}

{% tab title="RTU mode" %}

<table><thead><tr><th width="145">Parameter</th><th>Value (Description)</th></tr></thead><tbody><tr><td><strong>Slave ID</strong></td><td>Unique identifier assigned to the Modbus slave. In RTU mode, multiple slaves may share the same serial bus (RS‑232/422/485); therefore, each slave must have a <strong>unique slave ID</strong> to avoid address conflicts.</td></tr><tr><td><strong>Hardware</strong></td><td>Select <strong>Generic</strong> when using the simulator’s <strong>on‑board serial ports.</strong><br>Select <strong>MOXA CP‑116E‑A / CP‑118EL‑A</strong> when using ports on a <strong>MOXA CP‑116E‑A or CP‑118EL‑A serial expansion card</strong> installed in the simulator.</td></tr><tr><td><strong>Serial port</strong></td><td>Path to the serial interface used for Modbus RTU communication. On OPAL‑RT systems with SuperMicro motherboards, the first serial port typically appears as <strong><code>/dev/ttyS0</code></strong>.</td></tr><tr><td><strong>Serial baudrate</strong></td><td>Communication speed of the Modbus RTU link (e.g., 9 600, 19 200, 38 400, 115 200 bps). All devices on the bus must use the <strong>same baudrate</strong>.</td></tr><tr><td><strong>Serial data bits</strong></td><td>Number of data bits used in each character frame. Common values include <strong>7</strong> or <strong>8</strong>, with <strong>8</strong> being typical for Modbus RTU.</td></tr><tr><td><strong>Stop bits</strong></td><td>Number of stop bits appended to each character frame. Standard configurations are <strong>1</strong> or <strong>2</strong> stop bits; all devices must match.</td></tr><tr><td><strong>Serial parity</strong></td><td>Parity scheme used by the Modbus RTU slave: <strong>None</strong>, <strong>Odd</strong>, or <strong>Even</strong>. When Odd or Even is selected, the parity bit is set so that the total number of “1” bits in the 8‑bit data field is <strong>even</strong> (Even parity) or <strong>odd</strong> (Odd parity). This parity bit is added to each transmitted character.</td></tr><tr><td><strong>Cycle rate (ms)</strong></td><td>Interval (in milliseconds) at which the model writes data to the slave’s outputs (coils and holding registers). When both the model and the master may modify outputs, this value must be <strong>greater than the model time step</strong>, otherwise master write operations will not be reflected in the model.</td></tr><tr><td><strong>Byte ordering</strong></td><td>Defines how 32‑bit values are encoded across two Modbus registers. For <strong>FLOAT32</strong>, the default <strong>ABCD</strong> ordering corresponds to IEEE‑754. Supported orders include <strong>ABCD</strong>, <strong>BADC</strong>, <strong>CDAB</strong>, and <strong>DCBA</strong>.</td></tr><tr><td><strong>Permit read/write requests with address gaps</strong></td><td><strong>Checked:</strong> From the lowest to the highest configured address, this option automatically creates any missing coils, discrete inputs, holding registers, or input registers and initializes them with a value of 0.<br><strong>Unchecked:</strong> The interface behaves normally.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Configure the slave(s) data points

1. Expand a slave to reveal its data point types.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-a046076b12c3fa079919081de9b0c90aa7599ce5%2FDR-hyp-modsl-data.png?alt=media" alt=""><figcaption></figcaption></figure>

2. Click a data point type (**Coils**, **Discrete inputs**, **Holding registers**, or **Input registers**) and use:

* **+** icon to add data points
* **–** icon to remove data points
* **Arrow** icons to reorder data points

3. Change parameters as desired:

{% tabs %}
{% tab title="Coils" %}

<table data-header-hidden><thead><tr><th width="130"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>Unique name used to identify the coil within the model and GUI.</td></tr><tr><td><strong>Address</strong></td><td>Modbus address at which the slave exposes this coil.</td></tr><tr><td><strong>Initial value</strong></td><td>Initial coil state (0 or 1).<br>• If the coil is controlled <strong>only by the master</strong>, this value is used at the beginning of the simulation.<br>• If the coil is controlled by the <strong>model</strong> or <strong>Both</strong>, the initial value comes from the model at startup.</td></tr><tr><td><strong>Control from</strong></td><td>Defines which entity controls the coil:<br><strong>Master:</strong> The coil behaves as a model input and can only be updated by the Modbus master. The model cannot override it.<br><strong>Model:</strong> The coil behaves as a model output and is updated exclusively by the model. A Modbus master may read the coil, but any write request is automatically overwritten by the model.<br><strong>Both:</strong> The coil is mapped to a model input, and a corresponding <em>from‑model</em> connection is created. The model periodically overwrites the coil value at the interval defined by the <strong>Cycle output rate (ms)</strong> parameter.</td></tr></tbody></table>
{% endtab %}

{% tab title="Discrete inputs" %}

<table data-header-hidden><thead><tr><th width="115"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>Unique name used to identify the discrete input within the model and the interface.</td></tr><tr><td><strong>Address</strong></td><td>Modbus address at which the slave exposes this discrete input.</td></tr></tbody></table>
{% endtab %}

{% tab title="Holding registers" %}

<table data-header-hidden><thead><tr><th width="120"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>Unique name used to identify the holding register within the model and interface.</td></tr><tr><td><strong>Address</strong></td><td>Modbus address at which the slave exposes this holding register.</td></tr><tr><td><strong>Initial value</strong></td><td>Starting value of the holding register.<br>• If controlled <strong>only by the master</strong>, this value is applied at the beginning of the simulation.<br>• If controlled by the <strong>model</strong> or <strong>Both</strong>, the initial value comes from the model at startup.</td></tr><tr><td><strong>Control from</strong></td><td>Defines which entity controls the register. Behavior is identical to coil control modes:<br><strong>Master:</strong> The register behaves as a model input and can only be modified by the Modbus master. The model cannot override it.<br><strong>Model:</strong> The register behaves as a model output and is updated exclusively by the model. A Modbus master may read it, but any write request is automatically overwritten by the model.<br><strong>Both:</strong> The register is mapped to a model input, and a <em>from‑model</em> connection is created. The model periodically overwrites the register value according to the <strong>Cycle output rate (ms)</strong> parameter.</td></tr><tr><td><strong>Register type</strong></td><td>Defines how the register value is encoded. Available types:<br><strong>UINT16:</strong> Standard Modbus 16‑bit unsigned integer.<br><strong>INT16:</strong> Non‑standard signed 16‑bit integer format supported for convenience.<br><strong>UINT32:</strong> Non‑standard 32‑bit unsigned integer. Uses two consecutive UINT16 registers and requires a <strong>2‑address offset</strong> before defining the next register. Supports multiple byte orderings as configured in the slave settings.<br><strong>INT32:</strong> Non‑standard 32‑bit signed integer. Also occupies two consecutive UINT16 registers and requires a <strong>2‑address offset</strong>. Supports multiple byte orderings.<br><strong>FLOAT32:</strong> IEEE‑754 single‑precision floating‑point (32‑bit). Occupies two consecutive UINT16 registers and requires a <strong>2‑address offset</strong>. Supports multiple byte orderings.</td></tr></tbody></table>
{% endtab %}

{% tab title="Input registers" %}

<table data-header-hidden><thead><tr><th width="110"></th><th></th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>Unique name used to identify the input register within the model and the interface.</td></tr><tr><td><strong>Address</strong></td><td>Modbus address at which the slave exposes this input register.</td></tr><tr><td><strong>Register type</strong></td><td>Defines how the input register value is encoded. All options mirror those available for holding registers:<br><strong>UINT16:</strong> Standard Modbus 16‑bit unsigned integer.<br><strong>INT16:</strong> Non‑standard signed 16‑bit value. Supported for convenience.<br><strong>UINT32:</strong> Non‑standard 32‑bit unsigned integer. Occupies <strong>two consecutive UINT16 registers</strong>. Requires a <strong>2‑address offset</strong> before defining the next register. Supports all byte‑ordering options configured in the slave settings.<br><strong>INT32:</strong> Non‑standard 32‑bit signed integer. Also occupies <strong>two UINT16 registers</strong> and requires a <strong>2‑address offset</strong>. Supports multiple byte orderings.<br><strong>FLOAT32:</strong> IEEE‑754 single‑precision floating‑point (32‑bit). Occupies <strong>two UINT16 registers</strong> and requires a <strong>2‑address offset</strong>. Supports multiple byte orderings.</td></tr></tbody></table>
{% endtab %}
{% endtabs %}
{% endstep %}

{% step %}

### Save the configuration

Click **Ok** or **Apply** to save the configuration.
{% endstep %}
{% endstepper %}


---

# 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-slave/configure-modbus-slave.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.
