Does my sampling rate act as a low pass filter?

nsaspook

Joined Aug 27, 2009
13,086
If I sample a thermocouple at a slow rate such as 1 Hz, do I need Low Pass Filters? I'm not aware of any noise sources that are that low in frequency, and since I'm sampling so slowly, does this by default eliminate noise contributions in the high frequency ranges?
Low frequency sampling rate high resolution systems still need a good LP filter for all the reasons mentioned above.

https://www.ti.com/lit/ds/symlink/ads1220.pdf section 9.1.2 on page 45
Many sensor signals are inherently bandlimited; for example, the output of a thermocouple has a limited rate of
change. In this case the sensor signal does not alias back into the pass-band when using a ΔΣ ADC. However,
any noise pick-up along the sensor wiring or the application circuitry can potentially alias into the pass-band.
Power line-cycle frequency and harmonics are one common noise source. External noise can also be generated
from electromagnetic interference (EMI) or radio frequency interference (RFI) sources, such as nearby motors
and cellular phones. Another noise source typically exists on the printed circuit board (PCB) itself in the form of
clocks and other digital signals. Analog input filtering helps remove unwanted signals from affecting the
measurement result.
A first-order resistor-capacitor (RC) filter is (in most cases) sufficient to either totally eliminate aliasing, or to
reduce the effect of aliasing to a level within the noise floor of the sensor. Ideally, any signal beyond f(MOD) / 2 is
attenuated to a level below the noise floor of the ADC. The digital filter of the ADS1220 attenuates signals to a
certain degree, as illustrated in the filter response plots in the Digital Filter section. In addition, noise components
are usually smaller in magnitude than the actual sensor signal. Therefore, using a first-order RC filter with a
cutoff frequency set at the output data rate or 10x higher is generally a good starting point for a system design.
https://www.analog.com/en/analog-dialogue/articles/practical-filter-design-precision-adcs.html

https://www.physicsforums.com/threads/power-from-the-super-moon.765429/post-5224011
PXL_20220708_163153058.jpg
https://forum.allaboutcircuits.com/threads/50nv-resolution.130468/post-1073894
 
Last edited:

BobTPH

Joined Jun 5, 2013
8,813
I gave up, I am not saying that a low pass filter should not be used. It will clearly reduce noise at frequencies above it’s cutoff.

The assertion that I take issue with is that averaging will not reduce noise. It will, in all cases that contain random noise. And even if the noise is a single frequency, it will reduce the noise in the case where that frequency is not correlated with the sampling frequency.
 

nsaspook

Joined Aug 27, 2009
13,086
I gave up, I am not saying that a low pass filter should not be used. It will clearly reduce noise at frequencies above it’s cutoff.

The assertion that I take issue with is that averaging will not reduce noise. It will, in all cases that contain random noise. And even if the noise is a single frequency, it will reduce the noise in the case where that frequency is not correlated with the sampling frequency.
There is no disagreement. You need both usually for proper low level signal processing.

Raw signal data chart display example with noise.
1657309373622.png
Post processed signal example:
1657309424264.png
 

MrChips

Joined Oct 2, 2009
30,712
Think in terms of the energy spectrum.

Suppose you were to remove all the energy in the desirable frequency band with everything above the Nyquist limit, fs/2, remaining.

When sampling at fs is applied, because of undersampling, all the energy above the Nyquist limit is frequency shifted to base-band, i.e. from 0 to fs/2 Hz.

You now have all this undesirable energy in the pass band which you don't want in the first place.
 

ag-123

Joined Apr 28, 2017
276
Ok I found the "answer", (ADC) sampling is actually a "brick wall" low pass filter. (wait a minute, but it does not remove the alised frerquencies).The answer is published in wikipedia
https://en.wikipedia.org/wiki/Whitt...alent_formulation:_convolution/lowpass_filter
https://en.wikipedia.org/wiki/Nyquist–Shannon_sampling_theorem
\[ x(t) = \left( \sum_{n=-\infty}^{\infty} T\cdot \underbrace{x(nT)}_{x[n]}\cdot \delta \left( t - nT \right) \right) \circledast \left( \frac{1}{T}{\rm sinc}\left(\frac{t}{T}\right) \right). \]

The term on the right with the sinc function is the effect of sampling.
The term on the left is the signal (+ all the "noise"), and as apparently it shows that the higher frequencies (noise) are simply included. So this signal consists the desired signal + the aliased components (the amplitudes of the higher frequency components as part of the signal). An RC filter before ADC can attenuate those higher frequency components.
The effect I'd think is that the resulting signal consist of frequency components \( f_{samp} / 2 \) which includes the original aliased amplitudes.

If however, the sample frequencies that we are interested in is below this sampling frequency, e.g. for temperature sensors mostly DC, we can still digitally process the sampled signals (which includes the aliased amplitudes) to remove those higher frequency fluctuations. So a digital low pass filter can attenuate the aliased signal so that there are fewer fluctuations. The aliased amplitudes would nevertheless be there, just attenuated.
 

Ian0

Joined Aug 7, 2020
9,671
Sampling at the same frequency as the interference will remove it.
Example - sample at 100 samples/second to remove the effects of power supply ripple - but it must 100Hz derived from the mains itself, not 100Hz from a microprocessor clock, otherwise it will slowly drift from sampling at the peak to sampling at the trough and back again.
 

drjohsmith

Joined Dec 13, 2021
852
Digital average does not remove the high frequency noise.
Any signal above the Nyquist limit gets folded down below fs/2.
You must use antialiasing filter if you cannot guarantee that the signal is already band-limited.
Your correct / and in this case wrong, !!

You dead right, any noise in the pass band of the input filter is seen in the ADC,
as you say , if the filtering is to high compared to the adc sample rate,
the noise will be aliased down,

BUT

The system I was describing,
The signal band of interest was as per the OP note, 1 Hz
and the ADC was sampling at say 10 KHz
thus the Nyquist filter needs to be better than 5 KHz,

Thus the digital filter can remove the noise above the 1 Hz range
in particular the 50 / 60 Hz,
 

MrAl

Joined Jun 17, 2014
11,389
Hello,

If the noise is completely random then it cancels out in the average. Some will be above the mean, some below the mean, and a random signal stored in memory can be modeled as an ordered list which would look like a triangle wave that goes above and below zero by equal amounts so any average would cancel it to zero. The question is, is it really random, and how many samples does it take to get a smooth average.
IF the signal comes from an unrelated source, the chances are it's random, but if the sampling period is harmonically related to the noise that presents a big problem, and if the sample averaging period is too short, we'll see pops and dips in the output which usually isnt good.
The other problem is if the noise has very low frequency components, then it's impossible to filter because the averaging period would have to be too long. An example of this is a Hall Effect Device, which has a lot of harmonics including low frequencies.

That said, i have had good luck with moving average filters and digitally programmed low pass filters which are very simple:
Vout[n+1]=(Vin[n]+Vout[n]*(N-1))/N
where N would be the averaging period in integer units of sample periods (and greater than 1).
So a typical implementation would read:
Vout=(Vin+Vout)*7)/8
and a smoother version would read:
Vout=(Vin+Vout*15)/16
and a much much smoother version would read:
Vout=(Vin+Vout*1023)/1024
This last one means abrupt changes that level off take a longer time to show up as the full value.
I've gone very high in N for some filters where the speed of response of the system was not a big issue.

There are also low pass filters you can develop from Z transforms which also work well and you can go higher in order without too much difficulty.

There is also oversampling which is an interesting way to make measurements.
 

drjohsmith

Joined Dec 13, 2021
852
Digital average does not remove the high frequency noise.
Any signal above the Nyquist limit gets folded down below fs/2.
You must use antialiasing filter if you cannot guarantee that the signal is already band-limited.
You are dead right

BUT that is not what we are saying.

The averaging "lowers" noise in the signal thats below the Nyquist / 2
it has the effect of increasing the SNR, an effect that is used to increase the ENOB

So if I sample at say 10 KHz, with a 12 bit ADC
I have an anti alias filter at say 2 KHz

I average 4 samples
I get a sample at 500 HZ , at an equivalent to 13 bits,

No one has said anywhere that one should not have a Nyquist filter,

Out of interest,
https://www.analog.com/en/technical...l guideline, oversampling,10log10 (OSR) in dB.
 

ag-123

Joined Apr 28, 2017
276
here is a real experiment, I brought an LMT86 near a lighter flame for an instant, nearly blew it.
This is how it heats up rapidly and cools, time scale is in 1/10 seconds.

https://www.stm32duino.com/viewtopic.php?p=8524#p8524

In this application, there is a 1 nF capacitor at the ADC (or rather OpAmp - as a buffer) input to ground.
It is rather visible especially at the lower temperatures, there are "spikes".
This is already significantly tempered by the 1 nF capacitor as an RC filter.
Without that capacitor, this RFI (radio frequency interference) would present itself at the ADC, and the results would likely be much worse than that seen above.


The signal is not further digitally processed other than the 1 nF external capacitor RC filter.
I've thought about it, I can reduce those spikes using a moving median filter say about 5-7 values. I may even need to track a regression to pick off the outliers. But a moving median filter is cpu intensive, especially if the width is larger.
The alternates are using averages or exponential averages, they have similar effect but not as 'aggressive' as moving median filter to remove outliers.

but the gist here is, that 1nF capacitor removed this drastic RFI signals and leaving only some 'spikes' in an actual measurement, and no further digital processing is used.
I worked the bode plot of that 1nF RC filter
https://www.stm32duino.com/viewtopic.php?p=8509#p8509
it looks like this

so 'noise' above 100khz are pretty much removed before it reaches the ADC. And that above about 3-5khz are heavily attenuated before the ADC.

3d printers uses a 10 uF ! capacitor as a filter, that is quite extreme.

But I'd guess it is because thermistors in that environment is noisier and that a 3d printer is a "production" environment, so it is more important to attenuate spikes to ensure that the hotend is maintained at a stable temperature during print.
The downside of using a huge capacator RC filter is temperature movements are attenuated as well and I can observe the PID temperature control oscillating a little as it overshoots a little and is cooled down.
 
Last edited:
Top