Development and delay analysis of data acquisition gateway for train monitoring and control system

To solve data processing for the train multiple monitoring and control devices, a multi-protocol data acquisition gateway based on the embedded Linux system was designed. The principle of the gateway was proposed. The gateway’s communication abilities of RS485 network and Ethernet as well as RS485 network based on HDLC protocol and Ethernet were demonstrated by delay analysis for data propagation. The implementation of data acquisition and retransmission for the LKJ and TCMS provides support for achieving the aims of remote monitoring and fault diagnosis for rail transit train.


Introduction
The monitoring and control are an effective method to guarantee the driving safety for rail transit train, the active duty trains in China are equipped with various monitoring and control systems. Among which the most typical ones are the train operation monitoring and recording device LKJ2000, the safety information synthesis monitoring and control device TAX2, and the Train Control and Management System (TCMS). The train monitoring and control system is used to guarantee the driving safety for onboard system of train, moreover, which are the monitoring and control center of train that can implement various functions such as safety monitoring, operation information recording and real-time braking control, etc. At present, the status information, safety information and monitoring information of train stored in onboard devices can only be obtained by train, but not by repair depots, locomotive depots or railway administration information center. As a result, the realtime status monitoring and fault diagnosis will be influenced. Therefore, to implement the remote monitoring and fault diagnosis, a method using embedded system to acquire data in real time and process data at the same time on vehicles was proposed [1,2]. Aiming at acquiring and propagating data of on-board devices (such as LKJ, TAX and TCMS), supplying solvable schemes for the data acquisition of train control devices that are responsible for the remote monitoring and fault diagnosis, a multi-protocol data acquisition gateway based on the embedded Linux and ARM9 was designed according to the format of output data and the working principle of electrical interfaces of devices (such as LKJ, TAX and TCMS) on vehicles.

Operation principle of gateway system
The real-time fault diagnosis for data processing on vehicles and the data dumping are very difficult due to the diversification of monitoring and control devices and the inconsistent of data recording format. A data acquisition gateway (as shown in Figure 1) for the locomotive data service system was designed based on the train operation monitoring and recording device LKJ2000, the data message format and the working principle of electrical interfaces [2] of TCMS system. The data acquisition gateway is a special network node in a network system, working as a data communication and processing area. The main functions of the gateway during data acquisition and retransmission are as follows: Data propagated from the LKJ2000 or the TAX2 to the gateway where the protocol of data conversed from the RS485 to the TCP/IP through the RS485 bus, then sent to the database server on vehicles through the Ethernet. The database server completes data processing and dumping or sends data packets to the LKJ or the TAX devices through the gateway.
According to the character that the RS485 bus used in the TCMS system is based on the HDLC propagation protocol in data link layer. The TCMS data packets complete the conversion of the HDLC protocol data packets to the RS485 protocol data packets in data link layer using the ASIC chip Z85230 in RS485 transceiver of the gateway before entering the gateway core processing unit [3][4][5]. Then the RS485 protocol data will be conversed to the UDP/IP protocol data that meet the requirement of transferring through the Ethernet. At the end, the UDP/IP protocol data will be sent to the data server on vehicles. The process of data sending from the data server on vehicles to the TCMS system is opposite.
The maximum communication rate of the RS485 bus network is 10Mbps, however, which propagation rate is inversely proportional to the propagation distance. For instance, the maximum propagation rate for the twisted-pair wires of 100 meters long is only 1Mbps while for the Ethernet of TCP/IP protocol, the maximum propagation rate is 100Mbps [6,7]. We need to solve speed distribution between the RS485 bus network and the Ethernet in the situation of propagating large data. The methods mostly adopted in actual operation are as follows: Using a bigger RAM as Data Buffer in gateway to improve capacity, decrease the waiting time of data in low propagation rate end and improve the total propagation efficiency. Using short distance propagation in low rate network based on the characters of the RS485 bus, trying to avoid the network congestion caused by long waiting time when data propagating from the high propagation rate network to the low propagation rate network with a too low propagation rate.

Hardware design
As shown in Figure 2, the hardware of the gateway can be divided into core processor module, Ethernet propagation module, data acquisition module, debugging module, power module and other assistant modules such as status indication module.  The core processor module and the Ethernet module use the kernel board M287 integrated by Zhiyuan Electronics, jointly possessing central processing unit function and Ethernet propagation function. The core processor is a kind of industrial grade microprocessor designed based on the Freescale i.MX287 high performance processor ARM926EJ-S that integrated the 128M memory DDR2 used for the program operation of processor and the 128M Flash program memory NAND used for the storage of Linux kernel image, root file system, boot files and application program. etc. The highest dominant frequency of the core processor is 454MHz and supporting many kinds of serial ports (such as UART, I2C, SPI, 12bitADC and 10/100M Ethernet interfaces). The Ethernet propagation module [8], which uses the Ethernet controller DP83848K that integrated hardware protocol stack, possessing the tidy media independent interface RMII and supporting accessing the Ethernet in a 10/100Mb/s single mode under half-duplex or full-duplex mode. The data acquisition module can be divided into 2-channel RS485 interfaces, 1-channel RS422 interface and 1-channel RS232 interface. The RS485 interface module uses the isolated transceiver RSM3485HT that integrated electrical isolation, power isolation and protector of interface chip and bus as the RS485 bus driver. The enhanced serial communication controller Z85230 was added between the gateway core processor and the RS485 transceiver. Thus, the data receiving and transmitting of HDLC protocol and the requirement of receiving part of data of the TCMS system for a HXD3 locomotive can be implemented [9]. The RS422 interface module uses the isolated transceiver RSM3422P as the RS422 bus driver. The RS232 interface module uses the isolated transceiver RSM232 as the RS232 bus driver that is used for network card debugging. The power module, supplying power for the gateway system, was added with voltage stabilizing diode and over current protection fuse to guarantee the normal operation of gateway components and the stable operation of system. In addition, a voltage stabilizing circuit based on power isolation chip DCR010505U was used to improve the stability of the RS485 data acquisition module. LED lamps were added into the status indication module to indicate working states of gateway, including power state, program running state and communication states of LKJ, TCMS and Ethernet.

Software framework
A multi-protocol gateway based on the embedded Linux system was designed in this paper according to the data acquisition demand for LKJ2000, TAX2 and TCMS to implement the communication between the train monitoring and the controlling heterogeneous network [10]. The software block diagram of the data acquisition gateway communication module for train monitoring and control is shown in Figure 3. Including hardware layer, operation system layer and application layer and the software framework can also be divided into hardware layer, drive layer, kernel layer, interface layer, application layer and data layer further.  The hardware layer provides electrical interfaces for the communication of the gateway with other devices, including 1 Ethernet interface and 4 serial ports mainly. The UART0 communicates with the Z85230 and implements RS485 bus receiving and transmitting after being converted by the Z85230.
The operation system layer provides management and control schemes for the application and operation of the gateway hardware and software, including Linux system start-up leading file U-Boot, operation system kernel, root file system and device driver that composed of 1 Ethernet driver and 4 serial drivers. The Linux system provides necessary service and corresponding interfaces for the operation of application program after finishing configuration, initializing hardware and loading drivers.
The application layer provides program for the implementation of gateway function, completes data caching and command queue. The Data Buffer is composed of the Read Buffer that caches the LKJ2000, TAX2 and TCMS data acquired by gateway and the Write Buffer that caches register data of on-board data server's write commands. The command queue, composed of the read queue and the write queue, serves for the Data Buffer. The read queue stores read commands of the LKJ2000, TAX2  5 and TCMS when the gateway polls these devices automatically. The write queue stores write commands that need to be retransmitted when on-board data server is accessing the LKJ2000, TAX2 and TCMS. The priority of the write command queue is higher than the read command queue.

Design for data propagation
Most of the communication activities between the interface layer and the application layer will appear message collision and response timeout due to the differences of data format and working principle of the two propagation subnets that connected by data acquisition gateway. Thus, make it easy to cause instability for the gateway system and fall into cycle replacement. The most common solution used is to translate protocol of the message data format that communicating between the two-layer communication subnet, so that the data message format of the upper subnet converted into one that accord with the lower layer subnet. At the end, the precondition of communicating between heterogeneous networks can be implemented. By decomposing communication event between the two-layer network into two time-sharing asynchronous events using data deposit mechanism [11] and then processing the two events to implement the protocol propagation between heterogeneous buses in a broader sense and the data retransmission in heterogeneous networks and improve the communication efficiency of the gateway.
In the design of this gateway, the Ethernet interface Eth0 can be used as not only a client end, but also a service end. The gateway used as Ethernet host in the network system, communicating with other Ethernet nodes such as data server on vehicles using UDP protocol, the work flow of the gateway is shown in Figure 4. Reading configuration files and completing data mapping for the Ethernet and the serial ports. Initializing the Socket according to IP, waiting for the connection of the target network nodes and the data server.