pothosware / SoapyPlutoSDR

Soapy SDR plugin for PlutoSDR
https://github.com/pothosware/SoapyPlutoSDR/wiki
GNU Lesser General Public License v2.1
53 stars 22 forks source link

Fix TX needs 12 bit samples MSB aligned #9

Closed zuckschwerdt closed 5 years ago

zuckschwerdt commented 5 years ago

received RX samples are LSB aligned (i.e. the lower 12 bits of the int16_t), transfered TX samples however need to be MSB aligned (i.e. the upper 12 bits of the int16_t). S.a. https://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz/software/basic_iq_datafiles#binary_format This fix shifts the TX buffer 4 bits up, removing the current -24 dB attenuation.

guruofquality commented 5 years ago

If the fixed point 16-bit numbers are now +/-(1 << 15), make sure to change nativeStreamFormat(): https://github.com/pothosware/SoapyPlutoSDR/blob/master/PlutoSDR_Streaming.cpp#L28 This may be used by SoapyRemote for scaling, for example.

zuckschwerdt commented 5 years ago

Good idea. Setting fullScale=32768 would eliminate the need for <<4 on the buffer. Is it acceptable to have a RX fullScale of 2048 but a TX fullScale of 32768? Setting/requiring 32768 on TX would also conceal the hint that this is 12 bits.

With the current PR the fact that the 12 bits need to be MSB aligned would be transparently hidden, but probaly at the cost of an applications scaling it's Q0.15 or floats down and then the driver scaling it up again.

guruofquality commented 5 years ago

Is it acceptable to have a RX fullScale of 2048 but a TX fullScale of 32768?

Yes, they can be different. As long as the numbers are accurate.

zuckschwerdt commented 5 years ago

Native format now has proper fullScale, CU8, and CF32 are scaled appropriately.