Hello all, I'm relatively new to world of USRP, and having some problems with configuring two USRP N210 devices to receive simultaneously. I am just trying to do a proof of concept type of experiment.
In my setup one of the N210.s is equipped with a WBX daughterboard and the other with a TVRX2 daughterboard, as my frequency of interest lies within the FM-radio region. The devices are connected to each other via a MIMO cable. One port on each device is connected to an antenna (Port RX2 on the master device equipped with the WBX and port RX1 on the slave device equipped with the TVRX2). So far I think I have gotten my setup to run smoothly, except for when I am receiving a signal only one of the two ports in which I have my antennas connected is showing a signal. I'm using the UHD C++ API to configure the system. I think my problem lies within my inability set the channel configuration settings correctly. The configuration settings are displayed in the code below. Another possible reason for this situation could be that there is some problem with how I have setup the buffering. The code: int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string ant_ch0("RX2"); std::string ant_ch1("RX1"); std::string ref("mimo"); std::string time("mimo"); //Master device address std::string master_args("192.168.10.2"); // Slave device address std::string slave_args("192.168.10.3"); // sub_dev parameters for channel mapping std::string subdev0("A:0"); std::string subdev1("A:RX1"); // Numbers taken by using command uhd_find_devices in terminal //int master_index = 1; //int slave_index = 0; // Common variables double freq(105e6); double gain(10); double bw(1.7e6); double rate2(1e7); // for data transmission rate from USRP to host // Channel numbers size_t ch1 = size_t(~0); size_t ch0 = size_t(~0); ch1 = 1; ch0 = 0; // Motherboard indices for setting sources const size_t mb1 = 1; const size_t mb0 = 0; // --------------------------- CONFIGURATION --------------------------- // Addressing and defining the usrp devices uhd::device_addr_t addresses("addr0=192.168.10.2, addr1=192.168.10.3"); uhd::usrp::multi_usrp::sptr usrp =uhd::usrp::multi_usrp::make(addresses); // Setup Subdevice specification: // The subdev spec maps a physical part of the daughter board to a channel number // Here we create two channels on two separate mboards on two separate usrp devices usrp->set_rx_subdev_spec(subdev0,ch0); usrp->set_rx_subdev_spec(subdev1,ch1); // Set rx rate (rate at which the data is //transferred between the host and the device) usrp->set_rx_rate(rate2); // sets across all channels // Throw error if exactly two mother boards aren't connected UHD_ASSERT_THROW(usrp->get_num_mboards() == 2); // configuring the slave over mimo cable // make m_board 1 slave over mimo cable usrp->set_clock_source(ref, mb1); usrp->set_time_source(ref, mb1); // Set time on master mboard \should have master mboard number usrp->set_time_now(uhd::time_spec_t(0,0),mb0); //Set master clock rate (this affects the digitization speed) //usrp->set_master_clock_rate(rate, ch1); //usrp->set_master_clock_rate(rate, ch2); // Sleep a while so time can be properly locked boost::this_thread::sleep(boost::posix_time::milliseconds(100)); // Set Gain usrp->set_rx_gain(gain,ch1); usrp->set_rx_gain(gain,ch0); // Set center frequncy uhd::tune_request_t tune_request(freq); usrp->set_rx_freq(tune_request,ch1); usrp->set_rx_freq(tune_request,ch0); // Set Bandwidth usrp->set_rx_bandwidth(bw,ch1); usrp->set_rx_bandwidth(bw,ch0); // Set antenna to recieve only usrp->set_rx_antenna(ant_ch1,ch1); usrp->set_rx_antenna(ant_ch0,ch0); //-------------- GET AND WRITE DATA STREAM TO FILE ---------------- // SETUP STREAMING PARAMETERS uhd::stream_args_t stream_args("fc32","sc16"); // channels to use int c1 =0; int c2 =1; std::vector<int> channel_nums(2); channel_nums[1] = c1; channel_nums[2] = c2; uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args); double seconds_in_future = 1.5; double total_num_samps = 10000; // the first call to recieve will later on block this many seconds before recieving double timeout = seconds_in_future +0.1; size_t num_acc_samps = 0; //number of accumulated samples 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); //std::cout << "H2" << std::endl; // CREATE BUFFERS uhd::rx_metadata_t md; // will be filled automatically when data is recieved const size_t samps_per_buff = rx_stream->get_max_num_samps(); // 2D buffer vector std::vector<std::vector<std::complex<float> > > buffs( usrp->get_rx_num_channels(), std::vector<std::complex<float> > (samps_per_buff)); // 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()); ///////////////////// CREATION OF FILES TO STREAM IN /////////////////////////// // The file names std::string file1 = "ch1_d.dat"; std::string file2 = "ch2_d.dat"; // Open actual files std::ofstream outfile1; outfile1.open(file1.c_str(), std::ofstream::binary); std::ofstream outfile2; outfile2.open(file2.c_str(), std::ofstream::binary); //////////////////////////////////////////////////////////////////////////////// // THE ACTUAL RECIEVE STREAMING AND WRITING IS DONE HERE while(num_acc_samps < total_num_samps){ // RECIEVING A SINGLE PACKET size_t num_rx_samps = rx_stream->recv(buff_ptrs, samps_per_buff, md, timeout); // use small timeout for subsequent packets timeout=0.1; // ERROR HANDLING if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT){ std::cout << boost::format("Timeout while streaming") << std::endl; break; } if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){ throw std::runtime_error(str(boost::format("Reciever Error %s") %md.strerror())); } 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; // WRITING TO FILE 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; } if (num_acc_samps<total_num_samps) std::cerr << "Recieve timeout before" << "all samples received..." << std::endl; // close files if(outfile1.is_open()) outfile1.close(); if(outfile2.is_open()) outfile2.close(); //finished std::cout<<std::endl << "Done!" <<std::endl<<std::endl; return EXIT_SUCCESS; } To clarify, when I plot the received signals one of the channels shows a smooth FM-signal, while the other plot shows horizontal line with an amplitude of zero. Most of the code has been created using the USRP examples, with a few tweaks here and there. The command usrp->get_pp_string(), returns the following configuration summary: Using Devices: Multi USRP: Device: USRP2 / N-Series Device Mboard 0: N210r4 Mboard 1: N210r4 RX Channel: 0 RX DSP: 0 RX Dboard: A RX Subdev: WBXv3 RX+GDB RX Channel: 1 RX DSP: 0 RX Dboard: A RX Subdev: TVRX2 TX Channel: 0 TX DSP: 0 TX Dboard: A TX Subdev: WBXv3 TX+GDB TX Channel: 1 TX DSP: 0 TX Dboard: A TX Subdev: Unknown (0xffff) - 0 0x6325a8 The code compiles, and can also be run without any errors. Any help concerning the issue would greatly appreciated as I am also running on a tight schedule. Thanks already in advance -Julian
_______________________________________________ USRP-users mailing list USRP-users@lists.ettus.com http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com