Design and implementation of a multi-data stream transmission and control system based on TCP/IP

Publisher:电子思维Latest update time:2012-06-06 Source: 现代电子技术 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
0 Introduction
With the development of industry, the scale of industrial sites is getting larger and larger. Several or even dozens of computers complete different industrial measurement or control tasks in different geographical locations, reflecting the trend of networking, integration, distribution, and node intelligence. Along with this, the number of data sources and the complexity of equipment monitoring increase. For this reason, a multi-data stream network transmission measurement and control system is designed. This system is a network measurement and control platform built on the basis of TCP/IP technology, which realizes the information interaction and equipment control of multiple distributed computers, and has the advantages of simplicity, high efficiency, and high real-time performance.

1 System principle and composition
The multi-data stream transmission measurement and control system can be divided into five parts: data source device module, data transmission and real-time processing module, remote console module, console device module, and front-end single-chip microcomputer acquisition device module. The system composition is shown in Figure 1. In this measurement and control system, each measurement and control part is relatively independent, and can complete the acquisition of multiple parameters such as voltage and current; the results are sent to the data and real-time processing device or console device in the form of multiple data streams for real-time reception, storage and processing, and the data is transmitted to the remote console monitoring interface through the network; the remote console monitoring interface completes the display and synthesis of the front-end data, so as to analyze the status of the front-end equipment. In Figure 1, the TCP protocol is used between the data source device and the data transmission and real-time processing device. The data source device is the server, and the data transmission and real-time processing device is the client. After the client successfully requests data from the server, it stores, integrates and sends the data streams provided by multiple servers to the remote console. The UDP protocol is used for communication between the data transmission and real-time processing device and the remote console. At the same time, the user sends control commands to the console device through the remote console to complete the remote command control of the console device. After the console device completes the action, it will transfer the collected signal of the microcontroller measurement and control module received through the RS 422 serial communication interface and send it back to the remote console using the network interface. The UDP protocol is used for communication between the console device and the remote console device.

a.jpg


The following introduces the basic composition and functions of the five main parts of the multi-data stream transmission control system.
1.1 Data source device module and single-chip microcomputer module
The data source device module and single-chip microcomputer acquisition module are two independent modules as front-end data acquisition devices. The data source device provides multiple TCP data streams for the data transmission and real-time processing equipment, and the single-chip microcomputer provides serial port data frames for the console equipment.
1.2 Data transmission and real-time processing module
The system block diagram of the data transmission and real-time processing module is shown in Figure 2.

c.jpg


The data transmission and real-time processing module is the client, and the data source device computer is the server. The two are connected to the network through a switch, and multiple data streams are communicated with the data source device module based on the TCP protocol. The data is written to the local disk in binary file format. After receiving a complete data (fixed-length TCP stream data), the part of the data that the user is interested in is integrated into a data frame and sent to the monitoring interface of the remote console through the UDP protocol. At the same time, the user can also manually or automatically select part of the data of multiple code streams for local data curve graphic display or data bar graphic display. [page]

1.3 Remote console module
The remote console is responsible for network wake-up and network monitoring of the data transmission and real-time processing module and the console module, as well as completing related operations on the power supply of remote devices. The remote console receives network data frames of adjacent modules (including data frames for integrating multiple data streams by the data transmission and real-time processing module and data frames for single-chip microcomputer acquisition forwarded by the console module), sends network control frames to the console (completes tasks such as parameter setting, system opening and closing, board operation, serial port operation, etc.), and uses UDP protocol for communication.
1.4 Console device module
The console device module consists of a CPCI industrial control computer and a relay board. The power supply relay card uses the NI PXI-2564 16-channel 5 A SPST switch module, which is a high-power relay card that can perform power input and power backup; the power-off and power-on control signal relay card uses the ADLINK PXI-7901 16-channel general SPDT switch module, which can control and switch the power supply. The system structure and external interface relationship are shown in Figure 3.

b.jpg


The system is powered by Agilent N6700 series module power supply. The console is connected to the single-chip microcomputer measurement and control module through the RS 422 serial communication interface and the network is connected to the remote console. For stable and reliable communication, the Gigabit Ethernet between the console and the remote console is converted to an optical fiber connection through an optoelectronic converter. The console accepts the control of the remote console, decodes and displays the data from the single-chip microcomputer acquisition module and transmits it to the remote console. The communication adopts the UDP protocol.

2 Software Design and Implementation
2.1 Multiple Events to Realize Network Port and Serial Port Communication
The console module needs to receive the remote control command frame of the remote console and the serial data from the RS 422 serial communication interface (connected to the single-chip microcomputer acquisition module), and package the serial data into a predetermined format UDP data frame and forward it to the remote console. For this purpose, the console software needs to establish a background manager (CTConManager) to start two independent threads, the network monitoring thread and the serial port monitoring thread, to monitor the network port and the serial port. The flow chart of the two is shown in Figure 4.

d.jpg


The software needs to convert the serial port data into UDP data frames for transmission, so the network monitoring thread uses the method of waiting for multiple events to handle the network event (m_evtNetWork) and serial port event (m_evtOverlappedSeira1) created by the WSACreateEvent function. The serial port monitoring process uses the asynchronous event mode to monitor the data reception of the serial port. The network event is bound to the current socket interface by the WSAEvent Select function, and the serial port event is set to the network monitoring thread after the serial port receives a complete data frame. When the console network can receive the network frame of the remote console (that is, a network event occurs), the thread calls the ProcessNetworkEvent function to process this event (that is, start parsing the remote command frame), and the corresponding serial port event calls the ProcessSerialEvent function of the network monitoring thread to process this event (that is, send a data frame). The network timeout event (WSA_WAIT_TIME OUT) in the thread handles the timeout task (ProcessTimeOut Event), including the cyclic detection of the serial port and board status and the sending of the status data packet.
The software uses this mechanism to respond to multiple events in a timely manner, realizes the docking of the serial port and the network interface, saves device resources, and improves system efficiency.
2.2 TCP multi-data stream integration and synchronization processing
According to system requirements, the data transmission and real-time processing module extracts the data of the same or different fields of multiple TCP streams and integrates them into a UDP datagram and sends it to the remote console.
Since it is very likely that the arrival time of a data stream will be delayed relative to other data streams during the transmission of multiple TCP data streams, this will cause data asynchrony during the integration into UDP datagrams. To solve this problem, the software uses a data queue-based method to achieve code stream synchronization. First, multiple TCP stream data (TCPDataValue) of a given length are added (pushed) to multiple corresponding queues (CDataQueue). When the length of all queues is greater than or equal to 1, that is, all queues have elements, the first element in the queue (that is, the first element pushed into the queue) is popped out (GetFirstData), and then the data of the code stream is extracted.

[page]

The following uses three data streams as an example to illustrate the implementation of this mechanism. The main code is as follows:
e.jpg
f.jpg
The software uses this mechanism to ensure the synchronization of multiple data streams without significantly affecting the real-time performance of the data.

3 System Test
The software test environment is an industrial computer equipped with the system hardware environment. The industrial computers are connected to each other through a Gigabit Ethernet network with optical fiber. The system currently has a console device with a relay board; several LINKSYS (model SRW2024) 24-port Gigabit bandwidth switches; 3 sets of data source equipment, the data acquisition cycle of a single data source device is 20 ms, and the entire frame length is 4 096 B; a set of single-chip microcomputer measurement and control equipment (32 data channels), the data acquisition cycle is 200 ms, and the entire frame length is 32 B. The system is tested for a period of time to accumulate data to obtain the system's throughput, command response time, resource consumption and efficiency.
After a long period of test operation, it is shown that the network of this system can achieve a throughput of 6-7 MB/s, and the data is stable, reliable, and highly synchronized. Compared with the data source, there is no disorder or packet loss. The console device can better allocate the CPU scheduling processing time of the network port and the serial port, receive remote control commands reliably, and the hardware response time is short. The entire system takes up less resources and runs smoothly on a general configuration computer, meeting the design requirements.

4 Conclusion
The multi-data stream transmission measurement and control system based on TCP/IP realizes the control of various data acquisition system equipment, data transmission and processing. This system uses TCP/IP technology, data acquisition technology and object-oriented software development technology, and uses existing network resources to achieve real-time acquisition and storage of information, efficient control of equipment, and intuitive display of the user software interface with high cost performance. After several months of test operation, it is stable, reliable, and has high real-time performance, achieving the purpose of multi-data stream transmission measurement and control.

Reference address:Design and implementation of a multi-data stream transmission and control system based on TCP/IP

Previous article:Basic terminology for semiconductor functional testing
Next article:The high resistance of thermistors is used in single chip microcomputers to measure temperature using the frequency method.

Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号