Electronic – Arduino Analog pin problem

analogarduinocircuit analysisvoltage

enter image description here

Right now im trying to measure the AC voltage with arduino. So my plan was to convert this 230AC to 4,25 DC with this circuit and it works when i read with my tester i've got 4,25V.


(The purpose of measuring AC voltage is because I am doing a wattimeter with arduino and I want it to be the most precise possible, i mean here in spain we should have 230V but i have 235V and some house have 240V I want to be able to read this difference calibrating my arduino with my house voltage, so if the analog input voltage goes up, this means the ac voltage must be higher and arduino makes the conversion)


The problem is when i connect it to arduino, the digital values (0-1023) go from 500-850 and that's a lot of error.

I can't find my error can someone explain me this behaviour.
I also calculated this capacitor to make the most stable line of Dc current.

Do I have any way to fix this ?
Thanks!

Best Answer

A multimeter can show a good, stable and easily scalable DC voltage. You think you within software measure the DC and scale it to the current AC voltage value.

Unfortunately the DC isn't stable, it has remarkable AC component due the charging and discharging of C1. Simulate it - 6Vrms AC source, the rectifier, C1 and 940 Ohm load. You must do long averaging in the software or get remarkably bigger C1.

Another thing:

If you want the same watts which kWh meters cumulate for the billing, you must measure instantneous power. That means: sinusoidal voltage and sinusoidal current values are multiplied and integrated for average during one AC cycle period That's watts. Measuring separately voltage and current and multiplying the rms values isn't the same. Partially or fully reactive loads are noticed differently.

ADD: How to get the needed C1 if the fluctuation is wanted to keep low by increasing C1's capacitance:

We can calculate how much C1 discaharges after getting charged to peak voltage, The peak voltage must have the drop in rectifier diodes taken into the account. That makes the scaling in the software a little tricky, multiplying isn't enough! There's also an offset.

Here's a coarse calculation for C1: (=scanned paper)

enter image description here

The discharge period is conservatively assumed to be full 10ms (gives too high capacitance). We avoid the need to solve where the rising sine curve meets the falling voltage.

We will see that in first comment guessed 700uF is far too small. This shows that simulations should be done to reveal errors. We can do it here:

enter image description here

There's plotted voltage in NODE1, the lower image is in high zoom:

enter image description here

enter image description here

We see 15mV fluctuation. That's in NODE1. C1 voltage swings 30mV. This is less than we expected due the conservative discharging period length.

In simulator it's easy to test different variations. Next I would increase R1 and R2 to allow smaller C1. 2000uF is quite a big chunk. For the same reason I would add another C in parallel with R2

NOTE: There's not taken into the account

  • transformer's non-ideality
  • actual used rectifier; the simulation uses a generic type