Design and Implementation of a Real Time Control System for a 2DOF Robot Based on Recurrent High Order Neural Network Using a Hardware in the Loop Architecture

In this paper, a real-time implementation of a sliding-mode control (SMC) in a hardwarein-loop architecture is presented for a robot with two degrees of freedom (2DOF). It is based on a discrete-time recurrent neural identification method, as well as the high performance obtained from the advantages of this architecture. The identification process uses a discrete-time recurrent highorder neural network (RHONN) trained with a modified extended Kalman filter (EKF) algorithm. This is a method for calculating the covariance matrices in the EKF algorithm, using a dynamic model with the associated and measurement noises, and it increases the performance of the proposed methodology. On the other hand, the decentralized discrete-time SMC technique is used to minimize the motion error. A Virtex 7 field programmable gate array (FPGA) is configured based on a hardwarein-loop real-time implementation to validate the proposed controller. A series of several experiments demonstrates the robustness of the algorithm, as well as its immunity to noise and the inherent robustness to external perturbation, as are typically found in the input reference signals of a 2DOF manipulator robot.


Introduction
In many current medical applications, the utilization of manipulator robots plays a very important role in dedicated procedures that require high accuracy and high performance in real time. Medical robots have been used in neurosurgery, orthopedics, and urology, and in these fields the robotic systems have been developed for minimally invasive interventions. Medical robotic systems are typically mechanical manipulators with rigid links connected by joints that allow relative motion from one link to another [1]. For example, a robotic enhanced device has been used in limb rehabilitation, which could replace (or partially relieve) physiotherapists [2], and authors in [3] reported the use of a manipulator robot for percutaneous ultrasound-guided therapy.
The systems typically used for these procedures are robots with two degrees of freedom (2DOF). However, 2DOF systems are highly nonlinear, with strong interconnections and dynamic behaviors. Robot manipulators are examples of nonlinear complex dynamics with strong interconnections, parameters and dynamics that are difficult to measure and to model [4]. One of the non-linearities can be present when the motor rotor is positioned anywhere in the dead zone for the equilibrium position. If the frictional torque exceeds the torque applied by the motor windings, the rotor will not move. Other non-linearity can be an asynchronous generator introduced in the system due to actuator saturation [5].
For the mentioned reasons, the neural networks (NNs) are selected to avoid these kinds of difficulties in the identification process.
Due to these facts, there is a need to design custom controllers to improve the accuracy and stability required in medical applications. A typical control scheme for 2DOF systems is composed of two processes: an identification model that approximates the model of the system, and a control algorithm.
In the identification process, the behavior of the 2DOF system is approximated using a nonlinear function. However, due to its complex dynamics, is very important to consider several aspects to obtain a good approximation of the identification model. Two important factors are the viscous friction in the joints of the robot, and the inertia and the gravity of the 2DOF system in continuous time [6] or in discrete time [7]. In this context, recently neural network algorithms have gained popularity to identify complex dynamics systems, due to their learning capabilities and inherent adaptability. An example of this approach is presented in [8], which used a decentralized neural identification in discrete time, trained with an extended Kalman filter (EKF) with static covariance matrices. An adaptive tracking controller based on a recurrent neural identifier was used in [9]. A fully connected neural network was used to identify a time-varying delayed nonlinear dynamic system in [10]. Another identification model that uses a fuzzy cerebellar model articulation controller with a neural network on continuous time was reported in [11]. In [12] a modified EKF algorithm, where the associated state and measurement noise covariance matrices are composed by the coupled variance between the plant states, is presented.
On the other hand, the sliding-mode control (SMC) technique has been used as a controller to ensure high accuracy, given that it provides a high insensitivity to parameter variations, representing a powerful yet simple implementation and allowing the operation of the switched-mode power converters. The potential of SMC was first demonstrated in [13]; moreover, SMC was validated in [14], where a robust control scheme based on the discrete-time block feedback linearization technique combined with SMC was presented.
In recent work, an identification algorithm similar to the EKF algorithm was used to approximate the dynamics in discrete time, with a 2DOF manipulator robot. In [4] a robot dynamics is analyzed for a 2DOF manipulator robot using an unscented Kalman filter in a parallel series configuration as the learning algorithm. In this it was not necessary to know the parameters of the plant or external disturbances. Another investigation showing a different method to examine a non-singular fast time sliding mode controller (NFTSM) is in [15] where a wavelet neural network (WNN) was used. The inputs were approximations of the upper limits of uncertainties and disturbances, to mitigate the effect of uncertainties taking into account approximation errors and unknown uncertainties. Thus, it can be concluded that achieve a high tracking precision, reducing the vibration phenomenon and also a quick response against errors and uncertainties.
In [16], simulation and experimental work involving a 3DOF robot manipulator was controlled using a back propagation neural network (BPNN) in discrete time given a normalized opening ratio of the joints. The Artificial Neural Network (ANN) output was the control voltages applied to motors mounted in the 3DOF.
As a different way to approximate and control the dynamics involved in a 2DOF Robot, the novel control architecture presented in [17] employs an adaptative neural network using proportional derivative control comparison plus a feedforward fuzzy controller, where the NN is pre-trained in simulation several times to obtain a suitable values of weights to avoid overshoots in the torque being applied to every joint. Another method of controlling a non-linear system is the neuro-fuzzy controller for the position control arm used in [18], where a five layer neural network is used to adjust the input and output parameters of the membership function in a fuzzy logic controller, concluding that this proposed control is better than a proportional-integral-derivative (PID) controller for a robot trajectory.
Finally, in [5], a real-time implementation of a recurrent wavelet first-order neural network is presented. In the mentioned paper is proposed to achieve better identification of the dynamic behavior where a 2DOF robot manipulator is used for designing a centralized neural integrator back stepping control scheme.
In this paper, we propose a control scheme based on a decentralized recurrent highorder neural network (RHONN) in order to identify the dynamics of a 2DOF system in discrete time, coupled with the SMC technique. The RHONN is trained online using the modified EKF reported in [12]. This training algorithm ensures fast learning convergence of the identification error. The proposed control system includes the RHONN identification of the plant and the application of the SMC control technique, ensuring the stability and robustness of the system. The validation of the system is carried out in a hardware-in-loop architecture based on Xilinx System Generator (XSG) software [19], which enables the use of a Matlab/Simulink environment to create and verify hardware designs, using a Virtex 7 field programmable gate array (FPGA). The hardware-in-loop (HIL) simulation is used to test the controller system design to verify the response of the system in real time, due to virtual stimulus without the burden of sacrificing scarce programmable resources [20].
The main contributions can be highlighted as follows. • The control system design and implementation for a 2DOF manipulator robot using a RHONN in a hardware-in-loop architecture. • Is presented a methodology for identification and tracking of the 2DOF manipulator robot. • A Real Time implementation on an FPGA of the proposed control system based in a RHONN with an EKF algorithm with an SMC. • Inside the EKF the FPGA computes the associated state and measurement noise covariance matrices composed by the coupled variance between the plant states. • The results are obtained with a hardware-in-loop architecture and the experiments and the results show the high performance of the system. Section 2 presents the discrete-time 2DOF robot manipulator model used and the rest of this paper is mainly divided into three parts. First, in Section 3, we present the control system architecture, and explain the neural identification method based on the RHONN, the extended Kalman filtering training algorithm and the discrete time sliding mode controller. Secondly, the design and implementation in real time based on hardware-in-loop architecture are presented in Section 4. Finally, in Section 5 we present the experimental tests with real-time results to validate the performance of the system in the identification process and the tracking control.

Discrete-Time 2DOF Robot Manipulator Model
The model of a 2DOF manipulator robot, presented in [21,22], is described using a second-order nonlinear differential equation: where q is the 2 × 1 vector of joint positions,q is the 2 × 1 vector of joint velocities, τ is the 2 × 1 vector of applied torques, M(q) is the 2 × 2 symmetric positive definite manipulator inertia matrix, C(q,q) is the 2 × 2 matrix of centripetal and Coriolis torques, and g(q) is the 2 × 1 vector of gravitational torques. Then, the model in Equation (1) can be represented in state space as: where x 1 = [q 1 q 2 ] is the output of the system, x 2 = [q 1q2 ] , M = M(q,q) ∈ R 2 , C = C(q,q) ∈ R 2 , g(q 1 , q 2 ) ∈ R 2×1 , f (q 1 ,q 2 ) ∈ R 2×1 , and τ = [τ 1 τ 2 ] is the torque vector as the input signal. Using the Euler method, the model in Equation (2) can be represented in discrete-time as: with x 1 (0) = [0 0] and x 2 (0) = [0 0] , where k ∈ Z ∪ 0 is the time index with Z as the set of non-negative numbers and T s is the sampling time. It must be noted that the Euler method represents a good alternative for the nonlinear discrete plant when the sampling rate is very low [23].

Discrete-Time 2DOF Robot Manipulator Model
In Figure 1, the proposed control system is presented. The structure has a neural identifier based in a RHONN trained with the EKF algorithm, and a discrete-time sliding mode controller. The system is validated on a FPGA hardware-in-loop implementation and Matlab/Simulink is used to model the 2DOF manipulator robot and the reference signal.

Neural Identification Method
The identification of the 2DOF model represented in the discrete-time model in Equation (3) is realized using a RHONN architecture [12]. The mathematical expression of the RHONN is described by the following Equation (4): where χ is the neural network state, w 1 , w 2 and w 3 are the synaptic weights calculated online by the EKF algorithm, S(·) is the sigmoidal activation function, u(k) is the l-th input signal, k is the discrete time step, l-th are the states of the NN, and y is the output of the RHONN [12]. The RHONN architecture used to identify the 2DOF system model, described by Equation (4), is presented in Figure 2. The RHONN is composed of two neurons and one layer; the high order is due to the second-order multiplication between the two states of the system. The potential of this RHONN is centered in the EKF algorithm with the covariance matrix explained in Section 3.2.

Extended Kalman Filtering Training Algorithm
In previous research, we demonstrated that Kalman filtering (KF) estimates the state of a linear system with an additive state and output white noise [12]. However, as the neural network mapping is a nonlinear system, then it is necessary to use an extended-KF (EKF) algorithm as described in [24]. The EKF is used for non-stationary discrete systems to ensure the accuracy of the online training process, and the mentioned method is shown below. with where l = 1, 2 is the number of joints, j = 1, 2 is the number of states of each joint, j ×m is the Kalman gain matrix, L l j is the respective number of neural network weights, χ l j (k) ∈ R m is the j-th neuron state corresponding to the l-th joint, is the derivative of j-th neural network state as is explained in more detail in [25]. For the proposed time-varying learning algorithm, the covariance matrices P l j (k), Q l j (k) and R l j (k) are initialized as diagonal matrices with random entries, and Q l j (k) and R l j (k) are composed of a time-varying coupled covariance between the j-th plant state, which allows the identification of interactions associated to the plant states and helps with the neural convergence. This technique is proposed in [12] and requires the efficient computation of Q l j (k) and R l j (k) in time-varying form such that it minimizes the identification error: This can be done in such a way that minimizes the variance (σ): where x m (k) = E(x(k)) and y m (k) = E(y(k)) are expressed in terms of the recursive expectation value, E(•), which represents the instantaneous mean value of the signal. For the proposed formulation, the state [x 1 (k) x 2 (k)] and output x 1 (k) = y(k) are considered as available measurements [14]. To get the best identification process, the algorithm calculates the prediction covariance matrices with a recurrent on-line feeding process.

Discrete-Time Sliding Mode Controller
For the present proposal, we assume that the RHONN of Equation (4) can be represented in general nonlinear discrete-time form as follows: where χ(k) ∈ R n is the state vector of the system (neural network state), u(k) ∈ R m is the input vector, y(k) ∈ R p is the output vector, the vector f (·) and the function B(·) are smooth vector fields, and d(k) is a vector that represents non-modeled dynamics and disturbances. This implies a non-singular transformation of the system in Equation (9), and can thus be represented in a controllable block form as in [26]. The r block is as follows: where , and the sets of numbers (n 1 , n 2 , ... n r ), which define the structure of the system in Equation (10), and satisfy n 1 ≤ n 2 ...≤ n r ≤ m [26]. Then, the transformation regarding the tracking error z(k) is defined as follows: where ∆ i (k) represents the identification error for the i-th joint block, and χ id (k) is the desired value for χ i (k) obtained as follows: It is important to mention that for n 1 , n 2 ..., n r > 1,B i+ =B i B iBi −1 is a pseudoinverse matrix and thus we can guarantee thatB i is non-singular. For our particular case, B is a scalar (ω l 1 ). Additionally, the fact that the K i diagonal matrix is made by k l elements, which constitutes a Schur matrix, means it yields the following expression: Then, applying the procedure explained in [14], the transformations in Equations (11)-(13) reduce the system in Equation (4) to the following form: Then, if we apply the block control technique in the last block of system, Equation (14) yields with the superscript l = 1, 2 as the l-th joint, obtainingf l 2 (χ(k), k) = ω l 1 (k)S χ l 1 (k) − χ ld (k + 1). Each joint has two blocks (r = 2), with n 1 = 1 and n 2 = 1,∆ l j (k) = ∆ l j (k + 1), and the subscript constitutes the j-th neural network state.
The sliding function s l D (k) can be derived from the block control transformation in Equation (11), and the last block of Equation (14) can be represented as Following the procedure explained in [14], the control law can be defined as for ũ l eq (k) > u l 0 (k) (17) where u l 0 (k) represents the input signal (torques τ 1 (k) and τ 2 (k) of the system in Equation (3)), withũ and In Equation (18),ũ eqα (k) belongs to the part that rejects the nonlinear dynamics of the RHONN in Equation (4), andũ eqβ (k) reduces the effect of the unknown identification error ∆ l j (k) of Equation (14). The results of the closed-loop system are shown in the next section. Now, following the procedure explained in [25]: the control law in Equation (17) is able to drive the system in Equation (15) within a small neighborhood of the sliding manifold z l 2 (k) = 0. Thus, the control error z l 2 (k) satisfies The sliding mode motion in an O(T s ) boundary layer of z l 2 (k) = 0 is described by the first-order system: By direct inspection of Equation (22), there exists k l 1 such that ∀k l > k l 1 , the position control error z l 1 (k) satisfies It is worth mentioning that the identification error∆ l 1 (k) can be made arbitrarily small by adding more higher order terms into the neural identifier in Equation (4), increasing the number of adjustable weights [12]. The 1 γ is a positive constant and must be modified to get a convergence of the sliding mode δ l 1 variable.

Real-Time Implementation and HIL Method
The real-time implementation of the proposed system is presented in Figure 3. The reference signal and the 2DOF manipulator robot model were realized in Matlab. The neural identifier based on the RHONN architecture, the EKF algorithm for the training, and the controller based on the discrete time sliding modes were implemented in a hardwarein-loop architecture using in the Evaluation Board Virtex 7 FPGA with an internal data acquisition device.
The testing of the system is performed with a virtual stimulus provided in HIL architecture so it gives an extraordinary opportunity to perform a real test case with a virtual stimulus, allowing the system to process the signals in real time and consequently obtain results in real time.
The nonlinear 2DOF manipulator robot is modeled in Matlab using the discrete-time presented in Section 2. The RHONN neural network is trained online using the EKF algorithm, where the associated state and measurement noise covariance matrices are composed by the coupled variance between the plant states. The implementation of the RHONN as the neural identifier was realized in the XSG design and the hardware-in-loop approach with a Virtex 7 FPGA. The results of the identification process and tracking control architecture was validated in a Matlab/Simulink environment and with the FPGA results. Figure 4 shows an image of the hardware-in-loop architecture.

Experimental Test and Real Time Results
The identification results are presented in Figure 5a for the first plant state of joint 1, where the identification process used the hardware-in-loop architecture with the FPGA and the real angular position for the first joint. Please note that in Figure 5a the initial condition for the neural identifier is 0. Then, in one step simulation time, the signal of the neural identifier estimates the angular position for the first joint with very good precision. Figure 5b displays the identification error for the first state of joint 1, where e 1 1 (k) is the error obtained with the FPGA hardware-in-loop architecture. For simplicity, only the identification of the first state of joint 1 is presented.
The results of the identification procedure shown in Figure 5a,b and explained in this work are completely valid for reducing the estimation error by means of computation of the associated state and measurement noise covariance matrices composed by the coupled variance between the plant states.

Experimental Test and Real Time Results
The identification results are presented in Figure 5a for the first plant state of joint 1, where the identification process used the hardware-in-loop architecture with the FPGA and the real angular position for the first joint. Please note that in Figure 5a the initial condition for the neural identifier is 0. Then, in one step simulation time, the signal of the neural identifier estimates the angular position for the first joint with very good precision. Figure 5b displays the identification error for the first state of joint 1, where e 1 1 (k) is the error obtained with the FPGA hardware-in-loop architecture. For simplicity, only the identification of the first state of joint 1 is presented.
The results of the identification procedure shown in Figure 5a,b and explained in this work are completely valid for reducing the estimation error by means of computation of the associated state and measurement noise covariance matrices composed by the coupled variance between the plant states.

Tracking Results
In order to show the tracking simulation results, the following reference signals were applied: with ω 1 = (3.5 t + 1) rad/s and ω 2 = (3 t + 3) rad/s. These reference signals were chosen arbitrarily to demonstrate a very good approximation. A sample time of k = 0.001 s is used, and if we then insert them into Equation (17), we obtain the following supply torques: The closed-loop simulation results using the FPGA hardware-in-loop architecture are presented in Figure 6.
The results for this real-time implementation are limited to the robot's physical parameters. The applied torque in Figure 6 has the maximum value calculated for this controller and it is applied

Tracking Results
In order to show the tracking simulation results, the following reference signals were applied: with ω 1 = (3.5 t + 1) rad/s and ω 2 = (3 t + 3) rad/s. These reference signals were chosen arbitrarily to demonstrate a very good approximation. A sample time of k = 0.001 s is used, and if we then insert them into Equation (17), we obtain the following supply torques: The closed-loop simulation results using the FPGA hardware-in-loop architecture are presented in Figure 6.
The results for this real-time implementation are limited to the robot's physical parameters The applied torque in Figure 6 has the maximum value calculated for this controller and it is applied

Tracking Results
In order to show the tracking simulation results, the following reference signals were applied: with ω 1 = (3.5 t + 1) rad/s and ω 2 = (3 t + 3) rad/s. These reference signals were chosen arbitrarily to demonstrate a very good approximation. A sample time of k = 0.001 s is used, and if we then insert them into Equation (17), we obtain the following supply torques: The closed-loop simulation results using the FPGA hardware-in-loop architecture are presented in Figure 6.
The results for this real-time implementation are limited to the robot's physical parameters. The applied torque in Figure 6 has the maximum value calculated for this controller and it is applied with limitations. An example of this can be if the applied disturbance reaches the limit of the physical resistance of the 2DOF construction material for the present 2DOF robot. It can be pushed to an uncontrolled dynamic behavior. However, the non-modeled dynamics can be tolerated until the 2DOF and the torque applied to the 2DOF resist the external involved perturbances if not reaching the SMC design parameters presented in this paper (Equation (17)).
Appl. Sci. 2020, 0, 5 11 of 16 uncontrolled dynamic behavior. However, the non-modeled dynamics can be tolerated until the 2DOF and the torque applied to the 2DOF resist the external involved perturbances if not reaching the SMC design parameters presented in this paper (Equation (17)).
(a) (b) The system works in open-loop during the interval from 0-0.5 s, and this in order to let the RHONN estimate the state space variables. After this setup period, the system is set in closed-loop An external disturbance is applied in the interval of time from the fifth to sixth second in a step-wise way. The tracking results for joints 1 and 2 are displayed in Figure 6, and their corresponding tracking errors are shown in Figure 7.
Additionally, in Figure 8 the applied torques are shown. As can be seen in Figure 8a, the applied torques T 1 (k) and τ 1 (k) reached the maximum value τ max 1 (k) specified in Equation (25) after approximately 3.4 s of simulation. This is the time in which the system proceeds to the sliding manifold s 1 D (k) ũ 1 eq (k) ≤ u 1 0 (k) . After these 3.4 s, the control law u 1 (k) is a smooth function which means that the sliding manifold s 1 D (k) has been reached ũ 1 eq (k) > u 1 0 (k) . After that the (a) Appl. Sci. 2020, 0, 5 11 of 16 uncontrolled dynamic behavior. However, the non-modeled dynamics can be tolerated until the 2DOF and the torque applied to the 2DOF resist the external involved perturbances if not reaching the SMC design parameters presented in this paper (Equation (17)).
The system works in open-loop during the interval from 0-0.5 s, and this in order to let the RHONN estimate the state space variables. After this setup period, the system is set in closed-loop An external disturbance is applied in the interval of time from the fifth to sixth second in a step-wise way. The tracking results for joints 1 and 2 are displayed in Figure 6, and their corresponding tracking errors are shown in Figure 7.
Additionally, in Figure 8 the applied torques are shown. As can be seen in Figure 8a, the applied torques T 1 (k) and τ 1 (k) reached the maximum value τ max 1 (k) specified in Equation (25) after approximately 3.4 s of simulation. This is the time in which the system proceeds to the sliding manifold s 1 D (k) ũ 1 eq (k) ≤ u 1 0 (k) . After these 3.4 s, the control law u 1 (k) is a smooth function which means that the sliding manifold s 1 (k) has been reached ũ 1 eq (k) > u 1 0 (k) . After that the (b) Figure 6. (a) Angular position tracking results for x 1 1 (k), and (b) for x 1 2 (k).
The system works in open-loop during the interval from 0-0.5 s, and this in order to let the RHONN estimate the state space variables. After this setup period, the system is set in closed-loop. An external disturbance is applied in the interval of time from the fifth to sixth second in a step-wise way. The tracking results for joints 1 and 2 are displayed in Figure 6, and their corresponding tracking errors are shown in Figure 7.
Additionally, in Figure 8 the applied torques are shown. As can be seen in Figure 8a, the applied torques T 1 (k) and τ 1 (k) reached the maximum value τ max 1 (k) specified in Equation (25) after approximately 3.4 s of simulation. This is the time in which the system proceeds to the sliding manifold s 1 D (k) ũ 1 eq (k) ≤ u 1 0 (k) . After these 3.4 s, the control law u 1 (k) is a smooth function, which means that the sliding manifold s 1 D (k) has been reached ũ 1 eq (k) > u 1 0 (k) . After that the disturbance is applied at 5 s, and in consequence the applied torques goes to the maximum value. This point can be observed in the tracking results shown in Figure 6a and the applied torques T 2 (k) and τ 2 (k) are shown in Figure 8b. In other words, after the 0.5 s, the value specified in Equation (25) means that the sliding manifold s 2 D (k) has been reached immediately thanks to the controller in ũ 2 eq (k) > u 2 0 (k) . Table 1 contributes with the hardware resource utilization of logic circuits used in the hardware-in-loop architecture for the complete control system, which has the SMC controller and the RHONN neural identifier. This table shows the quantity of DSP48s circuits that were used as arithmetic blocks with floating point variables. It also allows integration of other kind of structures in a training device with an FPGA. The proposed design saves a great deal of resources that can be used for improved versions of the algorithms presented herein, to increase the applicability of this method.
Appl. Sci. 2020, 0, 5 12 of 16 Table 1 contributes with the hardware resource utilization of logic circuits used in the hardware-in-loop architecture for the complete control system, which has the SMC controller and the RHONN neural identifier. This table shows the quantity of DSP48s circuits that were used as arithmetic blocks with floating point variables. It also allows integration of other kind of structures in a training device with an FPGA. The proposed design saves a great deal of resources that can be used for improved versions of the algorithms presented herein, to increase the applicability of this method.   Table 1 contributes with the hardware resource utilization of logic circuits used in the hardware-in-loop architecture for the complete control system, which has the SMC controller and the RHONN neural identifier. This table shows the quantity of DSP48s circuits that were used as arithmetic blocks with floating point variables. It also allows integration of other kind of structures in a training device with an FPGA. The proposed design saves a great deal of resources that can be used for improved versions of the algorithms presented herein, to increase the applicability of this method

Discussion
The main goal of the work presented in this paper was the control system designed for the 2DOF manipulator robot using a RHONN module in a hardware-in-loop setup. As such, we have presented a methodology for identification and tracking of the plant (2DOF) to be controlled. Once the identification and tracking results are reached, the present proposal can be expanded with a real 2DOF implementation, where the mathematical model is unknown and only the state variables are available. The results are obtained without the necessity to know the complete mathematical model of the plant,

Discussion
The main goal of the work presented in this paper was the control system designed for the 2DOF manipulator robot using a RHONN module in a hardware-in-loop setup. As such, we have presented a methodology for identification and tracking of the plant (2DOF) to be controlled. Once the identification and tracking results are reached, the present proposal can be expanded with a real 2DOF implementation, where the mathematical model is unknown and only the state variables are available. The results are obtained without the necessity to know the complete mathematical model of the plant,

Discussion
The main goal of the work presented in this paper was the control system designed for the 2DOF manipulator robot using a RHONN module in a hardware-in-loop setup. As such, we have presented a methodology for identification and tracking of the plant (2DOF) to be controlled. Once the identification and tracking results are reached, the present proposal can be expanded with a real 2DOF implementation, where the mathematical model is unknown and only the state variables are available. The results are obtained without the necessity to know the complete mathematical model of the plant, or the parameters. Even when the results are obtained via a hardware-in-loop configuration, the proposed methodology constitutes an advance in a new control system architecture: the RHONN, modified EKF, and SMC implemented on an FPGA. This is due to the strategy proposed in this work, which guarantees there is no requirement for an exact mathematical model to be reproduced by an FPGA. Furthermore, the contribution of this proposal is in the area of programming a RHONN on an FPGA. The FPGA can compute and solve the problem with this architecture: a RHONN in discrete-time; the modified extended KF algorithm where the associated state and measurement noise covariance matrices are composed by the coupled variance between the plant states; and the decentralized discrete-time sliding mode controller combined with a block control algorithm. The results of the control system with the new combination of the mentioned architectures has been discussed in detail and the experiments show very satisfactory results.
The results of the tracking control and identification process show the high performance of the system, which is a tangible evidence of the new design architecture implemented for discrete nonlinear systems.
This control system architecture has never been solved with this methodology in this field and has not used the XSG, ignoring its potential in the design of complex systems. Using an FPGA and co-design, in tandem with a hardware-in-loop approach, any control can be implemented in the re-configurable hardware for quick simulation and production.

Conclusions
The design and implementation of a real-time control system for a 2DOF robot based on a neural network and hardware-in-loop architecture has been presented in this paper, and it is an adequate alternative for a 2DOF manipulator robot performing medical tasks. A decentralized RHONN was trained online with the modified EKF algorithm, where the associated state and measurement noise covariance matrices were composed by the coupled variance between the plant states. Additionally, a sliding-window-based method for dynamical modeling of non-stationary systems with a decentralized SM controller was implemented as an improvement for the 2DOF manipulator robot. In addition, the SM controller was successfully implemented, enabling the system to provide a relative fast-tracking error of the control signal with a slight use of computing resources. FPGA implementation allows a high performance and fast time calculations in a relatively low-cost platform. The testing of the system with virtual stimuli, and the internal acquisition data device provided by the Board Virtex 7/Evaluation kit through the HIL architecture, made the real-time results shown in this paper possible. The use of an FPGA implementation for this problem avoids the necessity to have an external data acquisition device, decreasing the number of circuits for the final design. Additionally, the control system implementation requires a smaller layout for manufacturing the digital circuit in a printed circuit board (PCB).
Future work can be expanded to consider different dynamic systems and SMC variations with new mathematical contributions in the algorithm in discrete time. The control system exposed with this methodology can be used in future work in high-accuracy medical tasks with a high performance.

Conflicts of Interest:
The authors declare no conflicts of interest.