Transmiting MO in sync mode causes samples gap in between the signal

Discussions related to embedded firmware, driver, and user mode application software development
Post Reply
gjgonzalez
Posts: 2
Joined: Wed Sep 13, 2023 8:35 am

Transmiting MO in sync mode causes samples gap in between the signal

Post by gjgonzalez »

I am trying to transmit a FM chirp simultanously using both channels (Tx0 and Tx1) working in synchronous mode for a Radar app.
Using a single channel (SO) works as expected, see picture:
https://photos.app.goo.gl/DdeKJgD4ZFBZuzY79

but when i using both channels, the output signal is twice as long and has gaps whitout samples in between, see picture :
https://photos.app.goo.gl/8pZG9fJ8CHmY9J926

I have tried to reduce the Sample rate from 20Msps to 10Msps and 5Msps with the same (unsucesfull) result

I'm using the below Tx code

Code: Select all

	int status;
        int16_t zero_sample[8] = { 0 }; 

        struct bladerf_metadata tx_meta;

        memset(&tx_meta, 0, sizeof(tx_meta));
   
        tx_meta.flags = BLADERF_META_FLAG_TX_BURST_START;
        tx_meta.timestamp = start_time;
         
        while (!d_finished) {
            if (d_armed) {
                // Record when the new waveform actually started in the metadata
                d_meta =
                    pmt::dict_add(d_meta, d_sample_start_key, pmt::from_long(d_tx_sample_count));
                d_armed = false;	
            }
            status = bladerf_sync_tx(d_dev, d_tx_buff.data(), d_tx_buff.size()/2, &tx_meta, TIMEOUT_MS);

            if (status != 0){ 
                GR_LOG_ERROR(d_logger,  boost::format("TX failed: %s, at pulse: %lu\n") % bladerf_strerror(status) % d_pulse_count);
	            break;
	    }
            d_pulse_count++;
            d_tx_sample_count += d_tx_buff.size();
            tx_meta.flags &= ~BLADERF_META_FLAG_TX_BURST_START;   

        }
        // Send a mini EOB packet
        tx_meta.flags |= BLADERF_META_FLAG_TX_BURST_END;

        status = bladerf_sync_tx(d_dev, zero_sample, 1, &tx_meta, TIMEOUT_MS);
        if (status != 0) {
            GR_LOG_ERROR(d_logger, boost::format("TX failed: %s\n") % bladerf_strerror(status));
        }
 



Modifing this code as follows solves the problem, but there are small drifts (a few samples delay) from chirp to chirp, witch is not an option for a Radar app.:

Code: Select all

	int status;
        int16_t zero_sample[8] = { 0 }; 

        struct bladerf_metadata tx_meta;

        memset(&tx_meta, 0, sizeof(tx_meta));
   
        tx_meta.flags = BLADERF_META_FLAG_TX_BURST_START | BLADERF_META_FLAG_TX_BURST_END;
        tx_meta.timestamp = start_time;
         
        while (!d_finished) {
            if (d_armed) {
                // Record when the new waveform actually started in the metadata
                d_meta =
                    pmt::dict_add(d_meta, d_sample_start_key, pmt::from_long(d_tx_sample_count));
                d_armed = false;	
            }
            status = bladerf_sync_tx(d_dev, d_tx_buff.data(), d_tx_buff.size()/2, &tx_meta, TIMEOUT_MS);

            if (status != 0){ 
                GR_LOG_ERROR(d_logger,  boost::format("TX failed: %s, at pulse: %lu\n") % bladerf_strerror(status) % d_pulse_count);
	            break;
	    }
            d_pulse_count++;
            d_tx_sample_count += d_tx_buff.size();
            tx_meta.flags |= BLADERF_META_FLAG_TX_NOW;   

        }
        // Send a mini EOB packet
        status = bladerf_sync_tx(d_dev, zero_sample, 1, &tx_meta, TIMEOUT_MS);
        if (status != 0) {
            GR_LOG_ERROR(d_logger, boost::format("TX failed: %s\n") % bladerf_strerror(status));
        }
 


Any ideas/help in order to use MO with sync interface (without samples drift, of course) will be appreciated
Regards
gjgonzalez
Posts: 2
Joined: Wed Sep 13, 2023 8:35 am

Re: Transmiting MO in sync mode causes samples gap in between the signal

Post by gjgonzalez »

I found the problem in a libbladeRF bug, see:

https://github.com/Nuand/bladeRF/issues/942
Post Reply