CN103856578A - Automatic slave station address acquisition method through Modbus RTU and slave station - Google Patents

Automatic slave station address acquisition method through Modbus RTU and slave station Download PDF

Info

Publication number
CN103856578A
CN103856578A CN201410003527.XA CN201410003527A CN103856578A CN 103856578 A CN103856578 A CN 103856578A CN 201410003527 A CN201410003527 A CN 201410003527A CN 103856578 A CN103856578 A CN 103856578A
Authority
CN
China
Prior art keywords
address
slave station
station
network
modbus rtu
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.)
Granted
Application number
CN201410003527.XA
Other languages
Chinese (zh)
Other versions
CN103856578B (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.)
Southwest University
Original Assignee
Southwest University
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 Southwest University filed Critical Southwest University
Priority to CN201410003527.XA priority Critical patent/CN103856578B/en
Publication of CN103856578A publication Critical patent/CN103856578A/en
Application granted granted Critical
Publication of CN103856578B publication Critical patent/CN103856578B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The invention discloses an automatic slave station address acquisition method through Modbus RTU and a slave station. The method includes the step that the slave station sends an address reuse detection packet to a communication link of a Modbus RTU network where the slave station is located, wherein the address reuse detection packet comprises a temporary station address and is used for detecting whether the temporary station address is occupied by other slave stations in the Modbus RTU network, and if the detection result shows that the temporary station address is not occupied by other slave stations in the Modbus RTU network, the slave station uses the temporary station address as a fixed communication address of the slave station. According to the method, the problem that the slave station can not obtain the station address automatically can be solved, so plug and play of the slave station can be achieved, and the flexibility and the expandability of the Modbus RTU can be improved.

Description

Modbus RTU slave station automatic acquisition station address method and slave station
Technical field
The present invention relates to industrial network control technical field, relate in particular to method and the slave station of slave station automatic acquisition station address in a kind of Modbus RTU.
Background technology
Modbus(bus) be by Modicon(Mo Dikang) company was in invention in 1979, the whole world is first really for the bus protocol of industry spot, and it,, through several years development, has been widely used and can on serial communication or Ethernet, have realized.Wherein Modbus is mainly divided into ASCII(American Standard Code for Information Interchange according to transmission mode, ASCII) pattern or RTU(Remote Terminal Unit, remote-terminal unit) pattern, the Modbus based on these two kinds of patterns is called respectively " Modbus ASCII " and " ModbusRTU " by those skilled in the art.
For Modbus RTU, its link protocol is MS master-slave agreement, at one time, bus can have at least one slave station, but Neng Youyige main website only, and communication is initiated request by main website, the request of slave station response main website and realizing, concrete main website can initiate and the communicating by letter of slave station with unicast mode and broadcast mode, and wherein unicast mode refers to the single slave station of main website addressing, addressed slave station receives and processes the request of main website, and returns to response to main website handling after request; Wherein broadcast mode refers to that main website sends request to all slave stations, and this request only limits to write order, and slave station need not return and replys.
At present for slave station in Modbus RTU in the time that it networks, it need to be its configuration station address, wherein the configuration mode of station address mainly comprises hardware setting and software distribution, wherein hardware setting refers to by toggle switch combination or hand-held setting apparatus are set, select certain communication station address, realize manual configuration; Wherein software distribution is generally by main website in Modbus RTU, slave station to be carried out to address assignment to realize.But along with the expansion of number of network node, system equipment personnel constantly increase the management difficulty of station address, easily cause network station address to use and obscure, each station address effect and use interrogatory are true.Especially for the mode of carrying out address assignment by main website, complicated network topology structure and task relation increase severely the identification difficulty of main website and complexity, be difficult to realize the automatic distribution function in address, and realize and usually occurring in netinit and failover procedure for traditional automatic address configuration mode, each network service station is by the abnormal behaviour of Sampling network, realize the automatic distribution of the network address, but normally in service at network, whether system None-identified has new node to add, be that slave station does not possess plug and play capabilities, a little less than flexibility and expandability.
Summary of the invention
In view of this, the invention provides method and the slave station of slave station automatic acquisition station address in a kind of Modbus RTU, for solving the problem that slave station cannot automatic acquisition station address, make slave station can realize plug and play, improve flexibility and the expandability of Modbus RTU.
The invention provides a kind of Modbus RTU slave station automatic acquisition station address method, comprising:
Slave station sends address multiplex detection packet to the communication link of the Modbus RTU network at place, described address multiplex detection packet comprises interim station address, and whether described address multiplex detection packet is used for surveying described interim station address and is taken by described other slave station of Modbus RTU network;
When result of detection be described interim station address not by described Modbus RTU network in other slave station while taking, described slave station takies the fixed communication address of this interim station address as described slave station.
Further, described slave station also comprises before sending address multiplex detection packet: described slave station is according to the idle address of network address list calculated address value minimum as described interim station address, and described network address list is for recording the station address having been taken by other slave station that described slave station detects.
Further, described slave station sends address multiplex detection packet to the communication link of the Modbus RTU network at place, comprising:
When described slave station detects the described communication link free time, produce the random delay time;
In the time that described delay time at any time arrives, described slave station sends described address multiplex detection packet to the communication link of place Modbus RTU network.
Further, in the time that described slave station at least twice transmission does not all receive that containing the address multiplex detection packet of same interim station address detection is replied, described result of detection is not just taken by other slave station in described Modbus RTU network for described interim station address.
Further, described slave station also comprises after taking the fixed communication address of this interim station address as described slave station: in the time that described slave station receives the address multiplex detection packet containing this fixed communication address, make detecting and reply.
Further, described slave station also comprises after taking the fixed communication address of this interim station address as described slave station:
Described slave station, according to described fixed communication address, sends networking request bag to main website;
Described slave station respond described main website receive send after described networking request bag for asking the request report of described slave station essential information.
The present invention also provides a kind of slave station for Modbus RTU automatic acquisition station address, comprising:
Detecting module, communication link for from the Modbus RTU network to place sends address multiplex detection packet, described address multiplex detection packet comprises interim station address, and whether described address multiplex detection packet is used for surveying described interim station address and is taken by described other slave station of Modbus RTU network;
Processing module, for when result of detection being described interim station address while not taken by described other slave station of Modbus RTU network, described slave station takies the fixed communication address of this interim station address as described slave station.
Further, also comprise: interim station address generation module, for according to the idle address of network address list calculated address value minimum as described interim station address, described network address list is for recording the station address having been taken by other slave station that described slave station detects.
Further, described detecting module, comprising:
Random delay time generation unit, in the time detecting the described communication link free time, produces the random delay time;
Transmitting element, in the time that described delay time at any time arrives, described slave station sends described address multiplex detection packet to the communication link of place Modbus RTU network.
Further, also comprise: networking module, for according to described fixed communication address, sends networking request bag to main website; And for respond described main website receive send after described networking request bag for asking the request report of described slave station essential information.
Beneficial effect of the present invention:
The embodiment of the present invention, whether the interim station address being sent in address multiplex detection packet detection address multiplex bag to communication link by slave station is taken by other slave station, when result of detection is while being unoccupied, slave station takies this interim station address, thereby solve the how problem of automatic acquisition station address of slave station, thereby realize the automatic network-building of the network equipment, make can realize task control and separating that Modbus RTU communicates by letter in planned network systematic procedure, strengthen the flexibility of network design and management, simultaneously in the replacement of the network equipment and the process of expansion, can realize the plug and play of equipment, without configuring static mailing address, strengthen the utilance of mailing address, in addition, in the process of single or multiple new networking slave station automatic acquisitions address, Modbus RTU main website will not participate in station address and assigns or intervene, greatly reduce the load of main website.
Brief description of the drawings
Below in conjunction with drawings and Examples, the invention will be further described:
Fig. 1 is the topological diagram of Modbus RTU network.
Fig. 2 is the schematic flow sheet of the first embodiment of Modbus RTU slave station automatic acquisition station address method provided by the invention.
Fig. 3 is the schematic flow sheet of the second embodiment of Modbus RTU slave station automatic acquisition station address method provided by the invention.
Fig. 4 is the schematic flow sheet of the 3rd embodiment of Modbus RTU slave station automatic acquisition station address method provided by the invention.
Fig. 5 is the detail flowchart of slave station automatic acquisition station address provided by the invention.
Fig. 6 is the flow chart that the identification of Modbus RTU main website newly enters network slave station.
Fig. 7 is the schematic diagram of a kind of practical application methods of the present invention.
Fig. 8 is the structural representation of the embodiment of the slave station for Modbus RTU automatic acquisition station address provided by the invention.
Embodiment
As shown in Figure 1, it is the topological diagram of Modbus RTU network, it is mainly made up of a Modbus RTU main website and several Modbus RTU slave stations, wherein between each station, connects by RS-485 bus, and accesses respectively the terminal resistance of 120 Ω at 485 bus two ends.In Modbus RTU network, between each station, communication all adopts this bus transfer, and each correct communication message all meets Modbus RTU transport protocol standard.
Regulation according to Modbus RTU transport protocol standard: first communication initiates request by main website to slave station, and the main website of Modbus RTU can only initiate a communications transaction at every turn, in network, all slave stations all can receive this request message, then by resolving the address field content of this message, judge whether this content is this station address, if make corresponding response, otherwise abandon this message.Wherein the effective range of address field is 1-247, and other No. 0 address is broadcast address, and all slave stations all do not carry out message while receiving " No. 0 address " request and reply.
Regulation according to Modbus RTU transport protocol standard: Modbus RTU adopts master-slave communication pattern.First network service initiate request (carrying the station address of slave station) by main website to certain slave station, this request is received by slave stations all in network, slave station receives after request, the station address that carries in request and the station address of itself are compared, if identical, illustrate that this request mails to our station, need to reply, if not identical, illustrate that this request and our station are irrelevant, abandon request.
That is to say, in Modbus RTU network, if network arbitrary node initiating communication, other all nodes all can receive this message, and then each slave station determines whether by the address field of detection messages our station data are to determine whether reply.Based on this, the embodiment of the present invention is recognized: when slave station is wanted to obtain station address, can be with the identity of interim main website (pseudo-main website), in network, send the multiplexing detection bag that comprises certain address, if this address is taken by other slave station, slave station will receive that other slave station that takies this address replys accordingly so, if this address is not taken by other slave station, slave station can not be received accordingly and reply, and now slave station can take this station address.Based on this thinking, the invention provides following technical thought.
Please refer to Fig. 2, is the schematic flow sheet of the first embodiment of Modbus RTU slave station automatic acquisition station address method provided by the invention, and it comprises:
Step S21, slave station send address multiplex detection packet to the communication link of the Modbus RTU network at place.
Wherein, slave station can be the new slave station networking, and it will complete networking must obtain an occupation of land location not taken by current other slave station that has completed networking.Or slave station can be the slave station having networked, but due to failure cause, need to again obtain station address, thereby avoid this tributary address to be taken by other communication slave stations in failure process.
Wherein, address multiplex detection packet comprises interim station address.
Wherein, whether address multiplex detection packet is taken by other slave station of Modbus RTU network for the interim station address of surveying wherein.From Modbus RTU host-host protocol, if this interim station address is taken by certain slave station in Modbus RTU network, receive after address multiplex detection packet when this slave station so, will do accordingly and reply.
Wherein, the particular content of address multiplex detection packet is mainly made up of Modbus RTU diagnostic function code 08H and subfunction code 00H00H, according to Modbus rtu protocol code requirement, protocol data bag (being Protocol Data Unit, referred to as " PDU ") corresponding to this address multiplex detection packet can be expressed as: 08H00H00H.
Concrete, step S21 can comprise: when slave station detects the communication link free time, produce the random delay time; In the time that the random delay time arrives, slave station sends address multiplex detection packet to communication link.Herein, the communication link free time refers to that this shows that previous frame message is sent completely from least 3.5 character times till now time that finally receives character.Herein, the generation of random delay time can be called random delay function and realized by slave station.Herein, detecting communication link when idle, do not send immediately address multiplex detection packet but probability that the benefit that sends again address multiplex detection packet after taking time delay a period of time is the address multiplex detection packet that can the new log equipment of Avoids or reduces (being new networking slave station) sends conflicts with other communication messages.
Step S22, when result of detection for this interim station address not by Modbus RTU network in other slave station while taking, slave station takies the fixed communication address of this interim station address as this slave station.
Wherein, in the time that slave station at least twice transmission does not all receive that containing the address multiplex detection packet of same interim station address detection is replied, result of detection is not just taken by other slave station in Modbus RTU network for interim station address, can improve like this accuracy.Herein, twice identical address multiplex detection packet should keep enough transmission intervals, to ensure that other slave station has time enough response.
Wherein, after not receiving and detecting and reply and refer to that slave station sends address multiplex detection packet, in official hour, do not receive any message, although or receive that in official hour message, the message of receiving are not all replying of doing for address multiplex detection packet.
In addition, in the process of slave station automatic acquisition address, in Modbus RTU, main website will not do any processing to this behavior, and, when main website receives after address multiplex detection packet, because this message is non-main website request-reply, main website sets it as invalid packet and casts out.
The present embodiment, each new networking slave station all will be simulated master function, send address multiplex detection packet at network idle phase, these slave stations can be referred to as to interim pseudo-main website.And will can not do any reaction to address multiplex detection behavior in this course for real Modbus RTU main website, and just set it as an invalid communications packets to ignoring.Between pseudo-main website and real Modbus ASCII main website, be to act on the different periods, between the two, do not conflict.And after new networking slave station completes mailing address automatic acquisition, the function of interim pseudo-main website will be lost.
The present embodiment, whether the interim station address being sent in address multiplex detection packet detection address multiplex bag to communication link by slave station is taken by other slave station, when result of detection is while being unoccupied, slave station takies this interim station address, thereby solve the how problem of automatic acquisition station address of slave station, thereby realize the automatic network-building of the network equipment, make can realize task control and separating that Modbus RTU communicates by letter in planned network systematic procedure, strengthen the flexibility of network design and management, simultaneously in the replacement of the network equipment and the process of expansion, can realize the plug and play of equipment, without configuring static mailing address, strengthen the utilance of mailing address, in addition, in the process of single or multiple new networking slave station automatic acquisitions address, Modbus RTU main website will not participate in station address and assigns or intervene, greatly reduce the load of main website.
Please refer to Fig. 3, is the schematic flow sheet of the second embodiment of Modbus RTU slave station automatic acquisition station address method provided by the invention, and it comprises:
Step S31, slave station according to the idle address of network address list calculated address value minimum as interim station address.
The step S32-step S33 identical with step S21-step S22 difference.
Wherein, network address list is for recording the station address having been taken by other slave station that slave station detects.
Wherein, in network address list, the length of each element is a byte, and because tributary address in Modbus RTU is 1-247, therefore the maximum length of network address list is 247.
Wherein, for slave station, it is empty that network address list is initially, and is CA when slave station receives station address icommunication data packet time, show this station address CA itaken by other slave stations, slave station is by CA iadd in network address list, wherein CA i∈ U, U={1,2 ..., 247}.In addition, when slave station is with station address CA isurvey as interim station address, if receive while replying accordingly, also show this station address CA ioccupied, slave station is also added in network address list.
Wherein, the idle address that slave station obtains address value minimum according to network address list is during as interim station address, and wherein idle address is in 1-247 station address, to remove in network address list to have detected and had { FCA by occupied station address i| FCA i∈ U-AT}, wherein FCA ifor idle address set, AT is used station address set (wherein this set element is corresponding one by one with network address list content) for this slave station has detected.Obviously, idle network address number is greater than 1, and then step S31 selects the wherein minimum interim station address of conduct, i.e. MIN (FCA i).
Please refer to Fig. 4, is the schematic flow sheet of the 3rd embodiment of Modbus RTU slave station automatic acquisition station address method provided by the invention, and it comprises:
The step S41-step S42 identical with step S11-step S12.
Step S43, slave station, according to the fixed communication address obtaining, send networking request bag to main website.
Wherein, networking request bag R (CA i) request function code be 11H, the networking request bag R (CA based on Modbus RTU i) form be: MIN (FCA i), 11H, CRC_L, CRC_H.
Wherein, adopted the mode of step S41 and step S42 to obtain the slave station transmission networking request bag R (CA of fixed communication address i) carry out after still needing to wait for idle and random delay a period of time of network.
Step S44, slave station response main website receive send after networking request bag for asking the request report of slave station essential information.
Wherein, in each slave station, all there is the parameter θ of the essential information at this station of mark i, this parameter comprises the essential information such as type, function of slave station.
Wherein, R (CA in the time that main website in Modbus RTU receives networking request bag i), illustrate that station address is MIN (FCA i) slave station asking networking identification, main website, by request report slave station ID (function code: 11H), identifies the essential information of the slave station of this request networking identification so, to complete networking identification.
Wherein, in waiting for the slave station of main website cognitive phase, when it is received after main website request message, by facility information θ iaccording to Modbus RTU function code 11H specification encapsulation, then reply to main website, can enter normal communication mode to this for this slave station.
In addition, when slave station takies behind the fixed communication address of this interim station address as this slave station, even if slave station, in the time that networking request stage receives the address multiplex detection packet containing this fixed communication address, is also made corresponding detection and replied, represent that this station address is occupied.
In addition, analyzed from above embodiment: for main website in Modbus RTU, in processing communication things process, it receives network service bag and is totally divided into three kinds of situations:
1, the request response message of slave station.This message normally occurs in Modbus RTU main website and sends after communication request, the response that in network, corresponding slave station is made.In this process, Modbus RTU slave station is according to this message of protocol specification normal process.
2, the slave station request message that newly networks.The method of the automatic acquisition station address providing according to the embodiment of the present invention, in the address detected stage, main station will not participate in any roles such as address assignment.And obtain after effective address when slave station, cannot be obtained the information of this slave station by main website, initiatively send networking request communication message bag to network primary station by slave station.In the time that main website receives the message bag of this form, representing has new slave station to add in network, waits for main website identification.Then Modbus RTU main website initiatively initiates request slave station ID to this slave station, identifies device type and the function etc. of this slave station.
3, Network Abnormal message.This message generally comprises, garble message (comprise that CRC inspection is wrong, parity errors, character overflow etc.), unsolicited message.Wherein, for main website, address multiplex probe messages also will be considered unsolicited message.
Please refer to Fig. 5; it is the detail flowchart of slave station automatic acquisition station address provided by the invention; many details that it has comprised the embodiment of the present invention; this contributes to help to understand the present invention; but to those skilled in the art; it is only preferably technical scheme of the present invention that this many details limits the technical scheme forming, and should not be construed as unique implementation of the present invention or the restriction to protection range.The flow process of Fig. 5 comprises:
Step S501, after slave station starts, initialization self configuration.
Wherein initialization self configuration comprises system configuration initialization, communication initialization, parameter initialization etc.
In addition, slave station automatic acquisition station address mode provided by the invention needs define grid address table AT, and its maximum length is 247, and each element is without symbol-byte type, and its effect is mainly used in storing this equipment station and detects by used mailing address.
Then, definition address multiplex probation counter C1 and networking request counter C2, be respectively used to calculate the number of times of the multiplexing detection times of interim station address and networking request identification.
Finally, slave station configures relevant communication timer, response timeout timer and random delay timer etc.
Step S502, after device initialize completes, then according to network address list AT, obtain minimum idle address, prepare address multiplex probe messages, and zero clearing counter C1 and C2.The content according to the present invention, if now network is communicating message transmissions, continues to wait for link idle.If now link is idle condition, produce a random number according to preset random delay strategy, then set delay time, open time delay timer.
In the slave station of time delay wait, need the information of Real-Time Monitoring communication link.If before time delay finishes, network link, without any communication behavior, sends off-the-shelf address multiplex detection packet.If link packet transmission detected in this stage, abandon the chance that this address multiplex sends, then wait for link idle next time.In this simultaneously, slave station receiver message information.
Step S503, in the time that slave station has received new message, check basic communication mistake, comprising CRC(Cyclic Redundancy Check, cyclic redundancy check (CRC) code) verification, character parity, character overflow checking, the checking of communication message length and the overtime checking of interframe character etc.If verification inerrancy enters step S504, resolve this message, then enter step S505; If wherein there is a condition not meet and enter step S507.
Step S504, inspection address field content, obtain station address wherein.
If the station address that step S505 step S504 obtains is identical with the interim station address of our station, illustrate that this station address is taken by other slave stations, then enter S506 and process.If this content is not equal to our station temporary address, show that other equipment stations communicate by letter, then cast out this invalid communications packets, directly enter step 507.
Step 506, through step S505 judgement, conflict with other stations in the address that our station has obtained, according to the rule of " first detection, first obtains ", our station must be abandoned taking of this address, avoids address conflict.First network address list need to be upgraded in this station, and this station address is added in network address list, provides reliability foundation for obtaining the idle address of network next time.Then our station again again obtains the idle address of minimal network and prepares address multiplex detection packet according to network address list, waits for link idle, prepares the address detected on Xin Yi road, and this step is as step S502.Meanwhile, this station needs zero clearing counter C1 and C2, avoids historical data to bring error message to testing result.
Step S507, judge response whether overtime.The present invention surveys to judge by address multiplex whether the acquired address of our station repeats with other stations.In step S502, S506, S510, send after address multiplex detection packet at every turn, all will start the response timeout timer of our station.If the set of response timeout flag bit, enters step S508, detect whether there is new message otherwise enter step S502.
Step S508, request response timeout detected when this communication station, by address multiplex probation counter C1 cumulative 1.
Herein, the effect of address multiplex probation counter C1 is for recording this station, the address of existing use have been sent and detected bag number of times, and does not all receive the relevant detection in this station and reply.Can strengthen the reliability that uses this address to the repeated detection of address multiplex, avoid the misleading because network is busy or garble brings.
Step S509, judge that address multiplex tests the higher limit whether having reached.If C1 accumulative total response timeout number of times is more than or equal to this higher limit, enter next step S511, show that this station has obtained network idle address success, successfully enters networking request stage.If this Counter Value is less than this higher limit, enter step S510.
Step S511, send after address multiplex detection packet in view of the last time, do not receive respective communication station and reply,, in this step, send networking request, and restart response timeout timer.
In the address detected stage, after new traffic is successfully obtained station address from station equipment, possesses basic communication ability.But this process is between network service slave station, by obtaining this free time address in the mode of pseudo-main website request, network primary station does not participate in the task of this address automatic acquisition, and (being slave station) joined in this system not know there is new network node.Object of the present invention is exactly to realize can detecting that in any stage of the network operation network has the access of new traffic equipment.So at networking cognitive phase, this new traffic slave node is by sending specific request identification message bag, the information such as type, function of notice main website identification equipment of itself to network primary station.In step S511, when this station detects network idle, send networking request message bag to bus links.Also starting-up response overtime timer of while, and zero clearing networking request counter C2, then enter in step S512 and detect link packet.
An important function of the present invention can be supported multiple from station equipment while access network exactly simultaneously, and completes the task of corresponding automatic acquisition address.Obtain the slave station of the idle address of network, when having detected that other slave stations detect this station address when whether occupied, this slave station should be replied test, as step S514, show that this address is occupied, then enter step S516 and judge whether response timeout.
As due to communication failure or other reasons, when after slave station request networking request, do not receive the identification request from system main website, then there is response timeout, enter step S517, cumulative to request networking number of times.Then enter step S518, whether the networking request number of times of judgement transfinites.If this networking request number of times of station has exceeded the higher limit allowing, abandon, to the taking of bus, reentering address detected pattern, from newly obtaining the idle address of network.Otherwise, reenter step S511, attempt initiating networking request with main website.
If detect that at step S514 new message is the request our station ID of main website, illustrate that main website has identified this communication slave station and entered network, then enter step S519 and reply network primary station required parameter.In this answering, without calling random delay strategy, because this request is initiated by main website, and the Modbus RTU main website that is controlled by of our station is dispatched.When new networking slave station responds after main website request, this station also formally enters normal communication mode simultaneously, and the process of whole slave station automatic acquisition mailing address finishes.
Please refer to Fig. 6, is the flow chart that the identification of Modbus RTU main website newly enters network slave station, and it comprises:
First in step S601, in the time that main website detects new link packet in Modbus RTU, then enter step S602, carry out basic communication process at once.Do not meet the basic communication checking of Modbus rtu protocol if step S602 detects this message, abandon this error message, then return by step S607.If correct message inspection is striven for when this message, enter step S603.
Step S603, judge receive message whether be request-reply.According to the substance of Modbus rtu protocol, first network using Modbus RTU main website initiates request to certain station of network, and then Target Station responds according to the content of request.So in the time that main website receives new message, first judgement whether the function of target slave station reply.If so, enter step S606 and carry out packet parsing according to Modbus rtu protocol, finally return by step S607.If not the Target Station of request is replied, enter step S604.
Step 604, main website identification newly enter Network Communication slave station.In communication process flow chart, increased the measuring ability of networking request message.When receiving, network primary station not our station request, but while meeting the request communication message of report slave station ID, showing has new communication slave station to wait for main website identification in network, in step S604, judged result is true, enter step S605, increase the task of initiative recognition slave station ID.If the message receiving is neither request-reply, the networking request of the communication equipment that neither newly network, abandons this communication message.This has in fact also embodied on the other hand Modbus RTU main website and has ignored address multiplex detection process.
Please refer to Fig. 7, with regard to the schematic diagram of a kind of practical application of the present invention, it analyzes time period network communication link message information content introduction the present invention simultaneously by detection.
As shown in Figure 7, suppose to exist in the existing network based on Modbus RTU four nodes (node is Modbus RTU main website or Modbus RTU slave station), comprising a Modbus RTU main website and three Modbus RTU slave station (S1, S2, S4), wherein the station address of three Modbus RTU slave stations is respectively 1,2,4.Modbus RTU network using time triggering mode, at time period [t 0, t 0+ Δ T p] in, Modbus RTU main website is according to successively each slave node of poll (S1, S2, S3) of network task.
If at t=t iin the moment, network newly adds communication slave station Si, due to [t 0, t 0+ Δ T p] Modbus RTU main website is in poll slave station in the time period, so in this process network always in busy condition.When Si is at t=t 0+ Δ T ptime detect that link is idle condition, at once obtain idle mailing address and prepare address multiplex detection packet according to AT.
But, due at [t i, t 0+ Δ T p] in the time period, slave station Si does not also do any address multiplex test, so AT be sky, the communication station address that Si obtains is for the first time 1.According to random delay strategy provided by the invention, it is Δ t that Si arranges delay time 3.If in this time delay process, link remains idle condition always, after delay time finishes, horse back sends the address multiplex detection packet about address 1.
Obviously, because the slave station S1 that communicates by letter in network has taken this station address, so in the time that S1 receives Si about the multiplexing test of address 1, will reply.Then, Si will join address 1 in AT according to this response, show that this station address has been used by other stations, then again obtain minimum address blank.
Because address 1 is occupied, according to network address list, the idle address of minimum obtaining is for the second time 2.Obviously this address is also taken by communication slave station S2.S2 sends after the multiplexing test pack of address 2, and by the test of replying of receiving from S2, then Si abandons address 2 equally, and scheduler Table A T.Adopt and use the same method, Si will continue to obtain minimum idle address 3.Owing to using this address without any slave station in network, as figure show, Si sends continuously and all do not receive mailing address for three times is 3 reply, Si will forever take this address.It should be noted that and between address multiplex test, need the reserved abundant time to the response of corresponding station, as shown in Figure 4, Δ t 2for the response timeout time, and there is Δ t 2> Δ t 3.
Please refer to Fig. 8, is the structural representation of the embodiment of slave station provided by the invention, and it comprises:
Interim station address generation module 1, for according to the idle address of network address list calculated address value minimum as described interim station address, described network address list is for recording the station address having been taken by other slave station that described slave station detects.
Detecting module 2, communication link for from the Modbus RTU network to place sends address multiplex detection packet, described address multiplex detection packet comprises interim station address, and whether described address multiplex detection packet is used for surveying described interim station address and is taken by described other slave station of Modbus RTU network;
Processing module 3, for when result of detection being described interim station address while not taken by described other slave station of Modbus RTU network, described slave station takies the fixed communication address of this interim station address as described slave station.Wherein, processing module 3 comprises: random delay time generation unit 31, in the time detecting the described communication link free time, produces the random delay time; Transmitting element 32, in the time that described delay time at any time arrives, described slave station sends described address multiplex detection packet to the communication link of place Modbus RTU network.
Networking module 4, for according to described fixed communication address, sends networking request bag to main website; And for respond described main website receive send after described networking request bag for asking the request report of described slave station essential information.
The present embodiment, whether the interim station address being sent in address multiplex detection packet detection address multiplex bag to communication link by slave station is taken by other slave station, when result of detection is while being unoccupied, slave station takies this interim station address, thereby solve the how problem of automatic acquisition station address of slave station, thereby realize the automatic network-building of the network equipment, make can realize task control and separating that Modbus RTU communicates by letter in planned network systematic procedure, strengthen the flexibility of network design and management, simultaneously in the replacement of the network equipment and the process of expansion, can realize the plug and play of equipment, without configuring static mailing address, strengthen the utilance of mailing address, in addition, in the process of single or multiple new networking slave station automatic acquisitions address, Modbus RTU main website will not participate in station address and assigns or intervene, greatly reduce the load of main website.
Finally explanation is, above embodiment is only unrestricted in order to technical scheme of the present invention to be described, although the present invention is had been described in detail with reference to preferred embodiment, those of ordinary skill in the art is to be understood that, can modify or be equal to replacement technical scheme of the present invention, and not departing from aim and the scope of technical solution of the present invention, it all should be encompassed in the middle of claim scope of the present invention.

Claims (10)

1. a Modbus RTU slave station automatic acquisition station address method, is characterized in that: comprising:
Slave station sends address multiplex detection packet to the communication link of the Modbus RTU network at place, described address multiplex detection packet comprises interim station address, and whether described address multiplex detection packet is used for surveying described interim station address and is taken by described other slave station of Modbus RTU network;
When result of detection be described interim station address not by described Modbus RTU network in other slave station while taking, described slave station takies the fixed communication address of this interim station address as described slave station.
2. Modbus RTU slave station automatic acquisition station address method as claimed in claim 1, it is characterized in that: described slave station also comprises before sending address multiplex detection packet: described slave station is according to the idle address of network address list calculated address value minimum as described interim station address, and described network address list is for recording the station address having been taken by other slave station that described slave station detects.
3. Modbus RTU slave station automatic acquisition station address method as claimed in claim 1, is characterized in that: described slave station sends address multiplex detection packet to the communication link of the Modbus RTU network at place, comprising:
When described slave station detects the described communication link free time, produce a random delay;
In the time that described random delay arrives, described slave station sends described address multiplex detection packet to the communication link of place Modbus RTU network.
4. Modbus RTU slave station automatic acquisition station address method as claimed in claim 1, it is characterized in that: in the time that described slave station at least twice transmission does not all receive that containing the address multiplex detection packet of same interim station address detection is replied, described result of detection is not just taken by other slave station in described Modbus RTU network for described interim station address.
5. the Modbus RTU slave station automatic acquisition station address method as described in any one in claim 1-4, it is characterized in that: after described slave station takies the fixed communication address of this interim station address as described slave station, also comprise: in the time that described slave station receives the address multiplex detection packet containing this fixed communication address, make detecting and reply.
6. the Modbus RTU slave station automatic acquisition station address method as described in any one in claim 1-4, is characterized in that: described slave station also comprises after taking the fixed communication address of this interim station address as described slave station:
Described slave station, according to described fixed communication address, sends networking request bag to main website;
Described slave station respond described main website receive send after described networking request bag for asking the request report of described slave station essential information.
7. for a slave station for Modbus RTU automatic acquisition station address, it is characterized in that: comprising:
Detecting module, communication link for from the Modbus RTU network to place sends address multiplex detection packet, described address multiplex detection packet comprises interim station address, and whether described address multiplex detection packet is used for surveying described interim station address and is taken by described other slave station of Modbus RTU network;
Processing module, for when result of detection being described interim station address while not taken by described other slave station of Modbus RTU network, described slave station takies the fixed communication address of this interim station address as described slave station.
8. slave station as claimed in claim 7, is characterized in that: also comprise:
Interim station address generation module, for according to the idle address of network address list calculated address value minimum as described interim station address, described network address list is for recording the station address having been taken by other slave station that described slave station detects.
9. slave station as claimed in claim 7, is characterized in that: described detecting module, comprising:
Random delay time generation unit, in the time detecting the described communication link free time, produces the random delay time;
Transmitting element, in the time that described delay time at any time arrives, described slave station sends described address multiplex detection packet to the communication link of place Modbus RTU network.
10. slave station as claimed in any one of claims 7-9, is characterized in that: also comprise:
Networking module, for according to described fixed communication address, sends networking request bag to main website; And for respond described main website receive send after described networking request bag for asking the request report of described slave station essential information.
CN201410003527.XA 2014-01-03 2014-01-03 The automatic acquisition station address approach of Modbus RTU slave stations and slave station Active CN103856578B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410003527.XA CN103856578B (en) 2014-01-03 2014-01-03 The automatic acquisition station address approach of Modbus RTU slave stations and slave station

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410003527.XA CN103856578B (en) 2014-01-03 2014-01-03 The automatic acquisition station address approach of Modbus RTU slave stations and slave station

Publications (2)

Publication Number Publication Date
CN103856578A true CN103856578A (en) 2014-06-11
CN103856578B CN103856578B (en) 2017-10-13

Family

ID=50863780

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410003527.XA Active CN103856578B (en) 2014-01-03 2014-01-03 The automatic acquisition station address approach of Modbus RTU slave stations and slave station

Country Status (1)

Country Link
CN (1) CN103856578B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104486182A (en) * 2014-11-27 2015-04-01 上海华冠电子设备有限责任公司 Serial Modbus communication extending method
CN106878488A (en) * 2017-04-29 2017-06-20 成都工鼎科技有限公司 A kind of Modbus RTU bus address auto-allocation methods
CN108931615A (en) * 2018-08-10 2018-12-04 珠海市万顺睿通科技有限公司 Air pollution monitoring method and monitoring system based on motion detection device
CN109150681A (en) * 2018-09-07 2019-01-04 深圳市雷赛控制技术有限公司 RTEX bus networking method and system
CN109873741A (en) * 2019-02-25 2019-06-11 南京金信通信息服务有限公司 A kind of system and working method of single-wire shared bus agreement
CN110061896A (en) * 2019-05-06 2019-07-26 浙江明度智控科技有限公司 A kind of MODBUS-RTU bus address collision detection method
CN110505319A (en) * 2019-08-07 2019-11-26 金陵科技学院 A kind of RS485 is from device address auto-allocation method and system
CN113746712A (en) * 2021-09-01 2021-12-03 蓝思智能机器人(长沙)有限公司 MODBUS _ RTU protocol-based one-master multi-slave communication method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008005191A (en) * 2006-06-22 2008-01-10 Yokogawa Electric Corp Communication system
CN101170471A (en) * 2006-10-25 2008-04-30 Abb专利有限公司 Method for operation of a bus system
CN101309306A (en) * 2008-07-16 2008-11-19 哈尔滨工业大学 Method for allocating addresses from node device in Modbus communication network
CN102325201A (en) * 2011-10-27 2012-01-18 珠海派诺科技股份有限公司 Method for allocating network addresses to slave node equipment in Modbus communication network
CN102664719A (en) * 2012-05-03 2012-09-12 杭州电子科技大学 Distributed secure transmission method applied to distributed control system (DCS)

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008005191A (en) * 2006-06-22 2008-01-10 Yokogawa Electric Corp Communication system
CN101170471A (en) * 2006-10-25 2008-04-30 Abb专利有限公司 Method for operation of a bus system
CN101309306A (en) * 2008-07-16 2008-11-19 哈尔滨工业大学 Method for allocating addresses from node device in Modbus communication network
CN102325201A (en) * 2011-10-27 2012-01-18 珠海派诺科技股份有限公司 Method for allocating network addresses to slave node equipment in Modbus communication network
CN102664719A (en) * 2012-05-03 2012-09-12 杭州电子科技大学 Distributed secure transmission method applied to distributed control system (DCS)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104486182B (en) * 2014-11-27 2018-05-01 上海仪电楼宇科技有限公司 A kind of method of serial Modbus expanding communications
CN104486182A (en) * 2014-11-27 2015-04-01 上海华冠电子设备有限责任公司 Serial Modbus communication extending method
CN106878488B (en) * 2017-04-29 2020-03-20 成都工鼎科技有限公司 Automatic Modbus RTU bus address allocation method
CN106878488A (en) * 2017-04-29 2017-06-20 成都工鼎科技有限公司 A kind of Modbus RTU bus address auto-allocation methods
CN108931615A (en) * 2018-08-10 2018-12-04 珠海市万顺睿通科技有限公司 Air pollution monitoring method and monitoring system based on motion detection device
CN109150681A (en) * 2018-09-07 2019-01-04 深圳市雷赛控制技术有限公司 RTEX bus networking method and system
CN109150681B (en) * 2018-09-07 2021-03-16 深圳市雷赛控制技术有限公司 RTEX bus networking method and system
CN109873741A (en) * 2019-02-25 2019-06-11 南京金信通信息服务有限公司 A kind of system and working method of single-wire shared bus agreement
CN109873741B (en) * 2019-02-25 2019-12-31 南京金信通信息服务有限公司 System and working method of single-wire shared bus protocol
CN110061896A (en) * 2019-05-06 2019-07-26 浙江明度智控科技有限公司 A kind of MODBUS-RTU bus address collision detection method
CN110061896B (en) * 2019-05-06 2021-04-13 浙江明度智控科技有限公司 MODBUS-RTU bus address conflict detection method
CN110505319A (en) * 2019-08-07 2019-11-26 金陵科技学院 A kind of RS485 is from device address auto-allocation method and system
CN113746712A (en) * 2021-09-01 2021-12-03 蓝思智能机器人(长沙)有限公司 MODBUS _ RTU protocol-based one-master multi-slave communication method and system

Also Published As

Publication number Publication date
CN103856578B (en) 2017-10-13

Similar Documents

Publication Publication Date Title
CN103716420A (en) Automatic station address obtaining method of Modbus ASCII slave station and slave station
CN103856578A (en) Automatic slave station address acquisition method through Modbus RTU and slave station
CN102664719B (en) Distributed secure transmission method applied to distributed control system (DCS)
CN101682542B (en) Suspending transmissions in a wireless network
CN103826252B (en) Method of acquiring and sending sequence numbers among main and slave devices and system
US9270554B2 (en) Communication apparatus and delay detecting method
CN100558051C (en) Two-way conversion link is carried out the method for fault detect
CN103039046B (en) Method and device for fault-tolerant, time-controlled real-time communication
CN106209542B (en) Industry internet field layer wideband bus architecture system
US10440648B2 (en) Sleeping and wake-up methods and apparatuses of master-slave network, and power saving system of master-slave network
EP3261275B1 (en) Method for clock synchronization of an industrial internet field broadband bus
CN105262555B (en) Time synchronization method, programmable logic device, single board and network element
CN106100955B (en) Industrial internet field layer broadband bus data depth detection implementation method
CN103004143A (en) Frame transmission and communication network
CN106254238A (en) A kind of data transmission method, Centralized Controller and communicator
CN104092790B (en) Base station master-slave communication method and system
CN103929377A (en) Wired network and wireless network combined dispatching method and system and related devices
CN109391968A (en) Communication means and communication device
JP6836692B1 (en) Data collection management device and data collection system
CN105553765A (en) FC-AV protocol processing chip network communication robustness testing method
KR101063327B1 (en) Industrial automation network system based on ubiquitous sensor network and its real time synchronization method
ES2250056T3 (en) COMBINED PROCESS OF MASTER / SLAVE-PRODUCER / CONSUMER COMMUNICATION FOR A NETWORK.
CN106686697A (en) Management method for zigbee terminal device node
CN117749559A (en) Communication method, device and system based on EtherCAT and computing equipment
CN104283739A (en) Detection method and device based on distributed ISSU

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
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 402460 No. 160 Changyuan Street College Road, Rongchang District, Chongqing

Patentee after: Southwest University

Address before: 400715 No. 2, Tiansheng Road, Beibei District, Chongqing

Patentee before: Southwest University

CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 400715 No. 1, natural road, Beibei District, Chongqing

Patentee after: SOUTHWEST University

Address before: 402460 Chongqing city Rongchang District Xueyuan Road Changyuan Street No. 160

Patentee before: SOUTHWEST University