|

A Guide to Modbus Communication Interfaces

March 11, 2024

A Guide to Modbus Communication Interfaces

Modbus is a widely used industrial communication protocol with several variants, including Modbus RTU, Modbus ASCII, and Modbus TCP/IP. It was initially developed by Modicon (now part of Schneider Electric) in the late 1970s and has since become a de facto standard for connecting various devices in industrial automation.

Technical Aspects of Modbus:

Modbus Variants:

Diving deeper into the technical facets of Modbus, this protocol showcases its versatility through its different variants, each tailored to specific communication needs and environments. Modbus RTU, ASCII, and TCP/IP serve as the core adaptations, providing a range of encoding methods and network capabilities.

  1. Modbus RTU: This variant uses binary encoding and is typically implemented over RS-232 or RS-485 physical layers. It is known for its simplicity, efficiency, and reliability in serial communication.
  2. Modbus ASCII: Similar to Modbus RTU but uses ASCII characters for encoding. While it’s less efficient due to the character-based encoding, it can be useful for troubleshooting and debugging.
  3. Modbus TCP/IP: This is an Ethernet-based version of Modbus, often referred to as Modbus/TCP. It encapsulates Modbus frames within TCP/IP packets, allowing for communication over Ethernet networks.
Modbus Frame Structure:

Modbus frames consist of several fields, including the Slave Address, Function Code, Data, and Error Checksum. The Function Code indicates the type of operation to be performed, such as reading or writing data.

  1. Slave Address: The Slave Address field is a crucial part of the Modbus frame, and it specifies which slave device on the network should respond to the request. In a Modbus network, multiple slave devices can be connected to a master (or client). The slave address helps the master identify which specific device it wants to communicate with.
  2. Function Code: The Function Code field is used to define the type of operation to be performed on the slave device. It indicates whether the master wants to read data from the slave, write data to the slave, or request other specific actions. Function codes are standardized and serve as command codes in the Modbus protocol. Modbus uses a variety of standardized function codes, each with a specific purpose. Some common function codes include:
    • Read Holding Registers (Function Code 03): Used by the master to request data from the slave’s holding registers.
    • Write Single Register (Function Code 06): Used to write a single data value to a holding register in the slave.
    • Write Multiple Registers (Function Code 16): Allows the master to write multiple values to consecutive holding registers in the slave.
    • Read Input Registers (Function Code 04): Similar to Read Holding Registers but used for reading input registers in the slave.
    • Read Discrete Inputs (Function Code 02): Used to read the status of discrete inputs (binary inputs) in the slave.
  3. Data: The Data field contains the actual data being transmitted between the master and the slave. The content and format of the data depend on the specific Modbus application and the function code. For example, if the function code indicates a read request, the data field may contain the requested data from the slave.
  4. Error Checksum: The Error Checksum field is used to ensure the integrity of the Modbus frame during transmission. It typically contains a checksum value, such as a cyclic redundancy check (CRC) or longitudinal redundancy check (LRC). The receiving device uses the checksum to verify that the data received matches the data sent. If there is a mismatch, it indicates a transmission error, and the frame may need to be retransmitted.
Modbus Master-Slave Architecture:

In Modbus communication, the architecture follows a master-slave model. The master initiates requests to read or write data, while the slave devices respond to these requests.

Modbus Data Types:

Modbus supports various data types, including binary, integer, floating-point, and more. Data is typically stored in 16-bit or 32-bit registers, and each register has a unique address.

  1. Binary:
    • Binary data type represents information in a simple on/off or true/false format.
    • Typically, a single bit is used to convey binary information.
    • Examples of binary data in Modbus might include the status of a digital sensor (e.g., a limit switch is either open or closed).
  2. Integer:
    • Integer data type represents whole numbers, either positive or negative.
    • Depending on the implementation, integers may be represented as 16-bit (2-byte) or 32-bit (4-byte) values.
    • Integer data types are often used to convey numerical values like temperature readings, counts, or setpoints.
  3. Floating-Point:
    • Floating-point data type represents real numbers with decimal places.
    • Typically, 32-bit (4-byte) or 64-bit (8-byte) floating-point formats are used.
    • Floating-point data types are suitable for conveying measurements with fractional parts, such as temperature in degrees Celsius or voltage in volts.
  4. 16-bit Registers:
    • These registers store 16 bits (2 bytes) of data. They are commonly used for holding binary and integer data types.
  5. 32-bit Registers:
    • Some Modbus implementations support 32-bit (4-byte) registers for storing larger integer values or floating-point numbers.
Modbus Addressing:

Devices on a Modbus network are identified by unique slave addresses, allowing the master to communicate with specific devices. Each device has a range of registers that can be accessed using function codes.

  1. Coil Addresses (0xxxx): These addresses are used for binary data types, such as on/off states. For example, Coil Address 00001 might represent the state of a particular switch.
  2. Input Addresses (1xxxx): Input addresses are also used for binary data types, typically representing the status of inputs. Input Address 10001 might indicate the state of a sensor.
  3. Holding Registers (4xxxx): Holding registers are used for integer and floating-point data types. For instance, Holding Register 40001 might store a temperature value.
  4. Input Registers (3xxxx): Input registers, like holding registers, are used for integer and floating-point data but typically represent read-only values. Input Register 30001 might hold a voltage reading.
Modbus Error Handling:

Modbus provides basic error-checking mechanisms, such as CRC or LRC checksums, to ensure data integrity during transmission.

  1. CRC (Cyclic Redundancy Check):
    • CRC is a widely used error-checking technique that calculates a checksum based on the contents of the data being transmitted.
    • In Modbus, CRC is applied to the entire message, including the slave address, function code, data, and any additional fields.
    • The CRC calculation generates a unique checksum value that is appended to the end of the message.
    • When the receiver receives the message, it also calculates the CRC checksum based on the received data.
    • If the calculated CRC checksum at the receiver matches the one sent by the sender, it indicates that the data was likely transmitted without errors.
    • If there is a mismatch between the calculated and received CRC checksums, it suggests that an error occurred during transmission, and the receiver requests retransmission of the message.
  2. LRC (Longitudinal Redundancy Check):
    • LRC is a simpler error-checking method compared to CRC.
    • In Modbus, LRC is applied to individual bytes within the message.
    • As each byte is transmitted, its value is added to a running sum.
    • The LRC checksum is calculated as the two’s complement of the sum of all transmitted bytes.
    • The LRC checksum byte is then appended to the end of the message.
    • When the receiver receives the message, it calculates its own LRC checksum based on the received bytes.
    • If the calculated LRC checksum at the receiver matches the one sent by the sender, it suggests that the data was likely transmitted without errors.
    • If there is a mismatch between the calculated and received LRC checksums, it indicates a potential error in the transmission.
Modbus Speed and Compatibility:

Modbus RTU and Modbus ASCII are well-suited for applications where low-speed, serial communication is sufficient. They are compatible with various hardware and software platforms.

Modbus TCP/IP:

Modbus/TCP extends Modbus to Ethernet networks, offering higher data rates and improved integration with modern industrial systems. It utilizes standard Ethernet hardware and IP addressing.

Security Considerations:

Modbus, especially the serial variants, lacks robust security features by default. When used over public networks like the internet, additional security measures should be implemented to protect against unauthorized access and data tampering.

Application Areas:

Modbus is commonly used in supervisory control and data acquisition (SCADA) systems, programmable logic controllers (PLCs), and various industrial automation applications for monitoring and controlling devices like sensors, actuators, and motors.

Modbus is a versatile and widely adopted protocol for industrial automation due to its simplicity, reliability, and compatibility with a wide range of devices. Engineers often use Modbus variants based on their specific application requirements and the choice between serial or Ethernet communication. However, it’s essential to consider security measures when using Modbus over open networks to protect sensitive industrial systems.

Source

Related Story

Comparing Eight Different Types of Servo Motors to Stepper Motors

While servo motors are often chosen as a high-performance alternative to stepper motors, their variety and specialized applications are less commonly understood. This article aims to explain the differences between the types of servo motors, enhancing your understanding of when and why to use each type.

Related Articles



Editor’s Pick: Featured Article

Weidmüller’s u-control 2000: The Automation Controller

Weidmüller’s u-control 2000: The Automation Controller

Weidmüller’s scalable engineering software, u-control 2000, adapts individually to your requirements. And, the u-control is powerful, compact and fully compatible with Weidmüller’s I/O system u-remote. This article looks at what makes u-control the heart of your automation.

Programmable logic controllers (PLCs) are one of the main components of any automated system. A typical control system has inputs, outputs, controllers (i.e., PLCs), and some type of human interaction with the system, a human machine interface (HMI), for example.

Read More



Latest Articles

  • The Drive Towards Energy-Efficient Data Centres

    April 17, 2024 By Shahrukh Ashhar Data centres are the backbone of our digital world. They serve as the foundation for various online activities like streaming, e-commerce, and website/app usage. In today’s tech-driven world, our attention is actively captured by our online activities, all of which heavily depend on data centres. The demand for storage… Read More…

  • ABB’s Expansion Joint System Helps Expand Sustainable Transportation Possibilities

    How two feet is helping connect Canada’s new automated light rail transit network April 17, 2024 Engineering ingenuity for robust infrastructure ABB is proud to have designed and produced the expansion joint system used on the Champlain Bridge section of the REM, Montreal. Canada is considered to have one of the best developed infrastructures in… Read More…