Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
March 28, 2024, 08:39:30 20:39


Login with username, password and session length


Pages: [1]
Print
Author Topic: How to measure AC voltage with pic without converting to DC  (Read 24706 times)
0 Members and 1 Guest are viewing this topic.
localcrack
Active Member
***
 Muted
Offline Offline

Posts: 173

Thank You
-Given: 64
-Receive: 21



« on: May 28, 2009, 09:03:22 09: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.

please post it..
Logged
Thiru09
Cracking Team
Senior Member
****
Offline Offline

Posts: 319

Thank You
-Given: 383
-Receive: 1164



« Reply #1 on: May 28, 2009, 10:17:45 10: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:

    Your ADC should have faster conversion capability.
    For higher frequencies, this method may not be applicable.
    Maintain a fixed delay between successive reads of ADC.

Please let me know if you have any problems.

With best regards,
Thiru
Logged
titi
Active Member
***
Offline Offline

Posts: 229

Thank You
-Given: 3679
-Receive: 834



« Reply #2 on: May 28, 2009, 07:26:05 19: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:
  if ReadADC>Value then
    Value=ReadADC
  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 Offline

Posts: 110

Thank You
-Given: 53
-Receive: 51


« Reply #3 on: May 28, 2009, 09:17:55 21: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.
The ADC voltage will be: Umeas*(R1/2)/(R3+R1/2). Adjust division factor for Vpeak= maximum ADC voltage.

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 Offline

Posts: 115

Thank You
-Given: 71
-Receive: 13


« Reply #4 on: June 02, 2009, 12:02:19 00:02 »

hi friends,

How about ac square wave?
« Last Edit: June 03, 2009, 12:13:43 00:13 by free » Logged

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

Posts: 254

Thank You
-Given: 141
-Receive: 178


« Reply #5 on: August 15, 2009, 11:40:44 11: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 Offline

Posts: 13

Thank You
-Given: 175
-Receive: 4


« Reply #6 on: August 15, 2009, 04:03:45 16: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.
The ADC voltage will be: Umeas*(R1/2)/(R3+R1/2). Adjust division factor for Vpeak= maximum ADC voltage.

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 Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #7 on: August 17, 2009, 01:37:03 01:37 »

@ Faros

 Grin 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..
 Grin   then again we are splitting hair here   Grin
Logged

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

Offline Offline

Posts: 5

Thank You
-Given: 10
-Receive: 0


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

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


Logged
Faros
Senior Member
****
Offline Offline

Posts: 254

Thank You
-Given: 141
-Receive: 178


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

Hi Parmin,

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

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 Offline

Posts: 582

Thank You
-Given: 494
-Receive: 133


Very Wise (and grouchy) Old Man


« Reply #10 on: August 18, 2009, 01:48:24 01:48 »

 Cheesy

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  Roll Eyes

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

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

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 Offline

Posts: 44

Thank You
-Given: 16
-Receive: 18


« Reply #11 on: September 17, 2009, 03:57:27 15: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 Offline

Posts: 229

Thank You
-Given: 3679
-Receive: 834



« Reply #12 on: September 17, 2009, 06:23:35 18: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.

And please, read my previous post and this of Thiru09.

Best Regards.
« Last Edit: February 12, 2012, 08:58:16 20:58 by titi » Logged
sam_des
Senior Member
****
Offline Offline

Posts: 253

Thank You
-Given: 124
-Receive: 146


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

Hello,

Check the attached file for AC line measurement without lossing it's shape.
Any comments are welcome ...

regards,
sam_des
Logged

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

Posts: 173

Thank You
-Given: 64
-Receive: 21



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

where is proteus 7.6

I can't open the file
Logged
titi
Active Member
***
Offline Offline

Posts: 229

Thank You
-Given: 3679
-Receive: 834



« Reply #15 on: September 18, 2009, 04:32:09 16: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]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC