A Distributed Web-Based System for Temporal and Spatial Power Quality Analysis

A distributed web-based system for temporal and spatial power quality analysis has been realized and tested. Connecting by internet local instruments able to perform high accuracy measurements in real time, the Power Quality information, locally measured, can be sent to a remote central server which aim is to plot them and stored the data for future analysis. The remote instruments have been realized, tested and placed in two Italian cities, Palermo and Rome, where actually work while the server works in Rome. The web application allows to select the single instrument and to show its stored PQ information.


Introduction
End-user equipment are increasingly getting affected by poor power quality (PQ) problems; for this reason the analysis of PQ is meeting more and more the interest of the scientific community [1,2]. Since the matter is complex, it can be faced from many different points of view. Surely, the effects on electrical devices and equipment joined with the lack of quality and the possible solutions to adopt to mitigate these effects are two aspects more and more investigated by researchers, so as the analysis of the causes that can lead to the degradation of the signal also has a big relevance within the scientific community. Each of the different aspects of this matter involve different competencies and skills: from the analysis of the physical laws, up to the study of algorithms to analyse the electrical phenomena that can happen in an electrical network that can lead to PQ phenomena; the study and realization of more accurate sensors able to satisfy all the needs of the normative, as well as the study and realization of more accurate input stages of the measurement instruments able to accurately reproduce the signal before its sampling; and the realization of updated hardware that mainly tries to make PQ monitoring simpler and more economical.
The PQ monitoring is a topic largely addressed in technical and scientific literature. The systems proposed differs, especially in the main aim of monitoring, acquisition, conditioning devices and platform used to transmit and store data, as reported in the following. Particular applications can be found in [3] where an industrial Programmable Logic Controller (PLC) on a web-based platform is used for transient detection of microgrid systems and in [4] where frequency fluctuations of high voltage transmission grid are monitored for the individuation of generator tripping. Some systems are designed to reach the maximum stability using commercial systems or PQ analyzers for the data acquisition [1,5,6,7,13], but often this choice reduces the flexibility and increases the costs, especially in the case of a large number of measurement points (MPs).
PQ is defined by some normative terms and CEI EN 50160 [8] describes it with 13 parameters: Prompt quantification of these parameters that define the PQ is desirable as soon as a problem occurs [2,9]. A quick response on the measurement instrument has the advantage of monitoring in real or almost real time the electric line and allowing, as soon as possible, the activation of all the possible procedures to mitigate the effects of electric energy degradation. An instrument conceived for this aim allows punctual monitoring and control of the line, but it cannot help understand the trend of a possible problem along the electric line. Real-time PQ monitoring geographically spread on the territory could help take some corrective actions in advance. To provide customers such information, both locally and on a nationwide basis, a web-based near real-time PQ monitoring system is necessary [1,[9][10][11][12][13][14][15][16][17]. Some of the needs associated to a PQ monitoring network can be summarized as follows: 1. The increasing problems in electrical distribution system obliges to have monitoring and measurement systems of the overall electrical network [18].

3.
For planning and developing a smart grid, useful data can be derived by continuously checking electrical quantities and power consumption [18].

4.
The constant and continuous detection and analysis of PQ parameters can suggest the adoption of new maintenance philosophies to improve the overall efficiency of the mains.

5.
For evaluating the performances of an electrical network in a deregulated electric market, the availability of a database related to PQ and reliability indices to electric regulator and customers are necessary.

6.
The availability of electrical network performances on a web database will help both the electrical equipment manufacturers to redesign their equipment to meet the PQ needs present in that area and the customers to choose which apparatus buy to avoid premature breakages.

7.
The availability of web-based power quality and reliability indices of various utilities will help the customer choose the electric supply and utilities that offer differentiated services for customers that have special requirements [29].
A general architecture for a distributed PQ monitoring foresees a wide network with many instruments distributed on a territory that locally sample the mains (one phase, tri-phases, and tri-phases that are more neutral) expanding the data through a series of specific algorithms to find the PQ parameters. In an architecture so conceived, the instruments should send raw data to a remote server that is able to plot the trend of the PQ parameters and able to synthesize a series of key performance indexes that allow to globally evaluate the electrical network.
A PQ monitoring network has, however, some critical elements that must be considered. First, it is necessary to consider the great number of data to manage. The normative foresees to acquire up to the 40 th harmonics of the fundamental; in case of continuous sampling, this leads a great number of samples for second of at least 4 kSamples/s. A more detailed sampling, i.e., a sampling frequency of 25 kSamples/s (equals to 50 kbyte/s, 4,32 Gbyte per day) is typical [2,[30][31][32][33][34]. To send all these information to a central remote control station could be extremely heavy. To partially solve this problem, it is possible to send to the server only the trace of the signal where the normative limit of the PQ parameter is exceeded. Another problem is the synchronization of the instruments that, for how the architecture is conceived, are distributed in a wide territory. Reference [35] proposes the synchronization of the clock of master and slave devices to permit the plotting of measured values with time. Unfortunately, this technique does not permit great time accuracy, around 10 -6 . A better solution is proposed by [2,36,37] that uses the timing directly coming from National Time Metrological Institute, but this implies its availability on site. To overcome this last need, other studies try to connect the synchronization to the global positioning system (GPS) both exploiting the actual facility through the 1 Pulse Per Second synchronization signal and developing new synchronization devices able to capture the fundamental frequencies of the GPS [38][39][40].
The Electric and Electronic Measurement Laboratory at Roma Tre University is engaged with PQ evaluation for 10 years and this chapter wants to show the most recent novelties on PQ instruments previously realized, in particular the web architecture that allows the realization of a web PQ instrument that is geographically widespread. This architecture allows both temporal and spatial PQ analysis.
The proposed system is totally self-made. In this way, great flexibility is guaranteed from the local acquisition system to the web interface for data management, storage, analysis, and visualization.
Our current application is to monitor the quality of the electricity supplied to some central telecommunication. In these stations, the telecommunication equipments use a high-accuracy metrological clock coming from INRiM (Istituto Nazionale di Ricerca Metrologica -the National Italian Metrological Institute). We have developed an ad hoc acquisition card that, using this clock combined with the timestamp received from the GPS, can start the acquisitions with a maximum uncertainty of 244 ns on the sampling instant (limit due to the clock frequency of 2,048 kHz).
The data transmission is based on FTP protocol. In this way, by simply sending two files, each MP transmits to a remote server the computed parameters and a sample of recorded waveforms that allow us to apply for a second time a more accurate analysis or some innovative algorithm for scientific purposes.
The use of the web paradigm has the advantage to be totally OS independent: a generic web browser is sufficient to perform all the operations and it allows using the system even on mobile devices. It should be remarked as the proposed system have been designed to be easily upgraded with more performing algorithms or with more functionalities.
In the next section, the MP structure will be presented. In particular, we will describe the acquisition system composed of a self-made acquisition card and a local PC that perform the analysis and create the files to be sent to the server. Section 3 will describe the server architecture and the data management. In Section 4, the web interface will be presented.

Measurement point structure
First, we need to describe the instrument for PQ analysis. In each measurement point (MP) localized in a territory, a PQ measurement device is present. As shown in Figure 1, it is composed of: • A self-made acquisition card ( Figure 2) able to sample both voltages and currents of a classical three-phase plus neutral electric line. Key features of this card are: • A 14-bit, 8-channel simultaneous-sampling analog to digital converter (ADC).
• High-accuracy voltage and current sensors with flat response in the band of interest: the chosen sensors are voltage dividers for the voltages and Rogowski coils for the currents.
• GPS module to synchronize the system with the UTC time coming from satellites. This module also allows getting the timestamp of each acquisition.
• USB interface to transmit acquired data to a processing unit and to power up the acquisition card.
• High stability metrological clock (coming from INRiM, the National Italian Metrological Institute, which provides a 2048 kHz clock signal with a stability of about 10 -10 s) and wired logic for high-accuracy acquisition timing. With this sample rate, it is possible to avoid the use of anti-aliasing filters that could distort the signal and, at the same time, it is possible to respect the maximum frequency of disturbances prescribed by the regulations. Theoretically, with the sampling frequency used by us (25 kS/s), you can calculate up to more than 200 harmonics of the fundamental, but since the regulation for instrumentation for power quality (CEI EN 61000) refers to the 40 th harmonic, we limited the estimation to the latter. Since all the data are stored on the server, it is always possible to increase the number of estimated harmonics. Moreover, with a frequency of 25 kS/s the minimum frequency specified by the regulations of 12.8 kS/s is fully respected.
• A power supply system, consisting of a buffer battery and a power supply to charge the battery, guarantees up to 3 days of autonomy in case of mains failure. In this way, it is possible to capture and analyze the trend of the power grid immediately after the return of voltages and to establish the duration of interruption.
• A remote control device is connected to the telephone line (PSTN -Public Switched Telephone Network) that provides basic information about the status of the system. This device also allows, in case of problems, to reboot the entire system using commands sent via the telephone keypad. • A processing unit (see Figure 3) that receives samples from the acquisition card and processes the acquired data to estimate various parameters (mains frequency, three-phase RMS values, magnitude and phase of each harmonic, etc.). For every acquisition, this unit generates two files, a binary file containing the raw values acquired directly from the ADC and a text file with the estimated parameters. The filename is the UTC timestamp of the acquisition. These files are regularly sent to the central server via an FTP connection but, in case of connection issues, the data is locally recorded and then it is sent as soon as the connection is again available. The processing unit is designed to operate in full autonomy, but, if necessary, the system can be accessed remotely via remote desktop software and then it is possible to check if there are anomalies, perform updates, troubleshoot malfunctions, etc. This remote connection is possible with two scripts, one that locally runs on the processing unit and the other that runs on the central server, they together allow to register the IP address of each MP. The IP address is essential to use the remote desktop software and its registration by the server is required as the measuring points have dynamic IP addresses. The processing unit allows to locally analyze the acquired data to perform a parameters estimation and events detection. If an event is detected, the unit saves the recorded waveforms and sends them to the central server. In this way, a remote machine that has higher computing resources will perform an accurate analysis of the specific disturbance or fault. However, the system is characterized by high flexibility and it is possible to balance the computational load between the local and remote machine.
The current local processing scheme is represented in Figure 4. The algorithm used for the estimation of the parameters is the multi-harmonic least squares fitting. Compared with the more largely used methods such as FFT and zero crossing, this method does not require a coherent sampling and it is able to give good estimations also for short observations (few cycle of the fundamental). In the conditions of interest for the power quality analysis, this class of algorithm assures the maximum accuracy possible.
If the frequency is known, this algorithm allows estimating the amplitudes and phases of the harmonics and simply solving a linear system. This approach requires estimating the frequency in advance using some other algorithm. If the frequency is unknown, the algorithm becomes more complex and requires a recursive method. In [44] a non-recursive approach that is very useful for power quality applications was presented. This approach strongly reduces the computational load of the non-linear, multi-harmonic least square fitting, preserving at the same time its accuracy. As shown in Figure 4, in our system the method [44] has been used for the accurate estimation of the grid frequency. The estimated frequency is used in a second step to estimate the harmonic parameters using the linear multi-harmonic least squares. As indicator for the presence of some non-harmonic disturbances (interharmonic, subharmonic, transients, etc.), the software calculates the variance of the residuals defined as the difference between the acquired samples and the model-based reconstructed signal. If the variance is over a selected threshold determined on the basis of the SNR (signal to noise ratio) of the acquisition card the associated record will be analysed with more detail for a second time by a remote machine. The algorithms running on the remote machine can be updated in relation to the applications.

Server
The server is a LAMP (Linux -Apache -MySQL -PHP) machine ( Figure 5). It is also an FTP server to allow receiving files from the MPs. The server has a modular structure; each measuring device used has a folder (with its subfolders "bin" for binary files and "txt" for text files) where it sends files. So if a monitoring point is added, a folder (and its subfolders) will be added to the server directories.
At regular and predetermined intervals, the server runs PHP scripts that acquire the parameters contained in text files and put them in the database (DB). In addition, the database is modular, so if you add a physical monitoring point you need to add a table in the DB. Each point has its own table containing all the parameters calculated.
The web server allows having a website accessible from any Internet connection. This website allows the temporal and spatial analysis of the values acquired by the monitoring system and gets information from both the DB and the binary files stored.

Web interface
In this paragraph, the web user interface will be presented, highlighting data access and visualization. Exploiting a classical client-server architecture, it is possible to visualize the data using the common web browsers available for all the principal operative systems. In this way, the system has the advantage to be platform independent. At the moment, the developed web pages are the following: • The page to visualize the temporal evolution of the calculated parameters in a selectable range of time. Each point of the graph referred to a precise timestamp is clickable allowing the visualization of the voltages and currents waveforms recorded at that timestamp; • A page with the spectrum of the signal to analyse the harmonic content of voltages and currents; • A dashboard for three-phase analysis with the graphical representations of the voltages and currents phasors; • A dashboard for signal analysis to detect particular events that may be occurred; • A page to visualize the spatial distribution between the different MPs at a precise timestamp.
The different pages are linked to each other to facilitate the analysis.
To plot the temporal data and the waveforms in the web pages the "dygraphs.js" javascript library [41] has been used. This library allows plotting time records passing a structured text dataset. The library "D3.js" [42] has been used to draw the polar plots. To draw the 3D surface in the spatial interpolation page, the javascript library "three.js" [43] has been exploited. In the following sections, the four pages will be presented and described.

Temporal analysis web page
This is the main page of the web site. The principal aim of this page is to visualize a temporal evolution of one of the measured parameters and to display the waveforms recorded in a given timestamp. A screenshot of this page is shown in Figure 6.
The control bar on the top of the page allows the user to select the desired MP, the parameter, and the time interval to analyse. The time interval of interest can be chosen by selecting the initial and final timestamps. Clicking the "Refresh" button, the web page performs an AJAX request to the server containing the selected choices. A specific PHP script builds the query to the SQL database on the server, eventually performs a calculation (as in the case of the powers), and finally sends back to the client the required data. After the reception, the web page displays the temporal evolution in a graph.
The quantities that can be shown are: • Frequency; • RMS values for voltages and currents; A Distributed Web-Based System for Temporal and Spatial Power Quality Analysis http://dx.doi.org/10.5772/61145 • Harmonics up to 25 th for voltages and currents; • Total harmonic distorsion (THD), calculated using 50 harmonics; • Signal to noise ratio (SNR); • Total active and reactive power and harmonic powers.
The temporal evolution highlights both short-term and long-term periodicity of the phenomena. In some cases, an anomalous behaviour can be detected simply by the presence of spikes of evident deviations of some parameters from the normal range of variation.
Another important function of this page is the possibility to display the recorded waveforms of a given timestamp simply right-clicking the related point of the graph. Under the temporal plot will appear two graphs, the one on the left containing the voltage waveforms and one on the right containing the current waveforms. After clicking, some buttons will appear at the bottom. Through these buttons, it is possible to open different windows, which allow to perform further analysis and give additional information.

Harmonic spectrum window
By clicking the "Spectrum" button at the bottom of the Temporal Analysis page, a new window opens. This window shows two bar plots representing the harmonic compositions of both voltages and currents for the selected MP at a specified timestamp. Figure 7 shows the appearance of the window. Each harmonic bar contains three sub-bars indicating the harmonic level measured for each phase.

Three-phase analysis window
The "3-Phase" button on the main page ( Figure 6) opens in a new window, a page for the threephase analysis similar to the one shown in Figure 8. The situation is referred at the same MP and at the same timestamp currently displayed on the main page.

Residual analysis window
The "Residual" button on the main page ( Figure 6) opens the window similar to the one in Figure 9. This page allows a residual analysis of the voltages useful for the detection of non-harmonic disturbances. Calling the page, a non-recursive multiharmonic fitting [44,45] is performed to estimate the fundamental and the harmonic components. The residual is obtained by subtracting the estimated waveform to the measured data record. In this way, the fitting residual retains the noise and all the non-harmonic components eventually present on the voltage. The least squares multiharmonic fitting is an algorithm that allows to estimate the parameters of a periodic signal overcoming the well-known problem afflicting the Fourier Transform based algorithms (leakage and picket fence).
The histogram of the residuals is useful in knowing residual distribution. In the case of quasi-Gaussian distribution, the performed least squares fitting assures the best accuracy in the estimation of the signal frequency and the harmonic levels [44].
In Figure 10, two representative cases are shown. The top graph highlights the presence of an interharmonic (about 670 Hz) and the histogram shows a bimodal distribution typical of a sinusoidal component. In the situation represented at the bottom, the residual shows the presence of a fast transient probably due to a mechanical switching action. The bouncing effect is also visible.   . This figure shows the dashboard for the residual analysis. The residual is calculated as the difference between the data record and the estimated signal by multiharmonic least squares fitting. The residuals are composed of the noise and the non-harmonic components. So, the presence of some particular disturbances can be detected. On the right, the histogram of the residuals is also shown.
A Distributed Web-Based System for Temporal and Spatial Power Quality Analysis http://dx.doi.org/10.5772/61145

Spatial analysis page
In some cases, it can be useful to view the spatial distribution of a certain parameter at a certain timestamp. For this purpose, a dedicated web page has been developed. An example of this page is shown in Figure 11, in which is displayed the RMS measurements obtained in the city of Rome at 6:54 am on the 8 th of August, 2014. This window shows a city map on which a set of cylinders are positioned on the location of the active MPs of that city. The height of each cylinder is related to the measured value. An interpolation surface is also shown with the purpose of giving indicative information about the spatial distribution of the parameters. The geographical interface allows the individuation of local problems and eventually the propagation of large disturbances on a wide area. This tool will become more useful if the number of MPs is increased, so performing a denser spatial sampling.

Conclusions
The trend of the recent years highlights the importance of PQ monitoring for understanding both local and global phenomena. The former calls for an approach to induce the development of specific instrumentation with the aim of recording a series of parameters useful in solving a specific problem in a specific point of the network and to prevent damages or malfunctions in sensible devices. The latter calls for an approach that is useful in understanding the dynamics of the mains viewed as a largely interconnected network. In the new generation of monitoring systems, these two aspects have to coexist as useful tools to control and manage the mains especially with the large diffusion of distributed micro generation and the coming of smart grids.
In this chapter, it has been presented that the monitoring system developed in the Electric and Electronic Measurement Laboratory of Roma Tre University was built with the aim to have a monitoring system that is able to analyse the PQ both in time and space. The platform has been developed as modular as possible, not only to allow extending the monitoring network but also to add new innovative analysis tools that could be introduced in the next years. Another important aspect is the data collection. For scientific purposes, the system calculates the PQ parameters and stores the data in a database, while sampled waveforms are stored in a dedicated server. In this way, a large real data set is available as bench tests for further analysis that will be proposed in the future.