CN100477670C - Automatic distributing and setting up address method based on master-slave communication mode - Google Patents

Automatic distributing and setting up address method based on master-slave communication mode Download PDF

Info

Publication number
CN100477670C
CN100477670C CNB2005100386525A CN200510038652A CN100477670C CN 100477670 C CN100477670 C CN 100477670C CN B2005100386525 A CNB2005100386525 A CN B2005100386525A CN 200510038652 A CN200510038652 A CN 200510038652A CN 100477670 C CN100477670 C CN 100477670C
Authority
CN
China
Prior art keywords
address
virtual address
main website
instruction
slave station
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
CNB2005100386525A
Other languages
Chinese (zh)
Other versions
CN1674593A (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.)
Nanjing Post & Telecommunication College
Nanjing Post and Telecommunication University
Nanjing University of Posts and Telecommunications
Original Assignee
Nanjing Post & Telecommunication College
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 Nanjing Post & Telecommunication College filed Critical Nanjing Post & Telecommunication College
Priority to CNB2005100386525A priority Critical patent/CN100477670C/en
Publication of CN1674593A publication Critical patent/CN1674593A/en
Application granted granted Critical
Publication of CN100477670C publication Critical patent/CN100477670C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Small-Scale Networks (AREA)

Abstract

The present invention provides an address automatic distribution setting method based on master/slave communication mode. Said method includes two steps: 1). firstly, main station can find out some slave station on the bus, said slave station is in virtual address state, and its virtual address is not equal to the virtual address of any other slave station being in virtual state on the bus; and 2) main station can distribute and set real adress for said slave station. For vurtual address repetition or real address repetition which can be produced on the bus a command for commanding it implement reformation can be provided, after the address reformation, according to the above-mentioned two steps the address distribution can be implemented again. Said invention can utilize this mode to distribute real address for slave station being in virtual address state.

Description

A kind of address based on the master-slave communication pattern is distributed method to set up automatically
Technical field
The present invention relates to the address assignment method to set up based on the virtual address under a kind of master-slave communication pattern, this method can be used to adopt the industrial field bus of master-slave communication pattern, also can be used to adopt the wireless sharing media of master-slave communication pattern.This method do not need for operating office set any be used for address assignment such as switching device electronics or machinery, and adopt the method for complete communication protocolization to carry out the distribution and the setting of address.
Technical background
It is impossible for the bus system under the master-slave communication pattern up to now that automatic address distributes, and perhaps realizes very difficulty.Tradition thinks, in the bus system under adopting the master-slave communication pattern, and owing to the reason of layout does not allow the repetition of address, identification communication station that just can not univocality otherwise, and Data transmission that also therefore can not univocality.
The method that known a kind of automatic address distributes in the S7-300 of Siemens Company type instrument and meter for automation, but the realization cost prohibitive of this method; In addition, also have a kind of address assignment agreement that is used under the master-slave communication pattern, main website has the so-called physical path that is used for carrying out communication contact with slave station and sets respectively, the implicit address of determining each operating office with the connection of path; Siemens Company has also announced a kind of method that automatic address distributes that is used for based on range measurement, and this method is owing to need determine the address of slave station very big defective is arranged in the application to the different distance of a plurality of slave stations according to main website.
Although it is impossible that the automatic address under the master-slave communication pattern distributes at present technical, very difficult on perhaps realizing, but press in the application, such as in an existing system, add, just might run into the problem that repeat the address from station equipment; Similar problem also is present in to be changed in the slave station that damages, and also might run into the problem that repeat the address.
Summary of the invention
The purpose of this invention is to provide a kind of address assignment method to set up under the master-slave communication pattern based on the virtual address.This method has utilized the ambiguity that repeats to cause owing to the address to discern the repetition virtual address, provide a virtual address reorganization instruction to allow them produce a new virtual address for the virtual address of repeating, distribute a real address to finish the automatic distribution of address finally for each virtual address.
A kind of being used for has a plurality of operating offices (M, S1, S2, ... carry out the method that automatic address distributes in communication system .Sn), have at least the operating office that is called main website (M) below to bear higher level's function in these operating offices, and remaining S1, S2 ... .Sn is called slave station or clump belongs to the station.The bus at docking station and station belongs to shared physical transfer media, also can be the wireless physical transfer media of sharing.The train of signal of the instruction that sends by the M of main website can arrive all be connected on slave station S1, S2 on the bus ... .Sn.Want to finish main website and slave station S1, a S2 ... the communication between the .Sn, or the communication between two slave stations under certain conditions be only possible after the address that distribute univocality must for each slave station and main website.
1), main website finds out some slave stations on the bus earlier address setting distribution method of the present invention divides two steps to carry out:, this slave station is in virtual address state and its virtual address and is not equal on the bus any other and is in the virtual address of the slave station of virtual address state; 2), main website carries out the distribution and the setting of real address to this slave station.Repeat or the real address repetition for the virtual address that may occur on the bus, the order that makes its reorganization is provided, after the reorganization of address, carry out address assignment according to above-mentioned two steps again.Repeating step 1 and 2 can be followed successively by all slave stations that are on the same bus and distribute the address automatically.
It is considered herein that slave station has two kinds of address states: virtual address state and real address state.The purpose that the virtual address is set is in order to produce the real address by the virtual address, and the definite address of real address when being equipment work is equal to original tributary address; Any slave station of just having produced makes it be in the virtual address state and has a definite virtual address; All slave stations that are in the virtual address state receive only and handle virtual address query statement, virtual address reorganization instruction, the real address that main website sends instruction is set; What be in the virtual address state enters the real address state from standing in after the real address at oneself that receives the main website transmission is provided with instruction; The virtual address query statement that all slave stations that are in the real address state send for main website, virtual address reorganization instruction and real address are provided with instruction and need do any processing, if but receive and enter the virtual address state after the real address reorganization at own that main website sends is instructed.The slave station of real address state described here also has common transmission and receiving function certainly, and it is the defined bus protocol of each different transmission medium that these functions are enough to satisfy, and the present invention only is the function that has strengthened original slave station.
The step 1 of this method needs three types train of signal: the virtual address reorganization instruction that virtual address inquiry response instruction that the virtual address query statement that main website sends, slave station send and main website send.The virtual address query statement is the instruction that main website sends to slave station, comprises address realm, and address realm can be the some definite virtual addresses or the upper and lower bound of a certain section virtual address; Inquiry response instruction in virtual address is that slave station receives behind the query statement of virtual address its response, sends to main website by slave station, and the virtual address (A) that comprises slave station oneself is used to inform main website, also can comprise device description of slave station or the like in the instruction; Virtual address reorganization instruction is the instruction that main website sends to slave station, comprise address realm, address realm can be some definite virtual address or a certain section upper and lower bounds that needs the virtual address of reorganization that needs reorganization, also can comprise the virtual address scope after the reorganization in the instruction; The reorganization instruction of virtual address query statement and virtual address all belongs to the broadcast-type instruction, and all slave stations that are in the virtual address state all must receive and do respective handling on the bus.
The handling process of the main website of step 1 can be referring to Fig. 1.Main website sends the virtual address query statement, this query statement is received by all slave stations, as long as slave station belongs to virtual address state and the virtual address of oneself within the bound of address realm, they just send virtual address inquiry response instruction as the response to the virtual address query statement, and the virtual address (A) of informing main website oneself thus.Main website receives the virtual address inquiry response instruction from slave station in an official hour window, 1), main website do not receive response the response condition that main website receives can be three kinds:, show that the virtual address that does not have slave station belongs in the address realm of inquiry, main website can change an address realm and inquired about again or finish this inquiry this moment; 2), the virtual address inquiry response instruction of a slave station is received by main website, show and adopt the slave station of this virtual address (A) may have only one on the bus, promptly the virtual address of this slave station (A) is not equal to other the virtual address of any slave station on the bus, and this moment, main website can enter step 2; 3), the virtual address inquiry response instruction of a more than slave station is received by main website, show more than one of the number that satisfies the slave station of address realm in the query statement of virtual address on the network, need do further processing this moment, if promptly Cha Xun address realm is a certain section virtual address, then can dwindles address realm and resend the virtual address query statement; If the address realm of inquiry is some definite virtual addresses, then showing has a more than slave station to adopt this virtual address, and this moment, main website need send virtual address reorganization instruction at this virtual address.
Main website is after the virtual address inquiry response instruction of receiving a more than slave station, must handle in two kinds of situation: 1), main website is after the upper and lower bound at a certain section virtual address sends the virtual address query statement, main website receives the virtual address inquiry response instruction from slave station in an official hour window, if in the official hour window because the response of a more than slave station will cause main website to receive following error message: the independent response that a plurality of slave stations separate on the time is separately successively received by main website, make main website generation reception mistake or above-mentioned two kinds of mistakes that the comprehensive reception mistake that causes takes place simultaneously owing to the slave station response is overlapping in time.If one of above-mentioned three kinds of situations, main website can judge not only one of slave station number in the upper and lower bound that belongs to this section virtual address on the bus in view of the above, needs main website to dwindle address realm this moment and resends the virtual address query statement.2), main website is behind the virtual address query statement that sends at some definite virtual addresses, main website receives the virtual address inquiry response instruction from slave station in an official hour window, if in the official hour window because the response of a more than slave station will cause main website to receive following error message: main website receives independent response that a plurality of slave stations separate on the time separately successively, because the slave station response is overlapping in time makes main website that mistake or above-mentioned two kinds of mistakes take place to receive the comprehensive reception mistake that causes takes place simultaneously.If one of above-mentioned three kinds of situations, main website can judge in view of the above has a more than slave station to adopt this virtual address (A) on the bus, virtual address (A) promptly occurred and repeated, this moment, main website need send virtual address reorganization instruction at this virtual address (A).
Main station judging goes out on the bus slave station number not only the time that adopts some definite virtual addresses (A), and promptly the virtual address of slave station (A) has repetition, and main website can send virtual address reorganization instruction at this virtual address (A).After standing in the virtual address reorganization instruction that receives the main website transmission, as long as slave station belongs to the virtual address state and satisfies the bound requirement of address in the instruction of recombinating, slave station will produce the virtual address of a new numerical value (such as random number) as oneself.If comprise the virtual address scope after the reorganization in the reorganization instruction of the virtual address that main website sends, then the new virtual address of slave station generation must be within this scope.After instructing, the virtual address reorganization need not to respond any message from standing in to receive.
Adopt the slave station of certain virtual address may have only after one on learning bus, the virtual address (A) of this slave station can be learnt by main website from response instruction, can enter step 2 afterwards.Completing steps 2 needs three types train of signal: the real address that main website sends is provided with real address that instruction, slave station send and the real address reorganization that response instruction and main website send is set instructs.It is the instruction that main website sends to slave station that the real address is provided with instruction, comprises the real address (C) of some virtual addresses (B), corresponding distribution, also can comprise the device description of slave station; It is that slave station receives the real address response to it of instruction back is set that the real address is provided with response instruction, sends to the instruction of main website by slave station, comprises the real address (C) of the virtual address (B) of slave station oneself, corresponding distribution, also can comprise the device description of slave station; Real address reorganization instruction is the instruction that main website sends to slave station, comprise the real address scope, the real address scope is some definite real address or a certain section upper and lower bounds that needs the real address of reorganization that needs reorganization, also can comprise the virtual address scope after the reorganization; The real address is provided with instruction and belongs to broadcast-type instruction, and all slave stations that are in the virtual address state all must receive and do respective handling on the bus; Real address reorganization instruction also belongs to the broadcast-type instruction, and all slave stations that are in the real address state all must receive and do respective handling on the bus.
The handling process of the main website of step 2 can be referring to Fig. 2.Main website sends the real address instruction is set, some slave stations that is in the virtual address state are arranged to the real address state, this instruction is received by all slave stations, as long as the virtual address that slave station belongs to virtual address state and slave station equals the real address virtual address (B) in the instruction is set, then this slave station is provided with real address (C) in the instruction as oneself real address with the real address, and enters the real address state.Slave station also sends the real address and response instruction is set as the response that the real address is provided with instruction.1), main website do not receive response, shows that step 1 may be wrong, returns step 1 real address that main website receives from slave station in an official hour window is provided with response instruction, and the response condition that main website receives can be three kinds:; 2), main website receives that the real address of a more than slave station is provided with response instruction, showing has a more than slave station to adopt virtual address (B), and these slave stations have all entered the real address state of employing real address (C), and this moment, main website need send real address reorganization instruction at this real address; 3), main website receives that the real address of a slave station is provided with response instruction, show to adopt the slave station of this virtual address (B) may have only one on the bus, and this slave station entered the real address state of employing real address (C), finish at the address assignment of this slave station.
After main website transmission real address is provided with instruction, the real address that receives in an official hour window from slave station is provided with response instruction, if in the official hour window because the response of a more than slave station will cause main website to receive following error message: main website receives independent response that a plurality of slave stations separate on the time separately successively, because the slave station response is overlapping in time makes main website that mistake or above-mentioned two kinds of mistakes take place to receive the comprehensive reception mistake that causes takes place simultaneously.If one of above-mentioned three kinds of situations, main website can judge in view of the above to be had a more than slave station and has adopted real address (C) on the bus, real address (C) promptly occurred and repeated, this moment, main website need send real address reorganization instruction at this real address (C).
If find that there is repetition the real address of slave station on the network when main website is provided with instruction in the transmission real address or in the actual moving process, main website can send real address reorganization instruction.After standing in the real address reorganization instruction that receives the main website transmission, as long as slave station belongs to the real address state and satisfies the bound requirement of address in the reorganization instruction, slave station will enter the virtual address state and produce the virtual address of a new numerical value (such as random number) as oneself.If comprise the virtual address scope after the reorganization in the reorganization instruction of the real address that main website sends, then the new virtual address of slave station generation must be within this scope.After instructing, the real address reorganization need not respond any message from standing in to receive.The real address is provided with instruction can carry out at a certain section slave station with real address state that needs to recombinate, and can carry out at some definite slave stations with real address state of reorganization that needs.
Main website is at the duration of work of communication system, but resends the virtual address query statement in the moment that can be scheduled to or in a preset time section.
This method also is suitable for much much more main from system, promptly be suitable for (M1, M2 ... Mi, S1, S2 ... .Sn) such system.How the master is many will have a main website to finish address assignment from system, and remaining main website can not participate in address assignment or be taken as some special slave stations (having certain special mark) and treat.
As a method for simplifying of the present invention be: receive after real address that main website sends is provided with instruction from standing in, slave station need not responded any instruction, and main website can carry out in the actual moving process of network for the judgement that repeats the real address.
Main website is after sending virtual address query statement or real address instruction is set, main website receives the response message from slave station in an official hour window, if in the official hour window because the response of a plurality of slave stations will cause main website to receive following error message: main website receives independent response that a plurality of slave stations separate on the time separately successively, because the slave station response is overlapping in time makes main website that mistake or above-mentioned two kinds of mistakes take place to receive the comprehensive reception mistake that causes takes place simultaneously.Do an explanation with regard to these three kinds of situations below.
Main website receives that the situation of the independent response that a plurality of slave stations separate on the time separately successively is as follows: suppose to have in the communication system two node A and B to have same virtual address i, after if main website sends virtual address query statement or real address instruction is set at virtual address i, A and B can send response, then a kind of situation may take place, in official hour window T, A sends response earlier, and sending response behind the B, the situation figure of the independent response that two slave stations separate on the time separately successively can be referring to Fig. 3.The independent response that a plurality of slave stations separate on the time separately successively for example slightly.
It is as follows to make that owing to the slave station response is overlapping in time main website takes place to receive wrong situation: suppose to have in the communication system two node A and B to have same virtual address i, after if main website sends virtual address query statement or real address instruction is set at virtual address i, A and B can send response, then a kind of situation may take place, in official hour window T, A sends response earlier, do not wait the response of A to send the B that finishes and send response yet, make two responses can not separate in time like this, thereby the information that makes the mistake.Producing the situation figure that receives mistake owing to response is overlapping in time can be referring to Fig. 4.A plurality of slave stations produce owing to response is overlapping in time and receive wrong omiting for example.
Above-mentioned two kinds of mistakes take place simultaneously and cause comprehensive to receive wrong situation as follows: suppose to have in the communication system three node A, B and C to have same virtual address i, after if main website sends virtual address query statement or real address instruction is set at virtual address i, A, B and C can send response, then a kind of situation may take place, in official hour window T, A sends response earlier, and send response behind the B, do not wait the response of B to send the C that finishes and send response yet, make two responses of B, C can not separate in time like this.The comprehensive situation figure that receives mistake can be referring to Fig. 4.Three slave stations or more slave station since have same virtual address i all send other of response comprehensive receive wrong for example slightly.
Be chosen in the rule of applied instruction in the scope of the inventive method (virtual address query statement, the instruction of virtual address inquiry response, virtual address reorganization instruction, real address reorganization instruction, instruction is set in the real address or the real address is provided with response instruction): must make them not damage normal communication running, and can be identified reliably.
Description of drawings
The process chart of the main website of the step 1 of Fig. 1 address assignment method to set up
The process chart of the main website of the step 2 of Fig. 2 address assignment method to set up
The situation figure of the independent response that two slave stations of Fig. 3 separate on the time separately successively
Two slave stations of Fig. 4 produce owing to response is overlapping in time and receive wrong situation figure
A kind of comprehensive situation figure that receives mistake that three slave stations of Fig. 5 respond simultaneously
Embodiment
The automatic address that the present invention relates in communication system distributes.In an embodiment, communication system is an example with the modbus based on RS-485 exemplarily.But the present invention never only limits to the modbus based on RS-485, and can advantageously be applied to other bus systems of the above-mentioned type, especially in having the bus system of bus conductor, such as profibus or the like.
Up to now, be to do to distribute automatically in based on the modbus of RS-485 or profibus to the address of operating office, because in said system, be that the instruction that main website sends almost is positioned on all slave stations simultaneously by higher level's operating office.Tradition thinks that then slave station will be made a response to same train of signal with same form if for address assignment provides the sort signal string, so just can not obtain a kind of difference of univocality.The present invention has exactly utilized this ambiguity, utilized the ambiguity that repeats to cause owing to the address to discern the virtual address of repetition, provide a virtual address reorganization instruction to allow them produce a new virtual address for the virtual address of repeating, distribute a real address to finish the automatic distribution of address finally for each virtual address.
The inventive method can make the communication system with a plurality of operating offices automatically operate, this method do not need for operating office set any be used for address assignment such as switching device electronics or machinery, and adopt the method for complete communication protocolization to carry out the distribution and the setting of address.By this method, any one need not can be admitted in the bus through the slave station of prior manual intervention/configuration.
A kind of being used for has a plurality of operating office (M, S1, S2 ... carry out the method that automatic address distributes in communication system .Sn), have at least the operating office that is called main website (M) below to bear higher level's function in these operating offices, and remaining S1, S2 ... .Sn is called slave station or clump belongs to the station.The bus at docking station and station belongs to shared physical transfer media.
The train of signal of the instruction that sends by the M of main website can arrive all be connected on slave station S1, S2 on the bus ... .Sn.Want to finish main website and slave station S1, a S2 ... the communication between the .Sn, or the communication between two slave stations under certain conditions be only possible after the address that distribute univocality must for each slave station and main website.
The present invention sets slave station and has two kinds of address states: virtual address state and real address state.The purpose that the virtual address is set is in order to produce the real address by the virtual address, and the definite address of real address when being equipment work is equal to original tributary address; Any slave station of just having produced makes it be in the virtual address state and has a definite virtual address; All slave stations that are in the virtual address state receive only and handle virtual address query statement, virtual address reorganization instruction, the real address that main website sends instruction is set; What be in the virtual address state enters the real address state from standing in after the real address at oneself that receives the main website transmission is provided with instruction; The virtual address query statement that all slave stations that are in the real address state send for main website, virtual address reorganization instruction and real address are provided with instruction and need do any processing, if but receive and enter the virtual address state after the real address reorganization at own that main website sends is instructed.The slave station of real address state described here also has common transmission and receiving function certainly, and these functions are enough to satisfy for the defined bus protocol of each different transmission medium, only are the functions that has strengthened original slave station.
At automatic address between allotment period, those do not distribute the real address slave station S1, S2 ... .Sn is in the virtual address state.Start the main website that is used for address automatic allocating method of the present invention and take bus and send instruction, and monitor the response that receives instruction.Those be in the virtual address state slave station S1, S2 ... .Sn detects received instruction according to the mechanism that it is suitable for carrying out the inventive method, and the response that sends self under certain conditions is as to receiving the response of instruction.
Be example with the modbus based on RS-485 exemplarily below, the tributary address scope of modbus is 1 to 247.In the following example, bus communication speed all adopts 9.6Kbps, and main website receives the response from slave station sending after virtual address query statement or real address be provided with instruction in follow-up 300 milliseconds.
Embodiment 1: newly set up a communication system, one has ten slave stations in the system, and the virtual address that these slave stations belong to virtual address state and slave station is respectively 1,3,6,10,15,23,27,28,90,100.
Method 1: main website sends the virtual address query statement one by one to all addresses in the address realm, and promptly location 1 to 247 is sent the virtual address query statement respectively over the ground.Send the virtual address query statement at virtual address 1, the virtual address inquiry response instruction of a slave station is received by main website, and sending the real address then, instruction is set is that the real address of 1 slave station is made as 1 with the virtual address; Send the virtual address query statement at virtual address 2, response is not received by main website; Send the virtual address query statement at virtual address 3, the virtual address inquiry response instruction of a slave station is received by main website, and sending the real address then, instruction is set is that the real address of 3 slave station is made as 2 with the virtual address; Send the virtual address query statement at virtual address 4, response is not received by main website; Send the virtual address query statement at virtual address 5, response is not received by main website; Send the virtual address query statement at virtual address 6, the virtual address inquiry response instruction of a slave station is received by main website, and sending the real address then, instruction is set is that the real address of 6 slave station is made as 3... with the virtual address.By that analogy, original virtual address is 1,3,6,10,15,23,27,28,90,100 carries out after the real address is provided with from standing in, and the real address is respectively 1,2,3,4,5,6,7,8,9,10.
Method 2: main website sends the virtual address query statement one by one to all addresses in the address realm, and promptly location 1 to 247 is sent the virtual address query statement respectively over the ground.Send the virtual address query statement at virtual address 1, the virtual address inquiry response instruction of a slave station is received by main website, and sending the real address then, instruction is set is that the real address of 1 slave station is made as 1 with the virtual address; Send the virtual address query statement at virtual address 2, response is not received by main website; Send the virtual address query statement at virtual address 3, the virtual address inquiry response instruction of a slave station is received by main website, and sending the real address then, instruction is set is that the real address of 3 slave station is made as 3 with the virtual address; Send the virtual address query statement at virtual address 4, response is not received by main website; Send the virtual address query statement at virtual address 5, response is not received by main website; Send the virtual address query statement at virtual address 6, the virtual address inquiry response instruction of a slave station is received by main website, and sending the real address then, instruction is set is that the real address of 6 slave station is made as 6... with the virtual address.By that analogy, original virtual address is 1,3,6,10,15,23,27,28,90,100 carries out after the real address is provided with from standing in, and the real address is respectively 1,3,6,10,15,23,27,28,90,100.The real address that the back slave station promptly is set is equal to original virtual address.
Embodiment 2: newly set up a communication system, one has ten slave stations in the system, and the virtual address that these slave stations belong to virtual address state and slave station is respectively 1,1,6,10,15,23,27,28,90,100.Promptly there are two slave stations to adopt identical virtual address 1.
Main website sends the virtual address query statement one by one to all addresses in the address realm, and promptly location 1 to 247 is sent the virtual address query statement respectively over the ground.Send the virtual address query statement at virtual address 1, the virtual address inquiry response instruction of a more than slave station is received by main website, main website is at the reorganization instruction of apprehensive address, virtual address 1, the virtual address be 1 slave station receive receive virtual address reorganization instruction after, the virtual address of oneself is set to 2 and 8 respectively.Promptly the virtual address of 10 slave stations has become 2,6,8,10,15,23,27,28,90,100.Follow-up work is equal to example 1, the virtual address be 2,6,8,10,15,23,27,28,90,100 from stand in carry out the real address automatically distribute be provided with after, the real address is respectively 1,2,3,4,5,6,7,8,9,10.
Embodiment 3: add a slave station on an existing communication system, the virtual address of this slave station is assumed to be 168.Have 10 slave stations on original communication system, the real address is respectively 1,2,3,4,5,6,7,8,9,10.
Main website is at the duration of work of communication system, but resends the virtual address query statement in the moment that can be scheduled to or in a preset time section.When a system is working, the system that considers increases slave station can not be very fast, and main website is to the disposable virtual address query statement that sends in all addresses in the address realm, and promptly the lower limit of address is set to 1, the upper limit of address is set to 247, sends the virtual address query statement then.After this instruction is sent, the virtual address is that 168 slave station sends virtual address inquiry response instruction, the virtual address inquiry response instruction of this slave station is received by main website, and therefrom can obtain its virtual address is 168, and sending the real address then, instruction is set is that the real address of 168 slave station is made as 11 with the virtual address.
Embodiment 4: added two slave stations on an existing communication system, the virtual address of two slave stations all is 168.Have 10 slave stations on original communication system, the real address is respectively 1,2,3,4,5,6,7,8,9,10.
Main website is at the duration of work of communication system, but resends the virtual address query statement in the moment that can be scheduled to or in a preset time section.When a system is working, the system that considers increases slave station can not be very fast, and main website is to the disposable virtual address query statement that sends in all addresses in the address realm, and promptly the lower limit of address is set to 1, the upper limit of address is set to 247, sends the virtual address query statement then.After this instruction is sent, the virtual address is that 168 slave station all sends virtual address inquiry response instruction, the virtual address inquiry response instruction of a more than slave station is received by main website, and main website can adopt dichotomy to dwindle the address lookup scope to continue to send the virtual address query statement then ....The virtual address that can define two slave stations at last all is 168.Main website is at the reorganization instruction of apprehensive addresses, virtual address 168, and the virtual address is that the virtual address of oneself was set to 100 and 160 respectively after 168 slave station received virtual address reorganization instruction.Main website enlarges the address lookup scope afterwards, and the lower limit of address is set to 1, and the upper limit of address is set to 247, sends the virtual address query statement once more.After this instruction is sent, the virtual address is that 100 and 160 slave station sends virtual address inquiry response instruction, the virtual address inquiry response instruction of a more than slave station is received by main website, and main website continues to adopt dichotomy to dwindle the address lookup scope and continues to send the virtual address query statement then.Finally can determine to have two slave stations on the communication system, its address is respectively 100 and 160, is respectively it and distributes real address 11 and 12.
Embodiment 5: on an existing communication system, have 10 slave stations on the communication system, main website finds that it all is 9 that the real address of two slave stations is arranged.Be that the real address is respectively 1,2,3,4,5,6,7,8,9,9.Main website sends real address reorganization instruction at real address 9, and the real address is that the virtual address of oneself was set to 100 and 160 respectively after 9 slave station received virtual address reorganization instruction.Main website is provided with the address lookup scope afterwards, and the lower limit of address is set to 1, and the upper limit of address is set to 247, sends the virtual address query statement.After this instruction is sent, the virtual address is that 100 and 160 slave station sends virtual address inquiry response instruction, the virtual address inquiry response instruction of a more than slave station is received by main website, and main website continues to adopt dichotomy to dwindle the address lookup scope and continues to send the virtual address query statement then ....Finally can determine to have two slave stations on the communication system, its address is respectively 100 and 160, is respectively it and distributes real address 10 and 11.
Be chosen in the rule of applied instruction in the scope of the inventive method (virtual address query statement, the instruction of virtual address inquiry response, virtual address reorganization instruction, real address reorganization instruction, instruction is set in the real address or the real address is provided with response instruction): must make them not damage normal communication running, and can be identified reliably.

Claims (10)

1, a kind of address based on the master-slave communication pattern is distributed method to set up automatically, be used for having a plurality of operating office (M, S1, S2, ... carry out automatic address in communication system .Sn) and distribute, have at least an operating office that is called main website (M) to bear higher level's function in these operating offices, and remaining operating office (S1, S2, ... .Sn) be called slave station or slave station, the bus at docking station and station belongs to shared physical transfer media, main website takies bus and sends instruction, and monitor to receive the response of instruction, it is characterized in that two steps of branch carry out: step 1, main website finds out some slave stations on the bus earlier, and this slave station is in virtual address state and its virtual address and is not equal on the bus any other and is in the virtual address of the slave station of virtual address state; Slave station has two kinds of address states: virtual address state and real address state; The purpose that the virtual address is set is in order to produce the real address by the virtual address, and the definite address of real address when being equipment work is equal to tributary address; Any slave station of just having produced makes it be in the virtual address state and has a definite virtual address; All slave stations that are in the virtual address state receive only and handle virtual address query statement, virtual address reorganization instruction, the real address that main website sends instruction is set; What be in the virtual address state enters the real address state from standing in after the real address at oneself that receives the main website transmission is provided with instruction; The virtual address query statement that all slave stations that are in the real address state send for main website, virtual address reorganization instruction and real address are provided with instruction and need do any processing, if but receive and enter the virtual address state after the real address reorganization at own that main website sends is instructed; Step 2, main website carry out the distribution and the setting of real address to this slave station; Repeat or the real address repetition for the virtual address that may occur on the bus, the order that makes its reorganization is provided, after the reorganization of address, carry out address assignment according to above-mentioned two steps again; Repeating step 1 and 2 is followed successively by all slave stations that are on the same bus and distributes the real address automatically.
2, the address based on the master-slave communication pattern according to claim 1 is distributed method to set up automatically, it is characterized in that: the train of signal that completing steps 1 needs are three types: the virtual address reorganization instruction that virtual address inquiry response instruction that the virtual address query statement that main website sends, slave station send and main website send; The virtual address query statement is the instruction that main website sends to slave station, comprises address realm, and address realm is the some definite virtual addresses or the upper and lower bound of a certain section virtual address; Inquiry response instruction in virtual address is that slave station receives behind the query statement of virtual address its response, sends to main website by slave station, and the virtual address (A) that comprises slave station oneself is used to inform main website; Virtual address reorganization instruction is the instruction that main website sends to slave station, comprises address realm, and address realm is some definite virtual address or a certain section upper and lower bounds that needs the virtual address of reorganization that needs reorganization, also comprises the virtual address scope after the reorganization in the instruction; The reorganization instruction of virtual address query statement and virtual address all belongs to the broadcast-type instruction, and all slave stations that are in the virtual address state all must receive and do respective handling on the bus;
Main website sends the virtual address query statement, this query statement is received by all slave stations, as long as slave station belongs to virtual address state and the virtual address of oneself within the bound of address realm, they just send virtual address inquiry response instruction as the response to the virtual address query statement, and the virtual address (A) of informing main website oneself thus; Main website receives the virtual address inquiry response instruction from slave station in an official hour window, 1), main website do not receive response the response condition that main website receives can be three kinds:, show that the virtual address that does not have slave station belongs in the address realm of inquiry, main website changed an address realm and inquired about again or finish this inquiry this moment; 2), the virtual address inquiry response instruction of a slave station is received by main website, show and adopt the slave station of this virtual address (A) may have only one on the bus, promptly the virtual address of this slave station (A) is not equal to other the virtual address of any slave station on the bus, and this moment, main website entered step 2; 3), the main website virtual address inquiry response instruction of receiving a more than slave station, show more than one of the number that satisfies the slave station of address realm in the query statement of virtual address on the network, need do further processing this moment.
3, address based on the master-slave communication pattern according to claim 2 is distributed method to set up automatically, it is characterized in that: main website is as follows for the judgement and the relevant treatment thereof of the virtual address inquiry response instruction of receiving a more than slave station: main website is after the upper and lower bound at a certain section virtual address sends the virtual address query statement, main website receives the virtual address inquiry response instruction from slave station in an official hour window, if in the official hour window because the response of a more than slave station will cause main website to receive following error message: the independent response that a plurality of slave stations separate on the time is separately successively received by main website, make main website generation reception mistake or above-mentioned two kinds of mistakes that the comprehensive reception mistake that causes takes place simultaneously owing to the slave station response is overlapping in time; If one of above-mentioned three kinds of situations, main website judges not only one of slave station number in the upper and lower bound that belongs to this section virtual address on the bus in view of the above, needs main website to dwindle address realm this moment and resends the virtual address query statement;
Main website is behind the virtual address query statement that sends at some definite virtual addresses, main website receives the virtual address inquiry response instruction from slave station in an official hour window, if in the official hour window because the response of a more than slave station will cause main website to receive following error message: main website receives independent response that a plurality of slave stations separate on the time separately successively, because the slave station response is overlapping in time makes main website that mistake or above-mentioned two kinds of mistakes take place to receive the comprehensive reception mistake that causes takes place simultaneously; If one of above-mentioned three kinds of situations, main website judges in view of the above has a more than slave station to adopt this virtual address (A) on the bus, virtual address (A) promptly occurred and repeated, this moment, main website need send virtual address reorganization instruction at this virtual address (A).
4, the address based on the master-slave communication pattern according to claim 3 is distributed method to set up automatically, it is characterized in that: main station judging goes out on the bus slave station number not only the time that adopts some definite virtual addresses (A), there is repetition the virtual address (A) that is slave station, and main website sends virtual address reorganization instruction at this virtual address (A); After standing in the virtual address reorganization instruction that receives the main website transmission, as long as slave station belongs to the virtual address state and satisfies the bound requirement of address in the instruction of recombinating, slave station will produce the virtual address of a new numerical value as oneself; If comprise the virtual address scope after the reorganization in the reorganization instruction of the virtual address that main website sends, then the new virtual address of slave station generation must be within this scope; After instructing, the virtual address reorganization need not to respond any message from standing in to receive.
5, the address based on the master-slave communication pattern according to claim 1 is distributed method to set up automatically, it is characterized in that: on learning bus, adopt the slave station of certain virtual address may have only after one, the virtual address (A) of this slave station is learnt by main website from response instruction, enter step 2 afterwards; Completing steps 2 needs three types train of signal: the real address that main website sends is provided with real address that instruction, slave station send and the real address reorganization that response instruction and main website send is set instructs; It is the instruction that main website sends to slave station that the real address is provided with instruction, comprises the real address (C) of some virtual addresses (B), corresponding distribution; It is that slave station receives the real address response to it of instruction back is set that the real address is provided with response instruction, sends to the instruction of main website by slave station, comprises the real address (C) of the virtual address (B) of slave station oneself, corresponding distribution; Real address reorganization instruction is the instruction that main website sends to slave station, comprises the real address scope, and the real address scope is some definite real address or a certain section upper and lower bounds that needs the real address of reorganization that needs reorganization, also comprises the virtual address scope after the reorganization; The real address is provided with instruction and belongs to broadcast-type instruction, and all slave stations that are in the virtual address state all must receive and do respective handling on the bus; Real address reorganization instruction also belongs to the broadcast-type instruction, and all slave stations that are in the real address state all must receive and do respective handling on the bus;
Main website sends the real address instruction is set, some slave stations that is in the virtual address state are arranged to the real address state, this instruction is received by all slave stations, as long as the virtual address that slave station belongs to virtual address state and slave station equals the real address virtual address (B) in the instruction is set, then this slave station is provided with real address (C) in the instruction as oneself real address with the real address, and enters the real address state; Slave station also sends the real address and response instruction is set as the response that the real address is provided with instruction; 1), main website do not receive response, shows that step 1 may be wrong, returns step 1 real address that main website receives from slave station in an official hour window is provided with response instruction, and the response condition that main website receives can be three kinds:; 2), main website receives that the real address of a more than slave station is provided with response instruction, showing has a more than slave station to adopt virtual address (B), and these slave stations have all entered the real address state of employing real address (C), and this moment, main website need send real address reorganization instruction at this real address; 3), main website receives that the real address of a slave station is provided with response instruction, show to adopt the slave station of this virtual address (B) may have only one on the bus, and this slave station entered the real address state of employing real address (C), finish at the address assignment of this slave station.
6, address based on the master-slave communication pattern according to claim 5 is distributed method to set up automatically, it is characterized in that: after main website transmission real address is provided with instruction, the real address that receives in an official hour window from slave station is provided with response instruction, if in the official hour window because the response of a more than slave station will cause main website to receive following error message: the independent response that a plurality of slave stations separate on the time is separately successively received by main website, make main website generation reception mistake or above-mentioned two kinds of mistakes that the comprehensive reception mistake that causes takes place simultaneously owing to the slave station response is overlapping in time; If one of above-mentioned three kinds of situations, main website judges in view of the above to be had a more than slave station and has adopted real address (C) on the bus, real address (C) promptly occurred and repeated, this moment, main website need send real address reorganization instruction at this real address (C).
7, the address based on the master-slave communication pattern according to claim 6 is distributed method to set up automatically, it is characterized in that: if main website finds that there is repetition the real address of slave station on the network when sending the real address instruction is set or in the actual moving process, main website sends real address reorganization instruction; After standing in the real address reorganization instruction that receives the main website transmission, as long as slave station belongs to the real address state and satisfies the bound requirement of address in the instruction of recombinating, slave station will enter the virtual address state and produce the virtual address of a new numerical value as oneself; If comprise the virtual address scope after the reorganization in the reorganization instruction of the real address that main website sends, then the new virtual address of slave station generation must be within this scope; After instructing, the real address reorganization need not respond any message from standing in to receive; The real address is provided with instruction needs the slave station with real address state of reorganization to carry out at a certain section, carries out at some definite slave stations with real address state of reorganization that needs.
8, the address based on the master-slave communication pattern according to claim 1 is distributed method to set up automatically, it is characterized in that: main website is at the duration of work of communication system, but resends the virtual address query statement in the moment that can be scheduled to or in a preset time section.
9, the address based on the master-slave communication pattern according to claim 1 is distributed method to set up automatically, it is characterized in that: this method also is suitable for how main many from system, promptly is suitable for a plurality of (M1 of main website, M2, ... Mi) a plurality of slave stations (S1, S2 ... .Sn) such system; How the master is many will have a main website to finish address assignment from system, and remaining main website does not participate in address assignment or is taken as some special slave stations and treats.
10, the address based on the master-slave communication pattern according to claim 5 is distributed method to set up automatically, it is characterized in that: be: receive after real address that main website sends is provided with instruction from standing in as a method for simplifying of the present invention, slave station need not responded any instruction, and main website carries out in the actual moving process of network for the judgement that repeats the real address.
CNB2005100386525A 2005-04-01 2005-04-01 Automatic distributing and setting up address method based on master-slave communication mode Expired - Fee Related CN100477670C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2005100386525A CN100477670C (en) 2005-04-01 2005-04-01 Automatic distributing and setting up address method based on master-slave communication mode

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2005100386525A CN100477670C (en) 2005-04-01 2005-04-01 Automatic distributing and setting up address method based on master-slave communication mode

Publications (2)

Publication Number Publication Date
CN1674593A CN1674593A (en) 2005-09-28
CN100477670C true CN100477670C (en) 2009-04-08

Family

ID=35046850

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2005100386525A Expired - Fee Related CN100477670C (en) 2005-04-01 2005-04-01 Automatic distributing and setting up address method based on master-slave communication mode

Country Status (1)

Country Link
CN (1) CN100477670C (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101309306B (en) * 2008-07-16 2010-06-30 哈尔滨工业大学 Method for allocating addresses from node device in Modbus communication network
TWI481245B (en) * 2012-12-19 2015-04-11 Motech Ind Inc Address setting method for slave devices of communication network
CN103108319B (en) * 2013-02-06 2015-10-28 中达电通股份有限公司 For method and the device of LED street lamp built-in controller Lookup protocol address
CN103345217B (en) * 2013-06-18 2016-03-30 苏州骋研电子技术有限公司 Team control blower fan filtering unit system
CN104639666B (en) * 2013-11-06 2019-04-16 腾讯科技(深圳)有限公司 Method for accessing domain name and device
CN103716420A (en) * 2014-01-03 2014-04-09 西南大学 Automatic station address obtaining method of Modbus ASCII slave station and slave station
CN107205059B (en) 2016-03-17 2021-02-12 华为技术有限公司 Method for managing meter equipment address, acquisition terminal and meter equipment
CN106878488B (en) * 2017-04-29 2020-03-20 成都工鼎科技有限公司 Automatic Modbus RTU bus address allocation method
CN107580085B (en) * 2017-10-26 2019-12-13 北京科技大学 Networking method of Internet of things
CN108316975A (en) * 2018-02-06 2018-07-24 天地(常州)自动化股份有限公司 A kind of coal mine safety monitoring system sensor address auto-allocation method
CN108833602A (en) * 2018-05-24 2018-11-16 湖北文理学院 A kind of bus address auto-allocation method and system based on component manufacturing variation
CN109218155A (en) * 2018-09-13 2019-01-15 深圳益邦物联科技有限公司 Address automatic distribution system and method based on Modbus rtu protocol
CN110296503B (en) * 2019-05-10 2021-04-27 珠海格力电器股份有限公司 Method for automatically allocating addresses to air conditioning unit and air conditioning system
CN111756609B (en) * 2020-06-15 2022-03-04 苏州汇川控制技术有限公司 Station number automatic allocation method, master station equipment, slave station equipment and single-spindle detection system
CN115277295B (en) * 2022-07-29 2023-12-19 广东美的智能科技有限公司 Communication method of controller and controller

Also Published As

Publication number Publication date
CN1674593A (en) 2005-09-28

Similar Documents

Publication Publication Date Title
CN100477670C (en) Automatic distributing and setting up address method based on master-slave communication mode
CN1881120B (en) Communication master station startup period control method
CN101582824B (en) Node number automatic distribution method for controlling secondary node equipment of local area network bus
CN100534101C (en) Method and device for allocation of network terminal device addresses in a profinet-io network
CN103716420A (en) Automatic station address obtaining method of Modbus ASCII slave station and slave station
CN104079677A (en) Automatic allocation method of RS485 communication port address
CN101477506A (en) Addressing system and method of master equipment to slave equipment
CN103856578A (en) Automatic slave station address acquisition method through Modbus RTU and slave station
CN109656755A (en) The method and system of detection device state
CN102365844A (en) Communication adapter device
CN103001888B (en) A kind of transmission method of real time data and node device
CN104301191A (en) Bus system
CN104255041A (en) Communication system
CN101562639A (en) Information synchronization method, device and system
CN103186440A (en) Method, device and system for detecting in-place state of sub cards
KR100291005B1 (en) Fan-out expansion circuit for multi-drop connection with rs-485
EP2203821B1 (en) Secure data transmission method and apparatus
CN110290231A (en) Distribution method, distributor, central air conditioner system and storage medium
CN110995889A (en) Address allocation system and method
JP4988450B2 (en) Power line communication system in distribution board
CN102638589A (en) Determining method of corresponding connection relation of channels, as well as related connecting ends and system
US20200267115A1 (en) Switch and Method for Providing a Name Service within an Industrial Automation System by Distributing Supplemented Router Advertisement Messages
CN210518417U (en) Address allocation system
CN116016445A (en) Address allocation method for master-slave bus communication system
CN105306614A (en) Address management method, address management system, address manager and local address management device

Legal Events

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

Granted publication date: 20090408

Termination date: 20140401