Questions on interfacing to current sense transformer

Hey group,

I'm thinking of building a homemade power meter. I'm planning on using an Arduino with ethernet "shield" to allow me to read the power measurements over the internet. I see simple power meters, like the ubiquitous Kill-A-Watt, use a calibrated shunt resistor to measure current, but for isolation, I thought I'd use a current sense transformer instead. For voltage, I'll use a simple step down voltage transformer.

I would like to be able to calculate phase difference, real/imaginary power, etc, so I don't want to rectify to DC; I want to sample the AC signals and do so frequently enough to be able to estimate the above parameters.

I think I have most of this figured out the ADs on the Arduino are only 10b, so this won't be super accurate, but I think it'll work.

The only thing I'm unsure about is how to bias the voltage transformer and current transformer outputs so that they're suitable for the ADC. For example, assume I've selected a burden resistor for the current transformer so that the secondary voltage is 2.5Vp-p at rated input current, but the ADC wants to see 0-5V.

How do I add the necessary 2.5V?

As a followup to that, how to I determine the zero crossing time(s) once I've done this biasing?

I've thought that I would determine the time of peak-to-peak time of the waveforms in software. Something like:

int t = 0; int curr_sample; int prev_sample; int prev_prev_sample;

while (1) { prev_prev_sample = prev_sample; prev_sample = curr_sample; curr_sample = read_adc(); if (curr_sample < prev_sample) && (prev_pre_sample < prev_sample) { peak_value = prev_sample; peak_value_time = t-1; } t++;

but I'm afraid that with noise, this will only get me close to the peak. (I can filter, in hardware or software, I suppose)

Anyway, tips are appreciated. This is my first electronics project in a looooong time.

-- dave j

Reply to
David Jacobowitz
Loading thread data ...

Bias the low side of both the voltage and current sense transformers to +2.5 volts DC to keep the ADC happy.

Your software should sample the voltage and current as close to simultaneously as possible... within 10 usec is OK. Sample fairly often, but it's not really important. I've done good meters that sampled as slowly as 27 times a second. Nyquist is not an issue here.

Process the samples as follows:

Average blocks of, say, 1024 samples, and subtract the average from each sample. That removes the 2.5 volt offsets.

Square and average the volt and amp samples independently (block average or lowpass filter) and then square root. That gives you true RMS volts and amps. Multiply them to get KVAs.

Multiply and average (block or lowpass filter) the product of the voltage and current sample pairs. The result is true power.

You can integrate power to KWH. You can also compute power factor as true power over KVAs, but you lose the lead/lag sign.

Something like that.

Add some random noise to the analog current signal, a few LSBs maybe, to smear out the ADC quantization error and extend the low-end resolution.

John

Reply to
John Larkin

For power, you need to know I * V, not just I and V; were you planning on an analog multiplier (there are variants from two transistors or a Gilbert cell on up to pricey modules)?

Neither of your isolation solutions will correctly measure if there's DC, of course.

One could use a sense resistor, voltage divider, and fleapower to a few transistors to make a power output, then convert to frequency and feed it to your Ethernet processor through optoisolators into a counter.

Reply to
whit3rd

Interesting, and yes, I will sample as closely together as I can. The uC I'm using, an AVR has multiple analog inputs, but they are muxed to only one ADC, so I'll have to sample serially, but it should be close.

Ah, clever, the simple average will tell me the bias; that's what I was wondering about.

For some reason I had not thought of this. I was going to measure the peaks and adjust for RMS, but if I'm sampling reasonably quickly, I can do a true RMS!

Basically, I'm calculating the instantenous power with the products of the coincident samples, and I can integrate over a cycle (or longer) to give the true power.

No, this is great. Once I've got the data into two sample streams, it's all straightforward math.

Like audio dither? How much noise do I add?

I'm excited to do this project. I think it's going to work!

thanks, dave j

Reply to
David Jacobowitz

I was planning on sampling I and V independently and quickly enough that I can deal with them as instantaneous quantities.

Right, this is a problem I was anticipating, because there was no way I could imagine to bias these signals perfectly so that they would have 0 DC component, or even an accurately pre-computable DC component. But another poster, John, pointed out that I can simply average over time, and that will be the DC component. Assuming the DC component does not change, or changes very slowly, I can simply subtract it from each sample to get back the original unbiased AC signal.

This is another approach that could work, where I turn the I, V, and I*V into scalar quantities before sending them to the computer. I'll keep it in mind!

thanks, Dave J

Reply to
David Jacobowitz

"whit3rd" David Jacobowitz

Neither of your isolation solutions will correctly measure if there's DC, of course.

** DC offset on the AC supply voltage is normally very small - but loads that draw large DC componets exists, like some hair dryers power tools and hot air guns.

The best solution is to use a Hall Effect sensor for current, these work linearly down to the 10mA level and from DC to tens or hundreds of kHz.

The voltage step down tranny is an issue too - as most small E-core types will have significant waveform distortion and phase offset at the zero crossing. Both errors are due to magnetising current in the primary.

Small ( ie 5 to 10VA) toroidal mains types typically have no such problem.

..... Phil

Reply to
Phil Allison

"David Jacobowitz" whit3rd

Right, this is a problem I was anticipating, because there was no way I could imagine to bias these signals perfectly so that they would have 0 DC component, or even an accurately pre-computable DC component.

** You have missed the point.

The AC supply voltage can have a DC component and some loads cna have a large DC component in the current - ie operaing in half wave only mode.

Isolating transforrms will not carry this compoent through to you electronics.

See my other post for a solution for the current.

... Phil

Reply to
Phil Allison

ds

d

I was not too worried about DC in the mains, but the DC I was purposefully introducing to get a nonnegative signal for the ADC.

I thought the Hall Effect devices would be expensive, but they appear to be in the $4-6 range, about what I paid for my current transformer. Hmm.

pes

.

Yeah, my plan was to use whatever little tranformer was laying around for this. I expect distortion and phase offset, but I was prepared to ignore them for my purposes. (Was also going to ignore nonlinearity in the current transformer.)

Are these effects minimized if the transformer is loaded to its rating or almost completely unloaded. (I was going to do the latter.)

Thanks, Phil.

-- dave j

Reply to
David Jacobowitz

ode.

I did miss your point. I get it now. If the load I'm measuring is not "symmetric" (like a half-wave rectified PS) it will have a DC component, and this is actually important to capture correctly if I want accurate results.

This is turning out more complicated than I had anticipated. Even if I use the Hall sensor, I will still have to bias before sampling, and then subtract that bias in software afterwards. But I'll not be able to determine what bias was "real" and what was artificial.

Might have to accept that bad behaving loads will be mismeasured.

Reply to
David Jacobowitz

"David Jacobowitz" "Phil Allison"

I was not too worried about DC in the mains,

** Makes the meter design you propose give completely false readings.

I thought the Hall Effect devices would be expensive, but they appear to be in the $4-6 range, about what I paid for my current transformer.

** I should have said " Hall effect transducer " - ie a complete device you pass a current carrying wire or wires through.

These cost more like US$20-30 each.

Yeah, my plan was to use whatever little tranformer was laying around for this. I expect distortion and phase offset, but I was prepared to ignore them for my purposes. (Was also going to ignore nonlinearity in the current transformer.)

Are these effects minimized if the transformer is loaded to its rating or almost completely unloaded. (I was going to do the latter.)

** Unloaded is probably worst.

Small toroidals are not expensive - stop being a tight arse!!

..... Phil

Reply to
Phil Allison

You can also add a little differential analog RC lag to one or the other to make up for sample delays. Or alternate E:I then I:E to average things out. But current transformers usually add phase lead that varies with current... and fixing THAT in software is a trick.

I prefer to use a shunt and couple that with a signal-level transformer. That's more constant on phase. Or use a shunt and float the whole meter on it, no magnetics at all.

You can actually compute the DC average to a fraction of an ADC LSB. It works.

Yes. Voltage waveforms are rather distorted nowadays, and currents can be much, much worse. True RMS is the way to go.

Many cycles, since the signals will be very noisy. You can block integrate and then divide, or you can simulate a multipole, continuous lowpass filter for a nice smooth analog meter effect.

A few adc lsb's p-p. Random noise is good, but a triangle works well too. Just make sure it's uncorrelated to the line frequency. The noise will raise the RMS current noise floor a little, but since it's uncorrelated to the voltage waveform, it contributes no longterm power or energy error. And it makes the low end power measurement beautifully linear. I've done metering-quality stuff (resolution 1 watt in 20,000) using a dithered Wilkinson-type 7-bit ADC.

No point in dithering the voltage signal, since it's big and nearly constant.

The math is fun. There's some really interesting math involved in selecting the sample rate. You'd like a block of N samples (2^M typically maybe) to hit uniformly-spaced phase angles of the sine wave over a number of cycles. Turns out that there are some magic numbers involved that result in super-stable results.

Oh, one last trick: most multiplexed ADCs have a little bit of carry-over between channels. That can produce a low-level fake power. You can digitize ground between the E and I samples to "discharge" the ADC guts, or take two I samples and throw the first one away. Or cal the error out (it usually goes as E^2)

This is actually an interesting problem. It's not easy to make an electronic meter that's as good as the ancient rotating disk.

John

Reply to
John Larkin

If the line voltage has a zero DC component (and it's usually very small) a DC component in the current waveform contributes no power. Rotating disk meters ignore DC (or actually may slow down a little!) and most commercial-scale meters use 5-amp-secondary current transformers to pick off the big line currents. So there's plenty of precedence for AC coupling.

John

Reply to
John Larkin

I've done what he proposes and had the meters tested and certified by public utilities and test labs. They always test with AC!

Hall sensors are good on phase and bandwidth, but tend to drift with temperature a lot. Of course, only gain matters; DC offset is easily removed in software. None of the utility-grade electronic meters that I've seen use Hall sensors. Many use cheap shunts and no magnetics.

Hall multipliers have been used to compute power all in one chunk, but the their DC offset matters.

John

Reply to
John Larkin

Thanks so much for the help! The parts are trickling in via UPS. With luck and a few quiet nights after the baby is asleep, I should get a chance to tinker...

-- dave j

PS: I think Phil may have a point; I think your analysis above may only be correct for real power. What do you think?

Reply to
David Jacobowitz

"John Larkin Criminal Fuckhead "

"Phil Allison"

** Cos they know what I just posted above is true.

How funny.

** Hall effect *transducers* OTOH have no such issue.

Of course, only gain matters; DC offset is easily

** None of them provide isolated output signals either - FUCKHEAD

The concept of context has no meaning to autistic scum like Larkin.

..... Phil

Reply to
Phil Allison

Two resistors, voltage divider. AVR also has a differential input, which you may be interested in.

BTW, make sure to diode or zener or TVS protect the CT's output / Arduino's input. Wouldn't want someone turning on a refrigerator and sinking 10A through your AVR's input protection diodes (or what was left of them).

For a left-aligned 16 bit variable,

if ((signed)val > 0) { ... }

Arduino is just ATmega32, isn't it? I'd rather go like this (note GCC syntax):

-=-=-

// Global variables for holding ADC conversions static uint8_t byte1, byte2;

// Initialization, place in main()

// ADC enabled, start converting ADC0, left aligned result, // 125kHz prescaler (8MHz clock), and interrupt ADMUX = 1

Reply to
Tim Williams

..careful with the phase shift in the voltage transformer...

Reply to
Robert Baer

I think that real power is the averaged value of the instantaneous product of voltage and current, and that a sampled system can approximate that to high precision. And that real power is what utilities charge you for. It's hard to tell what Phil thinks.

Power factor is fuzzily defined for non-stationary and non-sinusoidal loads. Even people in utility metering departments get tangled up over that. All the revenue meters I've seen ignore any DC components.

If you want to build a true DC-to-daylight wattmeter, go for it. It's just more work, and in a real AC power system, you won't see much DC real power. Define power factor any way that pleases you, and compute that, too.

The elegant part of the wattmeter I've suggested is that it acts like an ac-coupled lockin amplifier, and cheap analog parts and ADCs can produce really good numbers. I've sold over to 100,000 wattmeter channels like this in instruments that have been tested by dozens of utilities and test labs.

John

Reply to
John Larkin

It's a good idea to R-C lowpass filter both the voltage and current signals, to take out spikes and such. Those filters can be tweaked to null out modest constant phase errors. Plus the delay between the voltage and current samples can be tweaked, too.

John

Reply to
John Larkin

If you take the voltage and current samples on alternate interrupts, you may add a lot of time delay == phase shift. Depends on how fast you can stand to interrupt and how much CPU you leave for the operate side. Issues tend to push towards a more complex ISR that's run less often, samples both inputs bang-bang, and does most of the signal math. KWH integrations can be done on the operate side at a much lower rate.

John

Reply to
John Larkin

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.