CN113938500B - Modbus protocol packet method based on RS485 - Google Patents

Modbus protocol packet method based on RS485 Download PDF

Info

Publication number
CN113938500B
CN113938500B CN202111045057.XA CN202111045057A CN113938500B CN 113938500 B CN113938500 B CN 113938500B CN 202111045057 A CN202111045057 A CN 202111045057A CN 113938500 B CN113938500 B CN 113938500B
Authority
CN
China
Prior art keywords
registers
data
point location
gateway
register
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
CN202111045057.XA
Other languages
Chinese (zh)
Other versions
CN113938500A (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.)
China Construction Third Bureau Intelligent Technology Co Ltd
Original Assignee
China Construction Third Bureau Intelligent Technology 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 China Construction Third Bureau Intelligent Technology Co Ltd filed Critical China Construction Third Bureau Intelligent Technology Co Ltd
Priority to CN202111045057.XA priority Critical patent/CN113938500B/en
Publication of CN113938500A publication Critical patent/CN113938500A/en
Application granted granted Critical
Publication of CN113938500B publication Critical patent/CN113938500B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • 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
    • H04L2012/40208Bus networks characterized by the use of a particular bus standard
    • H04L2012/40228Modbus
    • 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/4026Bus for use in automation systems
    • 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)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention provides a Modbus protocol packet method based on RS485, which belongs to the technical field of the Internet of things and comprises the steps that a cloud platform obtains point location information of data requirements and registers, and after clusters to which each register belongs are obtained according to the point location information, the data requirements and the point location information of all the clusters are issued to a gateway. After obtaining the packets to which all the registers in each cluster belong according to the point location information, the gateway generates at least one set data packet based on the data requirement, the preset maximum length of the data packet and the maximum interval number of the registers, and transmits all the set data packets to the sensor. The gateway acquires the corresponding response data packet from the sensor by the minimum set data packet quantity, reduces the data quantity of on-line invalid inquiry, increases the data quantity of effective inquiry, can increase the inquiry efficiency and increases the number of the points supported by a single gateway.

Description

Modbus protocol packet method based on RS485
Technical Field
The invention relates to the technical field of the Internet of things, in particular to a Modbus protocol packet method based on RS 485.
Background
Industry 4.0 is the fourth industrial revolution leading to intelligent manufacturing, a factory integrates production equipment, wireless signal connection and sensors into an ecosystem platform, and the ecosystem can monitor the whole production line flow and autonomously execute decisions, and utilizes the technologies of information physical systems, internet of things, industrial Internet of things, cloud computing, cognitive computing, artificial intelligence and the like.
In brief, the goal of industry 4.0 is that all labor in the process of natural resources from mining, collection, until production becomes commodity into the circulation area is automated, possibly through intelligent systems. In the past, several industrial leather hits, the roles played by people are greatly desalted in the industry 4.0, and intelligent manufacturing is becoming the mainstream.
The industrial Internet of things cloud platform needs to acquire a large amount of sensor data through an industrial Internet of things gateway, and intelligent manufacturing is realized through big data and an AI algorithm. The main acquisition mode of the gateway for acquiring data is to acquire related information from an industrial sensor through a Modbus RTU RS485 protocol. Industrial sensors are of many kinds, and each time a new sensor is to be supported, the cloud platform or the gateway needs to be integrated with the new sensor, and each time relevant codes of the cloud platform and the gateway need to be modified, which is very time-consuming and delays business opportunity.
Most industrial sensors adopt standard Modbus RTU RS485 protocol transmission, the Modbus RTU RS485 protocol divides parameters supported by the sensors into a plurality of registers for a third party gateway to inquire or set through the Modbus RTU RS485 protocol, so the third party gateway must know the meaning and analysis mode represented by each register to read the sensor. The cloud platform is informed through a specific protocol, and the cloud platform needs to know the meaning of the cloud platform to carry out big data statistics and analysis. All needs to be based on the cloud platform and the gateway to fully know the precondition of the sensor characteristics so as to develop and display.
Modbus communication messages are divided into inquiry messages and response messages. The Modbus communication protocol follows the communication steps of the Master and Slave computers, the Master computer adopts an active inquiry mode to send out inquiry messages to the Slave computer Slave side, and then the Slave side prepares response messages according to the received inquiry message content and transmits the response messages back to the Master computer. In general, a Master is a device acquisition server, and a Slave is a target acquisition device.
As shown in fig. 1, an architecture diagram of an industrial internet of things in the prior art is shown, after a cloud platform is manually programmed according to customer requirements and technical details (for example, sensor specifications), an inquiry/setting instruction (i.e., an inquiry message) is issued to a gateway, then the gateway transmits the instruction issued by the cloud platform to various industrial sensors, and finally the gateway returns the inquiry/setting results (i.e., corresponding messages) fed back by the various industrial sensors to the cloud platform. All work is done by the cloud platform, causing many inconveniences, such as: the cloud needs to integrate novel sensors continuously, the cloud cannot access a large number of points due to low efficiency, the cloud is poor in real-time performance, a large amount of flow is wasted on low-value data, and the cloud has higher performance required for executing all tasks.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide the Modbus protocol group package method based on RS485, and a user can quickly support various standard Modbus RTU sensors only by filling the differences of different sensors in a form mode, so that the query efficiency can be increased, and the number of the points supported by a single gateway can be increased.
In order to achieve the above purpose, the technical scheme adopted is as follows:
a Modbus protocol grouping method based on RS485 comprises the following steps:
the cloud platform acquires the data requirements and the point location information of the registers, and after acquiring the clusters to which each register belongs according to the point location information, the cloud platform transmits the data requirements and the point location information of all the clusters to the gateway;
after obtaining the packets to which all the registers in each cluster belong according to the point location information, the gateway generates at least one set data packet based on the data requirement, the preset maximum length of the data packet and the maximum interval number of the registers, and transmits all the set data packets to the sensor.
Preferably, after the sensor receives all the setting data packets, at least one response data packet is fed back to the gateway.
Preferably, each time a new sensor is accessed to the cloud platform, the point location information of the sensor is collected;
the sensor reports point location information to the cloud platform in a table form.
Preferably, each cluster corresponds to the same sensor, and all registers in the same cluster belong to the same sensor.
Preferably, after obtaining the packets to which all registers in each cluster belong according to the point location information, the gateway specifically includes:
the gateway divides all registers in the cluster into an abnormal point cluster and a normal point cluster according to the point usage contained in the point information;
and the gateway respectively divides all registers in the abnormal point location cluster and the normal point location cluster into a plurality of first groups according to the reporting frequency contained in the point location information.
Preferably, the gateway generates at least one setting data packet based on a data requirement, a preset maximum length of the data packet, and a preset maximum number of intervals of the register, and specifically includes:
the gateway divides all registers in each first group into a plurality of second groups according to the preset maximum interval number of the registers;
the gateway divides all registers in each second group into a plurality of third groups according to the preset maximum length of the data packet;
the gateway generates at least one setup packet based on the addresses and the number of all registers in the third packet.
Preferably, the setting data includes a function code, a start address, and a register number;
the starting address is the address of the first register in the third packet;
the number of registers is the difference between the first effective address and the last effective address in the third packet.
Preferably, the point location information includes type related information and acquisition related information.
Preferably, the type related information includes:
the point location application is used for representing the data application of the register, and the data application comprises normal time inquiry and abnormal time inquiry;
a bit type for representing a data type of the register, the data type including an analog quantity and a digital quantity;
a dot-by-dot factor for representing a scaling factor of a register;
and the reporting frequency is used for indicating the reporting frequency of the register.
Preferably, the collecting related information includes:
a register address representing an address range of the register, the address range being 0 to 65535;
a read length for representing a read length of the register;
a data format for representing a data format of a register, the data format including double, int, unit, and long;
a calculation formula for representing a calculation formula of the register.
The invention has the beneficial effects that:
the user only needs to fill in the difference, namely point location information, of different sensors in the cloud platform in a form mode, so that the gateway can quickly support various standard Modbus RTU sensors.
The gateway is not simple transparent transmission, a large amount of point location information is intelligently combined together according to the point location distribution diagram, the gateway acquires corresponding response data packets from the sensor by the minimum set data packet number, the data volume of on-line ineffective query is reduced, the data volume of effective query is increased, the query efficiency can be increased, and the number of point locations supported by a single gateway is increased.
Drawings
Fig. 1 is a schematic diagram of an industrial internet of things architecture in the prior art.
Fig. 2 is a flowchart of a Modbus protocol packet method based on RS485 in an embodiment of the present invention.
Fig. 3 is a schematic diagram of a Modbus protocol packet method based on RS485 in an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific examples described herein are intended to illustrate the invention and are not intended to limit the invention. Moreover, all other embodiments which can be made by a person of ordinary skill in the art based on the embodiments of the present invention without making any inventive effort are within the scope of the present invention.
The present invention will be described in further detail with reference to the accompanying drawings and examples.
As shown in fig. 2 and 3, the present invention provides a Modbus protocol packet method based on RS485, which includes:
step S1, the cloud platform acquires the data requirements and the point location information of the registers, and after obtaining the clusters to which each register belongs according to the point location information, the cloud platform issues the data requirements and the point location information of all the clusters to the gateway.
And S2, after obtaining the groups of all the registers in each cluster according to the point location information, the gateway generates at least one set data packet based on the data requirement, the preset maximum length of the data packet and the maximum interval number of the registers, and transmits all the set data packets to the sensor, wherein the set data packet is used for configuring the sensor.
And step S3, feeding back at least one response data packet after the sensor receives all the setting data packets.
Furthermore, each time the cloud platform is connected with a new sensor, the point location information of the sensor is collected. The sensor reports point location information to the cloud platform in a table form.
Further, each cluster corresponds to a sensor, and all registers in the same cluster belong to the same sensor.
In this embodiment, the sensors all adopt standard Modbus RTU RS485 protocol transmission, and each time the cloud platform accesses a new sensor, the sensors report point location information thereof to the cloud platform in a form of a table, and the point location information is used for representing the attribute of the sensor. And the cloud platform divides all the registers into different clusters according to the point location information, and all the registers in the same cluster belong to the same sensor. The standard sensor is not required to be integrated continuously, and the newly accessed sensor can be supported by filling the sensor difference according to the table content.
The gateway is not simple transparent transmission, a large amount of point location information is intelligently combined together according to the point location distribution diagram containing each register address, the gateway acquires corresponding response data packets from the sensor by the minimum set data packet number, the data volume of on-line invalid query is reduced, the data volume of effective query is increased, the query efficiency can be increased, and the number of point locations supported by a single gateway is increased.
In a preferred embodiment, the cloud platform issues the user's data requirements and point location information of all clusters to the gateway. According to the point usage contained in the point location information, the gateway divides all registers in the cluster into an abnormal point location cluster (including the point location which needs to be queried in the case of abnormality) and a normal point location cluster (including the point location which needs to be queried in the case of common condition).
And the gateway respectively divides all registers in the abnormal point location cluster and the normal point location cluster into a plurality of first groups according to the reporting frequency contained in the point location information.
And the gateway divides all registers in each first group into a plurality of second groups according to the preset maximum interval number of the registers.
And the gateway divides all registers in each second packet into a plurality of third packets according to the preset maximum length of the data packet.
The gateway generates at least one setup packet based on the addresses and the number of all registers in the third packet.
In this embodiment, the point location information of all registers collected by the cloud platform includes register addresses, all registers are distributed on an address axis according to addresses, part of the point location information is in discrete distribution, part of the point location information is in continuous distribution, all registers in a first packet are divided into a plurality of second packets according to the maximum interval number of the registers, as many registers as possible including registers specified in data requirements in each packet need to be sent to each second packet, but the length of the data packet of the set data packet cannot be infinitely long, therefore, considering the maximum length of the data packet, all registers in each second packet are divided into a plurality of third packets, and finally the gateway generates at least one set data packet based on the addresses and the number of all registers in the third packets.
In the preferred embodiment, each third packet requires a set-up packet to be delivered.
The setting data includes a function code, a start address, and the number of registers.
The starting address is the address of the first register in the third packet.
The number of registers is the difference between the first effective address and the last effective address in the third packet.
In a preferred embodiment, the point location information includes type related information and acquisition related information.
The type-related information includes:
the point location uses are used for representing the data uses of the register, and the data uses comprise normal time inquiry and abnormal time inquiry.
A bit type for representing a data type of a register, the data type including an analog quantity and a digital quantity.
A dot-by-dot factor, which is used to represent the scaling factor of a register.
And the reporting frequency is used for indicating the reporting frequency of the register.
In a preferred embodiment, the collecting the related information includes:
register addresses, which are used to represent the address range of registers, are 0-65535.
A read length, which is used to represent the read length of the register.
A data format for representing a data format of a register, the data format including double, int, unit, and long.
A calculation formula for representing a calculation formula of the register.
The invention is not limited to the embodiments described above, but a number of modifications and adaptations can be made by a person skilled in the art without departing from the principle of the invention, which modifications and adaptations are also considered to be within the scope of the invention. What is not described in detail in this specification is prior art known to those skilled in the art.

Claims (7)

1. The Modbus protocol grouping method based on RS485 is characterized by comprising the following steps of:
the cloud platform acquires the data requirements and the point location information of the registers, and after acquiring the clusters to which each register belongs according to the point location information, the cloud platform transmits the data requirements and the point location information of all the clusters to the gateway; each cluster corresponds to the same sensor, and all registers in the same cluster belong to the same sensor;
the gateway obtains the grouping of all the registers in each cluster according to the point location information, generates at least one set data packet based on the data requirement, the preset maximum length of the data packet and the maximum interval number of the registers, and transmits all the set data packets to the sensor;
the gateway obtains the grouping of all the registers in each cluster according to the point location information, and specifically comprises the following steps: the gateway divides all registers in the cluster into an abnormal point cluster and a normal point cluster according to the point usage contained in the point information; the gateway divides all registers in the abnormal point location cluster and the normal point location cluster into a plurality of first groups according to the reporting frequency contained in the point location information;
the gateway generates at least one set data packet based on the data requirement, the preset maximum length of the data packet and the preset maximum interval number of the register, and specifically comprises the following steps:
the gateway divides all registers in each first group into a plurality of second groups according to the preset maximum interval number of the registers;
the gateway divides all registers in each second group into a plurality of third groups according to the preset maximum length of the data packet;
the gateway generates at least one setup packet based on the addresses and the number of all registers in the third packet.
2. The RS485 based Modbus protocol packet method of claim 1, wherein the sensor feeds back at least one reply packet to the gateway after receiving all the setup packets.
3. The method for packaging Modbus protocol based on RS485 according to claim 1, wherein each time a new sensor is accessed to the cloud platform, the point location information of the sensor is collected;
the sensor reports point location information to the cloud platform in a table form.
4. The RS485 based Modbus protocol packet method according to claim 1, wherein the setting data includes a function code, a start address, and a number of registers;
the starting address is the address of the first register in the third packet;
the number of registers is the difference between the first effective address and the last effective address in the third packet.
5. The RS485 based Modbus protocol packet method of claim 1, wherein the point location information includes type related information and acquisition related information.
6. The RS485 based Modbus protocol packetization method of claim 5, wherein the type related information comprises:
the point location application is used for representing the data application of the register, and the data application comprises normal time inquiry and abnormal time inquiry;
a bit type for representing a data type of the register, the data type including an analog quantity and a digital quantity;
a dot-by-dot factor for representing a scaling factor of a register;
and the reporting frequency is used for indicating the reporting frequency of the register.
7. The RS485 based Modbus protocol packetization method of claim 5, wherein the collecting related information comprises:
a register address representing an address range of the register, the address range being 0 to 65535;
a read length for representing a read length of the register;
a data format for representing a data format of a register, the data format including double, int, unit, and long;
a calculation formula for representing a calculation formula of the register.
CN202111045057.XA 2021-09-07 2021-09-07 Modbus protocol packet method based on RS485 Active CN113938500B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111045057.XA CN113938500B (en) 2021-09-07 2021-09-07 Modbus protocol packet method based on RS485

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111045057.XA CN113938500B (en) 2021-09-07 2021-09-07 Modbus protocol packet method based on RS485

Publications (2)

Publication Number Publication Date
CN113938500A CN113938500A (en) 2022-01-14
CN113938500B true CN113938500B (en) 2024-03-22

Family

ID=79275200

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111045057.XA Active CN113938500B (en) 2021-09-07 2021-09-07 Modbus protocol packet method based on RS485

Country Status (1)

Country Link
CN (1) CN113938500B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110704265A (en) * 2019-10-11 2020-01-17 山东有人信息技术有限公司 Early warning information active reporting method and system based on Modbus protocol
CN111884915A (en) * 2020-07-17 2020-11-03 杭州电子科技大学 Method for improving efficiency of acquiring modbus equipment by gateway
WO2021072981A1 (en) * 2019-10-17 2021-04-22 广东绿腾新能源服务有限公司 Blockchain-based energy data linking method and apparatus

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110704265A (en) * 2019-10-11 2020-01-17 山东有人信息技术有限公司 Early warning information active reporting method and system based on Modbus protocol
WO2021072981A1 (en) * 2019-10-17 2021-04-22 广东绿腾新能源服务有限公司 Blockchain-based energy data linking method and apparatus
CN111884915A (en) * 2020-07-17 2020-11-03 杭州电子科技大学 Method for improving efficiency of acquiring modbus equipment by gateway

Also Published As

Publication number Publication date
CN113938500A (en) 2022-01-14

Similar Documents

Publication Publication Date Title
CN103792928B (en) A kind of industrial field data acquisition analysis system based on Modbus
US7312721B2 (en) Data collector for an automated meter reading system
CN108769121A (en) Intelligent industrial equips the method for uploading of internet of things data acquisition system and gathered data
CN101827302B (en) Processing method and unified service platform are unified in multi-service
CN105357061A (en) Operation and maintenance monitoring analysis system based on large-data-flow processing technology
CN205038511U (en) Industrial field data remote monitering system
CN107193266A (en) A kind of platform monitoring system of big data
CN103955509A (en) Quick search method for massive electric power metering data
CN103984323A (en) Integrated configurable industrial information monitoring, analyzing and controlling system
CN107609812A (en) A kind of new intelligent warehousing system
CN110445824A (en) NB-IoT data reporting method, device, system and computer readable storage medium
CN113938500B (en) Modbus protocol packet method based on RS485
Antonova et al. Implementation of IoT technology for data monitoring via cloud services
CN105223927A (en) A kind of continuous casting cloud computing research and development manufacturing system
CN201974925U (en) Remote fire monitoring alarm system based on internet of things
CN110139234A (en) A kind of wireless sensor network dormancy dispatching method based on node grouping
CN112132519B (en) Bottled gas cross network system based on big data of Internet of things
CN108710347A (en) A kind of monitoring cloud platform
CN111064402B (en) Diesel generating set cloud communication module with long connection and small data flow
CN201910071U (en) E-commerce system based on 3G ( the 3rd generation telecommunication) network
CN110780630A (en) Protocol library docking execution system suitable for Internet of things and working method
CN114422873B (en) Method, device and equipment for dynamically accessing industrial Internet identification analysis platform
CN113343037B (en) Data mapping method of embedded master-slave device
CN108696585A (en) A kind of distributed storage method and system of data
CN108153260A (en) A kind of Discrete Intelligence manufacture system control terminal based on internet

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