Microcontroller True RMS with noisy waveforms?

Sampling fast and then pausing to calculate is certainly valid to my mind. Sampling at ~ 50kHz is more than you need.

Among many other problems, yes. I would think that sampling at half the rate, but for a known full cycle would be better. For that matter, sampling at 1/4 the rate for two full cycles, and having some sort of windowing would be better yet.

Is the sampling preemtive, or does all the other processing stop while a half-wave is being sampled? Much of what I say about "easy" or "hard" is predicated on the idea that you're perfectly capable of writing an ISR to sample data while other processing is going on.

Indeed. Or getting the phase wrong. This is a big part of why I'm suggesting that slower sampling of longer intervals is a good idea.

The answer to that would come from close scrutiny of the microprocessor data sheet, but I'm 99.44% sure that it just detects when the input is above some threshold. Whether that's good enough for what you're trying to do is beyond me, though.

--
Tim Wescott 
Wescott Design Services 
 Click to see the full signature
Reply to
Tim Wescott
Loading thread data ...

Actually the sampling uses a DMA channel such that you 'set and forgot' and come back later to get the results in a large array in memory.

It is. It uses an Analog 'watchdog' feature that looks for thresholds and triggers an interrupt.

Another option I'm exploring it to use a hardware circuit to trigger on the 60hz (schmitt trigger plus filtering). Then use this result in a pulse width accumulator and use this to sync to the waveform to determine the sample length of exactly one period (or two or more if if we chose). The schmitt trigger circuit appears to be much more robust against noise and harmonics and can be heavily filtered without introducing a lot of software complexity. Its about a 20 cent circuit so . . . . . Please i need it anyway to compute Hz for display purposes. In this scenario we might start at any point in a given cycle and stop at the same point in the next cycle; result should be the same.

Reply to
EnigmaPaul

Can't do it continuously as many other functions are handled such as communications, operator interface, loads of fault management, timers, and other control logic. There needs to be some sort of time slicing to do everything.

Reply to
<address_is

Do it in an ISR.

--
John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    
 Click to see the full signature
Reply to
John Larkin

Holy crud. Wow, are you in way over your head. You NEED a micro dedicated to your measurement tasks. One pass at your stuff once every

200 ms just won't cut it. You need at least one pass every 1 us (due to the high frequency hash generated by the VFDs). Yes, you NEED that much data. Well, maybe not really. You can use equivalent time random sampling for the final product, with rep rate of a few ms; but that is a much more complex design.

?-/

Reply to
josephkk

You might want to consider using one of the Analog Devices chips that were custom designed for calculating these things:

formatting link

formatting link

You would just have to poll it and get the measurement results out periodically.

Chris

Reply to
Chris Jones

No it's not: just sample less.

He's trying to measure average values, not reconstruct waveforms.

--
John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    
 Click to see the full signature
Reply to
John Larkin

You are also way out of your depth. The final instrument may not have to have a really fast sample rate, but to understand the waveforms in a laboratory test regime with over 10 samples at the VFD switching frequency is needed to have any hope of understanding those waveforms. That frequency is many kilohertz to many tens of kilohertz. Thus the high sample rate for the lab work. If the field requirement is serious high accuracy in characterizing the hash the sample rate requirement remains high in the final instrument.

?-)

Reply to
josephkk

How many electronic power meters have you sold? I've sold thousands to utilities and academics for end-use load studies, and they are smart, critical customers.

The final instrument may not have to

A power meter doesn't "understand" waveforms. It just averages a lot of sampled E*I products.

--
John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    
 Click to see the full signature
Reply to
John Larkin

While you need short (say 1 us) sampling pulses to a S&H circuit, for a repetitive waveform, there are plenty of time to do the ADC and post processing for reconstructing the waveform or calculating the effective value.

Sampling every 200 ms is a bit slow, but sampling every 10-20 ms should give good results, especially noting the mechanical inertia of the motor, which does not allow fast speed changes.

Reply to
upsidedown
[on electric metering, for three-phase power]

That's a potential weakness; any low currents-for-a-long-time will get underreported, because of quantization error. It might be better to use an analog E*I multiplier, and a dither add-in signal, and digitize THAT. It might also help to integrate E*I onto a hold capacitor, 'cuz it's cheaper than fast sampling.

I'm curious: can one rely on the AC frequency as an integration timebase, or does a crystal clock have to be employed? I'm guessing this depends on the customer. It has to use a local clock if there's a variable-frequency motor drive target system.

Reply to
whit3rd

The classic fix for quantization error in a power meter is to add a bit of noise to the current signal. I've used both random noise and a small free-running triangle wave. A bit or two RMS is enough to smear out the ADC steps. Since the noise doesn't correlate with the voltage waveform, it washes out of the average.

If you use a 16 bit ADC, there will be plenty of noise; you don't have to add more. You can do utility grade metering, 20,000:1 dynamic range, with a noise dithered 8 bit ADC.

Analog multipliers can't handle the wide range that metering requires. They will always have some DC offset that looks like power. You can software auto-zero (essentially AC couple) voltage and current samples before you multiply, and get the resulting offset errors very, very small. Magnetic induced hum becomes a bigger error.

I usually do the sampling and math in a periodic interrupt routine, which is based on the crystal oscillator of the uP.

--
John Larkin         Highland Technology, Inc 

jlarkin at highlandtechnology dot com 
 Click to see the full signature
Reply to
John Larkin

Blather all you will. The issue IIUC is trying to understand how the VFD hash might upset metering and switchgear equipment.

?-)

Reply to
josephkk

Doesn't sound like blather, that is the key insight for power measurement isn't it? It transforms the problem. Instead of needing to perfectly reconstruct the current and voltage signals, requiring high performance, fast ADCs and CPU horsepower... you can just randomly sample (acquire instantaneous voltage/current pairs) at whatever speed you can manage.

If you want to "understand the waveforms" you need a scope, not a "microcontroller [to measure] true RMS".

--

John Devereux
Reply to
John Devereux

Right. Average or lowpass filter enough samples to get the measurement-to-masurement noise down where you want it.

There's a trick: real-word power measurements are inherently so noisy that you don't need to be compulsive about this. And if anybody certifies your meter for power, they will do it with a nice steady lab source, probably of a known frequency like 50 or 60 Hz.

The thing that people pay money for is energy, and energy is a long-term integral, millions or billions of samples in a billing period. The statistics win here.

Actually, there are a few tricks.

--
John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com    
 Click to see the full signature
Reply to
John Larkin

to

speed

that

known

long-term

Many years ago, I worked at a meter shop (EIL) where we built true-RMS analog meters which used glass vacuum-filled thermocouple bulbs to read the signal of about 5-8 volts RMS on the filament of a high voltage CRT, and

IIRC it used two of them and applied a DC current to one and measured the differential of the thermocouple outputs until they matched, at which point the DC voltage equaled the noisy AC signal. This would work for anything

from DC to high frequency RF.

But the thermocouple bulbs were very expensive, fragile, and hard to obtain, so I sought to design a less expensive alternative. I made a transducer consisting of a small incandescent lamp and a photocell, and it seemed to work fairly well, but I thought I could use just one of them, and found that the bulb (and/or photocell) would age appreciably over several hours or days. But such a system should work OK with two such sensors as in the thermocouple design.

A better system might be to use one sensor and switch between the input signal and a known DC signal and obtain a match. This should take care of any aging or differences in the sensors. The AC signal could be processed with dividers and amplifiers to read either voltage or current. This method should be accurate and capable of handling wideband noise and odd waveforms with high crest factors, but it would be slow.

In any case, measuring true RMS voltage and current is different from reconstructing waveforms and power measurement. For true power readings,

simultaneous samples of voltage and current are necessary, or an analog multiplier can be used. With PWM VFDs, the chopping frequency is generally in the 5kHz to 25kHz range, so a sampling rate of 50 kHz or so should be

sufficient. Of course there may be much higher harmonics, but they are probably not too significant, and may be filtered at the output of the VFD or by the instrumentation. Power, power factor, and phase angle are generally not too critical, although power needs to be measured fairly accurately especially at lower levels which may affect energy measurement over long periods of time.

I think it is best to add some LC filtering to the output of the VFD to reduce the fast switching and high frequency harmonics, which can cause high voltage transients that can damage insulation and introduce losses due to dielectric dissipation.

Measuring phase angle can be tricky, and in some cases it is better to determine the peak signal rather than zero crossings. I have found that some AC waveforms are asymmetrical to the point that zero crossings can vary up to several degrees. This was especially noticeable in a phase angle meter that used zero crossings and read several degrees differently when one signal was inverted for a +/- 180 degree reading instead of 0-360.

Paul

--
John Larkin                  Highland Technology Inc 
www.highlandtechnology.com   jlarkin at highlandtechnology dot com 
 Click to see the full signature
Reply to
P E Schoen

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.