*4.1. FLC-based Direct Power Control*

In this section, for the new PVMT and DPC-based VSI model presented in (20), a robust and simple controller consisting of feedforward and feedback control structure is designed. In Figure 2, the FLDPC method's schematic for the PV-VSI is depicted. In this control, the power (real and reactive) references are tracked by controlling their actual value using FLC.

The real and reactive power errors can be obtained using (21):

$$e\_P := P\_{ref} - P$$

$$e\_Q := Q\_{ref} - Q \tag{21}$$

where active and reactive power references are represented by *Pref* and *Qref*, respectively, and real and reactive power errors are *e<sup>P</sup>* and *eQ*, respectively.

As shown in Figure 2, for obtaining zero steady state error, two error signals (*e<sup>P</sup>* and *eQ*) and their rate of change (*P-error\_rate* and *Q-error\_rate*) are given as inputs to two FLCs. The outputs of FLCs provided the control inputs *F<sup>P</sup>* and *F<sup>Q</sup>* for the feed-forward controllers. Due to non-availability of the FLC block in the RSCAD library, FLC is built in RSCAD software by writing codes using ANSI language in C-builder. Each FLC consisted of two inputs and one output, as depicted in Figure 2. The two inputs were the error and error-rates of power for each FLC. The membership functions of inputs and outputs were named identical for both real and reactive power. The variables representing error were NM (negative medium), ZV (zero value), and PM (positive medium). Similarly, error-rate variables were NM1 (negative medium 1), ZV1 (zero value 1), and PM1 (positive medium 1). The variables of output were BNE (big negative error), NME (negative medium error), ZE (zero error) and PME (positive medium error). In Figures 3 and 4, the real and reactive power FLCs' membership functions for error, error-rate and outputs are shown.

To ensure smooth control by FLC, triangular-based membership functions were considered in this study.

**Figure 3.** Membership functions of (**a**) P-error (*eP*), (**b**) error\_rate of P (*deP/dt*) and (**c**) output of FLC (*FP*).

**Figure 4.** Membership functions of (**a**) Q-error (*eQ*), (**b**) error\_rate of Q (*deQ/dt*) and (**c**) output of FLC (*FQ*).

An important part in the design of FLC is choosing the scaling factors of input and output membership functions optimally. This can be obtained by implementing optimization techniques to minimize the deviation between inverter output powers and the reference powers. In this study, a black-box optimization technique known as the nonlinear Simplex method of Nelder and Mead is adopted for obtaining the optimal scaling factors of input and out membership functions [42]. The reason for choosing the black-box optimization technique is that it can be easily used in conjunction with time-domain or real-time simulation tools [24]. The process of black-box optimization entails the successive evaluation of the objective function for the different sets of parameters for the membership functions. In this process, the real-time simulation program, i.e., RSCAD/RTDS, is used to evaluate the value of the objective function. First, an initial set of parameters was used to initialize the real-time simulation in RTDS, and the value of the objective function was numerically evaluated. Then, based on the optimization algorithm and the value of the objective function, a new set of parameters were obtained, and the process was repeated until an optimal set of parameters is determined.

To assign the input and output control, fuzzy rules were formed based on IF-THEN rules, which are summarized in Table 1. The rules were decided depending on the cooperation between the estimated error and complexity of FLC. In this paper, defuzzification was carried out by using the Sugeno-type weighted average method [43] to produce the real crisp output of *F<sup>P</sup>* and *FQ*.


**Table 1.** Rule table for FLCs of real and reactive power.
