AC RMS current measurement, converting to DC for Arduino

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
You are correct about the op amp not being able to provide enough current, so it does require a buffer.
Also requires a plus and minus supply for the plus and minus AC waveform.
You may be able to offset it but that can get a little problematic to do.

Below is my take, using a transimpedance amp with buffer (LT1010) directly at the transformer output (I1) which avoid the diode drop voltage, giving 0V at the transformer output.
The transimpedance output then goes to an ideal full-wave rectifier circuit.

View attachment 144711
That looks great! Thanks for sharing.

I must confess, I had to stare at the ideal rectifier for at least 5 minutes before it finally clicked - at first I was sure it must only be a half-wave rectifier! Of course, now that I see what's going on, it seems obvious, but it looked bizarre to me at first.

I still really want to find a solution that works on a single 5V supply, so I may experiment with the offset idea, or maybe just use a charge pump or other DC to DC converter to get the required voltages.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307

crutschow

Joined Mar 14, 2008
34,283
Here's the circuit simulation with a +5V supply and a charge pump circuit to generate the -5V.
The LT1010 can only output about 3V max with a 5V supply, so I added some gain at the output to bring it up to near 5V peak.

Note that C1 should be ceramic, and C2, C3 should be ceramic or tantalum.

The simulation is quite slow (many minutes) due to the high frequency switching in the charge pump circuit.

upload_2018-1-30_12-43-53.png
 

Attachments

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Here's the circuit simulation with a +5V supply and a charge pump circuit to generate the -5V.
The LT1010 can only output about 3V max with a 5V supply, so I added some gain at the output to bring it up to near 5V peak.

Note that C1 should be ceramic, and C2, C3 should be ceramic or tantalum.

The simulation is quite slow (many minutes) due to the high frequency switching in the charge pump circuit.

View attachment 144770
Looks great!

I may still experiment with a single supply bias arrangement, just as an exercise to wrap my head around op amp designs some more. Right now it's all still a little murky.

Regardless, your solution is certainly cleaner and simpler, and most likely what I'll build for myself in reality - I'm just curious to play with other ideas for practice.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
That's good.
It's how you learn. :)
Often you learn more by figuring out why something doesn't work than how something does.
Very true! I've already gone down a number of dead end streets trying unconventional approaches to circuits (mostly trying to solve problems from this forum.) So far, I've gained valuable knowledge from each of these attempts. Hopefully the trend continues!

Occasionally one of my weird ideas works too, and that's always exciting. Either way, learning is fun!
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
That's good.
It's how you learn. :)
Often you learn more by figuring out why something doesn't work than how something does.
Thanks again for all your advice and support!

I've done some playing around in simulation, and I can get a single supply version *almost* working like I want. I had to add one op amp to buffer a 2.5V reference, and another towards the tail end to subtract the 2.5V signal and make the output ground referenced again. It seems like I'm down to the point where the limiting factor is rail-to-rail performance. If I make the op amps' negative supply just 0.3V negative, then everything works about the same as the real dual supply, ground referenced version, so I know the bias and subtract circuits are essentially working right, but as soon as I make the op amp negative supply exactly ground, I get a minimum offset near ground - not obvious on larger signals, but quite obvious on smaller signals (say, 50mA input.)

Given that this approach requires two extra op amp channels and would require very careful selection of good rail-to-rail specs (if that would even be enough to pull it off,) it's obvious that simply adding a negative voltage converter as you suggested earlier would be the better approach. I had pretty much figured that would be the end result, but was just curious to see if I could figure out the logic of this circuit. I think I have, so I'm content now. As soon as I get a chance, hopefully this weekend, I'm going to build a version of your idea with a charge pump voltage inverter supplying the negative supply. I'll let you know how things go.

My interpretation (transformer input, RC smoothing on output) of your circuit:
current-xformer_crutschow_03.png

My attempt at a single supply version, which only works with a tiny hint of negative supply to avoid offset errors:
current-xformer_crutschow_07.png
 

Attachments

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
In general rail-rail op amps cannot pull the output completely to ground with any significant load (such as the feedback resistors), as you found.
So, my first attempt at building your circuit, using a TC7660 to create a negative supply, was a bit rocky. It was a significant improvement over previous error levels, but still had a lot of both offset and gain errors. Probing around with a multimeter showed some really odd behavior that I couldn't explain.

It made a lot more sense when I scoped things and found a 400mV P-P oscillation at somewhere between 800kHz and 1MHz! I tried putting a cap in parallel with the resistor in the feedback loop, but with minimal benefit. I could see enough change to be tantalizing, but not enough to solve my problems. The largest I tried there was 1uF, because I don't have anything larger than 1uF that isn't polarized, and I didn't think I could use a polarized cap across a resistor that has AC running through it.

So, I got a little more experimental, threw convention out the window, and tried a 10uF tantalum cap from the positive rail to the op amp output. This completely killed the oscillation, and eliminated nearly all of my voltage errors.

After those steps, the circuit was performing well enough that the limiting factor was my Arduino's inaccurate ADC performance at lower voltages, so I wrote a tiny bit of code that corrects it to within a few mV (instead of 12-13mV of error before adjustment.) With the new circuit, the eliminated oscillation, and the compensated ADC voltage conversions, I'm now getting readings within about 2% of what my meter reads, all across my measurement range!

I know that the capacitor placement doesn't match the standard approach, but it seems to be working. Any thoughts on potential pitfalls with this approach? Does it seem ok, or should I really be finding a better solution to the oscillation?

As long as I'm double-checking things, I've also added a pair of protection diodes in case I ever try to measure too much current for the chosen feedback resistor (I'm thinking of implementing a switching arrangement to allow multiple ranges.) It seems logical, safe, and harmless to me, but I don't entirely trust myself on this one. Any thoughts on the protection diodes?

Thanks!
current-xformer_crutschow_08.png
 

crutschow

Joined Mar 14, 2008
34,283
Adding 10μF to stop the oscillation is a brute-force technique that's not recommended.
Do you have 0.1μF ceramic decoupling capacitors directly from all op amp power pins (both plus and minus) directly to ground with short leads?
If not, that can cause the observed op amp oscillations.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Adding 10μF to stop the oscillation is a brute-force technique that's not recommended.
Do you have 0.1μF ceramic decoupling capacitors directly from all op amp power pins (both plus and minus) directly to ground with short leads?
If not, that can cause the observed op amp oscillations.
No, I had a larger decoupling cap across the two power pins instead of the two smaller caps to ground (being sloppy and lazy, I used what was in front of me instead of digging or shopping for the right thing :rolleyes::oops:.)

I'll dig through my parts and try to get my decoupling right, then retest without the 10uF.

I had a hunch that it wasn't right. Thanks for reminding me of what I was missing.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Adding 10μF to stop the oscillation is a brute-force technique that's not recommended.
Do you have 0.1μF ceramic decoupling capacitors directly from all op amp power pins (both plus and minus) directly to ground with short leads?
If not, that can cause the observed op amp oscillations.
How about the protection diodes I added?

My thinking there was that if I try to measure too large of a current, the op amp will saturate but the transformer will still try to push/pull more current, and that the protection diodes will protect the op amp inputs (as long as the discrepancy isn't large enough to fry the protection diodes!)

Does this seem like an acceptable approach? I know ideally I'd just never measure the wrong thing with this circuit, but if I can protect myself a little by making the circuit more idiot resistant, that would be great!
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Adding 10μF to stop the oscillation is a brute-force technique that's not recommended.
Do you have 0.1μF ceramic decoupling capacitors directly from all op amp power pins (both plus and minus) directly to ground with short leads?
If not, that can cause the observed op amp oscillations.
Well, I tried the improved decoupling, exactly as described, but it didn't stop the oscillation.

I tried it with and without the 10uF tantalum I'd had across the positive and negative supplies at the op amp pins, with no difference either way.

With the three decoupling caps in place, I tried adding 1uF in parallel with the feedback resistor, as suggested countless places, and it only reduced the oscillation by about 25%.

Finally I tried another brute force approach that is perhaps just a little less brute-ish: I realized that a cap directly on the output of the op amp would appear as near-zero impedance to the output, but putting it on the other end of the feedback resistor would at least put that resistance in series with it, so I tried a 1uF cap from the op amp inverting input (also the junction of feedback resistor and transformer input) to ground.

This didn't work quite as well as the brute force 10uF, but it worked far, far better than anything else I've tried. What I see now looks more like random noise than the obvious oscillation before, and it's down to maybe 25 or 30mV P-P. Down at this level, it appears to have no impact on the readings I get from the filtered average output, and no apparent offset errors at any stage in the circuit.

I have a bad feeling you're going to say this cap location is no better than the last one. If you have more ideas on alternate ways to stop the oscillation, I'm all ears. The only advice I've found from searching online is to put a cap in parallel with the feedback resistor, but I haven't had any success with that so far (I've tried 1uF, 0.1uF, and some tiny one I don't remember now, maybe 100pF?) It seems like every article and app note on trans impedance amps is talking about LDRs, so maybe the fact that this is connected to a transformer is making it behave differently in terms of oscillation and filter needs?
 

crutschow

Joined Mar 14, 2008
34,283
It could be that the transformer inductance is a factor in the oscillation.
If the cap on the input suppresses the oscillation, then use it.
Sometimes you have to use what works, even if you don't understand why. :rolleyes:
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
It could be that the transformer inductance is a factor in the oscillation.
If the cap on the input suppresses the oscillation, then use it.
Sometimes you have to use what works, even if you don't understand why. :rolleyes:
I must confess now that I'm guilty of discussing a circuit that differs from the schematic I've shared...

When I was discussing oscillations and ways to fix them with a capacitor, I didn't have the LT1010 buffer yet. I didn't own any at the time, and didn't think it was necessary when I was only measuring a few amps max (only a few mA of current required from op amp.)

I finally got my new shipment of parts and added the LT1010. At first it appeared not to be working, but then I removed the big cap and it's working beautifully now. It seems to work equally well with a capacitor in parallel with the feedback resistor (which seems to be the traditional, preferred fix for oscillation problems when they do occur.)

Thanks again for all your help, and sorry for any confusion I caused by testing without the buffer and not making that clear.
 
Top