Searching \ for '[EE] averaging multiple samples to reject AC inter' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/power.htm?key=ac
Search entire site for: 'averaging multiple samples to reject AC inter'.

Exact match. Not showing close matches.
PICList Thread
'[EE] averaging multiple samples to reject AC inter'
2020\08\10@154241 by Bob Blick

face
flavicon
face
I have sensors that feed an instrumentation amplifier running a voltage gain of 10 before going into the A/D converter of a microcontroller.

There is AC line interference. It is small, but if I can reduce the effect, that would be good. I'm in the 60 Hertz part of the world, but ultimately this will be used in both 50Hz and 60Hz locations. Battery operated, this is not conducted interference or power supply ripple. Shielding is not possible. I only need to process the signal about 4 or 5 times per second. The signal is changing, so long-term averaging is bad. Actually any averaging will result in a tradeoff between response time and accuracy that I will need to evaluate.

These sensors are multiplexed with others and I can't sample continuously.

If I average multiple samples taken at 1/300 second intervals over a 1/10 second period, that should give some improvement at 50Hz and 60Hz without getting too involved, correct? This would fit into my existing multiplexing constraints.

I seem to recall being in this situation before but forget what I did at the time.

Thanks for any suggestions.
Bob
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\10@160121 by Manu Abraham

picon face
Hi Bob,

I've had a similar situation, So, I did oversampling and decimation;
This not only reduced the swings, but indeed improve the ADC resolution.

The serious downside to this, is the response time;
But that was the whole logic to it. But the lower response time was
not an issue at my end.

In one situation, I was doing 1024x oversampling and a 10x decimation.
Was able to get about probably 100 samples per second, IIRC.

Regards,
Manu

On Tue, Aug 11, 2020 at 1:16 AM Bob Blick <spam_OUTbobblickTakeThisOuTspamoutlook.com> wrote:
{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\10@161617 by Jim

flavicon
face


A .1 second worth of samples is 30 samples at a 1/300 sampling period.
If my calculations are correct, 30 samples, at a 1/300 second sampling
period, that would reduce interference below about 5 Hz, if I am
thinking correctly about the Nyquist theory. If the interference is low frequency, this method should provide some
degree of reduction.  If the interference is higher frequency than that,
there may be little to no reduction.
The best way to find the answer is probably to just write the code to
implement the algorithm, and test it under actual conditions.

Regards,

Jim

> ---{Original Message removed}

2020\08\10@161705 by Dwayne Reid

flavicon
face
Hi there, Bob.

Old-time Dual-Slope digital meter systems did exactly what you describe, with great effectiveness.

dwayne


At 01:44 PM 8/10/2020, Bob Blick wrote:
{Quote hidden}

-- Dwayne Reid   <.....dwaynerKILLspamspam@spam@planet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
780-489-3199 voice   780-487-6397 fax   888-489-3199 Toll Free
http://www.trinity-electronics.com
Custom Electronics Design and Manufacturing

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\10@163438 by Richard Prosser

picon face
I did something similar a longish time ago - synchronised my sampling with
the mains frequency & averaged over a full  cycle. I can't remember the
details but It worked well. I think I was using a Keithly meter as the adc
and it handled the AC triggering side of things.

RP

On Tue, 11 Aug 2020 at 08:17, Jim <jimspamKILLspamjpes.com> wrote:

{Quote hidden}

> > ---{Original Message removed}

2020\08\10@172629 by Bob Blick

face
flavicon
face
Hi Dwayne,
That's exactly what I wanted to hear. Thanks!
Bob

________________________________________
From: .....piclist-bouncesKILLspamspam.....mit.edu <EraseMEpiclist-bouncesspam_OUTspamTakeThisOuTmit.edu> on behalf of Dwayne Reid
Sent: Monday, August 10, 2020 1:14 PM
To: Microcontroller discussion list - Public.
Subject: Re: [EE] averaging multiple samples to reject AC interference

Hi there, Bob.

Old-time Dual-Slope digital meter systems did exactly what you
describe, with great effectiveness.

dwayne


At 01:44 PM 8/10/2020, Bob Blick wrote:
{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\10@180952 by Sean Breheny

face picon face
Most multimeters still use dual-slope ADCs. One major advantage of this
technique (averaging over a multiple of the line frequency) is that it
actually places a notch (zero) of the transfer function at the line
frequency. It is MUCH better than simply a low-pass filter since it will
pass some frequencies above the line frequency and can pass frequencies up
to more than half the line frequency will very minimal attenuation.

On Mon, Aug 10, 2020 at 4:15 PM Dwayne Reid <dwaynerspamspam_OUTplanet.eon.net> wrote:

{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\11@050849 by David C Brown

picon face
Does that mean that multimeters from America are disadvantaged in Europe?
And vv?
__________________________________________
David C Brown
43 Bings Road
Whaley Bridge
High Peak                           Phone: 01663 733236
Derbyshire                eMail: KILLspamdcb.homeKILLspamspamgmail.com
SK23 7ND          web: http://www.bings-knowle.co.uk/dcb
<http://www.jb.man.ac.uk/~dcb>



*Sent from my etch-a-sketch*


On Mon, 10 Aug 2020 at 23:12, Sean Breheny <RemoveMEshb7TakeThisOuTspamcornell.edu> wrote:

{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\11@075841 by Dave Tweed

face
flavicon
face
David C Brown wrote:
> Does that mean that multimeters from America are disadvantaged in Europe?
> And vv?

Not at all. Averaging for 1/10 second, which is 5 whole cycles of 50 Hz or
6 whole cycles of 60 Hz, works equally well in both systems.

-- Dave Tweed
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\11@120142 by David Van Horn

flavicon
face
I did a filter some years back where I averaged up enough samples to get a complete cycle of the AC line, inverted it, and added it back to the data, which worked pretty well at getting rid of line based interference.

________________________________
From: RemoveMEpiclist-bouncesspamTakeThisOuTmit.edu <piclist-bouncesEraseMEspam.....mit.edu> on behalf of Richard Prosser <EraseMErhprosserspamgmail.com>
Sent: Monday, August 10, 2020 2:34 PM
To: Microcontroller discussion list - Public. <RemoveMEpiclistEraseMEspamEraseMEmit.edu>
Subject: Re: [EE] averaging multiple samples to reject AC interference

I did something similar a longish time ago - synchronised my sampling with
the mains frequency & averaged over a full  cycle. I can't remember the
details but It worked well. I think I was using a Keithly meter as the adc
and it handled the AC triggering side of things.

RP

On Tue, 11 Aug 2020 at 08:17, Jim <RemoveMEjimspam_OUTspamKILLspamjpes.com> wrote:

{Quote hidden}

> > ---{Original Message removed}

2020\08\11@121651 by David C Brown

picon face
Thanks
Not that I have any intention of going to America in the near future
__________________________________________
David C Brown
43 Bings Road
Whaley Bridge
High Peak                           Phone: 01663 733236
Derbyshire                eMail: RemoveMEdcb.homeTakeThisOuTspamspamgmail.com
SK23 7ND          web: http://www.bings-knowle.co.uk/dcb
<http://www.jb.man.ac.uk/~dcb>



*Sent from my etch-a-sketch*


On Tue, 11 Aug 2020 at 12:59, Dave Tweed <EraseMEpicspamspamspamBeGonedtweed.com> wrote:

{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\11@212006 by Art

flavicon
face

That's a great idea David, but with averaging, much performance is lost.
And, even without averaging, there is a finite propagation delay (phase
error) through the electronics-whether digital or analog.

It occurred to me that I might use a second A/D converter to quantify
the 60Hz powerline frequency and apply that correction digitally. There
will still be propagation delay and the amplitude of the 2 data streams
will never match precisly, but the sampling of the realtime data can be
delayed and sync'd by some amount by delaying the digital clock time
sampling of one of the waveforms. 

Such a practice probably improves the line frequency interference
problem, but might require lots of time to figure our whether it is usable.

I know that a similar technique is used in analog receiver inputs in
order to reduce line noise arcing, and it does work. MFJ makes the
hardware, but it takes a very long time to find the correct amount of
delay/phase/amplitude as the tuned circuit has nearly infinate
combinations of possible settings. Once the sweet spot is found, it
works well until the ambient temperature in the shack changes and
everything needs retweaking::>

The same concept cannot be applied to very low 50 or 60 Hz interference,
there is no way to make variable inductors and capacitors to make the
concept work.
-
Aloha,

W1ABA


On 8/11/20 11:59 AM, David Van Horn wrote:
> I did a filter some years back where I averaged up enough samples to get a complete cycle of the AC line, inverted it, and added it back to the data, which worked pretty well at getting rid of line based interference.
>



--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist

2020\08\12@114930 by David VanHorn

picon face
When I implemented the averaging filter it was on a Z8 running at 1 mips.
Didn't notice any performance issues in our application. (MICR reader)

On Tue, Aug 11, 2020 at 7:19 PM Art <RemoveMEky1kKILLspamspammyfairpoint.net> wrote:

{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\12@180804 by David VanHorn

picon face
" assuming the time it takes to aquire a sample is constant, how about
taking 3 readings A, B, C such that A and C are from the signal to be
measured and B is from the mains reference then the adjusted signal
becomes:"

is the shape of the AC line frequency what you're actually trying to remove?
Or is it a line frequency interference signal which is locked to the line
but not the same shape as the line waveform?


On Wed, Aug 12, 2020 at 3:25 PM sergio <smplxSTOPspamspamspam_OUTallotrope.net> wrote:

{Quote hidden}

-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\12@191112 by RussellMc

face picon face
>
> If averaging a not overly large number of samples then retaining a record
> of all samples and adding a new one to the total and dropping the oldest
> off gives a much more responsive result than eg

Latest/N + Sum x N-1/N


Russell


>
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\14@210313 by RussellMc

face picon face
On Thu, 13 Aug 2020 at 21:53, sergio <spamBeGonesmplxSTOPspamspamEraseMEallotrope.net> wrote:


> do you mean:
>
> Latest/N + Sum x (N-1)/N
>

You'd hope so :-)

         R
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\15@045809 by Isaac Marino Bavaresco

picon face


Em 14 de agosto de 2020 22:04:36 BRT, RussellMc <KILLspamapptechnzspamBeGonespamgmail.com> escreveu:
>On Thu, 13 Aug 2020 at 21:53, sergio <EraseMEsmplxspamEraseMEallotrope.net> wrote:
>
>
>> do you mean:
>>
>> Latest/N + Sum x (N-1)/N
>>
>
>You'd hope so :-)
>
>          R
>--
>http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
>View/change your membership options at
>http://mailman.mit.edu/mailman/listinfo/piclist

Does N grow indefinitely?
If yes, the new values will have less and less influence as time goes by.
If not, there will be a steady increase in the final result.
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\15@083609 by RussellMc

face picon face
On Sat, 15 Aug 2020 at 20:56, Isaac Marino Bavaresco <
@spam@isaacbavaresco@spam@spamspam_OUTgmail.com> wrote:

> Em 14 de agosto de 2020 22:04:36 BRT, RussellMc <spamBeGoneapptechnzspamKILLspamgmail.com>
> escreveu:
>


> >> Latest/N + Sum x (N-1)/N
>
> Does N grow indefinitely?
> If yes, the new values will have less and less influence as time goes by.
> If not, there will be a steady increase in the final result.
>

Sorry - it didn't occur to me that that was ambiguous.
Note that this was an algorithm that I said was not as good as retaining K
samples and averaging them.


N is a selected factor that controls how much effect the latest sample has
compared to all prior samples.

Define "AVAL" as the averaged value
Initially, set AVAL = 1st sample

Set N to say 4. This means that from now on new samples will account for
1/4 of the new value of AVAL and the old value will account for 3/4 of the
value of AVAL.

so AVAL = 1/4 x latest sample + 3/4 x AVAL

If N was 10 it would be  1/10x sample + 9/10 x AVAL.

This is not a marvellous method but has the advantage of not requiring
retaining any prior sample values and of the effects of past samples
diminishing relatively rapidly.

Example:
N=4
Sequence 5 5 5 5 5  20   20     20   20     20
Output     5 5 5 5 5 8.75 11.6  13.7 15.3  16.5 ...

For a single step function AVAL never reached the new value!

______________________________
Better:

If you retain say the last 4 and average them with the same input you get
5 5 5 5 5 8.75  12.5 16.25 20 20 ...

For a single outlier eg  5 5 5 5 5 20 5 5 5 5 5 5
You'd get 5 5 5 5 5 8.75 8.75 8.75 8.75 5 5 5

ie the outlier has an effect for N samples.


    R

>
>
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

2020\08\15@094238 by RussellMc

face picon face
>
>
> Hi Russell,
>
> I've had problems (long long ago) with:
> .. (actually (Latest + Sum x (N-1))/N, but same thing)
>
> I've just done a simulation and a blip can cause an error much futher down
> the line that expected. Consider a constant reading of 1 and a window of
> 10. The average after everything has settled down is 1 as expected. Now
> introduce a reading of 1023 (being 2^10-1). After 44 samples (still of 1)
> the average has slowly come down but is still at 2.
>
> Yes.
This post assumed a life that I did not intend :-).
I originally said ~~= that keeping N values in a FIFO and averaging them
(so you can completely throw away samples after N cycles) was superior to
the method discussed above.
I've used both (lonnnnnnnnnnnnnng ago) and (again) the retain-N -samples
method is superior.

There are of course methods tricks" for dealing with outliers
beyond acceptable limits, but, not using the method is even better.


      Russell
-- http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
mailman.mit.edu/mailman/listinfo/piclist
.

More... (looser matching)
- Last day of these posts
- In 2020 , 2021 only
- Today
- New search...