Is it unrealistic to have a 125 MHz sampling rate with a cutoff frequency of 5 Hz? I downloaded a few filter programs and used their methods and it seems that even with thousands of taps it still looks pretty bad. Is there a better way to implement this digitally or should I just stick with an analog implementation?

  • 1
    \$\begingroup\$ Why 125MHz? Is that a 5Hz the cutoff for a high pass filter or for a low pass filter? \$\endgroup\$ – JRE Jun 16 '15 at 15:11

The basic formula for a simple filter relies on the ratio of time between samples and the time constant of the filter i.e. T\$_S\$/CR.

At 125MHz Ts is 0.000000008 and CR = 0.03 for a 5Hz cut-off.

Quite a few digital systems are going to produce errors unless you are working with decent floating point numbers. This is a simple digital IIR filter with a nod to the CR time of an analogue low pass RC filter: -

enter image description here

It's dead easy to implement in a spreadsheet and you can apply integer math (or whatever you are using) to see how it performs with the vast difference in sampling frequency and target cut-off frequency.

| improve this answer | |
  • \$\begingroup\$ OK, that's what I thought. So if I lowered my sampling rate of the filter and averaged inputs across the 125 MHz rate, would this help deal with aliasing? \$\endgroup\$ – Erik Jun 16 '15 at 15:07
  • \$\begingroup\$ I've got a reference to IIR filte4 design on my profile. Take a look and see the facts as I see them but this has nothing to do with aliasing. Aliasing happens when you sample too slowly. \$\endgroup\$ – Andy aka Jun 16 '15 at 16:18
  • \$\begingroup\$ Ok yes I see what you mean... You have to decimate appropriately and averaging should be ok. \$\endgroup\$ – Andy aka Jun 16 '15 at 16:20
  • \$\begingroup\$ Ok thank you, I will see how the downsample->filter approach works. \$\endgroup\$ – Erik Jun 16 '15 at 17:20
  • \$\begingroup\$ Very useful simple diagram for the lpf, I will try an implementation \$\endgroup\$ – Erik Jun 16 '15 at 17:27

Analog will be simpler (or maybe not - a circuit that works correctly from 5Hz to 75MHz might be difficult to implement,) though you can also use a digital implementation of an IIR filter.

FIR filters (which is what you tried to implement, judging by use fo the term "taps") will require a lot of taps for a 5Hz (assuming high pass, else why would you need 125MHz) filter at 125MHz sampling rate.

An IIR filter can do nearly the same job with just a few adds and multiplies. Look around for filter design software and algorithms for IIR filters.

It might also be fun (read as "challenging") to build an active filter with a cutoff of 5Hz that can still pass frequencies up to 75MHz.

I think your best bet really is a digital IIR filter - provided you can guarantee that the signal content below 5Hz won't push the ADC input past its limits (for example, a 2Hz signal at 5V peak to peak when your ADC can only take 3V peak to peak.)

| improve this answer | |
  • \$\begingroup\$ Alright, thanks. You nailed it on the head, I have been reading several papers on FIR filters but I hadn't really looked at IIR at all. I will try an IIR implementation and see how it does. \$\endgroup\$ – Erik Jun 16 '15 at 15:11
  • \$\begingroup\$ What are you doing with the rest of the signal (from 5Hz up to 75MHz?) \$\endgroup\$ – JRE Jun 16 '15 at 15:13
  • \$\begingroup\$ Well, I have a fast PID filter running for a locking electronics application. If I run a slow PID on the PID output, the lock lasts much longer. The slow PID helps accounts for changes in temperature/other environmental effects. The slow PID doesn't care about the high frequency output of the fast PID, it just observes the lower frequency noise. So basically I'd be filtering out the fast PID output. This has been done in analog but I'm trying to switch to digital. \$\endgroup\$ – Erik Jun 16 '15 at 15:16
  • \$\begingroup\$ Ah. So, actually you are using a low pass filter. That makes your options wider. \$\endgroup\$ – JRE Jun 16 '15 at 15:24
  • \$\begingroup\$ Yeah, I guess I just needed to realize that it's not too realistic to implement with FIR, I will try with IIR. Thanks for your help! \$\endgroup\$ – Erik Jun 16 '15 at 15:29

If one has a stream of 125M samples/sec, and one wants a stream with that same number of samples that only contains components that are 5Hz or below, the best way to accomplish that is to repeatedly perform a combined low-pass filter/downsample operation. A 100 sample/second stream is going to contain just as much information about signals 5Hz and below as would a 125M sample/second stream, but a low-pass filter with a cutoff at at 1/20 of the sample rate will require many fewer taps than one with a cutoff at 1/25,000,000 of the sample rate.

If one needs a high-pass filter rather than a low-pass filter, one can use symmetric low-pass filters in all the down-sampling operations, and then reconstitute the higher-speed signals from the lower-speed ones (again using symmetric filters) so that one ends up with a 125M samples/sec signal whose 5Hz content will be delayed by a fixed amount of time relative to the original. Delay the original signal by that same duration and subtract the reconstituted signal from it, and the result will be a signal which contains all of the high-frequency content of the original but none of the low-frequency content.

Note, btw, that at lower sample rates, the amount of work per second required to implement a filter with N taps will go down. If the first stage downsamples by 50%, the next stage will only have to do half as much work as if it was operating on the full-speed original signal. Later stages could afford to use more taps, and could thus afford to downsample by larger amounts.

| improve this answer | |
  • \$\begingroup\$ Thanks, I have one more question about that approach then: will too much down-sampling by averaging bring rise to bad aliasing? That is my one fear about this approach. \$\endgroup\$ – Erik Jun 16 '15 at 17:18
  • \$\begingroup\$ @Erik: Down-sampling in multiple stages should help eliminate that. If the cutoff for the filter is seven octaves below Nyquist of the original signal, but one only downsamples by 50%, even a 12dB/octave filter will reduce any possible aliasing by 72dB. To avoid adding quantizing noise and associated aliasing, it may be necessary to use higher precision for intermediate computations than are used for the original sample, but the reduced sample rate should make that feasible. \$\endgroup\$ – supercat Jun 16 '15 at 17:31
  • \$\begingroup\$ @Erik: Use of comb filters might make it possible to get even better performance, if one chooses their coefficients (and down-sampling ratios) such that they block out anything that would end up getting aliased to any frequency which isn't well above the final 5Hz cutoff. If the first resampling rate is 25Mhz and the second sampling is 5Mhz, the first filter must reject anything which is anywhere close to a non-zero multiple of 5Mhz, but anything that isn't near a multiple of 5MHz will after the 5MHz sampling operation yield a frequency which is high enough to be taken out by later stages. \$\endgroup\$ – supercat Jun 16 '15 at 17:44
  • \$\begingroup\$ Sure the multi-stage ds seems smart. At this point I'm going to go with a multi-stage downsampling and then a IIR lowpass filter. From there I will tune it until I'm satisfied. Thanks for the help. \$\endgroup\$ – Erik Jun 16 '15 at 17:53
  • \$\begingroup\$ @Erik: I don't know whether your real goal is high-pass or low-pass filtering. If your real goal is high-pass filtering (reject everything below 5Hz), be aware that an IIR filter will delay different frequencies by different amounts. I think comb filtering for the early stages and an FIR for the later stages is probably the approach I'd favor. \$\endgroup\$ – supercat Jun 16 '15 at 18:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.