1
$\begingroup$

I am using HackRF or Pluto SDR for transmission of a CW signal, after reading the documentation of the HackRF one SDR I found out that it transmits data in only 8-bit signed quadrature samples. Now I want to convert the complex data to 8-bit signed data, which will be stored as a .bin file which then will be transmitted over the SDR. I can convert the data from complex128 to complex64 but when I use np.int8 the array that gets generated consists mostly of 0 and 1 and all other data is lost.

And I also dont have any idea on which type of data the pluto sdr transmits have tried gnu radio but failed to understand.

Thanks in advance to anyone who helps me. Below is the code that I am using to generate the I/Q samples ''' import numpy as np import matplotlib.pyplot as plt from scipy import signal np.set_printoptions(threshold=np.inf)

# Parameters
fs = 20e6 #sampling frequency
pulse_duration = 140e-6  # sec
no_samp = int(fs * pulse_duration)
bandwidth = 10e6
fc = 2.4e9  #This willbe set as local oscillator frequency and will be directly set in GNU 
radio while genertaion of the chirp 
     
# Create axis for transmitted chirp
time_axis = np.linspace(0, pulse_duration, no_samp)
f0 = - bandwidth / 2
f1 = + bandwidth / 2
c = 3e8  # Speed of light
alpha = bandwidth / pulse_duration

# Generation of transmitted signal
trans_chirp = np.exp(1j * 2 * np.pi * (f0 * time_axis + (alpha * time_axis ** 2) / 2))
data_type = trans_chirp.dtype
print(trans_chirp)
# Print the data type
print("Data Type:", data_type)

trans_chirp = trans_chirp.astype(np.int8)

# Plot the chirp in the same window
plt.figure()
plt.plot(time_axis, trans_chirp)
plt.xlabel('time (s)')
plt.ylabel('Amplitude')
plt.title(f'chirp for f0 = {f0/1e9}e9, f1= {f1/1e9}e9')
plt.grid(True)
plt.tight_layout()
plt.show()

data_type = trans_chirp.dtype

# Print the data type
print("Data Type:", data_type)


trans_chirp.tofile("C:/Users/Intern2/Desktop/trans_chirp.bin")

'''

$\endgroup$
1
  • $\begingroup$ Cast your data to real floats so that $x\in \mathbb{C}^N \rightarrow x \in \mathbb{R}^{2N}$. The real and imag parts will be interleaved. Scale the data such that its max absolute value is $2^7$. Now cast it to np.int8 and write to file. $\endgroup$ Commented Jan 26 at 18:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.