0% found this document useful (0 votes)
12 views125 pages

AC Voltage Measurement Using Pic Microcontroller - Two Methods

This document provides a tutorial on measuring AC voltage using the PIC16F877A microcontroller through two methods: a potential transformer and a difference amplifier. It explains the necessary components, circuit diagrams, and programming code required for both methods, emphasizing the importance of stepping down high AC voltage to safe levels for microcontroller input. The tutorial is aimed at students and hobbyists interested in practical applications of microcontrollers in voltage measurement.

Uploaded by

madhujaggi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views125 pages

AC Voltage Measurement Using Pic Microcontroller - Two Methods

This document provides a tutorial on measuring AC voltage using the PIC16F877A microcontroller through two methods: a potential transformer and a difference amplifier. It explains the necessary components, circuit diagrams, and programming code required for both methods, emphasizing the importance of stepping down high AC voltage to safe levels for microcontroller input. The tutorial is aimed at students and hobbyists interested in practical applications of microcontrollers in voltage measurement.

Uploaded by

madhujaggi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 125

 Menu 

AC Voltage measurement using


PIC16F877A microcontroller

In this tutorial, we will learn to measure AC voltage using


a pic microcontroller with two methods. One is using a
potential transformer and the second one is using an op-
amp as a di�erence ampli�er. That’s means, in the �rst
method, we will use a voltage transformer to step down
220V AC and in the second method, we will use an
operational ampli�er as a di�erence ampli�er to step
down high AC voltage. But for both methods, we will use
pic microcontroller ADC to take AC voltage samples. For
this tutorial, we will use the PIC16F877A microcontroller.
However, the logic used in this tutorial can be used with
other microcontrollers such as 8051, AVR, Arduino,
Raspberry Pi, Beaglebone, etc.

You have came across many online tutorials on various


websites about voltage measurement using di�erent
microcontrollers. But all these tutorials are about
measurement of low DC voltage.In this project, you will
learn how to measure high AC voltage using PIC16f877A
micrcontroller.

In this tutorial, We will discuss ac voltage sensing with


two method:

1. Using di�erence ampli�er method


2. Using potential transformer method

Table of Contents 

Alternating voltage measurement


To measure 220V AC, you need to step down this voltage.
Because microcontrollers can’t measure voltage greater
than 5V. If you give voltage more than 5V to the analog
input of microcontroller, it will get damage permanently.
To assure protection of microcontroller, you will need to
step down 220 volt AC into AC voltage whose peak value
should be less than 5V. For example , 220V AV mean RMS
voltage and its peak value is equal to 311 volt. similarly
you have to step down high AC voltage of in such a way
that its peak value should not be greater than 5 volt.

There are two methods to step down 220 alternating


voltage into low alternating voltage which peak value
should not be greater than 5 volt.

Potential Transformer ( All Electrical Engineering


students must know about P.T and its use)
Di�erence ampli�er ( I will discuss di�erence
ampli�er method in this project.)

Potential Transformer can also be used to step down 220


Alternation voltage.But why you want to spend more
money? when you can do this with the help of cheap
operational ampli�ers and few resistors. Di�erence
ampli�er method is more economical than potential
Transformer when you want to step down voltage less
than 400 volt AC.

NOTE: Di�erence ampli�er me thod is


economical for voltage me asurement less
than 400 volt. Because ab ove 400 volt, this
method become expensive than potential
Transformer. There are re asons behind it. I
am not going to discuss re asons here.This
method is suitable for �na l year students
who want to measure Alte rnating voltage
and current.

Di�erence Ampli�er circuit


Di�erence ampli�er is used to amplify voltage from two
voltage levels.In case of Alternating voltage we have two
voltage level one is positive with respect to neutral and
other is negative with respect to neutral. I will
recommend you to Google about di�erence ampli�er
and its use.

you can adjust the gain of di�erence ampli�er according


to our requirement by selecting proper values of
resistors.In this project gain is equal to :

Gain= R8/(R1+ R2+ R3) ;

In Alternating voltage case second voltage level is zero.


Because during positive cycle and negative cycle other
side is considered zero or neutral. So output voltage will
be

vout = gain * Vinput;


Di�erence ampli�er to step down voltage

In Above picture, resistor R1, R2, R3 R4, and R5 have high


values which do not allow high voltage to appear across
op-amp. Because high input resistors are used that’s why
micro ampere current will low and this way power loss
will be in mili watts. According to di�erence ampli�er gain
formula our gain will be:

gain= (22K)/( 1.2M + 1.2M + 2.2K) = 0.0091

NOTE: you must make calculation according to peak


value of sine wave. Because peak voltage is the maximum
voltage input to micrcontroller analog pin.So with a .0091
gain, with respect to peak voltage of sine wave output
voltage from op-amp is :

Vout = .0091 * 311 = 2.8301 volt


(peak output voltage)

As you see above �gure we have connected other


terminal of R7 to 5 volt instead of ground as we do while
using di�erence ampli�er in many applications. R7
resistor is used to increase DC voltage level op-amp
output. Sine wave have zero DC voltage level and
negative voltage cycle. Microcontroller can not read
negative voltage.So we increase the DC level of sine wave
by 5 volt.In this way negative voltage will not appear
across microntroller. Now output peak voltage from op-
amp is 5 + 2.8301 = 7.8301 volt. But as I have mentioned ,
microcontrollers can not measure voltage greater than 5
volt.So as shown in above �gure we have used voltage
divider to divide voltage by 2.Hence output voltage is:

Vout = 7.8301/2 =
3.90155;

Capacitors C1, C2, and C3 are used to �lter harmonics


from input voltage and to provide protection to
micrcontroller from harmonics.Now AN pin can be
connected to microcontroller analog pin to measure
voltage easily.

Video lecture on AC voltmeter design

To know about how to measure analog voltage using


analog module of PIC16F877A microcontroller go through
PIC microcontrollers tutorials..

PIC MICROCONTROLLERS TUTORIALS

COMPLETE CIRCUIT DIAGRAM


To know about LCD interfacing with PIC micronctrollers,
go through pic microcontrollers tutorials

PIC MICROCONTROLLERS TUTORIALS

LCD displaying voltage value..

Complete circuit diagram:


Alternating voltage measurement circuit diagram

If you want to get complete code and circuit diagram


comment on this with your email address.

AC voltage measurement code


Code for this project is written using Mikro C.To
download code for AC voltage measurement click on link
below : [sociallocker]

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 txt[5];
char txt1[5];
void voltage_READ(void)
{
float max;
int i;
int t[40];
ADCON0.ADON=1;
for(i=0; i<=39; i++)
{
v= ADC_Read(0); //Digital value convert
v =v*(10.0/1023.0);
v=(v-5.0);
t[i]=v*110.1909091;
}

ADCON0.ADON=0;
max=t[0];
for(i=0; i<=39; i++)
{
if(max<t[i])
max=t[i];
}
max=max*.707106781;
intToStr(max, txt);
Lcd_out(1,9,txt);
delay_ms(1000);
}

void main()
{
Lcd_Init(); // Initialize LCD
ADCON0.ADCS1=1;
ADCON0.ADCS1=0;
ADCON0.ADON=0;

while(1)
{

Lcd_out(1,1, "Voltage:");
voltage_READ();
}
}

Don’t forget to subscribe us to get info about next useful


projects in your inbox. if you want to purchase simulation
in 15$ US. Contact me at
[email protected] After sending
payment, send me email, I will send you code and
simulation in your email. thanks

[button-brown url=”http://store.microcontrollerslab.com
/product/ac-voltage-measurement-using-pic16f877a-
microcontroller/” target=”_blank” position=”left”]Buy code
and proteus simulation in 15$[/button-brown]

Second method to measure AC voltage


In that article I have discussed each and everything you
need to know to make ac voltage measurement project.
In that article, I have used operational ampli�er as a
di�erence ampli�er to step down ac voltage level from
220 volt ac to less than 5 volt ac. But I have seen many
people struggling with that method. So I have decided to
write a article on how to measure ac voltage using
potential transformer and pic microcontroller with
digital lcd display.

How to measure ac voltage:


Ac voltage can be measure with following methods:

AC voltage measurement using digital millimeter


AC voltage measurement using analog voltmeter
AC voltage measurement using microcontroller
AC voltage measurement using potential
transformer and digital display (I will discuss this
method in this tutorial)
AC voltage measurement using di�erence
ampli�er and pic microcontroller

As I have already discussed in this project, I will be using


potential transformer to step down 220volt ac voltage to
less than 5 volt ac. I will discuss it later why we need to
step down ac voltage to measure it with the help of pic
microcontroller.

Main components of ac voltage


measure project:
Followings are the main components of ac voltage
measurement project. Brief descriptions of all
components are also given below:

Potential transformer
Bridge recti�er
voltage divider circuit
Liquid crystal display
PIC16F877A pic microcontroller

What is potential transformer (PT)


Potential transformer is a type of transformer which is
used to step down ac voltage. It is used to measure ac
voltage by stepping down AC voltage. For example in this
project, potential transformer is used to step down
220volt ac voltage to 12 volt ac. Potential transformer
secondary winding have less turn than primary winding’s.
So according to below mentioned turns ratio formula, it
step down ac voltage.

Ns/Np = Vs/Vp

What is bridge recti�er?


Bridge recti�er is electronics circuit used to convert ac
voltage into pulsating dc voltage. In other words it
converts, negative cycle of AC voltage into positive cycle.
Now the question is why we need bridge recti�er in this
project? Because microcontrollers can’t reads negative
voltage. Therefore we need to convert negative half cycle
of AC voltage into positive cycle. Bridge recti�er is made
using recti�er diodes connected in a form to form a
bridge. 1N4007 recti�er diodes are used to make H
Bridge.

Voltage divider circuit:


Voltage divider circuit as it name suggests is used to
divide voltage. Two resistors are used to as voltage
divider. Potential transformer step downs 220 volt AC in
to 12 volt AC. After that bridge recti�er is used to convert
12 volt ac into pulsating dc. But microcontroller cannot
read voltage more than 5 volt. Therefore voltage divider
circuit further divide the voltage in two parts and less
than 5 volt appear across analog to digital converter pin
of pic microcontroller. I will discuss later about analog to
digital converter.

Liquid crystal display:


Liquid crystal display or LCD is used to used to display
value of measured ac voltage. 16X2 LCD is used in this
project. LCD is interfaced with pic16f877a
microcontroller. IF you don’t know how to interface LCD
with PIC16F877A microcontroller, check following article:

LCD interfacing with pic16f877a microcontroller

PIC16F877A microcontroller:

PIC16F877A microcontroller is used in this project.


PIC16F877A microcontroller is belongs to 16F family of
pic microcontrollers. It have built in analog to digital
converters module. Some of basic features of
PIC16F877A microcontroller is given below:

Built in analog to digital converters


Comparator modules
Digital input and output pins
Serial communication
UART communication
I2C communication and many others.

For more information about pic16f877a microcontroller


features and if you are new to microcontroller’s worlds,
check following article.

Getting started with PIC16F877A


microcontrollers

Circuit diagram of how to measure ac


voltage using microcontroller
Circuit diagram of how to measure AC voltage project is
given below. I have already explained all the components
of this project above.
How to measure ac voltage using microcontroller

Input to circuit is 220 volt AC voltage. Potential


transformer step downs 220 volt AC voltage in 12 volt AC.
After that bridge recti�er converts step down AC into
pulsating dc voltage. Voltage divider further divides the
voltage into two parts. Voltage less than 5 volt appear
across analog to digital converter pin of pic16f877a
microcontroller. Microcontrollers are basically small
micro computers which understand only digital values.
Built in analog to digital converter module of pic16f877a
microcontroller converts analog values of AC voltage into
digital values. These digital values are used in processing
of data with in microcontroller. Pieces of instructions
written in the form of coding told microcontroller what to
do. Microcontroller itself do not do anything. You tell him
to do whatever you want him to perform by writing
pieces of information called program.
Simulation result of how to measure ac
voltage project:
Diagram below shows simlation results of ac voltage
measurement project. LCD displays 220 volt AC which is
measured with the help of microcontroller and necessary
components connected with the microcontroller and
potentioal transformer.

How to measure ac voltage using pic microcontroller

List of components :
List of required componensts for how to measure ac
voltage is given below:

Category,Reference,Value,Order Code
Capacitors,"C1",22pF,
Capacitors,"C2",22pF,
Resistor R1 = 30K , R2 = 10K, R3 = 10K;
Integrated Circuits,"U1",PIC16F877A,
Diodes,"D1",1N4007,
Diodes,"D2",1N4007,
Diodes,"D3",1N4007,
Diodes,"D4",1N4007,
Miscellaneous,"TR1",TRAN-2P2S PT,
Miscellaneous,"X1",CRYSTAL 8MHZ,

Program for how to measure AC voltage


using PT
program given below is written using MIkro C compiler.

// LCD module connections


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;
// End LCD module connections

float maxpoint = 0;
int i;
unsigned int temp=0;

char ch[5];

void main()
{
TRISA = 0XFF;// All input
TRISB0_bit = 1;//set as input
TRISB1_bit = 1;//set as input
ADC_Init();

// Initialize LCD configuration...


Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

while(1)

{
Lcd_Out(1,1,"AC voltage");

for(i=0;i<500;i++)
{
if(temp = ADC_Read(0),temp>maxpoint)
{
maxpoint = temp;
}
}
maxpoint = ( maxpoint * 5 )/ (1023) ;
maxpoint = maxpoint * 4;
maxpoint = maxpoint + 1.4;
maxpoint = maxpoint * 18;
maxpoint = maxpoint * ( 1 / sqrt(2) );
intToStr(maxpoint, ch);
lcd_out(2,1, Ltrim(ch));
maxpoint = 0;
}// while
}// void mai

I have made necessary comments in code for your


understanding.If yo still have any issue in understanding
of code, let me know.If you have no issue after reading
this article your comments are welcome. you can also
check these PIC16F877A projects:

AC current measurement using PIC16F877A


AC power measurement using PIC16F877A
Three phase ac power measurement
Three phase ac voltage measurement

 PIC microcontroller projects


Subscribe to Blog via Email
Enter your email address to subscribe to this blog and
receive noti�cations of new posts by email.

Email Address

SUBSCRIBE

268 thoughts on “AC Voltage


measurement using PIC16F877A
microcontroller”
tahir
August 24, 2014 at 5:19 pm

Hi,
can you send me its code and simulation
�le……………?
thanks ,

id: [email protected]
Reply

masood
March 24, 2016 at 2:06 am

Hi,
can you send me its code and simulation
�le……………?
thanks ,
[email protected]

Reply

BILAL
March 9, 2018 at 12:14 pm

Hello can you help me for the code.


Thanks in advanced.
Reply

uday
October 5, 2014 at 4:25 pm

hi bro please send me code for this AC voltmeter


and ammeter projects
Thank you

Reply

Prashant
October 6, 2014 at 5:49 am

Nice post.
Send schematic and code on
[email protected]

Reply

idreesmuhamed
October 9, 2014 at 4:48 pm

hello , iam idreesmuhamed , in the fact , your


project is very important because iam electric
engineer
, please send to me the code and iam be thankfull
for you .

Reply

Visitor
October 11, 2014 at 6:14 pm

Dear i am new here on your blog.Can you please


send me the code of this alternating voltage
measurement project.

Reply

BILAL Malik
October 12, 2014 at 3:21 pm

code downloading link is available at the end of


post

Reply

immad
May 12, 2015 at 11:10 pm

cannot dowload the code bro


Reply

Deepak
October 12, 2014 at 3:09 pm

The information provided on your page here


turns very useful for me and i thanks you for this.
I have made the simulation but having a little
problem with the code so if you send me the code
then i am very grateful to you.
I am an electrical engineering student in Delhi
Technological University and the topic here on
this page is similar to my minor topic so please
help me and send the code as soon as possible.

Reply

BILAL Malik
October 12, 2014 at 3:32 pm

I have added code downloadable link at the end


of post. use this link to download code. Good
luck

Reply

Wak
March 13, 2017 at 2:34 am
Please I need to measure three phase voltage
line to line and three. Phase current by using
pic18f4550

Reply

prabakaran
October 12, 2014 at 5:55 pm

good tutorial can u send me the simulation

Reply

BILAL Malik
October 12, 2014 at 5:58 pm

Use pictures given in article to draw circuit


diagram

Reply

Abuzur
October 27, 2014 at 12:19 pm

Dear Bilal,
Good work keep going, send me the source code
in .c �le if possible.

Reply

pulsetronics
October 28, 2014 at 12:52 pm

Pls try to elaborate on your ADC conversion using


di�erential ampli�er

Reply

pulsetronics
October 28, 2014 at 12:53 pm

Pls try to elaborate on your ADC conversion using


di�erential ampli�er in the software… Thanks
Reply

vu bao
November 10, 2014 at 3:23 am

hi! can you explain me how to �nd the formular


“for” look of source code:

v=v*(10.0/1023.0);
v=(v-5);
t[i]=v*110.1909091;

thanks you so much!

Reply

Amanti
June 1, 2018 at 11:13 pm

Hi please send for me the code


thanks so much!

Reply

Aby Francis Wilson


November 17, 2014 at 4:28 pm

Hello
Can you sent me the simulation �le to
[email protected]

Reply

DHURGHAM
November 19, 2014 at 8:12 am

thank u so much Mr.bilal


can i follow ur website?

Reply

naveen
December 1, 2014 at 4:39 am

nice work
Reply

med
December 26, 2014 at 9:21 am

think you

Reply

ateeb akmal
January 2, 2015 at 6:24 pm

kindly send me code at


[email protected]

Reply
Mrunal
January 6, 2015 at 3:53 am

Nice work! you have shown a easy way to


interface and measure high voltage using
microcontroller. Thank you. but I am having some
doubts, after calculating current through
resistors, it is 9.57×10^-5 so by calculating voltage
drop across R1, so (9.57×10^-5) x(2.2M) is 219.34V
it should be low isn’t it? please guide me.

Reply

Vijay
January 7, 2015 at 4:42 am

Thank you for sharing with us! I have assembled


this ckt on bread board, without interfacing it with
PIC. So the output voltage should be 7V
DC(without voltage dividing) isn’t it? but mine is
getting 5V DC so what might be the problem? or
its normal ?

Reply

BILAL Malik
January 7, 2015 at 8:58 am
check your circuit connections and its also
depend on maximum input voltage to di�erence
ampli�er

Reply

Hashim Ashraf
March 30, 2017 at 1:34 pm

If you are using a multimeter to measure the o/p


voltage it shows the average voltage . use dso
instead.

Reply

Mrunal
January 8, 2015 at 5:53 am

Hi, will you please explain your code of


voltage_Read routine? I didn’t get how you have
done calculation.. Thank you.

Reply

frendy
January 12, 2015 at 2:29 am
Hi Bilal Malik

I would like to ask is this circuit is also applicable


to 110Vac. I was able to try your circuit in 220Vac
and I was successful on it but when I try to 100Vac
it shows di�erent voltage readings. I appreciate if
you reply on my inquiry.

thanks
frendy

Reply

Mrunal
January 13, 2015 at 10:41 am

my LCD is showing 388V always, though I remove


input from LM258! what might be the problem?

Reply

Mrunal
January 17, 2015 at 4:48 am

Now its working! thanks man! but reading is not


constant! �uctuating

Reply
BILAL Malik
January 17, 2015 at 6:54 pm

you are checking it on hardware or software ?

Reply

Mrunal
January 20, 2015 at 4:36 am

I am checking it on hardware. And now reading


is constant. I added one 0.1uf cap.

Reply

Nitz
June 15, 2017 at 12:29 am

Where u added the cap

Reply

Mho
April 5, 2018 at 5:16 pm

please is it working alright for you? where did


you add the capacitor?
Reply

Mho
May 30, 2018 at 5:04 pm

Please where did u add the cap? I am also


having the same �uctuation issues, and I eally
need this project urgently.
Reply

Nasaii Mustafa
March 14, 2017 at 10:59 am

Is it this project for measure voltage and current


? or voltage only
Reply
Bilal Malik
March 14, 2017 at 11:24 pm

voltage only you can buy complete code for


current and voltage both

Reply

Mrunal Ahirrao
January 21, 2015 at 11:43 am

It would be helpful if you please explain the code.

Reply

Tung
January 22, 2015 at 10:37 am

That is great, Please send me the code and


simulation �le for voltmeter and ammeter project

Thank you so much!

Reply
Justin Jose
February 2, 2015 at 9:41 am

Please send me the code and schematic of


voltmeter and ammeter projects.

Reply

Ayotomiwa Adekahunsi
February 5, 2015 at 9:26 am

great work,, pls send the code in mikroC. would


love to see this work on my pc.

Reply

BILAL Malik
February 5, 2015 at 9:30 am

code link is given in article. check the article


again

Reply

mpandi
February 7, 2015 at 5:50 am
Nice post Please send schematics and code .i am
also interested in MCU projects Kindly help me..

Reply

Asfand Sattar
February 12, 2015 at 4:13 pm

[email protected]

Please Email !

Thank you

Reply

mahdi
February 12, 2015 at 1:13 pm

hi dear
please send me your code and explain more
about how measuring voltage and current.

Reply

Mase Ashipala
February 18, 2015 at 11:59 am
Hi there please send me your code for this AC
voltmeter and ammeter project. I am very much
interested in this project .
Thanks a million

Reply

Pandi
February 22, 2015 at 12:06 pm

I am very much interesting to do PIC mcu projects


with mikroC compiler. Especially AC voltage
measurement by PIC mcu.Kindly send me the
complete circuit diagram and Source code for 16F
877A AC voltage measurement projects.

Reply

joynal
March 2, 2015 at 7:43 am

Hi
can you send me its code and simulation �le
email: [email protected]

Reply
Bilal Malik
May 7, 2015 at 12:06 am

Code link is given at the end of post

Reply

abu shaid sujon


March 15, 2015 at 8:00 am

can u please send me the code in my email

email—- [email protected]

Reply
Ajay Rai
March 18, 2015 at 10:51 am

hi,
can u pls send me the code and its simulation
�le..
thanks

Ajay Rai
[email protected]
Reply

TAnvir Mahtab
March 23, 2015 at 7:23 am

Hi,
I am Tanvir Mahtab from Bangladesh. Is this
circuit work in 220VAC ?
Please give me complete project.

e-mail: [email protected]

Thank you.

Reply

BILAL Malik
March 24, 2015 at 2:22 pm
yes it can measure 220volt AC

Reply

RaviKumar
March 25, 2015 at 12:54 pm

Can you send the complete source code with


proteus �le

Reply

BILAL Malik
March 25, 2015 at 1:00 pm

code link is given at the end of post

Reply

Abhishek c
April 8, 2015 at 7:00 pm

sir i code is not downloading can send to my


mail id [email protected]

Reply
sajan
March 27, 2015 at 7:42 pm

ID : [email protected]
Can i Do the Same Stu� Using AC-AC adapter????

Reply

mahdi
March 29, 2015 at 10:47 am

hi
please send me the code and schematic of
voltmeter and ammeter.
thank you.
[email protected]

Reply

kalyan
April 4, 2015 at 11:59 am

please send the ckt and source code of pic for


voltmeter and ammeter

regards
kalyan
Reply

Jalal Khan
April 7, 2015 at 7:33 pm

Plz send me the mickroC code and proteus �le. I


am an electronics engr
Reply

Abhishek c
April 8, 2015 at 6:58 pm

hello sir i m unable to download the code can u


send the code my mail id
[email protected]
Reply

lacika
April 8, 2015 at 9:28 pm

Hi,
can you send me its code and simulation
�le……………?
thanks ,
id: [email protected]

Reply

chitra
April 9, 2015 at 1:58 pm

Sir,
will you pls mail me code of pic16f877a for closed
loop voltage regulation of a converter in MPLAB if
possible
Regards,
Chitra

Reply

BILAL Malik
April 9, 2015 at 2:19 pm

I will try to write article on it

Reply

Prashanth
April 9, 2015 at 2:52 pm

Plz send me a code..i cant open voltage code.txt in


ur link provided..plz help me..

Reply

vasyl
April 16, 2015 at 10:26 pm

Hi!
Plz send me the mickroC code and proteus �le for
this project.

[email protected]

Thanks,
BR Vasyl

Reply

shukri
April 17, 2015 at 4:05 pm

hello siir..could you sent me the code


programming for this project?i need your..thank
you…

Reply
Justin
April 24, 2015 at 5:31 pm

Your post is a life saver, thanks. Can you send me


the code buddy 🙂
Reply

trinh dat
May 1, 2015 at 9:56 am

very good
please send me its code and simulations
thanks you

Reply

trinh dat
May 1, 2015 at 9:59 am

Email: [email protected]

Reply

trinh dat
May 1, 2015 at 9:58 am
please send me code and simulation, thanks you
very much
Email: [email protected]

Reply

quoc dat
May 1, 2015 at 10:05 am

please send me code and simulation, thanks you


so much
email: [email protected]

Reply
RK
May 10, 2015 at 5:55 pm

Hi Friends,
Can you explain this step on the source code:

v=v*(10.0/1023.0);
v=(v-5);
t[i]=v*110.1909091;
please explain how to �nd 110.1909091 value
Thank U

Reply

BILAL Malik
May 10, 2015 at 7:33 pm

It is inverse of gain of di�erence ampli�er

Reply

RK
May 10, 2015 at 9:27 pm

Thank u BILAL Malik friend ,

How to change the source code to the measure


3phase voltage (0-600v )
please tell friend……
Reply

BILAL Malik
May 10, 2015 at 10:27 pm

try to adjust the gain of di�erence ampli�er

Reply

RK
May 11, 2015 at 7:43 pm

Hi friend
I am try to adjust the gain of di�erence ampli�er
to change R8 value change to 15KOHm
gain =15K(1.2m+1.2m+2.2K)
gain = .0062443
source code
v=v*(10.0/1023.0);
v=(v-5);
t[i]=v*160.1467

input voltage 14V but display voltage 21V


how to sl the err plz tell frd ……..

Reply
syuhada
May 12, 2015 at 10:22 pm

i want source code

Reply

BILAL Malik
May 12, 2015 at 10:23 pm

source code is given in post

Reply

Iro
June 4, 2015 at 11:14 pm

Dear Bilal,

I’m having proplems with the circuit. When I plug


in the mains , the fuse turns o�.
Have you any idea what the problem could be?

Iro

Reply
Bracoch
June 9, 2015 at 11:41 pm

Thenk’s!!!

Reply

badr
June 10, 2015 at 7:19 pm

thank you it is good project

Reply

JOEL
June 13, 2015 at 8:38 am

hi,
thanks for such an interesting and nice tutorial.
please send me the source code and simulation.
[email protected]

Reply
chinnathambi.J
June 23, 2015 at 3:54 pm

sir please send the MPLAB program and code to


this mail address [email protected]

Reply

Jowah Lewis
July 5, 2015 at 6:00 am

Good day Sir,


I cant �nd the circuit for the input AN2 to the
microcontrollers pin 3. thanks in advance

Reply

ajikumar
July 5, 2015 at 6:35 am

plz share code

Reply

BILAL Malik
July 5, 2015 at 12:45 pm
code is given in post

Reply

shiva
July 7, 2015 at 11:52 am

sir
we are using pic18 . how to provide input to pic18
from potential divider circuit. ? code is not clear
please explain in detail. please reply to my email
id.thank you……….

Reply

BILAL Malik
July 7, 2015 at 5:22 pm

this code is not for potential divider. you have to


make little bit changes in code to use directly
with voltage divider second method can be used

Reply

ali
July 8, 2015 at 12:50 am
hi
please send me code for this AC voltmeter and
ammeter projects
Thank you

Reply

Ahmad
July 8, 2015 at 1:42 am

Hello Sir

Please send me simulation �le.

Thanks a lot

Reply

Mahreen
July 13, 2015 at 10:42 am

sir can you please send me the MPLAB code using


potential divider to this mail address.
[email protected]

Reply
alireza
July 16, 2015 at 9:20 am

Hello
Please send me simulation �le.
Thank you.

Reply

mohammad
July 29, 2015 at 1:16 pm

Hi please send perfect project to me


Tanks

Reply

Morsi Jaber
August 8, 2015 at 5:52 pm

please send me code and isis simulation thank


you very much

Reply
Mayuri
August 10, 2015 at 4:27 pm

Kindly share the complete code with comments.I


am not able to understand the code.

Reply

Mayuri
August 10, 2015 at 4:28 pm

Kindly share the code with comments on id


[email protected]

Reply

abdullah
August 12, 2015 at 4:45 am

i need code project

Reply

ayat
August 26, 2015 at 12:54 am
hi any one have model related this topic ”
automatic load sharing of transformer by using
gsm technique

Reply

Bilal Malik
September 6, 2015 at 3:07 am

you can purchase code from me fot automatic


load sharing of transformer

Reply

ayat
September 7, 2015 at 8:05 pm

is there any matlab or proteous simulation ? if


there is how much its price?

Reply

Bilal Malik
September 8, 2015 at 11:41 am

@disqus_DxKEfDmTkd:disqus contact me at
[email protected]
Reply

Gourab
September 5, 2015 at 9:12 am

Dear sir, Thanks for the tutorials. Can you send


me the code for Atmega16 microcontroller.
Thanks in Advance. My Email Id:
[email protected]

Reply

Bilal Malik
September 6, 2015 at 3:07 am

pic code is given. You can hire me to write code


using Atmega16
Reply

chand hanif
September 16, 2015 at 12:34 pm

Dear Sir, can we use lm358 in place of lm258. will


it work while measuring 230 VAC.
Reply

chand hanif
September 16, 2015 at 12:40 pm

dear sir, Thanks for a fruitful tutorial. can lm358


work in place of lm258 fo measuring ac 230 V
Reply

althaf k
October 1, 2015 at 10:50 pm

sir,please give me complete coding and circuit


diagram of this project(AC voltage measuring )
my Email id: [email protected]
Reply

Paccy
October 6, 2015 at 12:04 pm
HELLO SIR,
Current value is also shown in the simulation pic.
sir can you please explain how that current is
measured.

Reply

Bilal Malik
October 8, 2015 at 2:45 pm

I have already explained it

Reply

jemshihas
October 14, 2015 at 6:20 pm

hi
i appreciate for your great work…
sir what is the relevance of 40 in int t[40];

Reply

Kivutha Danson
October 21, 2015 at 5:53 pm
good project can you share it at my email;
[email protected]

Reply

Tiệp Lê
November 8, 2015 at 11:10 pm

Can you share it at my email, I need it. help me;


[email protected]

Reply

Bilal Malik
November 13, 2015 at 11:42 am

Everything is given in article, What else you


need?

Reply

safeedeen
November 11, 2015 at 10:32 pm

Hi, Do you measure the peak of Pulse?


Reply

Bilal Malik
November 13, 2015 at 11:41 am

Yes you can measure it using same concept

Reply

joe li
November 30, 2015 at 4:08 pm

hello could you send me di�erence ampli�er


method’s circuits?thank you

[email protected]

Reply

‫ﺣﺴﺎن ﻣﺤﻤﺪ اﻟﺸﻴﺦ ﺳﻌﻴﺪ‬


December 5, 2015 at 9:19 am

Can you sent me the simulation �le to


[email protected]

Reply
‫ﺣﺴﺎن ﻣﺤﻤﺪ اﻟﺸﻴﺦ ﺳﻌﻴﺪ‬
December 5, 2015 at 9:20 am

Pleassssssss Can you sent me the simulation �le


to [email protected]

Reply

Nigromante
December 12, 2015 at 2:43 am

Please send code and circuit diagram the


di�erence ampli�er method’s to
[email protected]. thank you

Reply
Azlan rizal
December 25, 2015 at 7:43 am

Hai,
For the �rst method using di�erence ampli�er,
what is the wattage for resistor R1,R2,R3 and R4?
Is it 10w,5w or 1/4w ?

Reply

BILAL Malik
January 9, 2016 at 9:32 pm

quarter watt resistors are enough

Reply

rocksstar
January 9, 2016 at 3:01 am

waw you ara amazing

Reply

alif osman
January 10, 2016 at 2:15 pm
hello sir,
can you send me the complete �le for this project.
my email: [email protected].
thank you.

Reply

omer
January 14, 2016 at 9:07 pm

Hello,
Will you please send me the code and Simulation
of the di�erence method. @ Bilal Malik
email: [email protected]

Reply

Rolando
January 18, 2016 at 6:46 am

Great project.

Please send me the schematic diagrams and


codes.

Reply
KPBS
February 1, 2016 at 12:32 pm

Can you please send me the voltage and current


full circuit and full code to display both current
and voltage as shown in the post.

Reply

Richard
February 9, 2016 at 1:58 am

[email protected]
Please send me the whole circuit and full code. If
you have the Python code that will be really nice!

Reply

Jagatheeswaran
February 9, 2016 at 5:37 pm

I just did simulation in proteus and I dont know


how generate the sine how you generated. Can u
please help me??

My mail id: [email protected]


Reply

sura
February 13, 2016 at 8:11 pm

Comment Text*i prefer to do it .. so it will be


helpful for me receiving ur full code n cct
Reply

king mayor
February 13, 2016 at 11:07 pm

I love this , Pls elaborate on code using lm258


And kindly pls send me the full code on my email

Reply
Sarfaraj
February 22, 2016 at 2:13 pm

can i make the same project using 8051


microcontroller?

Reply

BILAL Malik
February 22, 2016 at 9:31 pm

yes it can be designed

Reply

Vinoth
February 23, 2016 at 12:58 pm

Hi,
can you pls send me its full code ……………?
thanks ,

Reply

parthi
February 26, 2016 at 1:27 pm
can you pls send me its full code ……………?
thanks ,
ID: [email protected]

Reply

�x
February 28, 2016 at 12:27 am

cool job

Reply

�x
February 28, 2016 at 12:27 am

ill like full code too . thanks mail�[email protected]

Reply

Ali Farkouh
February 29, 2016 at 6:43 pm

cool job,
pls sent me the code
Reply

Ali Farkouh
February 29, 2016 at 6:47 pm

[email protected]

Reply

Thushara
March 1, 2016 at 8:33 am

pls post to me c code [email protected]


thank u

Reply

Angoh
March 5, 2020 at 11:33 am

Thanks for the codes… I juts tried building the


codes it’s having a lil problem .please kindly
check the line code:

ADC_Init();

There is were I got stuck when trying to build my


codes and running it..

Please check and get back to me ..


Thanks

Reply

Microcontrollers Lab
March 5, 2020 at 1:24 pm

This code will work with Mikro C for PIC only


and make sure to include adc library from the
library manager
Reply

che kinsley neba


March 6, 2016 at 2:00 am

please i dont undertand when you write char


ch(5) what does that 5 represent
Reply
che kinsley neba
March 6, 2016 at 3:21 am

please can i have the code in c++ language.

Reply

Sayantan Ghosh
March 12, 2016 at 4:45 am

kindly send me code and circuit diagram at


[email protected]

Reply

ja�ar
March 15, 2016 at 10:44 am

Can you send me the full code and circuit diagram


at
ja�[email protected]

Reply
raouh
March 15, 2016 at 1:47 pm

Thanks man for everythings . this is my A.E :


[email protected] …..Thank u again and
have a great day 🙂
Reply

marie
March 15, 2016 at 3:21 pm

Hello,
thank you for this project ,please send me its code
and simulation.

Reply

Ajlal
March 16, 2016 at 11:29 pm

Great work!!

Please send me ALL the �les (Full circuit diagram


and code)?

Thanks.
Reply

BILAL Malik
March 17, 2016 at 1:09 am

simulation and full circuit diagram is not free of


cost

Reply

ryu
March 21, 2016 at 10:39 am

Hello.
please me poject �les. code and simulation.
[email protected]

Reply

ryu
March 21, 2016 at 10:40 am

[email protected]

Reply
Donald J Murray
March 31, 2016 at 10:32 am

You could just use a voltage divider down to


below 5V and use the PIC ADC at a 10Ksamples/s
or some appropriate sample rate. This way you
can do more than just get voltage……can calculate
peak to peak, RMS, noise, etc…
However, certain applications have regulatory
requirements to isolate 220V, such as using a
transformer (or optical)….for safety reasons….i.e.
A voltage divider might not be enough.

Reply

tejas shete
February 22, 2017 at 11:48 pm

sir please can u contact me by mail I Really need


some help to �nd derivative using pic uc..my
mail [email protected]

Reply

Kevin Sekeres
April 1, 2016 at 9:41 pm

Please send code and schematics, thanks!


Reply

mourad
April 4, 2016 at 3:32 pm

please send me full code of voltage and current


measurment
Reply

mourad
April 4, 2016 at 3:34 pm

[email protected]

Reply

Hai Luong Nhu


April 20, 2016 at 8:20 am

I have a question.
Why you not use bridge diode & divider voltage as
beginning without potential transformer. We use
another resistor values transforming 220V to less
than 5V?
Reply

Dheepu
April 25, 2016 at 5:39 pm

Can you please send me the full code and circuit


diagram
Reply

kamal
April 28, 2016 at 3:33 pm

Hi
while simulate , output always remain constant as
5v
even when i change ac source voltage o/p still 5 v
or will it works by practical
help

Reply

Foma
May 10, 2016 at 11:36 pm

please send me full code of voltage and current


measurment

Reply

Adil
May 12, 2016 at 1:28 am

Hi bro please send me code for this AC voltmeter :


[email protected]
Thank you.

Reply

raj
May 30, 2016 at 12:09 pm

plz send me a code of this project with circuit


diagram

Reply

Dov
June 5, 2016 at 6:06 pm

Thanks for an informative lesson. I have a few


questions. First, many people talk about the
dangers of this kind of circuit not being isolated. Is
this safe as long as the circuit is correctly
implemented? If people are worried about AC
voltage being connected to the CPU by a stray
wire, then clearly this could happen to any design,
even an optoisolated one.

Second, why the capacitor C3? What is that doing?


It looks like just noise stabilization?

Reply

yahya
June 6, 2016 at 4:41 pm

its great,
pls send me the simulation and code.

Reply

BILAL Malik
June 7, 2016 at 2:14 pm

simulation is not for free

Reply

yahya
June 6, 2016 at 6:27 pm
can i use Lm741 instead

Reply

yahya
June 6, 2016 at 6:29 pm

can i also use recti�er to change to dc than adding


5v

Reply

yahya
June 7, 2016 at 12:00 pm

Hello,
this is great contribution.
I want to use ur idea in geophysics.
After injecting a current from 220v ac modi�ed
sine wave with two electrode inserted in the
earth, i will record the potential di�erence in
another two electrodes that does not have any
direct connection to the source electrodes.
so my questions are
1. can i use recti�er before/after the opamp to get
positive voltage in micro-controller(i am using
arduino uno).
2. can i replace the opamp with 741 ic
3. what do you suggest me to remove those
noises(self potential of the earth) coming from the
earth that does not have the same form from our
modi�ed sine wave. I saw some use synchronous
recti�er tapping from the source as a reference
signal.

Reply

saheed mustopha
June 27, 2016 at 9:09 am

please send me a code to [email protected].

Reply

adil
June 28, 2016 at 5:32 am

anyone can explain the above mention code for


voltage read?
why we multiply the ADC_read(0) value with
10/1023 and after this take minus 5 from it?
also tell me why we multiply it with 110.19 ?

thank you

Reply
keerthi
July 7, 2016 at 9:39 am

Great job,very happy with your program,


can you just share your code
MAIL-ID:- [email protected]

Reply

Dien
July 14, 2016 at 11:16 am

How to choose Value Cap(C1,C2,C3)???

Reply

Dien
July 14, 2016 at 11:22 am

[email protected]

Reply

Sarp
July 15, 2016 at 7:51 pm
What if the input is half wave recti�ed AC? Then
you measure the rms wrong by just processing
the positive part..

Reply

Oluwatobi
July 17, 2016 at 6:28 am

please I need the code and simulation for AC


voltage measurement

Reply

franka
July 22, 2016 at 1:57 pm

Hi, may I ask why is the input voltage for LM258


12v? Can I give it as 5V? Because If it is 12v, I have
go put in an another DC source for this, which
make it not really convinient compare to the
project with transformers.

Reply
ashwati
July 30, 2016 at 1:14 pm

plzzz send me component name list used in


circuit diagram on my gmail account
[email protected]

Reply

pip
September 27, 2016 at 1:39 pm

Hi Bilal,
Please, could you explain to me why there are “for
i=0; i<= x; i++" to get voltage?

Why use x=39 or 500?

Thanks.
Reply

Kingsley
September 28, 2016 at 5:53 pm

great job sir, i found your article here so intriguing


and i am iterested. i will be very grateful if you
send me the complete work with code for the AC
voltmeter in my email @ [email protected].
thank you sir! i am Kingsley, a computer
engineering student from Nigeria.

Reply

Kingsley
September 28, 2016 at 6:00 pm

please i need the complete code for the AC


voltmeter so i can design the setup as you have
already done. Thank you sir

Reply

albert
November 1, 2016 at 12:36 pm

hie this tutorial is fascinating . may you send the


code o [email protected]

Reply

Alex Hunter
December 14, 2016 at 5:16 pm
Excellent help me a lot, almost to start a project
about it.

Reply

Alex Hunter
December 14, 2016 at 5:22 pm

Please send me code of the project , thanks from


Buenos Aires

Alex

Reply

Rahul
December 14, 2016 at 7:08 pm

Di�erence ampli�er method is economical for


voltage measurement less than 400 volt. Because
above 400 volt, this method become expensive
than potential Transformer. There are reasons
behind it.
What are those reasons..?

Reply
New Tan
December 18, 2016 at 3:46 pm

Can you send me the source code and simulation?

Reply

kumaresh
December 21, 2016 at 10:06 am

Hi,
can i use above circuit for three phase voltage
measurement, please give me any idea for that
and thanks.

Reply

tamil
December 30, 2016 at 11:11 am

hi bilal i have no experience in c language but


there is something i’d like to explain me .
i have a project of building an automatic voltage
regulator in assembly language.

your post on ac voltage measurment using


di�erence ampli�er surpases my mind .
at the output of the op amp we should get an
alternating voltage .so how can a pic read an
altenative voltage ???
what should be the value of the input voltage?
that should be written in the assembly program
for comparison ???
what’s the value obtained after conversion in a
8bit pic ADC??? of 100v,140,180,200,220,240?

Reply

Ravi N
January 3, 2017 at 11:27 pm

Hi
Wish You Happy New Year.
Nice Explanation. Great Work.
Can you Please share the complete code for the
Measurement of AC voltge & Current.
[email protected]
Thanks& Regards
Ravi

Reply

tamil
January 7, 2017 at 3:49 am

Hi
V= (10.0/1023.0); why 10?
V =(v-5.0); v-5.0 howw?
t[i]=v*110.1909091;
Please explain
[email protected]

Reply

tamil
January 7, 2017 at 9:27 am

hi how can a pic measure with accuracy the Ac


voltage that comes from the op amp?
can you also explain it with some formulas??
in addition to that may you explain also
v =v*(10.0/1023.0); why 10????
v=(v-5.0); how v-5.0?????
t[i]=v*110.1909091;

Reply

José Miguel
March 31, 2017 at 2:11 am

v =v*(10.0/1023.0); why 10???? because of the


voltage divider -> v =2*v*(5/1023.0)
v=(v-5.0); how v-5.0????? Remove o�set
t[i]=v*110.1909091; Inverse Di�erential gain

Regards
Reply

satheesh
February 23, 2018 at 7:13 pm

Why we inverse di�erential gain?

Reply

simon ndungu
July 1, 2019 at 8:31 pm

@José Miguel

v =v*(10.0/1023.0); why 10???? because of the


voltage divider -> v =2*v*(5/1023.0)
v=(v-5.0); how v-5.0????? Remove o�set
t[i]=v*110.1909091; Inverse Di�erential gain
That does not add up,
v =v*(10.0/1023.0); why 10???? because of the
voltage divider -> v
no way the maximum output from the ac setup
can only amount to 3.915V given that the
voltage divider halfs the output of the 7.831,
it doesn’t make sense why you would equate it
to 10!!!!

t[i]=v*110.1909091; Inverse Di�erential gain ???


How is it calculated or the values just landed
here from no where?
Reply

Isiguzo C. E.
December 9, 2019 at 8:53 am

Late reply but i hope this will help someone


someday.
1. Why He used 10. Originally, the resolution
should be 5000mV/1023 (5V/1023) but because
the negative half cycle was previously ignored
since PIC cannot measure negative voltages, to
compensate for that, you multiply by 2. i.e from
+5v to 0V to -5V for normal sinusoidal signal.
Note the 5000mV is actually the 5V supply to PIC.
It has been used because the ADC module is
using the supply voltage to the PIC as its
reference voltage (Vref).

2. About the V-5 ==>> Recall the DC level of the


Stepped down signal was raised by 5V to
eliminate negative voltages to the PIC Pin. Since
the negative part of the cycle has now been
adequately compensated in V = V *
(5.0*2/1023.0), it is necessary to subtracted the
added DC level raising voltage which is 5V. Thus,
V-5.

3. On t[i] = V * 110.1909091; I believe he used


the already stated formula
Vout = gain * Vin
Since we now want to measure Vin,
Vi = V/gain
which is same as
Vi = V * (1/gain)

1/gain = 1/0.0091 = 109.190909143.


Thus,
Vi = V * 109.190909143.
Can’t tell why he used 110.1909091 instead.
Note, t is a variable (placeholder for Vi) and it is
logging 40 di�erent Vi levels (i.e. from 0 to 39)
with respect to i that will make for better
measurement accuracy and precision…
Hence,
t[i] = V * 109.1909091

Thank you!

Reply

burak
January 11, 2017 at 3:53 am

Hi
Can you send me the source code please ?
[email protected]

Reply

Jagdeep kataria
January 14, 2017 at 9:50 pm

Hi Bilal,
I read this article long time back, but didn’t got
chance to used it.
Now for one of my project I decided to use above
explained circuit.
I noticed one strange behaviour of above circuit
which I am not able to understand fully.

Circuit gives exact calculated gain, when R1 is


connected to neutral of grid & live wire to R4.
But moment we inter change the input
connection gain of circuit comes totally di�erent
then previous case. Simulation does not show any
behaviour like this.
did you observe anything like this ???

Reply

saheed
January 17, 2017 at 8:32 pm

Thanks sir,more power to your elbow


I will like to have the full code sir

Reply

Pawan Meshram
February 2, 2017 at 4:15 pm

can u send me complete circuit diagram and code


Reply

Jay
March 1, 2017 at 10:34 am

Is a di�erence ampli�er the same thing as a


di�erential ampli�er or are you referring to a
method of measurement with an op amp? This
was unclear to me.

Thanks,

Jay

Reply

francis
March 7, 2017 at 10:02 am

I love this.please send me complete details on


this.

Reply

Rohan
March 9, 2017 at 9:51 pm
Hello, I have a query. In the di�erence ampli�er, I
am giving the Amplitude of 311V (for 220v) but
the LCD is showing 220v (No Fault) and for for the
amplitude of 340V (240V), the LCD is showing
240v (No Fault).
Then I realized that the circuit trips (Shows fault)
when the voltage reaches to 260V in the LCD.
I want to change this part. Can you please point
out that which part of this code is needed to
change?
Your project is really awesome, but if you help me
a little, it will be very much appreciable.
Thanks in advance 🙂
Reply

Sandar Lwin
March 12, 2017 at 6:21 pm

great work,, pls send me the code and schematic


of voltmeter and ammeter projects in mikroC.
thank you.

Reply

Nasaii Mustafa
March 13, 2017 at 9:13 pm
Hi Mr. Bilal Malik. actually im interested to the
“Alternating voltage measurement circuit
diagram(with complete code)”.Which is it can
measure 240Vac and current �ow. So how can i
get the code and circuit? if need pay or anything.
Please reply me on [email protected]. Thank
You Mr Bilal Malik

Reply

Bilal Malik
March 13, 2017 at 9:34 pm

contact me at
[email protected] if you want
to purchase code and circuit diagram

Reply

Ramtec
March 14, 2017 at 3:26 am

Hello. Thank you very much for your helpfull ac


measurement circuit.
I built it in an pcb and make my own program. It
work �ne, but i am having a problem with the
linearity.
I adjust the voltage for 120V and it look �ne, but
when the voltage is low than 60V, the voltage
measured is more or less 4 to 5V di�erent. When
the voltage is 180V, the measurement is more or
less 10V Di�erent.

What could be the problem.?

Reply

Emeraldo Ramos
May 15, 2019 at 5:03 pm

Can i get help about it?

Reply

José Miguel
March 31, 2017 at 1:49 am

And the divider voltage was not considered in the


calculations….

v= ADC_Read(0);
v =v*(10.0/1023.0);
…………
v = v*2; -> divider voltage was not considered
…………
v=(v-5.0);
t[i]=v*110.1909091;

Reply
José Miguel
March 31, 2017 at 2:08 am

Jajaja ok, I have paid more attention to C code.

v =v*(10.0/1023.0); // Here is v*2


Above is the same this:
v =v*(5/1023.0);
v =v*2;
Regards
Reply

Amanti
June 1, 2018 at 10:57 pm

Hi can i get full c code of this code . Thanks so


much!!

Reply

Snoc
April 5, 2017 at 2:29 pm

Very nice design and tutorial. But I would really


appreciate it if I get the the complete �le on the
di�erence appli�er type via my email.
Thanks.
[email protected]

Reply

Ali
April 12, 2017 at 10:54 pm

sir kindly send all details with code at


[email protected]

Reply
Nishit sehgal
July 19, 2017 at 12:13 pm

Hi,
why you are running for loop for only 39 times
and where you are using t[40] value, it is
confusing me,
i am also not able to change the value of power
supply to ampli�er and to R11 resistor, it is by
default Vcc, does that make any di�erence- dont
know how to make 12v or 5v.

How i can measure voltage being supplied by AC


voltage source.

Awaiting response

Reply

kang,yonkkoo
July 23, 2017 at 5:31 pm

please send me complete all details with code at


[email protected],thank you~

Reply

Hossein
September 10, 2017 at 2:18 pm
Hello dear,
thank you for this teach, I create this circuit but I
have 2.5 volt in op-amp output(after R9), so I
measurement input voltage, after R1,R4 I have
98.5V AC, after R2,R5 I have ~0.3 VAC and after
R3,R6 I have ~0 VAC, so when I remove input 220
volt Output not change!!!
Can you help me for knowing where is my
mistake???
thanks a lot.

Reply

Hossein
September 14, 2017 at 11:31 am

Hello,
I use LM358, and couldn’t give a normal output,
so when I remove the Op-Amp. I can see 3.01
VAC after 2.2K resistors. but when op-amp is in
circuit output voltage is 0!!!!

Reply

usha
October 20, 2017 at 5:40 am

please mail me the code for this project


my mail id [email protected]
Reply

ayush kothari
October 26, 2017 at 5:56 pm

hello…..plz mail me the code and proteus �le


my id…[email protected]
Reply

Joachim
October 27, 2017 at 3:14 pm

Send me code and circuit diagram please:


[email protected]

Reply

rohit
October 29, 2017 at 11:33 pm

hey ,
osm teach
how you maintain it to show current values on lcd
Reply

rohit
October 29, 2017 at 11:38 pm

please send me other codes and details

Reply

naad
October 31, 2017 at 1:00 am

can i get the simulation please

Reply

Ayanda
November 17, 2017 at 7:42 am

Hi, please send me the complete code and circuit


diagram.
thank you in advance

Reply
Milos
December 22, 2017 at 2:26 pm

Can you send me a code for AC Voltmeter?


[email protected]

Thank you.

Reply

gokula krishnan
January 17, 2018 at 12:13 pm

pic 16f877a controllers adc can measures dc


pulsating voltage or not…… if not how can i
convert into steady dc… (i.e my input 2.5vdc
pulsating voltage am required same voltage in
steady dc voltage)….pls help me….
Reply
Sushil K. Gaonkar
August 11, 2018 at 10:04 am

Input is not received in constant way , how we


can use the formula.

Reply

hosjiu
January 19, 2018 at 9:57 am

Hi, please send me the complete code and circuit


diagram.
thank you in advance.
[email protected]

Reply

chathuranga
March 23, 2018 at 5:39 pm

Sir, please send me complete code and circuit


diagram. thank you

Reply
Mho
April 3, 2018 at 1:31 pm

Nice tutorial. I want to ask concerning the linearity


of the circuit. Has anyone built it in real life? Is the
linearity recommendable? I just ask because I
tried it on proteus, and I didn’t get very impressive
results, so I am curious if anyone has actually built
it.
Thanks.

Reply

s.vinoj
April 12, 2018 at 7:38 am

could you please send me the complete circuit


diagram.
Reply

omayma
April 13, 2018 at 3:26 am

Can you send me a code for AC Voltmeter


Reply

oumayma
April 13, 2018 at 5:33 pm

please i need the complete code for the AC


voltmeter so i can design the setup as you have
already done. Thank you sir
Reply

Bhautik
April 13, 2018 at 6:06 pm

I see that you have used Separate 5v source for


incresing dc level and powering pic. What can you
suggest if you want to achieve same just by using
AC input . Could you Explain that

Reply

Sanjay Dalvi
April 17, 2018 at 7:36 pm

Excellent article. Can you pls send e the code


My mail ID : [email protected]

Reply

mahdi
April 30, 2018 at 10:39 pm

hi
please send me code

Reply

GOd's will
May 10, 2018 at 1:24 am

help please i am getting a �xed -388v in my lcd.. i


am using proteus and 16f876
Reply

Idris
May 23, 2018 at 2:27 pm

Firstly thank you sir for ur support.


I did as u instructed but at output of my LCD it
was giving me 388v please what is d solution sir.
Reply

Nitin Patil
June 6, 2018 at 6:06 pm

Hi, I am looking for low cost ac voltage sensing


circuit. would you pls email me the method using
di�erence ampli�er??
Reply

wa�
June 13, 2018 at 5:43 am

hello please send me code

Reply

Okoye Franklin
October 22, 2018 at 8:20 pm

Good day sir, I am Okoye Franklin from Enugu


Nigeria, I what to no if I can get this project from
you, How to Read AC voltage with comparator,
Am using PIC16f886 MikroC.
Reply

Mho
February 11, 2019 at 5:59 pm

Just use the code, and change the registers to


match with the ic u are using. I did the project
using pic16f886, and it works quite well. Nice
tutorial. I learnt a lot.

Reply

Gowtham
October 30, 2018 at 9:50 pm

Hi, can you send me the source code.


[email protected]
Reply

Vedika Vyas
January 8, 2019 at 5:29 pm

Hello can you please send me the C code for this


project
Reply

anil
January 9, 2019 at 2:08 pm

Di�erential ampli�er still needs a ground


reference through a resistor or a voltage divider
in your case if want to DC bias the output.
Without this the output will get saturated due to
supply limitation and voltage di�erence b.w the
inputs. This will probably never give you a true
representation of 50hz sine wave on the output.

Reply

Vishu
May 15, 2019 at 2:30 pm

Hi,

Pl send me the circuit diagram & code.

Thnaks

Reply

sanju
June 6, 2019 at 12:28 pm
please send me the ckt and code for Alternating
voltage and current measurement

Reply

Tiham
June 21, 2019 at 2:52 pm

Hi, please send me the code and circuit diagram .

Reply

Chris
July 11, 2019 at 3:14 pm

Please I need the complete code


[email protected]

Reply

diadia ndiaye
July 29, 2019 at 1:09 am

slt s’il vous plait envoyez moi le code sur


[email protected]
Reply

Emmasss
July 30, 2019 at 8:59 pm

Thanks a lot nice article

[email protected]
Reply

ibrahim baalbaki
August 1, 2019 at 4:35 pm

i need to measure 220v ac using pic16f676


without comparator please send me the whole
code and the schematic circuit
thank you

Reply

NIRAKSHAA
August 19, 2019 at 10:46 pm

SEND ME THE FILE


Reply

russell
November 11, 2019 at 12:43 am

Can I et a copy of te code


my emai;[email protected]
Reply

habte nbrete
January 9, 2020 at 6:09 pm

hi it is a nice work. can I get the code. I have an


assignment about it.

Reply

diwas
February 10, 2020 at 8:52 pm

hey! this code helped me very well so far. it will


help more if you can tell me how you calculated
the multiplication and addition
factors(values)……..thanks
Reply

JJ
April 23, 2020 at 9:36 pm

Hi,can I get the code?

Reply

james
June 16, 2020 at 11:48 pm

Will you be able to do a tutorial to measure wide


range of AC input not just 220VAC. I would say
from 85VAC to 264VAC. That will be helpful.

Thank You
Reply

Mark Chipper�eld
October 24, 2020 at 6:40 am

Looking to build a high voltage DC/AC test meter.


This could be a good starting point
Reply

Mark Chipper�eld
October 24, 2020 at 6:44 am

Hi,

Can I get the project.


Code and Proteus Project.

Mark

Reply

enrique
November 20, 2020 at 7:01 pm

Excelentes proyectos ,muchas gracias


Reply

osman
December 30, 2020 at 9:07 pm

dear
how can i control controll load use this program?
please help me.
thanks in advance.

Reply

Mohit Nair
January 8, 2021 at 10:45 pm

Very informative.Thank you very much.Please


share your mikroC code as well.

Reply

eng.zaid
January 9, 2021 at 3:10 am

why do i get an o�set of 17 volts?

Reply
Prince
February 4, 2021 at 5:27 am

How much cost if anyone use PT in this project


you have mentioned?

Reply

‫ﻣﻬﺪﯾﺎر ﻣﻘﺪم‬
February 12, 2021 at 2:59 am

Hi… Thanks for your circuited but … It can be so


useful if you calculate the accuracy of this circuit
by considering tolerance of resistors… I do that
and Its too bad.
Assume : v in peak = 300v , tolerance = +%5 , u
Controller ADC = 10 bits , v ref = 3.3v
gain = 0.00915827
v out real = 2.74788 => v out adc = 2.748 => v in
(calculated by u controller) = 301 v

Assume : v in peak = 300v , tolerance R8 = +%5 , ,


tolerance R1 , R2 and R3 = +%5 ,u Controller ADC
= 10 bits , v ref = 3.3v
gain = 0.0101223
v out real = 3.03669 => v out adc = 3.036 => v in
(calculated by u controller)= 333.62

———————————————————————
———————————————–
Reply

Microcontrollers Lab
February 12, 2021 at 11:15 am

Well, it depends on how many samples you take


and then average them out. Also, using a
correction factor always serves the purpose for
low costs designs like this.

Reply

haider
June 4, 2021 at 1:39 am

Can you help me with a project


solar energy measurement using pic
microcontroller

Reply

Leave a Comment
Name *

Email *

Website

Notify me of follow-up comments by email.

Notify me of new posts by email.

POST COMMENT

PIC Projects List


AC Voltmeter

Temperature sensor

Digital Frequency Meter

Digital humidity Meter

Pure Sine Wave Inverter

Greenhouse Control System

Under and Over Voltage Protection

Solar Charge Controller

Control of street lights


Line follower Robot

Automatic Transfer Switch

Buck Converter

Boost Converter

Buck-Boost Converter

Intensity Street Lights

Solar Power Auto Irrigation

Solar Tracking System

Metal Detector Robot

Solar Energy Measurement

Time-based Solar Tracking

Zero-crossing Detector

Power factor Meter

Digital Watt Meter

Power Factor Controller

Digital Voltmeter

Digital Ammeter

Digital Ohmmeter

Digital DC wattmeter

Digital clock

Speed Control Induction Motor

AC Power Control

Sine wave frequency Meter

Automatic Electronic Bell

DS18S20 Interfacing

Digital Thermometer

Footstep Power Generation

Soft Starter 3 Phase Induction Motor

Voltage Stabilizer

Multiple Input Charger


GSM based devices control

HUMANOID robotic ARM

Electronic lock

Bluetooth home automation

Wireless controlled robot

Digital multimeter

Contactless tachometer

Password circuit breaker

Bluetooth Controlled Robot

Remote controlled home Automation

Wireless electronics notice board

Vehicle Theft Intimation

Load Control Energy Meter

Vehicle Tracking System

Electric Energy Theft Intimation

Parking management system

IoT Based Load Control

Three Phase Motor Drive

RFID based Electronic Lock

Three-phase Voltage Meter

Prepaid Energy Meter

RFID Attendance System

Three Phase Solid State Relay

Thyristor Controlled Power

Cyclo Converter

Esp8266 Home Automation

Hand Gesture Robot

Voice Controlled Home Automation

Density-Based Auto Tra�c Signal

Energy Management System


Auto Power Supply Control

Flexible AC Transmission System

Four Quadrant Control DC Motor

Remote Monitoring of Transformer

Underground Cable Fault

Power Grid Synchronization

Flammable Gas Prevention

Ultrasonic Radar System

IoT based temperature data logger

Home security system

3 phase ac power Meter

Wireless Health Monitoring

Monthly Electricity Billing

Liquid Level Controller

BLDC Speed Control

Vehicle Movement Street Light

Worker Alcohol Detector

IoT Based ICU Patient Monitoring

GPS based clock

Display GPS Co-ordinates

Temperature controller

GPS based speedometer

GSM based dc motor control

PC Controlled Stepper Motor

XBee Based Device Control

Accelerometer Based Tilt Sensor

Accident Alarm

Temperature and Gas Monitoring

dspic33fj12GP202 SPWM

DsPIC33F Sine wave inverter


MPPT Charge Controller

Heartbeat pulse sensor

Digital Barometer

ACPWM Induction Motor

Rotation Induction Motor

Closed-Loop Control BLDC

Fire Plus Gas Detection

Power Meter Billing

Bill Prediction with SMS Alert

Touch Screen Home Automation

Ultra-Fast Electronic Circuit Breaker

IoT Smart Energy Meter

IoT based Liquid Level Monitoring

IoT based Weather Reporting

IoT Based Toll Booth Manager

Coin Based Water Dispenser

Three-phase SVPWM

3 phase sine wave inverter

3 phase VFD

Variable Frequency Drive

soft starter for single phase

Programmable AC Power Control

AC Dimmer of Two Loads

Informative Blind Stick

Induction Motor Protection

Multilevel Inverter

DC motor speed control

AC Current Meter

DC Voltmeter 7-Segment
Subscribe to Blog via Email

Email Address

SUBSCRIBE
PCB Assembly Services
Categories

Select Category

ADVERTISEMENT

Recent Posts
ESP8266 Send Sensor Readings to Google Firebase and Build an
Android app to display Data

ESP32 Send Sensor Readings to Google Firebase and Build an


Android app to display Data

BME680 with Arduino: Display Gas, Pressure, Temperature and


Humidity on OLED

MicroPython ESP32 and ESP8266: Program with VS Code and Pymakr

ESP8266 NodeMCU Server-Sent Events (SSE) Web Server (Arduino


IDE)

ADVERTISEMENT
Tutorials
ESP32
ESP8266
Pic Microcontroller
8051 Microcontroller
MSP430 Microcontroller
Arduino
Tiva LaunchPad

Subscribe to Blog via Email


Enter your email address to subscribe to this blog and receive
noti�cations of new posts by email.

Email Address

SUBSCRIBE

Recent Posts
ESP8266 Send Sensor Readings to Google Firebase and Build
an Android app to display Data
ESP32 Send Sensor Readings to Google Firebase and Build an
Android app to display Data
BME680 with Arduino: Display Gas, Pressure, Temperature
and Humidity on OLED
MicroPython ESP32 and ESP8266: Program with VS Code and
Pymakr
ESP8266 NodeMCU Server-Sent Events (SSE) Web Server
(Arduino IDE)
Copyright © 2013-2021 Microcontrollerslab.com All Rights
Reserved

You might also like