Summary of the invention
In view of this, the invention provides a kind of electric power communication method and system, improve the system communication real-time, and simplify swivel link in communication network, the minimizing network, save software and hardware resources with realization based on MODBUS TCP/IP.
A kind of electric power communication method based on MODBUS TCP/IP is used for power communication system, comprises MODBUS TCP/IP main website and MODBUS TCP/IP slave station, comprising:
Slave station deposits system status information in the corresponding informance address field in according to the instruction that main website sends;
Main website reads in each switching value and analog quantity polling period in the target slave station handshake register and described instruction corresponding response status indicator position, when responsive state sign position is 1, reads described system status information.
Above-mentioned execution mode is used for having important information to return in the power communication process, processing as far and near state information, device communications status or other device locking information or the like, the information that main website reads in each switching value and analog quantity polling period in the target slave station handshake register message address territory is in time fed back to the operator, reduce communication load, reached the strong and succinct technique effect of networking of real-time communication.
Preferably, described method also comprises: with the switching value of electric power communication device and analog quantity stem register as handshake register, and in described handshake register mark and main website instruction corresponding response status indicator position.
In the above-mentioned execution mode, be object with the electric power communication device, some registers of switching value and analog quantity stem are used as handshake register, be used for the more mutual communication process states of communicating pair, handshake register is in the slave station allocation space, the main website visit of issuing an order.
Preferably, the instruction of sending when described main website is when revising electric power communication device running status definite value, to be specially:
Slave station receives the modification definite value of utilizing function code to write by main website, and described amended definite value is put into the definite value zone, and replacement fixed value modification responsive state sign position, and the notice main website reads the current definite value in modification back;
Main website reads the described fixed value modification responsive state sign position in the described handshake register continuously in each switching value and analog quantity polling period, read when described fixed value modification responsive state sign position is 1 and revise the back definite value.
In said embodiment, main website writes the modification definite value by function code, and described modification definite value comprises definite value group number, area code, definite value number and value data to be revised.
Preferably, when the instruction of sending when described main website is read failure record ripple, be specially:
Slave station reads the record ripple piece the recorder data successively and deposits record ripple address field in from buffering area, and, replacement read failure record wave response status indicator position;
Main website reads the failure wave-recording responsive state sign position of handshake register continuously in each switching value and analog quantity polling period, read this record ripple piece when described failure wave-recording responsive state sign position is 1;
When a plurality of record ripple piece was arranged in the described recorder data, the main website zero clearing failure wave-recording responsive state sign position and the said process that circulates were until finishing reading of whole failure wave-recording.
What above-mentioned execution mode embodied is after main website finds newly to record ripple from handshake register, to adopt function code to read the process of record ripple fritter one by one from record ripple address field.
Preferably, described method also comprises: for described electric power communication device distributes address field and functional address territory, be specially:
With each electric power communication device is that object distributes address field, and with element identifier (element ID) among the MODBUS application protocol MBAP each electric power communication device is identified, and each object has the full register space of MODBUS;
According to master station communication function distribution function address field, the mapping of setting up described functional address territory and described address field.
Present embodiment is that object distributes address field with the electric power communication device, each object has the full register space 0000H-ffffH of MODBUS, according to concrete function distribution function address field in the space, the application function and the address field of electric power communication device are bound one to one again.
Preferably, described method also comprises: utilize the protocol identifier among the MODBUS application protocol MBAP to identify the acquisition protocols of slave station to each electric power communication device.
Protocol identifier among the described MBAP is used to identify the acquisition protocols of each electric power communication device on the slave station, as CAN communication protocol, MODBUS serial port protocol, IEC60870-5-103 agreement etc.
Preferably, described method also comprises:
Main website sends regularly write switch amount and the instruction of regularly writing analog quantity to described slave station in each switching value and analog quantity polling period, and the indication slave station writes described instruction in the reverse transmite data register (TDR) address field.
In this by way of example, described main website can take to allow main website oppositely slave station be passed regularly the write switch amount periodically down and regularly write the order of analog quantity, orders to write in the reverse data register address field that slave station puts.
Preferably, described method also comprises: main website is with the counter of the TCP message sequence number transaction identifier as MBAP, the calling/response packet between coupling main website and the slave station.
In the present embodiment, main website sends a calling bag or receives a response packet, and then this counter adds 1, and making zero after overflowing resets, and has solved order and the inconsistent problem of the order of request that the calling in the Ethernet/response packet arrives.
A kind of power communication system based on MODBUS TCP/IP comprises MODBUS TCP/IP main website and MODBUS TCP/IP slave station, and described slave station is provided with a plurality of, and described main website and a plurality of slave station pass through ethernet communication;
Described a plurality of slave station is connected by bus with electric power communication device respectively;
Described each slave station is used for, and the instruction of sending according to main website deposits system status information in the corresponding informance address field in;
Described main website is used for, and reads in each switching value and analog quantity polling period in the target slave station handshake register and described instruction corresponding response status indicator position, when responsive state sign position is 1, reads described system status information.
Preferably, described bus is specially: RS232/485 and/or CAN bus.
Described System and method for correspondence, powerline network framework based on MODBUS TCP/IP, main website cycle taking turn switching value and analog quantity, state in the handshake register of reading back in real time, realize the real-time information interaction between main website and the slave station, reduced communication load, it is succinct to have reached network architecture, the purpose that software and hardware resources is economical.
From above-mentioned technical scheme as can be seen, the embodiment of the invention is based on MODBUS TCP/IP electric power communication method, utilize the opportunity of main website cycle taking turn switching value and analog quantity, read electric power communication device state in handshake register in real time, reach the purpose of slave station, not only the communication efficiency height to main website reporting real-time state, and reduced communication load, and network construction form is succinct, has overcome network architecture complexity in the prior art, and software and hardware resources expends high technological deficiency.
Embodiment
For quote and know for the purpose of, hereinafter the technical term of Shi Yonging, write a Chinese character in simplified form or abridge and be summarized as follows:
MODBUS TCP/IP:MODBUS Transmission Control Protocol/InternetProtocol; Transmission control protocol/internet interconnection protocol based on MODBUS.
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
The MODBUS agreement is a kind of all-purpose language that is applied on the electronic controller.By this agreement, controller each other, controller is via communicating by letter between network (for example Ethernet) and the miscellaneous equipment.MODBUS TCP/IP is as a kind of control field automation standard, existing programmable logic controller (PLC) (PLC) based on MODBUS communication needs mixed networking, software and hardware expends height, and this MODBUS TCP/IP of employing in these method and system, can carry out real time communication by the disclosed mode of the inventive method embodiment, simplify communication network, reduced communication load and network transit node, save software and hardware resources.
Fig. 1 shows a kind of electric power communication method based on MODBUS TCP/IP, is used for power communication system, comprises MODBUS TCP/IP main website and MODBUS TCP/IP slave station, comprising:
Step 11: slave station deposits system status information in the corresponding informance address field in according to the instruction that main website sends;
Need to prove: described system status information comprises far and near state information, device communications status or other device locking information etc. that interactive information between main website and the slave station and electric power communication device return.
Step 12: main website reads in each switching value and analog quantity polling period in the target slave station handshake register and described instruction corresponding response status indicator position;
Step 13: judge whether described responsive state sign position is at 1 o'clock, if, then read described system status information, otherwise, carry out step 14;
As preferably, in the present embodiment with the switching value of electric power communication device and analog quantity stem register as handshake register, and in described handshake register mark and main website instruction corresponding response status indicator position.Specific to present embodiment, be object with the electric power communication device, switching value and 8 registers of analog quantity stem are used as handshake register, but do not limited to above-mentioned execution mode.
Step 14: if behind the wait timeout, corresponding state sign position is 0 o'clock, then communication failure.
In order to improve such scheme, as preferably, main website is with the counter of the TCP message sequence number transaction identifier as MBAP, the calling/response packet between coupling main website and the slave station.In the present embodiment, main website sends a calling bag or receives a response packet, and then this counter adds 1, and making zero after overflowing resets, and has solved order and the inconsistent problem of the order of request that the calling in the Ethernet/response packet arrives.
In the present embodiment, the information that main website reads in each switching value and analog quantity polling period in the target slave station handshake register message address territory is in time fed back to the operator, rationally reduce communication load, reached the strong and succinct technique effect of networking of real-time communication.
Fig. 2 shows another electric power communication method based on MODBUS TCP/IP, and the method flow that this embodiment embodies is the main website instruction of sending when revising electric power communication device running status definite value specifically comprises:
Step 21: slave station receives the modification definite value of utilizing function code to write by main website, and described amended definite value is put into the definite value zone, and replacement fixed value modification responsive state sign position, and the notice main website reads the current definite value in modification back;
Step 22: main website reads the described fixed value modification responsive state sign position in the described handshake register continuously in each switching value and analog quantity polling period;
Step 23: judge whether described fixed value modification responsive state sign position is 1, if, then read and revise the back definite value, otherwise, carry out step 24
Step 24: if behind the wait timeout, fixed value modification responsive state sign position is 0 o'clock, then revises the definite value failure.
It should be explicitly made clear at this point: in said embodiment, main website writes the modification definite value by function code, and described modification definite value comprises definite value group number, area code, definite value number and value data to be revised.
Fig. 3 shows another electric power communication method based on MODBUS TCP/IP, this embodiment embodies be when instruction that described main website sends be the flow process of read failure when recording ripple, specifically comprise:
Step 31: slave station reads the record ripple piece the recorder data successively and deposits record ripple address field in from buffering area, and, replacement read failure record wave response status indicator position;
Step 32: main website reads the failure wave-recording responsive state sign position of handshake register continuously in each switching value and analog quantity polling period;
Step 33: failure judgement records whether wavy attitude sign position is 1, and when described failure wave-recording responsive state sign position is 1, read this record ripple piece, otherwise carry out step 33, and, main website zero clearing failure wave-recording responsive state sign position;
Step 34:, then read the failure of record ripple at 0 o'clock if behind the wait timeout, failure wave-recording status indicator position is.
Step 35: judge whether that with complete the reading of whole record ripple if still have record ripple piece not to be read, circulation step 31-step 34 then is until finishing reading of whole failure wave-recording.
Need to prove: a common record ripple partial data need be divided into after some record ripple fritters main website finds newly record ripple from handshake register, and the employing function code reads the process of recording the ripple fritter one by one from recording the ripple address field.
Fig. 4 shows another electric power communication method based on MODBUS TCP/IP, comprising:
Step 41: with each electric power communication device is that object distributes address field, and with element identifier (element ID) among the MODBUS application protocol MBAP each electric power communication device is identified, and each object has the full register space of MODBUS;
Step 42: according to master station communication function distribution function address field, the mapping of setting up described functional address territory and described address field;
Present embodiment is that object distributes address field with the electric power communication device, each object has the full register space 0000H-ffffH of MODBUS, according to concrete function distribution function address field in the space, the application function and the address field of electric power communication device are bound one to one again.
Step 43: utilize the protocol identifier among the MODBUS application protocol MBAP to identify the acquisition protocols of slave station to each electric power communication device;
Step 44: slave station deposits system status information in the corresponding informance address field in according to the instruction that main website sends;
Step 45: main website sends regularly write switch amount and the instruction of regularly writing analog quantity to described slave station in each switching value and analog quantity polling period, and the indication slave station writes described instruction in the reverse transmite data register (TDR) address field.
Among this embodiment, described main website can take to allow main website oppositely slave station be passed regularly the write switch amount periodically down and regularly write the order of analog quantity, orders to write in the reverse data register address field that slave station puts.More specifically, the above-mentioned slave station that is applied as sends reverse control to main website, sends the order of slave station inverse operation by slave station to main website contrary operation address field and realizes, after the slave station request command is received by main website, carries out the reverse control of transmitting from the slave station request.
Fig. 5 shows a kind of power communication system based on MODBUS TCP/IP, comprises MODBUSTCP/IP main website 51 and MODBUS TCP/IP slave station, as shown in the figure:
Described slave station 52 is provided with a plurality of, and described main website 51 passes through ethernet communication with a plurality of slave stations 52;
Described a plurality of slave station 52 is connected by bus with electric power communication device 53 respectively;
Described each slave station 52 is used for, and the state information that electric power communication device 53 is returned in the instruction of sending according to main website 51 deposits in the return information address field;
Described main website 51 is used for, and reads in each switching value and analog quantity polling period in the target slave station handshake register and described instruction corresponding response status indicator position, when responsive state sign position is 1, reads described system status information.
Particularly, described slave station has a plurality of, identifies one in the drawings, and other identify no longer one by one.Described bus is specially: RS232/485 and/or CAN bus.
Described System and method for correspondence, powerline network framework based on MODBUS TCP/IP, main website cycle taking turn switching value and analog quantity, state in the handshake register of reading back in real time, realize the real-time information interaction between main website and the slave station, it is succinct to have reached network architecture, the purpose that software and hardware resources is economical.
In sum:
Embodiments of the invention are based on MODBUS TCP/IP electric power communication method, utilize the opportunity of main website cycle taking turn switching value and analog quantity, read electric power communication device state in handshake register in real time, reach the purpose of slave station to main website reporting real-time state, not only the communication efficiency height has rationally reduced communication load, and network construction form is succinct, overcome network architecture complexity in the prior art, software and hardware resources expends high technological deficiency.
Each embodiment adopts the mode of going forward one by one to describe in this specification, and what each embodiment stressed all is and the difference of other embodiment that identical similar part is mutually referring to getting final product between each embodiment.For the disclosed device of embodiment, because it is corresponding with the embodiment disclosed method, so description is fairly simple, relevant part partly illustrates referring to method and gets final product.
It will be understood by those skilled in the art that and to use many different technologies and in the technology any one to come expression information, message and signal.For example, the message of mentioning in the above-mentioned explanation, information can be expressed as voltage, electric current, electromagnetic wave, magnetic field or magnetic particle, light field or above combination in any.
The professional can also further recognize, the unit and the algorithm steps of each example of describing in conjunction with embodiment disclosed herein, can realize with electronic hardware, computer software or the combination of the two, for the interchangeability of hardware and software clearly is described, the composition and the step of each example described prevailingly according to function in the above description.These functions still are that software mode is carried out with hardware actually, depend on the application-specific and the design constraint of technical scheme.The professional and technical personnel can use distinct methods to realize described function to each specific should being used for, but this realization should not thought and exceeds scope of the present invention.
The method of describing in conjunction with embodiment disclosed herein or the step of algorithm can directly use the software module of hardware, processor execution, and perhaps the combination of the two is implemented.Software module can place the storage medium of any other form known in random asccess memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or the technical field.
To the above-mentioned explanation of the disclosed embodiments, make this area professional and technical personnel can realize or use the present invention.Multiple modification to these embodiment will be conspicuous concerning those skilled in the art, and defined herein General Principle can realize under the situation that does not break away from the spirit or scope of the present invention in other embodiments.Therefore, the present invention will can not be restricted to these embodiment shown in this article, but will meet and principle disclosed herein and features of novelty the wideest corresponding to scope.