Blog

How to Test a Modbus Device: A Practical Guide to Modbus TCP and RTU

· Sərvin Əliyev

How to test a Modbus device: Modbus 360 polling a PLC, an energy meter and a drive over Modbus TCP and RS-485

The panel is wired, the PLC is powered and the SCADA screen still shows zeros. Every commissioning engineer knows this moment. The problem can be anywhere: a wrong IP address, a swapped RS-485 pair, a register that is off by one, or a float whose words arrive in the opposite order.

This guide walks through how to test a Modbus device step by step, so you can tell within minutes whether the problem is the network, the device or the register map. It covers Modbus TCP, Modbus RTU and RTU over TCP, and it uses Modbus 360, our free cross-platform Modbus master and slave simulator, for the examples. The method works with any Modbus tool.

Modbus in two minutes

Modbus is a request and response protocol. One side, the master (also called client), asks; the other side, the slave (also called server), answers. A slave never speaks unless it is asked. A SCADA system, an HMI or a test tool on your laptop is usually the master; PLCs, energy meters, drives, flow meters and RTUs are usually slaves.

The same Modbus request travels over three common transports:

Modbus TCPModbus RTURTU over TCP
MediumEthernetRS-485 or RS-232 serial lineEthernet
Device selectionIP address, port 502, Unit IDSlave ID 1–247 on a shared lineIP address and port of the converter, then slave ID
Error checkTCP itself (no CRC in the frame)CRC-16 at the end of every frameCRC-16 inside the TCP payload
Typical usePLCs, gateways, modern metersMeters, drives, sensors, older equipmentSerial-to-Ethernet converters in transparent mode

Modbus TCP and Modbus RTU network topology and frame structure

Two practical consequences follow from this:

  • On Modbus TCP, every device has its own IP address. The Unit ID still matters when a gateway sits in front of serial devices; for a device that speaks TCP natively it is often 1 or 255.
  • On Modbus RTU, all devices share one pair of wires and only one master is allowed on the line. Every device needs a unique slave ID, and every device must use the same baud rate, parity and stop bits.

RTU over TCP is the one that confuses people. Many serial-to-Ethernet converters do not translate RTU into Modbus TCP; they simply pass the RTU frame, CRC included, through a TCP socket. If your tool talks Modbus TCP to such a converter, the device will never answer. Choose the transport that matches the converter's mode.

The four register tables and the "40001" trap

Modbus data lives in four tables. Each has its own function codes:

The four Modbus register tables with their function codes and the 40001 addressing offset

TableIn manualsSizeAccessReadWrite
Coils00001–099991 bitRead / writeFC01FC05, FC15
Discrete Inputs10001–199991 bitRead onlyFC02–
Input Registers30001–3999916 bitRead onlyFC04–
Holding Registers40001–4999916 bitRead / writeFC03FC06, FC16

The leading digit in "40001" is not part of the address. It only tells you the table. On the wire, register 40001 is holding register address 0, 40002 is address 1, and so on. Some manuals use this "one-based" notation, some list zero-based addresses, and some mix both on the same page.

This is the single most common reason for wrong values during commissioning. The symptom is easy to recognize: every value you read looks like it belongs to the neighbouring register. The fix is just as easy: subtract one from the address, or add one, and read again. Modbus 360 uses zero-based addresses, the same numbers that go into the request.

Also check which table the manual means. A meter that publishes voltage as an input register will answer FC03 with an exception, or with unrelated data, because you asked the wrong table.

What you need before you start

Gather these before you connect anything:

  1. The register map from the device manual: address, data type, scaling, unit and byte order for each value.
  2. For Modbus TCP: the device IP address, port (502 unless changed) and Unit ID. Your laptop must be in the same subnet or have a route to it.
  3. For Modbus RTU: a USB to RS-485 adapter, the device slave ID and the serial settings: baud rate, data bits, parity and stop bits. The Modbus specification defaults to even parity, but many devices ship with 9600 8N1. Do not guess; read the manual or the device display.
  4. One known value you can verify, such as the mains voltage on a meter or the setpoint shown on a drive's keypad. This is how you prove that the decoding is right, not only the communication.

Step by step: testing a Modbus device

1. Prove the network path first

Before opening any Modbus tool, check the layer below it. For Modbus TCP, ping the device and make sure nothing else blocks port 502. For RTU, confirm the adapter shows up as a COM port (Windows) or /dev/ttyUSB0 (Linux), and that the A and B wires go to the right terminals.

A detail that costs hours on site: many Modbus TCP devices accept only a few simultaneous connections, some only one. If the SCADA server is already connected, your laptop may be refused or disconnected. Stop the other master, or use a device that allows more connections, before you blame the network.

2. Connect and read a single register

In Modbus 360, create a connection on the Connections page: choose Modbus TCP, Modbus RTU or RTU over TCP, then enter the IP and port or the COM port and serial settings. Saved connections keep their transport settings, and the last working connection is restored the next time you open the app.

Then read one register you know exists, for example the first holding register in the map. Do not start with a block of 100 registers: if one address in the block does not exist, many devices reject the whole request with an exception, and you will not know which address caused it.

If you get a value, communication works. Everything after this point is about the register map.

3. Decode the value correctly

A 16-bit register holds a raw number. To turn it into volts, amperes or degrees you need three things from the manual:

  • Data type: Int16, UInt16, Int32, UInt32, Float or Double. A temperature of -5.0 °C sent as Int16 with a multiplier of 0.1 (raw value -50) shows up as 65486 if you decode it as UInt16.
  • Scaling: many devices send integers with a fixed multiplier. A raw value of 2305 with a multiplier of 0.1 is 230.5 V. In Modbus 360 the formula is value = raw × multiplier + offset, and the unit is shown next to the value.
  • Byte order for 32-bit and 64-bit values, which deserves its own section.

4. Get the byte order right for 32-bit values

A Float32 or Int32 does not fit in one 16-bit register, so the device splits it across two. The standard says nothing about which register comes first, so manufacturers chose differently. That gives four possible orders: ABCD, CDAB, BADC and DCBA.

The float value 230.5 split across two Modbus registers and decoded with four byte orders

Take a meter that reports 230.5 V as a float. In IEEE 754 that is 0x43668000, sent as register 40001 = 0x4366 and register 40002 = 0x8000. Decoded as ABCD you get 230.5. Decoded as CDAB you get -2.42e-41. As BADC, 2.30e+23. As DCBA, 1.18e-38.

So if a value is absurdly small, absurdly large or flips sign, suspect the byte order before anything else. Modbus 360 shows the raw hex next to the decoded value and lets you switch between the four orders per register, so you can try them against your known value in seconds.

5. Write only when you are sure

Reading is harmless; writing is not. Writing a holding register can change a setpoint, start a motor or open a breaker. Before you write:

  • Confirm the address and data type by reading the same register first.
  • Use FC06 for a single register and FC16 for several registers, including the two halves of a 32-bit value. Use FC05 or FC15 for coils.
  • Agree with the people on site that the equipment is in a safe state.

6. Poll efficiently

Once single reads work, group the registers you need. Reading 40 adjacent registers in one FC03 request is far faster than 40 separate requests, especially on a 9600 baud serial line. Modbus 360 does this automatically with block polling: adjacent registers are combined into one request. Keep in mind the protocol limits: up to 125 registers per FC03 or FC04 request and up to 2000 coils per FC01 request.

Common Modbus errors and how to fix them

When a device answers with an error, it returns an exception code. When it does not answer at all, you get a timeout. Here is what each one usually means:

SymptomMost likely causeWhat to check
Timeout, no responseWrong IP or port, wrong slave ID, wrong serial settings, A/B swapped, another master holding the connectionPing the device; check Unit ID, baud rate, parity and stop bits; swap A and B; disconnect the other master
Exception 01: Illegal FunctionThe device does not support this function code for that tableTry FC04 instead of FC03 (or the reverse); check which table the manual uses
Exception 02: Illegal Data AddressThe address does not exist, or the block includes an address that does not existRead a single register; try address minus one; shorten the block
Exception 03: Illegal Data ValueToo many registers requested, or a written value is out of rangeRequest fewer registers; check the allowed range in the manual
Exception 04: Slave Device FailureThe device hit an internal error while processing the requestCheck the device status and its own diagnostics
Exception 06: Slave Device BusyThe device is processing a longer commandRetry after a short delay
Exception 0A: Gateway Path UnavailableThe gateway has no route for that Unit IDCheck the gateway's routing table
Exception 0B: Gateway Target Device Failed to RespondThe gateway answered, but the serial device behind it did notTroubleshoot the serial side: slave ID, serial settings, wiring
CRC errors or garbage on RTUBaud or parity mismatch, electrical noise, missing terminationMatch serial settings; add 120 Ω termination at both ends of the bus; use shielded twisted pair
Values shifted by one registerOne-based versus zero-based addressingSubtract or add one to the address
Values absurd or with the wrong signWrong byte order, wrong data type or wrong scalingTry the other byte orders; check signed versus unsigned; check the multiplier

On RS-485, three electrical rules solve most remaining problems. Put a 120 Ω terminating resistor at both physical ends of the line and nowhere else. Wire the devices as a daisy chain, not a star. And remember that the A/B labels are not consistent between manufacturers: if nothing answers and the settings are right, swap the two wires.

When the cause is still not clear, look at the frames themselves. A traffic sniffer shows every request and response with timestamps, so you can see whether the device answers late, answers with an exception or does not answer at all. Modbus 360 includes a traffic sniffer with CSV export and a Test Center for sending raw Modbus TCP frames (MBAP header and PDU) and inspecting the reply byte by byte.

Finding unknown devices: address scanning

Sometimes nobody knows the slave ID or which registers exist. Two tools help here:

  • A Unit ID finder sends a short request to each ID in a range and lists the ones that answer. On an RTU line with unknown devices, this saves you from trying 247 IDs by hand.
  • An address scanner walks through a register range and shows which addresses return data and which return an exception. This is useful when the manual is missing or does not match the firmware.

Scan gently. Some older devices respond slowly, and an aggressive scan on a live line can disturb the SCADA polling that already runs there.

Testing without the hardware: slave simulation

The device is often the last thing to arrive on site, while the SCADA or HMI project has to be ready before it. A Modbus slave simulator solves this: your laptop pretends to be the device, and the SCADA polls it as if it were real.

Modbus 360 includes a Modbus TCP and RTU slave with all four register tables. Each register can hold a fixed value or change on its own: count up, alternate or random, including random Float32 signals. A ready-made three-phase power meter simulation produces voltage, current, power factor, frequency, active power and an accumulating energy counter, which is enough to test most energy dashboards. You can paste address and value columns straight from Excel and save the whole device as a reusable .m360slave profile.

This also works the other way. When a PLC programmer says "my side is fine", you can simulate the meter and prove whether the PLC reads it correctly.

Turning a PDF manual into a register map

The slowest part of commissioning is often not the communication but typing the register map from a 200-page PDF. Modbus 360 can read the manual for you: it extracts the register table (address, name, data type, scale, unit and byte order) with an AI model and shows it in an editable review table. Every row keeps the page it came from, so you can check it against the manual before you save it as a master profile or open it in the slave simulator. It works with OpenAI, DeepSeek or a local model such as Ollama.

Treat the result as a draft, not as truth. Check a few values against the manual and against the live device; that is exactly what the source page on each row is for.

A short checklist for site work

  • Read the register map first: table, address base, data type, scaling and byte order.
  • Prove the network path: ping and port for TCP, COM port and wiring for RTU.
  • Read one known register before reading a block.
  • Compare at least one value with a value you can verify on the device.
  • Fix addressing (plus or minus one) before you touch byte order.
  • Try the four byte orders on 32-bit values.
  • Write only after reading the same register, and only when the equipment is safe.
  • Save the working connection and register profile so the next visit takes minutes.

Frequently asked questions

What is the default Modbus TCP port?

Port 502. Some devices let you change it, and some gateways use a different port for RTU over TCP, so check the device configuration if 502 does not answer.

What is the difference between Modbus RTU and Modbus TCP?

Modbus RTU runs over a serial line (usually RS-485), selects devices by slave ID and protects each frame with a CRC. Modbus TCP runs over Ethernet, selects devices by IP address and relies on TCP for error checking. The function codes and register tables are the same in both.

Why does my Modbus device return wrong values?

The three usual causes are an address that is off by one (40001 is address 0), the wrong byte order for 32-bit values, and the wrong data type or scaling. Check them in that order.

Can I test a SCADA or HMI project without the real device?

Yes. Run a Modbus slave simulator on your computer, load the device's register map and point the SCADA at your computer's IP address or COM port.

Is Modbus 360 free?

Modbus 360 is a free download for Windows, Linux and macOS (Apple Silicon). The free edition covers everyday testing and troubleshooting; a one-time Pro license removes the limits, for example on the number of registers imported from a PDF manual.

Does Modbus 360 support Modbus ASCII or Modbus UDP?

Not at the moment. It supports Modbus TCP/IP, Modbus RTU and Modbus RTU over TCP.

Try it on your next commissioning

Modbus problems are rarely mysterious once you look at them in the right order: network, single register, addressing, data type, byte order. A good tool makes each step visible.

Download Modbus 360 for Windows, Linux or macOS, or read more on the Modbus 360 product page. If you are building a larger monitoring system on top of Modbus devices, see Luna SCADA or contact us.

Modbus 360