Slave guide
Every screen and step in this guide was checked in the v1.3.4 (Windows) Release build.
In Slave mode the PC acts as a Modbus device (a slave): it opens a TCP port or a serial port and answers the master's read and write requests. When you have no device at hand, want to practise Poll or Script, or need to test an HMI or PLC program, simulate the device with Slave first.
This chapter uses a small lab as its example: a gateway with a power meter and an inverter behind it, plus a separate room sensor.
Contents
| Section | Topic |
|---|---|
| 1 | How Slave answers requests |
| 2 | A tour of the window |
| 3 | Building a simulated device: listener, device, Slave ID, registers |
| 4 | Setting values |
| 5 | Testing with Poll, and watching what the master accesses |
| 6 | Gateways and several listeners |
| 7 | Stopping and listening again |
| 8 | Testing with Script |
| 9 | RTU Slave |
| 10 | Saving the project |
1. How Slave answers requests
Three terms first:
| Term | Meaning |
|---|---|
| Listener | A TCP address and port (for example 127.0.0.1:502) or a serial port. The master connects here |
| Device | A simulated device behind a listener, with its own name and Slave ID |
| Register table | One table per Slave ID and function area of a device, listing the addresses you want to watch or set |
How it answers:
- If the listener has a device with the Slave ID the master asks for, Slave answers; if not, it does not answer and the master times out.
- Every Slave ID has all 65536 addresses in each of the four function areas. Reading an address not listed in the register table uses the Unlisted addresses setting. Set it from LISTENERS & DEVICES with ⚙ → Edit device (also in Add device). Answer 0 is the default, including on projects saved before v1.3.14: the read returns 0, or whatever the master wrote there earlier. Exception 02 (illegal data address) returns exception code 02 instead. The setting applies to the whole device (every Slave ID), is saved in the project, and takes effect at once even while listening. It has been available since v1.3.14.
- Values the master writes take effect at once and the next read returns them. When the address is listed in the table, its Value updates too.
- Discrete Inputs and Input Registers are read-only to the master; they can only be changed on the Slave screen.
2. A tour of the window
Download the practice file 08-lab.mbslave, switch to Slave, open it with File → Open Project..., then connect with Poll as in section 5. The window looks like this:

Top
| Item | Meaning |
|---|---|
| Listen / Stop | Starts or stops the listener the selected device is on. Devices on the same listener start and stop together |
Values you change are served on the next request. | Reminder: a value you change is used from the master's next read |
| Apply format | Changes the format of the checked rows in one go |
The status bar shows the state of the listener the selected device is on:
| Item | Meaning |
|---|---|
Listening / Offline | Listening / not listening |
TCP 127.0.0.1:502 (this PC only) | Listen address and reach |
Waiting for a master / Master connected / N masters connected | Whether a master is connected |
Requests, Reads, Writes, Errors | Requests, reads, writes and errors this listener has received |
Last request | When the last request arrived |
Left: LISTENERS & DEVICES
Devices are grouped by listener: each listener comes first (for example TCP 127.0.0.1:502, a green dot while listening), followed by its devices and their Slave IDs. Answering on the right of a device means it is answering, Offline that it is not listening; a device's dot turns blue when it has just received a request.
Header buttons: ⚙ edits the selected device, + adds a device, - deletes one.
Register table
| Column | Meaning |
|---|---|
| ☐ | Check box, used by Apply format and delete |
| Monitor | ★ marks rows to keep an eye on; Monitored only shows just those. It does not change how Slave answers |
| Address | The address |
| Name / Description | The name |
| Format | The format values are shown and typed in |
| Value | The current value. Double-click to change it |
| Last access | The master's latest access: Read · just now (blue), Write · 3 s ago (orange). The row flashes when just accessed |
| Count | How many times this address has been accessed |
Log
The Log at the bottom lists traffic on all listeners: RX is a request received (Event Request), TX a reply sent (Reply), and Source is the listen address. The filter drop-down offers All traffic, TX, RX and INFO; Clear clears the log. To read the frames, see Troubleshooting 11.
3. Building a simulated device
Listen address
Select the device and click ⚙ (or double-click it) to open Edit device, then set Mode (Modbus TCP / RTU), Listen IP and TCP Port, or the serial settings. Listen IP decides who can reach the simulated device (127.0.0.1 this PC only, 0.0.0.0 every network, or a particular network adapter); see Getting started: Connect to a real device. It cannot be changed while listening; click Stop first.
Unlisted addresses is in the same Edit device dialog, and in Add device. It can be changed while listening. What each choice does is in How Slave answers requests.
Adding a device
Clicking + (or Device → Add Device) adds a device straight away:
- Its listen address is the same as the first device in the list, so it is added to that listener (one more device behind a simulated gateway).
- Its Slave ID is set to a number not yet in use.
- It starts with one holding register,
0x0000.
To make it a separate listener, click ⚙ and change the port or IP.
To delete a device, select it and click -. A listening device must be stopped first, and at least one device must remain.
Slave ID
Slave ID tabs work as in Poll: + adds one, right-click → Set Slave ID... changes it, × deletes it. Slave IDs in Slave range from 1 to 247 (0 is broadcast, 248–255 are reserved). Devices on the same listener cannot share a Slave ID.
Function areas and registers
- Device → Add Function Area... adds a function area; right-click a tab → Close closes it.
- + Add register: enter Start address and Quantity to add consecutive addresses.

- Click the Format column (or double-click the address or name) to open the Point window and change the name and format:

- Check several rows and click Apply format to change their format in one go; click - Delete register to delete them.
The formats are the same as in Poll (Signed, Unsigned, Hex, Binary, Long, Float, Double and the byte orders); see Poll guide 5. Float and Long take 2 registers, Double takes 4. Slave has no engineering conversion: values are always entered raw.
4. Setting values
Double-click the Value column, type the new value and press Enter:
- While listening, the change takes effect at once and the master's next read returns it. There is no "write" button to press.
- Values changed while not listening are served once listening starts.
- Type values to match Format: negative numbers for Signed,
0x1234for Hex,3.48for Float. Coils and discrete inputs take0or1. Invalid values are not applied, and a note saysNot applied: "..." is not valid.
Practice: select Inverter and, in 03 Holding Registers, change Output speed (0x0002) to 1480. On the Poll side, Output speed becomes 1480 rpm on the next round.
5. Testing with Poll
Download 08-lab-poll.mbproj. It has two Poll devices:
| Poll device | Connection | Slave ID | Simulated device |
|---|---|---|---|
| Gateway 502 | 127.0.0.1:502 | 1, 2 | Power meter (ID 1), Inverter (ID 2) |
| Room sensor | 127.0.0.1:1502 | 1 | Room sensor (ID 1) |
- In the Slave window, open
08-lab.mbslave. SelectPower meterand click Listen (127.0.0.1:502; Power meter and Inverter start answering together). Then selectRoom sensorand click Listen (127.0.0.1:1502). - Switch another window to Poll, open
08-lab-poll.mbproj, selectGateway 502and click Connect, then selectRoom sensorand click Connect.
On the Poll side, one device reads the two devices behind the gateway through two Slave ID tabs:

On the Slave side, Last access and Count keep going up on every row.
Watching the master's writes
In Poll, select Gateway 502 and its ID 2 tab, click Stop to pause polling, change Run command to 1 and click Write F6. In Slave, Run command becomes 1, Last access shows an orange Write, and Writes in the status bar goes up by 1:

(Writing while polling works the same way; the next read just turns Last access back to Read very quickly.)
6. Gateways and several listeners
| To simulate | Do this |
|---|---|
| One device | One listener, one device |
| A gateway with several devices behind it (same IP and port, different Slave IDs) | Several devices on one listener, each with its own Slave ID. Devices added with + go on the first device's listener |
| One device answering several Slave IDs | One device, with more IDs added in its Slave ID tabs |
| Several independent devices | Give each device a different port (for example 502, 1502) or a different Listen IP |
Rules:
- Slave IDs cannot repeat on one listener.
0.0.0.0takes every address, so it cannot be used alongside another IP on the same port; one COM port can only have one set of serial settings.- One window has up to 32 listeners.
- If another program (or another Roach Modbus Tool window) is already listening on the same IP and port, Listen fails and says why.
For the full rules, see Getting started: Several devices at once.
7. Stopping and listening again
- Stop stops the listener the selected device is on, and any master connected to it is disconnected. Other devices on the same listener stop with it; other listeners are not affected.
- When you click Listen again, every address's value (including addresses not in the register table that the master wrote) is back to what it was before Stop, like a device's non-volatile memory. The power-cycle test relies on this; see Script examples 4.
- File → New Project, or opening another project, clears the kept values.
- Switching to Poll or Script mode stops every listener (Poll and Slave never run at the same time).
8. Testing with Script
Every Script example can use Slave as the device under test, for example:
- Script tutorial: write, then read back
- Script examples 3: two listeners on different ports, to practise a gateway test
- Script examples 4: Stop / Listen to simulate a power cycle
Run Script and Slave in separate windows: switching a window to Script mode stops its Slave listeners.
9. RTU Slave
In the device settings, set Mode to Modbus RTU, pick the COM Port, and set Baud, Data bits, Parity and Stop bits to match the master.
- The master and Slave must be on two different serial ports, joined by an RS-485 / RS-232 cable (or USB adapters). To practise on one PC, use virtual serial port software to create a pair of connected COM ports.
- Devices on the same COM port share one listener; their serial settings must match and their Slave IDs must not repeat.
- On Linux, add your account to the
dialoutgroup first; see Troubleshooting 3.
10. Saving the project
Slave projects use the .mbslave extension and work the same way as in Poll (File → New Project, Open Project..., Save Project, Save Project As...; Device → Export Device... and Import Device... for single devices).
Besides the listener settings, devices, Slave IDs and register tables, a Slave project also keeps each listed row's current value, including values the master wrote. Addresses not in the register table are not saved.
Next steps
- Poll guide: reading and writing as the master, engineering conversion
- Script examples: automated tests with Slave as the device
