Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AC voltage Measurement Problem

Status
Not open for further replies.

Pulsetronics

Member level 3
Member level 3
Joined
Oct 31, 2014
Messages
67
Helped
9
Reputation
18
Reaction score
9
Trophy points
8
Location
Lagos
www.pulsetronics.blogspot.com
Activity points
382
I tried measuring AC voltage using Potential transformer of 6v output and rectified before passing through a capacitor 1uf 50v and voltage Divider (390k and 10k) then to adc pin , the voltage at ADC pin is stable but the voltage at the output varies.

Code:
// using mikroC as compiler
 Float  i;
 Char volt[6];
While(1){
  I = Adc_read(0);
  I = I * 5000/1023;
  I= I /10 ;
  Floattostr(I, volt);
  Volt[5] = 0;
 Lcd_out (1,1" Ac voltage: ");
Lcd_out_cp(volt);
  Delay_ms(1000);
}
 

When you say "the voltage at the output varies" do you mean the voltage reported by the software varies? How much does it vary? What is your hardware?
 

try this way
Code:
// using mikroC as compiler
 Float  i;
 Char volt[6];
While(1){
  I = Adc_read(0);
  Delay_ms(1);
  I = I+I;//1
 Delay_ms(1);
 I = I+I;//2
 Delay_ms(1);
 I = I;//....n
 Delay_ms(1);
 I = I/n
 
  I = I * 5000/1023;
  I= I /10 ;
  Floattostr(I, volt);
  Volt[5] = 0;
 Lcd_out (1,1" Ac voltage: ");
Lcd_out_cp(volt);
  Delay_ms(1000);
}
 

I means sometimes it displays 240v,174v, 200v and so on but voltage at the ADC pin remains 2.2v...my question is should I increase the capacitor used to Filter the rectified output from 1u to 100u?
 

If, as you say, the input to the adc is constant, do you expect that adding a capacitor will make it 'more constant'? Again, WHAT IS YOUR HARDWARE? If you are driving the ADC directly from your voltage divider, I would suggest adding a buffer between the divider and the ADC. The ADC may be loading the divider. Are you SURE there's no ripple on the ADC input? Have you actually looked at it with an oscilloscope?
 

Two problems:

1. the capacitor should be across the voltage not having it 'pass through' it.
2. The ADC input drive impedance is probably far too high to it to precharge it's sample and hold circuit. Consider using much smaller resistor values.

Show your schematic, it sounds like you have almost everything wrong!


Brian.
 

adc.jpg

That's the sketch of my circuit
 

To get more stable readings,
!) Take many samples of ADC and take average.
2)Increase 0.1uF capacitor to 10uF-22uF.
 

Thanks to everyone.. But I think using high impedance input for the ADC might have caused the problem maybe I will try using a resistor of Lower values.

I know the problem is not from the software. I will also change the capacitor value from 0.1u to 10u.

More suggestions will be accepted.. Thanks to you all.
 

Increasing the capacitor will make the reading more stable but at the expense of it being slower to track voltage changes. I would leave it as it is.

Personally, I would drop the divider resistors to 1/10 of their present values. That keeps the scaling factor the same but removes the possible problem of the ADC input being starved of current. Most ADC recommend that for best results the input impedance is kept below 5K.

However, I think your underlying problem is in software. You have not shown what type of variable 'I' is and you may be overflowing it. You also only take one ADC reading and then multiply it several times before dividing the result again. I suggest you restructure your program so you use a loop and repeat the ADC reading function several times while accumulating the result in a suitable variable (maybe an unsigned int or unsigned long). There is no point in adding a delay each time you pass through the loop so I would remove that altogether. At the end of the loop, do a single calculation to average and scale the result to get the voltage.

Brian.
 

You gave two different divider ratios for the voltage divider 390k/15k and 390k/10k. None of it makes sense for 6V AC input voltage (about 8.5 V peak). It also doesn't fit the voltage numbers reported for your program.

So either the circuit, the program or both must be expected to be different.

10 or 15k voltage divider is unsuitably high as ADC source impedance, review the respective PIC datasheet chapter.

For a guess about most likely reason of observed measurement variations, I would await corrected schematic/code. It should be also clarified if the ADC voltage reference (usually Vdd) is stable.

Deriving an AC voltage measurement from the peak voltage is probably the least accurate method considering possible waveform variations, but should still give better results than reported. If true rms measurement isn't an option, averaged rectified value is the next best method.
 

Thanks to you betwixt but the truth is whenever am measuring DC volts I don't face problems like this, I will surely take different samples before conversion but I strongly believe that its hardware problem.
 

hello

use a larger buffer to store result of floatToStr
Code:
char volt[17];

ADC doesn't like to have a large capacitor on his input
Increase the 1µF capacitor across the diode bridge ouput instead , and remove the capacitor on ADC input.

test the raw result to check stability.
Code:
 I = Adc_read(0);

- - - Updated - - -

hello

use a larger buffer to store result of floatToStr
Code:
char volt[17];

ADC doesn't like to have a large capacitor on his input
Increase the 1µF capacitor across the diode bridge ouput instead , and remove the capacitor on ADC input.

test the raw result to check stability.
Code:
 I = Adc_read(0);

Divide by 10, the values of Resistor divider
39K-> 3,9K
15k-> 1,5K
 

ADC doesn't like to have a large capacitor on his input
Why, particularly? In addition, I won't consider 100 nF as a large capacitor.

I believe, things are a bit different. The explicite requirement is a low source impedance for ADC inputs. A capacitor as such can't meet this requirement, but at least it doesn't hurt.
 

Thanks to you betwixt but the truth is whenever am measuring DC volts I don't face problems like this, I will surely take different samples before conversion but I strongly believe that its hardware problem.

Excuse me, but what is the difference between a "stable voltage" (your original post) and a DC voltage? If what you call a "stable voltage" is not DC, then I think we've found your problem.
 

Since you have neglected to show the return path of the ADC, we can assume it is the same ground and that you measured it with a DMM.

However this can often overlook the common mode noise and imbalanced impedance of the ADC input using a single ended input. With these many assumptions on both our parts, it is likely you are getting many issues on CM and DM noise causing errors.
 

You can should measure the AC voltage and the corresponding divider voltage and tabulate this in two columns, the AC voltage can be increased in steps of 10 or 20 Volts.

You can plot these results on the graph and see if they are linear. If the transformer gets saturated qucktly then the readings may not be linear, so you probably have to useanother transformer or implement a lookup table in the software.

If you want a readymade solution then buy something like this..https://www.yoctopuce.com/EN/products/usb-electrical-sensors/yocto-volt

thanks
a
 

You still haven't told us what kind of variable 'I' is.

You have made 'i' a float but that isn't the same variable as 'I', in C the case is important.

Have you corrected the software logic that calculates the result yet? As shown you use 'I' (whatever it is), keep adding it to itself, divide it to find the average (which will aways be 'I') then you do some math on the result. You only take one reading then possibly overflow using the unnecesary calculations.

If you want an average, try something like this:
Code:
#define samples 10
char x = samples;
unsigned int average = 0;
while(x)
{
average += (unsigned int)Adc_read(0);
x--;
}
average /= samples;
then do the appropriate scaling calculation. Sorry, I can't indent the lines with my present text editing facilities. Change the number in the #define to set the number of samples you want to take. If your circuitry is correct and you are not introdcucing noise to the measurement, you should be able to do it in one measurement, maybe two to be safe.

Brian.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top