You are on page 1of 4

alternating current measurement using pic microcontroller

BILAL Malik

July 18, 2014

PIC microcontrollers

640 Views

alternatingcurrentmeasurementusingpicmicrocontroller:

In this artcile I will discuss how to measure alternating current using current transformer and pic
microcontroller.
Currenttransformer:

It is used to measure alternating high current of the order of thousand Amperes.It 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.

Howtomeasuresecondarysidecurrent:
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 concern
In this tutorial tutorial we will use PIC microcontroller to measure alternating current.

Hardwarecomponents:
1. PIC16f877A
2. CT
3.difference amplifier
Differenceamplifier:

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

Check Also

voltage drop across .1 ohm shunt resistor =8v


then current according to ohm law
V=IR
I=V/R

Green house intelligent control

I=8/.1=8A

system

Green house
intelligent
control system
but the problem is ADC of pic microcontroller can never measure
voltage
greater
thanis5 volt.so to solve
designed to protect the plants from more

cool and
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.

Circuitdiagram:

circuit diagram of AC voltmeter using pic microcontroller

current measurement using pic microcontroller complete circuit


code:

/****************************************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, thats why I have written this topic.
enjoy!!!!!
remember me in your prayers in return
if you still have any question,feel free to comment on this post.

You might also like