Data acquisition method and system based on cascade Ethernet equipment
Technical Field
The invention relates to a data acquisition method, in particular to a data acquisition method based on cascade Ethernet, and also discloses a data acquisition system applying the data acquisition method.
Background
Industrial automation systems are evolving towards distributed, intelligent real-time control, where communication is critical, and ethernet is widely regarded as the best solution for future industrial networks due to its "one-to-bottom" reputation.
The data acquisition is an interface technology for acquiring data from the outside of a system and inputting the data into the inside of the system by using a device, and the data is repeatedly acquired at the same point at certain intervals (called sampling period), so that the data acquisition method is widely applied to various fields. With the rapid development of the internet industry, data acquisition combined with ethernet has been widely used in the internet and distributed fields, bringing data acquisition into a new era.
The periodic data acquisition adopts a working architecture of a client/server, a data summarizing end is used as the client, an acquisition terminal is used as the server, when the data summarizing end needs to acquire data, a command request is sent to the acquisition terminal, and the acquisition terminal responds to the command request and returns the data to be acquired. According to the communication flow, the data acquisition of other residual acquisition terminals is completed in one sampling period. The defects are that: the cascaded ethernet terminal devices need to specify IP addresses, and the IP addresses between the ports of adjacent devices must be in one network segment. The number of terminal devices cannot be dynamically adjusted, and when the number of cascade devices is increased or decreased, network connection configuration items of associated devices need to be modified to ensure that adjacent devices can access each other after the increase or decrease.
In addition, the number of cascade devices is increased, the number of required IP addresses is increased in multiple, the time for each device to operate the TCP/IP protocol stack cannot be ignored, and the real-time performance of data communication is greatly reduced.
Disclosure of Invention
Aiming at the defects of the prior art, the invention provides a cascade Ethernet equipment-based data acquisition method which is free from configuration and adaptive to the quantity change of network equipment.
Another technical problem to be solved by the present invention is to provide a system applying the aforementioned data acquisition method.
The technical problems to be solved by the invention are realized by the following technical proposal. The invention relates to a data acquisition method based on cascade Ethernet equipment, which is characterized in that the method is used for data communication between a data summarizing terminal and a plurality of sets of acquisition terminals; the data summarizing terminal and the acquisition terminal are terminal equipment;
the plurality of sets of acquisition terminals are connected through an Ethernet cable in a hand-in-hand manner and finally connected to the data sink terminal to form a cascade system of Ethernet interfaces;
the method is based on the expansion of the data link layer of the Ethernet, and uses an identifier and a data field, wherein the length of the identifier is 2 bytes, and the value is larger than 0x5dc.
The data acquisition method based on cascade Ethernet equipment, which is disclosed by the invention, has the further preferable technical scheme that: for a data summarizing terminal or an acquisition terminal connected to the cascading system, a new data frame is received, whether the numerical value in the identifier domain is the same as the defined numerical value or not is judged, and if the numerical value is the same, a data acquisition method is adopted for processing; if not, then processing is performed by a standard protocol stack.
The data acquisition method based on cascade Ethernet equipment, which is disclosed by the invention, has the further preferable technical scheme that: using the first byte of the data field as a command code, and completing communication with different functions according to different values; designing a second byte of the data field as an auxiliary code; the definition of the command code is as follows:
(1) "0x1" means transmitting a data frame to a specified terminal device
The terminal equipment sends a data frame to the terminal equipment with the appointed hardware physical address, and the terminal equipment conforming to the address receives the data frame and performs corresponding functional processing according to the auxiliary code;
(2) "0x2" means a request in response to the command code "0x1
After receiving the data frame with the command code of 0x1, the terminal equipment replies the data frame with the command code of 0x 2;
(3) "0x3" means transmitting data frames to a plurality of terminal devices
The terminal equipment sends a data frame with a command code of 0x3 to other equipment in the whole cascade system, and the terminal equipment which receives the data frame carries out corresponding functional processing according to the auxiliary code;
(4) "0x4" means a request in response to the command code "0x3
After receiving the data frame with the command code of 0x3, the terminal equipment replies the data frame with the command code of 0x 4.
The data acquisition method based on cascade Ethernet equipment, which is disclosed by the invention, has the further preferable technical scheme that: the terminal equipment in the cascade system rapidly acquires the hardware physical addresses of the adjacent equipment and the serial equipment thereof by adopting the following method:
(1) The terminal equipment, namely the terminal equipment with the adjacent request direction, namely the response party 1, sends a data frame with the command code of 0x3, the source physical address in the data frame is the self physical address, the destination physical address is the broadcast address of all 1's, the auxiliary code is 1, and the 3 rd to 8 th positions of the data domain store the self physical address;
(2) After receiving the data frame, the responder 1 responds to the data frame with the command code of 0x4, the auxiliary code of 1, and the positions from 3 rd to 8 th of the data field store the physical address of the requester, and the positions from 9 th to 14 th of the data field store the physical address of the responder; meanwhile, the data frame is forwarded to the adjacent terminal equipment, namely the responder 2, through another port, and the source physical address is changed into the physical address of the responder 1 before forwarding;
(3) After receiving the data frame, the responder 2 responds to the data frame with the command code of 0x4, and forwards the data frame to the adjacent terminal equipment, namely the responder 3, through another port;
after receiving the response data frame of the response party 2, the response party 1 forwards the response data frame through another Ethernet port until the request party receives the response data frame;
(4) After receiving the response data frame of the response party 2, the response party 1 forwards the response data frame through another Ethernet port until the request party receives the response data frame;
(5) And so on until the last terminal device responds by sending a data frame with a command code of "0x 4".
The data acquisition method based on cascade Ethernet equipment, which is disclosed by the invention, has the further preferable technical scheme that: the data communication is carried out between any two terminal devices in the cascade system, the functions of configuration, control and alarm lamp are completed, the terminal device X and the terminal device Y carry out data communication, and a transfer device is arranged between the two devices, wherein the data communication method is as follows:
(1) The terminal equipment X sends a data frame with a command code of 0X1 to the adjacent transfer equipment, wherein the source physical address in the data frame is a broadcast address of which the destination physical address is all 1, the auxiliary code is 1, the 3 rd to 8 th positions of the data field store the physical address of the terminal Y, and the 9 th to 14 th positions of the data field store the physical address of the terminal Y;
(2) After the transfer equipment receives the data frame and judges that the 9 th to 14 th positions of the data domain are different from the physical address of the transfer equipment, the data frame is transferred through another Ethernet port, and the source physical address is changed into the physical address of the transfer equipment before the transfer;
(3) The terminal equipment Y receives the data frame forwarded by the transfer equipment, judges that the numerical value of the 9 th to 14 th positions of the data domain is the same as the physical address of the terminal equipment Y, and processes different functions according to the value of the auxiliary code;
(4) The terminal equipment Y sends a response data frame with a command code of 0X2 to the transfer equipment, the source physical address in the data frame is the address of the transfer equipment, the destination physical address is the address of the transfer equipment, the auxiliary code is 1, the 3 rd to 8 th positions of the data field store the physical address of the terminal equipment X, and the 9 th to 14 th positions of the data field store the physical address of the terminal equipment X;
(5) After the transfer equipment receives the data frame and judges that the command code is 0X2 and the values from 3 rd to 8 th of the data domain are different from the self address, the data frame is forwarded through another Ethernet port, the source physical address is changed into the physical address of the transfer equipment before forwarding, and the target physical address is the address of the terminal equipment X;
(6) After receiving the forwarding frame, the terminal device X determines that the command code is "0X2" and the values from 3 rd to 8 th of the data field are the same as the self address, and finally receives the response data frame of the terminal device Y.
The data acquisition method based on cascade Ethernet equipment, which is disclosed by the invention, has the further preferable technical scheme that: the data summarizing terminal initiates a communication request to a plurality of collecting terminals, and the data summarizing terminal is required to return the respective collected data to the data summarizing terminal, so that a one-to-many periodical data communication process is realized; in a communication period of 'one-to-many', the 'data summarizing end' only needs to send a command request once, and a plurality of 'acquisition terminals' respond in turn and return acquired data of the terminal:
(1) The data summarizing terminal, namely the acquisition terminal with the adjacent request direction, namely the response party 1, sends a data frame with the command code of 0x3, the source physical address in the data frame is the broadcast address of all 1's, the auxiliary code of 2's, and the 3 rd to 8 th positions of the data domain store the physical address of the data frame;
(2) After receiving the data frame, the responder 1 responds to the data frame with the command code of 0x4, the auxiliary code of 2, and the positions from 3 rd to 8 th of the data field store the physical address of the requester, and the positions from 9 th to 14 th of the data field store the physical address of the responder; meanwhile, the data frame is forwarded to the adjacent terminal equipment, namely the responder 2, through another port, and the source physical address is changed into the physical address of the responder 1 before forwarding;
(3) After receiving the data frame, the responder 2 responds to the data frame with the command code of 0x4, and forwards the data frame to the adjacent terminal equipment, namely the responder 3, through another port;
(4) After receiving the response data frame of the response party 2, the response party 1 forwards the response data frame through another Ethernet port until the request party receives the response data frame;
(5) And so on until the last terminal device responds by sending a data frame with a command code of "0x 4".
The technical problems to be solved by the invention can be further realized by the following technical scheme. The invention also discloses a data acquisition system based on the cascade Ethernet equipment for realizing the data acquisition method, which is characterized by comprising a data summarizing terminal and a plurality of sets of acquisition terminals, wherein the sets of acquisition terminals are connected by an Ethernet cable in a hand-in-hand manner and finally connected to the data summarizing terminal to form the cascade system of the Ethernet interface. Each acquisition terminal is provided with 2 Ethernet interfaces.
Based on the fact that the ethernet device can receive all "1" physical addresses or data frames identical to its own physical address, data frames not conforming to the physical address will be discarded. According to the principle, the invention designs the methods of 'quick physical address exchange', 'point-to-point communication' and 'one-to-many communication', and realizes the data acquisition method of the cascade Ethernet.
1. Unique identifier design
Data frames conforming to the identifier features of the present invention can only be processed by distinguishing the identifier from data frames such as TCP/IP. The identifier designed by the invention is compatible with the existing hardware network equipment and the standard software protocol stack. In other words, the terminal device adopting the invention can coexist with other standard network devices in a local area network.
2. The self-adaptive terminal equipment is increased or decreased without configuration
The user does not have to set the IP address, nor care whether the IP address is in a network segment. Even if the cascade network dynamically contracts and terminal equipment is increased or reduced, the method of the invention can still work normally without being influenced.
Compared with the prior art, the invention has the following advantages and technical effects:
(1) Configuration-free, adaptive network device number change
The user does not have to set the IP address, nor care whether the IP address is in a network segment. Even if the cascade network dynamically contracts and terminal equipment is increased or reduced, the method of the invention can still work normally without being influenced.
(2) High efficiency, easy realization, and better real-time performance of data communication
a) The prior art needs to run a huge TCP/IP protocol stack to forward a data frame, and the time spent is far longer than the time spent in the invention.
b) The method of the invention can be realized by FPGA (field programmable gate array) technology or custom chips, the receiving/processing/forwarding of the data frames can be performed in parallel, and the forwarding time of the data frames can be ignored.
Drawings
FIG. 1 is a schematic diagram of the overall cascade system architecture of the present invention;
FIG. 2 is a schematic diagram of an Ethernet data frame format;
FIG. 3 is a flow chart of a process of receiving a new data frame;
FIG. 4 is a schematic diagram of a fast hardware address exchange flow;
FIG. 5 is a schematic diagram of a point-to-point communication process;
fig. 6 is a schematic diagram of a one-to-many communication method.
Description of the embodiments
Specific embodiments of the invention will be further described below with reference to the accompanying drawings, in order to facilitate a further understanding of the invention by those skilled in the art, without limiting the scope of the claims thereto.
Embodiment 1, a cascade ethernet-based data acquisition method: the method is used for data communication between data summarizing terminals and N sets of acquisition terminals (N is more than or equal to 1).
N sets of 'acquisition terminals' are connected through an Ethernet cable in a hand-in-hand mode and finally connected to the 'data sink terminal', so that a cascade system structure of an Ethernet interface is formed. The overall cascade system architecture is shown in fig. 1.
The data acquisition method does not conflict with the existing HUB, switch and other network devices and TCP/IP and other standard protocol stacks.
The data acquisition method is extended based on a data link layer of the Ethernet, and uses an identifier and a data field, wherein the length of the identifier is 2 bytes, and the value is more than 0x5dc. As shown in fig. 2.
For a data summarizing terminal or an acquisition terminal connected to the cascading system, a new data frame is received, whether the numerical value in an identifier domain is the same as the numerical value defined by the method is judged, and if the numerical value is the same as the numerical value defined by the method, the method is adopted for processing; if different, then processing is done by a standard protocol stack (TCP/IP, etc.). The whole data frame processing flow is shown in fig. 3.
The method uses the first byte of the data field as a command code, and completes the communication of different functions according to different values. The present invention designs the second byte of the data field as an auxiliary code.
For convenience of description, the data summarizing terminal and the collecting terminal are simply called as terminal equipment.
Definition of command codes:
(1) "0x1" means transmitting a data frame to a specified terminal device
The terminal equipment sends a data frame to the terminal equipment with the appointed hardware physical address, and the terminal equipment conforming to the address receives the data frame and performs corresponding functional processing according to the auxiliary code.
(2) "0x2" means a request in response to the command code "0x1
After receiving the data frame with the command code of 0x1, the terminal equipment replies the data frame with the command code of 0x 2.
(3) "0x3" means transmitting data frames to a plurality of terminal devices
The terminal equipment sends a data frame with the command code of 0x3 to other equipment in the whole cascade system, and the terminal equipment which receives the data frame carries out corresponding functional processing according to the auxiliary code.
(4) "0x4" means a request in response to the command code "0x3
After receiving the data frame with the command code of 0x3, the terminal equipment replies the data frame with the command code of 0x 4.
The related communication method is as follows:
(1) Quick hardware address exchange method
The terminal equipment in the cascade system can rapidly acquire the hardware physical addresses of the adjacent equipment and the serial equipment thereof by using the method.
a) The terminal device (the requesting party) sends a data frame with a command code of 0x3 to the adjacent terminal device (the responding party 1), the source physical address in the data frame is a broadcast address with a destination physical address of all 1, the auxiliary code is 1, and the 3 rd to 8 th positions of the data domain store the physical address of the data frame.
b) After receiving the data frame, the responder 1 responds to the data frame with the command code of 0x4, the auxiliary code of 1, and the positions from 3 rd to 8 th of the data field store the physical address of the requester, and the positions from 9 th to 14 th of the data field store the physical address of the responder; and simultaneously, the data frame is forwarded to the adjacent terminal equipment (the responder 2) through another port, and the source physical address is changed into the physical address of the responder 1 before forwarding.
c) After receiving the data frame, the responder 2 responds to the data frame with the transmission command code of "0x4", and forwards the data frame to the adjacent terminal equipment (the responder 3) through another port.
After receiving the response data frame of the response party 2, the response party 1 forwards the response data frame through another Ethernet port until the request party receives the response data frame
d) After receiving the response data frame of the response party 2, the response party 1 forwards the response data frame through another Ethernet port until the request party receives the response data frame
e) And so on until the last terminal device responds by sending a data frame with a command code of "0x 4".
The whole process is shown in fig. 4. In the figure, "AB", "CD", "EF", etc. represent hardware addresses of terminal devices, as follows.
(2) Point-to-point data communication
And data communication is carried out between any two terminal devices in the cascade system, so that the functions of configuration, control and alarm lamp are completed.
The terminal X (AB) and the terminal Y (EF) communicate data, and a transfer device (CD) is provided between the two devices.
a) The terminal X sends a data frame with a command code of 0X1 to adjacent transfer equipment, the source physical address in the data frame is a broadcast address with a destination physical address of all 1, the auxiliary code is 1, the 3 rd to 8 th positions of the data field store the physical address of the terminal Y, and the 9 th to 14 th positions of the data field store the physical address of the terminal Y;
b) After the transfer equipment receives the data frame and judges that the 9 th to 14 th positions of the data domain are different from the physical address of the transfer equipment, the data frame is transferred through another Ethernet port, and the source physical address is changed into the physical address of the transfer equipment before the transfer;
c) The terminal Y receives the data frame forwarded by the transfer equipment, judges that the numerical value of the 9 th to 14 th positions of the data domain is the same as the physical address of the terminal Y, and processes different functions according to the value of the auxiliary code;
d) The terminal Y sends a response data frame with a command code of 0X2 to the transfer equipment, the source physical address in the data frame is the address of the transfer equipment, the destination physical address is the address of the transfer equipment, the auxiliary code is 1, the 3 rd to 8 th positions of the data field store the physical address of the terminal X, and the 9 th to 14 th positions of the data field store the physical address of the terminal X;
e) After the transfer equipment receives the data frame and judges that the command code is 0X2 and the values from 3 rd to 8 th of the data domain are different from the self address, the data frame is forwarded through another Ethernet port, the source physical address is changed into the physical address of the transfer equipment before forwarding, and the target physical address is the address of the terminal X;
f) After receiving the forwarding frame, the terminal X determines that the command code is "0X2" and the values from 3 rd to 8 th of the data field are the same as the self address, and finally receives the response data frame of the terminal Y.
The whole process is shown in fig. 5. In the figure, "XXXX", "YYYY", and the like denote data in a data frame, and the following is the same.
(3) One-to-many communication method
The data summarizing terminal initiates communication requests to a plurality of collecting terminals, and the data summarizing terminal is required to return the respective collected data to the data summarizing terminal, and the one-to-many communication is a periodical data communication process.
In a one-to-many communication period, the data summarizing end only needs to send a command request once, and a plurality of acquisition terminals respond in turn according to the method of the invention and return the acquired data of the terminals. The whole process is shown in fig. 6.
a) The data summarizing end (requesting party) sends a data frame with a command code of 0x3 to an adjacent acquisition terminal (responding party 1), the source physical address in the data frame is the broadcasting address of all 1's, the auxiliary code is 2, and the 3 rd to 8 th positions of the data domain store the physical address of the data frame.
b) After receiving the data frame, the responder 1 responds to the data frame with the command code of 0x4, the auxiliary code of 2, and the positions from 3 rd to 8 th of the data field store the physical address of the requester, and the positions from 9 th to 14 th of the data field store the physical address of the responder; and simultaneously, the data frame is forwarded to the adjacent terminal equipment (the responder 2) through another port, and the source physical address is changed into the physical address of the responder 1 before forwarding.
c) After receiving the data frame, the responder 2 responds to the data frame with the transmission command code of "0x4", and forwards the data frame to the adjacent terminal equipment (the responder 3) through another port.
d) After receiving the response data frame of the response party 2, the response party 1 forwards the response data frame through another Ethernet port until the request party receives the response data frame
e) And so on until the last terminal device responds by sending a data frame with a command code of "0x 4".
In embodiment 2, referring to fig. 1, a cascade ethernet device-based data acquisition system for implementing the data acquisition method described in embodiment 1 includes a "data summary terminal" and several sets of "acquisition terminals", where several sets of "acquisition terminals" are connected by an ethernet cable in a hand-in-hand manner and finally connected to the "data summary terminal" to form a cascade system of ethernet interfaces. Each acquisition terminal is provided with 2 Ethernet interfaces.