# FPGA-Based Methodology for Detecting Positional Accuracy Degradation in Industrial Robots
## 2 Materials and Methods
### Proposed Methodology  
The proposed methodology to determine if there is a deviation in the joints of a manipulator robot through the analysis of its motor currents is presented in a general way in Figure 4.  
In this work, it is considered that the calibration conditions of the robot, as well as its electromechanical components, are in optimal operating conditions. However, robot calibration is a procedure that is performed with external sensors or with the tools provided by the manufacturers. In this sense, the implementation of robot calibration algorithms in FPGA involves not only the implementation of these but also the development and implementation of control or communication systems to operate the robot along with all subsystems that this entails, this aspect is subject to the limitation of the logical resources of the FPGA device and the resolution of the processing of fixed point operations and it is beyond the scope of this work. The proposed method starts with the database of the robot to be analyzed; for this, a synthetic and a real-world dataset are used. The current signals of the robot motors are required when performing a repetitive trajectory or task for a prolonged time. Signals are acquired at two different moments: at the beginning of the trajectory or task and hours after the task's start. In this way, the dataset contains signals with different operating conditions, named cold operation (CO) for the initial state and hot operation (HO) for the second state. Figure 5a-f shows the real-world dataset motor current signals of joints one to six during the CO state. In the pre-processing of the signals to provide robustness to the method, different noise levels are added to the signals in the dataset. These noisy signals are then employed in subsequent process stages as a dataset. The noise levels used are 5 dB, 10 dB, 15 dB, and 20 dB. Figure 6a,b show the current signal for CO and HO states from the real-world dataset, respectively, both with 5 dB of noise. Figure 4: General diagram of the proposed methodology. perform the analysis. However, as shown in [18], only the first four levels are considered relevant for the analysis due to the amplitude and narrow frequency bands of the last two decomposition levels. Additionally, due to the FPGA system memory resources, and the DWT soft-core functionality, only levels three and four are used for the analysis. Figure 7 presents the DWT decomposition at level four for the joint one, with 5 dB noise added from the real-world dataset. Figure 7a,b represent the approximation and details of the CO state, respectively. On the other hand, Figure 7c,d display the results for the HO state. Afterward, for the approximations and details of levels 3 and 4 of each signal, the RMS and variance indices are calculated; this process is repeated with each window that makes up the original signal. Subsequently, the indicators corresponding to each signal are averaged over the number of windows. This process is applied to each signal in the dataset, and the obtained indices are used for training, validation, and testing of a classifier based on ANN. To perform the complete robot analysis, the above process is replicated for each robot joint exploiting the FPGA's concurrent processing capability. In this case, for a UR5 robot, there are six classifiers based on ANN. In this way, each classifier keeps a simple configuration and the resource consumption for the hardware implementation of the whole process is kept below the capacity of the proprietary FPGA board. Finally, the soft-cores for DWT, statistical features calculation, and neural network classifier are developed to validate the method implementation in an FPGA system, and the classifier results are displayed to the user in a command line terminal. The proposed methodology is tested in two synthetic and one real scenario for this work. For the synthetic scenario, the robot's database is obtained through the dynamic modeling of the robot and its simulation, performing a parametric trajectory as shown in Figure 8a.