CN105278918B - The read method of register and the register using the read method - Google Patents

The read method of register and the register using the read method Download PDF

Info

Publication number
CN105278918B
CN105278918B CN201510673664.9A CN201510673664A CN105278918B CN 105278918 B CN105278918 B CN 105278918B CN 201510673664 A CN201510673664 A CN 201510673664A CN 105278918 B CN105278918 B CN 105278918B
Authority
CN
China
Prior art keywords
response
communication
reading
time
read
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.)
Expired - Fee Related
Application number
CN201510673664.9A
Other languages
Chinese (zh)
Other versions
CN105278918A (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.)
Gree Electric Appliances Inc of Zhuhai
Original Assignee
Gree Electric Appliances Inc of Zhuhai
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 Gree Electric Appliances Inc of Zhuhai filed Critical Gree Electric Appliances Inc of Zhuhai
Priority to CN201510673664.9A priority Critical patent/CN105278918B/en
Publication of CN105278918A publication Critical patent/CN105278918A/en
Application granted granted Critical
Publication of CN105278918B publication Critical patent/CN105278918B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention discloses a kind of read method of register and the register using this method, and wherein read method comprises the following steps:1) calculate and take the total communication time Tsum1 for once asking response for not being segmented reading manner;2) the total communication time Tsum2 for once asking response for taking segmentation reading manner is calculated;3) compare Tsum1 and Tsum2, used according to the determination of the individual numerical value of idle address and be not segmented reading manner or segmentation reading manner.Read method of the present invention can help to judge to read using segmentation in Modbus RTU are communicated still not to be segmented reading manner, so as to the suitable reading manner of optimum selecting, effectively improve communication efficiency when reading register.

Description

The read method of register and the register using the read method
Technical field
The present invention relates to digital independent field, and in particular to a kind of read method of register;The invention further relates to one kind A kind of register, and in particular to discontinuous address space holding register using the read method.
Background technology
In Modbus communications protocol contents, due to reserved or other reasons, the input register or holding register of slave Address space it is often discontinuous, often vacant a part of address of intermittent in address space, so work as host computer When being monitored in real time to the slave in bus and constantly reading its running status, for the digital independent of discontinuous address space Mode just turns into the key for influenceing its communication efficiency.Traditional reading manner for discontinuous address space register mainly wraps Include the following two kinds mode:Mode one, reading is not segmented, that is, once read all interior from lowest address to maximum address Hold, including the reserved or content of vacant intermediate address due to other reasons, and only parse significant in institute's reading of content Part;Mode two, segmentation is read, that is, is read one by one respectively in discontinuous address space in the data of each contiguous segmentation part Hold.
In view of the factor such as slave addresses, function code, initial address, register capacity, check byte in reading order Influence, during vacant scope narrow (between such as two significant addresses an only vacant address) in address, the phase of mode one Communication efficiency can be improved for mode two, but when the vacant scope in address is wider (between such as two significant address segmentations Vacant 100 addresses), although mode two needs twi-read, caused communication time (including shared by Twice requests frame Time, twice the time shared by response frame, two request before the dead time and two response before the dead time) it is often small In communication time caused by mode one (time shared by time, a response frame shared by a claim frame, one please Ask the preceding dead time, one response before the dead time).In summary, both modes, it is vacant to be respectively suitable for different addresses Situation, it is therefore desirable to according to the vacant situation of address space and combine specific communication process parameter optimum selecting reading manner.
The content of the invention
A kind of read method of register and the register using the read method are provided in the embodiment of the present invention, to solve The problem of can not effectively being read when the address space of register occurs vacant in the prior art.
To achieve the above object, the present invention provides a kind of read method of register, and it comprises the following steps:1) calculate and adopt Take the total communication time Tsum1 for once asking response for not being segmented reading manner;2) calculate and take segmentation reading manner once Ask total communication time Tsum2 of response;3) compare Tsum1 and Tsum2, according to the individual numerical value of idle address determine using regardless of Section reading manner or segmentation reading manner.
Preferably, total communication time of response is once asked to include dead time T1 before asking, dead time before response T2, claim frame holding time and response frame holding time.
Preferably, work as e1>(Br/16) when (104/Br+T1+T2), selection segmentation reading manner, wherein, e1 is vacant Address number, Br be serial communication baud rate.
Preferably, under Modbus-RTU communication modes, the claim frame of read input register and holding register is fixed For 8 bytes, response frame is 5+2*n byte, wherein, n is expressed as the address number once read.
Preferably, the communication total time for once asking response for not being segmented reading manner is:Tsum1=(16/Br) * (n1+e1+n2)+(104/Br+T1+T2), wherein, n1 and the number that n2 is two sections of effective addresses.
Preferably, the communication total time for once asking response of segmentation reading manner is:Tsum2=(16/Br) * n1+ (104/Br+T1+T2)+(16/Br)*n2+(104/Br+T1+T2)。
Preferably, dead time T1 is determined that the dead time, T2 was by bottom before response by upper machine communication main frame before request Machine communication slave determines.
The present invention also provides discontinuous address space holding register in a kind of Modbus-RTU communications, and it uses above-mentioned skill Read method in art scheme.
Read method of the present invention can help to judge to read still not using segmentation in Modbus-RTU communications Reading manner is segmented, so as to the suitable reading manner of optimum selecting, effectively improves communication efficiency when reading register.
Brief description of the drawings
Fig. 1 is the communication total time schematic diagram that response is asked in read method of the present invention;
Fig. 2 is with vacant Modbus communication protocol address configuration schematic diagrams in read method of the present invention.
Embodiment
The present invention is described in further detail with specific embodiment below in conjunction with the accompanying drawings, but not as the limit to the present invention It is fixed.
Fig. 1 shows the communication time schematic diagram that response is asked in communication, as can be seen from Figure 1 once asks response Time includes before asking dead time, response frame holding time before dead time, claim frame holding time, response.Therefore, counting When calculating the communication total time for once asking response, the baud rate for communication of setting up serial ports first is Br, is paused before concurrently setting request The dead time is set to T1 and T2 before time and response, sets claim frame holding time as Trequest, when response frame takes Between be Tresponse, then once ask response communication total time be Tsum, its expression is as follows:
Tsum=T1+T2+Trequest+Tresponse.
Under Modbus-RTU communication modes, the claim frame of read input register and holding register is fixed as 8 bytes, Response frame is 5+2*n byte (n is expressed as the address number once read), and claim frame, the frame format of response frame are respectively such as table 1st, shown in table 2:
Table 1 asks frame format
Device address Function code Initial address Data bulk CRC check code
1 Byte 1 Byte 2 Bytes 2 Bytes 2 Bytes
The response frame form of table 2
Device address Function code Byte number Valid data CRC check code
1 Byte 1 Byte 1 Byte n Bytes 2 Bytes
Then:
Claim frame holding time Trequest=(8/Br) * 8
Response frame holding time Trequest=(8/Br) * (5+2*n)
So the communication total time for once asking response is:
Tsum=T1+T2+Trequest+Tresponse=(16/Br) * n+ (104/Br+T1+T2)
Typically in the communication of specifically monitored system, the baud rate Br of serial communication is fixed, the dead time before request T1 can be determined that dead time T2 is determined by slave computer (communication slave) before response by host computer (host computer communication), it is possible thereby to Find out, once the communication total time of request response and the address number n of read access are linear.
Fig. 2 is shown to be configured with vacant Modbus communication protocol addresses, wherein, the number difference of two sections of effective addresses For n1 and n2, vacant address number is e1 therebetween.The embodiment of the present invention can be examined simultaneously according to the vacant situation of address space Consider serial communication baud rate and request before the dead time and response before the dead time, by compare communication total time, not Preferentially made a choice in segmentation reading manner and segmentation reading manner.
When the register of non-address continuous space is read under Modbus communications protocol, that is, there are specific vacant feelings Communication total time calculation under condition is as follows:
Take be not segmented reading manner once ask response communication total time be:
Tsum1=(16/Br) * (n1+e1+n2)+(104/Br+T1+T2)
Take segmentation reading manner once ask response communication total time be:
Tsum2=(16/Br) * n1+ (104/Br+T1+T2)+(16/Br) * n2+ (104/Br+T1+T2)
By above-mentioned formula, we may determine that occur it is specific it is vacant in the case of using not being segmented reading manner and segmentation is read Take difference of the mode on communication total time.By comparing Tsum1 and Tsum2, calculate and work as Tsum1>Tsum2 (i.e. read by segmentation Mode is taken to be better than not being segmented reading manner) when, i.e. e1>(Br/16) when (104/Br+T1+T2), the communication for being segmented reading manner is total The communication total time that time is not segmented reading manner relatively is shorter.
Therefore, for the specific communication for using Modbus/RTU patterns, dead time T1 and sound before baud rate Br, request In the case of should fixing preceding dead time T2 (generally, these parameters are all fixed), the number of idle address exists In the case of (Br/16) (104/Br+T1+T2), selection segmentation reading manner reads register, otherwise uses and is not segmented reading Mode is taken to read register.
Embodiments of the invention are only the descriptions carried out to the preferred embodiment of the present invention, not to present inventive concept and Scope is defined, on the premise of design philosophy of the present invention is not departed from, skill of the engineers and technicians to the present invention in this area The all variations and modifications that art scheme is made, all should fall into protection scope of the present invention, the claimed technology contents of the present invention, All record in detail in the claims.

Claims (3)

1. a kind of read method of register, it is characterised in that comprise the following steps:1) calculate to take and be not segmented reading manner Once ask total communication time Tsum1 of response;2) calculate and take when once asking total communication of response of segmentation reading manner Between Tsum2;3) the Tsum1 and Tsum2, reading is not segmented according to the individual numerical value of idle address determines use Mode or the segmentation reading manner, described be not segmented are read as once reading in all from lowest address to maximum address Hold, only parse part significant in institute's reading of content;The segmentation is read as reading one by one in discontinuous address space respectively The data content of each contiguous segmentation part;
Wherein, under Modbus-RTU communication modes, the claim frame of read input register and holding register is fixed as 8 words Section, response frame is 5+2*n byte, and n is expressed as the address number once read;The once request for not being segmented reading manner The communication total time of response is:Tsum1=(16/Br) * (n1+e1+n2)+(104/Br+T1+T2), the segmentation reading manner Once ask response communication total time be:Tsum2=(16/Br) * n1+ (104/Br+T1+T2)+(16/Br) * n2+ (104/Br+T1+T2), n1 and n2 are the number of two sections of effective addresses;
It is described once to ask total communication time of response to include dead time T1 before asking, dead time T2, claim frame before response Holding time and response frame holding time;
Work as e1>(Br/16) when (104/Br+T1+T2), the segmentation reading manner is selected, wherein, e1 is vacant address Number, Br are the baud rate of serial communication.
2. read method according to claim 1, it is characterised in that the dead time, T1 was by upper machine communication before the request Main frame determines that dead time T2 is determined by slave computer communication slave before the response.
3. discontinuous address space holding register in a kind of Modbus-RTU communications, it is characterised in that employ any of the above-described Read method described in item claim.
CN201510673664.9A 2015-10-15 2015-10-15 The read method of register and the register using the read method Expired - Fee Related CN105278918B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510673664.9A CN105278918B (en) 2015-10-15 2015-10-15 The read method of register and the register using the read method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510673664.9A CN105278918B (en) 2015-10-15 2015-10-15 The read method of register and the register using the read method

Publications (2)

Publication Number Publication Date
CN105278918A CN105278918A (en) 2016-01-27
CN105278918B true CN105278918B (en) 2017-12-08

Family

ID=55147988

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510673664.9A Expired - Fee Related CN105278918B (en) 2015-10-15 2015-10-15 The read method of register and the register using the read method

Country Status (1)

Country Link
CN (1) CN105278918B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106843807A (en) * 2016-12-22 2017-06-13 天津力神特种电源科技股份公司 The adjustment method that vehicle-mounted Li-ion batteries piles are quickly analyzed and positioned
CN106781403A (en) * 2017-02-23 2017-05-31 湖南工业大学 A kind of communication technology of the remote data transmission based on LORA and GPRS
CN111884915A (en) * 2020-07-17 2020-11-03 杭州电子科技大学 Method for improving efficiency of acquiring modbus equipment by gateway
CN112073280B (en) * 2020-09-07 2022-04-08 阳光新能源开发股份有限公司 Communication method and device based on Modbus protocol and communication equipment
CN112256617B (en) * 2020-10-23 2021-04-20 福州富昌维控电子科技有限公司 Method and terminal for improving serial port communication efficiency of equipment
CN112291101B (en) * 2020-11-06 2021-12-07 珠海格力电器股份有限公司 Communication node and communication framing optimization method of upper computer to lower computer

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5862391A (en) * 1996-04-03 1999-01-19 General Electric Company Power management control system
CN101739328A (en) * 2009-12-16 2010-06-16 台安科技(无锡)有限公司 Method for enhancing speed of PC in monitoring singlechip through ModBus protocol
CN103546467A (en) * 2013-10-23 2014-01-29 上海爱控自动化设备有限公司 Method for transmitting Modbus RTU protocol on TCP/IP network
CN104038499A (en) * 2014-06-17 2014-09-10 宁波三星电气股份有限公司 MODBUS RTU protocol based data transmission method
CN104052631A (en) * 2014-05-22 2014-09-17 中兴通讯股份有限公司 Equipment information collecting method, device and system
CN104407983A (en) * 2014-12-02 2015-03-11 上海电器科学研究院 Modbus address remapping method used for electric quantity module
CN104486185A (en) * 2014-12-12 2015-04-01 中广核工程有限公司 Control system communication method and system for nuclear power plant
CN104601420A (en) * 2014-12-31 2015-05-06 江西清华泰豪三波电机有限公司 Method for flexibly reading power station data by utilizing Modbus

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8150950B2 (en) * 2008-05-13 2012-04-03 Schneider Electric USA, Inc. Automated discovery of devices in large utility monitoring systems

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5862391A (en) * 1996-04-03 1999-01-19 General Electric Company Power management control system
CN101739328A (en) * 2009-12-16 2010-06-16 台安科技(无锡)有限公司 Method for enhancing speed of PC in monitoring singlechip through ModBus protocol
CN103546467A (en) * 2013-10-23 2014-01-29 上海爱控自动化设备有限公司 Method for transmitting Modbus RTU protocol on TCP/IP network
CN104052631A (en) * 2014-05-22 2014-09-17 中兴通讯股份有限公司 Equipment information collecting method, device and system
CN104038499A (en) * 2014-06-17 2014-09-10 宁波三星电气股份有限公司 MODBUS RTU protocol based data transmission method
CN104407983A (en) * 2014-12-02 2015-03-11 上海电器科学研究院 Modbus address remapping method used for electric quantity module
CN104486185A (en) * 2014-12-12 2015-04-01 中广核工程有限公司 Control system communication method and system for nuclear power plant
CN104601420A (en) * 2014-12-31 2015-05-06 江西清华泰豪三波电机有限公司 Method for flexibly reading power station data by utilizing Modbus

Also Published As

Publication number Publication date
CN105278918A (en) 2016-01-27

Similar Documents

Publication Publication Date Title
CN105278918B (en) The read method of register and the register using the read method
US11341061B2 (en) Address translation method, apparatus, and system
CN103546467B (en) The method applying Modbus rtu protocol on TCP/IP network
CN106951388A (en) A kind of DMA data transfer method and system based on PCIe
US9178839B2 (en) Sharing buffer space in link aggregation configurations
CN102362464A (en) Memory access monitoring method and device
US10198374B2 (en) Configurable on-chip interconnection system and method and apparatus for implementing same, and storage medium
CN103353851A (en) Method and equipment for managing tasks
CN104765701B (en) Data access method and equipment
WO2023207361A1 (en) Memory management method, system, device and computer readable storage medium
WO2011102698A2 (en) Method and apparatus for device synchronization and power conservation in a wireless communication system
US20130061009A1 (en) High Performance Free Buffer Allocation and Deallocation
CN110191204A (en) A kind of Intranet communication between devices method, system, device and computer storage medium
CN109426623A (en) A kind of method and device reading data
WO2019174206A1 (en) Data reading method and apparatus of storage device, terminal device, and storage medium
JP2012089948A (en) Data transmission device and data transmission method
CN104346131B (en) A kind of host control method for supporting batch to read and write slave register
CN105760310A (en) Address assignment method and DDR controller
US20190087351A1 (en) Transaction dispatcher for memory management unit
EP3534576A1 (en) Packet transmission
CN106776393B (en) uninterrupted serial port data receiving method and device
CN105183390B (en) Data access method and device
WO2017070869A1 (en) Memory configuration method, apparatus and system
WO2016086686A1 (en) Baseband resource management method and device
US10606751B2 (en) Techniques for cache delivery

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20171208