Post Go back to editing

unable to decode ofdm data after calling iio_buffer_refill.

Category: Software
Product Number: Pluto SDR
Software Version: v0.32
OFDM system works when I directly pass the symbols generated by ofdm_tx() --> do_ofdm_rx(),
but it fails when transmitting over the air using pluto_transmit() and receiving with pluto_receive()
all_flow do_ofdm_tx()-->pluto_transmit() ----> pluto_receive()-->do_ofdm_rx()
pluto_receive() is successfully receiving samples but do_ofdm_rx() fails to process them correctly
unable to decode ofdm data after calling iio_buffer_refill.
call_flow do_ofdm_tx()-->pluto_transmit() ----> pluto_receive()-->do_ofdm_rx()

While debugging i tested
do_ofdm_tx() --> do_ofdm_rx() this works.
I have seperated the tx and rx threads

here is my pluto_transmit()

===============================================
 
int pluto_transmit(float complex *buffer, int len, int do_dump_rx, int is_last) {
int llen = len;

if (more_tx_data == 0) {
tx_p_dat = (char *)iio_buffer_first(txbuf, tx0_i);
tx_p_end = (char *)iio_buffer_end(txbuf);
more_tx_data = 1;
}

for (int ii = 0; ii < llen; ii++) {
float complex x = buffer[ii];

// Directly write the input symbols to the transmit buffer
((int16_t *)tx_p_dat)[0] = ((const int16_t)(creal(x) * 8192.0)); // scale to work well for OFDM waveforms
((int16_t *)tx_p_dat)[1] = ((const int16_t)(cimag(x) * 8192.0));

tx_p_dat += tx_p_inc;

//if (tx_p_dat == tx_p_end) {
if(ii == (llen -1)){
iio_buffer_push(txbuf);
tx_p_dat = (char *)iio_buffer_first(txbuf, tx0_i);
tx_p_end = (char *)iio_buffer_end(txbuf);
more_tx_data = 0;
break;
}
}

if (is_last) {
// zero pad the last symbol
if (more_tx_data == 0) {
while (tx_p_dat != tx_p_end) {
((int16_t *)tx_p_dat)[0] = 0;
((int16_t *)tx_p_dat)[1] = 0;
tx_p_dat += tx_p_inc;
}
}

more_tx_data = 0;
iio_buffer_push(txbuf); // send out the last symbol to the DMA
}

=============================================
int pluto_receive() {

int16_t i ,q;

//if(p_dat == p_end || !more_data) {
if(more_data == 0){
n_rx = iio_buffer_refill(rxbuf)/4;
p_dat = iio_buffer_first(rxbuf,rx0_i);
p_end = iio_buffer_end(rxbuf);
more_data=1;
}
for(int ii=0 ; ii <n_rx; ii++)
{
i = ((const int16_t*)p_dat)[0];
q = ((const int16_t*)p_dat)[1];

IF = ((float) i)/32768.0f;
QF = ((float) q)/32768.0f;
//sample = (float complex) (IF + _Complex_I * QF);
rx_sample_buf[ii] = (float complex) (IF + _Complex_I * QF);

}
more_data=0;
do_ofdm_rx(n_rx);

}
=============================================================
BW = 3200,000 HZ
OFDM = 128
SUB CARRIER = 3200,000/128 = 25,000 HZ
SAMPLING RATE = 25,000 SYM/S.
symbol duration = 1/25000 = 40us
CP = 12.5% of symbol duration = 5us.
OFDM SYMBOL TIME = 45us
144 OFDM SYMBOLS SPREAD ACROSS 128 SUB-CARRIER IN 45us.
OFDM SYMBOL DURATION(INCLUDING CP) = 45us
OFDM symbol generation rate = 22,222 OFDM syms/sec.
symbol rate = 22,222 X 144 = 3199968 = 3.2Msps
=============================================================


made the comments more descriptive
[edited by: abpreen14 at 2:00 PM (GMT -5) on 19 Nov 2023]