0

I need to acquire an analog signal via an ADC and send it via a digital communication line (CAN bus) with a given frequency $f_{send}=100Hz$. If I understand correctly this means that this constraint imposes a low pass filter on the acquired signal of $f_{send}$. My question is: what is the correct sampling rate to use for the analog signal given this constraint?

Currently to solve this problem my approach is the following:

  • the analog signal has a hardware antialiasing filter of $1KHz$
  • I sample the signal at $f_{samp}=2.5KHz$ to satisfy Nyquist-Shannon
  • The samples are then filtered via a digital IIR filter set to a cut-off frequency of $f_{send}$.
  • Every $1/f_{send}$ seconds I take the last acquired and filtered sample and send it through the communication line. enter image description here

I don't know if the steps I take are logically sound and/or have logical errors that mis-rapresent the data that I send through the comm-line. For example:

  1. Since I need to send data at $f_{send}$ (stage 4 in image) does it make sense to have a low pass filter of $f_{send}$ on the sampled data or do I need at least $2*f_{send}$ (stage 3)? i.e. What is the value of IIR_LPF: 100Hz or >200Hz?
  2. Moreover, my adc produces $1/f_{samp}$ samples in a second (stage 2), and the same number of samples appear after stage 3. Each $1/f_{send}$ seconds I need to send a sample on the digital line. Which sample I use out of the $f_{samp}/f_{send}$ ones? The last one? The average of them all?
  3. If my main constraint is to send data at $f_{send}$ do I lower the $f_{samp}$ to something near $2*f_{send}$ or I keep the current setup so that I have more filtering data?

Text books and resources talk a lot about aliasing, hardware sharing factor and sampling frequency but never about a real case scenario like this.

1 Answers1

1

Short answers:

  1. The second LPF's cutoff frequency must be $f_\text{send}/2$. Nyquist says that $f_\text{send} > 2B$, so the signal's maximum frequency $B$ must satifsy $B < f_\text{send}/2$.
  2. You can send just one out of every $N$ samples (this is called "decimation", a special case of resampling). There is no need to average them (averaging may help reduce noise in some cases, but it's not clear that's the case in your situation).
  3. The design may be modified to use only one filter (or three, or more...). Having only one filter means that it needs to have a very steep respone (that is, a filter of very high order). A sequence of filters allows filters of a lower order (simpler). Simulation is your friend here: simulate a few different scenarios and figure out the optimum combination given your requirements.

Long answer:

Here's a diagram similar to the process you describe. The first LPF and ADC correspond to your diagram. The cutoff frequency of the second LPF needs to be 50 Hz. The signal at (3) is "resampled" (or decimated) to a sampling frequency of 100 Hz.

enter image description here

The signal at (4) has a sampling rate of 100 Hz; its maximum frequency component must be 50 Hz to prevent aliasing, and this is ensured by the IIR digital LPF with cutoff at 50 Hz.

In your question, you don't mention a resampler, but here it is necessary, since the signal at (3) still has a sampling rate of 2.5 kHz.

(Note that the filters in the diagram are assumed ideal; you need to make sure that the filters reduce the aliases to a magnitude you are comfortable with.)

Some additional notes:

  • The signals at (2), (3) and (4) are discrete-time (sampled) signals. Their sampling rates are different, though: it is 2500 kHz at (2) and 100 Hz at (4).
  • There are several techniques to modify the sampling rate of a discrete-time signal. The process in general is known as "resampling". To go from 2500 to 100 Hz, as in this question, one may simply "decimate" the signal at (3), taking one sample out of every 25 and ignoring the other 24 samples.
  • When resampling, Nyquist must still be complied with. When decimating signal (3) to change its sampling rate from 2500 to 100, any component larger than 50 Hz will be aliased. Therefore, the LPF with cutoff at 50 Hz is necessary.
MBaz
  • 15,314
  • 9
  • 30
  • 44
  • And what about the smapling frequency? Does it make sense to lower it as to reach the magnitute of 100Hz? Or the higher sampling increases accuracy? – Jhonathan Asimov Jan 03 '24 at 16:31
  • @JhonathanAsimov I've edited my answer; please see if it is clearer. Also, increasing the sampling frequency at point (4) does not help, since the signal at (3) has nothing above 50 Hz (ideally). – MBaz Jan 03 '24 at 18:38
  • At stage 3 i'm not using an LPF with cut-off at 50Hz but 100Hz (equal to fsend), therefore at stage 4 I don't use a resampler (i don't know what it is), I just send the last sample available after stage 3 every 10ms (100Hz of fsend). My doubt was if the last sample used has significance since only one out of 10 are used after the LPF @3 – Jhonathan Asimov Jan 11 '24 at 21:38
  • @JhonathanAsimov The LPF at (3) should have cutoff of 50 Hz or you risk aliasing. If you know for sure that the signal at (2) has no significant components higher than 50 Hz, then filtering at 100 Hz may be fine, but it's still suboptimal. – MBaz Jan 11 '24 at 22:24
  • Resampling is just the process of converting a signal from one sampling rate to another. In your case, you're going from 1,000 to 100 samples per second. The process of taking 1 sample out of N is often called "decimation". It works fine, except for the possiblity of aliasing, which is why having an appropriate LPF (anti-aliasing) filter is important. See https://dsp.stackexchange.com/questions/62177/downsample-resample-vs-antialias-fitlering-decimation and https://en.wikipedia.org/wiki/Downsampling_(signal_processing) – MBaz Jan 11 '24 at 22:27
  • In response to the second last comment, I don't understand why you suggest using a 50Hz lpf for a 100Hz sending rate... moreover I think your whole diagram has some values inverted...stage 1 is an lpf of 1KHz and that can't be changed because it is a hardware filter... then I sample with the ADC at 2KHz for NYQST and antialiasing (maybe should be 2.5Khz) and this is step 2, after that my only constraint is to send the signal at 100Hz send period (step 4).. I will update my question – Jhonathan Asimov Jan 13 '24 at 11:38
  • You know you will sample a signal $s(t)$ at rate $f_s$. The sampled signal $s[n]$ contains frequencies up to $f_s/2$. Any frequency content in $s(t)$ above $f_s/2$ will be aliased in $s[n]$. To avoid aliasing, you need to filter $s(t)$ prior to sampling, with a LPF with cutoff at $f_s/2$. (The same is true if the original signal is already discrete-time, and it will be resampled). – MBaz Jan 13 '24 at 19:57
  • So you are saying that stage 4 is another sampling stage like the adc does for s(t)? So I need to apply NYQST the same way right? In that case I have some troubles understanding why I could have aliasing in the discrete domain: I can't get a picture in my mind where a 100Hz signal after stage3 (in my figure) could be sampled not correctly at stage 4 since we are in discrete domain... And secondly, for what concerns point 2 in my question do you have some suggestions? Is it correct to have more samples available and send just the last one? – Jhonathan Asimov Jan 14 '24 at 17:28
  • Yes, Nyquist applies to (re)sampling an already sampled signal. (I'm in a bit of a hurry, I'll try to respond to your other questions later) – MBaz Jan 14 '24 at 17:52
  • @JhonathanAsimov I've edited my answer; I hope you find it more useful. – MBaz Jan 14 '24 at 20:40
  • Thank you, it is, I just have some doubts on step 1 and 2 shouldn't the frequencies be inverted? LPF at 1Khz and ADC at 2Khz following NYQ? – Jhonathan Asimov Jan 22 '24 at 22:26
  • @JhonathanAsimov I've updated my answer to better match the edits to your question. – MBaz Jan 25 '24 at 20:27