# Low-Cost Implementation of an Adaptive Neural Network Controller for a Drive with an Elastic Shaft
## 2 Description of the Plant and the Controller  
The analyzed cascade control structure (Figure 2) consists of two loops: the outer loop with the speed controller (RBFNN), and the inner loop, which is tied to the power converter; the last part of the system is the plant--the two-mass drive. The current loop (the inner loop) is responsible for creating an electromagnetic torque and can be described in the following manner:  
\[G_{i}(s)=\frac{1}{T_{f}s+1} \tag{1}\]  
where \(T_{f}\) is the total time of the current control loop and the power electronics operation, \(s\) is the Laplace operator. Figure 1: Structure of the Radial Basis Function Neural Network. Figure 2: The control structure with the adaptive RBFNN speed controller applied to the two-mass drive. It was assumed that there was no delay in this part of the drive. Hence, the time constant was set to zero, and the final equation can be rewritten as:  
\[G_{i}(s)=1. \tag{2}\]  
The plant is based on two electrical machines coupled by a long shaft. Such a system is often referred to as the two-mass system [46, 47]. Nonlinear phenomena such as friction and backlash were omitted in the equations [48, 49, 50, 51, 52]:  
\[\omega_{1}s =\frac{m_{e}-m_{s}}{T_{1}} \tag{3}\] \[\omega_{2}s =\frac{m_{s}-m_{L}}{T_{2}}\] (4) \[m_{s}s =\frac{\omega_{1}-\omega_{2}}{T_{c}} \tag{5}\]  
where \(\omega_{1}\) and \(\omega_{2}\) are the speed of the motor and the load, respectively, \(m_{e}\) and \(m_{s}\) are the electromagnetic and torsional torque, \(m_{L}\) is the disturbance (the load torque). \(T_{1}\), \(T_{2}\), and \(T_{c}\) are the time constants which correspond to the motor, the load, and the shaft. The parameters of the control system were adjusted to the laboratory setup so that the time constants correspond. All variables were assumed to be observable and available to the control algorithm. RBF neural networks are a special case of feedforward neural networks [53]. Their distinctive feature is that they always have one hidden layer whose neurons have radial activation functions. The most commonly used radial basis function can be described using the following formula [54]:  
\[h_{i}=\exp\left(-\frac{\|\mathbf{x}-\mu_{i}\|^{2}}{2\sigma_{i}^{2}}\right) \tag{6}\]  
where \(h_{i}\)--the output of the \(i\)-th hidden layer neuron, \(x\)--the input vector, \(\mu_{j}\)--the center vector of the \(j\)-th neuron, \(||\cdot||\)--euclidean distance, \(\sigma_{j}\)--the width of the activation function. The output of the RBF neural network can then be calculated as:  
\[y_{out}=\sum_{i=0}^{n}w_{i}h_{i} \tag{7}\]  
with \(w_{i}\) being the \(i\)-th weight. The online weight update approach was chosen to ensure adaptability and robustness to changes in parameters. The gradient descent algorithm was selected to update weights of the neural network. The weights are updated as in the equation presented below:  
\[w_{i}(k+1)=w_{i}(k)+\Delta w_{i}(k). \tag{8}\]  
With the cost function described as:  
Figure 1:0  
where \(\omega_{refm}(k)\) -- the desired value of the angular speed from the reference model in the \(k\)-th iteration [12]. The correction value for the \(i\)-th weight can be calculated as:  
Figure 1:1where \(\eta\) -- learning rate. To adjust the structure of the network, the parameters of the radial activation function are also subject to adaptation. The new values of center and widths are calculated as follows:  
Figure 1:2  
Figure 1:3  
The following equations describing the adaptation for centers \(\mathbf{\mu}_{i}\) and widths \(\sigma_{i}\) were applied:  
Figure 1:4  
Figure 1:5  
where \(\gamma\) is learning rate associated with the parameters of the radial basis functions.