Page 1 of 1

Direct sampling to bandwidth output, how done?

Posted: Sat Aug 01, 2020 3:17 pm
by tustinfarm
This is fairly deep technical question that applies to all SDRs, purely my curiosity, posting on the chance there is an SDR expert out there who can answer it in a simple manner, or post a hyperlink...

I have always wondered how the raw ADC samples in the RTL-SDR dongle (28.8 megasamples/second?) are processed and downsampled to the lower rates needed to transfer data out of the dongle to the PC software for a given bandwidth setting. In other words, a 2 MHz bandwidth setting requires a lot more bits/second from the USB connection than a 1 MHz setting, but how exactly is the original raw data from the ADC sampling transformed in the dongle? Is a FFT done, followed by filtering at the selected the bandwidth, then a reverse transform? Or some kind of mathematical averaging on the entire stream to downconvert it?

Re: Direct sampling to bandwidth output, how done?

Posted: Mon Aug 03, 2020 3:44 pm
by hotpaw2
The mathematically correct solution is to use a perfect band-limiting anti-aliasing or low-pass filter before decimation or interpolation. In reality, no filter is perfect. So an anti-aliasing filter should have a stop band attenuation below the radio's desired noise floor at and above the new downsampled sample rate.

Anti-alias filtering can be implemented in software or hardware by many different methods, including using a high-order IIR filter, or using a windowed Sinc or computer optimized FIR filter. An IIR is usually implemented by sections of recursive arithmetic (biquads, corresponding to sections of analog LC filters). A IIR works similar to averaging, but due to feedback and multiple sections, is a lot smoother in the frequency domain. A FIR filter can be implemented by straight convolution (a lot of vector arithmetic), perhaps using a polyphase filter bank or Farrow interpolator for each set of FIR filter coefficients. or by overlap-add/save FFT/IFFT fast convolution for greater efficiency. There are other solutions including CIC filters and incremental multi-rate filtering and downsampling (reducing the sample rate in steps).

For fractional sample rate ratio changes, one can also upsample before downsampling, but I prefer polyphase interpolation methods to upsampling as more computationally efficient.

Band-pass filtering plus under-sampling can also be used for downsampling a tuned spectrum slice. But, more commonly, heterodyning down to complex or IQ baseband before low-pass filtering seems to be a more efficient and commonly implemented algorithm.

Re: Direct sampling to bandwidth output, how done?

Posted: Tue Sep 01, 2020 10:10 pm
by qrp
hotpaw2 wrote:
Mon Aug 03, 2020 3:44 pm
Anti-alias filtering can be implemented in software or hardware by many different methods
Anti-alias filtering can be done in hardware only for analog signal (before ADC). This is impossible in software (in digital domain after ADC output). The only way is to apply anti-alias filter to the analog signal before ADC input.

For example you can use low-pass filter before ADC. If you don't apply anti-alias filter, you will get aliasing on the ADC output for frequency components above Fs/2 and you cannot remove it in digital domain, because there is no way to distinguish aliased components from real components.


RTLSDR ADC running at 28.8 MHz, so the ADC output bandwidth is 14.4 MHz. So, there is needs LPF with about 14 MHz cut-off. But RTLSDRv3 uses LPF for 30 MHz or something like that, so you can listen stations above 14 MHz through aliases. If you want to eliminate aliasing effect there is needs to add external LPF or BPF filter on the RTLSDR dongle input for specific frequency band. Just make sure that your filter pass band doesn't intersects with 14.4 MHz boundary.

Re: Direct sampling to bandwidth output, how done?

Posted: Thu Sep 10, 2020 9:54 pm
by hotpaw2
qrp wrote:
Tue Sep 01, 2020 10:10 pm
Anti-alias filtering can be done in hardware only for analog signal (before ADC). This is impossible in software (in digital domain after ADC output). The only way is to apply anti-alias filter to the analog signal before ADC input.
If you decimate in software, and the sampled signal has a bandwidth higher than the new target sample rate, then it is required to do anti-alias filtering in software. Thus software filtering has to be possible (DSP IIR or FIR typically).

Whether anti-aliasing filtering is required in hardware before sampling depends on the bandwidth of the analog signal. A narrowband signal from a signal generator may not need it. But, yes, typical RF signals require filtering before sampling.