alternating current measurement using pic microcontroller

alternating current measurement using pic microcontroller. In this artcile I will discuss how to measure alternating current using current transformer and pic microcontroller. After reading this, you will be able to design AC Ammeter using PIC16F877A microcontroller. It is very important task in pic microcontroller projects. I have already posted a dc current measurement circuit with code. you can also read it.

Current transformer for AC current measurement

It is used to measure alternating high current of the order of thousand Amperes. It steps down ac current to lower value so that it can be easily read with the help of microcontroller. Step down ability of current transformer  depends on the rating of current transformer and its current step down ratio.Suppose you have a current transformer with current ratio of 100:10 Ampere .Its mean primary current of transformer is 100 Amp and secondary current is 10 Amp.you can not use this  current transformer to measure current more than 100 Amp.By measuring secondary side low current, we can easily convert it into primary current value by using current ratio formula. I will discuss in later part of this discussion how to use this step down ratio in programming part.

How to measure secondary side current of CT

There are many methods to measure low alternating current you can also measure it using AC ammeter. But if you want to perform some control operation and want to send measured current value to other place.You have to use some kind of intelligent system.
For example you want to make a current protection circuit and circuit specification are followings
 if current flowing through a line is greater then 100 Ampere, a control action  should be performed to operate a rely
if current is greater than 100 Ampere relay=open
if current is less than 100 Ampere relay=close
 To make such kind of intelligent system, we may use analog and digital electronics,but its better to use digital electronics as far as cost issue is concernIn this tutorial tutorial we will use PIC microcontroller to measure alternating current.

Hardware components of alternating current measurement:

1. PIC16f877A

2. CT




3.difference amplifier

AC current measurement circuit working

Difference amplifier:

To measure this current with pic microcontroller,we have to use ADC module of PIC microcontroller.To use ADC module we will convert current into voltage form by using a .1 ohm shunt resistor across CT and we will measure this voltage drop across shunt resistor.Then this voltage drop can be easily converted into current again.For example
voltage drop across .1 ohm shunt resistor =8v
then current according to ohm law
                                                        V=IR
                                                         I=V/R
                                                        I=8/.1=8A
but the problem is ADC of pic microcontroller can never measure voltage greater than 5 volt.so to solve this problem we can use difference amplifier.By adjusting gain of difference amplifier we can reduce voltage lower than 5 volt.Following diagram shows the circuit of CT and difference amplifier.For more information about difference amplifier how to adjust its gain etc, you can search on Google.

Video lecture on alternating current measurement

Circuit diagram of alternating current measurement:

alternating current measurement

circuit diagram of AC voltmeter using pic microcontroller 

 

current measurement complete circuit

current measurement using pic microcontroller complete circuit

program of alternating current measurement using microcontroller

/****************************************BILAL MALIK UET***************************
 ****************************************BILALMALIKUET.BLOGSPOT.COM****************/
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
float v;
char txt1[5];
/*************************current measurement funtion****************************/
void current_READ(void)
      {
           float max;
           int i,current;
           int t[40];
           ADCON0.ADON=1;
           for(i=0; i<=39; i++)
           {
           v= ADC_Read(1);
           v =v*(10.0/1023.0);
           v=(v-5.0);
           t[i]=v*10;
           }
           ADCON0.ADON=0;
           max=t[0];
           for(i=0; i<=39; i++)
           {

           if(max

            max=t[i];
           }
           max=max*.707106781;
           intToStr(max, txt1);
           Lcd_out(2,8,txt1);
           delay_ms(1000);
      }
/***********************************main funtion********************************/
void main()
{
          Lcd_Init();                        // Initialize LCD
          ADCON0.ADCS1=1;
          ADCON0.ADCS1=0;
          ADCON0.ADON=0;
          while(1)
         {
            Lcd_out(2,1, “Current:”);
            current_READ();
          }

}

This code is used to measure secondary current of CT.you can easily calculate primary current according to your CT current ratio by using current ration formula.You just have to add one more line in current function written above if you have basic understanding of microcontrollers programming.I hope this topic help you in your works and projects.I found thousands of people searching for this topic on net, that’s why I have written this topic on alternating current measurement using pic microcontroller. enjoy!!!!!remember me in your prayers in return :)if you still have any question,feel free to comment on this post. You can purchase simulation and code in 15$ only. Buy now and after purchasing send me email. I will send you code and simulation. my email address is bilalmalikuet@gmail.com

36 Comments

  1. pulsetronics October 28, 2014
  2. wael November 8, 2014
  3. Manoj January 7, 2015
  4. Rayan ibrahim January 9, 2015
  5. Mrunal February 6, 2015
  6. Mrunal February 6, 2015
  7. joynal March 4, 2015
    • BILAL Malik March 4, 2015
      • oussama May 6, 2016
  8. rakib March 8, 2015
    • BILAL Malik March 9, 2015
  9. Smith March 23, 2015
  10. Joynal March 24, 2015
    • BILAL Malik March 24, 2015
  11. idreesmuhamed April 4, 2015
    • BILAL Malik April 4, 2015
  12. Xin May 23, 2015
  13. flexo June 18, 2015
  14. Morsi Jaber August 8, 2015
  15. Mayuri August 10, 2015
  16. Mayuri August 10, 2015
  17. Epal Hijau September 15, 2015
  18. G Wa Tano December 1, 2015
  19. Anteneh Shitahun January 4, 2016
  20. gj January 22, 2016
  21. mourad April 5, 2016
  22. Haris April 15, 2016
  23. PAT May 9, 2016
  24. kunal kashalkar June 8, 2016
  25. manta_7 July 15, 2016
  26. America August 4, 2016
  27. djalltra August 18, 2016
  28. Djalltra September 12, 2016
  29. MHO September 22, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,363 other subscribers