On 07/09/2019 06:20 AM, pablo.mdiaz via USRP-users wrote:
Hi all,

We have a X310 SDR and we are obtaining IQ samples from 4 channels. To do that we created 4 buffers to store them and for debug purposes write them in a file.

The problem we have is that at the beginning of the buffers they appear to be empty (full of zeros), the attached file contains a memory dump of all the buffers.

The following code is the initialization of the SDR, maybe we are forgetting to initialize some parameters.

    std::string device_args = "RIO0";
    std::string subdev = "A:0 A:1 B:0 B:1";
    std::string clock_source = "internal";

    usrp = uhd::usrp::multi_usrp::make(device_args);
    usrp->set_clock_source(clock_source);
    usrp->set_rx_subdev_spec(subdev);

    uhd::tune_request_t tune_request(freq);

    for (int i = 0; i < CHANNELS; i++) {
        usrp->set_rx_rate(rate,i);
        usrp->set_rx_freq(tune_request,i);
        usrp->set_rx_gain(gain,i);
        usrp->set_rx_bandwidth(bw,i);
    }

    uhd::stream_args_t stream_args("fc32", "sc16");
    stream_args.channels = {0, 1, 2, 3};
    stream_args.args["spp"] = "512";
    rx_stream = usrp->get_rx_stream(stream_args);
    const int spp = rx_stream->get_max_num_samps();

std::vector<std::vector<std::complex<float>>> buffs (
        num_channels,
        std::vector<std::complex<float>> (spp)
    );

    for(int i = 0; i< buffs.size(); i++)
        buffPtrs.push_back(buffs[i].data());

uhd::stream_cmd_t stream_cmd = uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS;
    stream_cmd.stream_now = false;


//We suspect this block is causing the odd behavior
{
    stream_cmd.time_spec = uhd::time_spec_t (1.9);
    rx_stream->issue_stream_cmd(stream_cmd);
    std::this_thread::sleep_for(std::chrono::milliseconds(2000));
}

Then this function is called multiple times to gather the IQ samples

    read = rx_stream->recv(buffPtrs, 512, rx_metadata, 2);

Hope you can help us, thanks beforehand.

Pablo (Universidad Politécnica de Madrid)

There will always be some amount of "rubbish" in the start of the sample stream, because the DDC filters are filled with *something* prior to
  samples percolating through them.

Also, you're starting streaming at some time in the future, but you're assuming that the X310 system clock starts at zero when you initiate a session with it. It does not. The X310 system clock starts at zero on *power up*, and will continue counting up from there until it is
  reset with a set_time_now() or set_time_next_pps() command.

There is no reason to wait 2 seconds after sending the issue_stream_cmd().



_______________________________________________
USRP-users mailing list
USRP-users@lists.ettus.com
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

Reply via email to