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!

  • 1
    \$\begingroup\$ How often are you measuring? What accuracy do you want? \$\endgroup\$ – Tony Stewart EE75 Jan 15 '18 at 21:38
  • \$\begingroup\$ I am measuring every second, could i get a value for getting allways the same spot of the wave ? I want like 2V AC error max. \$\endgroup\$ – Pol Jan 15 '18 at 21:40
  • \$\begingroup\$ OK then would you prefer Average over 1 second or peak converted to average RMS or ?. \$\endgroup\$ – Tony Stewart EE75 Jan 15 '18 at 21:48
  • \$\begingroup\$ maybe the peaks would work \$\endgroup\$ – Pol Jan 15 '18 at 22:09
  • 1
    \$\begingroup\$ Lots of measurement errors and too little design analysis. Do you not understand what you show , how it works? \$\endgroup\$ – Tony Stewart EE75 Jan 15 '18 at 22:35

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
  • \$\begingroup\$ What C1 would you recommend? \$\endgroup\$ – Pol Jan 15 '18 at 21:37
  • \$\begingroup\$ @Pol If you allow say 0,5% fluctuation, you need 700uF with you current resistor values. Simulate it to see! It's your free and easy to use tool to avoid some basic errors. You can as well increase R1 and R2 or add multistage filtering or both, in simplest form add a capacitor in parallel with R2 (have bigger R1 and R2 than 470 ohm to keep the needed capacitance low). Hopefully you have noticed that diode voltage drop should be taken as offset, not as scaling in all versions. \$\endgroup\$ – user287001 Jan 15 '18 at 21:51
  • \$\begingroup\$ I will try getting a 700 uF capacitor and change the one I have now, can you tell me what calculation did you do to get this value? \$\endgroup\$ – Pol Jan 15 '18 at 22:09
  • \$\begingroup\$ @Pol That 700uF is not exactly calculated, it is an approximation in my head. It can easily have still tens of percents error. I'll add proper calculation to the answer in 1 hour. \$\endgroup\$ – user287001 Jan 15 '18 at 22:16
  • \$\begingroup\$ @Pol The answer is completed. We see that the guessed C1=700uF was quite a bad suggestion. Sorry for wasting the time. \$\endgroup\$ – user287001 Jan 15 '18 at 23:57

You haven't got any low pass filtering of the rectified signal, so the Arduino will see the unsteady waveform. Your "tester" will have a low pass filter built-in, hence why it works.

As a first pass you could add a 4700R before C1 so they form a low-pass RC filter to reduce the oscillation of the rectified signal presented to the remainder of the circuit.


Design Flaws

  • errors in transformer ratio since rated Vout is at rated VA load.
  • offset from bridge 2 diode drop
  • excessive 40% ripple from RC=15ms for a 10ms rectified 50Hz

Simple fix for ripple error

  • Changing R1,R2 to 22k with C=15uF will give RC=660ms
  • For f=100Hz when RC= 66T (T=10ms) the rectified peaks will have < 1% ripple error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.