3 Phase Voltage Measurement using Atmel AVR Microcontrollers

3 Phase Voltage Measurement

3 Phase voltage measurement is a little bit tricky task. I will start from the basics and give you details step by step.

Specification of this Project

  • Measure voltage of each phase
  • Measure angle of each phase
  • Gives Line to Line voltage as well
  • All results display on 16×2 LCD
  • Less components needed
  • Cheap system

Difference between 3 Phase voltage and 1 Phase

Let’s start with the basics of 3 – Phase voltage.

In 1-Phase voltage you have to take care about only one phase. So during measurement you don’t have to worry about voltage angle. But in 3-phase system you have to take care of all three phases and their present angle as well. Angle of voltage is very important factor in 3-phase systems, it tells that which phase are we dealing with. At a identical time all three phases have different angles. So we have to measure it as well. Look at the figure below:

3 Phase Voltage waveform with vector diagram
Figure1: 3 Phase Voltage waveform with vector diagram

There are two diagrams present in the figure above. 3 overlapped voltage waveforms are showing the real version of 3 phase voltage through oscilloscope. 2 phases are 120 degrees apart to each other and 3rd phase is 240 degree apart to first phase. You can take these phase angles as -120,0,120 degrees as well.  It depends on the reference phase you take. So during measurement of 3 phase voltage, we have to measure these angles as well.

Hardware Part:

In hardware part we will study about the circuit diagram and components of the system. I used a 16×2 LCD to display our results. To save us from extra wiring I used 4 bit interfacing of LCD with Atmega8.

Components Needed

Click on the component name to buy the product from reliable sources:

 Now look at the complete circuit diagram:

Circuit Diagram for 3 Phase Voltage Measurement
Figure 2: Complete Circuit Diagram

Three voltage sources present at the right side of the diagram is basically star connection of 3 phase voltage source.  It is output of 3 phase transformer.

How to step down the 3 Phase Voltage?

3 Phase step down transformer at such small level is hard to get. So there is an easy way to step down the 3 phase voltage using 3 single phase 220V/6V or 110V/6V transformers. Connect primary side of three transformers with each phase of source and neutral will be common.  Take a look on the figure below to understand the connections.

Step Down the 3 phase Voltage
Figure 3 : Connections to Step down 3 phase voltage

This connection is basically star to star(Y-Y) connection.

Note: In circuit diagram I did not use voltage dividers while giving voltage to IC and ATmega8 microcontrollers for simplicity. Before giving the voltage to the IC and ATmega8 microcontroller, check the output voltage first. If peak of the voltage is more than 5 Volts then use voltage dividers to further step down the voltage.

3 Phase Voltage Source in Proteus:

To make a 3-phase voltage source in proteus, the setting of each source should be as shown is figures below:

Protues Setting for Voltage Source
Figure 4: Setting for 1st phase


Protues Setting for Voltage Source
Figure 5: Setting for 2nd phase


Protues Setting for Voltage Source
Figure 6: Setting for 3rd phase

I set frequency of 50Hz to the each source and give time delays to second and third source. When you will convert this time delays into angle you will get 120 and 240 degrees respectively. I will explain this time delay formula in coding part.

I have divided remaining discussion into two parts.

  1. Voltage measurement part
  2. Angle Measurement part

Voltage Part:

Let’s start with the voltage measurement. We will measure the all 3 phases of voltage by first converting it into DC then fed it to the microcontroller Atmega8 which is from the family of Atmel AVR microcontrollers.

AC Voltage Measurement
Figure 7: Voltage Measurement Circuit

As you see in the figure, a diode is present to rectify the voltage and the capacitor will remove the ripples.  Zener is here just to protect the Atmega8 microcontroller. In case of any surge voltage it will remove that surge.


Angle Measurement Part:

To measure the angle I used the zero detection technique which is implemented through 3 amplifiers. These amplifiers are working as comparators here. In zero detection technique the comparators wait for the zero point. Whenever a zero point came, they give a high signal at the output. Let’s understand this technique through the circuit diagram.

AC Voltage Angle Measurement
Figure 8: Angle Measurement Circuit

I connected ground (zero level) to the non-inverting (+) pin of comparator. A sine wave is coming on the inverting (-) pin of comparator. In sine wave, zero points came in each cycle. So whenever these points came a High signal is generated on the output of comparator which will read by microcontroller.

Every comparator will give high signals to the microcontroller. Time consumed between one high signal to other high signal is basically our required angle. Let’s have a look on coding part to understand this technique clearly.

Coding Part:

If you have knowledge of ADC and 4 bit LCD interfacing then the remaining tricky part in the coding is only angle measuring part of 3 phase voltage. I am not going to explain the voltage measuring part because it is exactly same as single phase AC voltage measurement. Let’s just stick with the only demanding part here.

3 Phase Voltage Waveform
Figure 9: 3 Phase Voltage Waveform

Take a look on this figure again. Three white circles are basically neutral or zero points of three phases. We just have to measure the t1 and t2 which are time differences of three phases.  If we get these t1 and t2 then we can easily get the above angles as well. Understand the coding below and you will understand the whole scenario here. Don’t worry you can get whole code and simulation at the end of article.

void loops1(){
if ( (PINC &(1<<4)) != 0  ){
TCCR1B = 0x01; // Start timer1 at Fcpu/1
if ( (PINC &(1<<5)) != 0  ){
TCCR1B = 0x00;//stop timer1
g=TCNT1;//getting number of counts

At PINC.4 of Atmega8 Microcontroller, output of the comparator of phase B is connected and at PINC.5 output of the comparator of phase C is connected. So when zero crossing of phase B will occur, a high value will be generated and loop will break and at the same time timer1 will start counting. After when zero crossing of phase C occur, a high value will be generated and timer1 will stop counting. The TCNT1 value (which is counter register) of Timer1 will be stored in ‘g’ variable.

Now, what will happen after getting this counter value? We have to convert this counter value to angle. Look at the code below to learn how to convert the counter value to angle.

int calculatioins(){ 
  unsigned int k=0;
 //To complete number of counts
 //To convert  into seconds
 float pf=(float)g/1000000;
 //To convert seconds into degrees
 pf=pf*50*360;//here frequency = 50hz
 k = pf;
 return k; 

I hope you got the answer. If you have any query comment below. We are looking forward for your feedback and Don’t forget to like our facebook page. 🙂

To download Complete Code click the links below:

Proteus File Complete Code

28 thoughts on “3 Phase Voltage Measurement using Atmel AVR Microcontrollers”

  1. hello sir i want to display the voltage in each line, since i don’t have a neutral wire how can i calculate the voltage in each line ??

  2. I have measures line to neutral voltage of all three phases but i want to measure line line voltage. Can you tell tell me how to measure line to line voltage?

  3. It is one of the good method for the capture of zero crossing and hence for the measurement of phases. Your circuit must have some problem. Check your circuit, specially the comparators and their connections.

    1. no, it is not the circuit problem, because I also tested from a function generators directly. If I change the code to find the maximum value from the loop, than the result is accurate, but I am just trying to figure it out why….really strange.

      1. There is a mistake I just found out in my code.
        Voltage 3 routine reading from same ADC channel as Voltage 2. Voltage 3 must read channel 2 not 1
        v[i] = adc_read(1); must be
        v[i] = adc_read(2);. Otherwise code is okay.

  4. I have so many problems using this method to read the phase. How can you be sure when PINC(1<<4) !=0 happens exactly at the beginning of each signals. because the whole time period of the high level signals can be recognized as PINC(1<<4). and When I test the code on my zerocrossing circuit, the result are 0,0,0,0,0,0,120,0,0,0,120….. , which means it does not always detect the time difference.I think i basically use the same code, Can you think of why?

    1. What do you mean ? In simulation or on real device. What is the correct value and what is the displayed value ? Maybe there are some defective components or the zenner is mounted upside down or the input port of the Atmega is defective. I am still working on simulator, trying to use 16×4 display and showing the line frequency of the Line 1. So far I succede to modify the source code so all the parameters are shown on the 16×4 display. I hope that Ismail Sarwar will guide ( help ) me to display the Line 1 ( V1 ) frequency.

    2. Check your connections first. And calibration is the most important part while implementing the circuit in hardware. So take care of it as well.

    1. Yes you can use it for the measurement of frequency as well. Some changes will be required in the code and circuit. Only one comparator will be used in the circuit. Code will be set in such a way that time of two zero crossing will be calculated. This time will be then finally converted into frequency.

      1. Hi,
        After many days and testing, I have succede made some modifications to your schematic and code but not happy with the results. I have use the second AO from U3, and inserted few lines and modify other lines. I know only electronics. My programming skils are verry poor.

        The problem is that I don’t know how to display the frequency with one decimal after the value, something like 50.2 or 50.6.
        I din’t post the entire code here because is too large.
        The display looks like this:

        V1=224V A1=0*
        V2=224V A2=120*
        V3=225V A3=240*
        Line=387V 50Hz

        Please help me to make the display show the frequency with 1 decimal.
        Is there a way to send you the entire code and the modified schematic ?
        Thank you for this project.

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.