Non-Zero Crossing Point Detection in a Distorted Sinusoidal Signal Using Logistic Regression Model

: Non-Zero crossing point detection in a sinusoidal signal is essential in case of various power system and power electronics applications like power system protection and power converters controller design. In this paper 96 data sets are created from a distorted sinusoidal signal based on MATLAB simulation. Distorted sinusoidal signals are generated in MATLAB with various noise and harmonic levels. In this paper, logistic regression model is used to predict the non-zero crossing point in a distorted signal based on input features like slope, intercept, correlation and RMSE. Logistic regression model is trained and tested in Google Colab environment. As per simulation results, it is observed that logistic regression model is able to predict all non-zero-crossing point in a distorted signal.


Introduction
In many electrical domains like in industrial electronics, grid synchronization, power quality and power system protection etc., accurate non-zero crossing point (NZCP) detection is critical. Practical line voltages are seldom distortion-free, and they usually include a lot of harmonics and noise, which can cause synchronisation issues. NZCP detection is an easy task in case of pure sinusoidal signal, it can be identified using simple comparator circuits. However, NZCP detection in a distorted sinusoidal signal using comparator circuits is not appropriate as it contains multiple false ZCPs. So there is a need to build an accurate mechanism to separate NZCPs in a distorted sinusoidal signal. In case of protection systems, the fault current has DC decaying component. This component decreases the accuracy and speed of the protection relay operation [1]. A separate methodology is required to estimate and remove dc component from the fault current with in one cycle. After elimination of dc component, fault current signal passes through ZCP detection circuit to identify the zero-crossing and open circuit breaker at ZCP points.
Many researchers are working on ZCP detection problem and provided various solutions. Artificial Neural Network (ANN) model is developed in [2] to predict the ZCPs in distorted signal. Distorted signal simulated in MATLAB with noise levels 10% to 50%, and with THD levels 10% to 50%. Data samples extracted from these signals with a window size of 15. A phase-delay free method is proposed in [3] to detect the ZCPs of back electromotive force in spindle motors.In this method rotor position detection with sensor-less control of spindle motors in hard disk drives. The method applies a digital filtering procedure to identify the true and false zero-crossing points of phase back electromotive forces, the latter of which are caused by the terminal voltage spikes due to phase commutations. This methodology is especially suitable for high-speed sensor-less brush-less dc motors. Impact of asymmetric machine parameters and resistance tolerance of back emf measurement circuit on ZCP detection based sensor-less control of high speed brush less DC motor is studied in [4]. In this study, authors did not analyze the impact of asymmetric mutual inductance on ZCP detection.
A digital zero-crossing detector circuit is used for phase synchronization and frequency tracking to control the grid-tie power converter for efficient energy conversion system in [5]. Zero-crossing point detection based methodology is proposed in [6] to estimate the synchronization between the signals. This technique observes the synchronization between signals by detecting the phase change with in half cycle. This methodology works well in the frequency range of 50 Hz to 52 Hz only. Power quality is analyzed based on measurements like RMS value, frequency and harmonics. For accurate measurements, proper zerocrossing detection is required. In [7], comparative analysis between digital filters for ZCP detection in power quality measurement in presence of 3rd and 5th harmonics and noise is presented.
ZCP detection using Digital pulse-frequency modulator based of FPGA is implemented in [8] to identify the zero current and zero voltage transition. This methodology is implemented to change the resonant pulse width in a quasi-resonant pulsed converter under the different load conditions. Analog ZCP detection based on digital zero-crossing detection algorithm with signal reconstruction and least square fitting technologies is used in [9] for high precise time difference measurement in ultrasonic flow measurement unit. ZCP detection in line voltage based on multistage filter, least square line fitting model and extrapolation of the ZCP is implemented in [10]. This methodology is implemented only on 50 Hz sinusoidal signal but arguing that this can be applicable up to 60 Hz signal. ZCP detection in inductor current for high current swithed mode DC-DC converters is presented in [11]. In this paper voltage polarity detector based on the transistor memory cell and auto zero-comparator is used for ZCP detection.
An adaptive, robust, and computationally efficient disturbance reduction method for line-frequency zero-crossing detectors using multiplicative general parameters adaptive algorithm is proposed in [12]. The proposed adaptive system consists of a fixed finiteimpulse response filter block and two multiplicative general parameters. Fast zero-crossing point detection method based on global minimization algorithm is proposed in [13]. A new approach to the design of a digital algorithm for network frequency estimation is proposed in [14]. The algorithm is derived using Fourier and zero crossing technique. The Fourier method is used as digital filter and zero-crossing point detection technique is applied to the cosine and sine components of the original signal which can be corrupted by higher harmonics. An indirect way of detecting the Zero-Crossing instant of the back EMF from the three terminal voltages without using the neutral potential is proposed in [15]. The method proposed in [16] uses the voltage mode PWM changing the ramp slope according to the ac line voltage to control the switch on-time. The performance was verified with a 100 W boost PFC converter.
A digital frequency measurement method is proposed is proposed in [17] to overcome the difficulty that the single zero-crossing point detection is sensitive to noise in the traditional dual mixer time difference measurement method.The proposed method uses sinusoidal beat technology, multi-channel synchronous acquisition technology, and digital frequency measurement technology. Sensor less control of BLDC motor based on zero-crossing point detection of the back electromotive force (BEMF) is proposed in [18]. Micro-controller based and low cost speed controller for BLDC motors up to 500 W is developed in [19] by employing the zero crossing point (ZCP) detection of the back-electromotive forces. Estimation of line back electromotive force based on sensor-less control strategy is proposed in [20]. In this work, commutation rule for different positions of the rotor is developed based on the phase relationship between the ideal commutation points of the brush-less direct current motor and the zero-crossing points (ZCPs) of the line backelectromotive force. A current decomposition method and a control diagram are proposed in [21] to eliminate the fundamental circulating currents by detecting zero cross current point which increases the accuracy of the control algorithm.
Identification of Safety operation area represented by back emf ZCP in a high speed BLDC motor in terms of free wheeling angle is implemented in [22]. Effect of PWM techniques mechanism on free wheeling angle is investigated. For given motor parameters, torque and speed area of BLDC motor are identified. Robust ZCP detection mechanism is developed in [23] using support vector machine. In this study, authors considered noise level up to 20% and THD level 50%. ZCP detection using voltage sensors, voltage shifter and micro controller is discussed in [24]. Machine learning is powerful approach to find the solution for various problems in electrical engineering like load forecasting [25][26][27] and health care [28] etc., Most of the researchers are also using machine learning based approach to detect the ZCP in distorted signals. In this paper also machine model called logistic regression model is used for NZCP detection.
Zero crossing sampling digital phase-locked loop (PLL) is analyzed as a building block for a phase synchronization syste in [29]. In this paper, analysis of PLL is described using frequency domain methods. The design and performance analysis of frequency synchronization and transfer over packet networks is presented in [30]. In this paper, authors uses time stamps-based raised cosine pulse shaping first order adaptive zero-crossing digital phase-locked loop (AZC-DPLL). The system is designed to recover frequency as well as packets, independently of the input signal level in the presence of noise. A first-order derivative of Gaussian filter is used to detect and locate rapid changes in voltage signal caused by crossing of a threshold angle determined by maximum overlap of capacitive electrodes in [31].
Main contributions of this paper are as follows: • ZCP detection in wide range of distorted signals by considering noise levels from 10% to 60%, THD level from 10% to 60%. • Logistic regression model which is a machine learning model is used for the first time ZCP detection. • New data consists of 96 datasets which are developed to work on ZCP detection problem and are available in https://data.mendeley.com/datasets/d2hs6zt8gw/1 (accessed on 20 March 2022). • Performance of the machine learning models to detect ZCP in distorted signal with various window sizes is observed.
The remaining part of the paper is organized as Section 2 explains the datasets and machine learning models, Section 3 describes result analysis and Section 4 presents conclusions.

Methodology
This section presents the process of extracting the slope,intercept,correlation(R) and RMSE features from a distorted sinusoidal signal. Also, it describes about the datasets created for ZCP detection problem. And, also it discusses about the architecture and training process of logistic regression model used for the ZCP detection.

Feature Extraction and Datasets
Distorted sinusoidal signals of 5 cycles are generated for 0.1 s with noise level of 10% to 60%, with THD levels of 10% to 60% using MATLAB. Features like slope, intercept, correlation (R) and RMSE are extracted from these distorted signal with various window size like 5, 10, 15 and 20 using equations as mentioned in [2]. Total of 96 datasets are developed from a distorted signal with various noise and THD levels, window size. The complete information about all these data sets are shown in Figures A1-A3 in Section Appendix A. This complete data is published in mendeley data repository [32]. In the label column of each dataset consists either 0 or 1. 0 represents Non-Zero Crossing point (NZCP) and 1 represents Zero Crossing Point (ZCP).

Logistic Regression Model
Logistic regression model [33] is useful for the binary classification problem and the architecture is shown in Figure 1. Logistic Regression, like linear Regression, is a statistical machine learning method. It categorises the data by looking at outcome variables at the extreme ends. Logistic regression generates a logistic curve with a range of 0 to 1 [34]. Sigmoid activation function is mathematically modelled as shown in Equation (1) and it gives the output value between 0 and 1 [35]. As the Sigmoid activation function is in LGR model that is useful to predict the probability to exist ZCP in the signal. Complete training algorithm to update the model parameters (m1, m2, m3 and m4) and bias parameter (b) using stochastic gradient decent (SGD) optimizer [36] is presented in Algorithm 1. The cost function that is used in this problem is binary cross-entropy [37,38] that is mathematically modeled as shown in Equation (2). Training process of logistic regression model with sample calculations is presented in Appendix B.  for sample = 1, 2, . . . , N do 4: Predict the label y p using Equation (3). 5: Update the model parameters using Equations (4)-(8)  (9) Accuracy = Numbero f samplescorrectlyclassi f ied Totalnumbero f samples (9)

Result Analysis
Logistic regression model is trained with all 96 datasets which are created with various levels of noise, THD and window size in Google Colab. The performance of all these models is observed in terms of accuracy.

Data Analysis
Statistical information like mean and standard deviation of a few datasets i.e., ZCP-Noise-25, ZCP-THD-25 and ZCP-NTHD-37 that are created for this work are presented in Table 1. From the Table 1, it is observed that features like slope (m), intercept (c), correlation (R) and RMSE are in different ranges i.e., m in range from −1243 to 6546, c in range from −512 to 358.2553, R in range from −1 to 1 and RMSE is in range from −1 to 93. In order to train the machine learning models all these data samples are normalized between 0 and 1 using Min-Max Scalar method as shown in Equation (10).
Box plot is developed based on data available in dataset ZCP-Noise-01 in order to observe the outliers in the data and presented in Figure 2. From the Figure 2, it is observed that input features in dataset ZCP-Noise-01 has outliers as the tested signal is a distorted signal with noise level of 10%. Similarly for other datasets also outliers are observed using box plot. Histogram plot is developed based on data available in dataset ZCP-Noise-01 in order to observe the distribution of the data and presented in Figure 3. Correlation among various features like slope, intercept, correlation and RMSE in various datasets like ZCP-Noise-25, ZCP-THD-25 and ZCP-NTHD-37 is observed using correlation plots as presented in Figure 4. From the Figure 4, it is observed that there is correlation more than 50% between slope and intercept.

Machine Learning Model Performance on Distorted Signal with Noise
Logistic Regression Model(LGR) model is trained and tested on datasets which are created with a distorted sinusoidal signal with various noise levels from 10% to 60%. Testing and training accuracy for LGR model on these 28 datasets are presented in Table 2. The window size that gave better testing accuracy is considered as optimal LGR model to predict the ZCP in distorted signal for each noise level and is highlighted in Table 2. from Table 2, it is observed that LGR model is able to predict NZCP with better accuracy in distorted signal for each noise level with window size 5. The information about correctly and wrongly predicted ZCPs are presented in Table 3. From Table 3, it is observed that LGR model is unable to detect true ZCP points but is able to detect all non-ZCP points in the distorted signals due to noise.

Logistic Regression Model Performance on Distorted Signal with THD
Logistic Regression Model(LGR) model is trained and tested on datasets which are created with a distorted sinusoidal signal with various THD levels from 10% to 60%. Testing and training accuracy for LGR model on these 28 datasets are presented in Table 4. The window size that gave better testing accuracy is considered as optimal LGR model to predict the ZCP in distorted signal for each THD level and highlighted in Table 4. The information about correctly and wrongly predicted ZCPs are presented in Table 5. From Table 5, it is observed that LGR model is unable to detect true ZCP points but is able to detect all non-ZCP points in the distorted signals due to harmonics with THD levels.

Logistic Regression Model Performance on Distorted Signal with Harmonics and Noise
Logistic Regression Model(LGR) model is trained and tested on datasets which are created with various THD and noise level combined distorted signals. Testing and training accuracy for LGR model on these 40 datasets are presented in Table 6. The window size that gave better testing accuracy is considered as optimal LGR model to predict the ZCP in distorted signal for each THD and noise level combination and highlighted in Table 6. The information about correctly and wrongly predicted ZCPs are presented in Table 7. From Table 7, it is observed that LGR model is unable to detect true ZCP points but is able to detect all non-ZCP points in the distorted signals due to both noise and harmonics.

Performance of the LGR Model on Test Signal
A test signal with noise level 10% and peak value of fundamental component 1V is generated in MATLAB. This test signal has total 3 zero crossing points and 48 non-zero crossing points. Feature like slope, intercept, correlation and RMSE are extracted from test signal and processed through LGR model to detect non-zero crossing points. Figure 5 shows test signal, actual non-zero crossing points and predicted non-zero crossing points. From the Figure 5, it is observed that the developed LGR model able to detect all non-zero crossing points, but unable to detect zero-crossing points.

Comparative Analysis
Comparison of performance of logistic regression model based on it's performance on zcp detection in a distorted signals with noise 10% to 60% , in a distorted signals with THD 10% to 60% and in a distorted signals having noise level 10%, 30%, 60% and THD level 20%, 40%, 60% in terms of testing accuracy is presented in Figure 6. From Figure 6, it is observed that logistic regression model is able to detect zero-crossing points on noisy signal with good accuracy than on harmonic and combined signals.
Comparison of logistic regression model based on the performance on zcp detection in a distorted signal with various noise levels and harmonic levels in terms of testing accuracy is presented in Figure 7. From Figure 7, it is observed that logistic regression model is able to detect zero-crossing points on noisy signals with good accuracy than harmonic signals.

Conclusions
Accurate non-zero crossing point detection in a distorted signal is a complex task and essential to operate the power system network without power quality issues, protect the system against faults and for efficient power electronics converter controller design. In this study, performance of the logistic regression model on accurate NZCP detection in a distorted sinusoidal signal is discussed.
Distorted sinusoidal signals are generated in MATLAB with various noise and THD levels and from each signal features like slope, intercept, correlation and RMSE are extracted in order to prepare the data to train and test the logistic regression model. From the observations based on simulation results, logistic regression model is performing slightly better to detect NZCP in distorted signal with noise than harmonics and combined signal. From the observations based on simulation results, logistic regression model is able to predict non-ZCP points with good accuracy but is unable to detect ZCP as the model is highly biased towards non-ZCPs as more samples in dataset belongs to Non-ZCP.
NZCP detection problem is further extended by incorporating the voltage swell in the sinusoidal signal by considering other machine learning models like decision tree and random forest, deep learning sequence models like recurrent neural network, long-short term memory and gated recurrent unit. Data Availability Statement: Active power load data used to train and test machine learning models is available at https://data.mendeley.com/datasets/d2hs6zt8gw/1, accessed on 7 February 2022.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript:  Figure A1. Information about distorted signal with noise. Figure A2. Information about distorted signal with harmonics. Figure A3. Information about distorted signal with noise and harmonics.

Appendix B. Training Procedure for Logistic Regression Model
In order to explain the training process of the logistic regression model shown in Figure 1 using Algorithm 1, sample data shown in Table A1 is considered. Learning rate η is considered as 0.1. Initial random model parameters are shown in Table A2. Calculate output of LGR model using Equation (3).  Table A3. Calculate output of LGR model using Equation (3).   Table A4. Calculate output of LGR model using Equation (3).   Table A5.   Training process for logistic regression model using stochastic gradient descent optimizer is completed, new model parameters and bias parameter are shown in Table A6.  Table A1 and model parameters shown in Table A6 are used to predict the output label using Equation (3). Confusion matrix is shown in Table A7. Accuracy [39,40] of the given logistic regression model is calculated using Equation (9) and it is equal to 100%. Accuracy = TNZCP + TZCP TNZCP + TZCP + FNZCP + FZCP = 0 + 1 0 + 1 + 0 + 0 = 100%