MANUFACTURING / INTEGRATION / AUTOMATION
LIVE TOOL

Modbus tools

Build and read Modbus RTU, ASCII and TCP frames, check CRC-16 and LRC, and look up exception codes. In Chrome or Edge it can also talk to a device on a serial port (RS-485 / RS-232 adapter) through Web Serial: request and reply, polling and a log. Reading is the default; every write is confirmed first.

Tool
Registers in results (all parts)

Registers are always listed as hex, UINT16 and INT16. For 32- and 64-bit values, floats, BCD and text, choose the type and the order the device uses; the conversion is the one of the PLC data converter.

Request

Address 0 on the wire = holding register number 40001 / 400001.

Numbers in decimal or as 0x hex. Quantities follow the specification: 1 … 2000 coils or inputs and 1 … 125 registers per read, 1 … 1968 coils and 1 … 123 registers per write. Requests outside these limits are not built.

Runs in this browser. Data is not uploaded or stored.

Frame

01 03 00 00 00 0A C5 CD

8 bytesRequest
25 bytesNormal reply (exception: 5 bytes RTU)
ReadAccess

Read Holding Registers: 10 holding registers from address 0 (40001 / 400001), unit 1, as RTU.

    The request in every framing
    FramingBytesFrame
    RTU (chosen)801 03 00 00 00 0A C5 CD
    ASCII17:01030000000AF2\r\n
    TCP (MBAP)1200 01 00 00 00 06 01 03 00 00 00 0A
    Fields of the RTU frame
    FieldBytesValue
    Address (unit id)011
    Function0303 (0x03) Read Holding Registers
    Start address00 000 (40001 / 400001)
    Quantity00 0A10 holding registers
    CRCC5 CD0xCDC5 (low byte first)

    Frame

    A reply does not repeat the address it answers: type the request’s start address (0-based) to list the registers with their addresses. Auto framing: “:” … CR LF is ASCII; protocol id 0 with a matching length is TCP; otherwise RTU (checked by its CRC).

    Try

    Runs in this browser. Data is not uploaded or stored.

    Decoded

    03Function
    RTUFraming
    1Unit id
    CRC OKCheck

    RTU, unit 1: Read Holding Registers: 10 registers from address 0 (40001 / 400001). Framing: RTU: the last two bytes are the CRC of the bytes before them.

      fields
      FieldBytesValue
      Address (unit id)011
      Function0303 (0x03) Read Holding Registers
      Byte count1420 bytes
      Register values00 E1 01 90 41 C8 00 00 FF FE 1D C0 00 01 00 00 12 34 00 070x00E1 0x0190 0x41C8 0x0000 0xFFFE 0x1DC0 0x0001 0x0000 0x1234 0x0007
      CRC99 8A0x8A99: correct (low byte first)
      data in the response: 10 registers
      AddressNumberHexUINT16INT16
      040001 / 4000010x00E1225225
      140002 / 4000020x0190400400
      240003 / 4000030x41C81684016840
      340004 / 4000040x000000
      440005 / 4000050xFFFE65534-2
      540006 / 4000060x1DC076167616
      640007 / 4000070x000111
      740008 / 4000080x000000
      840009 / 4000090x123446604660
      940010 / 4000100x000777

      Bytes

      Try

      Runs in this browser. Data is not uploaded or stored.

      Checksums

      0xCDC5CRC-16/MODBUS
      C5 CDSent as (low byte first)
      0xF2LRC
      6Bytes

      CRC-16/MODBUS of 6 bytes: 0xCDC5, sent low byte first as C5 CD.

        Checksums
        ChecksumValueDetail
        Bytes601 03 00 00 00 0A
        CRC-16/MODBUS of all bytes0xCDC5sent as C5 CD (low byte first)
        RTU frame with this CRC801 03 00 00 00 0A C5 CD
        LRC of all bytes0xF2sent as the characters “F2”
        ASCII frame with this LRC:01030000000AF2\r\n
        CRC of the first 4 bytes0xD8F1F1 D8; the last two bytes are 00 0A: not this CRC
        LRC of the first 5 bytes0xFCthe last byte is 0A: not this LRC

        Download offline versionSingle HTML file · v1.6 · 360 KB · works without internet

        How the frames are built and read

        A Modbus request is a protocol data unit (PDU: function code and data, at most 253 bytes) wrapped in an application data unit for the line it travels on. The tool follows the Modbus Application Protocol Specification V1.1b3, Modbus over Serial Line V1.02 and Modbus Messaging on TCP/IP, as recalled; the points that could not be checked against the documents here are listed at the end.

        Framing

        Functions

        Exception responses

        A device that cannot carry out a request answers with the function code + 0x80 (0x83 for 03) and one exception code.

        01 Illegal Function
        The device does not support this function code, or not in its current state.
        02 Illegal Data Address
        An address of the request is not available in the device: the start address, or start + quantity, is outside what it has. Check 0-based addresses against register numbers (40001 = address 0).
        03 Illegal Data Value
        A value of the request is not allowed: for example a quantity outside the limits, a byte count that does not match, or a coil value other than FF00 / 0000.
        04 Server Device Failure
        An unrecoverable error occurred in the device while it was performing the requested action.
        05 Acknowledge
        The device has accepted a request that takes a long time and is processing it; poll it later for completion.
        06 Server Device Busy
        The device is busy with a long command; send the request again later.
        07 Negative Acknowledge (not in V1.1b3)
        Not in the exception table of V1.1b3; older Modicon documentation (unverified here) used 07 for a program function the device cannot perform.
        08 Memory Parity Error
        Used with function codes 20 and 21 (file records): the device found a parity error in its memory.
        0A Gateway Path Unavailable
        A gateway could not set up a path to the target device; it may be misconfigured or overloaded.
        0B Gateway Target Device Failed To Respond
        A gateway got no response from the target device; the device may be absent or not answering.

        Addresses and register numbers

        Worked examples (the tool’s examples)

        1. Read 10 holding registers from unit 1 at address 0 (registers 40001 … 40010): PDU 03 00 00 00 0A; RTU 01 03 00 00 00 0A C5 CD (CRC 0xCDC5, low byte first); ASCII :01030000000AF2 CR LF (1 + 3 + 0 + 0 + 0 + 10 = 14 = 0x0E, LRC = 0x100 − 0x0E = 0xF2); TCP with transaction id 1 00 01 00 00 00 06 01 03 00 00 00 0A.
        2. The reply has 3 + 20 + 2 = 25 bytes: 01 03 14 (byte count 20) then the registers 00E1 0190 41C8 0000 FFFE 1DC0 0001 0000 1234 0007 and the CRC 99 8A. Register 40001 = 0x00E1 = 225; registers 40003 – 40004 = 0x41C8 0x0000 = 25.0 as FLOAT32 (ABCD); 40005 – 40006 = −123456 as INT32 (illustrative values).
        3. The exception reply 01 83 02 C0 F1: function 0x83 = 03 + 0x80, exception 02 Illegal Data Address.
        4. Writing 25.0 as FLOAT32 (ABCD) to address 100 with function 16: 01 10 00 64 00 02 04 41 C8 00 00 61 B6.
        5. The check value: the CRC-16/MODBUS of the nine characters “123456789” is 0x4B37.

        Common mistakes

        Input and files

        Not verified against the documents

        Questions

        Is register 40001 address 0 or 1?
        Address 0. On the wire a Modbus request carries a 0-based address. The numbers 40001, 30001, 10001 and 00001 are a convention of manuals and SCADA tools (from the Modicon days, not part of the protocol): the first digit names the table and the rest counts from 1. So holding register 40001 is address 0, 40108 is address 107, and the six-digit form 400001 … 465536 reaches every address. The builder shows both side by side.
        Why does my device answer with exception 02?
        Exception 02 (Illegal Data Address) means that the start address, or the start plus the quantity, is outside what the device has. The most common cause is an off-by-one between register numbers and addresses (40001 is address 0), or reading a block that crosses a gap in the device’s map. Exception 03 (Illegal Data Value) usually means a quantity outside 1 … 125 registers, and 01 a function the device does not support.
        How is the Modbus RTU CRC calculated?
        CRC-16/MODBUS: start with 0xFFFF; for each byte XOR it into the low byte, then eight times shift right and, when the bit shifted out was 1, XOR 0xA001 (the polynomial 0x8005 reflected). There is no final XOR. The result is sent low byte first: the CRC 0xCDC5 of 01 03 00 00 00 0A goes on the wire as C5 CD. The check value of the ASCII text “123456789” is 0x4B37.
        Can a web page talk to my Modbus device?
        Over a serial port, yes, in Chrome, Edge or Opera on a computer: Web Serial lets the page open a USB serial adapter after you choose it in the browser’s own window. The page sends a request only when you press Send or Poll, asks for a confirmation before every write and never writes in a loop. Modbus TCP needs a network socket, which a web page cannot open, so TCP frames can be built and read here but not sent.
        Why do I get no reply (timeout)?
        Most often the port settings differ from the device (baud, parity, stop bits), the unit id is wrong, the A and B wires of the RS-485 pair are swapped, or the bus lacks termination and biasing. A wrong framing (RTU against an ASCII device) also gives no reply. A device answers nothing at all to a broadcast (unit 0) and to a request with a CRC error.