Low-Frequency Signal Sampling Method Implemented in a PLC Controller Dedicated to Applications in the Monitoring of Selected Electrical Devices

High requirements for power systems, and hence for electrical devices used in industrial processes, make it necessary to ensure adequate power quality. The main parameters of the power system include the rms-values of the current, voltage, and active and reactive power consumed by the loads. In previous articles, the authors investigated the use of low-frequency sampling to measure these parameters of the power system, showing that the method can be easily implemented in simple microcontrollers and PLCs. This article discusses the methods of measuring electrical quantities by devices with low computational efficiency and low sampling frequency up to 1 kHz. It is not obvious that the signal of 50–500 Hz can be processed using the sampling frequency of fs = 47.619 Hz because it defies the Nyquist–Shannon sampling theorem. This theorem states that a reconstruction of a sampled signal is only guaranteed possible for a bandlimit fmax < fs, where fmax is the maximum frequency of a sampled signal. Therefore, theoretically, neither 50 nor 500 Hz can be identified by such a low-frequency sampling. Although, it turns out that if we have a longer period of a stable multi-harmonic signal, which is band-limited (from the bottom and top), it allows us to map this band to the lower frequencies, thus it is possible to use the lower sampling ratio and still get enough precise information of its harmonics and rms value. The use of aliasing for measurement purposes is not often used because it is considered a harmful phenomenon. In our work, it has been used for measurement purposes with good results. The main advantage of this new method is that it achieves a balance between PLC processing power (which is moderate or low) and accuracy in calculating the most important electrical signal indicators such as power, RMS value and sinusoidal-signal distortion factor (e.g., THD). It can be achieved despite an aliasing effect that causes different frequencies to become indistinguishable. The result of the research is a proposal of error reduction in the low-frequency measurement method implemented on compact PLCs. Laboratory tests carried out on a Mitsubishi FX5 compact PLC controller confirmed the correctness of the proposed method of reducing the measurement error.


Introduction
Currently, the increasing use of monitoring systems for various systems that measures various quantities can be seen. Previous methods of measuring these parameters required the use of methods using relatively high sampling frequency of the measured signals and relatively high computing power for processing the obtained measurement data. The papers [1,2] presented a new method of measuring and obtaining parameters of electric signals, it required parallel sampling of current and voltage with a frequency of only 8 Hz. The calculation formulae of the processing method were also relatively simple, which allowed their application in simple microprocessor systems.
The article [2] presented the implementation of the measurement of the current, voltage, and power using the low-frequency method. A laboratory stands for testing the application on a PLC controller was presented. The results of the research were presented and the obtained results were analyzed, and in particular, the influence of time delays on the errors of the obtained measurement was shown.
The 8Hz sampling method can be used successfully to monitor slowly changing loads, in particular electrical devices, in a stable state. The obtained information about the active and reactive power of the device as well as the rms values of the current and voltage can be used to control the active power and to compensate for the reactive power. The advantage of this method is that relatively inexpensive microcontrollers (equipped with at least two analog inputs) are able to control the device themselves and, at the same time, measure its power without the need to use additional expensive measurement modules [3].
Monitoring of the electrical parameters is important and useful information used in the control of the device and in meeting the energy quality requirements of the power supply system and, in particular, minimizing reactive power. The article [4] discusses the impact of technical limitations of measuring instruments on the measured electric parameters.
The article [5] presented the use of synchronous sampling with the use of a PLL (Phase Locked Loop).
Another interesting application of the low-frequency signal sampling method can be the monitoring of electromagnetic circuits, especially the monitoring of electromagnets in various technical applications [6].
There are many applications where low-frequency sampling methods can be used. One of the first examples might be monitoring and diagnostics of the internal combustion engines [7] or to measure the Weber-ampere characteristic [8].
Low-frequency sampling methods can be successfully applied in the problems of impedance analyses or the determination of dielectric solids [9].
The novel variable frequency sampling method is proposed [10], which solves the contradiction between low-frequency acquisition for CLVData and high-frequency acquisition for SSVData.
With the use of low-frequency methods, it is possible to monitor human physiological parameters in real time in order to conduct a comprehensive assessment of human health by registering changes in human health information [11].
In the areas of intelligent construction and monitoring of building structures, with the help of low-frequency methods, measurements related to the physical-chemical parameters of buildings and thermal characteristics can be made [12].
In [13] a near-real-time plug load identification approach was proposed which uses low-frequency power data (1/60 Hz) to identify plug loads in office spaces.
In [14], the performance of photovoltaic (PV) modules as a function of time is monitored by observing different slopes at successive time intervals. Slopes are denoted as degradation rates and used to express array performance degradation.
When measuring low-frequency vibrations, this method of data processing can be used to determine dynamic errors and the accuracy and reliability of the measurement [15,16].
The article [17,18] presents a transducer that allows us to measure the instantaneous value of the current with a Hall linear sensor. The advantage of the transducers presented in this paper is their simple design and low cost.
In modern building automation systems, in which various optimization and control algorithms have been implemented, it is very important to approach the signal processing with the appropriate frequency. These findings can assist policy and decision-makers in identifying the right smart meter hardware to meet appliance-level energy efficiency and building automation goals [19].
Another important application of a cheap low-frequency parameter measurement system is a new area of energy recovery from dragging mechanical elements and converting this energy into electrical energy used to power electronic components [20].
In addition to the typical applications of methods related to the processing of electrical signals in the field of broadly understood electrical engineering, many other applications can be found.
Another area of application of low-frequency sampling can be the broadly understood field of electromobility and data processing for the purpose of determining the location of vehicles [21].
Navigation and traffic jam warning systems also show great potential for the use of low-frequency methods [22] and low-frequency sampling methods can be used in monitoring weather parameters [23].
Also, low-frequency signal sampling methods can be used, for example, in water quality monitoring. Based on such a solution, it is possible to monitor, for example, the dynamics of the spread of pollution or the deterioration of water quality in the water supply system at any time [24].
Also, the application of these signal processing methods can be used in monitoring large bodies of water, for example, by the sea, for observing oscillations of water waves and for early warning of their undesirable effects [25].
Based on these methods, it is possible to construct frequency measurement algorithms based on the full properties of cyclically repeated arithmetic operations in computational algorithms [26].
Also, in the processing of simple two-dimensional data sampled with a low frequency [27].
Low-frequency sampling methods can be used in monitoring seismic events and observation of slow earthquake signals in the micro seismic frequency band [28].
Also, in the processing of simple two-dimensional data sampled with a low frequency [29].
Medicine is an important area of application of the methods. One of the areas here is the measurement of signals available during the diagnosis of a patient's health condition [30].
The article presents the issues related to the parallel and real, serial, system for acquiring signals from two analog input channels. These real signal acquisition systems are typical low-cost PLCs, microcontrollers, and measurement cards. Next, this article was presented calculated the sampling period Ts for slow-sampling. Angular delays of samples readout of series sampling acquisition equipment are also defined. The theoretical basis for calculating the value of current, voltage, and power on an electrical receiver powered by sinusoidal voltage is also presented. The laboratory studies of the discussed measurement method were presented. It presents an appropriate measurement scheme with the characteristics of the elements used in its construction. The conducted research showed that the important issue of ensuring the accuracy of the measurement of the presented method is the selection of the signal sampling frequency and the maintenance of this frequency at a constant level.
The use of aliasing for measurement purposes is not often used because it is considered a harmful phenomenon. In our work, it was used for measurement purposes with good results.
The considerations in the article will focus on the analysis of periodic waveforms of current and voltage, allowing for a good illustration of the low-frequency properties of the proposed method.
The rest of the paper is organized as follows: in the second section, the concept of low-frequency method to sampling periodic signals is described. Necessary dependencies for the measurement method are presented and the method of measuring sinusoidal and non-sinusoidal signals is illustrated as well as the new issues connected to the low-frequency signal processing is presented. The third part describes the experiments and the results obtained. In the beginning, a laboratory system with a PLC controller was presented, which was used to carry out the research. This section presents the measurement results for sinusoidal voltage and current signals, followed by non-sinusoidal ones. Finally, conclusions are given in Section 4.

Low-Frequency Method of Sampling Periodic Signals
A common technique for digital platforms to acquire and process data is to use high sampling rates to measure signals (which in turn requires multiple samples per period) [1]. This is because these techniques must follow the Nyquist-Shannon sampling theorem, which requires at least two samples per period in the measured signal. For the 50 Hz signals, that is, with a period of T = 20 ms, it means a 100 Hz sampling rate at a minimum. Instead, the slow sampling that occurs when the sampling period Ts is longer than the period of the signal T results in a sampling rate much lower than 50 Hz.
The sampling period Ts for slow-sampling can be calculated as: In typical industrial (low-cost) PLCs, microcontrollers, and measurement cards, the acquisition of the measured signals is carried out using one AD converter and a multichannel multiplexer. This signal acquisition method is referred to in the literature as the serial sampling method. Figure 1 shows two signals (voltage and current) sampled in such a serial-sampling acquisition system. In one channel, the voltage and current signals are sampled with an angular delay α while dβ is the readout delay between channels. Nowadays even cheap digital platforms such as FX5 Mitsubishi PLC along with its software provide a practically constant sampling rate, so the angular displacement error dα is negligibly small-it does not exceed 0.3% π/2-which makes it irrelevant. Therefore, it can frequently be assumed that dα  0 and the angular displacement α is constant (α  constant).

Theoretical Formulation
Up to the end of this paper, we assume that voltage is measured in Volt, current in Ampere, and power in Watt. Each continuous sinusoidal signal y(t) can be described by the function: or by its complex representation To calculate a harmonic of a sinusoidal signal we can take two consecutive samples with an interval Ts and use the following equation to identify it: where:     2 1 2 1 , = = y y t y y t -two consecutive samples of signal y(t) taken at the time t1 and t2.
The formulas for power and rms-value in the case of a parallel sampling are as follows [2][3][4]: where: p, q-active and reactive power, calculated as for parallel sampling [2,3], Alternatively, we can use four sampling points, which results in formulae: and the current and voltage rms values can be calculated with the formulae: The paper [4] showed that parallel sampling is not always feasible in real PLCs. In these cases, we are dealing with serial sampling.

Serial Sampling
As PLCs generally use serial sampling, current samples are taken with a delay to the voltage (or vice versa), introducing a delay error dβ.
This error needs to be corrected and a correction should be made to the power calculation formulas, so the key point is to determine this delay simply and accurately.
If, for example, the current signal is sampled with a delay Δt to the voltage, then the delay dβ  ωΔt causes an error in the power calculation. To correct this error, we use a correction formula, based on angle dβ, to calculate the power, which can be written using the rotation matrix: where: Δt-time delay between current and voltage samples, The next section presents a method of determining dβ, which can be carried out in a simple way without any additional hardware, before using the controller for measurement.

Determining dβ
As shown in [4], delay Δτ can be determined directly by testing the readout delay time between channels.
However, it can also be calculated more simply by measuring the power of a purely resistive load.
In this case (Q = 0) the formulae for active and reactive power (taking into account the delay dβ) for the resistive load are: and because it can also be assumed that (dβ) = 1, then sin s n 1 i Alternatively, a correction that results from the difference between average power values measured with card and PLC can be calculated with the formula: where 1 0 , tg tg -measured and exact Q/P.

Multiharmonic Signals
In the case of multiharmonic signals we take samples every 21 ms (Figure 2). This is the equivalent of a 1 kHz sampling rate for stable periodic signals, but requires much less PLC processor power and does not overload its data acquisition system.

Two Samples Method
To calculate a harmonic of a sinusoidal voltage signal we can take two consecutive samples with an interval 5 s T and use the following equation to identify it: where: F= where:

Multiharmonic Current of Odd or Even Harmonics
When a multi-harmonic signal occurs, which has only odd harmonics [1 3 5 7 9], Fourier coefficients for harmonics up to 9 are related with 10 consecutive samples by the matrix equation where: cos c ) (9 9) ( ) os 7 sin 7 s ) in 9 9) ( 9 9 The RMS value of the signal can be calculated from the formula: When the signal has even harmonics [2 4 6 8] only we can use a similar approach to calculate them based on 10 consecutive samples where:

Power Calculation
The calculation of power is carried out based on the fundamental harmonic only, that is, on the assumption that voltage is monoharmonic.
Complex power for the fundamental harmonic S1 can be calculated as: XC,1, XS,2-real and imaginary parts of the 1st harmonic of X, P, Q-active and reactive power.

Sinusoidal Signals of Voltage and Current
The block diagram of the low-frequency measurement system for measuring voltage, current, and power consumption by a single-phase load is shown in Figure 3.  Table 1 shows the basic parameters of this controller. As can be seen from the table, the controller manufacturer has significantly increased its efficiency by increasing the computing power, reducing the instruction execution time, and increasing the program memory capacity and the memory of variable/registers. Thanks to the new software package GX-Works3, the user gains the possibility of more easily building the software application for the controller. Built-in functionality, for example, communication via Ethernet and RS-232.485, positioning and motion control in four axes, and the possibility of expanding with additional I/O modules, makes the compact FX5 series controller especially recommended for industrial automation applications (eFactory technology) in the Edge-Object layer. This layer now not only transfers data from the object to the management layer, but also performs some calculations of object variables and send the already processed data to the management layer. This reduces the traffic in the Ethernet network and accelerates the process of monitoring and diagnostics of the supervised facility.
The external module FX5-4AD-ADP, with four analog inputs, is connected to the FX5-32 MT controller via the left side adapter. This module has an input range of −10 to 10 V and a resolution of 14 bits. The range of analog inputs of this module is important because the applied current and voltage measuring converters generate an output voltage in the range from −10 to 10 V DC/AC. The measuring system does not use two analog inputs built into the controller, as their input voltage is in the range of 0-10 V, which would require the use of additional voltage shifters. The basic specification of the FX5-4AD-ADP analog input module is shown in Table 2.   Table 2. The basic specification of the FX5-4AD-ADP analog input module.

No. Item Specification Parameters 1.
Number of analog input points 4 points (4 channels)

3.
Digital output value 14-bit binary value Input

4.
0-10 V, 0 to 16000, 625 μV 0-5 V, 0 to 16000, 312.5 μV Input characteristics, resolution (analog input range, digital output value, resolution Voltage) 1-5 V, 0 to 2800, 312.5 μV −10-10V, -8000 to +8000, 1250 μV Conversion speed maximum 450 μs (The data will be updated at every scan time of the PLC) In the measuring system discussed, two LEM type transducers were used. They use the Hall effect in their actions. This provides galvanic isolation between the converter input and output. The output voltage range of these converters is −10 to 10V. The converters are designed for PCB mounting. These transducers have good linear characteristics and an accuracy of less than 1%. The LEM LV 25-P voltage converter measures AC/DC voltage in the range from −500 to 500 V. The LEM HY 5-P converter measures AC/DC current in the range from −15 to 15 A.
A universal measurement card by National Instruments, type Ni USB 6259, was used as a model measuring system. This card has both analog and digital inputs and outputs. Thanks to the built-in buffer memory, the card can transfer data to and from a computer, via the USB interface, without losing data during transmission. The basic parameters of the analog inputs of this card are presented in Table 3. Maximum working voltage for analog ±11 V of AI

Sinusoidal Signals of Voltage and Current
In the case of sinusoidal signals, the sampling period should be 25 S T ms  , however, PLC does not hold the same sampling period S T all the time, which is shown in Figure 4.   The difference between two-point and four-point measurement methods of RMS values are depicted in Figure 6. Calculated power with Formulas (5) and (7) without correction are depicted below in Figure 7. Because it was a purely resistive load (with Q = 0) the correction that results from the difference between true power value and this measured with PLC can be calculated with the Formula (12) and should be used in Formula (9) to get the corrected power depicted below in Figure 8. A comparison of values obtained with DAQ card and PLC measurement are listed in Table 4.

Non-Sinusoidal Current and Sinusoidal Voltage Signal
In the case of nonsinusoidal signals, the sampling period should be 21 S T ms  , however, PLC does not hold the same sampling period S T all the time, which is shown in Figure 9. The measured samples with PLC and DAQ card with an average power and average RMS-values of current and voltage are depicted below in Figure 10.

Required Number of Samples
Because the current is nonsinusoidal we take 10 consecutive samples to determine the harmonics RMS-value of current with Formulas (16) and (17) and only 3 samples to determine the harmonics and RMS-value of voltage with Formulas (14) and (15) because voltage is almost always sinusoidal ( Figure 11). Alternatively, we can use two samples of voltage distanced by four samples (every fourth sample) ( Figure 12).   A comparison of values obtained with DAQ card and PLC measurement are listed in Table 5.
Comparing the results, it can be easily seen that in the case of sinusoidal signals, the delay in sampling between the voltage and current channels changes mainly the reactive power. However, this can be easily fixed with the correction given by Equation (12) or (13). additionally, the four-point sampling version does not differ much from the twopoint version as smoothing can always be obtained by averaging two adjacent samples. In the case of multi-harmonic signals, the slow-sampling method reflects well the harmonic content of the signal. It is also able to determine the active power well. It should be noted that sinusoidal voltage is sampled with a lower frequency than the multi-harmonic current. The economical three-point sinusoidal voltage sampling method used in this case proved to be better in power calculations than the two-point method.

Conclusions
The algorithms presented in the paper enable us to do a calculation of the basic electrical parameters of sinusoidal and non-sinusoidal signals, up to the ninth harmonic, in a simple way. These procedures do not overload the processors of PLC controllers or their measurement modules, thus enabling the controllers to perform their normal control work for which they are intended. These algorithms can be used in devices monitoring the quality of electricity and in devices protecting against overload or distortion of electric voltage or current.
They could also be used in systems dedicated to the diagnostics of the parameters of electrical machines and devices as simple damage indicators.
The algorithms proved to be accurate and the relative error did not exceed a few percent. It is possible to use this method to measure impedance that changes slowly over time, measure frequency deviations from 50 Hz of the supply sinusoidal signal, and to detect short-circuits in the rotor of a three-phase motor. Works on these issues are in progress and in some of them, the results confirming the usefulness of slow sampling for determining the above-mentioned parameters of electrical signals have already been obtained.
The paper shows that sometimes, using certain peculiarities of signal processing, it is possible to construct effective computational algorithms, which, as it generally seems, due to the adopted laws and principles in the classical approach, are on the verge of applicability.
In terms of the ubiquitous development of devices and methods related to the development of Industry 4.0, it seems to be a very interesting solution. After a slight modification of the already existing systems with PLC drivers, such simple measurement algorithms can be implemented in most systems. It can be a simple and effective tool for tracking and diagnosing faults in less known machines and electrical devices, where there are generally no online condition monitoring and control systems.