1
\$\begingroup\$

I am trying to make a circuit to transform 240VAC, split-phase to a 0 to 5V waveform for an Arduino ADC so I can measure the mains voltage. I have read this question (How to measure line voltage (220V) with an arduino?), which describes very well how to use a transformer to isolate the circuit from mains voltage and bias the transformer secondary voltage so it's always positive (relative to ground).

Simulating this circuit, however, I found that the transformer causes the line voltage and current to be out of phase (as expected for an inductor). I am trying to ensure that my measurement system has a minimal impact on the mains voltage and current, so I wanted to correct the transformer primary power factor so voltage and current are in phase. To do this, I created the following circuit:

Power Factor Corrected

This circuit assumes the primary inductance is 4H, but with the transformer I'd like to use, I can't find its inductance in the datasheet.

However, when I add the remainder of the secondary side, there is a 90° phase shift in the voltage.

Phase Shift in Output

Here, the second scope is the voltage across the 100kΩ resistor (representing the ADC input). The third scope is an XY-plot with the mains voltage on the x-axis and the ADC input voltage on the y-axis.

I attempted to fix this with another capacitor to induce a 90° phase shift, but I run into a problem where the larger the capacitor is, the closer to output phase is to the input phase, but the gain decreased. Conversely, a smaller capacitor increases my gain, but corrects the phase shift less.

First Attempt to Phase Correct

It make sense that the gain decreases since the capacitor changes the impedance of the voltage divider, but also changes the impedance of the entire secondary side.

Because of this, I thought about adding an op amp to buffer the stages, but now this is getting more complicated than I can easily design. Ultimately, I need to do three things to the secondary side in order to have the correct input to the ADC:

  1. Scale the peak-to-peak voltage to ~5V
  2. Add a DC offset of ~2.5V so the output voltage swings from 0 to 5V
  3. Phase correct the output voltage so its voltage is no longer leading the mains voltage.

I can use the op amp to both scale the voltage swing and add a DC offset, but I wasn't able to decouple the gain/scaling from the phase correction. I even tried a circuit that buffered the output twice, but still had problems.

How can I accomplish my three goals for conditioning the ADC signal?

\$\endgroup\$
17
  • \$\begingroup\$ Do you have some strong desire to do the isolation with a transformer, or would you be open to using some form of isolator? There are ways to compensate the nonlinearity of optoisolators with a feedback loop. \$\endgroup\$
    – Hearth
    Mar 20, 2019 at 0:26
  • \$\begingroup\$ @Hearth I've only ever thought of optos for digital signals, but I guess that's because of the phototransistor non-linearity you mention. It sounds like that might be more complicated and I still need a way to reduce the mains voltage to power an opto. If it's easier though, I'd definitely consider it \$\endgroup\$
    – Hari
    Mar 20, 2019 at 0:32
  • \$\begingroup\$ Of course there's also always the option of an isolation amplifier as well, or digitizing the signal with an ADC and then sending it across a digital isolator. \$\endgroup\$
    – Hearth
    Mar 20, 2019 at 0:41
  • \$\begingroup\$ All of that, though, completely skips over the fact that you know what your circuit is, and you can do the reverse of it in software if you need to. A phase correction isn't that complicated, surely? \$\endgroup\$
    – Hearth
    Mar 20, 2019 at 0:42
  • \$\begingroup\$ @Hearth You mean phase correcting in software isn't complicated? That is true. At the same time, if I just wish away my problems with software, I won't learn how to design good hardware. I'd prefer to minimize computational load if possible, so a hardware solution would be nice. \$\endgroup\$
    – Hari
    Mar 20, 2019 at 1:03

1 Answer 1

1
\$\begingroup\$

With no load (or a very light load) on the secondary, the primary current will lag the primary voltage by 90 degrees. This is because the primary inductance dominates and, because it is an inductor, it will take a current that is largely 90 degrees lagging the applied voltage. Nothing strange happening here. This is transformer physics.

The output voltage will be in phase with the input voltage because the secondary induced voltage is proportional to the rate of change of primary magnetization current and, this therefore adds another 90 degrees to the current waveform.

\$\endgroup\$
3
  • \$\begingroup\$ This all makes sense, and certainly explains why adding a capacitor to the primary will correct the lag for a lightly-loaded secondary, but is there a way to modify the circuit to achieve: 1) Near-unity power factor for the primary, 2) A 0-5V output voltage, and 3) Zero phase shift between the primary and secondary voltage? \$\endgroup\$
    – Hari
    Mar 20, 2019 at 18:44
  • 1
    \$\begingroup\$ I think the problem for anyone reading this question is that it didn't become clear what you were doing until you last previous comment! Previously it seemed you were using a CT (current transformer) to measure power! \$\endgroup\$
    – Andy aka
    Mar 20, 2019 at 18:47
  • \$\begingroup\$ It did? I apologize. I thought it was clear from the linked question. I'll edit my question to state that I am trying to measure voltage, not current. \$\endgroup\$
    – Hari
    Mar 20, 2019 at 19:06

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.