Measure the Frequency of Grid Voltage and Phase Difference between Current of Load and Grid Voltage


Voltage range     : 40 V ~ 280 V (Vrms)
Current range     : 0 ~ 200 mA
Frequency          : 35Hz ~ 70Hz
Phase differnece : 0° ~ 90° (lead or lag)


        Voltage grid should be is 50Hz or 60Hz. But in reality the frequency of the grid are sometimes shifted slightly, so be below or above 50Hz or 60Hz. The stability of the voltage frequency is one indicator of the quality of electrical voltage. The stability of the power grid's frequency is a health indicator of the grid's ability to respond to changes in supply and demand of electricity. Although there are other grid characteristics that can be measured,
frequency is less affected by local disturbances than other attributes like voltage and current.

       As we develop more energy resources, these resources need to be integrated efficiently and cost effectively with our existing energy infrastructure – the power grids. Alternating Current, or AC, power generators need to be synchronized to provide optimal service and electric energy supply. When we consume electricity, we place a load on the power grid. We can develop smart appliances that can measure the grid's frequency and the health of the grid's power supply; then respond appropriately by scheduling or reducing load to help maintain grid stability.
      Most of the electrical load current draw currents that have a different phase with the voltage supplied to him. Current on inductive load is lagging behind the voltage. Current on incandescent sometimes precedes the voltage of grid. Fact, the current in the electrical load that use of switching power supply is extremely precede the voltage.
      In order to achieve maximum efficiency in electricity usage, the phase angle between the currents must be equal to the voltage, in other words, the current must be in phase with voltage. Real power comparison of voltage multiplied by current is called the power factor.
Ideally, power factor of load is to be one.
      Measuring instrument of real power and power factor both analog and digital has been widely available. However, a measurement to the phase difference between voltage and current flowing in the grid is still rarely found. The need for these measuring devices in the lab sometimes still constrained. This paper describes the results of the implementation of the ATmega8535 microcontroller as a major component of the device for measure the frequency of the grid voltage and measure the phase difference between voltage and current flowing in the load. Furthermore, the expected applications can be developed for the measurement of the values of voltage and current RMS, power and power factor, even down to the power analyzer  based microcontroller.
Programs in this microcontroller can be applied to several other AVR microcontroller series if this program will not be developed further.

The Need for Phase Difference Measuring Instrument
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current
Voltage and Current Converter
The Signal Conditioning
The use of the microcontroller ADC
Frequency Measurement
Phase Difference Measurement
Output Display Format

click here for more information

Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current


      The fundamental frequency of the current flowing to a load will be the same to the fundamental frequency of the voltage supplied to it. Due to the current usually have more harmonic components than voltage, frequency measurement easier done on the voltage supplied to it.
      The frequency of the grid voltage in Indonesia is 50 Hz, whereas in some other countries is 60 Hz. To reduce the calculation errors caused by harmonic components, frequency range of the measurement values can be restricted so that the harmonic frequencies will be ignored. To increase accuracy, measurements of the frequency value for the low frequency signal, is done by first measuring the value of the period, and not by counting the occurrence of waves. Nevertheless, the accuracy of the measurement result is displayed in the format of three digits such as the frequency measuring instruments for grid voltage.
best to avoid using voltage and current sensors
      Detection of voltage and current values does not use a voltage and current sensor. Generally, the voltage and current signal was converted to DC voltage signals by a sensor and then fed to the ADC input. But this will make the voltage and current cannot be analyzed further more.
      In this application, the value of alternating voltage which has been normalized is fed directly to the ADC input of the microcontroller. Current can be detected by the ADC after converted into a voltage. 



The Need for Phase Difference Measuring Instrument  
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current
Voltage and Current Converter
The Signal Conditioning
The use of the microcontroller ADC
Frequency Measurement
Phase Difference Measurement
Output Display Format

Voltage and Current Converter

Voltage-to-Voltage Converter:
                  Input                      Output
Vrms      0 ~ 280V        0.57 ~ 1.77V with 5VDC offset or
Vpp        0 ~ 400V        0.80 ~ 5.00V with 5VDC offset

Current-to-Voltage Converter:
                  Input                      Output
Irms      0 ~ 500mA      0.00 ~ 1.77V with 5VDC offset

      In order for the grid voltage and current flowing in the load can be read by the ADC microcontroller, voltage signal are converted using a voltage-to-voltage converter that is step-down transformer. While the current signal converted using current-to-voltage converter that is a step-up transformer which has very low inductance at primary coil and high inductance at secondary coil. For this purpose, we can use the adapter transformer. In this case, I_out and I_in fed to the low voltage coil and we get v0 and ground from high voltage coil as Figure 1.

Figure 1
      At the ADC input of microcontroller, we found clipper diode that can be utilized as a main component to build a zero cross detector that can be used to measure the period of input voltage. But in this study, the input voltage that is usually sinusoidal form will be entered as a whole, so that in future this system can be developed for the calculation of RMS values and power.

The Need for Phase Difference Measuring Instrument
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current

The Signal Conditioning
The use of the microcontroller ADC
Frequency Measurement
Phase Difference Measurement
Output Display Format

The Signal Conditioning


      v0 and v1 fed into the Signal_Conditioning block to have normalized so that the maximum voltage is Vpp = 5V. In this block, we add 2.5 V DC offset voltage to both signal so they have a voltage range of 0 to 5 V according to the ADC limits.
      The phase shift will occur while converting grid voltage to low voltage and converting current to voltage. To compensate them, on the block Signal_Conditioning, there is the phase shifting circuit that will adjust the phase again. This circuit also functions as a first-orde high-pass-filter. These filters are used to reduce the amplitude values of harmonic components which might make the calculation value of the frequency and phase difference to be wrong.
     The output of this block is a voltage signal v0' that it’s shape like the grid voltage, and voltage signals v1' it’s shape like the current grid. Phase shift between v0' and v1' equal to the phase shift between voltage and current grid.


The Need for Phase Difference Measuring Instrument
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current
Voltage and Current Converter

The use of the microcontroller ADC
Frequency Measurement
Phase Difference Measurement
Output Display Format

The use of the microcontroller ADC



     v0' fed to the input channel 0 of the ADC, while v1' fed to the second channel of the ADC input. Another channel ADC inputs are connected to the Ground to reduce the effects of cross-talk between the two entries. Voltage signal v0’ which represent the grid voltage and signal voltage v1’ which represent the load current, sampled by the ADC of microcontroller.
     The higher the ADC clock, so sampling process will be faster, but tend to diminish the accuracy of the ADC. In order to obtain fast conversion time but the accuracy of eight bits, then the ADC is run with prescaler = 16. This means that the ADC is run using a clock frequency of 691 kHz. Time to do a conversion or the conversion period (tc) is 14 times the clock period or about 20 microseconds. At 50 Hz input signal, sampling the voltage signal at intervals of 20 microseconds will provide a maximum error 0.1%


The Need for Phase Difference Measuring Instrument
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current
Voltage and Current Converter
The Signal Conditioning
Frequency Measurement
Phase Difference Measurement
Output Display Format

Frequency Measurement



     Measurement of the frequency of the grid voltage is done by first measuring the time between two successive foot of the mountain, as Figure 2. At the time of the grid voltage moves up above 2.5 V, a timer is run in normal mode. And when the value of grid voltage moves up on the 2.5 V anymore, timer 1 is stopped.  Timer 1 run during Δt1.
 
Figure 2
     Timer 1 is 16-bit timers. This timer is operated with prescaler = 8. Time for counting one digit is tT1 = 0.723 microsecond. The result of count is 16 bit hexadecimal value stored in a register TCNT1 that formed by pairing 8-bit registers TCNT1H and TCNT1L.
For 50 Hz input signal, the counting result is 6C00h. To avoid detection of the harmonic frequency, the frequency restricted from 35 Hz to 70 Hz. So that, the valid value of TCNT1 is from 9A49h until 4D24h. Maximum error of this counting is 0.004%.



The Need for Phase Difference Measuring Instrument
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current
Voltage and Current Converter
The Signal Conditioning
The use of the microcontroller ADC
Phase Difference Measurement
Output Display Format

Phase Difference Measurement

      After the timer 1 is stopped, the value TCNT1 immediately saved to memory. Furthermore, the timer run again for detecting the phase difference. This timer is run in CTC mode (Clear Timer on Compare Match), which means the timer will be reset when the count equals to the OCR1 register value. OCR1 value assigned half of the value of the first count results as Equation 1.

 
    (Eq. 1)
 

     This timer will be stopped again when the voltage value v1' move to rise above 2.5 V as Figure 3. To be able to detect v1’, just after the timer run again, the ADC input multiplexer is changed to channel 2.  This timer will count for the duration of time °Δt2. In theory, the phase difference (θ) for the case that the current lags behind the grid voltage is calculated using Equation 2.
    (Eq. 2)


Figure 3
     In  the program, TCNT11 is the result of a count by the timer during t1, TCNT12 is the result of a count by the timer during t2, and calculating the phase angle difference following the Equation 3. 
 
   (Eq. 3)
 

     The equation above can not be applied to cases that current precedes the grid voltage. In this case, the timer run until at v1' move falls below 2.5 V as Figure 4. Calculating the phase difference following the Equation 4.
    (Eq. 4)

Figure 4
     In  the program, TCNT11 is the result of a count by the timer during t1, TCNT12 is the result of a count by the timer during t2, and calculating the phase angle difference following the Equation 5.


    (Eq. 5)
      Since the equation for calculating the phase difference in the case where the current lagging against grid voltage and currents precede the grid voltage is different, then there must be an algorithm that can check the occurrence of such current. For that, after the timer is run a second time, the microcontroller immediately check the voltage at v1'. If
Δt2 starts with the value of voltage is less than 2.5 V as Figure 3, the current lags behind voltage considered.  Phase difference calculation was done using Equation 3. However, if Δt2 begins with a voltage value equal to or greater than 2.5 V as Figure 4, it is considered current precedes the voltage. Phase difference calculation was done using Equation 5.
Special cases the use of Equation 5 occurs when the current in phase with voltage.  This case resembles the illustration in Figure 4, voltage value slightly more than 2.5 V. In this case, the value of Δt2 will be equal to Δt1/2, so that according to Equation 5, the value of phase difference θ = 0.



The Need for Phase Difference Measuring Instrument
Measure the Frequency of Grid Voltage rather than Measure the Frequency of Current
Voltage and Current Converter
The Signal Conditioning
The use of the microcontroller ADC
Frequency Measurement

Output Display Format

Output Display Format


     Microcontroller operated with clock frequencies fcpu = 11.0592 MHz. With this frequency, we can set up communication with the computer using USART for different variations of the bit rate with 0% error. In this study, the frequency and phase difference value is stored in the log files using Hyperterminal. 
     Maximum errors caused by the ADC is 0.1%. While the error caused by the timer can be ignored because it is much more smaller than the error caused by the ADC. So that the value of the frequency of the grid voltage and the value of the phase difference between voltage and current can be displayed in the format of three digits. The value of the frequency range from 35.0 Hz to 70.0 Hz can be displayed with format XX.X Hz, whereas the phase difference value with a range from 0 to 90° shown enough with the format XX°. View the output can be coupled with information that the electric current is in phase, lagging behind the voltage or preceding against to the grid voltage.