Reconﬁgurable Power Quality Analyzer Applied to Hardware-in-Loop Test Bench

: Integration of renewable energy resources and conventional grids leads to an increase in power quality issues. These power quality issues require different standards to be followed for accurate measurement and monitoring of various parameters of the power system. Conventional power quality analyzers (PQAs) are programmed to a particular standard and cannot be reconﬁgured by the end user. Therefore, conventional PQAs cannot meet the challenges of a rapidly changing grid. In this regard, a Compact RIO-based (CRIO-based) PQA was proposed, that can be easily reprogrammed and cope with the challenges faced by conventional PQAs. The salient features of the proposed PQA are a high processing speed, interactive interface, and high-quality data-storage capacity. Moreover, unlike conventional PQAs, the proposed PQA can be monitored remotely via the internet. In this research, a hardware-in-loop (HIL) simulation is used for performing the power-quality assessment in a systematic manner. Power quality indices such as apparent power, power factor, harmonics, frequency disturbance, inrush current, voltage sag and voltage swell are considered for validating the performance of the proposed PQA against the Fluke’s PQA 43-B.


Introduction
The increase in the power demand during the last two decades has been significant. The major use of renewable energy sources for reducing CO 2 emissions and global warming requires the use of electronic devices, i.e., power converters, capacitor switches, and transformer energizing. This resulted in an obstructive effect in power systems [1]. The increase in the number of distributed energy sources and the system complexity resulted in unpredictable behavior in power systems that require efficient and effective power quality (PQ) measurements and monitoring. International standards provide an explanation of the method of accumulating and representing approximate data and identifying different indices for distinguishing PQ disturbances. The International Electrotechnical Commission (IEC) 61000-4-30 standard defines the methods for measuring and interpreting the results of PQ parameters in a 50/60-Hz system, which include active power (P), reactive power (Q), frequency, voltage sags and swells, voltage disturbance, supply voltage unbalance, and voltage and current harmonics and subharmonics [2].
An offline simulation of the power converters and power system applications in a software environment such as MATLAB/Simulink, PLECS, PSim, Dig SILENT, and Multisim was widely used to verify the design considerations and behaviors of circuits [3]. Although an offline simulation is a low-cost method and requires little setup, it is unacceptable in power electronics and power system applications as they suffer from high jitter, and their the article [28] shows a low-cost power quality analyzer based on frequency analysis which measures the AC waveform to detect power quality issues. In [29] a power quality analyzer was designed with an event logging capability, synchronized phasor measurement and an inter-area oscillation identifier. All aforementioned conventional PQAs are fixed in terms of measurement features and standards. Therefore, conventional PQAs cannot be reprogrammed and hence cannot meet the current demands of the rapidly changing grid.
In this paper, HIL simulation is used for PQ assessment in a systematic manner. It should be noted that the proposed CRIO-based PQ analyzer can be used independently and as well as in an HIL environment. As a base model, a three-phase, three-level neutral point clamped (NPC) converter is used for the real-time simulation using the HIL environment. The load voltage generated from the NPC is supplied for operating different loads using a power amplifier. Finally, the load voltage and load current are given as an input to the CRIO modules for obtaining the results of various PQ indices such as power, power factor, harmonics, frequency disturbance, inrush current, and voltage sag and swell. Compared with the aforementioned conventional PQAs, the proposed PQA offers the following benefits:

•
Can be installed at any location to measure the quality impacts, and the results can be monitored via the internet; • Provides robust measurement and algorithms implemented on hardware with reconfigurable firmware to meet the challenges of a rapidly changing grid; • Provides a flexible, interactive interface and high-quality data storage capacity from the grid; • Data are monitored on the low-power side to ensure safety for system users; • Complies with the international power-quality standards of the Institute of Electrical and Electronics Engineers and the International Electrotechnical Committee.
In summary, the HIL test bench is used to implement a three-phase NPC inverter. The output of the inverter is amplified to 220 V using a power amplifier and then connected to the load for various considered scenarios. The PQ analysis is performed using NI CRIO and a Fluke-based PQA. The study is organized as follows: Section 2 presents an explanation of the various PQ indices that determine the state of the power system. Section 3 presents a brief description of the RT HIL platform available at our university. Section 4 presents the RT HIL implementation scheme used in this research, a brief explanation of the CRIO hardware with its capabilities, and a discussion of the model implemented in the PHIL architecture. Section 5 presents an analysis and the experimental results obtained for the various considered scenarios. Finally, the conclusions of this research are presented in Section 6.

Power Quality Indices
The PQ indices (PQIs), which are continuously checked and monitored during the operation of the power system, are referred to for determining the state of the power system. In this paper, the PQIs listed by the IEEE standard 1459 [30] are adopted, and mathematical modelling is described for them.

Harmonics Distortion
The harmonics comprise multiples of the fundamental reference signal and can be determined using the Fourier transform and a superposition of the voltage and current waveforms. The fundamental harmonics can only be found for an ideal electrical system, i.e., of 50 Hz or 60 Hz. Harmonics are present owing to the use of non-linear loads, which generate them. Non-linear loads include electronic power converters, arc furnaces, high pressure discharge lamps, arc welders, power inverters, television power supplies, light emitting diodes, mobile and laptop chargers, and similar electronic devices and equipment [31]. The current and voltage can be expressed in a Fourier series as follows: i(t) = a n sin wt + b n cos wt (1) where the root mean square (rms) of the current can be found by: The rms of the subharmonic current can be calculated as: The THD of current can then be found by: Similarly, voltage (V(t)) can also be expressed in Fourier series as follows: V(t) = a n sin wt + b n cos wt (7) a n = 1 Similarly, rms of voltage can be expressed as: The rms of the subharmonic voltage can be calculated as: The THD of the Voltage can be find by:

Power and Power Factor
The measurement of power includes active power (P), reactive power (Q) and apparent power (S). P = V 1 I 1 cos φ 1

Inrush Current
The starting current of an induction motor is quite large due to the fact that slip (S) is unity and rotor resistance (R) is very low. The inrush current can be calculated as: (18) where S start = HP rated × code letter factor, V t is the terminal voltage of an I M and β is the ratio between I start and I nominal .

Voltage Sag and Swell
Whenever load is increased suddenly in a power system a voltage sag is observed at the receiving end, due to the voltage drop in the generator, the transformer and line resistance for short term and long term are as follows: where Voltage swell is observed in the power system due to a sudden drop of a huge load or due to excesses of the capacitive load at the receiving end.
where 0.1 ≤ α ≤ 0.9 and T ≤ t 2 − t 1 ≤ 9T Figure 1 presents the diagram of a typical RT-HIL platform, which consists of a server (master-control unit) and is connected to communicate with the other panels, i.e., development panel, deployment panel, phasor measurement units, and power amplifier. The PXI with a high throughput is physically connected with the controller through a high-speed digital input, digital output cards that transfer data at a rate of 100 MHz, and analogue output cards with a data transfer rate of 1 mega samples/s, which are called FlexRIOs. The controller used is an FPGA-based NI CRIO 9035 that provides both hardware and software flexibility in configuring it as per the requirements of the application. (master-control unit) and is connected to communicate with the other panels, i.e., development panel, deployment panel, phasor measurement units, and power amplifier. The PXI with a high throughput is physically connected with the controller through a highspeed digital input, digital output cards that transfer data at a rate of 100 MHz, and analogue output cards with a data transfer rate of 1 mega samples/s, which are called FlexRIOs. The controller used is an FPGA-based NI CRIO 9035 that provides both hardware and software flexibility in configuring it as per the requirements of the application.

Real-Time Implementation in Power Hardware-in-Loop
The HIL architecture facilitates users to build a model in MATLAB/PLECS/PSIM/Multisim and burn it into PXI through eHS solver provided by OPAL RT, which is an FPGA-based floating point solver that facilitates the users to burn an electrical circuit on FPGA automatically with a step size of nanoseconds and without having to code in VHDL or calculate system equations. The overall scheme of the RT system discussed above is shown in Figure 2. Hardware, i.e., CRIO used for PQ will be discussed in the upcoming section.

Real-Time Implementation in Power Hardware-in-Loop
The HIL architecture facilitates users to build a model in MATLAB/PLECS/PSIM/Multisim and burn it into PXI through eHS solver provided by OPAL RT, which is an FPGA-based floating point solver that facilitates the users to burn an electrical circuit on FPGA automatically with a step size of nanoseconds and without having to code in VHDL or calculate system equations. The overall scheme of the RT system discussed above is shown in Figure 2. Hardware, i.e., CRIO used for PQ will be discussed in the upcoming section. opment panel, deployment panel, phasor measurement units, and power amplifier. The PXI with a high throughput is physically connected with the controller through a highspeed digital input, digital output cards that transfer data at a rate of 100 MHz, and analogue output cards with a data transfer rate of 1 mega samples/s, which are called FlexRIOs. The controller used is an FPGA-based NI CRIO 9035 that provides both hardware and software flexibility in configuring it as per the requirements of the application.

Real-Time Implementation in Power Hardware-in-Loop
The HIL architecture facilitates users to build a model in MATLAB/PLECS/PSIM/Multisim and burn it into PXI through eHS solver provided by OPAL RT, which is an FPGA-based floating point solver that facilitates the users to burn an electrical circuit on FPGA automatically with a step size of nanoseconds and without having to code in VHDL or calculate system equations. The overall scheme of the RT system discussed above is shown in Figure 2. Hardware, i.e., CRIO used for PQ will be discussed in the upcoming section.

Compact RIO Hardware Description
Compact RIO combines the RT operating system with an embedded floating-point processor, a remarkable FPGA performance, and hot-swappable analogue and digital input/output modules, that provide quality and hardware flexibility. Each module in CRIO is directly connected with the FPGA, thus realizing minimum jitter and high-speed input/output signal processing [32]. The FPGA is physically linked to the RT processor via the PCI bus, as shown in Figure 3, which presents the internal architecture of the CRIO with an open retrieve to basic hardware resources. The FPGA and RT processor are programmed in LabVIEW, which is a graphical-based programming language platform. LabVIEW has an integrated data fetching mechanism for circulating data from the FPGA to the input/output modules and from the FPGA to the RT processor for the real-time analysis, data logging, post processing, and communication with a host computer. CRIO provides a compact solution, small size, wide operating temperature of −40 • C to +70 • C, and a low operating power consumption.
processor, a remarkable FPGA performance, and hot-swappable analogue and digital input/output modules, that provide quality and hardware flexibility. Each module in CRIO is directly connected with the FPGA, thus realizing minimum jitter and high-speed input/output signal processing [32]. The FPGA is physically linked to the RT processor via the PCI bus, as shown in Figure 3, which presents the internal architecture of the CRIO with an open retrieve to basic hardware resources. The FPGA and RT processor are programmed in LabVIEW, which is a graphical-based programming language platform. Lab-VIEW has an integrated data fetching mechanism for circulating data from the FPGA to the input/output modules and from the FPGA to the RT processor for the real-time analysis, data logging, post processing, and communication with a host computer. CRIO provides a compact solution, small size, wide operating temperature of −40 °C to +70 °C, and a low operating power consumption.

CRIO-Based PQ Analysis
The FGPA and RT in NI CRIO 9035 was programmed for PQ analysis using NI Lab-VIEW, and effective communication was developed between them for data sharing. The RT system containing pools of different Vis, reads the data from the FPGA VI using FIFOs for the THD analysis of the voltage and current, active power, reactive power, frequency, energy, voltage sag, voltage swell, and current measurement, as shown in Figure 4. Considering the IEC standard 61000-4-7: 2002 and EN50160, harmonic and inter-harmonic LabVIEW VI was developed, and for aggregated frequency values, IEC 61000-4-30: 2008 was adopted, which specified that the time duration considered for the voltage quality parameters (harmonics, inter-harmonics, and unbalance) must be 12 cycles for a 60 Hz system or a 10-cycle time interval for a 50 Hz system and is implemented using the zerocrossing method [33][34][35]. For the voltage and current measurement, 24-bit CRIO modules NI 9244 with the capability of measuring 400 V rms L-N and 800 V rms and NI 9247 with the capability of measuring 50 A rms were used to acquire data at 50,000 samples/s/channel. The data are then filtered and resampled for conversion into a fixed number of samples/cycle for the power calculations.

CRIO-Based PQ Analysis
The FGPA and RT in NI CRIO 9035 was programmed for PQ analysis using NI LabVIEW, and effective communication was developed between them for data sharing. The RT system containing pools of different Vis, reads the data from the FPGA VI using FIFOs for the THD analysis of the voltage and current, active power, reactive power, frequency, energy, voltage sag, voltage swell, and current measurement, as shown in Figure 4. Considering the IEC standard 61000-4-7: 2002 and EN50160, harmonic and inter-harmonic LabVIEW VI was developed, and for aggregated frequency values, IEC 61000-4-30: 2008 was adopted, which specified that the time duration considered for the voltage quality parameters (harmonics, inter-harmonics, and unbalance) must be 12 cycles for a 60 Hz system or a 10-cycle time interval for a 50 Hz system and is implemented using the zero-crossing method [33][34][35]. For the voltage and current measurement, 24-bit CRIO modules NI 9244 with the capability of measuring 400 V rms L-N and 800 V rms and NI 9247 with the capability of measuring 50 A rms were used to acquire data at 50,000 samples/s/channel. The data are then filtered and resampled for conversion into a fixed number of samples/cycle for the power calculations.

Model Loaded in PXI
As a base model, a three-phase, three-level NPC converter was used for a real-tim simulation developed in MATLAB Simulink, as shown in Figure 5. This model was loade into the OPAL-RT eHS-64 solver at a step size of 200 ns. The sinusoidal pulse width mod ulation (SPWM)-based PWM control for the NPC model was developed in LabVIEW FPGA and deployed in CRIO. The digital input/output module NI 9401 was used to co trol the switches of the NPC for the three-phase output voltage and current. After th model was loaded in the PXI, control was applied through CRIO, and a three-phase vol

Model Loaded in PXI
As a base model, a three-phase, three-level NPC converter was used for a real-time simulation developed in MATLAB Simulink, as shown in Figure 5. This model was loaded into the OPAL-RT eHS-64 solver at a step size of 200 ns. The sinusoidal pulse width modulation (SPWM)-based PWM control for the NPC model was developed in LabVIEW FPGA and deployed in CRIO. The digital input/output module NI 9401 was used to control the switches of the NPC for the three-phase output voltage and current. After the model was loaded in the PXI, control was applied through CRIO, and a three-phase voltage was observed from different analogue output pins of the data acquisition (DAQ) card that is directly connected with the PXI. The DAQ can generate a maximum of ±10 V depending on the input and the load cannot be operated under ±10 V. From one of the analogue outputs of the DAQ single-phase, four quadrant amplifiers were fed, which increased the voltage to 220 V for different scenarios as discussed in the results section.

Model Loaded in PXI
As a base model, a three-phase, three-level NPC converter was used for a real-time simulation developed in MATLAB Simulink, as shown in Figure 5. This model was loaded into the OPAL-RT eHS-64 solver at a step size of 200 ns. The sinusoidal pulse width modulation (SPWM)-based PWM control for the NPC model was developed in LabVIEW FPGA and deployed in CRIO. The digital input/output module NI 9401 was used to control the switches of the NPC for the three-phase output voltage and current. After the model was loaded in the PXI, control was applied through CRIO, and a three-phase voltage was observed from different analogue output pins of the data acquisition (DAQ) card that is directly connected with the PXI. The DAQ can generate a maximum of ±10 V depending on the input and the load cannot be operated under ±10 V. From one of the analogue outputs of the DAQ single-phase, four quadrant amplifiers were fed, which increased the voltage to 220 V for different scenarios as discussed in the results section.

Experimental Results
In order to compare the performance of the CRIO-based PQ analyzer and traditional Fluke-based PQ analyzer, three different scenarios were considered. The analysis is further discussed in the following case studies.

Analysis of Experimental Setup for First-Case Scenario
In this case, the results were obtained and analyzed with the RLC load in the HIL environment using the CRIO and the Fluke PQ analyzer. The RLC load with a 100 W incandescent bulb, 50 W fluorescent lamp, and a pump of 0.437 kW 0.5 HP used in this case study as comprise, capacitive, and inductive loads, respectively. The output of the DAQ ±10 V was increased to 220 V using a four-quadrant amplifier, and the load was connected at the output of the amplifier. The output voltage and total load current was presented in Figures 6-9. The voltage THD and its spectra were measured as shown in Figures 10 and 11 using CRIO and the Fluke-based PQ analyzer, respectively. Similarly, the current THD and its spectra are shown in Figures 12 and 13 using CRIO and the Fluke-based PQ analyzer, respectively. The current spectra show that the third and fifth harmonics are present in the system. Similarly, other parameters such as active power (P), reactive power (Q), apparent power (S), displacement power factor, and power factor are also measured through both the PQ analyzers as shown in Figure 14. The measurements are further compared for both the PQ analyzers, as shown in Table 1.                . Output voltage THD and its spectra obtained using Fluke PQ analyzer.

Figure 12.
Output current THD and its spectra obtained using CRIO PQ analyzer. Figure 12. Output current THD and its spectra obtained using CRIO PQ analyzer. Output current THD and its spectra obtained using CRIO PQ analyzer. Figure 13. Output current THD and its spectra using Fluke PQ analyzer. Figure 13. Output current THD and its spectra using Fluke PQ analyzer.
Energies 2021, 14, 5134 12 of 18 (a) (b) Figure 14. (a) Active, reactive, and apparent power, power factor and displacement power factor using CRIO PQ analyzer; (b) active, reactive, and apparent power, power factor and displacement power factor using Fluke PQ analyzer.

Analysis of Experimental Setup for Second-Case Scenario
For the inrush current measurement and analysis inductive load considered, i.e., two water pumps of the same power rating, as discussed earlier in the first-case scenario. Initially both the pumps were in the off condition as can be observed before 7.5 ms, when the current is zero. As the pumps are powered up, the inrush current is observed to increase from 7.5 ms to 20 ms with an amplitude of 9 A for the first three cycles, and this decays gradually after each proceeding cycle, and it takes a total of the first seven cycles to come into the steady state condition, which is almost 20 ms.
For the inrush current measurement, the Fluke was set to indicate a 5-A step for each box. It can be observed in Figure 15 that the results obtained are the same as those observed in the case of the CRIO. However, there is a slight difference in the peak value of the current. The Fluke shows a peak of 8.5 A in Figure 16, whereas the results obtained from CRIO show a peak of almost 9 A for the first three cycles. The comparison of the obtained results is shown in the Table 2.

Analysis of Experimental Setup for Second-Case Scenario
For the inrush current measurement and analysis inductive load considered, i.e., two water pumps of the same power rating, as discussed earlier in the first-case scenario. Initially both the pumps were in the off condition as can be observed before 7.5 ms, when the current is zero. As the pumps are powered up, the inrush current is observed to increase from 7.5 ms to 20 ms with an amplitude of 9 A for the first three cycles, and this decays gradually after each proceeding cycle, and it takes a total of the first seven cycles to come into the steady state condition, which is almost 20 ms.
For the inrush current measurement, the Fluke was set to indicate a 5-A step for each box. It can be observed in Figure 15 that the results obtained are the same as those observed in the case of the CRIO. However, there is a slight difference in the peak value of the current. The Fluke shows a peak of 8.5 A in Figure 16, whereas the results obtained from CRIO show a peak of almost 9 A for the first three cycles. The comparison of the obtained results is shown in the Table 2.   Figure 17 depicts the real-time monitoring of a hydro power generator using NI CRIO. The purpose of using this hardware, particularly for the analysis of the voltage sag and swell, is the availability of suitable loads for creating sags and swells for a fixed given excitation. So, in this regard, a nominal voltage of 12 Volts AC is generated via manual excitation of the hydro power generator. The results of the voltage sag and swell are obtained for 4 min by operating the CRIO PQ analyzer along with the Fluke PQ analyzer. Initially, the system is operating at no load with its nominal voltage output of approximately 12 V for the first half minute, as shown in Figures 18 and 19. Then, in the next 1 min, resistive and inductive load is applied to the generator in such a manner that the voltage drops below 10.8 V for observing the voltage sag. Again, for the next 1 min, the load is removed from the system and it allows its nominal output. Now, for analyzing the voltage swell, the capacitive load is connected in the system, and resultant increased voltage is observed beyond 13.2 V for another 1 min. Finally, the system is returned to its normal state by removing the load in the last half minute. The current variations in response to various load variations are shown in Figures 20 and 21 using the CRIO and Fluke PQA, respectively.

Analysis of Experimental Setup for Third-Case Scenario
In addition, the CRIO PQ analyzer provides a flexible, user-friendly interface and is also capable of real-time frequency measurement, as shown in Figure 22 with respect to   Figure 17 depicts the real-time monitoring of a hydro power generator using NI CRIO. The purpose of using this hardware, particularly for the analysis of the voltage sag and swell, is the availability of suitable loads for creating sags and swells for a fixed given excitation. So, in this regard, a nominal voltage of 12 Volts AC is generated via manual excitation of the hydro power generator. The results of the voltage sag and swell are obtained for 4 min by operating the CRIO PQ analyzer along with the Fluke PQ analyzer. Initially, the system is operating at no load with its nominal voltage output of approximately 12 V for the first half minute, as shown in Figures 18 and 19. Then, in the next 1 min, resistive and inductive load is applied to the generator in such a manner that the voltage drops below 10.8 V for observing the voltage sag. Again, for the next 1 min, the load is removed from the system and it allows its nominal output. Now, for analyzing the voltage swell, the capacitive load is connected in the system, and resultant increased voltage is observed beyond 13.2 V for another 1 min. Finally, the system is returned to its normal state by removing the load in the last half minute. The current variations in response to various load variations are shown in Figures 20 and 21 using the CRIO and Fluke PQA, respectively.

Analysis of Experimental Setup for Third-Case Scenario
In addition, the CRIO PQ analyzer provides a flexible, user-friendly interface and is also capable of real-time frequency measurement, as shown in Figure 22 with respect to   Figure 17 depicts the real-time monitoring of a hydro power generator using NI CRIO. The purpose of using this hardware, particularly for the analysis of the voltage sag and swell, is the availability of suitable loads for creating sags and swells for a fixed given excitation. So, in this regard, a nominal voltage of 12 Volts AC is generated via manual excitation of the hydro power generator. The results of the voltage sag and swell are obtained for 4 min by operating the CRIO PQ analyzer along with the Fluke PQ analyzer. the loads connected and removed at different time intervals, as discussed earlier. Moreover, the phasor or vector diagram in the case of different loads can also be obtained using the proposed PQA as shown in Figure 23a-c for resistive, inductive, and capacitive loads, respectively, for resistive load voltage and current in phase. However, for the inductive and capacitive load the phasor diagrams are 90 degrees out of phase. Thus, comparing the CRIO PQ analyzer with the Fluke PQ analyzer in terms of voltage sags and swells, frequency measurement, and phasor diagram, the CRIO PQ analyzer is found to be a more compact and reconfigurable solution. Cloud computing-based smart applications are growing progressively to deal with different power quality applications [36,37]. In contrast to the conventional PQAs, the CRIO-based PQA can be monitored remotely via the internet.  Initially, the system is operating at no load with its nominal voltage output of approximately 12 V for the first half minute, as shown in Figures 18 and 19. Then, in the next 1 min, resistive and inductive load is applied to the generator in such a manner that the voltage drops below 10.8 V for observing the voltage sag. Again, for the next 1 min, the load is removed from the system and it allows its nominal output. Now, for analyzing the voltage swell, the capacitive load is connected in the system, and resultant increased voltage is observed beyond 13.2 V for another 1 min. Finally, the system is returned to its normal state by removing the load in the last half minute. The current variations in response to various load variations are shown in Figures 20 and 21  the loads connected and removed at different time intervals, as discussed earlier. Moreover, the phasor or vector diagram in the case of different loads can also be obtained using the proposed PQA as shown in Figure 23a-c for resistive, inductive, and capacitive loads, respectively, for resistive load voltage and current in phase. However, for the inductive and capacitive load the phasor diagrams are 90 degrees out of phase. Thus, comparing the CRIO PQ analyzer with the Fluke PQ analyzer in terms of voltage sags and swells, frequency measurement, and phasor diagram, the CRIO PQ analyzer is found to be a more compact and reconfigurable solution. Cloud computing-based smart applications are growing progressively to deal with different power quality applications [36,37]. In contrast to the conventional PQAs, the CRIO-based PQA can be monitored remotely via the internet.  the loads connected and removed at different time intervals, as discussed earlier. Moreover, the phasor or vector diagram in the case of different loads can also be obtained using the proposed PQA as shown in Figure 23a-c for resistive, inductive, and capacitive loads, respectively, for resistive load voltage and current in phase. However, for the inductive and capacitive load the phasor diagrams are 90 degrees out of phase. Thus, comparing the CRIO PQ analyzer with the Fluke PQ analyzer in terms of voltage sags and swells, frequency measurement, and phasor diagram, the CRIO PQ analyzer is found to be a more compact and reconfigurable solution. Cloud computing-based smart applications are growing progressively to deal with different power quality applications [36,37]. In contrast to the conventional PQAs, the CRIO-based PQA can be monitored remotely via the internet.           In addition, the CRIO PQ analyzer provides a flexible, user-friendly interface and is also capable of real-time frequency measurement, as shown in Figure 22 with respect to the loads connected and removed at different time intervals, as discussed earlier. Moreover, the phasor or vector diagram in the case of different loads can also be obtained using the proposed PQA as shown in Figure 23a-c for resistive, inductive, and capacitive loads, respectively, for resistive load voltage and current in phase. However, for the inductive and capacitive load the phasor diagrams are 90 degrees out of phase.       Thus, comparing the CRIO PQ analyzer with the Fluke PQ analyzer in terms of voltage sags and swells, frequency measurement, and phasor diagram, the CRIO PQ analyzer is found to be a more compact and reconfigurable solution. Cloud computingbased smart applications are growing progressively to deal with different power quality applications [36,37]. In contrast to the conventional PQAs, the CRIO-based PQA can be monitored remotely via the internet.

Conclusions and Future Work
The integration of renewable energy into a modern grid has posed new PQ challenges. Conventional measurement instruments may not be adequate for meeting the challenges of the grid of tomorrow. In contrast to traditional PQA tools, a cost-effective CRIO-based PQA is presented in this paper, as it is software designed and provides a user-defined solution for identifying a problem early and preventing the occurrence of a power outage. The efficacy of the proposed PQA is verified by comparing its results with the state-of-the-art Fluke's 43-B PQA54. The proposed PQA can be modified or extended easily in a short period of time according to the latest international standards or any additional functionality required by the customer; however, its major limitation is that the customer should be familiar with the LabVIEW FPGA in order to modify the functionalities. The paper also illustrates the architecture of the HIL test bench to investigate and validate the performance of an electrical system in real time. A three-phase NPC converter loaded in the NI PXIe-1085 HIL and controlled through the CRIO for its real-time simulation and actual single-phase load was driven using a four-quadrant power amplifier for the PQ analysis. The results obtained via the PQA were in agreement with the requirements of the IEC standard 61000-4-7, 15, 30, and EN50160. The superiority of the CRIO hardware lies in the fact that, in addition to the PQA analysis, the same CRIO module in the HIL architecture may be used as rapid control prototyping for power converters.
Further work is required in different areas related to the control of each PQ index discussed in the study. For example, for THD reduction, active power filters can be designed in the HIL environment, and their performance can be evaluated as compared with passive low-pass filters. The inrush current can be decreased for a lower number of cycles using the controllers discussed in the literature. Moreover, our university installed a 1-MW grid connected a PV power plant. The proposed CRIO-based PQA will be implemented for monitoring the PQ of an overall photovoltaic grid and PV inverter output signals injected into the grid remotely via the internet.