Connect with us

Microcontroller True RMS with noisy waveforms?

Discussion in 'Electronic Design' started by EnigmaPaul, Jul 28, 2013.

Scroll to continue with content
  1. EnigmaPaul

    EnigmaPaul Guest

    Guys -

    In measuring True RMS voltage and current, waveforms from non-linear loads like rectifiers chop up the current and cause noise on the voltage. In measuring with an A/D converter of a microcontroller, we need to figure out zero crossing points in order to avoid truncation errors in the data to define the start and stop of each cycle. That is challenging with a lot of harmonics and noise that cause tons of false zero crossings.

    Does anyone have any experience in doing something similar to this and how did you deal with the zero crossing noise?

  2. EnigmaPaul

    EnigmaPaul Guest

  3. EnigmaPaul

    EnigmaPaul Guest

    Power Line Voltage.
    Actually it specifically needs to work with gensets, and gensets that are being loaded by non-linear loads like VFDs.
    There may be other reasons where synchronization is needed, such as to synchronize the transfer between two sources, but that appears to be a separateproblem. I probably need to also compute phase angle at some point as a future add-on so that needs to be considered.
  4. Guest

    The actual sampling rate does not have to be very high, if you can
    wait for the result for a few seconds.

    The sampling pulse to the S&H circuit must be narrow (hundreds of
    microseconds) but the actual A/D sampling rate could be about the same
    (but not exactly the same) as the mains frequency. With a sampling
    pulse every 361 degrees of mains frequency, it would take about 7
    seconds at 50 Hz and 6 seconds at 60 Hz to reconstruct a repetitive
    waveform with 1 degree resolution. Taking a few samples every mains
    cycle or reducing time resolution, would drop the averaging time

    Think about how sampling oscilloscopes works.
  5. EnigmaPaul

    EnigmaPaul Guest

    Hi Guys -

    As the OP, I realized that I should probably more clearly state my
    objectives so as to make it easier for you to focus your advice.

    1. I am measuring 3-Phase Volts and 3-Phase Amps
    2. It must yield a 'True RMS' measurement accurate to 1% of full scale
    for voltage (say 480V), and 2% of full scale current (5A).
    3. The current sensing will use standard 5A secondary Current
    Transformers across a precision shunt resistor.
    4. The processor available is a 32 bit ARM Cortex with built-in ADC (12Bit).
    5. I expect substantial harmonics and possibly conducted/radiated noise
    from non-linear loads such as VFDs. Measurement up to the 10th
    harmonic is desirable.
    6. I don't need especially speed response of the Volts and Amps values,
    substantial delay is acceptable up to perhaps a second or two.
    7. It must work with engine-driven generator outputs which may not be
    'stiff' power supplies compared to the grid. However, usually the
    outputs will be reasonably well regulated with electronic governors and
    automatic voltage regulators.
    8. Although its not part of my initial design, I do anticipate adding
    phase angle to complete KW and PowerFactor and to possibly trigger
    in-phase synchronization of two AC sources.
    9. Although there is a fairly high power CPU available, lots of other
    activities will be happening at the same time such as network
    communications, supervisory functions, time delay logic, processing of
    sensors, etc. This is happening within the framwork of a basic
    pre-emptive RTOS (FreeRTOS).
    10. It is desirable to do as much of the RMS processing and filter in
    software so as to keep the hardware generic.

    Hopefully this helps to focus the discussion.

    Thanks for your input Tim, John, and Mike.

  6. Guest

    Since 6 pulse rectifiers (without smoothing) tend to have quite long
    conducting angles, the peak/average ratio is pretty moderate, compared
    to single phase rectifier with a large capacitor, thus less problems
    with the dynamic range.
    The peak current handling (full scale) capacity needs to be many times
    the average ratings, if big single phase electronic loads without PFC
    are expected.
    So at least 20-30 sample points are needed.
    To get those points during a single 60 Hz cycle, a sampling rate above
    2000 Hz would be sufficient.
    If the generator frequency is sufficiently stable during that one
    second (mechanical inertia), you could spread out those 20-30 sample
    points all over the 1 s period, thus less than one sample/cycle.
    Taking a few asynchronous samples every cycle and the measurement will
    also follow subsecond speed fluctuation. Some odd sampling frequency,
    such as 379 Hz should work with 50/60 Hz with some governor
    tolerances, without falling to sync.
    While real power [kW] and power factor [0..1] make sense for any kind
    of waveform, the phase angle is relevant only for linear (RCL) loads,
    not for non-linear loads, such as the VFD input rectifiers.

    I think that you should forget the issue of trying to measure phase
    angles at the moment and study other methods to measure the RMS
    current. The real power can be obtained by multiplying the voltage and
    current samples obtained out and averaging the result.

    Doing a three lamp phase synchronizer in software ?? I still do not
    think that you need to know the phase angle.
  7. EnigmaPaul

    EnigmaPaul Guest

    Good comments guys.

    I am reviewing an existing software design from another engineer so I
    needed to spend some time trying to understand what is currently being
    done. This design works but has problems with current sensing not
    working or working inaccurately when presented with non-linear VFD

    The basic sequence is as follows. Each RMS calculation is tored in a
    ring buffer in FIFO fashion:

    Calculate average RMS current (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS Voltage (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS current (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS Voltage (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS current (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS Voltage (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS current (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS Voltage (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS current (Ph A, B, and C)
    Wait 200ms while doing other systems tasks

    Calculate average RMS Voltage (Ph A, B, and C)

    The averages of the above 5 calculations is taken and presented to the
    display screen and monitoring system.

    Each RMS calculation consists of:
    1) Each 1/2 waveform being sampled at 21us between each sample.
    2) Slope detection and zero crossing detection is used to start and
    stop the sampling and to identify "tops" and "bottoms" of the waveforms.
    3) The tops and bottoms are sampled in an alternating fashion for each
    RMS calculation above. Hence, we might sample a top and then approx
    200ms later start sampling a bottom.
    4) When two tops and two bottoms are sampled (equivalent to 2 cycles),
    then these are used to calculuate RMS and is fed to the ring buffer
    5) The microcontroller has a hardware feature for detecting zero
    crossings which is used at the basis of the zero crossing detection
    using interrupts. We also do some additional checks to verify
    monotonicity on the result of the zero crossing to try to verify that
    its legitimate and not "noise".
    6) There does not appear to be any low pass filtering in the digital
    domain. There is some hardware filtering; a second order filter that
    starts to roll off quickly after the 10th harmonic (assuming 60hz

    I know the devil is in the details and I've probably left out some
    important ones that I have yet to discover but I am wondering if anyone
    has any general comments or critique on this overall approach?

    It strikes me that:

    a) The sampling rate seems unnecessarily high. Its sort of like we can
    vastly oversampling with LONG gaps between sampling runs.
    b) Splitting the waveforms into tops and bottoms seems complicated and
    subject to error in the presence of harmonics. i.e. how do we know we
    are on a positive slope of the fundamental and not the positive slope
    of a double dip bump due to harmonics?
    c) There could be things changing in between the long gaps of sampling
    runs. For example the frequency shifts between the time we sampled the
    top and later sampled a bottom.
    d) the zero crossing detection in the microcontroller is a bit of a
    black box for me. Its not clear to me these are designed to work on
    noisy waveforms.

  8. EnigmaPaul

    EnigmaPaul Guest

    I fogot to mention that it is called the "Analog Watchdog".
  9. EnigmaPaul

    EnigmaPaul Guest

    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.
  10. Guest

    Guest Guest

    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
  11. josephkk

    josephkk Guest

    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.

  12. Chris Jones

    Chris Jones Guest

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

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

  13. josephkk

    josephkk Guest

    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.

  14. Guest

    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.
  15. whit3rd

    whit3rd Guest

    On Tuesday, July 30, 2013 7:41:30 AM UTC-7, John Larkin wrote:

    [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.
  16. josephkk

    josephkk Guest

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

  17. 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".
  18. P E Schoen

    P E Schoen Guest

    "John Larkin" wrote in message
    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.



    John Larkin Highland Technology Inc jlarkin at highlandtechnology dot com

    Precision electronic instrumentation
    Picosecond-resolution Digital Delay and Pulse generators
    Custom timing and laser controllers
    Photonics and fiberoptic TTL data links
    VME analog, thermocouple, LVDT, synchro, tachometer
    Multichannel arbitrary waveform generators
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day