Nuand / bladeRF

bladeRF USB 3.0 Superspeed Software Defined Radio Source Code
http://nuand.com
Other
1.15k stars 459 forks source link

Sample Rate is Halved When Using BLADERF_FEATURE_OVERSAMPLE #940

Open cwozny opened 1 year ago

cwozny commented 1 year ago

When using the new oversample feature, the sample rate seems to be effectively half of what gets set in bladerf_set_sample_rate(). This was tested by using a signal generator and feeding in a pulsed waveform with a 48 us duration. With oversample feature enabled, 8-bit resolution, and 50 Msps sampling rate, the pulse duration was incorrectly being measured as ~24 us. With default feature enabled, 8-bit resolution, and 50 Msps sample rate, the pulse duration was correctly being measured as ~48 us.

This was tested minutes apart and the only code delta was in this commit: https://github.com/cwozny/sdr_channelizer/commit/a36a758cb4c5a370b7851fd3c206c6b1297c71b8

I also tried to enable oversampling after setting the sampling rate due to an issue that @rthomp10 fixed with commit 86d68ee, but this didn't correct the sampling rate either.

Plots included for reference, note the time per division showing the pulse duration being halved when using oversampling.

default oversample

Board: Nuand bladeRF 2.0 (bladerf2) Serial #: xxxxxxxxxxxxxxxxxxxxxxxxxxxxx VCTCXO DAC calibration: 0x230b FPGA size: 77 KLE FPGA loaded: yes Flash size: 64 Mbit USB bus: 0 USB address: 1 USB speed: SuperSpeed Backend: libusb Instance: 0

bladeRF-cli version: 1.9.0-git-41ef6346 libbladeRF version: 2.5.0-git-41ef6346

Firmware version: 2.4.0-git-a3d5c55f FPGA version: 0.15.0

alex-appetiti commented 1 week ago

I've also come across the same issue, and was wondering whether or not the Nuand team had any updates.

My setup:

The curiosity aside, just by profiling the time it takes to get 50,000,000 samples, in the 16-bit version I get them in 2.5s, whereas in the 8-bit version I get them in 5s, suggesting that the sample rate is actually 10MHz.

alex-appetiti commented 1 week ago

As an update - I've now tried to set the sample_rate via the bladerf_set_rational_sample_rate function instead of the bladerf_set_sample_rate function, and the timings now match, although I do get the following warning Unhandled case in ad9361_tx_quad_calib line 3023 clkrf 10000000 clktf 20000000.

I'm a bit confused as looking at the source it seems that bladerf_set_rational_sample_rate is just converting to an integer then calling bladerf_set_sample_rate anyway.