Embedded Systems Conference
Breaking News
Newest First | Oldest First | Threaded View
Max The Magnificent
User Rank
Re: Noise Filtering
Max The Magnificent   8/5/2014 2:48:32 PM
@Elizabeth: I've used averaging to reduce the noise on an anlog signal but the way I usually do it is to capture sets of samples 2 or 4 times as fast as you need them...

I can't wait to get the main display up and running, and to hen start playing with differenmt filtering techniques to see which works and looks best on the display.


User Rank
Re: Noise Filtering
Wnderer   8/5/2014 7:11:20 AM

Okay, I see what you're doing now. Thanks.

User Rank
Re: Noise Filtering
elizabethsimon   8/5/2014 12:15:58 AM
Yes you are right about the first example I gave being a moving average FIR filter of order two. And it would be mroe efficient to do it using a circular buffer..

In the second example I was trying to show an IIR filter. I think it would work as written but might be clearer if it was broken into steps like this


   newSpectrumLeft[i] = analogRead(channelLeft) / 4; // new sample

   spectrumLeft[i] = (spectrumLeft[i] + newSpectrumLeft[i]) / 2; average


The difference between this example and the first one is that it's always influenced by ALL previous samples although the older samples have much less influence.

As an example, say you had the following values for newSpectrumLeft and you started with everything at zero

32 32 0 0 0 0 0

with the first example that I gave you would have

16 32 16 0 0 0 0

the second example should give

16 24 12 6 3 1

At least that's the idea I was trying to get across


User Rank
Re: Noise Filtering
Wnderer   8/4/2014 6:46:32 PM

I don't think that's exactly right. I believe your first example is a moving average filter of order 2 which is an FIR filter. I think your second example keeps getting bigger.  See the Wiki page.


I'm not sure the way he is averaging now is doing anything beneficial since he just averages short bursts of values. Implementing a moving average filter might improve the signal, but Max would need to implement a circular buffer for the spectrum values in between channel reads.


Some Notes on moving average filters, that seem to be missing from the Wiki.

A moving average filter implements a sinc function

H[f] = |sin(pi *f *M)/(M*sin(pi*f))| where M is the order of the filter. 

The full sampling frequency is divided into M humps.

The peak at the center of sampling frequency has an amplitude of 1/M for odd M. The peaks near the center will be close to this value for even M.

The amplitude of the second hump that occurs at 1.5/M approaches 1/1.5pi as M gets large.



User Rank
Noise Filtering
elizabethsimon   8/4/2014 4:44:17 PM
I've used averaging to reduce the noise on an anlog signal but the way I usually do it is to capture sets of samples 2 or 4 times as fast as you need them.

so in main you would have





while in your subroutine you would have


   oldSpectrumLeft[i] = newSpectrumLeft[i];

   newSpectrumLeft[i] = analogRead(channelLeft) / 4;

   spectrumLeft[i] = (oldSpectrumLeft[i] + newSpectrumLeft[i]) / 2;


This is the simplest form of FIR (Finite Impulse Response) filter


Or if you wanted a "running average" you could use something like


   spectrumLeft[i] = (spectrumLeft[i] + (analogRead(channelLeft) / 4)) / 2;


If you do this though, you need to make sure that you initialize spectrumLeft[i] to zero in your startup code. This is the simplest form of IIR (Infinite Impulse Response) filter.

The averaging technique your friend Steve showed you is most useful if you have a lot of noise on the analog signal which might occur if you had long wires or you were using adjacent signals to run PWM to a motor or something similar.


User Rank
waveform hardware
Sheepdoll   8/4/2014 2:59:11 PM

Your timing diagrams look similar to the ones I have for my pipe organ playback and paper roll conversions.  May be some similarity here as music is recorded as discreet 'events' which relate to frequency (pitch) and duration.

My preference on the Arduinos when dealing with sample and hold type shift registers, is to cascade the hardware timers.  This is how the USB scanner I showed at EELive! works.

One timer is set to the width of the clock pulse.  This toggles the clock line through the output compare. The cascaded timer (which can be done through the timer configuration) counts the clock pulses and can toggle the output compare pin automatically to generate the strobe.  This keeps the ISR routines small.  The overhead plus a shift of the bit in or out. 

For really tight constraints, Unrolled loops work well.  This is a code space/clock speed tradeoff.  AVRs have a lot of code space.




Top Comments of the Week
Like Us on Facebook

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
EE Life
Frankenstein's Fix, Teardowns, Sideshows, Design Contests, Reader Content & More
Max Maxfield

March 28 is Arduino Day -- Break Out the Party Hats!
Max Maxfield
Well, here's a bit of a conundrum. I just received an email from my chum David Ashton who hails from the "Unfinished Continent" Down Under. David's message was short and sweet; all he said ...

Bernard Cole

A Book For All Reasons
Bernard Cole
1 Comment
Robert Oshana's recent book "Software Engineering for Embedded Systems (Newnes/Elsevier)," written and edited with Mark Kraeling, is a 'book for all reasons.' At almost 1,200 pages, it ...

Martin Rowe

Leonard Nimoy, We'll Miss you
Martin Rowe
Like many of you, I was saddened to hear the news of Leonard Nimoy's death. His Star Trek character Mr. Spock was an inspiration to many of us who entered technical fields.

Rich Quinnell

Making the Grade in Industrial Design
Rich Quinnell
As every developer knows, there are the paper specifications for a product design, and then there are the real requirements. The paper specs are dry, bland, and rigidly numeric, making ...

Special Video Section
After a four-year absence, Infineon returns to Mobile World ...
A laptop’s 65-watt adapter can be made 6 times smaller and ...
An industry network should have device and data security at ...
The LTC2975 is a four-channel PMBus Power System Manager ...
In this video, a new high speed CMOS output comparator ...
The LT8640 is a 42V, 5A synchronous step-down regulator ...
The LTC2000 high-speed DAC has low noise and excellent ...
How do you protect the load and ensure output continues to ...
General-purpose DACs have applications in instrumentation, ...
Linear Technology demonstrates its latest measurement ...
Demos from Maxim Integrated at Electronica 2014 show ...
Bosch CEO Stefan Finkbeiner shows off latest combo and ...
STMicroelectronics demoed this simple gesture control ...
Keysight shows you what signals lurk in real-time at 510MHz ...
TE Connectivity's clear-plastic, full-size model car shows ...
Why culture makes Linear Tech a winner.
Recently formed Architects of Modern Power consortium ...
Specially modified Corvette C7 Stingray responds to ex Indy ...
Avago’s ACPL-K30T is the first solid-state driver qualified ...
NXP launches its line of multi-gate, multifunction, ...
EE Times Senior Technical Editor Martin Rowe will interview EMC engineer Kenneth Wyatt.
Flash Poll