A Real-Time Energy Management System Design for a Developed PV-Based Distributed Generator Considering the Grid Code Requirements in Turkey

: Each country must determine the Grid Code conditions and apply these criteria to integrate distributed generation (DG) systems into the existing electricity grid and to ensure a stable power system. Thus, experimental studies are required to provide an effective, national, and speciﬁc Grid Code. In this study, the Turkish Grid Code’s electrical criteria were examined, and the application of these criteria was carried out on a developed PV-based DG. A real-time energy management system (RTEMS) was proposed in the study. Electrical parameters on the developed DG were monitored in real-time by considering IEEE 1547, IEEE 929–2000, and Turkey’s electrical criteria. A practical grid code study was ﬁrstly investigated in detail about the Turkish Grid Code by a developed real-time monitoring-control and protection system. The proposed RTEMS method in the study is implemented as an inverter-resident system; thus, it provides advantages over many energy management systems embedded in the inverter. The degradation in power quality and non-detection zone (NDZ) problems encountered in active and passive island mode detection methods developed embedded in the inverter are eliminated in the proposed method. With the RTEMS method, where under and over-voltage, under and over voltage frequency, and unintentional island mode events can be detected in real-time, both the existing grid-code requirements are met, and the existing power quality and NDZ problem is eliminated with the recommended inverter-independent RTEMS method. switching on signal is transmitted to the breakers in the DG system. The grid frequency, phase angle, and active and reactive power also are determined by using LabVIEW data acquisition and power system toolboxes. The voltage signal is a sine wave, and it is converted to a square signal to calculate the grid frequency.


Introduction
Today, it is necessary to meet certain electrical connection conditions determined by international standards in general, and, in particular, by the countries for the distributed generators (DGs) to be connected to the current electricity grid. These connection conditions are connected to the current electricity grid. These connection conditions determined by each country itself are generally called the "Grid Code." The combination of the new generation photovoltaic-based and classical grid connection for the distributed generators is an essential case that should be conducted in a way that can guarantee the reliability of the system. Many countries have established some electrical criteria, taking into consideration the requirements and infrastructure of the national grid called "Grid Code" within this scope [1,2]. While a DG system provides the conditions for connecting to the grid, the necessary monitoring and protection equipment must be present at the grid side [3,4]. For this reason, the DG system must be installed in such a way that it can take the protection There are many studies in the literature on the connection of DGs to the grid studies, some general approaches related to connection criteria were presented, o ficiency of the system was investigated with the help of some simulation program study, electrical connections have put forward the DG system in Turkey that is for connection to the network in real-time and, following the country's Grid C been proposed a system protection and monitoring system. By investigating the ibility of the results obtained from the developed system with the Grid Code, a that can be used in practice for the establishment of new DG systems has been p There are some studies about micro-grids in the last decade regarding Grid an important project in U.S. micro-grids [7], all of the generators fed the utility There are three operation modes in this project for decreasing the field engineeri Three independent micro-grids were researched for grid-tied and islanding cond another micro-grid study [8]. A real-time controller was used, which controlled t with a LabVIEW control system. The performance of a micro-grid was researc the study also was investigated supplying sustainable power to the loads. The D grids are used for residential loads, and there are some applications, researching cro-grids [9][10][11].
An extensive micro-grid study was also examined in Britain. This project w Both companies and researchers work together on developing micro-grids, and th promoted by successful micro-grid progress [12]. An institutional micro-grid sys constituted in Australia. A radial type micro-grid system was comprised of dis generators. This study researches a DC distribution system at the low-voltage le Islanding, which is defined as the loss of the main grid, causes the voltage and frequency of the grid to suddenly go out of the nominal operating conditions. This will damage the DG system components, render the system inoperable (blackout), and endanger the life safety of the operator if an operator is working in the DG system. For this reason, when an undesired islanding event of DG systems occurs, the DG system must disconnect from the mains as soon as determined by the standards [1][2][3].
There are many studies in the literature on the connection of DGs to the grid. In these studies, some general approaches related to connection criteria were presented, or the efficiency of the system was investigated with the help of some simulation programs. In this study, electrical connections have put forward the DG system in Turkey that is required for connection to the network in real-time and, following the country's Grid Code, has been proposed a system protection and monitoring system. By investigating the compatibility of the results obtained from the developed system with the Grid Code, a solution that can be used in practice for the establishment of new DG systems has been proposed.
There are some studies about micro-grids in the last decade regarding Grid Code. In an important project in U.S. micro-grids [7], all of the generators fed the utility together. There are three operation modes in this project for decreasing the field engineering work. Three independent micro-grids were researched for grid-tied and islanding conditions in another micro-grid study [8]. A real-time controller was used, which controlled the relays with a LabVIEW control system. The performance of a micro-grid was researched, and the study also was investigated supplying sustainable power to the loads. The DC micro-grids are used for residential loads, and there are some applications, researching DC micro-grids [9][10][11].
An extensive micro-grid study was also examined in Britain. This project was met. Both companies and researchers work together on developing micro-grids, and they were promoted by successful micro-grid progress [12]. An institutional micro-grid system was constituted in Australia. A radial type micro-grid system was comprised of distributed generators. This study researches a DC distribution system at the low-voltage level with Energies 2021, 14, 6684 3 of 21 residential loads for a campus network [13]. Different application research also supports this result [14].
When the PV systems are connected to the grid from a low voltage level, the desired electrical connection criteria related to the Grid Code are generally provided by monitoring and protection circuits designed to be embedded in inverters. Especially in the European Union (EU) countries, there are over millions of roof-type PV-based DGs [15]. These DGs' meeting the Grid Code criteria means ensuring the reliability and stability of the grid. Similarly, the number of rooftop PV systems in the Netherlands and California state of America has reached numbers expressed in millions [16,17]. Failure to properly connect such a large number of DGs to the grid may cause significant problems in terms of the operation and reliability of the existing electricity grid. For this reason, the electrical monitoring and protection conditions specified in Grid Code must be fulfilled in the best way. The use of renewable energy sources is increasing rapidly in Turkey; studies are being made on different subjects, including DG systems [18][19][20][21][22][23].

Conventional Islanding Detection Methods
The Grid Code determines the lower and upper threshold values in frequency and voltage and the limits of the frequency-voltage region in which DGs can operate nominally. When the islanding event occurs, especially in active and reactive power equality situations, passive IDMs cannot detect the islanding event. This undetectable region is called the non-detection zone (NDZ). The minimum or zero NDZ is very important for testing the reliability of the proposed IDM method.
RLC circuit commonly used performance assessment of IDMs. To calculate the Q f , local load represented by parallel RLC. The w 0 is the angular resonant frequency of the load.
Then the RLC load operates at the resonance frequency. The Q f of the RLC is calculated Equation (1). The Q f is given by Equation (2). Q f of the parallel RLC circuit is frequency independent.
NDZ is also an essential criterion for IDMs. This area is not detected for islanding conditions. The NDZ is generally characterized by the power mismatch space. NDZ is seen, especially in passive methods.
where V is system voltage; f is system frequency V max and V min are over/under voltage threshold limits; f max and f min are over/under frequency threshold limits for circuit breakers (CBs) in DGs. Q f is the quality factor; ∆P and ∆Q represent the power mismatches.
Islanding detection methods (IDMs) can be classified into remote, local, and intelligent methods [2,3]. The conventional IDMs are defined as passive, active, and hybrid methods. Passive methods are operated by measuring the point of common coupling voltage and current in general. Besides, the reliability of the passive techniques is not sufficient for DGs because there is a large non-detection zone (NDZ) in these methods [4][5][6]. Active methods usually check the changes in the injected signal to the grid, and these methods also have NDZ. On the other hand, intelligent methods have no NDZ, and they do not change the power system quality [7]. The conventional IDMs have some problems related to islanding detection [8]. The system stability and the power quality are significant concerns for conventional detection methods, NDZ is a significant issue for an islanding detection method [9], Additional devices, such as transmitter and receiver sensors, increase the system costs [10]. Multiple inverter operations are essential for fault detection methods [11].
As shown in Table 1, modified, passive signal processing techniques are increase the islanding detection speed and reduce the NDZ. However, these methods also have implementation problems and performance limitations. The STFT method has a fixed window size, and individual frequency components are not localized in the window. WT methods are sensitive to noisy signals. Intelligent modified, passive methods have a high computational time because of training and testing procedures. These methods are less favorable for real-time applications. Table 1. Performance comparison of existing islanding detection methods [12].  The degradation in power quality and non-detection zone (NDZ) problems encountered in active and passive island mode detection methods developed embedded in the inverter are eliminated in the proposed method.

•
With the RTEMS method, where under and over-voltage, under and over voltage frequency, and unintentional island mode events can be detected in real-time, both the existing grid-code requirements are met, and the existing power quality and NDZ problem is eliminated with the recommended inverter-independent RTEMS method.
"The Guidelines for Generating Unlicensed Electricity in Turkish Electricity Market" was coming into force in 2011 by the Turkish Government. However, still, a national Grid Code is not in force in Turkey. In this study, the legal and the technical infrastructure of the electrical connection of the Photovoltaic-based distributed generator systems to the conventional distributed system from a low voltage level in Turkey was researched. The existing problems and the possible effects of the grid were also investigated. The status of the PV-based DG power plants in Turkey and the PV contribution of Turkey in EU countries were presented in the study. Besides, the paper also includes an application study realized to define the criteria for the Turkish Grid Code, and the obtained results from this study were presented. As a study case, a prototype grid-connected PV system was constituted in the laboratory, and a real-time LabVIEW-based monitoring and control system was realized within the scope of the research. Under-frequency and over-frequency protection and under-voltage and over-voltage protection were carried out to investigate a proper micro-grid management technique. This structure achieved a consistent operation of the PV system with the existing electrical grid of Turkey. Besides, the study firstly researched the threshold values of the PV grid connection to specify the criteria of the Turkish Grid Code. The proposed micro-grid management system and the obtained results from this Energies 2021, 14, 6684 5 of 21 study will make a significant contribution to defining the desired electrical grid criteria and, also, to establish the required Turkish Grid Code.

PV-Based DG Systems in EU and Turkey
The electrical generating power from renewables was not widespread in the EU until quite recently, just like in Turkey. The EU is dependent on outside financial sources to supply its energy demand, and fossil sources will waste shortly. The CO 2 emission is another factor in the EU, and it is considerably high in the world after the US and China. Consequently, the EU has extra motivation to supply its required energy from renewables because of these factors. In October 2014, the Member States of the EU reached an agreement about a new climate package for 2030. EU government leaders have committed themselves to the following goals: • Decreasing to at least 40% the greenhouse-gas emissions.

•
Enhancing to at least 32% the share of renewable energy.

•
Decreasing by at least 32.5% the total energy use in the EU.
The objective to reduce the EU's greenhouse gas emissions by at least 40% in 2030 is the basis for the EU's contribution to the Paris Agreement's goals to limit the global temperature [13].
Increasing energy efficiency and decreasing the consumption of energy at the same rate of effectiveness until 2030 in the EU are the other targets [13][14][15][16][17][18][19][20][21][22][23][24][25]. The EU countries have been developed, some promotions to reach the desired target of the renewables. The total installed power capacity of the world by the 2019 year-end is approximately 120 GWp and China has the most significant PV installed power capacity in the world [26][27][28]. Also, the total installed power of the EU has deployed 137.2 GW cumulatively till 2020 [29]. Germany has average solar radiation at the rate of 900 kWh/m 2 -year. Although Germany has lower solar radiation compared to Turkey, Germany is placed on the top in the world about generating electricity from PV-based DG systems. The installed power of nearly 1.4 million PV plants reached 55.3 GWp in Germany by the 2021 June-end [29,30].
The integration of PV plants must not cause danger in the normal operation of the grid. As a result, electrical specifications should provide and facilitate the suitable interconnection of the grid. The DG plants should support the steady-state operation and contribute to the stability of the power grid in cases of fault at the connection point, according to the German Grid Code [31]. The PV plants lower than 100 kWp in Germany usually are connected to the grid from the low voltage (LV) level [32]. Table 2 defines the basic requirements that the grid-tied generators should meet to be integrated into the grid.
The combination of the new generation photovoltaic-based and classical grid connection for the distributed generators is an essential case that should be conducted in a way that can guarantee the reliability of the system. PV-based DG systems must meet several technical requirements to make a successful grid connection, and the PV integration must not interrupt the regular operation of the grid. The PV-based DG power plants should adapt the defined electrical rules to provide the steady-state operation and the stability of the grid in cases of any fault at the connection point. The power quality, islanding detection, and protection, under/over-voltage protection, under/over-frequency protection, and electromagnetic interference are also critical issues to adapt PV-based DG systems into the grid.

DG Systems in Turkey
Turkish installed power is dependent on fossil fuels make up 80% of these sources. The most attractive indicator of this situation is the amount of natural gas, which is used in generating electrical energy. The total share of the natural gas used for generating electricity is nearly 20% in the world, but this rate is approximately 30% in Turkey [33].
On the other hand, Turkey has a significant amount of renewable energy potential, especially solar and wind power. The total share of the renewables in the total generated power of Turkey is targeted to be at least 30% in 2023 by considering the potential of renewables [33,34]. The EU target is to generate 32% of electrical power from renewables in 2030. It is possible to provide a significant part of the electrical energy demand of Turkey for the renewable energy-based DG systems, by promoting renewable energy-based DG plants and investing a stable grid infrastructure by the Turkish government.
Turkey has a 2640 h insolation duration, and it is the second country in EU countries with the capability of generating electricity from solar energy.
The annual average insolation of Turkey is 1311 kWh/m 2 -year shown in Table 3, and the insolation determined is 3.6 kWh/m 2 in a day. The sun duration is approximately 7.2 h in Turkey, and the annual sun period is 110 days in total [35]. The area of 4.600 km 2 is suitable for generating electricity from solar energy in Turkey. The high solar energy potential of Turkey also allows leading in Middle Eastern and African solar power markets.

A Comparison between PV Plants in Turkey and EU Countries
Although its high solar energy potential compared with the EU, Turkey falls far more behind the EU countries.
Turkey promotes the generating of electricity from solar energy by legislating licensed and unlicensed power generation laws. The financial promotions to the solar energy and energy regulations are performed by the Republic of Turkey Energy Market Regulatory Authority (EPDK). Renewable energy-based DG system installations until 2015 have been promoted to generate electricity for ten years by decreasing 85% of the renting and appurtenances costs with this law [36].
The penetration of PV plants in Turkey with the LV level is scarcely any by comparison with EU countries [27,31,33,35]. Nearly all of the unlicensed PV-based DG plants have a request to connect the PV plants from medium voltage levels [37].
The LV penetration of PV installations is restricted with 11 kWp except for the individual connections by the current renewable energy law. The many EU countries allow the generation of PV installations up to 100 kWp.
The PV installations connected to the grid with LV level have the same application, project, and acceptance process with up to the 1 MWp PV plants. The project cost of small PV installations is considerably high compared to the facility cost of large-scale PV plants.
Some of the Turkish electricity companies request digital interface protection relays in contrast to inverter protections that are acceptable with international standards under 11 kWp to provide personal security. The digital interface protection relays have high costs compared with the inverter and PV modules in small power installations. The application, project, and acceptance process takes a long time, and these procedures are required to purchase goods and engineering services. The confirmation of static calculations also makes it difficult for the PV plant owners.

Laws, Rules, and Grid Codes for DGs in Turkey
"The Guidelines for Generating Unlicenced Electricity in Turkish Electricity Market" [38] was coming into force in 2011 by the Turkish Government. The latest form of the rules was reformed in 2013 [38]. This law has paved the way for the integration of DGs into the electrical distribution system from low voltage levels. The PV installations are defined as licensed and unlicensed power generation plants with this renewable energy law and the power capacity of the PV plants is identified as below: • Unlicensed Power Generation Plants: <1 MWp. The PV power plants are aimed to constitute to supply their required energy and to give excess energy to the grid. Natural and legal all Turkish citizens can take advantage of the promotion prices indicated in Table 4 over ten years in January 2021. Providing that selling the excess generated energy to the electricity distribution companies is supported by the current renewable energy law [38][39][40]. The electricity distribution companies, which have a retail sales license, are obligated to purchase excess energy provided to the electricity distribution companies within this scope. The purchasing electrical power of the electricity distribution companies within this clause is accepted to support promotional prices.
The regulations related to solar energy in renewable energy law can be summarized: • There is no obligation to obtain a license and to establish a new company. • Naturally and legally, all Turkish citizens can appeal to establish a renewable energybased power plant. • Naturally and legally, all Turkish citizens can sell the excess energy to the electricity distribution companies.

•
The installed power is allowed a maximum of up to 1 MWp.

•
The PV plants benefit from purchasing guarantees from the electricity distribution companies. The penetration of PV plants in Turkey with the LV level is scarcely any, although the advantages of the renewable energy law. The reason is that all of the unlicensed PV installations between 1 kWp and 1MWp have the same application, project, and acceptance process. Thus, nearly all of the unlicensed PV-based DG plants have a request to connect the PV plants from medium voltage levels. As a result, the current renewable energy laws and guidelines should be revised according to technological developments to achieve a successful grid connection.

Unlicensed Electrical Energy Generation in Turkey
The small-scale power plants are connected to the electrical system from the distribution network regardless of the source defined as DG plants. The DG plants that have smaller than 1 MWp installed power are usually constituted as unlicensed electricity power plants in Turkey because of the unlicensed installation benefits of renewable energy-based power plants in the current law.
The first renewable energy laws in Turkey are defined as "The Law Related to Use of Renewable Energy Sources to Generate Electrical Energy" [39] and "The Guidelines for Generating Unlicenced Electricity in Turkish Electricity Market" [38,40].
The DG systems are designed to decrease the transmission and distribution losses by generating at the nearest point of the load. The DG systems are also designed to increase renewable energy-based power generation, as is known. Renewable energy laws include the concept of increasing renewable energy-based power generation. However, these laws are opposite to decreasing the transmission and distribution losses by generating at the nearest point of the load. The unlicensed power plants and consumers are in different locations in the electrical system, so it is not suitable for the DG concept. Besides, the current renewable energy law promotes renewable energy-based power generation.

Grid Connection Rules of Unlicensed PV Power Plants in Turkey
Renewable energy law has some restrictions to prevent misuse of the capacity rate of renewable energy generation. Table 5 shows one of these restrictions to specify the capacity of power plants connected with the LV level to the distribution generators belong to the electricity companies [41]. The main purpose of this restriction is to take advantage of the power plant owners without causing any adverse effects on power quality and the continuous power supplying of other consumers. The connections realized with special distribution transformers are accepted as medium voltage level connections by the electricity distribution companies. A PV power plant, which has 1000 kWp installed power, can be connected to the grid from medium voltage level with plant owners' 1250 kVA special distribution transformer. The other connection rules for unlicensed PV power plants are explained below [33,34,38]: The total capacity of the power generation plants connected to the distribution system with the LV level must not exceed 30% of the connected distribution transformer power.
The stiffness ratio is defined as the rate of the short circuit current of the distribution system/the nominal current of the distribution network. It must be over 30 for the co-generation plants that the installed power is over 1 MWp, and it must be over 70 for other power generation plants [41,42]. The distribution company can offer a new connection point when the stiffness ratio is not in acceptable values.  (4) The power generation plant is connected to the distribution system from the LV level and single-phase when the installed power of the PV plant is under five kWp. (5) The power generation plant is connected to the distribution network from the LV level and has three phases when the installed power of the PV plant is over five kWp. Thus, the phase current is under 16 A (11 kWp) [41]. (6) The power generation plant is connected to the distribution system with the LV/HV level and three phases when the phase current is over 16 A. The distribution company defines the voltage level decision. Table 6 summarizes this concept.
The unlicensed power generation plants must be designed, constituted, tested, and operated according to some standards [42,43]: • The power generation plant is connected to the distribution system with a single-phase must take into consideration the TS EN 50438 standard.

•
The power generation plant is connected to the distribution system with three-phase, and the phase current is under 16 A must takes into consideration the TS EN 50438 standard.

•
The power generation plant is connected to the distribution system with the LV level, and the phase current is over16 A must takes into consideration the TSE K 191 standard.

•
The power generation plant is connected to the distribution system with an HV level, and the phase current is over16 A must takes into consideration the TSE K 192 standard. The stiffness ratio is related to the short circuit power of the connection point that is determined by the connection characteristics and line of the distribution system [44]. It is not possible to determine the stiffness ratio in Turkey because of the lack of having no distribution network database and having no geographical information system. For this reason, this criterion is not implemented correctly in Turkey.
The grid connection rules in Turkey are targeted to associate with international standards as far as possible. Thus, it is aimed to accomplish the objective quickly by providing the latest global developments.
The micro, small, and medium-scaled PV power plants must be operated confidentially and compatible with the distribution system, so the plants must meet some requirements explained below:

•
The grid-connected PV plant must not affect the continuously supplying the electricity to the consumers and not cause power quality problems.

•
The PV power plant must be disconnected from the grid in abnormal electrical conditions, just like being out of the defined threshold values of under/over frequency and under/over voltage and in an islanding condition.
The voltage dips and the voltage sags are relevant parameters when making an investigation on the power quality effects of a PV power generation plant. The threshold value of the voltage sags is defined as a 2% change of the nominal voltage value in Germany [43]. The flicker is another considerable parameter with the evaluation of the power quality of a PV power system. The EN 50160 standard allows ±10% change of the nominal voltage value and ±1% change of the nominal frequency value, and this rule is applied in many EU countries [44][45][46]. These parameters have not been defined for PV power plants in Turkey, yet.

Grid Code and Current Status of Turkey
The unlicensed PV generation still needs an application confirmation. The application confirmation of the unlicensed PV power generation plants is performed by the Turkish Electricity Distribution Company (TEDAS) in Turkey. The project cost of the small PV installations is considerably high compared to the facility cost of large-scale PV plants. The same interface protection equipment is requested from all PV power generation plants between 11 kWp and 1 MWp. For this reason, the integration of PV power generation plants in Turkey with the LV level is scarcely any by comparison with EU countries. Thus, nearly all of the unlicensed PV-based DG plants have a request to connect the PV plants from medium voltage levels.
The primary purpose of an electrical protection system is that the restriction of the probable damages of the over-voltages and short circuit currents in a short circuit or an insolation fault condition. These drawbacks occur in grid equipment, just like a generator, transformer, cable, line, etc. The protection systems designed for this purpose provide the stabilization and sustainability of the grid by isolating the fault as soon as possible.
The application of the protection systems differs according to the selection of a generation plant or a consumer plant. The protection system of the PV power generation plants is similar to the conventional protection systems and goes into divisions as interface protection and generator protection.
The interface protection of a PV power generation plant is defined as the connection equipment of the plant, and it must have some functions indicated below [45,46]:

•
The protection of abnormal electrical conditions, in particular, against the islanding condition.

•
The interface protection must provide the requirements of power quality parameters of the grid, just like flicker, harmonic distortion, etc.

•
The synchronization, communication, monitoring, voltage and frequency control, grounding, and other electrical requirements.

•
The fault ride-through capability, active and reactive power control and dynamic grid support have also been researched recently [47,48]. These functions are additional issues for the electrical protection of the PV power generation plants that are connected at the transmission level.
The PV power generation plants, which are connected at the distribution level, do not require these protection functions at this stage of the grid integration. Defining a particular connection infrastructure is quite difficult because of the different expectations from the PV power generation plants that are connected from the transmission and distribution level. The evaluation of each connection-level requirement in its concept is a proper solution for selecting adequate protection.
The interface protection provides the reliable and parallel operation of the PV power generation plant with the grid. The interface protection prevents the reverse supplying condition and the disconnection of the PV power generation plant that cause the breaking of the reliability of the distribution system. Interface protection is obligated in small and medium-scaled PV power generation plants. However, it is allowed to be used in the inverter or the generator in micro-scaled PV power generation plants [49].
The selection of the internal or external interface protection is under the authority of electricity distribution companies. The internal interface protection provided by the inverters is sufficient under 11 kWp power for the connections from the LV level in Turkey. However, today many distribution companies require external protection between 11 kWp-1 MWp.

Experimental Case-Study Considering the Turkish Grid Code
The grid integration of PV power generation plants from the LV level is realized with a new energy management system shown in Figure 2. This structure was implemented in Turkey within the scope of developing the "Turkish Grid Code." Under/over-frequency protection, under/over-voltage protection, and a remote islanding detection system was performed to investigate a proper energy management system. This structure achieved a consistent operation of the PV system with the existing electrical grid of Turkey.  The developed real-time management system (RTEMS) with LabVIEW was designed and implemented to provide all requirements of the related international standards by considering the fundamental requirements of the "Grid Code" in Turkey. The goal of the study is to develop a new grid-interactive system that has a smart micro-grid management system in real-time. Consequently, the proposed system was implemented to define the requirements for the grid integration of the PV power generation plants with consideration to build a Grid Code.
IEEE 929-2000 shown in Table 7 is the most important international norm for consideration of the grid connection of DGs [50][51][52][53][54][55][56]. The fundamental requirements are defined in IEEE 929-2000. Moreover, Figure 2 shows the proposed islanding detection algorithm. Developed RTEMS consists of a 6 × 200 Wp PV array, a 1.3 kWp grid-connected inverter, LabVIEW data acquisition card, measurement circuits including LEM voltage and current sensors, and developed real-time software. In the PV system, the voltage and load-inverter output-grid currents acquired from the inverter output are converted into analog signals ranging from 0-10 V by the sensors. Then, these signals are evaluated by the developed RTEMS software, and the switching on signal is transmitted to the breakers in the DG system. The grid frequency, phase angle, and active and reactive power also are determined by using LabVIEW data acquisition and power system toolboxes. The voltage signal is a sine wave, and it is converted to a square signal to calculate the grid frequency. Figure 3 shows the developed RTEMS in the laboratory.

R PEER REVIEW 13 of 21
inverter output-grid currents acquired from the inverter output are converted into analog signals ranging from 0-10 V by the sensors. Then, these signals are evaluated by the developed RTEMS software, and the switching on signal is transmitted to the breakers in the DG system. The grid frequency, phase angle, and active and reactive power also are determined by using LabVIEW data acquisition and power system toolboxes. The voltage signal is a sine wave, and it is converted to a square signal to calculate the grid frequency. Figure 3 shows the developed RTEMS in the laboratory. The developed micro-grid has been evaluated under different grid conditions in the laboratory. The PV-based DG system was connected to the existing grid, and voltage, frequency, and current values were monitored. The micro-grid was connected to the grid by controlling the circuit breaker (CB). In case of any voltage or frequency unbalance that  The developed micro-grid has been evaluated under different grid conditions in the laboratory. The PV-based DG system was connected to the existing grid, and voltage, frequency, and current values were monitored. The micro-grid was connected to the grid by controlling the circuit breaker (CB). In case of any voltage or frequency unbalance that may occur in the grid, the PV-based DG system is automatically disconnected from the grid thanks to the developed DG protection system (DGPS). In the developed system, a sample application has been realized by considering the Turkish Grid Code threshold values. The real-time software interface of the protection and monitoring system applied with LabVIEW is shown in Figure 4a-c. The developed micro-grid was connected to the grid via a single-phase inverter, and the voltage and frequency values of the grid were monitored instantly. The CB is in a closed position, and the micro-grid has been operated depending on the grid electrical operating conditions by considering the Turkish Grid Code.  The under/over voltage protection and the under/over-frequency protection functions are the fundamental protection for the PV power generation plants and obligated all over the world [46]. Some distribution companies in the world find this protection constituted in inverter as internal protection sufficient for micro-scaled PV power generation plants operating under 50 kWp power, but it does not actualize in Turkey. The inverters The under/over voltage protection and the under/over-frequency protection functions are the fundamental protection for the PV power generation plants and obligated all over the world [46]. Some distribution companies in the world find this protection constituted in inverter as internal protection sufficient for micro-scaled PV power generation plants operating under 50 kWp power, but it does not actualize in Turkey. The inverters usually have over-current protection relays with a subjective concept, but the over-current protection is implemented with separate fuses and circuit breakers. The residual current device is requested to provide the security of life and property in the applications in Turkey.

Over Voltage Protection (OVP) in a Proposed DG Scenario
Overvoltages are voltage increases seen in half the period of the voltage as a result of atmospheric and switching conditions. Such disturbing effects usually occur as a result of the actuation and deletion of the capacitors in the grid or the consumer.
The threshold values used in the experimental study are defined in Table 8. DGPS generates a signal for opening CB were connected to the grid. During the operation of the micro-grid system, the magnitude of the voltage for the grid and the operation situation of the breaker are presented in Table 9. The condition zero for the breaker shows that the breaker is deactivated. In the case the status of the breaker is the logical one, it shows that the breaker is via the developed DGPS.  Table 9. Grid and circuit breaker status in OVP condition. In this study, where the maximum voltage fault percentage was resolute as ±10%, Figure 5 shows the part where the CB is operated as a result of ±10% deviation of the grid voltage from the 311 V voltage value measured at that moment. The DGPS software interface of these parts is also given in Figure 5. In this study, where the maximum voltage fault percentage was resolute as ±10%, Figure 5 shows the part where the CB is operated as a result of ±10% deviation of the grid voltage from the 311 V voltage value measured at that moment. The DGPS software interface of these parts is also given in Figure 5.

Under Voltage Protection (UVP) in Proposed DG Scenario
Short-term voltage dips pose significant problems for many small consumers and large, powerful industrial consumers. Such faults are usually caused by short circuit events at a point electrically remote from consumers. This disruptive effect causes sensitive consumers to be out of business. Figure 6a shows the part where the CB is activated as a result of a 10% decrease in the grid voltage from the 311 V voltage value, which is the current reference voltage. The DGPS software interface of these parts is also given in Figure 6b. When the status of the CB is zero, the CB is passive, and when is 1, the CB is ctivated.

Under Voltage Protection (UVP) in Proposed DG Scenario
Short-term voltage dips pose significant problems for many small consumers and large, powerful industrial consumers. Such faults are usually caused by short circuit events at a point electrically remote from consumers. This disruptive effect causes sensitive consumers to be out of business. Figure 6a shows the part where the CB is activated as a result of a 10% decrease in the grid voltage from the 311 V voltage value, which is the current reference voltage. The DGPS software interface of these parts is also given in Figure 6b. When the status of the CB is zero, the CB is passive, and when is 1, the CB is activated.
(a) (b) Figure 6. (a) UVP condition in DGPS; (b) status of grid voltage and CB.

Over Frequency Protection (OFP) in Proposed DG Scenario
In this study, in the case of over frequency, the breaker was activated an, whose maximum frequency error percentage was determined as ±10%, Figure 7a shows the part where the breaker is activated as a result of a 20% increase from the 50 Hz frequency value, which is the reference value of the grid frequency. LabVIEW screenshots of these parts are given in Figure 7b. Figure 7c shows the change of grid voltage, and Figure 7d shows the situation where the frequency value changes instantaneously from 50 Hz to 51 Hz. In

Over Frequency Protection (OFP) in Proposed DG Scenario
In this study, in the case of over frequency, the breaker was activated an, whose maximum frequency error percentage was determined as ±10%, Figure 7a shows the part where the breaker is activated as a result of a 20% increase from the 50 Hz frequency value, which is the reference value of the grid frequency. LabVIEW screenshots of these parts are given in Figure 7b. Figure 7c shows the change of grid voltage, and Figure 7d shows the situation where the frequency value changes instantaneously from 50 Hz to 51 Hz. In this case, the breaker is turned on by DGPS, and the PV system is disconnected from the grid. During the operation of the system, the amplitude, frequency value of the grid voltage, and the activation status of the breaker are evaluated. When the breaker status is Logic 0, the breaker is not active. When the logic is 1, the breaker is activated intervened.
(a) (b) Figure 6. (a) UVP condition in DGPS; (b) status of grid voltage and CB.

Over Frequency Protection (OFP) in Proposed DG Scenario
In this study, in the case of over frequency, the breaker was activated an, whose maximum frequency error percentage was determined as ±10%, Figure 7a shows the part where the breaker is activated as a result of a 20% increase from the 50 Hz frequency value, which is the reference value of the grid frequency. LabVIEW screenshots of these parts are given in Figure 7b. Figure 7c shows the change of grid voltage, and Figure 7d shows the situation where the frequency value changes instantaneously from 50 Hz to 51 Hz. In this case, the breaker is turned on by DGPS, and the PV system is disconnected from the grid. During the operation of the system, the amplitude, frequency value of the grid voltage, and the activation status of the breaker are evaluated. When the breaker status is Logic 0, the breaker is not active. When the logic is 1, the breaker is activated intervened.

Under Frequency Protection (UFP) in Proposed DG Scenario
LabVIEW reports belonging to this case are given in Figure 8a. Figure 8b shows the change of grid voltage, and Figure 8c shows the situation where the frequency value changes instantaneously from 50 Hz to 49 Hz. In this case, the breaker is turned on by DGPS, and the PV system is disconnected from the grid. During the operation of the system, the magnitude, frequency value of the grid voltage, and the activation situations of the breaker are evaluated.
When the CB situation is Logic 0, the CB is passive, and when is Logic 1, CB is activated [56].
The proposed RTEMS method in the study is implemented as an inverter-resident system; thus, it provides advantages over many energy management systems embedded in the inverter. Figure 9 shows assessing NDZs for proposed and conventional methods.

Under Frequency Protection (UFP) in Proposed DG Scenario
LabVIEW reports belonging to this case are given in Figure 8a. Figure 8b shows the change of grid voltage, and Figure 8c shows the situation where the frequency value changes instantaneously from 50 Hz to 49 Hz. In this case, the breaker is turned on by DGPS, and the PV system is disconnected from the grid. During the operation of the system, the magnitude, frequency value of the grid voltage, and the activation situations of the breaker are evaluated.
When the CB situation is Logic 0, the CB is passive, and when is Logic 1, CB is activated [56].
The proposed RTEMS method in the study is implemented as an inverter-resident system; thus, it provides advantages over many energy management systems embedded in the inverter. Figure 9 shows assessing NDZs for proposed and conventional methods. tem, the magnitude, frequency value of the grid voltage, and the activation situations of the breaker are evaluated.
When the CB situation is Logic 0, the CB is passive, and when is Logic 1, CB is activated [56].
The proposed RTEMS method in the study is implemented as an inverter-resident system; thus, it provides advantages over many energy management systems embedded in the inverter. Figure 9 shows assessing NDZs for proposed and conventional methods.

Conclusions
"The Guidelines for Generating Unlicensed Electricity in Turkish Electricity Market" was coming into force in 2011 by the Turkish Government. However, still, a national Grid Code is not in force in Turkey. In this study, the legal and the technical infrastructure of the electrical connection of the PV-based DG systems to the conventional distributed sys-

Conclusions
"The Guidelines for Generating Unlicensed Electricity in Turkish Electricity Market"

Conclusions
"The Guidelines for Generating Unlicensed Electricity in Turkish Electricity Market" was coming into force in 2011 by the Turkish Government. However, still, a national Grid Code is not in force in Turkey. In this study, the legal and the technical infrastructure of the electrical connection of the PV-based DG systems to the conventional distributed system from a low voltage level in Turkey was researched. The existing problems and the possible effects of the grid were also investigated. The status of the PV-based DG power plants in Turkey and the PV contribution of Turkey in EU countries are presented in the study.
Besides, the paper also includes an application study realized to define the criteria for the Turkish Grid Code, and the obtained results from this study were presented. A prototype grid-connected PV system was constituted in the laboratory. Under-frequency, over-frequency, under-voltage, and over-voltage protection statuses were examined with the help of the LABVIEW program for the monitoring and control of the observed system for obtaining a proper micro-grid management system. This structure achieved a consistent operation of the PV system with the existing electrical grid of Turkey. Besides, the study firstly researched the threshold values of the PV grid connection to specify the criteria of the Turkish Grid Code.
In this study, the Turkish Grid Code's electrical criteria were examined, and the application of these criteria was carried out on a developed PV-based DG. A real-time energy management system (RTEMS) was proposed in the study. Electrical parameters on the developed DG were monitored in real-time by considering IEEE 1547, IEEE 929-2000, and Turkey's electrical criteria.
A practical grid code study was firstly investigated in detail about the Turkish Grid Code by a developed real-time monitoring-control and protection system. The proposed RTEMS method in the study is implemented as an inverter-resident system; thus, it provides advantages over many energy management systems embedded in the inverter.
The UVP/OVP and UFP/OFP methods have a large NDZ that covers all of selected areas, and islanding detection is not possible in this area. Furthermore, the PJD method has a smaller NDZ according to UVP/OVP and UFP/OFP methods. Whereas the RTEMS method has the smallest NDZ comparing with other IDMs, and NDZ is shown as a point. The RTEMS method is more reliable for islanding detection comparing to passive methods. Therefore, Figure 9 shows that none of the inverter resident methods present a certain solution to detect islanding.
The degradation in power quality and non-detection zone (NDZ) problems encountered in active and passive island mode detection methods developed embedded in the inverter are eliminated in the proposed method. With the RTEMS method, where under and over-voltage, under and over voltage frequency, and unintentional island mode events can be detected in real-time, both the existing grid-code requirements are met, and the existing power quality and NDZ problem is eliminated with the recommended inverter-independent RTEMS method.
Author Contributions: G.B. and D.E. were involved in the development of the concept, software analysis, and hardware implementation, H.H.A. and P.S. supervised the project and validated the outcomes and numerical scale of proof, editing, and final formulation of the work for ensuring the quality of the presentation. H.H.A. and P.S. were involved in making the article for its final presentation and error-free technical aspects. D.E. and G.B. were involved to provide the graphical solution for the better presentation of the obtained results. All authors were involved equally in the contribution to present this research activity in its current full article for the readers with correction, edition, and proof version for its qual. All authors have read and agreed to the published version of the manuscript.