3
\$\begingroup\$

I am trying to make an AC voltage reading system according to the circuit below which I found online.

My voltage is coming out cyclical - why is that? Is the capacitor perhaps to blame for not discharging quick enough?

My circuit

Wiring diagram:

enter image description here

Below is the BOM used:

  • One 12-0-12 transformer
  • 1N4007 diode
  • 1uf capacitor 400V
  • Resistors 10k; 4.7k.
  • Zener diode (5V)
  • Arduino UNO
  • Connecting wires

My plot

It's a beautiful pattern but just useless.

Below is the plot when I remove all delay in sampling, 9600 baud rate:

without delay in sampling

Below is my plot, 115200 baudrate, no delay:

enter image description here

\$\endgroup\$
13
  • \$\begingroup\$ Probably too high voltage? \$\endgroup\$
    – Antonio51
    May 26 at 12:14
  • \$\begingroup\$ @Antonio51 But after rectification it should give a straight line, right? even if its higher than standard. In my country the domestic voltage is 220V ac. I have used a step down transformer to step it down to 12 volts. I checked, the variance isn't too great from 12 V. \$\endgroup\$
    – tiktok
    May 26 at 12:19
  • \$\begingroup\$ Not really constant. Add a discharge resistor, say 1k? \$\endgroup\$
    – Antonio51
    May 26 at 12:23
  • 3
    \$\begingroup\$ 50ms is too slow for line voltage reading. You are getting aliasing on the ripple. \$\endgroup\$
    – devnull
    May 26 at 12:33
  • 1
    \$\begingroup\$ Try working at higher speed rs232. 115 k without delay. \$\endgroup\$
    – Antonio51
    May 26 at 12:36

4 Answers 4

2
\$\begingroup\$

Yes you are simply reading the ripple on you capacitor. Also your source impedance toward the converter is quite high (more than 3kΩ) so it's possible that your ADC is starved and cannot sample properly.

What you have built is actually an envelope detector, a quite useful circuit in its own. You are charging your capacitor thru D1 but it can only discharge through D2's leakage and the input impedance of the ADC.

I'd expect to see the big triangular ripples (look at the frequency, it should be twice your mains frequency) but not the oscillation inside; this is quite strange.

Try to reduce the input divider resistor to lower the impedance (4.7k and 2.2k are more or less half the one you are using)

It's even possible that the wiring is picking up noise; lowering the impedance would help with that too.

\$\endgroup\$
5
  • \$\begingroup\$ I am using the code delay(50). Maybe that is why the oscillations? So are you saying I should change 4.7K to 2.2K. \$\endgroup\$
    – tiktok
    May 26 at 12:33
  • 2
    \$\begingroup\$ if you are using a delay then it's simply an aliasing artifact (search for sampling theorem). The outer ripple however remains, you can also try a bigger capacitor \$\endgroup\$ May 26 at 12:40
  • \$\begingroup\$ Like a 10uF capacitor? And I still have to reduce the resistance to 2.2K? I have updated my question, you are right, when I remove delay only the outer ripple remains. I tried 115200 baudrate at another recommendation, the outer ripple is clearly visible. \$\endgroup\$
    – tiktok
    May 26 at 12:44
  • 2
    \$\begingroup\$ well if only the envelope remains you have solved the problem. depending on your need you can average or find the peak or whatever you need from your waveform. search for "diode envelope detector" to tune your values, you could add a resistor to the output to stabilize the time constant \$\endgroup\$ May 26 at 12:55
  • 2
    \$\begingroup\$ It's a half wave rectifier, so the ripple should be the same as the mains frequency. \$\endgroup\$
    – GodJihyo
    May 26 at 13:27
4
\$\begingroup\$

If you want a good filtered voltage, you can try this ... "Little" ripple.
R3, R4 used to adjust voltage for Arduino.
NB: I forgot ... the time for a "good" value is ... 2 s.

enter image description here

\$\endgroup\$
5
  • \$\begingroup\$ Being new to electronics this is going to take a moment for me to understand. Why have you taken out the zener diode? ALso, I understand R1 =R2 =R3 =500ohm, but what is the value of R4? And how to know the polarity of a transformer? I thought AC did not have any polarity, my transformer does not even have color coded wires. \$\endgroup\$
    – tiktok
    May 26 at 15:19
  • 1
    \$\begingroup\$ If R3 and R4 are "well-chosen", voltage is always in limit for ADC input (ok, take a margin). R1, and R2 are lower for charging C1 "more" faster. No worries about polarity "+" on "my" generator, it is indicated because it says that the first starting half "wave" is positive when phase = 0. \$\endgroup\$
    – Antonio51
    May 26 at 16:14
  • \$\begingroup\$ Just one clarification, the connection to arduino analog pin needs to be at Vo, right? \$\endgroup\$
    – tiktok
    May 27 at 4:36
  • 1
    \$\begingroup\$ Yes, right. it is the output of the "system". Always check that voltage is not greater than 4V if the Arduino supply is 5V, or 2.8V if 3.3V. \$\endgroup\$
    – Antonio51
    May 30 at 10:44
  • \$\begingroup\$ alright...got it. thanks. \$\endgroup\$
    – tiktok
    Jun 1 at 5:40
4
\$\begingroup\$

In the wiring diagram the 1uF cap is connected with wrong polarity. Using it that way introduces a large inner leakage current with fast discharge rate. And it will destroy the cap on the long run.

\$\endgroup\$
3
  • \$\begingroup\$ Please forgive if this query appears too simplistic. My capacitor has a long leg and a short leg. The long leg I understand is the positive pole. But how to know which is positive and negetive pole of the Transformer? My transformer isn't color coded. And isn't ac supposed to keep shifting polarity unlike dc? \$\endgroup\$
    – tiktok
    May 26 at 15:14
  • 2
    \$\begingroup\$ @tiktok: This does not depend on the transformer, it delivers AC. Your diode creates a positive voltage relative to GND and you must connect the cap in the same polarity = short leg to GND. The symbol in the wiring diagram shows a white marker as indicator for the negative pin and this must be the other way round. \$\endgroup\$
    – Jens
    May 26 at 16:30
  • \$\begingroup\$ aha...ok. got it. Didn't know that about diodes. Thanks for the knowledge, will keep in mind. \$\endgroup\$
    – tiktok
    May 27 at 3:34
2
\$\begingroup\$

If you want a "circuit" that gives (within one-half period) the voltage, use something as the first part of this schematic (some adaptation is needed).

The idea is to phase 90° the voltage input, then compare to the ground with an op-amp, and then sampling with ADC at the rising or falling edge (positive or negative voltage) of the comparator ...

enter image description here

Adapted for 50 Hz ...

enter image description here

One can use also the output Vcomp and use an interrupt program on falling or rising edge, which sample the Vg input (attenuated if necessary).

\$\endgroup\$
2
  • \$\begingroup\$ But to know the peak, shouldn't the max function be enough? \$\endgroup\$
    – tiktok
    May 26 at 15:22
  • 1
    \$\begingroup\$ Yes. But you need measure until peak is max. here, no max function was used, just sample the output when you need. It is the "phasor" at the input and the op-amp that say when it is maximum at every cycle. I have adapted this sample to 50 Hz. \$\endgroup\$
    – Antonio51
    May 26 at 16:20

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.