### Residue theorem

The residue theorem is considered as one of the best tools to predict the area under a curve. The Cauchy Theorem stated that if a function is analytic on and in a closed contour C, then the integral over the closed contour is zero [16, 17].

### Theorem 1.

Let *D* be a simply connected domain, and let *C* be a simple closed positively oriented contour that lies in *D*. If *f*(*z*) is analytic inside and on *C*, except at the points *z*_{1},*z*_{2},.....,*z*_{n} that lie inside *C*, then

$$\begin{array}{@{}rcl@{}} \oint{f(z)}dz=2\pi\iota \sum\limits_{k=1}^{n} RES[f,z_{k}]. \end{array} $$

(18)

The illustration of such a situation is shown in Fig. 3, and the general form of the residue theorem can be expressed in Eq. (19).

$$\begin{array}{@{}rcl@{}} RES\, f(x)=\frac{1}{2\pi\iota}\int^{+\infty}_{-\infty} f(x) \, dx. \end{array} $$

(19)

The forward Euler method which is represented by Eq. (20), is implemented to ensure the convergence of the point to the reference point, so that the stability of the system is maintained [18, 19].

$$\begin{array}{@{}rcl@{}} \dot{y}\approx\frac{y(t+h)-y(t)}{h}. \end{array} $$

(20)

### Using residual for speed controller

In this controller (Residual for speed controller), a speed control loop has been designed using the residue theorem where the dq-axis current controllers are controlled using PI controllers. The speed boundary area is selected to be between a reference point plus the absolute value of the error and the reference point minus the absolute value of the error. The speed error (*e*) is the difference between the reference point and the actual measured point of speed. The implementation of Eq. (19) to the speed controller is done by assuming that at each point of time the speed lies in the boundary between the reference speed (*ω*_{rref}) plus error and the reference speed minus error. The rotor speed can be expressed as follows:

$$\begin{array}{@{}rcl@{}} RES(\omega_{r})=\frac{1}{2\pi\iota}\int^{\omega_{rref+e}}_{\omega_{rref-e}} \omega_{r} \, d\omega. \end{array} $$

(21)

By solving the above integration, the definition of the controlled speed can be described as:

$$\begin{array}{@{}rcl@{}} RES(\omega_{r})=\mid\frac{\omega_{rref}e}{\pi}\mid. \end{array} $$

(22)

The speed error is defined according to the forward Euler method to ensure the convergence of the speed to the reference speed which is shown in Eq. (20).

$$\begin{array}{@{}rcl@{}} \left. \begin{array}{ll} \dot{e}=e+c\\ e=\omega_{rref}-\omega_{r} \end{array}\right\} \end{array} $$

(23)

By solving (23),

$$\begin{array}{@{}rcl@{}} \dot{\omega}_{rref}-\dot{\omega}_{r}=\omega_{rref}-\omega_{r}+c \end{array} $$

(24)

Solving (24) with respect to the mechanical speed Eq. (5) to get the final design equation, which is used to generate the q-axis reference current. Then the design equation is presented in (25).

$$\begin{array}{@{}rcl@{}} i_{q}=\frac{3}{2 p \psi_{PM}}\left[T_{m}-B\omega_{r}-\frac{J}{\pi}\omega_{rref}-JK\right]. \end{array} $$

(25)

#### Controller stability analysis

The stability of a controller is determined by implementing the forward Euler which ensures the convergence of the operating point to the boundary. The forward Euler converges strongly when the function is Lipschitz [19, 20]. Assume that wind speeds change from 8 m/s to 10 m/s then the reference speed, which is generated from an MPPT controller, changes from *ω*_{rref1} to *ω*_{rref2}. Hence the rate of change of the actual speed is as the following:

$$\begin{array}{@{}rcl@{}} \dot{\omega}_{r}=\dot{\omega}_{rref}-\omega_{rref2}+\omega_{r1}-c. \end{array} $$

(26)

It should be noted that the term \(\dot {\omega }_{rref}\) has the highest influence in the controller decision. Furthermore, the change in the actual speed has the same sign of the change of the reference speed. The value of the constant *c* should ensure the convergence of the system and the stability and it must meet the following Lipschitz condition [21]:

$$\begin{array}{@{}rcl@{}} c\leq\frac{|\dot{\omega}_{r}-\dot{\omega}_{rref}|}{|\omega_{r}-\omega_{rref}|}. \end{array} $$

(27)

### Using residual for speed and currents controller

In this controller (Residual for speed and currents controller), the speed and dq-axis current controller are designed using the residue theorem. The boundaries are selected to be the reference value plus the error and the reference value minus the error. The linearized dq-axis equations and the final design equations are shown in (28) [22].

$$\begin{array}{@{}rcl@{}} \left. \begin{array}{ll} V_{d}=R_{s} I_{d}+L\frac{di_{d}}{dt},\\ V_{q}=R_{s} I_{q}+L\frac{di_{q}}{dt},\\ V_{d}=R_{s} I_{d}+LK,\\ V_{q}=R_{s} I_{q}+\frac{L\,e\,i_{qref}}{\pi}+LK. \end{array}\right\} \end{array} $$

(28)

The exact value of a rotor position angle is required in order to implement a dq-axis model. Many techniques for estimating the rotor position have been reported [23, 24]. In this controller, a back-EMF observer has been used to estimate the rotor position, since the back-EMF is a function of the rotating speed. The sinusoidal back-EMF equation in the *α*−*β* coordinate can be denoted as follows [22]:

$$\begin{array}{@{}rcl@{}} \left. \begin{array}{ll} e_{\alpha}=L\frac{d}{dt}i_{\alpha}+R_{s} i_{\alpha}+V_{\alpha},\\ e_{\beta}=L\frac{d}{dt}i_{\beta}+R_{s} i_{\beta}+V_{\beta}, \end{array}\right\} \end{array} $$

(29)

where *e*_{αβ}, *V*_{αβ} and *i*_{αβ} are the back emf, voltage and current of a PMSG in the *α*−*β* co-ordinate and *L* is the PMSG inductance. The rotor position *θ* can be estimated from Eq. (29) as follows [25]:

$$\begin{array}{@{}rcl@{}} \hat{\theta}=\tan^{-1}\left(\frac{e_{\alpha}}{e_{\beta}}\right). \end{array} $$

(30)

The values of the dq-axis voltages are used to generate a control signal of a pulse width modulation (PWM). The dq-axis voltages are normalized and compared with a triangular signal with an amplitude of 1 and a frequency of 20 kHz.

### Using proposed residual controller with estimated reference speed

One of the most important issues in WPGS control is the measurement of the wind speed. The accuracy of the wind speeds measurement can not be ensured using a single anemometer. Also, the data recorded using SCADA system contain noticeable deviations which influence in the power conversion efficiency [26]. In this controller, the wind speed is estimated using MPPT algorithm, and the reference speed is generated using the estimated data. The wind power model which is expressed in Eqs. 2 and 3 can be solved for the wind speed and the *P*_{m} is assumed to be the output DC power. The estimated wind speed can be shown as the following:

$$ V_{w}=\frac{-D_{21}\omega_{r}^{2}\pm \sqrt{D_{21}^{2}\omega_{r}^{4}-4D{11}\omega_{r}\left(D_{31}\omega_{r}^{3}-VI\right)}}{2D_{11}\omega_{r}}. $$

(31)

where *D*_{11}=0.0960, *D*_{21}=−0.0098 and *D*_{31}=−0.0040. The MPPT controller is implemented in the proposed controller-II which is presented in Section 4.3.