Entire Forum This board This topic Members Entire Site
 Pages: [1]
 Author Topic: How to measure AC voltage with pic without converting to DC  (Read 21663 times) 0 Members and 1 Guest are viewing this topic.
localcrack
Active Member

Offline

Posts: 175

Thank You
-Given: 64

 « on: May 28, 2009, 03:03:22 03:03 »

Hi friends,

I need AC voltage (0v to 450V) measurement circuit with pic.

I need such types of circuits that directly measures ac voltage without converting it to dc.

I also requires code in c.

 Logged
Thiru09
Cracking Team
Senior Member

Offline

Posts: 262

Thank You
-Given: 306

 « Reply #1 on: May 28, 2009, 04:17:45 04:17 »

Dear friend,

You may measure the AC directly by the following method:

1. First, step down the input AC voltage to 5V peak (depending upon your VCC). Here, you have to consider the peak level of AC. RMS value is lesser than its equivalent peak value.

RMS value = Peak / 1.414

You can use resistor divider network or transformer for this purpose.

2. Start scanning of voltage channel ADC. This can be done in two ways:

Make zero crossing detector and start reading the ADC after the zero crossing pulse is detected.

OR

Depending upon the frequency, read the ADC for a complete cycle. (You may not read one complete cycle from 0 to 360 deg, but no problem).

3. Average the samples got in one complete cycle. This reading will be proportional to the amplitude of input AC voltage. You need not convert the reading to RMS. Just apply calibration factor and calibrate it w.r.t. actual RMS value of input voltage.

You have to consider the following:

For higher frequencies, this method may not be applicable.

Please let me know if you have any problems.

With best regards,
Thiru
 Logged
titi
Active Member

Offline

Posts: 210

Thank You
-Given: 1900

 « Reply #2 on: May 28, 2009, 01:26:05 13:26 »

Hello,

To complete the method, i think it is more easy to read ADC at the maximum speed for a time of 2 periods by example and retain the max value of the ADC, so you have detect Peak and then you can calculate RMS value.

To detect the max value of ADC, it is easy to do that:

Value=0
Loop:
endif
if not end of time of 2 period then Loop

At the end of the time of 2 periods, you have in the variable Value the Max of ADC.

Some time detect zero crossing is not so easy because offset DC and noise on input pin of ADC.
Dont forget to protect the ADC input with a resistor and a reverse diode (1N4148) from the negative side of the wave.
You could also use only a resistor since the PIC has build-in diodes on each inputs.

Best Regards.
 Logged
an007
Active Member

Offline

Posts: 111

Thank You
-Given: 53

 « Reply #3 on: May 28, 2009, 03:17:55 15:17 »

try this:

do a voltage divider with 3 rezistors: R1 placed between V+ and ADC pin, R2 placed between GND and ADC pin (R1=R2), R3 placed between measured phase and ADC pin.

Do the folowing:
1. Get rid of dc level in the signal
a. DC_Average = sumOfSample/n
b. For each sample samples = PositiveValueOf(samples - DC_Average)
2. Calculate VRMS as folow:
samples=samples*samples; // square
value=samples+value; //sum of squares (for i=1 to n), n number of samples

value = value/n; // Mean of n samples
value = sqrt(value); // Square root

volts=(float)value*k ;multiplyng with division coefficient

hope helps,
//an
 Logged
free
Active Member

Offline

Posts: 115

Thank You
-Given: 71

 « Reply #4 on: June 01, 2009, 06:02:19 18:02 »

hi friends,

 « Last Edit: June 02, 2009, 06:13:43 18:13 by free » Logged

Some dream to escape reality, some to change it forever.
- Soichiro Honda -
Faros
Senior Member

Offline

Posts: 253

Thank You
-Given: 133

 « Reply #5 on: August 15, 2009, 05:40:44 05:40 »

Sorry for this late reply; didn’t notice before. I have designed the attached circuit 3 years ago; it is simple and should fulfill your requirements. The code is in Proton Basic but it can be easily coded in C. the sense code is just few lines. Just change R2 to 56K Ohm and use a bridge that can stand mains voltage.

Attached is Protues file + Code in Proton
 Logged
spider
Newbie

Offline

Posts: 13

Thank You
-Given: 175

 « Reply #6 on: August 15, 2009, 10:03:45 10:03 »

try this:

do a voltage divider with 3 rezistors: R1 placed between V+ and ADC pin, R2 placed between GND and ADC pin (R1=R2), R3 placed between measured phase and ADC pin.

Do the folowing:
1. Get rid of dc level in the signal
a. DC_Average = sumOfSample/n
b. For each sample samples = PositiveValueOf(samples - DC_Average)
2. Calculate VRMS as folow:
samples=samples*samples; // square
value=samples+value; //sum of squares (for i=1 to n), n number of samples

value = value/n; // Mean of n samples
value = sqrt(value); // Square root

volts=(float)value*k ;multiplyng with division coefficient

hope helps,
//an

Ok AN007
that is truly.
 Logged
Parmin
Hero Member

Offline

Posts: 558

Thank You
-Given: 378

Very Wise (and grouchy) Old Man

 « Reply #7 on: August 16, 2009, 07:37:03 19:37 »

@ Faros

yes your method works, but, if you read the OP, there is a restriction given.
That is the measurement is to be done without converting the AC voltage to DC.
The circuit you gave will do the job very well, but well..
it does not really give the solution..
then again we are splitting hair here
 Logged

If I have said something that offends you, please let me know, so I can say it again later.
sonicm
Inactive

Offline

Posts: 5

Thank You
-Given: 10

 « Reply #8 on: August 17, 2009, 04:31:21 04:31 »

but the pic power is DC, and PIC can measure only DC
if you don't need to convert AC to DC
if you use another ic then still need to convert to DC before send to pic

 Logged
Faros
Senior Member

Offline

Posts: 253

Thank You
-Given: 133

 « Reply #9 on: August 17, 2009, 12:21:04 12:21 »

Hi Parmin,

Long time didn’t hear from you, missed you dear friend …

Will you consider that using a current sensing as an AC-DC conversion? … I have another solution but it will be slower than the one I have posted before. (Thermal based sensing, light sensing).
 Logged
Parmin
Hero Member

Offline

Posts: 558

Thank You
-Given: 378

Very Wise (and grouchy) Old Man

 « Reply #10 on: August 17, 2009, 07:48:24 19:48 »

Truthfully, I do not have an answer on whether or not I approve the method presented.
Nor do I have any authority to say whether or not any of those are the correct answer

Just being a busy body, I read the OP say that the measurement is to be made without conversion of AC to DC
And I read the answers provided where all of them is in fact doing it WITH conversion..

Like any good puzzle - fundamental type questions like these does not surface often..
and whenever they do, it is good to see if someone have in fact created a better mouse trap..

I am here everyday Faros, but I do not post everyday.
Somehow I did not see much of your posts either?
How are you?
 Logged

If I have said something that offends you, please let me know, so I can say it again later.
preatorian
Junior Member

Offline

Posts: 44

Thank You
-Given: 16

 « Reply #11 on: September 17, 2009, 09:57:27 09:57 »

Hi all,
not a complete solution due to lack of time, but this is an idea. Use rsistor devider to bring down the peak to peak amplitude to around 4.5V..4.9V (depends on the case of ensurance you want). This is done with an star type connection of three resistors (connected to GND, Vdd, and Vmeasure) in such a way when shortened the input, the common point of all to be Vdd/2. Then you should measure the offset and half peak up and other half peak down in order to take in calclations the resistor's variations. Then you simply measure the input, recalculate (resistor correction) and use the formula in the link supplied by attachment here. There is a true rms measurment formula described, which plus is you can measure any waveform you like. The minus you have to perform sqware rooth calculations.

Regards
 Logged
titi
Active Member

Offline

Posts: 210

Thank You
-Given: 1900

 « Reply #12 on: September 17, 2009, 12:23:35 12:23 »

Hello,

in my previous message, i explains how mesure by example 220v AC with a PIC without using some converter to transform AC to DC.
It use just 2 resistors and a Diode.

D1 is only use to protect PIC against reverve voltage.

Here is how do that with an example in Proteus 7.6.

Best Regards.
 « Last Edit: February 12, 2012, 02:58:16 14:58 by titi » Logged
sam_des
Active Member

Offline

Posts: 223

Thank You
-Given: 62

 « Reply #13 on: September 17, 2009, 01:16:33 13:16 »

Hello,

Check the attached file for AC line measurement without lossing it's shape.

regards,
sam_des
 Logged

Never be afraid to do something new. Remember Amateurs built the Ark, Professionals built the Titanic !
localcrack
Active Member

Offline

Posts: 175

Thank You
-Given: 64

 « Reply #14 on: September 18, 2009, 09:29:40 09:29 »

where is proteus 7.6

I can't open the file
 Logged
titi
Active Member

Offline

Posts: 210

Thank You
-Given: 1900

 « Reply #15 on: September 18, 2009, 10:32:09 10:32 »

Hello,

You can open it with Proteus 7.5 SP3.

For Proteus 7.6 use Button Search proteus 7.6

Best Regards
 Logged
 Pages: [1]