AC RMS current measurement, converting to DC for Arduino

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
I wanted to come up with a way to datalog current measurements of up to 50A RMS, using a current transformer to do most of the conversion and 5VDC-based electronics for the rest. Accuracy doesn't have to super-tight, but if I can get within a few percent and be capable of reading amperages down to maybe 1 amp or less, that would be great.

What I've come up with is below. I scaled the resistor to keep the peak voltage on the secondary side below 5V for a 50A RMS primary current, and also chose the nearest resistor size I could to get an output with simple math. After averaging through the RC filter, the DC voltage at the output is almost 1/20th of the AC RMS amperage (factor is actually 20.19.)

I was wondering if anyone has any thoughts on this approach. Am I re-inventing the wheel? Is there a simpler or better way to get the same thing done? Are there hidden problems here that I'm not seeing in simulation?

One specific question I had is about the rectifier. My understanding is that the current transformer secondary will try to produce a specific amount of current (not specific voltage) and so the rectifier has no effect on the voltage dropped across the burden resistor. The simulation seems to confirm what basic math in a spreadsheet told me, but I'm still not 100% confident that I've got this right.

I also tend to get turned around when converting between RMS, Peak, and Average voltage levels. I'm pretty sure I've got this all right, but I'd love for someone to check my work.
current-transformer_PID-filter_06.png RMS-Peak-Avg conversions.png
 

WBahn

Joined Mar 31, 2012
29,979
Probably the most important question is whether the current you are trying to measure is sinusoidal (not the voltage, the current). If not, then you have significant problems because the circuit you have is what is known as "average responding" meaning that it is measuring the average of a rectified version of the current and then scaling that under the assumption that the actual current is of a particular waveform. The scaling factor that should be used depends on the waveform and that information is lost by the filter.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Probably the most important question is whether the current you are trying to measure is sinusoidal (not the voltage, the current). If not, then you have significant problems because the circuit you have is what is known as "average responding" meaning that it is measuring the average of a rectified version of the current and then scaling that under the assumption that the actual current is of a particular waveform. The scaling factor that should be used depends on the waveform and that information is lost by the filter.
Thanks! That's an excellent point, and to be honest, I'm not totally sure. I believe it'll be fairly close to sinusoidal. The power source is 208-240VAC, 60Hz mains. The load is a mix of resistive heating elements and motors, with at least 80% (and probably usually over 90%) of the current being drawn by the heating elements. I know the motors have a distorted current waveform (thought I had an image I could share, but I can't seem to find it,) but even they don't look too crazy.

I wonder how big the difference between a value arrived at this way and the true RMS value would be.

How are true RMS values obtained? Are there reasonable analog circuits that get you there, or does it require higher adc sample rates and doing the math in an mcu?

I'm guessing in my case it doesn't matter - I may have overstated my accuracy requirements. I think the average "amp clamp" used by handymen and electricians is not true RMS, and I'd be fine with getting results similar to what they offer.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Found it! Here's a slice of our motor current waveform. I superimposed a few images to show the current waveform when the motor is driven with two different SSRs (one zero crossing, and one random turn on,) both in relation to the voltage waveform.motor-current_zero-cross_random-turn-on_3d.png
 

AlbertHall

Joined Jun 4, 2014
12,345
As the frequency is fairly low, 60Hz, you take the AC from the current transformer direct to an ADC and sample often enough to be able to calculate a real RMS value.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
As the frequency is fairly low, 60Hz, you take the AC from the current transformer direct to an ADC and sample often enough to be able to calculate a real RMS value.
I was interested in seeing if I could figure out the analog circuit (and simplify my code in the process,) but you're probably right.

I can't feed negative voltage into an ADC, so I still have the diode drop question from above. Am I right in thinking that the voltage across the burden resistor will be proportional to the current like I'd want, not skewed by the forward voltage of the diodes?

I suppose the other way to get to the ADC without negative voltages would be AC coupling through a cap, with the ADC side biased to 2.5V by a voltage divider. Then I would just subtract 2.5V in the code

My gut feeling favors the rectifier idea to the AC-coupling idea, but I'm not sure which is really better.
 

AlbertHall

Joined Jun 4, 2014
12,345
I suppose the other way to get to the ADC without negative voltages would be AC coupling through a cap, with the ADC side biased to 2.5V by a voltage divider. Then I would just subtract 2.5V in the code
Connect one end of the transformer secondary to 2.5V and select a burden resistor to keep the peak voltage within the ±2.5V range and connect the other end of the transformer to the ADC input - no diodes needed. As you say you then subtract 2.5V from the ADC result.
 

WBahn

Joined Mar 31, 2012
29,979
How are true RMS values obtained? Are there reasonable analog circuits that get you there, or does it require higher adc sample rates and doing the math in an mcu?
One of the oldest ways was to essentially use the defining concept behind RMS -- the DC value that produced the same power dissipation in a resistive load. So apply your unknown signal to a resistor and apply a known signal to the other and then adjust the known signal until the temperatures of the two resistors were the same.

There are chips, such at the Maxim MX636, that are RMS to DC voltage converters.

EDIT: Corrected part number from MAX636 to MX636. Thanks, OBW0549.
 
Last edited:

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Huh. I hadn't thought to just reference the whole transformer secondary to 2.5V. It's so simple. It seems too good to be true! I'll try it out as soon as I get a chance. Thanks!

I must admit though, part of me is still interested in figuring out what can be done on the analog side, if only to learn from it.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Yikes! The chips are kind of pricey. I think I'll either do my own RMS with Albert's suggestion, or just live with the average vs. RMS error potential.

I had been hoping there was some clever, interesting circuit with a few op amps or transistors and a reasonable number of passives. If it's not that simple (which it must not be, or you guys would've mentioned that,) then I don't need to go the analog RMS route.
 

WBahn

Joined Mar 31, 2012
29,979
Yikes! The chips are kind of pricey. I think I'll either do my own RMS with Albert's suggestion, or just live with the average vs. RMS error potential.

I had been hoping there was some clever, interesting circuit with a few op amps or transistors and a reasonable number of passives. If it's not that simple (which it must not be, or you guys would've mentioned that,) then I don't need to go the analog RMS route.
I doubt there is anything simple using linear circuits with some tweaks because the relationship between the voltage waveform and it's RMS equivalent is highly nonlinear.
 

OBW0549

Joined Mar 2, 2015
3,566
Yikes! The chips are kind of pricey. I think I'll either do my own RMS with Albert's suggestion, or just live with the average vs. RMS error potential.
Provided your waveform more or less resembles a sine wave, I don't think you're going to see much of an error. An average-responding circuit usually gives pretty good results.

I had been hoping there was some clever, interesting circuit with a few op amps or transistors and a reasonable number of passives. If it's not that simple (which it must not be, or you guys would've mentioned that,) then I don't need to go the analog RMS route.
True RMS measurement is definitely not a trivial matter, as it involves squaring the input, averaging the result, then taking the square root. Non-linear operations like that are tricky and involve quite a few parts.
 

WBahn

Joined Mar 31, 2012
29,979
Yikes! The chips are kind of pricey. I think I'll either do my own RMS with Albert's suggestion, or just live with the average vs. RMS error potential.

I had been hoping there was some clever, interesting circuit with a few op amps or transistors and a reasonable number of passives. If it's not that simple (which it must not be, or you guys would've mentioned that,) then I don't need to go the analog RMS route.
The DigiKey price in onesies is only ~$4. What are you doing that this is too much and that would justify much in the way of your time to roll your own? If you can tolerate the error (and it probably wouldn't be much for the waveform you showed) then that is a quite reasonable approach.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
The DigiKey price in onesies is only ~$4. What are you doing that this is too much and that would justify much in the way of your time to roll your own? If you can tolerate the error (and it probably wouldn't be much for the waveform you showed) then that is a quite reasonable approach.
Hmmm, must've done the search wrong (playing on my phone, not a real computer right now, so may have done something silly.) The AD636 at Mouser was $55. That one startled me. A few of the other part numbers came up as obsolete in DigiKey. Maybe I'll take a closer look and see what I missed when I'm back at a real computer.

Either way, if the circuit I originally posted looks reasonable (aside from average vs rms error,) and I can do the high sample rate ADC thing as an alternative, I've got plenty of options regardless.

As always, thanks to all three of you. I appreciate the insights.
 

smooth_jamie

Joined Jan 4, 2017
107
you obviously have alot of good information from the other contributors of this post but I thought I'd offer my own advice :)

I cobbled together a small box that does exactly what you want (albeit over a range of 1mA to 100mA but you can set whatever range you want). Using an arduino and a couple of ADC's it can measure 8 channels in its current configuration but up to 16 should be possible with the addition of another two ADC chips.

I published it on instructables, it technically only measures peak but I calibrated it to measure RMS. It needs some refinement but it's a good foundation to build a cheap box of your own (it cost me roughly 100 GBP).

https://www.instructables.com/id/AC-Current-Monitoring-Data-Logger/

EDIT:
By the way this will only work properly with resistive loads, there is no power factor or voltage measurement. You can easily add these though.
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
you obviously have alot of good information from the other contributors of this post but I thought I'd offer my own advice :)

I cobbled together a small box that does exactly what you want (albeit over a range of 1mA to 100mA but you can set whatever range you want). Using an arduino and a couple of ADC's it can measure 8 channels in its current configuration but up to 16 should be possible with the addition of another two ADC chips.

I published it on instructables, it technically only measures peak but I calibrated it to measure RMS. It needs some refinement but it's a good foundation to build a cheap box of your own (it cost me roughly 100 GBP).

https://www.instructables.com/id/AC-Current-Monitoring-Data-Logger/

EDIT:
By the way this will only work properly with resistive loads, there is no power factor or voltage measurement. You can easily add these though.
Thanks, cool project!
 

Thread Starter

ebeowulf17

Joined Aug 12, 2014
3,307
Connect one end of the transformer secondary to 2.5V and select a burden resistor to keep the peak voltage within the ±2.5V range and connect the other end of the transformer to the ADC input - no diodes needed. As you say you then subtract 2.5V from the ADC result.
Thanks for this idea. The more I think about it, the more I'm leaning towards going this way. I'm going to do some speed tests on my busiest (slowest) Arduino sketches and see if there's any risk that I can't sample frequently enough to get good data, but I suspect it will work fine. How many samples per cycle do you think it takes to make a reasonable RMS approximation? If I sample ADC at 1Khz, that's a little over 16 samples per AC cycle. Do you think that's a reasonable sample rate to shoot for?

Here's my schematic and simulation. I did add some diodes as input protection in case of unexpectedly high amperage at primary.
current-transformer_RMS-ADC_01.png
 
Top