View previous topic :: View next topic |
Author |
Message |
dani
Joined: 02 Jun 2004 Posts: 16 Location: Pakistan
|
how to measure AC voltage Using PIC |
Posted: Wed Sep 21, 2005 1:28 am |
|
|
Hello all,
I want to design a low cost PIC based Digital Voltmeter which can measure ac voltage for 0v to 300v. Any circuit ideas then plz tell.
regards |
|
![](templates/subSilver/images/spacer.gif) |
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Wed Sep 21, 2005 1:46 am |
|
|
I am not very experianced but this is my advice:
decide first what kind of PIC you want to use. Then search the Datasheet for maximum voltage of that PIC (I don't know if there are any PICs who will work with a voltage of 300V). Then you need to "downgrade" the voltage to get it within the PICs voltage bounds. Then you need to connect that circuit to a analog input of the PIC and some code and it will work.
Hopefully you can use some of this information.
an small example for the code:
Code: | int ADC_read(int channel)
// Input : channel - pin channel to be used
// Output : void
// Action : reads an analog input from channel and converts it to a digital value
{
set_adc_channel(channel);
delay_us(50);
return read_adc();
}
void ADC_init()
// Input : void
// Output : void
// Action : initializes ADC
{
setup_adc_ports(A_ANALOG_RA3_REF); //sets A0, A1, A2 and A5 to analog and A3 to Vref
setup_adc(ADC_CLOCK_DIV_32); // define clock settings
} |
|
|
![](templates/subSilver/images/spacer.gif) |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Wed Sep 21, 2005 2:43 am |
|
|
Hi,
Firstly you need bring the voltage to 5 V dc, using a transformer and a voltage regulator like 7805.
Then you have to use another transformer (or maybe the same ), like 300/12 V ac, rectify the voltage to DC using a diode bridge, a suitable capacitor , since the voltage is around 14 V dc , you must bring this down to a peak voltage of 5 V dc (but ensure the input supply is 300 V AC when the DC voltage is 5 V).
To reduce the voltage you have to drop the voltage across resistances so that the output voltage given to ADC does not exceed 5 V . The resistance values depend on the transformer used..For protection you could use a 5.1 V zener diode connected across the ADC port. Software configuration is quite basic.
I don't think this needs any explanation.
If the voltage across the transformer is less than 300 V , the DC output voltage also reduces ( thus the AC voltage is analogous to the DC voltage).
One problem you could face with this method is linearity, you might find that at high voltages the readings are correct, whereas at low voltages it is not.
thanks
arun |
|
![](templates/subSilver/images/spacer.gif) |
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Wed Sep 21, 2005 8:34 am |
|
|
To measure 300V you need a voltage divider to get scale 300V down to the 5V most PIC A/Ds are built for. Next you need a precision rectifier to convert the DC to AC. Most of these use two op amps.
I don't have time now for a more detailed description but googling voltage divider and precision rectifier should get you some useful ino.
It is also possible you could synchronize your A/D readings to the AC line cycle. Then you could eliminate the rectifier circuit and replace it with software. A lot depends on the accuracy you need.
Also look up Microchip application note 521 or 527 or something like that that deals with connecting a PIC to AC power lines. _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
thanks for reply |
Posted: Thu Sep 22, 2005 5:43 am |
|
|
Hi all,
Thansk for reply,
I have used bridge recitfier and suitable devider network of resistors and then capasitors to get scale
0v ac --- 0v dc To
500v ac--- 5v dc
but i cannt get linearity i.e. reading differs at low voltages. |
|
![](templates/subSilver/images/spacer.gif) |
sseidman
Joined: 14 Mar 2005 Posts: 159
|
Re: thanks for reply |
Posted: Thu Sep 22, 2005 6:53 am |
|
|
Anonymous wrote: | Hi all,
Thansk for reply,
I have used bridge recitfier and suitable devider network of resistors and then capasitors to get scale
0v ac --- 0v dc To
500v ac--- 5v dc
but i cannt get linearity i.e. reading differs at low voltages. |
Why don't you build a lookup table and use simple linear interpolation to give you your value? You only need two points to define the linear region. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Sep 22, 2005 7:08 am |
|
|
I'd say "don't use a bridge rectifier". The problem here is that diodes, inherently have a drop, and also non-linear behaviour, and at low voltages this becomes significant. You can correct partially for this with a lookup table, but at really low voltages, there will be nothing coming through to correct. You need a precision rectifier, not a conventional 'bridge'. With a precision rectifier, you use an op-amp, to compensate for the diode drop. Have a look at:
<http://www.play-hookey.com/analog/full-wave_rectifier.html>
for a typical simple circuit. There is also a slightly simpler 'half wave' version, which for voltage reading will be fine. Remember also, that the impedance of the divider you are using, will be significant, if this is feeding directly to chip's analog input. You also then need to process the signal, to either integrate it (for the average reading), or take the peak level (for a peak voltage reading), otherwise the values being read, wil vary according to where in the mains cycle, the AD samples.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
Re: how to measure AC voltage Using PIC |
Posted: Thu Sep 22, 2005 11:32 am |
|
|
dani wrote: | ... which can measure ac voltage for 0v to 300v. |
I guess, you'll be making a differential measurement of the high voltage. To bring the high voltage down, you could use a differential amp with A<1. You could roll your own with an amp and 4 external resistors, or you could use the one with internal resistors like AD628. The latter has matched resistors.
Nick |
|
![](templates/subSilver/images/spacer.gif) |
|