CN113746712B - MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system - Google Patents

MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system Download PDF

Info

Publication number
CN113746712B
CN113746712B CN202111023352.5A CN202111023352A CN113746712B CN 113746712 B CN113746712 B CN 113746712B CN 202111023352 A CN202111023352 A CN 202111023352A CN 113746712 B CN113746712 B CN 113746712B
Authority
CN
China
Prior art keywords
station
data
calling
slave
communication
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
CN202111023352.5A
Other languages
Chinese (zh)
Other versions
CN113746712A (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.)
Lens Intelligent Robot Changsha Co Ltd
Original Assignee
Lens Intelligent Robot Changsha 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 Lens Intelligent Robot Changsha Co Ltd filed Critical Lens Intelligent Robot Changsha Co Ltd
Priority to CN202111023352.5A priority Critical patent/CN113746712B/en
Publication of CN113746712A publication Critical patent/CN113746712A/en
Application granted granted Critical
Publication of CN113746712B publication Critical patent/CN113746712B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • H04L12/40019Details regarding a bus master
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/403Bus networks with centralised control, e.g. polling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The invention provides a master multi-slave station communication method based on MODBUS_RTU protocol, which comprises the following steps: s1, a dispatching master station polls all call slave stations and acquires readback data fed back by the responding call slave stations; s2, the dispatching master station generates a broadcast frame according to a preset rule from data to be written of the calling slave station responding to the read-back data and sends the broadcast frame to the calling slave station responding to the response; s3, the responding calling slave station receives the broadcast frame and extracts corresponding data to be written in the broadcast frame according to the preset rule. Compared with the traditional polling method, the method reduces the communication period, optimizes the communication speed and improves the communication efficiency and quality.

Description

MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system
Technical Field
The invention relates to the technical field of computer communication, in particular to a master multi-slave station communication method and system based on MODBUS_RTU protocol.
Background
When an AGV (an unmanned transport vehicle equipped with an optoelectronic or magnetic navigation device, capable of traveling along a specified guide path and having safety protection and various transfer functions) schedules and uses an RS485 (communication interface) +a wireless module to communicate with a plurality of calling stations, data needs to be read and written for each station, and a master station is scheduled to sequentially perform read and write operations for each slave station by using a modbus_rtu protocol (a software communication protocol that can be used for RS485 communication) in a PLC system. The single site communication flow is as follows: scheduling and sending a read instruction; the calling site returns the read data; scheduling the sending of write data; the call station returns an acknowledgement that the write was successful, requiring 4 data frames (communication packets) per call station.
Currently, in AGV application, there are a large number of on-site calling stations (secondary stations), and the problem of station distribution and dispersion is that a lower baud rate (communication speed) must be set for ensuring stability by adopting wireless communication. Through practical tests, if 9600 baud rate is used, each data frame is calculated to be delayed in a wireless way, a single station needs about 100ms to complete 4-frame communication, if 30 call stations exist on site, each call station can take about 3 seconds to take a round of interactive data, thus the signal of the call docking device of the whole system has high control delay, and the efficiency of the docking action system of the AGV and the device is seriously slowed down.
Therefore, providing a method and a system for communication between a master station and a slave station based on the modbus_rtu protocol, which can effectively save communication time and improve communication efficiency, is a problem to be solved by those skilled in the art.
Disclosure of Invention
The invention aims to provide a master-multiple-slave station communication method and system based on MODBUS_RTU protocol, which have clear logic, safety, effectiveness, reliability and simple and convenient operation, and can effectively optimize communication speed and improve communication efficiency and quality.
Based on the above purpose, the technical scheme provided by the invention is as follows:
a master multi-slave station communication method based on MODBUS_RTU protocol includes the following steps:
s1, a dispatching master station polls all call slave stations and acquires readback data fed back by the responding call slave stations;
s2, the dispatching master station generates a broadcast frame according to a preset rule from data to be written of the calling slave station responding to the read-back data and sends the broadcast frame to the calling slave station responding to the response;
s3, the responding calling slave station receives the broadcast frame and extracts corresponding data to be written in the broadcast frame according to the preset rule.
Preferably, the preset rule in step S2 is specifically:
the data to be written of each calling slave station corresponds to the offset address in the broadcast frame one by one.
Preferably, the method comprises the steps of,
if the length of the data to be written of the calling slave station is larger than the length of the broadcast frame, writing the data to be written of the calling slave station into N broadcast frames;
the N value is specifically a quotient of the length of data to be written of the calling secondary station divided by the length of the broadcast frame plus 1.
Preferably, before step S1, the method further includes:
A1. setting the communication parameters of the dispatching master station and the communication parameters of the calling slave station, wherein the communication parameters of the dispatching master station and the communication parameters of the calling slave station are the same parameters;
A2. and setting a communication rule between the dispatching master station and the calling slave station according to the communication parameters.
Preferably, the communication rule specifically includes:
a first controller and a second controller are arranged in the dispatching master station;
the first controller reserves a continuous register;
the second controller establishes a byte array to accept the data packet.
Preferably, the communication rule further includes:
and presetting idle delay time after each broadcast frame is sent.
Preferably, after step S3, further comprising:
testing the dispatching master station to perform read-write operation on all call slave stations;
detecting whether the read-back data in the scheduling master station is the same as the read-back data in the responding call slave station;
and detecting whether the data to be written of the calling slave station responding in the dispatching master station is the same as the data written of the calling slave station responding in the dispatching master station.
A modbus_rtu protocol-based one master-multiple-slave communication system, comprising:
the polling module is used for realizing the polling of the dispatching master station to all calling slave stations;
the response module is used for enabling the calling slave station to respond to the polling request of the dispatching master station and feeding back read data;
the acquisition module is used for acquiring readback data fed back by the responding calling slave station;
the generation module is used for realizing that the scheduling master station generates and transmits a broadcast frame;
a broadcasting module, configured to implement broadcasting by the scheduling master station to the responding call slave station;
the first rule module is used for setting rules for generating the broadcast frames according to the data to be written of the calling secondary station;
and the extraction module is used for extracting the data to be written corresponding to the broadcast frame.
Preferably, the method further comprises:
the parameter setting module is used for setting the communication parameters of the dispatching master station and the communication parameters of the calling slave station;
the second rule module is used for setting a communication rule between the dispatching master station and the calling slave station;
the time module is used for presetting idle delay time after the completion of the transmission of each broadcast frame;
the test module is used for testing the dispatching master station to perform read-write operation on all call slave stations;
and the detection module is used for detecting whether the data between the dispatching master station and the calling slave station are the same.
Preferably, the method further comprises: AGVs;
the AGV is used for realizing data interaction between the dispatching master station and the calling slave station.
The invention provides a master-multi-slave station communication method based on MODBUS_RTU protocol, which is to poll all call slave stations through a dispatching master station so as to obtain readback data fed back by the responding call slave stations; the scheduling master station generates a broadcast frame according to the acquired readback data and the substitution data of the responding calling slave station and sends the broadcast frame to the responding preset slave station according to a preset rule; and after receiving the broadcast frame, the responding preset slave station extracts the corresponding data to be written in the broadcast frame according to the same preset rule, so as to realize data interaction.
In the actual application process, the invention acquires the readback data fed back by the responding calling slave station by one-time polling, then generates a broadcast frame according to the readback data, broadcasts the broadcast frame to the responding calling slave station, and the corresponding calling slave station extracts the data to be written in the broadcast frame according to the same rule. Compared with the traditional polling scheduling method, the communication method of the master station and the multiple slave stations based on the MODBUS_RTU protocol reduces the communication period, optimizes the communication speed and improves the communication efficiency and the communication quality.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a method for communication between a master station and a slave station based on a MODBUS_RTU protocol according to an embodiment of the present invention;
FIG. 2 is a flowchart before step S1 in a method for communication between a master station and a plurality of slave stations based on a MODBUS_RTU protocol according to an embodiment of the present invention;
FIG. 3 is a flowchart after step S3 in a method for communication between a master station and a plurality of slave stations based on a MODBUS_RTU protocol according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a master multi-slave communication system based on modbus_rtu protocol according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The embodiment of the invention is written in a progressive manner.
The embodiment of the invention provides a master-multiple-slave station communication method and system based on MODBUS_RTU protocol. The method mainly solves the technical problems of low communication efficiency and quality caused by long communication period and low communication speed of the traditional polling scheduling method in the prior art.
Referring to fig. 1, a method for communication between a master station and a plurality of slave stations based on modbus_rtu protocol includes the following steps:
s1, a dispatching master station polls all call slave stations and acquires readback data fed back by the responding call slave stations;
s2, the dispatching master station generates a broadcast frame according to preset rules from the data to be written of the call slave station and sends the broadcast frame to the call slave station;
s3, receiving the broadcast frame by the responding calling slave station, and extracting corresponding data to be written in the broadcast frame according to a preset rule.
In step S1, the scheduling master station polls the calling slave station, thereby acquiring readback data fed back by the responding calling slave station.
It should be noted that, polling refers to that a communication master station sequentially performs data interaction with a plurality of slave stations in a communication network. I.e. the dispatch master station sends an inquiry request to the calling slaves in turn, and if there are unresponsive calling slaves in it, skips the slaves and sends an inquiry request to the next calling slaves. In this embodiment, the interrogation request is to perform a read register operation.
In step S2, the dispatching master station generates a broadcast frame according to the read-back data and the data to be written of the call slave station which is responded according to the preset rule, and sends the broadcast frame to the call slave station which is responded.
It should be noted that, generating a broadcast frame and transmitting the broadcast frame is essentially broadcasting, where broadcasting refers to that a communication node in a communication network transmits data, and all other nodes can receive the data. In this embodiment, the content of the broadcast frame is a write register operation.
In step S3, after receiving the broadcast frame, the responding calling slave station extracts the corresponding data to be written in the broadcast frame according to the preset rule.
It should be noted that, the preset rule in step S3 is the same as the preset rule in step S2, and the corresponding data to be written may be extracted from the responding call slave station by the same preset rule. In this embodiment, after the call slave station receives the data, each station receives the same data because of the broadcast write data, and then obtains the required data according to its own slave station address offset.
In the actual application process, the invention acquires the readback data fed back by the responding calling slave station by one-time polling, then generates a broadcast frame according to the readback data, broadcasts the broadcast frame to the responding calling slave station, and the corresponding calling slave station extracts the data to be written in the broadcast frame according to the same rule. Compared with the traditional polling scheduling method, the communication method of the master station and the multiple slave stations based on the MODBUS_RTU protocol reduces the communication period, optimizes the communication speed and improves the communication efficiency and the communication quality.
Preferably, the preset rule in step S2 is specifically:
the data to be written of each calling slave station corresponds to the offset address in the broadcast frame one by one.
In the actual application process, each different calling slave station corresponds to different offset addresses in the broadcast write data frame of the data to be written of each different calling slave station. In this embodiment, if 10 slave stations from #1 to #10 write one word data per slave station, a write command should be used to write 00 stations, the data length is 10 words, the data to be written by the slave station 1 corresponds to the first data of the broadcast frame, the data to be written by the slave station 2 corresponds to the second data of the broadcast frame, and so on.
It should be noted that, the extraction rule in step S3 is also the same as the preset rule. In this embodiment, the scheduling master broadcasts writing 10 word data to the 10 call slave registers D0-D9, #1 call stations extract D0 register data as effective communication data, #2 call stations extract D1 register data as effective communication data, and so on #10 call stations extract D9 data as effective data.
Preferably, the method comprises the steps of,
if the length of the data to be written of the calling slave station is larger than the length of the broadcast frames, writing the data to be written of the calling slave station into N broadcast frames;
the N value is specifically a quotient of the length of data to be written of the calling secondary station divided by the length of the broadcast frame plus 1.
In the actual application process, if the length of the data to be written of the calling slave station is greater than the length of the broadcast frames, the data to be written of the calling slave station is written into N broadcast frames. In this embodiment, the broadcast write maximum length is 16 words (32 bytes, 1 byte 8 bits), i.e., the broadcast frame length is 32 bytes, and a call slave station exceeding this length needs to allocate a plurality of broadcast frames to write data. For example, to-be-written data of 60 bytes in length of the calling slave station a, two broadcast frames are required; three broadcast frames are required to call the 70 byte length of data to be written from station B.
Referring to fig. 2, before step S1, the method further includes:
A1. setting communication parameters of a dispatching master station and communication parameters of a calling slave station, wherein the communication parameters of the dispatching master station and the communication parameters of the calling slave station are the same parameters;
A2. and setting a communication rule between the dispatching master station and the calling slave station according to the communication parameters.
In step A1, communication parameters of the dispatch master station and the call slave station are set, and the communication parameters of the dispatch master station and the call slave station are the same, so that data interaction is performed between the dispatch master station and the call slave station. At the same time, an address is assigned to the calling secondary station. In this embodiment, the call secondary is set to a continuous address.
In step A2, according to the communication parameters, a communication rule between the dispatch master station and the call slave station is set. In this embodiment, the calling secondary station needs to reserve enough broadcast write addresses, i.e. how many secondary stations need to leave how many word length addresses.
Preferably, the communication rule is specifically:
a first controller and a second controller are arranged in the dispatching master station;
the first controller reserves a continuous register;
the second controller establishes a byte array to accept the data packet.
In the actual application process, the first controller is a PLC, and the second controller is a singlechip. The PLC reserves a continuous register for broadcasting writing, and the singlechip is required to establish a byte array as a broadcasting receiving BUF (data packet).
It should be noted that PLC refers to a programmable logic controller, which uses a type of programmable memory for storing programs therein, executing instructions for users, such as logic operations, sequence control, timing, counting, and arithmetic operations, and controlling various types of machines or production processes through digital or analog input/output.
The singlechip (Microcontrollers) is an integrated circuit chip, and is a small and perfect microcomputer system formed by integrating functions (possibly including a display driving circuit, a pulse width modulation circuit, an analog multiplexer, an A/D converter and the like) such as a central processing unit CPU, a random access memory RAM, a read-only memory ROM, various I/O ports, an interrupt system, a timer/counter and the like with a silicon chip by adopting a very large scale integrated circuit technology, and is widely applied to the field of industrial control.
A register refers to a very important memory cell in an integrated circuit, typically consisting of flip-flops. In integrated circuit designs, registers can be divided into two types, registers used internally in the circuit and registers that act as internal and external interfaces. The internal registers are not accessible by external circuitry or software, but simply store functions for implementation of the internal circuitry or meet timing requirements of the circuitry. The interface register can be accessed by the internal circuit and the external circuit or software at the same time, and the register in the CPU is one of the registers, and is known as an interface of software and hardware by a wide range of general programming users. In the computer field, registers are elements internal to the CPU, including general purpose registers, special purpose registers, and control registers. Registers have very high read and write speeds, so data transfer between registers is very fast.
Preferably, the communication rule further includes:
and presetting idle delay time after each broadcast frame is sent.
In the practical application process, an idle delay time is reserved after each write broadcast frame of the dispatching station is sent, the next communication operation is started after the delay time is up, the delay time is determined according to the length of the broadcast frame and the baud rate, and a certain margin is needed to be reserved for the wireless communication delay.
Referring to fig. 3, preferably, after step S3, the method further includes:
B1. the test dispatching master station performs read-write operation on all call slave stations;
B21. detecting whether the read-back data in the dispatching master station is the same as the read-back data in the responding calling slave station;
B22. and detecting whether the data to be written of the call slave station responding in the dispatching master station is the same as the data written of the call slave station responding in the dispatching master station.
In the practical application process, whether the dispatching master station can perform read-write operation on all the calling slave stations or not is tested, if the read-write operation is successfully completed, whether the read-back data and the read-out data in the dispatching master station and the calling slave stations are identical or not is detected, and the data to be written is identical to the data to be written.
Referring to fig. 4, a master multi-slave communication system based on modbus_rtu protocol includes:
the polling module is used for realizing the polling of the scheduling master station to all call slave stations;
the response module is used for enabling the calling secondary station to respond to the polling request of the dispatching master station and feeding back read data;
the acquisition module is used for acquiring readback data fed back by the responding calling slave station;
the generation module is used for realizing that the scheduling master station generates and transmits a broadcast frame;
the broadcasting module is used for realizing the broadcasting of the scheduling master station to the responding calling slave stations;
the first rule module is used for setting rules of generating broadcast frames according to data to be written of the calling secondary station;
and the extraction module is used for extracting the data to be written corresponding to the broadcast frame.
In the actual application process, the dispatching master station polls all calling slave stations through a polling module; the call slave station responds to the polling operation through a response module and feeds back read data to the scheduling master station; after the dispatching master station obtains the read-back data through the obtaining module, the generating module generates a broadcast frame according to the read-back data and the data to be written of the calling slave station, and broadcasts the broadcast frame to the responding calling slave station through the broadcasting module; the generation module is connected with the first rule module, and the scheduling master station sets rules in the first rule module to realize the operation of generating the broadcast frame; the calling slave station extracts the corresponding data to be written in the broadcast frame through the extraction module.
Referring to fig. 4, preferably, the method further includes:
the parameter setting module is used for setting the communication parameters of the dispatching master station and the communication parameters of the calling slave station;
the second rule module is used for setting a communication rule between the dispatching master station and the calling slave station;
the time module is used for presetting idle delay time after the completion of the transmission of each broadcast frame;
the test module is used for testing the dispatching master station to perform read-write operation on all call slave stations;
and the detection module is used for detecting whether the data between the dispatching master station and the calling slave station are the same.
In the actual application process, before the method starts, setting communication parameters of a dispatching master station and a calling slave station through a parameter module; setting a communication rule between the dispatching master station and the calling slave station through a second rule module; after the broadcasting module finishes transmitting the broadcasting to the responding calling slave station, presetting idle delay time through a time module; after the calling slave station extracts the corresponding data to be written in the broadcast frame through the extraction module, the testing module tests the dispatching master station to perform read-write operation on all the calling slave stations; in the test process, the detection module detects whether the data between the dispatching master station and the calling slave station are the same.
Preferably, the method further comprises: AGVs;
the AGVs are used for realizing data interaction between the dispatching master station and the calling slave stations.
It should be noted that, in this embodiment, the AGV realizes data interaction between the dispatch master station and the call slave station. AGV (Automated Guided Vehicles) is also called an unmanned carrier, an automatic navigation vehicle and a laser navigation vehicle. The automatic guiding system is characterized in that the automatic guiding system is arranged on the unmanned AGV, so that the automatic guiding system can automatically run along a preset route without manual navigation, and goods or materials are automatically conveyed to a destination from a starting point. The AGV has the advantages of good flexibility, high automation degree and high intelligent level, the running path of the AGV can be flexibly changed according to the storage position requirement, the production process flow and the like, and the cost for changing the running path is very low compared with that of a traditional conveying belt and a rigid conveying line. AGVs are commonly equipped with handling mechanisms that can automatically interface with other logistics equipment to achieve full process automation of cargo and material handling and transport. In addition, the AGV still has clean production's characteristics, and the AGV relies on the battery that takes certainly to provide power, and noiseless, the pollution-free in the operation process can be applied in many places that require operational environment clean.
In the embodiments provided in the present application, it should be understood that the disclosed method and system may be implemented in other manners. The system embodiment described above is merely illustrative, for example, the division of modules is merely a logical function division, and there may be other division manners in actual implementation, such as: multiple modules or components may be combined, or may be integrated into another system, or some features may be omitted, or not performed. In addition, the various components shown or discussed may be coupled or directly coupled or communicatively coupled to each other via some interface, whether indirectly coupled or communicatively coupled to devices or modules, whether electrically, mechanically, or otherwise.
In addition, each functional module in each embodiment of the present invention may be integrated in one processor, or each module may be separately used as one device, or two or more modules may be integrated in one device; the functional modules in the embodiments of the present invention may be implemented in hardware, or may be implemented in a form of hardware plus a software functional unit.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the above method embodiments may be implemented by program instructions and associated hardware, where the program instructions may be stored in a computer readable storage medium, and where the program instructions, when executed, perform steps comprising the above method embodiments; and the aforementioned storage medium includes: a mobile storage device, a Read Only Memory (ROM), a magnetic disk or an optical disk, or the like, which can store program codes.
It is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above describes in detail a method and a system for communication between a master station and a plurality of slave stations based on the modbus_rtu protocol. The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (9)

1. A method for communication between a master station and a plurality of slave stations based on a modbus_rtu protocol, comprising the steps of:
s1, a dispatching master station polls all calling slave stations and acquires readback data fed back by the responding calling slave stations;
s2, the dispatching master station generates a broadcast frame according to the read-back data and the data to be written of the responding calling slave station and sends the broadcast frame to the responding calling slave station according to a preset rule;
s3, the responding calling slave station receives the broadcast frame and extracts corresponding data to be written in the broadcast frame according to the preset rule;
the preset rule in step S2 specifically includes:
the data to be written of each calling slave station corresponds to the offset address in the broadcast frame one by one.
2. The modbus_rtu protocol based one-master-multiple-slave communication method according to claim 1, wherein if the length of data to be written of the calling slave is greater than the length of the broadcast frame, writing the data to be written of the calling slave into N broadcast frames;
the N value is specifically a quotient of the length of data to be written of the calling secondary station divided by the length of the broadcast frame plus 1.
3. The method for communication between a master station and a plurality of slave stations according to the modbus_rtu protocol as set forth in any one of claims 1 to 2, further comprising, before step S1:
a1 Setting communication parameters of the dispatching master station and communication parameters of the calling slave station, wherein the communication parameters of the dispatching master station and the communication parameters of the calling slave station are the same parameters;
a2 And setting a communication rule between the dispatching master station and the calling slave station according to the communication parameters.
4. The method for communication between a master station and a plurality of slave stations according to the modbus_rtu protocol of claim 3, wherein the communication rule is specifically:
a first controller and a second controller are arranged in the scheduling master station;
the first controller reserves a continuous register;
the second controller establishes a byte array to accept the data packet.
5. The modbus_rtu protocol-based one-master-multiple-slave communication method according to claim 4, wherein the communication rule further comprises:
and presetting idle delay time after each broadcast frame is sent.
6. The modbus_rtu protocol-based one-master-multi-slave communication method according to claim 5, further comprising, after step S3:
testing the dispatching master station to perform read-write operation on all call slave stations;
detecting whether the read-back data in the scheduling master station is the same as the read-back data in the responding call slave station;
and detecting whether the data to be written of the calling slave station responding in the dispatching master station is the same as the data written of the calling slave station responding in the dispatching master station.
7. A master multi-slave communication system based on modbus_rtu protocol, comprising:
the polling module is used for realizing the polling of the scheduling master station to all call slave stations;
the response module is used for enabling the calling slave station to respond to the polling request of the dispatching master station and feeding back read data;
the acquisition module is used for acquiring readback data fed back by the responding calling slave station;
the generation module is used for realizing that the scheduling master station generates and transmits a broadcast frame;
a broadcasting module, configured to implement broadcasting by the scheduling master station to the responding call slave station;
the first rule module is used for setting rules for generating the broadcast frames according to the data to be written of the calling secondary station;
the extraction module is used for extracting the data to be written corresponding to the broadcast frame;
the rule for generating the broadcast frame by the data to be written of the responding calling secondary station is specifically as follows: the data to be written of each calling slave station corresponds to the offset address in the broadcast frame one by one.
8. The modbus_rtu protocol based one master multi-slave communication system of claim 7, further comprising:
the parameter setting module is used for setting the communication parameters of the dispatching master station and the communication parameters of the calling slave station;
the second rule module is used for setting a communication rule between the dispatching master station and the calling slave station;
the time module is used for presetting idle delay time after the completion of the transmission of each broadcast frame;
the test module is used for testing the dispatching master station to perform read-write operation on all call slave stations;
and the detection module is used for detecting whether the data between the dispatching master station and the calling slave station are the same.
9. The modbus_rtu protocol based one master multi-slave communication system of claim 8, further comprising: AGVs;
the AGV is used for realizing data interaction between the dispatching master station and the calling slave station.
CN202111023352.5A 2021-09-01 2021-09-01 MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system Active CN113746712B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111023352.5A CN113746712B (en) 2021-09-01 2021-09-01 MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111023352.5A CN113746712B (en) 2021-09-01 2021-09-01 MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system

Publications (2)

Publication Number Publication Date
CN113746712A CN113746712A (en) 2021-12-03
CN113746712B true CN113746712B (en) 2023-04-25

Family

ID=78734776

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111023352.5A Active CN113746712B (en) 2021-09-01 2021-09-01 MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system

Country Status (1)

Country Link
CN (1) CN113746712B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112261512A (en) * 2020-12-07 2021-01-22 北京和利时系统工程有限公司 Master station remote control method, device, storage medium and equipment of unbalanced polling protocol

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8190697B2 (en) * 2009-05-20 2012-05-29 Square D Company Automated configuration of device communication settings
CN103856578B (en) * 2014-01-03 2017-10-13 西南大学 The automatic acquisition station address approach of Modbus RTU slave stations and slave station
CN105007209B (en) * 2015-06-04 2018-07-31 烟台东方威思顿电气有限公司 A kind of poll means of communication based on RS485
CN106878488B (en) * 2017-04-29 2020-03-20 成都工鼎科技有限公司 Automatic Modbus RTU bus address allocation method
CN108737590B (en) * 2018-05-15 2022-02-25 浙江正泰电器股份有限公司 Automatic address allocation method and system, Modbus master station and Modbus slave station
CN111327503B (en) * 2020-03-10 2022-03-01 明度智云(浙江)科技有限公司 MODBUS bus-based multi-master-station token scheduling device, communication method and system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112261512A (en) * 2020-12-07 2021-01-22 北京和利时系统工程有限公司 Master station remote control method, device, storage medium and equipment of unbalanced polling protocol

Also Published As

Publication number Publication date
CN113746712A (en) 2021-12-03

Similar Documents

Publication Publication Date Title
US4441162A (en) Local network interface with control processor & DMA controller for coupling data processing stations to common serial communications medium
US4887266A (en) Communication system
CN102938928B (en) Node control method, network controller and network system
EP0622710B1 (en) Digital communication network with a moderator station selection process
CN111200844A (en) Multi-slave machine bidirectional communication method
AU2014406732B2 (en) Radio base station and system having said radio base station
CN102291337B (en) Gateway for switching communication based on EtherCAT (Ethernet for Control and Automation Technology) protocol and Profibus-DP (Process Field Bus-Decentralized Periphery) protocol and communication method thereof
CN105915328A (en) Synchronization frame receiving processing method and device
CN102238055B (en) Downloading method and system based on MDIO (Management Data Input/Output) interface
CN107708088A (en) Data transmission method and wireless communication system
CN104298195A (en) Wireless communication networking method of multiple-shuttle cooperative work system
CN113746712B (en) MODBUS_RTU protocol-based one-master-multiple-slave station communication method and system
CN103186440A (en) Method, device and system for detecting in-place state of sub cards
CN203399150U (en) Electric energy meter networking system capable of automatically sending address information
EP0064818A1 (en) Data collision avoidance method
CN105530153A (en) Slave device communication method in network, communication network, master device and slave device
CN116955242A (en) Single-bus communication method, storage medium and intelligent terminal
CN106656711A (en) Method for pre-defining token bus time slot
JPH07182293A (en) Distributed processing system and data transfer controlling method
CN113965432B (en) Control system for two-channel CAN bus communication
CN201909948U (en) One-swath multi-imaging box chip, imaging system and imaging box
CN105072699B (en) Multiple method and devices from equipment access slot are quickly distributed in master-slave equipment
CN210780847U (en) EtherCAT bus clock distribution system
US6108344A (en) Method, means and system for communicating on a shared transmission medium
CN112764385A (en) System and method for realizing small PLC bus

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