CN113949604A - Modbus gateway instruction processing method and device and gateway equipment - Google Patents
Modbus gateway instruction processing method and device and gateway equipment Download PDFInfo
- Publication number
- CN113949604A CN113949604A CN202111216942.XA CN202111216942A CN113949604A CN 113949604 A CN113949604 A CN 113949604A CN 202111216942 A CN202111216942 A CN 202111216942A CN 113949604 A CN113949604 A CN 113949604A
- Authority
- CN
- China
- Prior art keywords
- instruction
- preset
- query
- gateway
- modbus
- 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.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 15
- 238000012545 processing Methods 0.000 claims abstract description 6
- 238000004590 computer program Methods 0.000 claims description 6
- 238000000034 method Methods 0.000 claims description 6
- 230000005540 biological transmission Effects 0.000 claims description 4
- 238000001514 detection method Methods 0.000 claims description 3
- 230000008569 process Effects 0.000 claims description 3
- 238000004891 communication Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/66—Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L12/403—Bus networks with centralised control, e.g. polling
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L2012/40208—Bus networks characterized by the use of a particular bus standard
- H04L2012/40228—Modbus
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computer And Data Communications (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Small-Scale Networks (AREA)
Abstract
The invention provides a Modbus gateway instruction processing method, a Modbus gateway instruction processing device and a Modbus gateway apparatus, wherein the Modbus gateway instruction processing method comprises the following steps: s1, a gateway sets an instruction storage cabin to store a preset instruction set, and writes the preset instruction set into the instruction storage cabin; s2, setting a polling flow, sending a plurality of preset instructions in a preset instruction set to the slave equipment through the polling flow, inquiring the preset instructions, and storing data results which are returned from the slave equipment and correspond to the preset instructions; and S3, the Modbus gateway acquires the query instruction sent by the host equipment and judges whether the preset instruction set in the instruction storage cabin comprises the query instruction, if so, the data result corresponding to the query instruction is returned to the host equipment, and if not, the query instruction is sent to the slave equipment and the data result corresponding to the query instruction is returned to the host equipment.
Description
Technical Field
The invention relates to the technical field of Modbus gateways, in particular to a Modbus gateway instruction processing method and device and gateway equipment.
Background
In industrial field application, the main function of the Modbus gateway is to complete the mutual transmission of the MODBUS protocol between the 485/232 serial port and the network. However, since the communication rate (1.2Kbit/s-256Kbit/s) of the 485/232 bus is much less than the network communication rate (usually 100Mbit/s), the delay is more than 10ms in the process from the slave device receiving the command to the completion of the response and transmitting the data back to the host device at the network end (for example, the rate of the serial bus at 9.6 Kbit/s) and when a plurality of slave devices need to be read at one time, the delay is increased linearly, which results in low data refresh rate and low data reading efficiency.
Disclosure of Invention
The invention aims to provide a Modbus gateway instruction processing method and device and a gateway device, which can improve the data reading rate of a Modbus gateway.
The embodiment of the invention is realized by the following technical scheme:
in a first aspect, a method for processing a Modbus gateway instruction is provided, which includes the following steps:
s1, a gateway sets an instruction storage cabin to store a preset instruction set, and writes the preset instruction set into the instruction storage cabin, wherein the preset instruction set comprises a plurality of preset instructions;
s2, setting a polling flow, sending a plurality of preset instructions in a preset instruction set to slave equipment through the polling flow, inquiring the preset instructions, and storing data results which are returned from the slave equipment and correspond to the preset instructions; in particular, a plurality of data results may be formed into a data result set and stored in the instruction storage compartment.
And S3, the Modbus gateway acquires the query instruction sent by the host equipment, judges whether a preset instruction set in the instruction storage cabin contains the query instruction, returns a data result corresponding to the query instruction to the host equipment if the preset instruction set contains the query instruction, sends the query instruction to the slave equipment if the preset instruction set does not contain the query instruction, returns a data result corresponding to the query instruction according to the query instruction like the Modbus gateway by the slave equipment, and returns a data result corresponding to the query instruction to the host equipment by the Modbus gateway.
Preferably, the polling procedure specifically includes: checking whether a preset instruction set in the instruction storage cabin comprises a preset instruction or not; if not, waiting for the storage of a preset instruction; if so, setting a query time interval through a timer, querying a preset instruction according to the time interval sequence, sending the preset instruction to the slave equipment, obtaining the preset instruction by the slave equipment, sending a data result corresponding to the preset instruction to the Modbus gateway, and receiving and storing the data result by the Modbus gateway.
Preferably, the preset instruction is an instruction for the master device to access an address of the slave device for the first time.
Preferably, the preset instruction is a frequent query instruction.
Preferably, the timer is a timeout timer.
In a second aspect, a Modbus gateway instruction processing apparatus is provided, including:
a storage unit for storing a preset instruction set;
the detection unit is used for detecting whether a preset instruction exists in the instruction storage cabin;
the first query unit is used for issuing a query instruction to the slave equipment and acquiring a data result;
the second query unit is used for querying whether a preset instruction which is the same as the query instruction issued by the host equipment exists in the preset instruction set, querying a data result corresponding to the preset instruction in the data result set and returning the data result to the host equipment;
a data transmission unit for transmitting the data result to the host device;
a timing unit for setting a polling time interval.
In a third aspect, a Modbus gateway device is provided, which includes a controller, a timeout timer, a first storage, a second storage, and a computer program stored in the second storage, where the computer program is executable by the controller to implement the above Modbus gateway instruction processing method, and the first storage is used to store a preset instruction set.
The technical scheme of the embodiment of the invention at least has the following advantages and beneficial effects:
according to the invention, the instruction storage cabin is arranged, the preset instruction set and the data result set corresponding to the query result of the preset instruction set are stored in the instruction storage cabin, and a part of instructions are queried in advance to obtain the result, so that the serial port interaction between the gateway and the slave equipment is reduced, the communication efficiency is improved, and meanwhile, the query reading efficiency is also improved;
the invention has reasonable design, simple structure and strong practicability.
Drawings
Fig. 1 is a schematic flowchart of a Modbus gateway instruction processing method according to embodiment 1 of the present invention;
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Example 1
As shown in fig. 1, in a first aspect, a method for processing a Modbus gateway instruction is provided, which includes the following steps:
s1, a gateway sets an instruction storage cabin to store a preset instruction set, and writes the preset instruction set into the instruction storage cabin, wherein the preset instruction set comprises a plurality of preset instructions;
s2, setting a polling flow, sending a plurality of preset instructions in a preset instruction set to the slave equipment through the polling flow, inquiring the preset instructions, and storing data results which are returned from the slave equipment and correspond to the preset instructions; in particular, a plurality of data results may be formed into a data result set and stored in the instruction storage compartment.
And S3, the Modbus gateway acquires the query instruction sent by the host equipment, judges whether a preset instruction set in the instruction storage cabin contains the query instruction, returns a data result corresponding to the query instruction to the host equipment if the preset instruction set contains the query instruction, sends the query instruction to the slave equipment if the preset instruction set does not contain the query instruction, returns a data result corresponding to the query instruction according to the query instruction like the Modbus gateway by the slave equipment, and returns a data result corresponding to the query instruction to the host equipment by the Modbus gateway.
The polling process specifically comprises the following steps: checking whether a preset instruction set in the instruction storage cabin comprises a preset instruction or not; if not, waiting for the storage of a preset instruction; if so, setting a query time interval through a timer, querying a preset instruction according to the time interval sequence, sending the preset instruction to the slave equipment, obtaining the preset instruction by the slave equipment, sending a data result corresponding to the preset instruction to the Modbus gateway, and receiving and storing the data result by the Modbus gateway.
The preset instruction is an instruction for the master device to access the address of the slave device for the first time.
The preset instruction is an instruction requiring frequent inquiry.
The timer is a timeout timer.
In a second aspect, a Modbus gateway instruction processing apparatus is provided, including:
a storage unit for storing a preset instruction set;
the detection unit is used for detecting whether a preset instruction exists in the instruction storage cabin;
the first query unit is used for issuing a query instruction to the slave equipment and acquiring a data result;
the second query unit is used for querying whether a preset instruction which is the same as the query instruction issued by the host equipment exists in the preset instruction set, querying a data result corresponding to the preset instruction in the data result set and returning the data result to the host equipment;
a data transmission unit for transmitting the data result to the host device;
a timing unit for setting a polling time interval.
In a third aspect, a Modbus gateway device is provided, which includes a controller, a timeout timer, a first storage, a second storage, and a computer program stored in the second storage, where the computer program is executable by the controller to implement the above Modbus gateway instruction processing method, and the first storage is used to store a preset instruction set.
In this embodiment, the host device is a Modbus host, the slave devices are a plurality of registers, the Modbus host is connected with the plurality of registers through a Modbus gateway, and accesses data stored in the registers, the Modbus host is connected with the Modbus gateway through a TCPmodbus protocol, and the registers are connected with the Modbus gateway through serial port lines.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (7)
1. A Modbus gateway instruction processing method is characterized by comprising the following steps:
s1, a gateway sets an instruction storage cabin to store a preset instruction set, and writes the preset instruction set into the instruction storage cabin, wherein the preset instruction set comprises a plurality of preset instructions;
s2, setting a polling flow, sending a plurality of preset instructions in the preset instruction set to slave equipment through the polling flow, inquiring the preset instructions, and storing data results which are returned from the slave equipment and correspond to the preset instructions;
and S3, the Modbus gateway acquires the query instruction issued by the host equipment, judges whether a preset instruction set in the instruction storage cabin contains the query instruction, returns a data result corresponding to the query instruction to the host equipment if the preset instruction set contains the query instruction, issues the query instruction to the slave equipment if the preset instruction set does not contain the query instruction, and returns a data result corresponding to the query instruction to the host equipment.
2. The Modbus gateway instruction processing method according to claim 1, wherein the polling process specifically comprises: checking whether a preset instruction set in the instruction storage cabin comprises a preset instruction or not; if not, waiting for the storage of a preset instruction; if yes, setting a query time interval through a timer, querying the preset instruction according to the time interval sequence, and storing a data result corresponding to the preset instruction.
3. The Modbus gateway instruction processing method according to claim 2, wherein the preset instruction is an instruction for a master device to access an address of a slave device for the first time.
4. The Modbus gateway instruction processing method according to claim 2, wherein the preset instruction is a frequent query required instruction.
5. The Modbus gateway instruction processing method according to claim 2, wherein the timer is a timeout timer.
6. The utility model provides a Modbus gateway instruction processing device which characterized in that includes:
a storage unit for storing a preset instruction set;
the detection unit is used for detecting whether a preset instruction exists in the instruction storage cabin;
the first query unit is used for issuing a query instruction to the slave equipment and acquiring a data result;
the second query unit is used for querying whether a preset instruction which is the same as the query instruction issued by the host equipment exists in the preset instruction set or not and querying a data result which is the same as the preset instruction;
a data transmission unit for transmitting the data result to the host device;
a timing unit for setting a polling time interval.
7. A Modbus gateway device, comprising a controller, a timeout timer, a first storage, a second storage, and a computer program stored in the second storage, the computer program being executable by the controller to implement the Modbus gateway instruction processing method of any one of claims 1 to 5, the first storage storing a predetermined instruction set.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111216942.XA CN113949604A (en) | 2021-10-19 | 2021-10-19 | Modbus gateway instruction processing method and device and gateway equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111216942.XA CN113949604A (en) | 2021-10-19 | 2021-10-19 | Modbus gateway instruction processing method and device and gateway equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113949604A true CN113949604A (en) | 2022-01-18 |
Family
ID=79331499
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111216942.XA Pending CN113949604A (en) | 2021-10-19 | 2021-10-19 | Modbus gateway instruction processing method and device and gateway equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113949604A (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030126222A1 (en) * | 2001-11-27 | 2003-07-03 | Peterson Clyde O. | Translator apparatus for two communication networks |
US20060240818A1 (en) * | 2005-04-22 | 2006-10-26 | Mccoy Robert | System, method, and apparatus for command and control of remote instrumentation |
CN102938728A (en) * | 2012-10-18 | 2013-02-20 | 北京经纬纺机新技术有限公司 | Method for converting Modbus TCP (Transmission Control Protocol)/IP (Internet Protocol) into Modbus serial gateway |
CN103166971A (en) * | 2013-03-15 | 2013-06-19 | 广东盈嘉科技工程发展股份有限公司 | Multiplexing serial port protocol converter |
CN112073280A (en) * | 2020-09-07 | 2020-12-11 | 合肥阳光新能源科技有限公司 | Communication method and device based on Modbus protocol and communication equipment |
-
2021
- 2021-10-19 CN CN202111216942.XA patent/CN113949604A/en active Pending
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030126222A1 (en) * | 2001-11-27 | 2003-07-03 | Peterson Clyde O. | Translator apparatus for two communication networks |
US20060240818A1 (en) * | 2005-04-22 | 2006-10-26 | Mccoy Robert | System, method, and apparatus for command and control of remote instrumentation |
CN102938728A (en) * | 2012-10-18 | 2013-02-20 | 北京经纬纺机新技术有限公司 | Method for converting Modbus TCP (Transmission Control Protocol)/IP (Internet Protocol) into Modbus serial gateway |
CN103166971A (en) * | 2013-03-15 | 2013-06-19 | 广东盈嘉科技工程发展股份有限公司 | Multiplexing serial port protocol converter |
CN112073280A (en) * | 2020-09-07 | 2020-12-11 | 合肥阳光新能源科技有限公司 | Communication method and device based on Modbus protocol and communication equipment |
Non-Patent Citations (2)
Title |
---|
李卓函;邵诚;杨素英;郭基伟;王峰;李彦生;: "异构总线多协议网关设计及其在电除尘监控系统中应用", 大连理工大学学报, no. 03, pages 434 - 442 * |
郭翠娟;李中原;荣锋;: "PROFINET-Modbus通信网关的设计", 仪表技术与传感器, no. 09, pages 121 - 126 * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7941618B2 (en) | Fully buffered DIMM read data substitution for write acknowledgement | |
CN110704265A (en) | Early warning information active reporting method and system based on Modbus protocol | |
CN110955626A (en) | Method and system for realizing Modbus communication on serial link | |
CN107590099A (en) | A kind of more main frames access method, expanding unit and the storage medium of slave | |
JPH04233055A (en) | Server architecture for terminal apparatus | |
CN103077147B (en) | A kind of global function 1553B bus IP Core based on chained list | |
CN111078597B (en) | Interrupt message generation device and method and end equipment | |
CN111737564B (en) | Information query method, device, equipment and medium | |
CN110635982A (en) | Double-host communication method and system on communication bus, industrial control gateway and storage medium | |
CN111176164A (en) | Method, device and medium for expanding multiple remote input and output modules | |
CN113852533B (en) | Multi-channel data communication system and method and electronic equipment | |
CN102710622A (en) | Protocol conversion device based on DeviceNet-Modbus | |
CN118921397B (en) | Communication connection method, device, storage device and program product | |
CN112817899B (en) | PCIE-based data transmission method and device, storage medium and electronic equipment | |
CN113949604A (en) | Modbus gateway instruction processing method and device and gateway equipment | |
CN110659236B (en) | AXI bus transmission device capable of autonomously replying write response | |
CN116680088B (en) | Multi-module simultaneous access system and method for multi-register storage | |
CN117909263A (en) | Remapping method, device and storage medium based on ID order preserving circuit | |
CN116431558B (en) | AXI protocol-based request response method, device, system and medium | |
CN115333894A (en) | Modbus communication hub based on multi-master-station communication requirements and reading method | |
CN114356831A (en) | Serial port communication method, device, equipment and computer readable storage medium | |
CN109992560B (en) | Communication method and communication system | |
CN116756078B (en) | Notification method and device of pcie data packet and storage medium | |
KR20180061885A (en) | Apparatus and system for providing modbus communication shortening polling time and method thereof | |
CN113032307A (en) | Integrated device access request processing method and related assembly |
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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220118 |
|
RJ01 | Rejection of invention patent application after publication |