Overview of Modbus Communication – Series 17

Click Jicheng Training WeChatOverview of Modbus Communication - Series 17 Follow me!

Jicheng Training Network’s official WeChat is the most professional and concentrated in the industrial control field, providing technical sharing, free videos, and a communication platform. Follow Jicheng, and there will be no problem in improving your skills!

1. Overview

All the content that needs to be discussed regarding the free port has been covered. The basic knowledge of RS485 communication has also been organized for everyone. From this article onwards, I will specifically explain the Modbus RTU protocol in RS485 communication.

First, it is important to clarify that the Modbus RTU protocol is one of the most commonly used protocols at the RS485 hardware level in industrial control. My main goals here are twofold: first, to help everyone master the use of the S7-200 Modbus library, and second, to help everyone understand the message format of the Modbus RTU protocol.

2. Features of Modbus RTU Protocol

Let’s first familiarize ourselves with the features of the Modbus RTU protocol.

1) Modbus RTU is a master-slave, half-duplex communication protocol, where there can only be one master station in the entire network. The master station does not have an address in the Modbus RTU network, while the actual address range for slave stations is from 1 to 247.

2) The message length of the Modbus RTU protocol is variable, and the minimum interval between messages is 3.5 character transmission time lengths.

3) The checksum method of the Modbus RTU protocol is CRC checksum.

3. Modbus Library Introduction

Overview of Modbus Communication - Series 17

Figure 3-1

MBUS_CTRL Command:

EN: Enable, must be enabled every cycle (SM0.0).

Mode: Mode selection, 1 = Modbus protocol, 0 = PPI protocol.

Baud: Baud rate setting.

Parity: Character check, 0 = No check; 1 = Odd check; 2 = Even check.

Timeout: Timeout. The time the master station waits for a response from the slave station, in milliseconds, with a range of 1 to 32767.

Done: Initialization completion flag, automatically set to 1 upon completion of initialization.

Error: If initialization fails, the error code is stored.

Overview of Modbus Communication - Series 17

Figure 3-2

MBUS_MSG Command:

EN: Enable, only one read/write function can be active at the same time.

First: Read/write request, must use edge triggering.

Slave: Slave address, range 1 to 247.

RW: Read/write operation, 0 = Read, 1 = Write.

Addr: Address of the data to read/write from the slave.

Count: Number of data items (number of bits or words). Note that the maximum data quantity is 120 words.

DataPtr: The starting address of the data buffer (pointer type). If it’s a read command, the returned data will be placed in this data area; if it’s a write command, the data to be written will be placed in this data area.

Done: Read/write function completion flag. Set to 1 when the function is completed.

Error: Read/write function error code. Valid when the Done flag is 1.

3.2 Slave Commands

Overview of Modbus Communication - Series 17

Figure 3-3

MBUS_INIT Command:

EN: Initialization, executed once during the first scan (SM0.1).

Mode: Mode, 0 = PPI, 1 = Modbus.

Addr: Slave address, range 1 to 247.

Baud: Baud rate.

Parity: Odd/even check.

Delay: Additional character inter-delay.

MaxAIQ: Maximum number of I/O points participating in communication, default value for S7-200 I/O image area is 128/128.

MaxAI: Maximum number of AI channels participating in communication.

MaxHold: Number of bytes in the V storage area (VW) participating in communication.

HoldStart: Starting address of the holding register area (pointer type).

Done: Initialization completion flag.

Error: If initialization fails, the error code is stored.

Overview of Modbus Communication - Series 17

Figure 3-4

MBUS_SLAVE Command:

EN: Enable. Executed during each scan (SM0.0).

Done: Set to 1 during communication, set to 0 when not in communication.

Error: Stores error codes, 0 = No error. Author: Ma Le

Excellent 485 communication! Hurry up and share and save it!Overview of Modbus Communication - Series 17

Jicheng Training: jcpeixun The most comprehensive video tutorials and practical content.

A learning and communication platform worth following!

Overview of Modbus Communication - Series 17

National Customer Service QQ/Hotline: 4001114100Overview of Modbus Communication - Series 17

For more exciting content, click Read the original text!

Leave a Comment