Hello everyone,

I am experencing some issues when switching the sample rate.
I have two synchronized USRP X310 with a total of 4 TwinRX. I am doing timed commands to jump around in the spectrum with all receivers at the same frequency (SIMO stuff). I also need to switch sample rates in between. When I keep the sample rate constant, everything works fine, but once I switch it between two timed receptions, I get very strange errors. Like I get an end-of-frame after just a part of the samples I requested. It seems like it is not possible to time the sample rate switch command. Here is a debug output of my code which makes it quite clear what happens:

(1) Changed sample rate from 1e+07 to 5e+07
(2) Requested 32768 Samples
(3) Requested 32768 Samples
(4) Requested 32768 Samples
(5) Changed sample rate from 5e+07 to 1e+07
(6) Reading 32768 Samples
(7) Got only 6553 of 32768 samples at EOF

Commands 1-5 are transmitted to the USRP right away using its command buffer. Then my program starts reading the first requested 32768 but gets only 6553, which is precisely 1/5th of the requested samples. I guess this is because he switched sample rate to 1/5th right before executing the first stream command. But the sample rate switch is also timed and should be executed after the three stream commands.

I attached the part of the code which is responsible for sending the timed commands to the USRPs. This runs basically in a while(1) in a seperate thread, while there is a seconds thread receiving the data blocks, which produced the lines 6-7 of above output.

Is this a bug or feature I don't get? Are set_rx_rate commands not timed when using set_command_time? How can I solve this isse? I need very precise timing and also fast switching between frequencies and sample rates.

Best regards,
Fabian
    double freq;
    if(!getNextCmdFrequency(freq))
    {
        firstTime = true;
        return;
    }
    //qDebug()<<"Generating recv 
for"<<currentCmdBlockListID<<"/"<<currentCmdSlotListID;

    // Check if this is the first command and reset current round time for 
minimum time contraint
    if(currentCmdBlockListID == 0 && currentCmdSlotListID == 0 && 
currentRoundTime < minimumRoundTime)
    {
        stream_cmd.time_spec += uhd::time_spec_t(minimumRoundTime - 
currentRoundTime);
        currentRoundTime = uhd::time_spec_t(0.0);
    }
    usrpDevice->set_command_time(stream_cmd.time_spec);
    if(currentSampleRate != receiveBlockList[currentCmdBlockListID]->sampleRate)
    {
        double oldSampleRate = currentSampleRate;
        currentSampleRate = receiveBlockList[currentCmdBlockListID]->sampleRate;
        deviceConfig.sampleRate = currentSampleRate;
        usrpDevice->set_rx_rate(currentSampleRate);
        double newSampleRate = usrpDevice->get_rx_rate();
        qDebug()<<"Changed sample rate 
from"<<oldSampleRate<<"to"<<newSampleRate;
    }
    setFrequency(freq);
    usrpDevice->clear_command_time();

    // Stream command
    stream_cmd.time_spec += receive_start_offset_ts;   // delay by start offset 
for the LO to lock
    stream_cmd.num_samps = 
receiveBlockList[currentCmdBlockListID]->samplesPerSlot;

    ReceiveCmdTime receivecmdTime;
    receivecmdTime.blockId = currentCmdBlockListID;
    receivecmdTime.slotId = currentCmdSlotListID;
    receivecmdTime.time = stream_cmd.time_spec.get_real_secs();
    commandTimeMutex.lock();
    commandTimeList.append(receivecmdTime);
    commandTimeMutex.unlock();
    rxStream->issue_stream_cmd(stream_cmd);

    // Calcluate time for next slot
    stream_cmd.time_spec += 
receiveBlockList[currentCmdBlockListID]->receiveTime + receive_stop_offset_ts;
    currentRoundTime += receive_start_offset_ts + 
receiveBlockList[currentCmdBlockListID]->receiveTime + receive_stop_offset_ts;
_______________________________________________
USRP-users mailing list
USRP-users@lists.ettus.com
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

Reply via email to