Low-Cost Voltage Zero-Crossing Detector for AC-Grid Applications

Abstract Renewable energy sources and energy storage devices are becoming more popular. Some of them like small hydropower turbines, wind turbines and diesel generators produce AC voltage with different frequency and voltage than the main grid. For them power electronics converters are necessary. Power electronics converters presented in industry use two or three level energy conversion, although direct AC to AC converters exist, but one of the main problems is the switch commutation when current or voltage is crossing the zero point. Zero crossing sensors are used to solve this problem. They consist of current or voltage measurement unit and zero crossing detector. Different approaches are used for zero crossing: hardware or software. Hardware approach is simple but it has low precision. Software approach has high precision but it is complicated and expensive. In this paper a simple low cost high precision approach is presented. It takes all advantages from both approaches. While tested with two types of microcontrollers the precision of experimental measurement is 25 μs - 40 μs.


I. INTRODUCTION
Alternative power sources are being pushed into reality.By the use of smart grids and micro grids they are expected to be in most of the individual households [1].This does not mean the end of the conventional power grid.It is being planned that during certain periods households with alternative power sources will perform as a small scale power plants and deliver additional power to the grid [2][3].During the periods when alternative power is not available those households will act as power consumers.
While current power grid is AC some experts claim that the future power grid will be DC or high frequency AC [4].Nevertheless to begin the implementation of smart grids now it is necessary to connect household power sources to an AC grid.Most of alternative power sources are DC such as solar cells, fuel cells, backup battery packs.In the case of power generators such as wind turbines, hydropower turbines and diesel generators the power primarily is produced in the form of AC.Typically it is rectified to DC and fed to a converter which performs some sort of voltage stabilization or conversion and in the final stage produces AC synchronized to the grid frequency.Basically two or three conversions are performed: AC/DC, DC/DC, DC/AC or AC/DC, DC/AC.The use of DC link involves extra costs in the form of expensive passive components.DC link can be avoided by using direct AC/AC converters as matrix converters [5].As the converter has alternating voltage at its input it is necessary to detect the polarity of this input voltage in order to perform correct control of converter switches.Typically bidirectional switches are used to form the selected converter topology.The input voltage polarity determines which one of the bidirectional switches will be operating.Therefore it is necessary to determine the input voltage polarity with maximum speed and precision.The origins of fast polarity detectors can be traced to zero crossing detectors, which at some instances are the same devices.Similar methods with more complex computations are used to synchronize to the grid [6][7][8][9][10].One example is Phase locked loop or PLL systems.PLL systems can synchronize two signal phases or give information about signal phase difference.PLL cannot give precision information about zero crossing.But in some application like direct AC/AC converters [5] or solid state relays zero crossing detection is necessary.
Direct AC/AC converters or matrix converters have more complicated control system than the conventional indirect AC/AC converters.One of the main issues to overcome in matrix converters is to perform fast commutation of bidirectional switches without overcurrent and overvoltage spikes when converter is feeding an inductive load [5].
The reason of overcurrent and overvoltage is the absence of freewheeling path in bidirectional switches.The commutation has to be actively controlled all the time with respect to two basic rules.The first rule is that two bidirectional switches of input cannot be switches instantly otherwise the switches will be destroyed by overcurrent.The second rule is that the bidirectional switches for each output phase should not all be turned off at any instant of time otherwise the switches will be destroyed by overvoltage.A few multistep strategies are used to solve this problem: four step commutation strategy, two step commutation strategy controlled with current or voltage [11][12][13][14][15][16].
One of the main problems of all multistep strategies of matrix converters is to detect the moment of zero crossing to realize the switch commutation.One of the possible solutions is to use dead-time technique like in [16].
As an example Fig. 1 presents a two phase to single phase matrix converter with the use of four step commutation strategy.In the following description switch S1 is turned off, and switch S2 is turned on.Current direction is negative (ILOAD < 0).
When a commutation of S2 is required, the current direction is used to determine which device of the active switch is not conducting.This device is then turned off.In this case, device S1:2 is turned off.The device that will conduct the current in doi: 10.2478/ecce-2014-0015 the incoming switch is then gated, S2:1 in this example.The load current transfers to the incoming device either at this point or when the outgoing device S1:1 is turned off.The remaining device in the incoming switch S2:2 is turned on to allow current reversals.This process is shown as a timing diagram in Fig. 2; the delay (tdelay) between each switching event is determined by the device characteristics [5].
All the current commutation techniques for matrix converters depend on the output line current direction.It is difficult to be reliably determined in a switching power converter.To solve this problem it was decided to build a simple zero crossing detector with maximal possible precision and low cost.

State Representation
Fig. 2. Four-step semi-soft current commutation between two bidirectional switch cells.

II. DETECTOR CLASSIFICATION
Zero crossing detectors can have two types of output signals.In one case the detector generates a narrow pulse when the input signal value is zero.In other case it outputs high level signal during positive input and low level during negative input.The zero crossing is supposed to be during the transition between positive and negative input signal.To detect the input voltage polarity the second case is the useful one.Voltage polarity detectors can be classified in two main categories: hardware and software detectors.Hardware detectors rely solely on hardware circuitry which typically consists of optocoupler or comparator/operational amplifier.Software detectors have some sort of input signal isolation and scaling circuitry.The scaled signal is fed in to some sort of computational device which performs signal filtering and analysis to determine the signal polarity.

A. Hardware Solutions
For simple purposes like AC dimmer applications rather low performance zero crossing detectors are used.Some companies manufacture dedicated integrated circuits for zero crossing detectors for thyristor and triac gate signal synchronization.Typically these solutions lack high speed which leads to phase delay.
There are multiple discrete element circuits that under certain circumstances can give decent performance.The simplest circuits (Fig. 3.) involve the use optoisolators [17].These types of circuits have the benefit of signal isolation but on the other hand the input diode forward voltage drop leads to voltage detection error.Comparators (Fig. 4.) can be used to compare input voltage to ground and achieve fast operation [18].These setups have the disadvantage that comparators can detect voltage dips (noise) in the grid and produce incorrect output signal.Comparator can generate multiple pulses during the input signal transition through zero which can be regarded as the main drawback of this type of detector.It is possible to use differential line receiver integrated circuits to achieve fast polarity detection [19] but they have the same drawback as comparator circuitsinput voltage distortions can cause faulty output signals.
The authors of [20] propose a circuit (Fig. 5.) that uses an operational amplifier as the main voltage polarity detector.The described circuitry has shown good performance with distorted input voltage.It is not mentioned in [21] but it can be estimated that the circuits input capacitor will produce a phase delay at the output which is quite undesirable.

B. Software Solutions
Software polarity detectors can be divided into two groups.The first group uses one of the hardware solutions to generate a pre-filtered input signal for the calculation device, e.g. a microcontroller.The second group processes the input signal as directly as possiblemicrocontrollers cannot have full grid voltage at its inputs so a voltage divider must be used and signal isolation is preferred.In both cases the microcontroller is programmed to perform some sort of filtering and analysis to determine whether input signal value is zero or not.Additional phase delay compensation and detector calibration can be performed in software [6], [8].
Literature proposes rule filtering to ignore polarity change in the middle of AC grid half period.Enhanced zero crossing can be determined using interpolation of optoisolator detector circuit [17].Fixed or dynamic hysteresis control can be used to improve comparator circuit noise immunity.References [21] and [22] propose to use adaptive filters to remove disturbances and obtain the base harmonic of the input signal.The use of neural network is promoted in [23].Comparators are used as pre-filters for neural network inputs.Advantage of neural network is its relatively easy implementation in a digital signal processor.The system is written to have good performance if proper feedback signal is used.
All represented software solutions are complicated and expensive.This work presents a simple solution consisting of software and hardware methods together.That approach simplifies zero crossing detection without precision losses.

III. SIMPLE HIGH PRECISION ZERO CROSSING DETECTOR
The proposed simple high precision zero crossing detector developed and tested within this research is a mixed solution which consist of a hardware as well as a software part.
Hardware part is represented in Fig. 6.It consists of voltage sensor, signal shifter and microcontroller.

A. Voltage Sensor
Voltage sensor reduces the input voltage and provides galvanic isolation.In reality it is not a voltage sensor but a current sensor (hall detector) which reduces input current by KN ratio.Input resistance R1 is used to set the input current.Output resistance RM is used to produce output voltage.Relationship between the input and output voltage is:

B. Voltage Shifter
Output signal of voltage sensor has a negative part so it cannot be used with microcontroller.A voltage shifter is used to solve this problem Voltage shifter is based on an operational amplifier summation schematic.It has two gains: voltage amplifying gain and voltage shift gain.Voltage amplifying gain represents resistors RG and R2.Shifting gain represents resistors RG, R3 and reference voltage VREF.

C. Microcontroller
Significant part of zero crossing detector system is microcontroller with applied software.Microcontroller reads signal of voltage Vout_s using ADC peripheral unit from voltage shifter unit pin.Measured signal is processed with microcontroller built-in firmware.Microcontroller generates the output signals which determinate input voltage polarity with high precision.

IV. ZERO CROSSING DETECTOR FIRMWARE
Software part of the zero crossing detector has quite a simple algorithm (Fig. 8.).Most part of the work is done by the peripheral devices: ADC, Timer0 and inputoutput ports of microcontroller.CPU has to calculate the average value of input voltage.
First step is to measure sensor output signal without any AC input voltage part.It is necessary to find zero point taking into account that input voltage value has distortionszero point zone is formed.Zero zone or ZZ is zero point with bias from input signal by a few points.
After zero zone identification AC value is connected to sensor and defines current state of the input signal.To realize it, during the first time ADC measures input voltage signal value a few times and calculates the average value, then compares it with ZZ values.If it is higher than ZZ value the microcontroller sets 1 to positive output otherwise sets 1 to negative output and starts ADC.If input signal value is already within ZZ it starts Timer0 and stops ADC.
Timer0 is necessary to relieve ADC and CPU for some other works.It forms a delay until the next ADC cycle.Timer0 counts from zero when it is activated until the ZZ value in time domain.ADC measures input signal a few times with small step between measurements.After that the CPU calculates average value of all measurement samples.
The calculated value of Vout_s is compared with ZZ value and depends on activate positive or negative output signal.Voltage measurement is repeated until the measured value of Vout_s is in ZZ range.Afterwards Timer0 is activated and all process is repeated.Simplified time diagram of zero crossing detection is presented in Fig. 7. Timer0 delay value depends on input signal frequency range value and precision of measured input signal.Frequency ranges are specified by standards, or by measurements.Precision of measurement signal depends on microcontroller's ADC and signal conversion devices.The presented above approach can be used with different kinds of microcontrollers.It depends on price of the device.In this work two kinds of microcontrollers were used.One was TMS320F28335 from Texas instruments.It is a quite expensive device, but the represented approach can be paralleled with many other tasks.The second device is a cheap MSP430F2554.But if the presented approach is used then it will be difficult to realize many tasks simultaneously.

V. RESULTS
Results of Zero crossing detection are presented in Fig. 9, Fig. 10 and Fig. 11.AC grid voltage is measured.LEM LV-25P sensor is used to reduce the input voltage.For the shift-up a circuit based on LM6171BIN operational amplifier is used.Texas instruments C2000 series TMS320F28335 microcontroller with high speed ADC and MSP430F2254 is used.The output signal of the microcontroller and input signal is compared with Fluke 199C oscilloscope.Fig. 12 and Fig. 13 show the results with MPS430.They were measured with GWINSTEC GDS-122 oscilloscope.Both approaches have similar precision but MSP430 CPU resources are fully used to work on zero crossing detection.Diagrams represented in Fig. 8 and Fig. 9 show that the output signal is lagging on rising edge by 20 µs and on falling edge by 25 µs.The results do not depend on input voltage magnitude value.It depends only on the input frequency distortion and latency of microcontroller and input devices latency.Generally latency of 25 µs is a good result.

A. Comparison with other solutions
It is difficult to calculate the value of a software system.But if being taken into account that for difficult mathematical calculations a powerful microcontroller is necessary then this solution price is relatively high.

VI. CONCLUSIONS & SUMMARY
The system is very fast and has high precision devices inside if using TMS320F28335 microcontroller.It has high precision and simple schematic and software.It can be used for high precision solutions like systems with bidirectional switches and control systems of resonance converters.The use of digital signal controller TMS320F28335 makes the system quite expensive.A cheaper MSP430F2254 microcontroller can be used as well.However, for most of the time it can work only for zero crossing detection.The main reason of this problem is the absence of hardware multiplier with which the calculation of average value would be faster.
The price of this system could be reduced by using cheaper elements like low cost voltage and current measurement sensors and so on.
Nowadays performance of microcontrollers grows very fast, and price reduces with the same speed.In future the same goals will be easy to achieve using optimal software solutions on powerful chips and with optimal programming software.Digital filters, adaptive system and so on could be used for this purpose.More research is necessary to find an optimal solution for the immunity of the input signal distortions.
VII. ACKNOWLEDGMENT Development of this article is co-financed by the European Regional Development Fund within the project "Intellectual Hybrid Uninterruptible Power Systems and Component Development and Research to Improve Energy Efficiency", agreement No. 2010/0225/2DP/2.1.1.1.0/10/APIA/VIAA/160.