Convert Complex int8 to Complex int16 And TX

Having issues with the site, hardware, source code, or any other issues?
Post Reply
urist
Posts: 4
Joined: Fri Dec 29, 2023 3:21 pm

Convert Complex int8 to Complex int16 And TX

Post by urist »

Hi,

I have a project where I'm am provided a `complex<int8_t>` buffer of samples for a HackRF. All values in the buffer are either `0+j0` or `127+j127` (zero power or max power). I'm wanting to convert it to the bladerf SC16.Q11 format of little endian `complex<int16_t>` covered here: https://www.nuand.com/libbladeRF-doc/v2 ... m_a_t.html

I perform the simple complex int8 to complex int16 mapping of `0+j0` to `0+j0` and `127+j127` to `2048+j2048`, which are the equivalent zero and max power values and I write them as little endian. Here is an `xxd` hex visual for the complex int8 samples I'm given (HackRF format):

Code: Select all

...
00000300: 7f7f 0000 7f7f 0000 0000 0000 0000 7f7f  ................
00000310: 0000 7f7f 0000 0000 0000 0000 0000 0000  ................
...
You can see that they are either pairs of 0x7f7f or 0x0000. When I convert this block of samples to the SC16Q11 format using the mapping mentioned above, I get:

Code: Select all

00000600: ff07 ff07 0000 0000 ff07 ff07 0000 0000  ................
00000610: 0000 0000 0000 0000 0000 0000 ff07 ff07  ................
00000620: 0000 0000 ff07 ff07 0000 0000 0000 0000  ................
00000630: 0000 0000 0000 0000 0000 0000 0000 0000  ................
Which to me looks to be Little Endian Complex int16.

The HackRF complex int8 buffer I'm given is very very short (2048 samples @ 2MSPS). I want to TX on bladerf TX1, but I'm unsure which `tx config` options suit my requirements. Here is my `bladeRF-cli` command list:

Code: Select all

set samplerate tx1 2M
set bandwidth tx1 2M
set frequency tx1 900
set gain tx1 18
tx config file=/tmp/brf_out.sc16q11 format=bin repeat=1 delay=0 samples=1024 buffers=8 xfers=4 channel=1
tx start
tx wait
I am setting `samples=1024` to the smallest possible value, `buffers=8`, and `xfers=4`. This means that I need to pass it a file of size 1024 samples * 8 buffers = 8192 samples, correct? I have zero-padded my file out to 8192 samples. And is my tx config valid and correct?

As is, the emitted waveform isn't quite right. The original complex int8's TX'd via a HackRF are processed correctly by my receiver, but the converted samples TX'd via bladerf aren't processed correctly. So something must be incorrect with my conversion or transmission.

Thank you for any help!
ratir
Posts: 1
Joined: Fri Jul 19, 2024 3:10 am

Re: Convert Complex int8 to Complex int16 And TX

Post by ratir »

urist wrote: Tue Jul 02, 2024 8:14 pm Hi,

I have a project where I'm am provided a `complex<int8_t>` buffer of samples for a HackRF. All values in the buffer are either `0+j0` or `127+j127` (zero power or max power). I'm wanting to convert it to the bladerf SC16.Q11 format of little endian `complex<int16_t>` covered here: https://www.nuand.com/libbladeRF-doc/v2 ... _a_t.html/ slope 3

I perform the simple complex int8 to complex int16 mapping of `0+j0` to `0+j0` and `127+j127` to `2048+j2048`, which are the equivalent zero and max power values and I write them as little endian. Here is an `xxd` hex visual for the complex int8 samples I'm given (HackRF format):

Code: Select all

...
00000300: 7f7f 0000 7f7f 0000 0000 0000 0000 7f7f  ................
00000310: 0000 7f7f 0000 0000 0000 0000 0000 0000  ................
...
As is, the emitted waveform isn't quite right. The original complex int8's TX'd via a HackRF are processed correctly by my receiver, but the converted samples TX'd via bladerf aren't processed correctly. So something must be incorrect with my conversion or transmission.

Thank you for any help!
The new event may change tomorrow
dianshi
Posts: 6
Joined: Sat Jul 20, 2024 3:03 pm
Contact:

Re: Convert Complex int8 to Complex int16 And TX

Post by dianshi »

Did you use hexdump to check the hex value inside converted file?
maintainothers
Posts: 2
Joined: Mon Aug 05, 2024 12:27 am

Re: Convert Complex int8 to Complex int16 And TX

Post by maintainothers »

If the waveform isn’t correct,fireboy and watergirl recheck the conversion logic and ensure the sample values align with the SC16Q11 format. For detailed format reference, visit the Nuand SC16Q11 documentation.
Post Reply