# A New Modeling Method of Angle Measurement for Intelligent Ball Joint Based on BP-RBF Algorithm
## 2 Simulation Analysis of Artificial Neural Network (ANN) Modeling
### Simulating Realization of ANN  
For the simulation calculation, the input of the ANN was the theoretical reading value of the Hall sensors, while the output was the rotation angle components \(\alpha\) and \(\beta\) in the space of the ball joint. The purpose of simulation is to determine the number of suitable input terminals of the artificial neural network so as to minimize the measurement error. According to the data training process of the ANN, the specific simulation steps are:  
1. In the measurement range of [-20-20\({}^{\circ}\)], the output magnetic induction intensity of the Hall sensor collected at intervals of one unit acted as the input of the ANN to build the model, while the angle corresponding to (\(\alpha\),\(\beta\)) was used as the output of the ANN to build the model. Because the sigmoid function is sensitive to the slight changes in the middle and the recognition degree of ANN is better, the sigmoid function was used to scale the data into the interval [-1,1]. 2. According to the training rules of the ANN, the initial parameters (\(W\),\(b\)) of the ANN were arbitrary numbers in (0,1), whether the \(W\) and \(b\) represented all weighting matrices and bias vectors in ANN, respectively. The output of the first training (\(\alpha_{1}\),\(\beta_{1}\)) was calculated, then the parameters (\(W\),\(b\)) were updated according to the function of the ANN itself. After several iterations, the parameters of ANN (\(W\),\(b\)) which minimized the error output function were obtained. 3. When all the training data of the neural network were finished and the output error was minimized after simulation, and the output achieved the required accuracy, the ANN modeling was complete. Two problems must be solved in the simulation. The first concerns the suitable number of input terminals of ANN. The second is how to choose the number of hidden layers of the ANN to improve the measurement accuracy. When the number of input terminals of ANN is three to five, the calculation error of the model is as shown in Figure 3. The angle components \(\alpha\) and \(\beta\) have similar error characteristics, so, the figure only lists the error values and law of the simulation measurement of angle \(\alpha\). The output error of the BP ANN is observed to decrease with the increase of the input. When the number of input terminals of ANN reaches five, the error no longer decreases. Similarly, we simulated the effects of the number of hidden layers on the calculation error and measurement accuracy of the model. Figure 4 presents an error diagram of the angle component \(\alpha\) of the BP ANN with multiple hidden layers when the number of sensors is constant. As can be seen, increasing the number of hidden layers reduces the output error. When increased to four layers, the calculation error tends to be flat. Finally, the BP ANN adopts the structure of five inputs and four hidden layers [13; 14; 15]. Figure 4: \(Cont.\)  
The simulation results show that the RBF ANN has a good nonlinear mapping ability and a fast convergence speed. The design of the hidden layer of the RBF ANN determines the number of the cores in the hidden layer. The RBF ANN trains and learns in [\(-20^{\circ}\)\(\sim\)\(20^{\circ}\)], so too many kernels will reduce the iteration speed and the curve approximation ability [17]. The measurement interval was divided into four parts using the BP ANN: The first interval was \(0^{\circ}\leq\alpha\leq 20^{\circ}\), \(0^{\circ}\leq\beta\leq 20^{\circ}\); the second interval was \(0^{\circ}\leq\alpha\leq 20^{\circ}\), \(-20^{\circ}\leq\beta\leq 0^{\circ}\); the third interval was \(-20^{\circ}\leq\alpha\leq 0^{\circ}\), \(0^{\circ}\leq\beta\leq 20^{\circ}\); the fourth interval was \(-20^{\circ}\leq\alpha\leq 0^{\circ}\), \(-20^{\circ}\leq\beta\leq 0^{\circ}\) (as shown in Figure 5). In each interval, the magnetic induction intensity values (\(B_{1}\), \(B_{2}\), \(B_{3}\), \(B_{4}\), \(B_{5}\)) at the positions of the three sensors (two unidirectional and 1 three-directional) were used as the input of the training data.