How to Use Modbus Protocol

Modbus Protocol is used in industry to allow devices such as meters and other smart electronic devices to communicate with other devices or control systems. This article will cover the basics of ASCII serial modbus, but modbus standards now include TCP/IP.


  1. Image titled Use Modbus Protocol Step 1
    Boot up computer into dos or command prompt mode.
  2. Image titled Use Modbus Protocol Step 2
    Attach the serial cable to the computer and the other end to the device.
  3. Image titled Use Modbus Protocol Step 3
    If you have a straight through cable, connect a null modem in line with the cable.
  4. Image titled Use Modbus Protocol Step 4
    Open a text editor such as 'edit' or 'kedit'.
    • The general format for the *.cfg file is
      • Title;
      • string length, null character, stop bit and speed;
      • Then the body starts in the format:
      • Device register, Modbus command, source register;
        • Note that all modbus lines end with a semicolon and EOL
  5. Image titled Use Modbus Protocol Step 5
    "#" indicate comments
    • There are numerous possible modbus commands, but you generally need only need a few.
      • Read input register
      • Read status register
      • Write input register
      • Write status register


  • Standard serial Modbus uses an RS–232 or RS-485 interface. The RS-232 is the standard nine or 25 pin serial cable commonly used to link computers to external modems, were a transmit, receive and ground pin are used.
    1. The RS-485 is a transmit receive pair that allows multiple devices (up to 255 the device has a hex byte that identifies it, 255 decimal = F - 1 in hex or 2^8 - 1 because counting starts at zero.) to be on the same wire link.
    2. In both cases the main communication is a master slave configuration were the master device queries the slave for information, and the slave responds with a string that includes a portion of the original message, and the requested information. With the RS-485 link, the slaves each have a unique identifier that allows them to know when they are expected to respond.
  • DOS works best


  • Using an editor like word can leave unexpected formatting or other code in the ASCII file.

Things You'll Need

  • A basic text editing program such as notepad.
    1. A modbus executable program
    2. A linking program that allows you to upload and download to and from the target device
    3. An understanding of the register structure of the device.
    4. A serial cable with the transmit and receive pairs rolled, so that the transmit pin from the source goes to the receive pin on the other device and vice versa, the receive pin on the source goes to the transmit pin on the other device.

Article Info

Categories: Hardware