Pages: [1] 2   Go Down
Author Topic: AC voltage measuring using arduino  (Read 4446 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to measure AC voltage using arduino and a 3-0-3 step down transformer. After rectification , I am giving the input to ADC channel. and measuring by multiplying by a factor (230/1023), But the output I am getting is around 130v
I think there is a mistake in the multiplication factor . Please help me 
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is input voltage to transformer?
What is output voltage from transformer?
Measuring voltage after a rectifier would create an error, proportional to current drown by load. You better to measure AC. 
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ac voltages are normally expressed as RMS equivalent volts unless otherwise specified. The conversation factor you will have to use in your program depends on the type of rectifier/filter you use, half wave, full wave bridge, full wave with center tapped transformer, etc. Basically the rectifier/filter will charge is some AC peak voltage value and the RMS factor will be some percentage of that value, .707 times that value is one classic value ratio.

So draw up your total wiring set-up and post your code and I'm pretty sure we can guide you to the proper conversion factor to use.

Lefty

Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is input voltage to transformer?
What is output voltage from transformer?
Measuring voltage after a rectifier would create an error, proportional to current drown by load. You better to measure AC. 


If the purpose is to just measure the normal equivalent AC primary line voltage and the only load is the arduino analog input pin then it can be done that way without significant error.
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If the purpose is to just measure the normal equivalent AC primary line voltage and the only load is the arduino analog input pin then it can be done that way without significant error.
  There would be voltage drop on bridge, even w/o load  p-n junction drop is temperature dependent.
 The question how accurate measurements OP needs, and if lag-off is acceptable.
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If the purpose is to just measure the normal equivalent AC primary line voltage and the only load is the arduino analog input pin then it can be done that way without significant error.
 There would be voltage drop on bridge, even w/o load  p-n junction drop is temperature dependent.
 The question how accurate measurements OP needs, and if lag-off is acceptable.

Yes, but if the purpose is to just measure the nominal AC line voltage, then the diode loss can be just part of the conversion factor used, as the voltage drop is fairly constant and not changing with normal AC line voltage variation.

Logged

Offline Offline
Edison Member
*
Karma: 36
Posts: 1338
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
...and a 3-0-3 step down transformer.
Sorry, I don't know what that is...   What's the output-voltage rating or the step-down ratio?   

Do you have a multimeter to measure the actual secondary voltage?

Most transformers put-out their rated voltage at full load.   A "12V 1A" transformer might actually put-out 12V when loaded to 1 Amp, but 18V with no load (or with a light load).

230VAC is the RMS voltage.   You can look-up the math if you wish, but RMS is sort-of an average*.    The peak value of a sine wave is about 1.4 times the RMS value (~plus and minus 320V peak).  And of course, the minimum is zero.    So with a rectifier, you should be getting "random" readings between zero and 320V (assuming everything is calibrated).  Or, if you put a capacitor on the rectifier output to hold the peak, you should read 320V.

Quote
...measuring by multiplying by a factor (230/1023)
You should give yourself some "breathing room"...  If 230V gives you 1023, then 250V is also going to give you 1023.


* RMS is related to power, and you get the same power with 230VAC as you get with 230VDC.  If you hook-up 230VDC to a light bulb, it will glow with the same brightness as with 230VAC.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the support and sorry for forgetting to give the details
I am using a 3-0-3 ,500 ma transformer with full wave rectifier. What I need is to measure the AC line voltage( Accuracy not so). Input is 230v/50Hz domestic line voltage.After the rectification I am using a10uF capacitor for filtering .
About 230/1023.
I think its a mistake. Since ADC is 10 bit , output voltage will be (analogout*(5/1024)). I am trying to change this.
I tried with a load resistance 10K, but readings drops to 160v
Code:
void setup()
{
  Serial.begin(9600);
}
void loop()
{
  int x,volt,y;
  x=analogRead(4);
  volt=x*(230/1023);
  Serial.println(x);
 
  delay(500);
   Serial.println(volt);
     delay(500);
}
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
About 230/1023.

If you know the the factor, then you are probably better off using the map(value, fromLow, fromHigh, toLow, toHigh) function to scale your reading, it will make your life easier.

So read in the analog value as X

Y= map(X, 0, 1023, 0, 230); //Adjust the 230 value based on real world comparison to actual measured
                                       // line voltage until they agree.

Print the Y value.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried the map function , but value was very high. Also, there is a chance of change in limit, as the voltage may fluctuate between 200-230. So I cant use that function
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried the map function , but value was very high. Also, there is a chance of change in limit, as the voltage may fluctuate between 200-230. So I cant use that function

The map function will track the changing input value and calculate the proper value every time you call it with a new value of X. You may have to adjust the 230 value if the conversion is too high, as I showed in the comment. Map is the proper tool to use and if not working for you then there is something else wrong going on.

Lefty
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

O'k, if I understand it right , your transformer is 230 / 3 - 0 - 3
But where is your bridge connected, to 3 - 0 pins or 3 - 3?
If to 3 - 3 , than after rectifier should be around   6 V  x sqrt ( 2 ) - 1.4 = 7.2 V, what is too mach for arduino input .
For 3 - 0 pins, 3 V x sqrt(2) - 1.4 = 2.8 V should be fine.
Formula to calculate AC = (( x * 5.0 / 1024 )  + 1.4 ) * ( 230.0 /  3.0 )  /  1.414)  ;
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 361
Posts: 17301
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

O'k, if I understand it right , your transformer is 230 / 3 - 0 - 3
But where is your bridge connected, to 3 - 0 pins or 3 - 3?
If to 3 - 3 , than after rectifier should be around   6 V  x sqrt ( 2 ) - 1.4 = 7.2 V, what is too mach for arduino input .
For 3 - 0 pins, 3 V x sqrt(2) - 1.4 = 2.8 V should be fine.
Formula to calculate AC = (( x * 5.0 / 1024 )  + 1.4 ) * ( 230.0 /  3.0 )  /  1.414)  ;

I'm sure your math is correct, and the algorithm makes sense, but why bother with all the complexity and floating point? As long as the rectified/filtered DC voltage is less the +5vdc for the highest possible line voltage, why not use the much simpler map() function  Y=map(x,0,1023,0,240) where 240 value is tweaked until Y indeed measures what a measurement of the line voltage actually is. The relationship is a straight linear one and the map function does that just fine using simple integer math.

Lefty
« Last Edit: March 06, 2012, 09:56:58 pm by retrolefty » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 27
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am attaching my circuit here. I will try your calculations and reply you soon




* PT.bmp (12.94 KB, 509x206 - viewed 112 times.)
Logged

Montreal
Offline Offline
Faraday Member
**
Karma: 30
Posts: 2602
Per aspera ad astra.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The relationship is a straight linear one and the map function does that just fine using simple integer math.
You are right, map would be easier, but at least bridges 1.4V (drop voltage) has to be included in map, otherwise error with 3 V transformer almost 30 %.
Quote
Y= map(X, 0, 1023, OFF-SET, 230); //Adjust the 230 value based on real world comparison to actual measured
Off- set could-be pre-calculated, approximately 230 x 1.4 / ( 3 * 1.414 )= 76 V, not very accurate , with  0.6 V per diode it's 65 V

Corrected: just noticed a drawings, there is only one diode, off-set about  230 x 0.7 / 3 x 1.414 = 38 V
« Last Edit: March 06, 2012, 10:27:45 pm by Magician » Logged

Pages: [1] 2   Go Up
Jump to: