CN112231260B - Preemptive multi-master RS485 bus communication method based on dynamic priority - Google Patents

Preemptive multi-master RS485 bus communication method based on dynamic priority Download PDF

Info

Publication number
CN112231260B
CN112231260B CN202011142100.XA CN202011142100A CN112231260B CN 112231260 B CN112231260 B CN 112231260B CN 202011142100 A CN202011142100 A CN 202011142100A CN 112231260 B CN112231260 B CN 112231260B
Authority
CN
China
Prior art keywords
bus
priority
frame
node
sending
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011142100.XA
Other languages
Chinese (zh)
Other versions
CN112231260A (en
Inventor
周德胜
梁光清
孙世岭
于庆
李涛
柏思忠
赵庆川
张远征
蒋洪庆
苟怡
刘芬
但强
王博文
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CCTEG Chongqing Research Institute Co Ltd
Original Assignee
CCTEG Chongqing Research Institute Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CCTEG Chongqing Research Institute Co Ltd filed Critical CCTEG Chongqing Research Institute Co Ltd
Priority to CN202011142100.XA priority Critical patent/CN112231260B/en
Publication of CN112231260A publication Critical patent/CN112231260A/en
Application granted granted Critical
Publication of CN112231260B publication Critical patent/CN112231260B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/40Bus structure
    • G06F13/4004Coupling between buses
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0002Serial port, e.g. RS232C

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention relates to a preemptive multi-master RS485 bus communication method based on dynamic priority, belonging to the field of coal mine safety monitoring and control and comprising the following steps: s1: the bus is in a half-duplex mode, is connected with a plurality of nodes with the same frame format, and can monitor the bus while occupying the bus to send data; s2: all nodes are 'master devices', and have unique ID numbers and variable bus use priorities; s3: before sending data, the node firstly monitors the state of a bus, and if the bus is busy, the priority of the frame is compared; s4: the node monitors data on the bus when sending the data, and stops sending immediately and delays sending if the frame on the bus is inconsistent with the frame sent by the node; s5: after the frame which is being sent by the communication node is preempted, the node adjusts the priority of the next sending according to a priority dynamic adjustment algorithm. The invention improves the number of the bus nodes and fully improves the bus use efficiency.

Description

Preemptive multi-master RS485 bus communication method based on dynamic priority
Technical Field
The invention belongs to the field of coal mine safety monitoring and control, and relates to a preemptive multi-master RS485 bus communication method based on dynamic priority.
Background
At present, a coal mine safety monitoring system basically realizes digital upgrading and transformation, and a sensing layer, a transmission layer and application layer equipment all adopt digital transmission. In the coal mine safety monitoring system, general technical requirements of AQ 6201 and 2019 coal mine safety monitoring system 5.7.5 definitely require that the local control execution time is not more than 2 s. The communication time among the sensors, controllers and actuators in the sensing layer in the monitoring system is required to be less than 2s, currently, the sensing layer in digital communication mostly adopts a two-wire (half-duplex) "master-slave" RS485 bus, and all the sensors, controllers and actuators on the bus are managed and communicated by a unique bus controller (monitoring substation). The substation generally polls and calls other nodes according to addresses, and any two nodes outside the substation need to occupy the bus at least for 2 times after completing information interaction once, so that the effective utilization rate of the bus is greatly limited, and the number of bus loading nodes at a given communication rate is limited.
Disclosure of Invention
In view of this, the present invention aims to provide a preemptive multi-master RS485 bus communication method based on dynamic priority, which solves the problems of low bus utilization rate, limited device number, and long control response time.
In order to achieve the purpose, the invention provides the following technical scheme:
a preemptive multi-master RS485 bus communication method based on dynamic priority comprises the following steps:
s1: the bus is in a half-duplex mode and is connected with a plurality of communication nodes, all the communication nodes adopt the same frame format, and all the communication nodes can monitor the bus while occupying the bus to send data;
s2: all communication nodes are 'master devices', and have unique ID numbers and variable bus use priorities; the priorities of different communication nodes can be the same, and the nodes with high priorities can seize the bus at any time;
s3: the method comprises the steps that a communication node monitors the state of a bus before sending data, immediately sends the data if the bus is idle, compares the priority of a frame which is transmitted on the bus with the priority of a frame which needs to be sent currently if the bus is busy, waits for the bus to be idle and then sends the frame if the priority of the frame is high, and otherwise immediately seizes the bus;
s4: the communication node monitors data on the bus while sending the data, stops sending immediately if a frame on the bus is inconsistent with a frame sent by the node, calculates the data time for starting sending next time by the node according to a delay avoidance algorithm, and delays the sending;
s5: after the frame being sent by the communication node is preempted, the node adjusts the priority of the next sending according to a priority dynamic adjustment algorithm.
Further, in step S2, all communication nodes adopt a uniform frame format and the first byte of the frame is the device ID and the second byte is the frame priority.
Further, in step S3, the communication node preempts the bus by sending a byte 0xFF to interfere with the bus.
Further, the formula of the delay avoidance algorithm in step S4 is as follows:
t=(a×id+b×l)t 0
wherein a and b are weight factors, and the range is (0-1); ID is a node ID; l is the priority; t is t 0 The time required to transfer one byte for the bus.
Further, in step S5, the formula of the priority dynamic adjustment algorithm is as follows:
l k+1 =α×k+l k
wherein alpha is a regulating factor, and the regulating factors of different communication nodes are not completely the same; k is preemptedNumber of times, k ═ 0, l k The kth transmission priority.
The invention has the beneficial effects that: the invention provides a preemptive multi-master RS485 bus communication method based on dynamic priority, aiming at the problems of low utilization rate of master-slave RS485 communication buses, limited equipment quantity, long control response time and the like of a sensing layer of a coal mine safety monitoring communication system, so that the number of transmission frames required by information interaction between any nodes on the buses is reduced, the general technical requirements of the coal mine safety monitoring system are met, the number of bus nodes is increased to the maximum extent, and the use efficiency of the buses is fully improved.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objectives and other advantages of the invention may be realized and attained by the means of the instrumentalities and combinations particularly pointed out hereinafter.
Drawings
For the purposes of promoting a better understanding of the objects, aspects and advantages of the invention, reference will now be made to the following detailed description taken in conjunction with the accompanying drawings in which:
FIG. 1 is a schematic diagram of a preemptive multi-master RS485 bus communication structure based on dynamic priority according to the present invention;
FIG. 2 is a 485 bus frame format diagram of the present invention;
fig. 3 is a flow chart of frame transmission according to the present invention.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It should be noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention in a schematic way, and the features in the following embodiments and examples may be combined with each other without conflict.
Wherein the showings are for the purpose of illustrating the invention only and not for the purpose of limiting the same, and in which there is shown by way of illustration only and not in the drawings in which there is no intention to limit the invention thereto; to better illustrate the embodiments of the present invention, some parts of the drawings may be omitted, enlarged or reduced, and do not represent the size of an actual product; it will be understood by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The same or similar reference numerals in the drawings of the embodiments of the present invention correspond to the same or similar components; in the description of the present invention, it should be understood that if there is an orientation or positional relationship indicated by terms such as "upper", "lower", "left", "right", "front", "rear", etc., based on the orientation or positional relationship shown in the drawings, it is only for convenience of description and simplification of description, but it is not an indication or suggestion that the referred device or element must have a specific orientation, be constructed in a specific orientation, and be operated, and therefore, the terms describing the positional relationship in the drawings are only used for illustrative purposes, and are not to be construed as limiting the present invention, and the specific meaning of the terms may be understood by those skilled in the art according to specific situations.
As shown in fig. 1, 2 and 3, the method of the present embodiment includes:
a. the bus is in a half-duplex mode and comprises a plurality of communication nodes, all the nodes adopt the same frame format and have the function of occupying the bus to send data and monitoring the bus at the same time.
b. All communication nodes are 'master devices', and have unique ID numbers and variable bus use priorities; the priorities of different nodes can be the same, and the nodes with high priorities can preempt the bus at any time.
c. When all communication nodes need to send data, the bus state is firstly monitored, if the bus is free, the data is immediately sent, if the bus is busy, the priority of a frame which is being transmitted on the bus is compared with the priority of a frame which needs to be sent, if the priority of the frame is high, the frame is sent after waiting for the bus to be free, and if the priority of the frame is not high, the bus is immediately preempted.
d. All communication nodes monitor the data on the bus while sending the data, if the frame on the bus is inconsistent with the frame sent by the node, the sending is stopped immediately, the data time for starting the sending of the node next time is calculated according to a delay avoidance formula, and the sending is delayed.
e. After the frame being sent by the communication node is preempted, the node adjusts the priority of the next sending according to a priority dynamic adjustment algorithm.
In this embodiment, the plurality of communication nodes are electrically connected correctly in step a to form an RS485 half-duplex communication network system.
B, respectively setting different IDs on all nodes on the bus, and giving frame initial priorities to different types of nodes according to actual requirements, wherein the priorities can be the same or different;
and c, when the node sends data, if the frame is sent for the first time, if the bus is idle, the data is sent immediately, if the bus is busy, the priority of the frame which is being transmitted on the bus is compared with the priority of the frame which needs to be sent at present, if the priority of the frame is high, the frame is sent after waiting for the bus to be idle, otherwise, the bus is immediately preempted.
D, when the node monitors that the frame on the bus is not consistent with the frame sent by the node while sending data, the node immediately stops sending, and the sending is stopped according to t ═ a × id + b × l) t 0 And calculating the data time of the next starting transmission of the node by using the formula, and delaying the transmission.
E, after the node is preempted in the frame sending process, the node sets the formula t as (a × id + b × l) t 0 The priority of the next transmission is adjusted.
Any node in this embodiment keeps listening to the bus state in real time.
In this embodiment, the node ID is a unique identifier for identifying a node on a bus, and the node ID cannot be duplicated in the same bus system.
In this embodiment, if a plurality of different nodes with the same priority seize the bus at the same time, according to the delay formula t ═ a × id + b × l) t 0 The calculated bus avoidance times are differentAvoiding the conflict again in the next sending process and reducing the conflict overhead of the bus.
In the embodiment, the priority of the nodes is dynamically adjusted, the priority with high priority obtains the use right of the bus, so that the real-time performance of the key data is ensured, meanwhile, the priority of the nodes with low priority is improved after being preempted for many times, the use right of the bus can still be obtained, and the fairness among the nodes is ensured.
The following examples are given in detail with two specific values:
in the embodiment, when designing the bus interface circuit, the 485 communication module adopts 2 SN65LBC184 chips of TI corporation, which are respectively marked as chip 1 and chip 2, A, B pins of chips 1 and 2 are respectively connected, chip 1 is used as a frame transceiving interface of the module, and chip 2 is used as a monitoring interface and only receives and does not transmit. The frame format is designed as follows:
address field Priority field Data field End field
1 byte 1 byte 8 bytes 2 bytes
The modules support an address range of 1-255 with a priority range of 0 to 8, with smaller priority values specifying higher priority. In a certain field application case, 6 nodes are provided, namely sensors S1 and S2, controllers C1 and C2 and actuators M1 and M2. The sensor S1, the controller C1, and the actuator M1 form a closed-loop control system 1, the IDs are respectively set to 1, 2, and 3, and have a high real-time requirement, the other nodes form a closed-loop control system 2, and the IDs are set to 4, 5, and 6, and have a low real-time requirement. All nodes are dispersed in a coal mine tunnel with the length of 4 kilometers, and in order to ensure reliable communication, the communication speed is 4800 bps. The priority of all nodes in the control system 1 is initialized to 5, a takes the value of 0.5, b takes the value of 10, and alpha takes the value of-1; the priority of all nodes in the control system 2 is initialized to 8, a is 0.5, b is 15, and alpha is-0.5. when the bus is busy, the nodes of the control system 1 acquire higher bus use priority, the priority of all frames is dynamically increased to 0 under extreme conditions, all nodes have the same priority, but the node backoff time of the control system 1 is shorter and the transmission is limited.
Finally, the above embodiments are only intended to illustrate the technical solutions of the present invention and not to limit the present invention, and although the present invention has been described in detail with reference to the preferred embodiments, it will be understood by those skilled in the art that modifications or equivalent substitutions may be made on the technical solutions of the present invention without departing from the spirit and scope of the technical solutions, and all of them should be covered by the claims of the present invention.

Claims (3)

1. A preemptive multi-master RS485 bus communication method based on dynamic priority is characterized in that: the method comprises the following steps:
s1: the bus is in a half-duplex mode and is connected with a plurality of communication nodes, all the communication nodes adopt the same frame format, and all the communication nodes can monitor the bus while occupying the bus to send data;
s2: all communication nodes are 'master devices', and have unique ID numbers and variable bus use priorities;
s3: the method comprises the steps that a communication node monitors the state of a bus before sending data, immediately sends the data if the bus is idle, compares the priority of a frame which is transmitted on the bus with the priority of a frame which needs to be sent currently if the bus is busy, waits for the bus to be idle and then sends the frame if the priority of the frame is high, and otherwise immediately seizes the bus;
s4: the communication node monitors data on the bus while sending the data, stops sending immediately if a frame on the bus is inconsistent with a frame sent by the node, calculates the data time for starting sending next time by the node according to a delay avoidance algorithm, and delays the sending; the formula of the delay avoidance algorithm is as follows:
t=(a×id+b×l)t 0
wherein a and b are weight factors, and the range is (0-1); ID is a node ID; l is the priority; t is t 0 Time required for transferring one byte for bus
S5: after the frame being sent by the communication node is preempted, the node adjusts the priority of the next sending according to a priority dynamic adjustment algorithm; the formula of the priority dynamic adjustment algorithm is as follows:
l k+1 =α×k+l k
wherein alpha is a regulating factor, and the regulating factors of different communication nodes are not completely the same; k is the number of preempted times, k ═ 0, l k The kth transmission priority.
2. The preemptive multi-master RS485 bus communication method according to claim 1, wherein: in step S2, all communication nodes adopt a uniform frame format, and the first byte of the frame is the device ID and the second byte is the frame priority.
3. The preemptive multi-master RS485 bus communication method according to claim 1, wherein: in step S3, the communication node preempts the bus by sending a byte 0xFF to interfere with the bus.
CN202011142100.XA 2020-10-21 2020-10-21 Preemptive multi-master RS485 bus communication method based on dynamic priority Active CN112231260B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011142100.XA CN112231260B (en) 2020-10-21 2020-10-21 Preemptive multi-master RS485 bus communication method based on dynamic priority

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011142100.XA CN112231260B (en) 2020-10-21 2020-10-21 Preemptive multi-master RS485 bus communication method based on dynamic priority

Publications (2)

Publication Number Publication Date
CN112231260A CN112231260A (en) 2021-01-15
CN112231260B true CN112231260B (en) 2022-08-02

Family

ID=74110692

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011142100.XA Active CN112231260B (en) 2020-10-21 2020-10-21 Preemptive multi-master RS485 bus communication method based on dynamic priority

Country Status (1)

Country Link
CN (1) CN112231260B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115052251B (en) * 2021-03-09 2023-08-18 Oppo广东移动通信有限公司 Broadcast information transmission method, apparatus, electronic device and storage medium
CN113395187B (en) * 2021-05-27 2022-05-20 深圳市常工电子计算机有限公司 485 bus based communication enhancement method and system
CN114826812B (en) * 2022-02-18 2024-05-03 浪潮工业互联网股份有限公司 Implementation method and system for RS485 communication multi-master station
CN115191105B (en) * 2022-06-07 2024-05-17 广东逸动科技有限公司 Method and device for preempting bus, electronic equipment, control system and storage medium
CN116701009B (en) * 2022-11-21 2024-05-17 荣耀终端有限公司 Data communication method and electronic equipment
CN117872841A (en) * 2023-12-12 2024-04-12 广州里工实业有限公司 Multi-bus input/output circuit system and control method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107104867A (en) * 2017-04-24 2017-08-29 珠海格力电器股份有限公司 The communication means and master-slave system of master-slave system
CN107995128A (en) * 2017-12-11 2018-05-04 日立楼宇技术(广州)有限公司 Data access method, device, host and the storage medium of fully mechanized mining centralized control system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8107379B2 (en) * 2005-05-04 2012-01-31 Cisco Technology, Inc. Dynamic TE-LSP priority and preemption
CN101136828B (en) * 2007-09-27 2010-10-06 广州市聚晖电子科技有限公司 RS485 based multi-host machine wired serial communication method
CN101626334B (en) * 2009-08-10 2013-06-12 中兴通讯股份有限公司 Method and device for controlling communication bus
CN102546141B (en) * 2012-02-20 2015-02-18 杭州海康威视系统技术有限公司 485 bus system and asynchronous half-duplex communication method thereof
CN105677608B (en) * 2015-12-31 2019-01-04 浙江众合科技股份有限公司 A kind of how main RS485 bus arbitration method and system
CN106982156B (en) * 2017-06-08 2019-11-15 日立楼宇技术(广州)有限公司 Priority setting method, device, communication system, equipment and readable storage medium storing program for executing

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107104867A (en) * 2017-04-24 2017-08-29 珠海格力电器股份有限公司 The communication means and master-slave system of master-slave system
CN107995128A (en) * 2017-12-11 2018-05-04 日立楼宇技术(广州)有限公司 Data access method, device, host and the storage medium of fully mechanized mining centralized control system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
"Design and implementation of heterogeneous IOT gateway based on dynamic priority scheduling algorithm";Dong Min等;《Transactions of the Institute of Measurement and Control》;20141231;全文 *
"RS485总线时分复用主动传输技术在安全监控系统的应用";邵严;《自动化与仪器仪表》;20200831;全文 *

Also Published As

Publication number Publication date
CN112231260A (en) 2021-01-15

Similar Documents

Publication Publication Date Title
CN112231260B (en) Preemptive multi-master RS485 bus communication method based on dynamic priority
CN105677608B (en) A kind of how main RS485 bus arbitration method and system
CN101741766B (en) Conversion device from CAN network to ethernet network
CN108494649B (en) Bus system based on combination of polling and uniform time slot and data transmission method
US4516205A (en) Access control of data transmission network
US11233736B2 (en) Vehicle gateway and method of controlling the same
CN103257946A (en) High-speed interconnecting method of controllers of tight-coupling multi-control storage system
CN101917318A (en) High-low speed bus systems and connection device thereof
CN203590251U (en) FlexRay control system based on serial RapidIO bus
CN104301191A (en) Bus system
CN107659456A (en) A kind of data collision transmission method based on RS485 communications
US4989203A (en) Apparatus for providing multiple controller interfaces to a standard digital modem and including separate contention resolution
US20040205284A1 (en) Systems and methods for interfacing legacy equipment to high-speed data buses
EP1003108A1 (en) Apparatus and method for providing round-robin arbitration
CN107357756A (en) The system that more equipment carry out IIC communications under holotype
CN105141483A (en) Multi-node network minimum communication interval measurement method based on CAN bus
CN104834618B (en) A kind of more apparatus scanning methods and power electronic system based on RS485 bus communications
CN210518417U (en) Address allocation system
CN109067631B (en) Multi-node automobile electric control method based on real-time Ethernet communication protocol architecture
KR100900980B1 (en) Data transfer system and method for considering response delay on CAN devices
CN110519145B (en) Multi-master 485 route communication method and system based on bidirectional ring network
CN109802877A (en) A kind of CAN bus based Communication System Design
CN209627394U (en) A kind of digital signal acquiring device and system
CN202205196U (en) Serial apparatus general communication bus system
CN115314070B (en) Cascaded high-speed long-line transmission device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant