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.

reading ac voltage in pic micro

Status
Not open for further replies.

raman00084

Full Member level 6
Joined
Nov 29, 2010
Messages
362
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,298
Activity points
4,006
i want to read ac voltage, to measure accurate line voltage. for this i have chosen a 6v step down transformer. i don't want to convert to dc that is by adding bulky capacitors the linearity and response time is poor.
kindly tel me how to do the above i want accurate reading kindly suggest the method and sample code i am using ccs compiler pic 18f4620 it has 10 bit adc .


regards
kalyan
 

hello,


look at **broken link removed** 230V AC measure with ransfo for insulation
 

Hi,

For high precision I recommend this:
Transformer - DC shift - attenuation + filter - ADC - RMS calculation.

==>

The nominal output of the transformer is 6V RMS, this means about +/-9V.
With low load expect more.

Your PIC has an analog input voltage range, it usually depends on the used Reference voltage.
(For accuracy reasons I don't recommend to use VCC as reference)

Let's assume you use an external reference and your analog input voltage range is 0...3V.
Then use a voltage divider to generate half the input range = 1.5V (two equal resistors and a capacitor should do)

Connect one transformer secondary out to the 1.5V.
Use a resistive voltage divider at the secondary that the voltage is lower than your ADC input range.
Connect the secondary out to a low pass filter (FC should be lower than f_sample /2).
Then to the ADC input. Use two external input protection diodes to gnd and VCC.

Select an sample rate wich is multiple of mains frequency, maybe 32 x f.

In software do the RMS calculation.

Klaus
 

Another option is to rectify the voltage after transformer. You could measure several samples per half-cycle, and calculate the rms value. I'm assuming that you don't want the peak value, but the true rms.

[EDITED]

Would not work:
Drop voltage across diode would affect result.
 
Last edited:
  • Like
Reactions: DanyR

    DanyR

    Points: 2
    Helpful Answer Positive Rating
Perhaps this project can help you: it contains an AC RMS voltmeter: https://www.edaboard.com/threads/343354/#post1464958
see the "Isolated" version.





- - - Updated - - -

If you assume that the mains voltage to measure is always sinusoidal (reasonable assumption), then you do not have to do all the sampling as described in the wattmeter document (see previous post). Simply measure the peak voltage (with a simple hardware peak detector) and calculate from there the RMS voltage. Do however take its diode voltage drop in mind...
If doing a peak detection as described above after a transformer, then do not use the same transformer for the supply of your pic etc...
You can avoid of course also the hardware peak detector, do the full sampling and pick the maximum (peak) value...
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top