A Uniﬁed Control Strategy of Distributed Generation for Grid-Connected and Islanded Operation Conditions Using an Artiﬁcial Neural Network

: This article presents a control strategy that enables both islanded and grid-tied operations of a three-phase inverter in distributed generation. This distributed generation (DG) is based on a dramatically evolved direct current (DC) source. A uniﬁed control strategy is introduced to operate the interface in either the isolated or grid-connected modes. The proposed control system is based on the instantaneous tracking of the active power ﬂow in order to achieve current control in the grid-connected mode and retain the stability of the frequency using phase-locked loop (PLL) circuits at the point of common coupling (PCC), in addition to managing the reactive power supplied to the grid. On the other side, the proposed control system is also based on the instantaneous tracking of the voltage to achieve the voltage control in the standalone mode and retain the stability of the frequency by using another circuit including a special equation ( wt = 2 π f t, f = 50 Hz). This utilization provides the ability to obtain voltage stability across the critical load. One beneﬁt of the proposed control strategy is that the design of the controller remains unconverted for other operating conditions. The simulation results are added to evaluate the performance of the proposed control technology using a different method; the ﬁrst method used basic proportional integration (PI) controllers, and the second method used adaptive proportional integration (PI) controllers, i.e., an Artiﬁcial Neural Network (ANN).


Introduction
Centralized power stations all over the world dominate the modern paradigm for power generation and supply. The generation of electricity in such plants generally uses as oil, coal, gas and nuclear power. The demand control network between stations and the end user resembles central electricity models. There are a few disadvantages to this single power plant scheme. The operating stresses in the existing transmission and distribution systems emerge from growing loads, which contribute to an increasing burden on electricity networks. Greenhouse gas emissions indicate a need for cleaner renewable energy sources. Alternative fuels like fuel cells, solar photovoltaic devices, wind turbines and biomass are used for distributed generation, as are microturbines and microgrids (DG). As a feasible solution to the above questions, these have been suggested.
New developments in DG technologies such as gas turbines, diesel engines, hydro turbines, and the wind energy conversion system (WECS) promise more efficient and greener power production [1,2]. Furthermore, DG is a feasible choice for maintaining high electrical efficiency because it can work in either a grid-tied or an islanded mode [3]. In the Sustainability 2021, 13, 6388 2 of 30 grid-tied mode, DG delivers energy to the utility and the local critical load [4]. However, DG can detach from the service and continue feeding critical local loads so that those critical loads will increase their power reliability [5]. The voltage is closely tightened with the tool in the grid-tied operation and regulated in the insular situation by the DG, such that both operating conditions are an important issue. DG would have to overcome the charge voltage as soon as possible in the event of the load voltage, which poses an obstacle to DG's operation regarding the reduction of the load voltage transient when insulating [6].
DG is described as small generators linked to the load of the end user. They will lower the investment costs in transmission and distribution network improvements whilst also meeting power demand and providing consumers with high-quality and reliable electricity supply without emissions and harmful environmental impacts [7,8]. As far as Figure 1 is concerned, DG can usually be interpreted as small power plants built and run within a local loading center.
Sustainability 2021, 13, x FOR PEER REVIEW 2 of greener power production [1,2]. Furthermore, DG is a feasible choice for maintaining hig electrical efficiency because it can work in either a grid-tied or an islanded mode [3]. In th grid-tied mode, DG delivers energy to the utility and the local critical load [4]. Howeve DG can detach from the service and continue feeding critical local loads so that those critic loads will increase their power reliability [5]. The voltage is closely tightened with the to in the grid-tied operation and regulated in the insular situation by the DG, such that bot operating conditions are an important issue. DG would have to overcome the charge voltag as soon as possible in the event of the load voltage, which poses an obstacle to DG operation regarding the reduction of the load voltage transient when insulating [6]. DG is described as small generators linked to the load of the end user. They will lowe the investment costs in transmission and distribution network improvements whilst als meeting power demand and providing consumers with high-quality and reliab electricity supply without emissions and harmful environmental impacts [7,8]. As far a Figure 1 is concerned, DG can usually be interpreted as small power plants built and ru within a local loading center. Electronic power conversion systems need to be built in order to monitor the energ supply and ensure the stable access of all of the DG's sources to the current power system [9]. In this manner, energy supply systems can also be regulated and conditioned. I particular, the typical connecting point between a DC bus and an AC environment achieved with most DG sources, such as low power variable AC wind turbines, DC fu cells, variable frequency AC Micro Turbines, PV panels, and electric power as a D voltage or converted to a DC voltage.
DG has multiple benefits and advantages, such as voltage support and power supp diversification, as well as the reduction of transmission and distribution network losse increased electricity efficiency, and transmission and distribution capability releas among others, which will boost the grid without installing or modifying any curren transmission/distribution infrastructure.
When interacting with DG systems, some problems and questions should b discussed. Particularly when the design is made for power distribution support, and whe Electronic power conversion systems need to be built in order to monitor the energy supply and ensure the stable access of all of the DG's sources to the current power systems [9]. In this manner, energy supply systems can also be regulated and conditioned. In particular, the typical connecting point between a DC bus and an AC environment is achieved with most DG sources, such as low power variable AC wind turbines, DC fuel cells, variable frequency AC Micro Turbines, PV panels, and electric power as a DC voltage or converted to a DC voltage.
DG has multiple benefits and advantages, such as voltage support and power supply diversification, as well as the reduction of transmission and distribution network losses, increased electricity efficiency, and transmission and distribution capability release, among others, which will boost the grid without installing or modifying any current transmission/distribution infrastructure.
When interacting with DG systems, some problems and questions should be discussed. Particularly when the design is made for power distribution support, and when the principles both the grid-connected (GC) and the stand-alone (SA) state are included, some considerations need to be made. Each DG device is usually run in the grid-connected mode, in which power is supplied or delivered to a pre-set grid, i.e., the new grid-synchronized control mode [10][11][12].
Once the principal grid is cut off from DG system by a grid breakdown, the DG system will sense the insulation and turn to a voltage control model to provide voltage stability to the local critical loads [13,14], which is the basis for the operation of a standalone operation, or the insulation mode. It is trendy that the grid-connected (GC) mode should also be able to operate in stand-alone mode [15]. This means that the grid is also accessible. New problems are being identified in DG control techniques for voltage adjustment in standby mode, current grid mode adjustment, and automated grid failure detection.
DG will provide advantages both for the customers and the utilities in delivery networks, and transmission networks are limited elsewhere. DG [16][17][18][19][20][21][22][23][24] is projected to reduce greenhouse gas emissions in relation to traditional generations because it increases the number of renewable energy supply consumers, and DG could act as a replacement for transmission and distribution infrastructure investments, which will help to prevent congestion in the current transmission networks. Thus, a high productivity network is achieved. The installation's energy quality can be grown by preparing and operating the production and storage appropriately.
Additionally, the need for new facilities can be postponed or replaced by delivery generations due to the opportunities of incorporation into houses; DG construction also takes place in the same place as the demand. In these situations, network strengthening might not be required if the production performance is combined with the demand-like air conditioning demand in hot regions-whilst the generation remains in the same order of magnitude as the demand.
In addition, normal power grid development may be delayed as a result of increasing the demand using DG, minimizing transmittance and distribution losses, resulting in a reduction of the energy transmission from a centralized plant and reduced transmission and distribution costs, which are a large part of the total electricity costs as a result of production units and power generation units. Moreover, it leads to a high voltage transient link between distributed generators and power networks. Moreover, problems exist with DG's provision of nonlinear local loads, such as electrical furnaces, semi-conductive equipment, solders and inductive furnace systems. Its reason for generating the harmonic components of the voltages and currents and its power supply to critics cannot achieve the optimum efficiency of DG when a grid breakdown occurs. It still takes a long time for the power grid to be repaired, before the DG is ready and in a state of service. In addition, during the transition from the island service, the inrush grid current is attached to the grid. During transmission from a grid-bonded to a standalone service, the output voltage of the DG may become unstable with poor dynamical efficiency.
In this case, the inverters are often controlled by a voltage control loop as a voltage source; the consistency of the load voltage during the transmission between the operating conditions can also be maintained at a constant, and this control can also be imposed on the DG in order to ensure power sharing among the DG and the grid-tying utility [25][26][27]. The bandwidth of the external power control circuit is also much lower than that of the voltage circuit, and therefore has low dynamic performance.
In addition, the inrush grid current occurs through a phase-locked loop (PLL) and Simulated Inductance during transmission from the standalone condition to the grid-tied condition. The grid current is also directly uncontrolled [28]. The hybrid voltage and the mode regulation of the current mode is an effective solution for DG, in which two different control sets are used .
The inverter is operated by other controls in the standalone operation as a voltage source whilst the current source is controlled by a grid-tying controller set. The voltage loop, and the current loop as a hybrid device in this method, can then obtain a pleasant dynamic output.
Moreover, the grid operation directly controls the output current and almost eliminates the inrush grid current. When the DG's operating state is converted, the hybrid voltage and power control system must be switched automatically through the controllers. When insulated, an automatic switch is attached to the voltage control model in order to prevent Sustainability 2021, 13, 6388 4 of 30 the loading voltage being either clamped by a utility or regulated by the DG, and the time for the transmission between the operational conditions will be calculated for the insulation detection phase. The speed and precision of the insulation detection technique is therefore a major problem in this approach, which provides a high-quality waveform of the load voltage [50][51][52][53]. Other problems with the solution are the grid current waveform efficiency and the charge voltage under a nonlinear local load. The output current of DG is normally desired to be strictly sinusoidal in the grid-tying operation [54], as the nonlinear local load is fed the harmonic components of the charge current flow entirely through the utility. A single-phase DG injects a harmonic current into the grid current utility, as represented in [55], in order to reduce the harmonic parts of the grid current. The DG controller strengthens the voltage control model in order to change the harmonic frequency resistance and then decrease the harmonic current into the power supply [56].
In a standalone operation, a nonlinear load will detract from the voltage [57], and several controls and a multi-loop control system have been suggested to obtain a high quality of the waveform for the load voltage, including [57], a resonant controller [58,59], and a control sliding mode [60]. However, in grid-tied operations, the focus of the existing control policies and dealing with a nonlinear local load in DG, in particular, focuses on either grid current efficiency elsewhere or load tension in the island operation (VL), and both of these are seldom improved using a single management approach.
In this study, a coherent control strategy is addressed which removes the previously mentioned limitations and shortcomings. The DG is advised to run in a standalone or grid-bundled service with this control system. However, the controllers used by each operating environment change the strategies simply. This control strategy manages voltage and frequency in an island operating condition of the DG interface using the voltage monitoring procedure for each device, which is performed by PI controls and a special circuit integrated in proportion instead of the Phase Locked Loop (PLL). The proposed control strategy even extends the fuel economy in grid-tied operation conditions.
With a view to the elimination of the harmonic component of the grid current in the grid operation, DG introduces harmonic power into the grid and thus reduces the harmonic component of the grid current and prevents ripples by means of L-C Filter architecture to produce the purest wave shapes possible.
The proposed control strategy based on an adaptive PI neural network-based controller is presented in this paper to gain high efficiency during microgrid operation and reduce the transient across the critical load in order to achieve the maximum stability in different operating conditions. First, the conventional control method through Basic PI controllers is presented and tested. Secondly, the proposed method through adaptive PI controllers based on Neural Networks is explained in detail and conducted on the same test system.
The proposed adaptive PI neural network strategy successfully achieves results better than the first method, as shown later in the simulation results section. This paper is organized as follows: Section 2 shows the description of the system under study, while Section 3 presents the proposed control strategy and algorithm. In Section 4, the simulation results are presented and accordingly, in Section 5, the discussion is carried out. Finally, in Section 6, the final conclusions are drawn.

General Elements in the Main Power Network
Because of their postponement function of supporting the power network, a broad proposal is made for linked distributed generators. In addition, many technologies, natural and saving products are included with the interface between the distributed generators and the main grid system. As interference, the utility network is made greater than the grid characteristics by decreasing the lack [61]. However, small turbines work as a part of the relation generator amplitude; as an illustration of distributed generator products, they possibly increase. Tiny, quality turbines are smaller in scale [62]. The inverter is not classically a 50/60 Hz Sine Wave AC when clamped together with the small turbine. Thus, to obtain the essential agreements on the main network as seen in Figure 2, a static energy converter should be interfaced with this topology. The integration of a DC source and the inverter into the low voltage utility network applies to all of the power network. The head elements of this integration method are to transform the non-fixed voltage and frequency delivered by the DC source into a frequency constant indicating the voltage level of the network. This system is linked to the DC-AC transformation network [63]. A three-step inverter and a DC source connected to the main network compose this network integration. The critical load and inverter are secured by means of a DC connector consisting of a condenser for the reduction of the harmonics. natural and saving products are included with the interface between the distributed generators and the main grid system. As interference, the utility network is made greater than the grid characteristics by decreasing the lack [61]. However, small turbines work as a part of the relation generator amplitude; as an illustration of distributed generator products, they possibly increase. Tiny, quality turbines are smaller in scale [62]. The inverter is not classically a 50/60 Hz Sine Wave AC when clamped together with the small turbine. Thus, to obtain the essential agreements on the main network as seen in Figure 2, a static energy converter should be interfaced with this topology. The integration of a DC source and the inverter into the low voltage utility network applies to all of the power network. The head elements of this integration method are to transform the non-fixed voltage and frequency delivered by the DC source into a frequency constant indicating the voltage level of the network. This system is linked to the DC-AC transformation network [63]. A three-step inverter and a DC source connected to the main network compose this network integration. The critical load and inverter are secured by means of a DC connector consisting of a condenser for the reduction of the harmonics. DG is a small part of the built DG power from 25 KW to 300 KW with high rotational speeds, as micro turbines (up to 120,000 rpm). The low-volume and high productivity of these micro turbines is shown in [64]. In order to ensure continuity with the energy grid, this technology must be combined with a static power converter, the direct current source and the interface attached to the micro turbine, which do not output a traditional 50/60Hz sine-wave ac. For interfaces between the micro turbine and the low-voltage distribution system, many power electronic systems are used. Instead of the variable frequency and tensile frequency, as seen in Figure 1, DC sources and the inverter are received at a constant frequency signal on a net voltage basis. This state usually uses the DC-AC conversion method [65].
As the grid fails, the interface structure includes a three-phase inverter attached to the DC source to provide critical loads. Related is the critical load and inverter by an LC filter which consists of an inductance of 1 × 10 −3 mH and a capacitor of 500 ×10 −6 to reduce the ripples; furthermore, the critical load is R = 2 ohm and L = 10 × 10 −2 . In addition, the DC Source is equal to 1 KV.

Proposed Control Method
A standalone or grid-bundled approach is described that begins with the DG. However, the controllers are dynamic [65] and linked with all of the operating conditions. DG is a small part of the built DG power from 25 KW to 300 KW with high rotational speeds, as micro turbines (up to 120,000 rpm). The low-volume and high productivity of these micro turbines is shown in [64]. In order to ensure continuity with the energy grid, this technology must be combined with a static power converter, the direct current source and the interface attached to the micro turbine, which do not output a traditional 50/60 Hz sine-wave ac. For interfaces between the micro turbine and the low-voltage distribution system, many power electronic systems are used. Instead of the variable frequency and tensile frequency, as seen in Figure 1, DC sources and the inverter are received at a constant frequency signal on a net voltage basis. This state usually uses the DC-AC conversion method [65].
As the grid fails, the interface structure includes a three-phase inverter attached to the DC source to provide critical loads. Related is the critical load and inverter by an LC filter which consists of an inductance of 1 × 10 −3 mH and a capacitor of 500 × 10 −6 to reduce the ripples; furthermore, the critical load is R = 2 ohm and L = 10 × 10 −2 . In addition, the DC Source is equal to 1 KV.

Proposed Control Method
A standalone or grid-bundled approach is described that begins with the DG. However, the controllers are dynamic [65] and linked with all of the operating conditions. The technique used for the monitoring organizes the voltage around the terminal and the DG interface frequency in the insulating state. The control system is used not only to control the active power of the DG interface but also to manage the grid's reactive energy supply. The interface network can also be structured at the joint connection point (PCC) or at the unit power factor (UPF). In the park transformation, the structure of the utilized control strategy is coordinated, which requires the immediate step angle of the PCC [66].
In the standalone or grid-connected operation of the control method, three two-position choices are convenient for id * , iq * , and θ. For the standalone condition, the three selectors are switched to position B.
For the grid-tied condition, the id* and θ selectors are turned to position A, while the iq * selector is connected to select the UPF (unified power factor) or the voltage regulation mode. The result of the current iq * is selected based on the desired condition. For the UPF condition, zero is assigned to iq * through the coordinates of its selector switch at position A. For the Standalone condition, in this situation, to obtain the voltage regulation result, the current iq * is specified to the result of the voltage regulation circuit (position B). For the UPF condition [66], zero is specified to id * through the coordinates of its selector switch, as shown in Figure 3.
The technique used for the monitoring organizes the voltage around the terminal and th DG interface frequency in the insulating state. The control system is used not only t control the active power of the DG interface but also to manage the grid's reactive energ supply. The interface network can also be structured at the joint connection point (PCC or at the unit power factor (UPF). In the park transformation, the structure of the utilize control strategy is coordinated, which requires the immediate step angle of the PCC [66 In the standalone or grid-connected operation of the control method, three two position choices are convenient for * , * , and θ. For the standalone condition, the thre selectors are switched to position B.
For the grid-tied condition, the * and θ selectors are turned to position A, while th * selector is connected to select the UPF (unified power factor) or the voltage regulatio mode. The result of the current * is selected based on the desired condition. For the UP condition, zero is assigned to * through the coordinates of its selector switch at positio A. For the Standalone condition, in this situation, to obtain the voltage regulation resul the current * is specified to the result of the voltage regulation circuit (position B). Fo the UPF condition [66], zero is specified to * through the coordinates of its selecto switch, as shown in Figure 3.

The Park Transform Calculations
As shown in Figure 4, describing the issues of the used controller for all condition of implementation, the inverse Park transform IPT and Park Transform PT [66], show through Equations (1) and (2), is taken to obtain the reference currents * , * and * :

The Park Transform Calculations
As shown in Figure 4, describing the issues of the used controller for all conditions of implementation, the inverse Park transform IPT and Park Transform PT [66], shown through Equations (1) and (2), is taken to obtain the reference currents ia * , ib * and ic * :

The Phase Angle Calculation
When the grid is linked, the selectors can be switched when an icon detectio programmer is used and when the angle θ required by the Park transform is believed t be grid-based, depending on the circuit breaker mode that binds the grid to the PCC. Th specifies the prerequisite for the PLL network to be linked. The key issues of this controlle in the Standalone Condition are to coordinate the load voltage at the needed level and t sustain the frequency at its certain value. The DG must supply the load with a speci current, in accordance with the rated voltage shown in Figure 5, in order to achieve certain voltage level [66]. Substituting * = 0 and θ = 2πft into Equation (3) results in th equations shown: * * sin 2П * * sin 2П 2П 3 * * sin 2П 2П 3 (3 The current * is the result from the voltage regulation circuit. For the standalon condition, the selector switches.

The Phase Angle Calculation
When the grid is linked, the selectors can be switched when an icon detection programmer is used and when the angle θ required by the Park transform is believed to be grid-based, depending on the circuit breaker mode that binds the grid to the PCC. This specifies the prerequisite for the PLL network to be linked. The key issues of this controller in the Standalone Condition are to coordinate the load voltage at the needed level and to sustain the frequency at its certain value. The DG must supply the load with a special current, in accordance with the rated voltage shown in Figure 5, in order to achieve a certain voltage level [66]. Substituting id * = 0 and θ = 2πft into Equation (3) results in the equations shown:

The Phase Angle Calculation
When the grid is linked, the selectors can be switched when an icon detectio programmer is used and when the angle θ required by the Park transform is believed t be grid-based, depending on the circuit breaker mode that binds the grid to the PCC. Thi specifies the prerequisite for the PLL network to be linked. The key issues of this controlle in the Standalone Condition are to coordinate the load voltage at the needed level and t sustain the frequency at its certain value. The DG must supply the load with a specia current, in accordance with the rated voltage shown in Figure 5, in order to achieve certain voltage level [66]. Substituting * = 0 and θ = 2πft into Equation (3) results in th equations shown: * * sin 2П * * sin 2П 2П 3 * * sin 2П 2П 3 (3 The current * is the result from the voltage regulation circuit. For the standalon condition, the selector switches. The current −iq * is the result from the voltage regulation circuit. For the standalone condition, the selector switches.

The Reference Calculations At Grid-Tied Conditions
A basic proportional-integral (PI) controller is connected to detect the error between the actual value active power (P-act.) within the range 10-250 KW, and the reference result of the active power (P-ref), which is set at (80 KW). The result from the PI controller is the needed direct current reference value for voltage compensation (id-ref). In order to achieve suitable tracking, the actual value active power to the reference value of the active power must be set by the proportional gain (Kp-d) and integration gain (Ki-d) to reach the minimum error between the input values [66], as shown in Figure 6. Here, suitable tracking is achieved based on the following items: the setting of the proportional gain (Kp-d) at 9 × 10 −12 and the setting of the integration gain (Ki-d) at 9 × 10 −3 .
Sustainability 2021, 13, x FOR PEER REVIEW 8 of

The Reference Calculations
At Grid-Tied Conditions A basic proportional-integral (PI) controller is connected to detect the error betwee the actual value active power (P-act.) within the range 10-250 KW, and the reference resu of the active power (P-ref), which is set at (80KW). The result from the PI controller is th needed direct current reference value for voltage compensation (id-ref). In order t achieve suitable tracking, the actual value active power to the reference value of the activ power must be set by the proportional gain (Kp-d) and integration gain (Ki-d) to reac the minimum error between the input values [66], as shown in Figure 6. Here, suitab tracking is achieved based on the following items: the setting of the proportional gain (Kp d) at 9 × 10 -12 and the setting of the integration gain (Ki-d) at 9 × 10 -3 .

At Standalone Conditions
A basic proportional-integral (PI) controller is connected to detect the error betwee the root mean square value of the voltage per unit within the range 0.1-1 Pu and th needed reference value of the voltage level, which is set at (1Pu) ( * . The result from the PI controller is the needed quadrature current reference result for the voltag compensation (iq-ref. ). In order to achieve the suitable tracking of the actual value of th voltage per unit ( to the reference value of the voltage per unit ( * , the proportion gain (Kp-q) and the integration gain (Ki-q) must be set to reach the minimum erro between the input values [66], as shown in Figure 7. Here, suitable tracking is achieve based on the following items: the setting of the proportional gain (Kp-q) at 725 × 10 −4 , an the setting of the integration gain (Ki-q) at 13.63 × 10 −1 .

Adaptive Proportional Integration using an Artificial Neural Network (ANN)
The way that a human brain designs a preventative model is an artificial neur network (ANN). ANNs are always at the center of profound awareness. Deep neur networks (DNNs), which are capable of handling unlabeled variables, are reliant on inpu symmetries or group variables, and whether they are grouped with marked variables fo practice. The set of input products is distinguished for each neuron. This means th digital objects can be taken using supervised or unmonitored preparation as an indicatio Figure 6. Reference calculations and the control method using PI controllers at grid connected mode.

At Standalone Conditions
A basic proportional-integral (PI) controller is connected to detect the error between the root mean square value of the voltage per unit within the range 0.1-1Pu and the needed reference value of the voltage level, which is set at (1Pu) (V PU * ). The result from the PI controller is the needed quadrature current reference result for the voltage compensation (iq-ref.). In order to achieve the suitable tracking of the actual value of the voltage per unit (V PU) to the reference value of the voltage per unit (V PU * ), the proportional gain (Kp-q) and the integration gain (Ki-q) must be set to reach the minimum error between the input values [66], as shown in Figure 7. Here, suitable tracking is achieved based on the following items: the setting of the proportional gain (Kp-q) at 725 × 10 −4 , and the setting of the integration gain (Ki-q) at 13.63 × 10 −1 .

The Reference Calculations At Grid-Tied Conditions
A basic proportional-integral (PI) controller is connected to detect the error between the actual value active power (P-act.) within the range 10-250 KW, and the reference result of the active power (P-ref), which is set at (80KW). The result from the PI controller is the needed direct current reference value for voltage compensation (id-ref). In order to achieve suitable tracking, the actual value active power to the reference value of the active power must be set by the proportional gain (Kp-d) and integration gain (Ki-d) to reach the minimum error between the input values [66], as shown in Figure 6. Here, suitable tracking is achieved based on the following items: the setting of the proportional gain (Kpd) at 9 × 10 -12 and the setting of the integration gain (Ki-d) at 9 × 10 -3 .

At Standalone Conditions
A basic proportional-integral (PI) controller is connected to detect the error between the root mean square value of the voltage per unit within the range 0.1-1 Pu and the needed reference value of the voltage level, which is set at (1Pu) ( * . The result from the PI controller is the needed quadrature current reference result for the voltage compensation (iq-ref.). In order to achieve the suitable tracking of the actual value of the voltage per unit ( to the reference value of the voltage per unit ( * , the proportional gain (Kp-q) and the integration gain (Ki-q) must be set to reach the minimum error between the input values [66], as shown in Figure 7. Here, suitable tracking is achieved based on the following items: the setting of the proportional gain (Kp-q) at 725 × 10 −4 , and the setting of the integration gain (Ki-q) at 13.63 × 10 −1 .

Adaptive Proportional Integration using an Artificial Neural Network (ANN)
The way that a human brain designs a preventative model is an artificial neural network (ANN). ANNs are always at the center of profound awareness. Deep neural networks (DNNs), which are capable of handling unlabeled variables, are reliant on input symmetries or group variables, and whether they are grouped with marked variables for practice. The set of input products is distinguished for each neuron. This means that digital objects can be taken using supervised or unmonitored preparation as an indication Figure 7. Reference calculations and the control method using PI controllers at standalone mode.

Adaptive Proportional Integration Using an Artificial Neural Network (ANN)
The way that a human brain designs a preventative model is an artificial neural network (ANN). ANNs are always at the center of profound awareness. Deep neural networks (DNNs), which are capable of handling unlabeled variables, are reliant on input symmetries or group variables, and whether they are grouped with marked variables for practice. The set of input products is distinguished for each neuron. This means that digital objects can be taken using supervised or unmonitored preparation as an indication of the clustering of the variables and a value. The network chooses a neuron from the outcome.
There are three layers to the structure of a neural-network algorithm: 1.
The input layer: this enters past variables' values into the next layer. The output layer: this is the model's prediction, in which the predictions made in the hidden layer are composed to obtain the final layer.
A machine learning scheme depending on artificial neural networks for vertical handover has been shown to obtain communication and the optimum-tied call mode [67].
The performance outputs reflect a perceived increase in QoS via voice, as well as variable utilities. Based on physical group optimization [68], a special network identification algorithm is recommended. The findings show that the structure's application decreases the machine complexity and time dramatically. An adaptive factor change algorithm [69] is seen in an artificial neural network, dependent upon the strategy for the creation of the network access. The study of the simulation revealed that the plan allows users to easily reach the final network, and output variance can be effectively ignored. A multi-layered feed forward algorithm of the neural network is used to decide the user device's optimal target network for the transfer of the current calling steps. Figure 8 reflects the structure in neural networks of a suggested transfer algorithm. Four layers included the suggested algorithm. Four input neurons-such as the currency expense, speed, RSSI, data rate, and output layer-are part of the first layer. The two hidden layers consist of numerous nodes which use hyperbolic tangent sigmoid functions. There are three layers to the structure of a neural-network algorithm: 1. The input layer: this enters past variables' values into the next layer. 2. The hidden layer: this is a main issue of a neural network. It has complex function which generate predictors. A group of nodes in the hidden layer mean that th neurons show the math functions which edit the input variables. 3. The output layer: this is the model's prediction, in which the predictions made in th hidden layer are composed to obtain the final layer.
A machine learning scheme depending on artificial neural networks for vertica handover has been shown to obtain communication and the optimum-tied call mode [67 The performance outputs reflect a perceived increase in QoS via voice, as well a variable utilities. Based on physical group optimization [68], a special networ identification algorithm is recommended. The findings show that the structure application decreases the machine complexity and time dramatically. An adaptive facto change algorithm [69] is seen in an artificial neural network, dependent upon the strateg for the creation of the network access. The study of the simulation revealed that the pla allows users to easily reach the final network, and output variance can be effectivel ignored. A multi-layered feed forward algorithm of the neural network is used to decid the user device's optimal target network for the transfer of the current calling steps. Figur 8 reflects the structure in neural networks of a suggested transfer algorithm. Four layer included the suggested algorithm. Four input neurons-such as the currency expense speed, RSSI, data rate, and output layer-are part of the first layer. The two hidden layer consist of numerous nodes which use hyperbolic tangent sigmoid functions.

The Reference Calculations
At Grid-Tied Conditions An Adaptive PI Controller Artificial Neural Network (ANN1) is connected to dete the error between the actual value active power (P-act.) within the range 10-250 KW an the reference value of the active power (P-ref), which is set at 80KW. The result from th Adaptive PI Controller Artificial Neural Network (ANN1) is the needed direct curren reference value for the voltage compensation (id-ref). The structure of the Artificial Neur Network (ANN1) is as shown in Figure 9. The design of the pact control of the ANN1 algorithm is used for more than 1000 dat points (input and output). The training data are generated with help of the PI controlle and stored the data in the workspace. Finally, the observed data are used to provid training in the MATLAB environment. The neural network model is presented in Figur  10. The ANN1 model's best performance value is 9.3647 × 10 −14 , as presented in Figure 1 The ANN1 model gradient (9.6935 × 10 −8 ), Mu 1 × 10 −13 and the validation check ar presented in Figure 12. The trained ANN1 model error value is presented in Figure 1 The regression of the ANN1 model's trained validation values are presented in Figure 1 Finally, the fitness function of the ANN1 model is presented in Figure 15.  The design of the pact control of the ANN1 algorithm is used for more than 1000 data points (input and output). The training data are generated with help of the PI controller and stored the data in the workspace. Finally, the observed data are used to provide training in the MATLAB environment. The neural network model is presented in Figure 10. The ANN1 model's best performance value is 9.3647 × 10 −14 , as presented in Figure 11. The ANN1 model gradient (9.6935 × 10 −8 ), Mu 1 × 10 −13 and the validation check are presented in Figure 12. The trained ANN1 model error value is presented in Figure 13. The regression of the ANN1 model's trained validation values are presented in Figure 14. Finally, the fitness function of the ANN1 model is presented in Figure 15. An Adaptive PI Controller Artificial Neural Network (ANN1) is connected to detect the error between the actual value active power (P-act.) within the range 10-250 KW and the reference value of the active power (P-ref), which is set at 80KW. The result from the Adaptive PI Controller Artificial Neural Network (ANN1) is the needed direct current reference value for the voltage compensation (id-ref). The structure of the Artificial Neural Network (ANN1) is as shown in Figure 9. The design of the pact control of the ANN1 algorithm is used for more than 1000 data points (input and output). The training data are generated with help of the PI controller and stored the data in the workspace. Finally, the observed data are used to provide training in the MATLAB environment. The neural network model is presented in Figure  10. The ANN1 model's best performance value is 9.3647 × 10 −14 , as presented in Figure 11. The ANN1 model gradient (9.6935 × 10 −8 ), Mu 1 × 10 −13 and the validation check are presented in Figure 12. The trained ANN1 model error value is presented in Figure 13. The regression of the ANN1 model's trained validation values are presented in Figure 14. Finally, the fitness function of the ANN1 model is presented in Figure 15.           The design of the control of the ANN2 algorithm is used for more than 2000 data points (input and output). The training data are generated with the help of the PI controller and store the data in the workspace. Finally, the observed data are used to provide the training in MATLAB environment. The neural network model is presented in Figure 17. The ANN2 model's best performance value is 6.278 × 10 −14 , as presented in Figure 18. the fitness function of the ANN2 model is presented in Figure 19.  Figure  21. Finally, the trained (ANN2) model error value is presented in Figure 22.  The design of the control of the ANN2 algorithm is used for more than 2000 da points (input and output). The training data are generated with the help of the controller and store the data in the workspace. Finally, the observed data are used provide the training in MATLAB environment. The neural network model is presented Figure 17. The ANN2 model's best performance value is 6.278 × 10 −14 , as presented Figure 18. the fitness function of the ANN2 model is presented in Figure 19.  The design of the V PU control of the ANN2 algorithm is used for more than 2000 data points (input and output). The training data are generated with the help of the PI controller and store the data in the workspace. Finally, the observed data are used to provide the training in MATLAB environment. The neural network model is presented in Figure 17. The ANN2 model's best performance value is 6.278 × 10 −14 , as presented in Figure 18. the fitness function of the ANN2 model is presented in Figure 19. The regression of the (ANN2) model's trained validation values are presented in Figure 20. The ANN2 model gradient (9.8462 × 10 −8 ), Mu 1 × 10 −13 and validation check are presented in Figure 21. Finally, the trained (ANN2) model error value is presented in Figure 22.

At Grid-Connected Mode
In this case, we start from 0 s to 0.4 s and from 0.75 s to 1 s using the C.B condition, which is the certain periodic time that the critical load is supplied by the main grid; during this condition, the PLL is actively connected using the voltage grid, sets the frequency, and is clamped with the grid frequency at 50 HZ as frequency stability; the actual value is tracked to the reference value of the active power at 80 KW, and the reference of the quadrature current is equal to zero; otherwise, the reference of the direct current is a certain value generated from the active power tracking circuit and the voltage load is equal to 230 V per phase-a. In addition, the active value of the direct and quadrature current is tracked to its reference value.

At Standalone Mode
In this case we start from 0.4 s to 0.75 s using the C.B condition, which is a limited periodic time in which the critical load is fed through the DC source, which is converted to AC through a three phase inverter and connected with the LC Filter to avoid the ripples that are generated from the inverter operation; during this condition, the switch will cross over the PLL and connect to a certain circuit included in the special equation (wt = 2πft, f = 50 HZ) to achieve the frequency stability, the same as in the grid-connected mode; the active value is tracked to the reference value of the voltage per unit at 1.0pu. and the reference of the direct current is equal zero; otherwise, the reference of quadrature current is a certain value generated from the voltage per unit tracking circuit, and the voltage load is equal to 230 V per phase-a. In addition, the active value of the direct and quadrature current is tracked to its reference value.

At Transferring from One Condition to Another
This statement analysis is critical to supervise the dynamic implementations of the recommended control structure within the transfer from one state to another. The voltage regulation circuit is applicable, and P * is obtained at 80 kW. Both the base and switching critical loads are clamped with the PCC. The CB is opened at t = 0.4 s and then reconnected at t = 0.75 s to disconnect the utility from the PCC within this periodic time. The dynamic characteristics of the used integrated network occur within the transference between the grid-tied state and the standalone state. The voltage per unit is closely organized at 1.0pu.

At Transferring Conditions from Grid-Connected to Standalone
In this case, especially at a certain time t = 0.4 s, the circuit breaker is switched off to switch from the grid-connected to the islanded mode; then, some issues are monitored and noted within this limited and very short period as per the following issues. Firstly, the load voltage per phase-a is decreased by a small value-50 V approximately-and secondly, the voltage per unit is reduced from 0.7pu. to 0.6pu. Thirdly, the load current per phase-a is decreased to 0.04 A, and fourthly, the direct current is equal to zero and the quadrature current is increased gradually to reach 0.2 A. Fifthly, the phase angel wt. is increased within 120 to 220, and the actual value of the active power is decreased to zero.

At Transferring Conditions from Standalone to Grid-Connected
In this case, especially at a certain time t = 0.75 s, the circuit breaker is switched on to switch from the islanded to the grid-connected mode; then, some issues are monitored and noted within this limited and very short period as per the following issues. Firstly, the load voltage per phase-a is damped down instantaneously as a quick transient and re-increased by a large value reach to 320 V; secondly, the voltage per unit is re-increased from 0.6pu. to 0.78pu. and re-decreased again to 0.7pu.
Thirdly, the load current per phase-a is quickly damped down as a transient and re increased by more than the previous value to reach 0.06 A. Fourthly, the direct current is over the transient by a large value, reaching 0.3 A, and the quadrature current is decreased to a zero value; fifth, the phase angel wt. is reduced to a zero value and the actual value of the active power overshoots from zero to 480 KW, and starts to decrease gradually to 80 KW as the reference value, as shown in Figures 23-32, and the total harmonic distortion in several operation modes are shown in Figures 33 and 34. Sustainability 2021, 13, x FOR PEER REVIEW 18 of Thirdly, the load current per phase-a is quickly damped down as a transient and increased by more than the previous value to reach 0.06A. Fourthly, the direct current over the transient by a large value, reaching 0.3A, and the quadrature current is decrease to a zero value; fifth, the phase angel wt. is reduced to a zero value and the actual valu of the active power overshoots from zero to 480KW, and starts to decrease gradually to KW as the reference value, as shown in Figures 23-32, and the total harmonic distortio in several operation modes are shown in Figures 33 and 34.    Thirdly, the load current per phase-a is quickly damped down as a transient and increased by more than the previous value to reach 0.06A. Fourthly, the direct current over the transient by a large value, reaching 0.3A, and the quadrature current is decreas to a zero value; fifth, the phase angel wt. is reduced to a zero value and the actual val of the active power overshoots from zero to 480KW, and starts to decrease gradually to KW as the reference value, as shown in Figures 23-32, and the total harmonic distorti in several operation modes are shown in Figures 33 and 34.    Thirdly, the load current per phase-a is quickly damped down as a transient and increased by more than the previous value to reach 0.06A. Fourthly, the direct curren over the transient by a large value, reaching 0.3A, and the quadrature current is decreas to a zero value; fifth, the phase angel wt. is reduced to a zero value and the actual va of the active power overshoots from zero to 480KW, and starts to decrease gradually to KW as the reference value, as shown in Figures 23-32, and the total harmonic distort in several operation modes are shown in Figures 33 and 34.

The Simulation Results Using an Adaptive PI Controller Artificial Neural Network (ANN)
A small voltage dip and rise occurred during the switching instance of the CB. The reference current, iq-ref, is created from the voltage control structure. Within the periodic time of grid-tied operation, iq-ref is critical to feed the reactive power to the main grid and handle the voltage at unity. Furthermore, iq-ref is raised to feed the overall load current (active and reactive elements) and then to generate a unity terminal voltage level when the grid is in failure. The reactive and active power items provided from the DG interface are schemed. The active power item is raised during standalone condition is start happened. An issue was expected because only 10 KW was provided to the load from the DG interface in the grid-tied state, and the rest was provided from the utility. When in standalone mode, the reactive power fed through the DG interface is decreased through an ignored result because the grid-tied controller was steadily feeding the load reactive power to control the voltage at unity. This simple variation is the same as an output of the correction that the voltage controller receives similar to the power loss because of the connection between the distribution bus and the PCC. As such, the vanishing of the grid-tied state is an issue for this small reactive power variation between the grid-tied and standalone states. The phase of the voltage at the PCC, which is familiar with its phase angle within the switching instant currents' IL are clear and pure waveforms. These outputs detect a high-dynamic feedback and the critical characteristics of the recommended unified control structure for the following of the load current and voltage control within the two stats of implementation and within the transfer between them.

At Transferring Conditions from Grid-Connected to Standalone
In this case, especially at a certain time, t = 0.4 s, the circuit breaker is switched off to switch from the grid-connected to islanded mode; then, there are some issues which are monitored and noted within this limited and very short period, as per the following issues. Firstly, the load voltage per phase-a is decreased by a small value, less than 50 V, and secondly, the voltage per unit is reduced from 0.72pu. to 0.65pu.
Thirdly, the load current per phase-a is decreased to 0.028 A, and fourthly, the direct current is approximately equal to zero (especially over-damped to zero and slightly raised to 0.02 A) and the quadrature current is increased from zero to 0.1 A. Fifthly, the phase angle wt. is increased within 120 to 220, and the actual value of the active power is decreased to 20 KW as a quick transient, and then re-increased by a small value and fixed at 40 KW.

At Transferring Conditions from Standalone to Grid-Connected
In this case, especially at certain time, t = 0.75 s, the circuit breaker is switched on to switch from the islanded to grid-connected mode; then, there are some issues which are monitored and noted within this limited and very short period, as per the following. Firstly, the load voltage per phase-a is increased by small value and reached 320 V. Secondly, the voltage per unit is re-increased from 0.65pu. to 0.72pu. Thirdly, the load current per phase-a is increased to 0.03 A, and fourthly, the direct current is over-transient by a certain value, reaches 0.07 A as a very quick response, and is re-reduced gradually to 0.045 A, reaching a stable value at 0.05 A; the quadrature current is decreased to a zero value. Fifth, the phase angel wt. is reduced to a zero value and the actual value of the active power is raised up from 40 KW to 90 KW as a quick transient and decreased to 80 KW as a reference value, as shown in Figures 35-44; the total harmonic distortions in several operation modes are shown in Figures 45 and 46.

General Comments about the Achieved Results
As shown in Section 4, which presented the achieved results based on basic PI controllers and Artificial Neural Networks, after accurate study, the proposed control model achieved voltage, frequency and power stability in grid-connected mode, islanded mode and transferring mode. On the other side, the stability results using adaptive PI controller Artificial Neural were better than the stability results achieved using Basic PI controllers, in addition, the Phase Locked Loop achieved frequency stability in the two methods.

Variations of the Control Parameters
The proposed control strategy will work on the system under study for power and frequency stability under different values of inputs. However, if major modifications are made to the system under study, the proposed control model may need some modifications to its parameter settings. This is expected because the PI and neural network structure design are mainly based on the current system under study.

Implementation Applied to Complex Problems
The control design and the algorithms for the adaptive PI controller Artificial Neural Networks which were used in this paper are a major control strategy that can be applied in large scale and complex problems, but in this case, the structure of the Artificial Neural Network and its design and parameters must be changed according to its new scale and the new problem, as mentioned in the previous comment. The proposed problem in this paper is practical, as there are different cases in real life that need the proposed model and control strategy to obtain voltage and frequency stability during the transfer from grid-connected mode to islanded mode and otherwise, in order to retain the efficiency of the sensitive and critical loads which can be effected negatively in its life time, and its efficiency due to the multi transients across it during the transferring modes.

Conclusions
In this paper, a unified control strategy was proposed for three-phase inverter interfacing DG to operate in both islanded and grid-tied modes. This strategy offers instantaneous transfer between the different operation conditions while maintaining the voltage and frequency references. In addition, the adaptive proportional integration (PI) controller based on an Artificial Neural Network (ANN) was utilized for the online tracking of the active power and voltage, where the reference direct and quadrature current estimation is based on the ANN instead of classical PI controllers. The proposed control strategy was compared with the conventional PI controller when applied to same test system, and better results were achieved. It was noted that the task of the proposed method was achieved successfully, and that the gain voltage and frequency stability in the standalone mode were maintained. In addition, the gain power and frequency stability were achieved in the grid-connected mode by using the phase-locked loop and power tracking within its conditions. Several simulation states were executed to adjust the dynamic implementation of the proposed control structure for the different operation conditions of the current-controlled structure using the MATLAB software package. The results achieved with the proposed adaptive PI-ANN based controller showed that it can form an efficient solution for modern power system control problems.