A Fault Diagnosis Approach for Rail Surface Anomalies Using FPGA in Railways

: Railway transport is a widely used means of transportation for passenger and cargo transportation. In recent years, more emphasis has been placed on railway transport. With the development of high-speed trains, it has become important for passenger transport. Due to the heavy construction of the train, continuous failures occur in the railway line. Various methods of inspection are available to detect these failures. In case of early fault detection and repair of major accidents can be prevented. In this study, an FPGA based method is proposed for rail surface inspection and fault diagnosis. The proposed method is realized by image processing with FPGA. The image is taken on the railway line with the camera attached to the FPGA development board. Pre-processing is performed on the obtained image. Edge extraction is applied to the image after pre-processing. The rail surface is detected using the image obtained as a result of edge extraction. The proposed method works in real time to monitor and diagnose faults. It detects many defects on the track surface. In addition, the proposed method measures the size of the fault on the rail surface. In this study, FPGA based condition monitoring device was developed. An architecture has been developed for implementing the proposed method with FPGA. This work using FPGA technology is low cost and fast compared to other methods. The proposed method is quite advantageous because of its real-time operation.


Introduction
Railway transportation is a type of transportation that is widely used today. Railway transportation is advantageous for passenger and cargo transportation. Railway components in railway transportation are very important for passenger safety. There are many faults on the rail line. As a result of these failures, the train and rail track components may be damaged [1][2][3]. Generally, the areas where failures occur are the rail mantle and the rail surface. In Figure 1, faults that can occur frequently on a sample rail are shown [4]. Rail flaws in railways have been published by the International Railway Association (UIC) with UIC 712 R code [5]. With this fault code, a lot of information such as the position, type of the rail fault is obtained. Codes consisting of three or four digits indicating the type of rail failures are given. By looking at these codes, it is understood to which region the rail fault occurs and what the fault is. Major failures such as rail breaks occur if the failures in the railway line are not repaired. Major failures that occur are affecting railway transportation negatively. For this reason, early diagnosis and intervention in railways is very critical. There are many contact and contactless methods for condition monitoring and fault detection on the railway line. Inspection types applied on rail; Ultrasonic method, vortex flow method, radiography method, liquid penetrant method, magnetic induction method and contactless methods with cameras. These methods are generally classified as contact and contactless These are contact and contactless methods. In contact method, the rail line components make condition monitoring and diagnostics by contacting the device [6,7]. Or the specialists can observe the rail track and identify the faults that occur. Such methods are costly, time consuming and take a lot of time. In contact methods, which may result in malfunction of the rail line during the monitoring. Also, as the contact methods take time to be implemented, railway transportation stops during this process. Thus, railway transportation problems occur. In the non-contact methods, the railway line is monitored using laser or normal cameras [8][9][10]. In recent years, image processing based methods _______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________, 1,2,3 have been developed and contactless status monitoring has been performed. Non-contact condition monitoring methods are quite fast compared to contact condition monitoring methods. In addition, contactless condition monitoring systems do not affect rail transport.
There are many studies in the literature with railway track monitoring and fault detection. Canan et all [11]. Rail has proposed a real-time image processing method for defect detection and classification. The rail surface was detected using image processing methods. Then detected rail defects on the rail surface image. Classification algorithms have been used to classify rail defects. The block diagram of methods of rail surface detection and rail defects classification is shown in the Figure 2. Yunus et all [12]. First of all, a feature extraction is made on a video image that contains an error-free rail line. Then, virtual failures were created on the image containing the faulty rail line and the feature extraction was performed and these two data groups were trained by being labelled as faulty and robust. In the test phase, the algorithm is implemented on a new video image that contains malfunctioning and robust frames. The study period and accuracy performance were measured and a decision mechanism was established. The flow chart of the proposed method in the literature is given in Figure 3.  [12] There are also studies in the literature that detect malfunctions using thermal cameras [13]. Xiaoqing et all [14]. It has proposed an image processing based method for detection of rail surface defects. Using a thermal camera, the rail surface is imaged. By performing image processing on thermal images, rail surface defects are detected. Ke et all [15] Railway proposed a classification method for surface condition monitoring. Rail surface with edge detection and segmentation is to classify the image. Michael et all [16]. An image processing based method is proposed for detection of failures on rail surfaces. In the proposed method, the rail surface is observed with close cameras. Thus, very small damage on the track surface is detected.
In this study, we propose an image processing based fault diagnosis method with FPGA architecture for rail track. In the proposed method, a camera attached to the FPGA development board and a rail line image are taken. In the obtained image, rail surface is detected. In this way, faults occurring on the rail surface can be easily calculated. The fact that this method is based on image processing is advantageous over other methods. The use of FPGA technology brings with it greater advantages. This work using FPGA technology is low cost and fast compared to other methods [17][18][19][20]. Thus, the proposed method is more advantageous than the other methods.

Proposed Method
In this study, an image processing based method is proposed. Software was developed on the FPGA development kit. The image is captured by the FPGA development kit and the rail surface is detected. Condition monitoring and fault detection are performed on the detected rail surface. An architecture has been created to implement the proposed method on the FPGA. The FPGA architecture of the proposed method in this study is given in Figure 4. In FPGA architecture, pre-processing is applied to the images first. As a result of pre-processing, a RAM block is used for edge detection on the image. The proposed method is implemented using the pixel values stored in the RAM block. The results of the proposed method are transmitted to the monitor via VGA. The general flow diagram of the proposed method is given in Figure  5.
In the proposed method, only the matrix of the sobel edge detection algorithm is used for feature extraction in the image. Sobel algorithm is easier than other edge detection algorithms. It is also easy to implement the Sobel algorithm on the FPGA development kit. Sobel edge detection algorithm is a scanning process with 3x3 size and matrices on the image matrix [21][22][23]. and matrices are given in the equation 1. , the matrix is used as the masking matrix. The purpose of using the matrix is to obtain the edges in the vertical direction more clearly. As a result of edge detection, the number of white pixels in each column in the image is calculated. The column with the maximum number of white pixels is called the rail surface. Thus, the rail surface can be easily detected. In figure 6 shows edge detection results using , and both matrices. matrix c) and matrices Figure 6 shows edge detection results using , and both matrices. In the proposed method, the rail surface is determined precisely using matrix. Also, when only matrix is used, unnecessary edges are not obtained. Thus, the success of the rail surface detection increases. After the rail surface fixation, defects on the rail surface are detected. The black pixels on the binary image are examined to detect failures on the track surface. All black pixels in the column are calculated for each row on the track surface. A signal is obtained by calculating the number of black pixels on the rail surface image. In Figure 7, the feature signal is obtained from the rail surface image. A threshold value is determined on the feature array obtained in figure. If the obtained feature sequence is below the threshold value, it is defined as stable and not defective. In addition, the size of the fault is also calculated by considering the values in the property array.

Experimental Results
In this study, an image processing based method is proposed to detect the FPGA based rail surface. The image of the railway line is taken via the camera connected to the FPGA development board. Edge detection is performed on the obtained image by using image processing methods. The rail surface is detected after edge detection. The general connection of the FPGA development board used in this study is shown in Figure 8. The images used in this study were taken from a locomotive used on railways. The image was captured with the FPGA development card placed on the locomotive. The image is displayed on the monitor connected to the FPGA development board. The rail surface is detected in the railway line using the experimental setup. A color image of the rail line taken from the camera is shown in Figure 9.a, and a gray converted image is shown in Figure 9.b. Using the gray image obtained in Figure 9b, the matrix of the sobel edge detection algorithm is applied. The threshold (T = 120) was applied to sharpen the image obtained as a result of edge detection. The obtained edge detection image is shown in Figure 10.a. After these operations, the rail surface was detected by the proposed method. When the rail surface is detected, the total number of white pixels in the rows of each column in the image is taken into account. The column with the largest number of white pixels is called the rail surface. The rail surface that is fixed is taken into an area and is shown in Figure 10 The rail surface detected in Figure 10 is cut through the image. The rail surface image is converted into a binary image. Condition monitoring and fault detection are performed using binary images. Figure 11.a shows the sample rail surface image, and Figure 11.b shows the binary image. In the figure given in Figure 11.b, the graph in Figure 11.d is obtained considering the black pixel numbers. The ratio of the total number of pixels in the column to the number of black pixels indicates the size of the defect. In this study, if the size of the black pixel is over 30%, it is defined as malfunction. The result of Figure 11.b is given in Figure 11.d. Fault size was measured over 40%. Figure 12 shows the results for the sample rail surface views. The necessary resources used in the development are shown in Table 1 as a result of the implementation of the proposed method in the FPGA development board. In practice, the desired signals are monitored in real time, apart from the display on the monitor. In this way, the variables used in practice are observed to test the accuracy of the proposed algorithm. Figure 13 shows the Signal Tab II Logic Analyzer section of the Quartus program. Here, the frame number of the image displayed on the "Frame_Cont" variable monitor observed here is the horizontal axis position of the pixel subjected to the "X_Cont" change processing, the vertical axis position of the pixel where the "Y_Cont" the horizontal axis of the surface.

Conclusions
In this study, an FPGA based image processing method is proposed to detect rail surface in railway line. In the proposed method, the image of the rail line taken from the camera was processed using the FPGA development kit. After the obtained image is transformed into gray form, feature extraction is performed by using the sobel edge detection algorithm. A method has been proposed to determine the rail surface after edge detection. The track surface was detected and a binary image was obtained. The malfunction is detected by considering the density of the black pixels on the binary rail surface image. It is also detected in the defective area. Implementation of this application using FPGA technology is quite advantageous compared to other methods. The contactless method is advantageous over the contact methods. The advantage of the proposed method is that it is fast and that the cost of implementation is low. All the failures on the rail surface can be easily detected by improving the results obtained in this study.