Compatibility design of distributed system communication network based on Modbus protocol and PLC devices

Publisher:DreamyMoonLatest update time:2024-03-29 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Introduction

The rapid development of modern industry has continuously promoted the rapid innovation of automatic control technology and equipment. At present, DCS, IPC, PLC and intelligent instruments have been widely used in factory on-site production control systems, and have developed into distributed industrial automatic control systems in which the above-mentioned equipment cooperate with each other and face the entire production process together. In this system, field communication technology is the key. However, due to the lack of a unified communication protocol standard at the beginning, the communication protocols of automatic control products of various manufacturers are independent, and the communication networks are each a system, which makes it difficult or even impossible to connect the network of automatic control equipment from different manufacturers, causing inconvenience to the flexible application of distributed control systems. In order to adapt to the market, some companies have made their own protocol standards public and can be used free of charge. After years of development, some communication protocols, such as Modicon's Modbus communication protocol, have been widely used in the industrial field due to their compatibility and ease of use, and have become a universal industrial communication standard. This article introduces the application of the communication network based on the Modbus protocol in the design of a distributed control system for a chemical fiber project.


2. System composition

1. System structure

The system structure is shown in Figure 1, in which the acquisition and control of field instrument signals are omitted. The system host computer uses Yokogawa CS3000 DCS distributed control system to centrally monitor the entire production process; the lower computer uses Omron's CS1H series PLC, which is distributed in 3 electrical control rooms and is responsible for the execution of field motors, OCV valves, flow switches, inverters, start and stop control of detection mechanisms, feedback signal acquisition, fault judgment and other operations.

wKgaomUOmZSAEP2BAABBNUlKPXE454.png

Considering the real-time communication, the DCS and the three PLC control stations are divided into two relatively independent communication networks: PLC1 and PLC2 form network 1 with one port of DCS, and PLC3 forms network 2 with two ports of DCS. Since neither the upper nor the lower computer has communication equipment for the same protocol, it is difficult to design. After consideration, it is decided to use the Modbus communication protocol to form the communication network of this distributed control system.

2. Communication network composition

2.1 Communication Protocol

Modbus protocol is a master-slave serial communication protocol suitable for the field of industrial control. It uses query communication to transmit information between master and slave devices, and can address the device address range of 1-247. The protocol includes two methods: broadcast query and single device query. The difference between the two is that broadcast query does not require the slave device to respond to the information. The master-slave device query communication process is shown in Figure 2.

wKgZomUOmZ-ADVJnAABkBj0t3-I557.png

Modbus protocol has two transmission modes: ASCII mode and RTU mode. At the same baud rate, RTU mode can transmit more data than ASCII mode, so most industrial networks use RTU mode. The information transmission message format in RTU mode is shown in Figure 3.

wKgZomUOmamAcxCuAAAxz850rcE112.png

It has no start bit and stop bit, but uses at least 3.5 character intervals as the start and end marks of the information. All character bits of the information frame are composed of hexadecimal characters 0-9 and AF. This design adopts the RTU mode communication method of single device query. According to the system structure, the DCS port one is set to two PLC slave addresses 01H and 02H, and the second port is set to a PLC slave address 01H, and the two function codes of the read word storage area 03H and the write word storage area 06H in the Modbus protocol are used.

2.2 Network composition and hardware introduction

The network uses RS485 serial interface, and the communication media is connected by 4-core shielded cable to connect the master and slave devices. The transmission distance is up to 1.5Km, full-duplex, and the serial port is set to a baud rate of 19200, 8 data bits, even parity, and 1 stop bit. The DCS communication part uses Yokogawa's communication module model ALR121, and is equipped with the Modbus communication software package provided by Yokogawa. The communication data capacity of this communication module is 4000 words. The PLC communication part uses Omron's C200H-ASCII 21 programmable special unit module (hereinafter referred to as ASCII module). This module supports BASIC language programming, has a 200K-byte program storage area, and is equipped with one RS232 and one RS485 communication serial port. By programming this module, various communications with peripheral devices can be realized. This system communicates with DCS based on the Modbus protocol through the ASCII module, converts the DCS's read and write instructions and data accordingly, and exchanges data with the PLC's CPU unit to achieve real-time transmission of upper and lower computer control information. As shown in Figure 4.

wKgZomUOmbCAOkHdAAA_j53dpqI968.png

3. Software Implementation

1. Establish address allocation and correspondence table

The monitoring of graphic symbol objects for field instruments on the DCS human-machine monitoring interface (HMI) needs to be achieved by collecting field instrument signals through the DCS I/O physical address. The DCS monitoring of field electrical execution and detection mechanisms is completed by the one-to-one correspondence between the DCS communication I/O address and the PLC I/O physical address. For this reason, before programming, it is necessary to establish a distribution and correspondence table of DCS communication I/O addresses and PLC I/O addresses. Due to the needs of PLC logic control programming, it is inconvenient to directly correspond the PLC I/O physical address to the DCS communication I/O address, so an indirect address method is adopted. The specific design uses the PLC data storage area DM area as the indirect address area, establishes a connection with the DCS communication I/O area, and then corresponds the DM area to the PLC I/O area. If the DCS %WB000101 communication I/O address is matched with the D0000.00 address, and D0000.00 is compared with the PLC I0000.00 physical input point, the operating status of the on-site electrical actuator can be fed back to the HMI. According to this method, a table of upper and lower computer address allocation and correspondence is established, but due to space limitations, the table is omitted.

2. Programming

The ASCII module supports BASIC language programming. In addition, it has added a number of system and function instructions, such as receive and send buffer operation instructions, information transmission error control CRC, LRC check function instructions, and read and write instructions for data exchange with the CPU unit. Programming uses the Hyperterminal software attached to the WINDOWS operating system. Through this software, the PC can transmit and display text files with other PCs or serial terminal devices connected to the network. When programming, connect the PC serial port to the RS232 serial port of the ASCII module, run the software, and you can program, upload, and debug the ASCII module on its interface. You can also write the program through the WINDOWS system's writing board first, save it in text format, and then transfer the program to the ASCII module through Hyperterminal. The main workflow of the communication program is shown in Figure 5.

wKgaomUOmbaAE1l6AADKYckZm8Y203.png

Some program codes are as follows:

OPTION BASE 0 //Define array

DIM R(128), FC(128)

R(48)=0:R(49)=1:R(50)=2:R(51)=3:R(52)=4:R(53)=5:R(54)=6:R (55)=7:R(56)=8

R(57)=9:R(65)=&h0a:R(66)=&h0b:R(67)=&h0c:R(68)=&h0d:R(69)=&h0e:R(70)=&h0f

R(97)=&h0a:R(98)=&h0b:R(99)=&h0c:R(100)=&h0d:R(101)=&h0e:R(102)=&h0f

OPEN #2, "COMU:19200, 8, E, 1" //Set serial port parameters

A%=LOC(2) //Judge the characters in the receiving buffer

IF A%=8 THEN

REX$=INPUT$(A%,#2)

……….

ENDIF

GOSUB *ZFCL //Decompose the information

IF ST=1 THEN *JAOY ELSE *BACK //Judge whether it is the information of this station

*JAOY

GOSUB *CRC //CRC cyclic redundancy check subroutine

IF R=CRC THEN *WORK ELSE *BACK //Information verification is correct

*WORK

IF (FU=3) THEN GOTO *DJS //Read the function code to judge and call the operation subroutine

IF (FU=6) THEN GOTO *XJS ELSE GOTO *BACK //Write function code judgment, call the operation subroutine

*DJS //Read subroutine

………

*XJS //Write subroutine

………

*CRC //CRC check subroutine

……….

*ZFCL //Character processing subroutine

………

Since the ASCII module supports ASCII code, and RTU is a hexadecimal character communication method based on binary code, a code conversion program is added to the program programming.

CH5$=MID$(REX$,5,1) :CH6$=MID$(REX$,6,1) //Extract character segment

VOL=ASC(CH5$)×256+ASC(CH6$) //Convert ASCII code characters to decimal numbers

VOL$=HEX$(VOL) //Convert decimal numbers into hexadecimal characters

3. Program optimization and safety measures

In the data exchange program between the ASCII module and the CPU unit, the ASCII module actively sends a read/write request signal to the CPU unit, and the CPU unit executes the data exchange program only when it receives the request. In this way, the PLC scan cycle is shortened and the real-time communication is improved.

In the information error control part, the CRC-16 cyclic redundancy check algorithm is used, which can reduce the information error rate to less than 10-14. If the information check error occurs, the program will clear the buffer and wait for the DCS information to be resent.

[1] [2]
Reference address:Compatibility design of distributed system communication network based on Modbus protocol and PLC devices

Previous article:EtherCAT to Modbus Gateway Using Modbus Slave to Simulate Slave Station Configuration Example
Next article:Design of polyester processing and drawing machine system using Siemens touch screen, PLC and inverter

Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号