CN113949604A - Modbus gateway instruction processing method and device and gateway equipment - Google Patents

Modbus gateway instruction processing method and device and gateway equipment Download PDF

Info

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
Application number
CN202111216942.XA
Other languages
Chinese (zh)
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.)
Chengdu Ebyte Electronic Technology Co ltd
Original Assignee
Chengdu Ebyte Electronic 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 Chengdu Ebyte Electronic Technology Co ltd filed Critical Chengdu Ebyte Electronic Technology Co ltd
Priority to CN202111216942.XA priority Critical patent/CN113949604A/en
Publication of CN113949604A publication Critical patent/CN113949604A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • 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

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

Modbus gateway instruction processing method and device and gateway equipment
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.
CN202111216942.XA 2021-10-19 2021-10-19 Modbus gateway instruction processing method and device and gateway equipment Pending CN113949604A (en)

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)

* Cited by examiner, † Cited by third party
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

Patent Citations (5)

* Cited by examiner, † Cited by third party
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)

* Cited by examiner, † Cited by third party
Title
李卓函;邵诚;杨素英;郭基伟;王峰;李彦生;: "异构总线多协议网关设计及其在电除尘监控系统中应用", 大连理工大学学报, no. 03, pages 434 - 442 *
郭翠娟;李中原;荣锋;: "PROFINET-Modbus通信网关的设计", 仪表技术与传感器, no. 09, pages 121 - 126 *

Similar Documents

Publication Publication Date Title
CN107590099B (en) Method for accessing slave machines by multiple hosts, extension device and storage medium
US7941618B2 (en) Fully buffered DIMM read data substitution for write acknowledgement
CN110955626A (en) Method and system for realizing Modbus communication on serial link
CN110704265A (en) Early warning information active reporting method and system based on Modbus protocol
JPH04233055A (en) Server architecture for terminal apparatus
CN103077147B (en) A kind of global function 1553B bus IP Core based on chained list
CN109992554B (en) Method for realizing 1553B bus communication protocol based on general Schema structure description
CN111078597B (en) Interrupt message generation device and method and end equipment
CN110635982A (en) Double-host communication method and system on communication bus, industrial control gateway and storage medium
CN113852533B (en) Multi-channel data communication system and method and electronic equipment
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
CN105472290A (en) Processing method and device for data transmitting and receiving operation modes
CN109285580B (en) Data preprocessing device and method and asynchronous double-end random access memory system
CN113923061B (en) GPU network communication method based on intelligent network card, medium and equipment
CN115333894A (en) Modbus communication hub based on multi-master-station communication requirements and reading method
US20090204665A1 (en) System and methods for communicating between serial communications protocol enabled devices
CN112948124B (en) Acceleration task processing method, device, equipment and readable storage medium
CN110659236B (en) AXI bus transmission device capable of autonomously replying write response
CN109992560B (en) Communication method and communication system
CN113032307A (en) Integrated device access request processing method and related assembly
CN116756078B (en) Notification method and device of pcie data packet and storage medium
CN220629487U (en) Repeater capable of expanding multiple hosts
CN111176164A (en) Method, device and medium for expanding multiple remote input and output modules
CN103605622B (en) A kind of method and apparatus transmitting data

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