On 08/25/2020 04:00 PM, Jay Labhart via USRP-users wrote:
Hello,

I have started to work with the B210 on a project. My interest is to collect samples from the 2 RX of the B210 looking at a frequency of channel 1 of 2.4GHz (2412). My goal is to use a grc to workout the algorithm then move to c++. I am having some challenges that I would like to ask the group for help.

I used a .grc to collect samples and review the algorithm. The graph is attached. At this point I am just collecting data. I use a series of variables to create 2 data files.

I moved to c++ and modified a sample to collect the same dataset.

I am using the python file gr_plot_iq.py to review the signals. When I review the grc graph the signals appear as I would think. The c++ the signals are scattered way apart and A&B are consistent.

Any thoughts would be greatful.

Test:
    2.4 GHz router chirping every 100 ms
        local area with no wireless except router
uhd
        2412000000 channel 1
        rate - 20 MSPS (only get 15)
        looking at 2 RX channels at same freq

hardware & os
Intel® Core™ i5-6400 CPU @ 2.70GHz × 4
12GB RAM
Ubuntu 18.04.5 LTS

attached is the probe from the uhd

The challenge is that I am seeing different results from the grc and the c++ file. On the grc graph I collect a variety of samples from the router. On the c++ file there only seems to be 1-2 samples. I would expect to see a similar set of samples.

Inline image


*c++ code excerpt*

    // detect which channels to use
    std::vector<std::string> channel_strings;
    std::vector<size_t> channel_nums;
    boost::split(channel_strings, channel_list, boost::is_any_of("\"',"));
    for (size_t ch = 0; ch < channel_strings.size(); ch++) {
        size_t chan = std::stoi(channel_strings[ch]);
        if (chan >= usrp->get_rx_num_channels()) {
            throw std::runtime_error("Invalid channel(s) specified.");
        } else
channel_nums.push_back(std::stoi(channel_strings[ch]));
    }

    // create a receive streamer
    // linearly map channels (index0 = channel0, index1 = channel1, ...)
    uhd::stream_args_t stream_args("fc32"); // complex floats
    stream_args.channels             = channel_nums;
    uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);

      if (total_num_samps == 0){
       std::signal(SIGINT, &sig_int_handler);
       std::cout << "Press Ctrl + C to stop streaming..." << std::endl;
       }

    // setup streaming
    std::cout << std::endl;
std::cout << boost::format("Begin streaming %u samples, %f seconds in the future...")
                     % total_num_samps % seconds_in_future
              << std::endl;
uhd::stream_cmd_t stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
    stream_cmd.num_samps  = total_num_samps;
    stream_cmd.stream_now = false;
    stream_cmd.time_spec  = uhd::time_spec_t(seconds_in_future);
rx_stream->issue_stream_cmd(stream_cmd); // tells all channels to stream

    // meta-data will be filled in by recv()
    uhd::rx_metadata_t md;

    // allocate buffers to receive with samples (one buffer per channel)
    const size_t samps_per_buff = rx_stream->get_max_num_samps();
std::vector<std::vector<std::complex<float>>> buffs(
usrp->get_rx_num_channels(), std::vector<std::complex<float>>(samps_per_buff));

    // create a vector of pointers to point to each of the channel buffers
    std::vector<std::complex<float>*> buff_ptrs;
    for (size_t i = 0; i < buffs.size(); i++)
        buff_ptrs.push_back(&buffs[i].front());

// the first call to recv() will block this many seconds before receiving double timeout = seconds_in_future + 0.1; // timeout (delay before receive + padding)

    size_t num_acc_samps = 0; // number of accumulated samples
    std::ofstream outfile1, outfile2;
    outfile1.open(file1.c_str(), std::ofstream::binary);
    outfile2.open(file2.c_str(), std::ofstream::binary);

    while (not stop_signal_called) {
        // receive a single packet
size_t num_rx_samps = rx_stream->recv(buff_ptrs, samps_per_buff, md, timeout);

        // use a small timeout for subsequent packets
        timeout = 0.1;

        // handle the error code
        if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT)
            break;
        if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE) {
//throw std::runtime_error(str(boost::format("Receiver error %s") % md.strerror()));
            std::cout << md.strerror() << std::endl;
        }

        if (verbose)
            std::cout << boost::format(
"Received packet: %u samples, %u full secs, %f frac secs")
                             % num_rx_samps % md.time_spec.get_full_secs()
                             % md.time_spec.get_frac_secs()
                      << std::endl;

      if (outfile1.is_open())
       outfile1.write((const char*)(&buffs[0].front()),
      num_rx_samps*sizeof(std::complex<float>));
      if (outfile2.is_open())
       outfile2.write((const char*)(&buffs[1].front()),
      num_rx_samps*sizeof(std::complex<float>));

        num_acc_samps += num_rx_samps;
        // check if continuous or number of samples
        if (total_num_samps != 0) {
            if (num_acc_samps >= total_num_samps)
                stop_signal_called = true;
        }
    }

*output from run with uhd*

Creating the usrp device with: ...
[INFO] [UHD] linux; GNU C++ version 7.5.0; Boost_106501; UHD_3.14.1.HEAD-0-g0347a6d8
[INFO] [B200] Detected Device: B210
[INFO] [B200] Operating over USB 3.
[INFO] [B200] Initialize CODEC control...
[INFO] [B200] Initialize Radio control...
[INFO] [B200] Performing register loopback test...
[INFO] [B200] Register loopback test passed
[INFO] [B200] Performing register loopback test...
[INFO] [B200] Register loopback test passed
[INFO] [B200] Setting master clock rate selection to 'automatic'.
[INFO] [B200] Asking for clock rate 16.000000 MHz...
[INFO] [B200] Actually got clock rate 16.000000 MHz.
Using Device: Single USRP:
  Device: B-Series Device
  Mboard 0: B210
  RX Channel: 0
    RX DSP: 0
    RX Dboard: A
    RX Subdev: FE-RX2
  RX Channel: 1
    RX DSP: 1
    RX Dboard: A
    RX Subdev: FE-RX1
  TX Channel: 0
    TX DSP: 0
    TX Dboard: A
    TX Subdev: FE-TX2
  TX Channel: 1
    TX DSP: 1
    TX Dboard: A
    TX Subdev: FE-TX1

Using Antenna 0: RX2
Using Antenna 1: RX2
Actual RX Freq: 2412.000000 MHz...
Actual RX Freq: 2411.999998 MHz...

RX Gain Range 0: (0, 76, 1)
...
Setting RX Gain: 64.000000 dB...
Actual RX Gain: 64.000000 dB...

Setting RX Bandwidth: 15.000000 MHz...
Actual RX Bandwidth: 15.000000 MHz...

Setting RX Rate: 15.000000 Msps...
[INFO] [B200] Asking for clock rate 60.000000 MHz...
[INFO] [B200] Actually got clock rate 60.000000 MHz.
Actual RX Rate: 15.000000 Msps...

Setting device timestamp to 0...

Begin streaming 10000 samples, 10.000000 seconds in the future...
Received packet: 2040 samples, 10 full secs, 0.000003 frac secs
Received packet: 2040 samples, 10 full secs, 0.000139 frac secs
Received packet: 2040 samples, 10 full secs, 0.000275 frac secs
Received packet: 2040 samples, 10 full secs, 0.000411 frac secs
Received packet: 1840 samples, 10 full secs, 0.000547 frac secs

Done!





_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
For one, you're using a 2Msps rate in your .grc flow-graph.


_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

Reply via email to