**5. Speed control of BLDC motor based on wavelet neural network**

The WNN-PID controller based on PSO is proposed in this section, which combines the ability of the artificial neural networks for learning with the ability of wavelet for identification, control of dynamic system, and also having the capability of self-learning and adapting [10, 11, 19, 37]. Two types of wavelet network are modified in this section, feedforward WNN and proposed recurrent WNN with online tuning optimization using PSO algorithm [22–24].

### **5.1 WNN-PID controller based on PSO**

In this type of controller, the WNN is utilized with PID controller based on PSO algorithm. WNN-PID controller utilizes online learning by PSO algorithm, where the PSO learning algorithm is used to train the translation parameters ak and bk, weights connection in the WNN, and the parameter (kp, ki, kd) of PID controller on-line with the model of BLDC motor to control the speed at the desired value. There are two major issues to implement any wavelet neural networks. First, the network architecture is used and second, the algorithm is used to learn the network by the PSO algorithm. **Figure 6** depicts the block diagram of the BLDC motor with WNN-PID based on PSO algorithm. The structure and the design of the WNN-PID controller will be given in the next subsection.

## **5.2 Design of the structure of WNN-PID controller based on PSO training algorithm**

**1. Design of PSO algorithm:** the PSO algorithm is discussed in Section 5, where each particle parameters are initiated to make a population and then the algorithm is accomplished according to the flow chart given in **Figure 6**, which includes training the parameters of this controller to guarantee the minimization of an objective function. The objective fitness is evaluated as follows:

$$\text{fitness function} = \min\left(\text{ISE}\right) + \min\left(\mathbf{M}\_{\mathbb{P}}\right) \tag{16}$$

where ISE is the integrated of square error and Mp is the maximum peak overshoot.

**2. Design of WNN-PID controller**: to design the WNN-PID controller, the type of WNN must be selected as shown in Section 3 and also the number of layers and neurons and the wavelet function type must be selected [16]. In this chapter, the input layer has two inputs: the speed error and the change of this error. One hidden layer with four neurons is used. Three types of mother wavelet functions are used and they are: the Mexican hat function is [10, 11, 22, 37, 39]

$$\boldsymbol{\Psi}(\mathbf{x}) = \left(\mathbf{1} - \mathbf{x}^2\right) \overline{\mathbf{e}}^{\frac{\mathbf{x}^2}{2}} \tag{17}$$

The first partial derivative Mexican hat is

$$\Psi(\mathbf{x}) = (-\mathbf{x})\mathbf{e}^{\frac{\mathbf{x}^2}{2}} \tag{18}$$

**Figure 6.** *Block diagram of the BLDC motor with WNN-PID controller based on PSO algorithm.*

The Morlet's basic wavelet function is

$$\Psi(\mathbf{x}) = \text{Cov}(\mathbf{w}|\mathbf{x}) \mathbf{e}^{\frac{-\mathbf{x}^2}{2}} \tag{19}$$

where x is the desired signal and w is a variable value, which was adopted to satisfy the admissibility condition. w = 5 is chosen. The output layer contains one output which is the sum of PID controller and WNN outputs. The parameters values of the WNN-PID controller, such as the dilation factors ak<sup>0</sup> <sup>s</sup> and the translation factors bk<sup>0</sup> <sup>s</sup> of the mother wavelet function, the weights connection wk<sup>0</sup> <sup>s</sup> of the WNN, and PID parameters (kp, ki, kd), are optimized online in PSO algorithm. The results given in this chapter are for Mexican hat function only. The results for the rest functions are similar to that in Mexican hat and are not given.
