Abstract
1. Introduction
The development trend in the high speed, high precision, integration, and intelligence of the CNC system has led to the continuous increase of software scale and computational complexity. It is always a challenge to improve its reliability [1, 2]. Therefore, there is a high demand for efficient methods that are able to locate the defect codes quickly and accurately. Although the FMEA and FTA methods have been successfully used for analyzing faults of the machine body [2–5], they cannot locate the defect codes effectively. When the software breaks down, the common methods for locating the fault are analyzing memory dump and inserting print statement [6], which largely depends on the experience and intuition of maintainers. As a result, they are not ideal methods for identifying the defect codes.
An important improvement in failure location is the conclusion that the fault will happen in the case of defect code being passed by execution trace [7]. Agrawal et al. [8, 9] proposed that the fault location can be obtained by subtracting successful set of sentences from the fault-set. However, this method fails to locate the defect code effectively. Renieris and Reiss [10] tried to use the “nearest neighbor” to locate the faults by comparing a failed path with a successful path that was most similar to the failed path. However, they can only choose the most similar path without taking other paths into consideration, which results in a poor failure location. Hence, these two methods are not effective at locating the fault quickly and effectively.
To overcome the shortcomings of the above methods, this study proposes a new method to locate the CNC system failure based on similar path set and ANN. When the CNC system works properly, the monitor keeps recording the input and output values and the execution paths of the software module. If a failure occurs, the failed path is generated according to the execution information recorded by the monitor. Then, the similar path set is obtained from the control flow graph and the failed path. Finally, the defect code is judged by ANN.
2. Structure of Software Fault Location of CNC System
Due to programming errors, some bugs can be easily introduced at the stage of software design; however, not all bugs can be excluded in the stage of software testing, which causes maintainers a lot of trouble. In order to reduce the economic loss caused by bugs, an efficient method that is able to locate the defect code quickly and accurately is highly required. It is well acknowledged that the execution path differs from the normal path when the failure occurrs, and these differences cover the detailed defect information.
This study proposes an innovative method in which the defect code can be located by ANN comparing the differences between the failed path and the similar path set. In the light of the airplane black box, each branch of software modules is inserted with a pile, and the monitor is designed accordingly. The structure of software fault location of CNC system is shown in Figure 1. When the CNC system works properly, the monitor keeps recording the input and output values and the execution path of software module. When the software of CNC system breaks down, the detailed fault location would involve the following steps.
The failed path is generated according to the execution information recorded by the monitor.
The control flow graph is established by analyzing the source codes of the software module.
The similar path set is obtained from the control flow graph and the failed path.
The feasibility of similar paths was judged by using the historical execution tracks recorded by the monitor.
The ANN is trained by the learning sample which is composed of a failed path and a similar path set.
Finally, the defect code is judged by inputting the virtual path into ANN.

Structure of software fault location of CNC system.
3. Monitor of the CNC System
The black box can record the flight data and cockpit voice when the airplane is working [11]. If airplane crashed, the fault analysis can be carried out by replaying the information recorded by the black box. Similar to the airplane's black box, this study will design the software monitor which can help to locate defect codes of the CNC system. In this case, the monitoring of the CNC system should offer the same attractive features as the airplane black box. For example, when the CNC system is working, as much information as possible can be recorded. Moreover, the system recourse occupied by the monitor should be small enough to ensure the least interference towards the CNC system.
As shown in Figure 2, the first step of designing the monitor of the CNC system is numbering the modules of each level. Each serial number corresponds to a layer of the module. Take the first 2 rows, for example; the main module in the first row is characterized as number “1”; in the second row, the module is marked as “1.1” for the compiler module, “1.2” for the interpolation module, “1.3” for the servo module, and so on. In the same way, the numbering continues until the module reaches the level of class or function. Also, the relationship between module name and its according number is stored in the database, which provides the base for the fault location.

Number of CNC modules.
The second step of designing the monitor is piling up modules of each level and recording their execution paths. As presented in Figure 3, the paths include

Structure of running information.

The simplified graph of module.
At work, the monitor instantiates the structure, when the execution trace arrives at the entrance of the software module. Then, the monitor assigns the element of the structure, and stores this structure in the database at the exit of the software module.
4. Similar Path Set
The detailed procedures for solving the similar path set involve analyzing the control flow graph established by the source code, searching for unconstrained edges, replacing the unconstrained edges of failure path, and judging the feasibility of similar paths.
4.1. Control Flow Graph
The control flow graph is a graphical representation of the program's control flow, by which the structure of the program can be conveniently analyzed. The control flow graph
4.2. Similar Path Set
The basic idea of the similar path set algorithm is shown in Figure 4. As shown in Figure 4, the path π

The basic idea of the similar path set.
As shown in Figure 5, the algorithm of the similar path set is based on “replacing the unconstrained directed edge → filling in blank of the discontinuous path.” The algorithm is performed as follows: firstly, the control flow graph, and the failed path are established according to the program module; secondly, all unconstrained directed edges are worked out from the control flow graph and the unconstrained directed edges in the failed path are marked out; the subpaths (π′ and π″) can be obtained after breaking off the failed path π

The algorithm of the similar path set.
5. ANN Recognition
An ANN is a programmed computational model that aims to replicate the neural structure and functioning of the human brain. Thus, it has the ability to generalize and learn [12–14]. In order to improve previous fault location methods, we use ANN to find the defect code in the failed path. In this study, the input is the directed edge coverage of an execution path which indicates whether the directed edge in the failed path is covered by the execution path. The output is the result (success or failure) of the corresponding execution path. Once ANN has been trained, the coverage of the virtual execution path with only one directed edge in the failed path is used as an input to compute the suspicions of the corresponding directed edge in terms of its likelihood of containing a defect code. The larger the value of the output is, the more suspicious the directed edge seems to be. The directed edges in the failed path can then be ranked in a descending order of their suspiciousness, and the directed edge with the largest suspicion contains defect code.
5.1. Learning Sample of ANN
We constructed a three-layer BP ANN (backpropagation artificial neural network) with

Structure of BP ANN.
Each neuron in the hidden layer uses the Log-Sigmoid function as its activation function. The output of the
where
The neuron in the output layer uses the line function as the activation function. The output of ANN is shown as follows:
where
When locating the software fault of CNC system, suppose that we have a failed path π

The schematic diagram of generation of the learning sample.
In this study, the
The value of
5.2. The Identify of BP ANN
Once ANN is trained, it has learned good mapping between the input (the execution path) and the output (the corresponding execution result), and it can identify whether a new execution path is a fault path. Moreover, it can judge whether an execution edge in the failed path contains a bug. To do so, this paper uses a set of virtual execution paths {

The suspicious computation of the directed edges.
After inputting the virtual path into the ANN, the output of ANN is the level of suspicion of the corresponding directed edge in a failed path. The larger the value of suspicion is, the more likely the directed edge will be faulty. Virtual paths are inputted into the ANN in order, and the suspicion of the directed edges is obtained, which is expressed by {
6. Analysis of Fault Location of CNC Software
In virtual axis machine tool [15], the experiment on fault location of CNC software was carried out. The principle of NURBS interpolation can be found in [16–18], and the control flow graph of NURBS interpolation was shown in Figure 9. Also, the bug was injected into the program of NURBS interpolation beforehand, and the defect code was the 25th line code. The piles were inserted in each branch of the program, and array for m path [11] denoted the execution paths. In the working process of NURBS interpolation, the execution information recorded by the monitor was written in the database.

The control flow graph.
While interpolating the NURBS curve (Figure 10), the program for NURBS interpolation failed (Figure 11), expressing the chord error as larger than the defined maximal chord error. To provide a detailed description of NURBS interpolation, the interpolation parameters were defined as follows: the control points were {(5, 5, 4), (25, 40, 9), (50, 70, 16), (60, 100, 22), (70, 73, 30), (50, 57, 37), (112, 40, 41)}; the weight vector was {1, 1.2, 1, 1.25, 0.9, 0.85, 1}; the knot vector was {0, 0, 0, 0, 0.4531, 0.5485, 0.6306, 1, 1, 1, 1}; the speed command was 4 m/s; the sampling time was 2 ms; the maximal allowable acceleration/deceleration was 5 m/s2; the maximal allowable chord error was 2 μm. When the interpolation point was at

NURBS curve.

Diagram of interpolation error.
The location for the above fault involved the following steps. To begin with, the control flow graph (Figure 9) was generated according to the program of NURBS interpolation. Next, the failed path π
As mentioned above, there were five similar paths and one failed path. So, the learning sample of BP ANN in this experiment can be expressed as {(1, 1, 0, 1, 1, 1), 0}, {(1, 0, 0, 1, 1, 1), 0}, {(1, 1, 0, 1, 0, 1), 0}, {(1, 0, 0, 1, 0, 1), 0}, and {(1, 1, 1, 1, 1, 1), 1}. In BP ANN, the input layer had six neurons corresponding to six directed edges, and the output layer had only one neuron. In addition, the hidden layer had four neurons. Each neuron in the hidden layer used the Log-Sigmoid function as the activation function, and the neuron in the output layer used the line function as the activation function. In BP ANN, both the learning rate and prediction accuracy were set to 0.01, while the maximum iteration number was set to 200. At each iteration, BP ANN calculated the average output error and adjusted every weight. The BP ANN was carried out based on MATLAB, and the average output error at each iteration was shown in Figure 12. After 95 iterations, the average output error was 0.0098252.

The average output error in training ANN.
After BP ANN was trained, the virtual execution paths such as (1, 0, 0, 0, 0, 0), (0, 1, 0, 0, 0, 0), (0, 0, 1, 0, 0, 0), (0, 0, 0, 1, 0, 0), (0, 0, 0, 0, 1, 0), and (0, 0, 0, 0, 0, 1) were input, respectively, to the BP ANN. The output of BP ANN was suspicious of the directed edge, which was shown in Table 1.
Suspicions of the failed path.
As indicated in Table 1, the directed edge with the largest degree of suspicion was
7. Conclusions
In summary, the application of a similar path set and ANN is very effective in establishing the fault location in the CNC software. The monitor can record the execution information in real-time during the operation of the CNC software. When the CNC software fails, the fault location can be carried out by the algorithm of the similar path set and ANN, and the experiment regarding the fault location of the NURBS interpolation module is carried out. The results of the above experiments show that the proposed method is a quick and accurate method in locating the fault in the CNC software without depending on the experience and intuition of maintainers.
This paper proposes a good foundation for self-repair of CNC software, especially for reliability self-growth of CNC software. The subsequent work is ongoing. The whole research will integrate the fault self-location, fault self-repair, and reliability self-growth, which will greatly improve the software reliability of the CNC system.
