[USRP-users] E312 low level access to control AD9361
Hi, all, I have a E312 device and I just find that the tuning speed of E312 is very slow (\~150ms) for each tuning. Thus I would like to modify the underlying tuning source code in the uhd software architecture. Here is what I found: I first create a multi_usrp object: uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(device_args); then I tune the usrp by running a loop: int count = 200;\ for(int a = 0; a < count; a++) {\ uhd::tune_request_t tune_request(600e6 + a\*10e6);\ \ usrp->set_rx_freq(tune_request, 0);\ usrp->set_tx_freq(tune_request, 0);\ } Basically, the loop tunes the frequency from 600MHz to 2.6 GHz with a step size of 10 MHz. The 200 tunings take 52 seconds, which is pretty slow. Thus, I traced the call stack from usrp->set_rx_freq(tune_request, 0). Here is what I found: 1. usrp->set_rx_freq(tune_request, 0); calls the method set_tx_frequency() in uhd/host/lib/usrp/dboard/e3xx/e3xx_radio_control_impl.cpp 2. then the method set_tx_frequency() in uhd/host/lib/usrp/dboard/e3xx/e3xx_radio_control_impl.cpp calls the tune() method in uhd/host/lib/usrp/dboard/e3xx/e3xx_ad9361_iface.cpp 3. then the tune() method in uhd/host/lib/usrp/dboard/e3xx/e3xx_ad9361_iface.cpp calls the method set_tx_frequency() in uhd/host/lib/rfnoc/radio_control_impl.cpp. The conclusion I have reached so far is the underlying tuning method is in uhd/host/lib/rfnoc/radio_control_impl.cpp: double radio_control_impl::set_tx_frequency(const double freq, const size_t chan)\ {\ std::lock_guard l(_cache_mutex);\ return _tx_freq\[chan\] = freq;\ } Then I just got stuck here, what is the _tx_freq\[chan\] ? I just can not find more. What I want to do is to modify the underlying ad9361 driver, so that when tuning a frequency, I can bypass the calibration in the ad9361 to speed up the tuning speed. Can anyone point me to 1.where I can find the source code for tuning for the E312 with uhd 4.0 or 2. how to use mpm to get low-level access to ad9361 so that I can write my own tuning method for ad9361 ? Thanks, Yan ___ USRP-users mailing list -- usrp-users@lists.ettus.com To unsubscribe send an email to usrp-users-le...@lists.ettus.com
[USRP-users] E312 ad9361 tuning() source code
Hi, all, I am having a USRP E312 and is working on implementing a stepped frequency radar application. The bandwidth of the radar is 1 GHz and the frequency step size is 10 MHz. My current implementation is similar to the example code “txrx_loopback_to_file.cpp” : a transmit thread sending a same baseband signal at the background; a loop handling the tuning center frequency and receiving data to a buffer. The following shows the code snippets. 1. the transmit thread: just sending a same baseband signal continuously void transmit_worker (std::vector> buff, \ uhd::tx_streamer::sptr tx_streamer, \ uhd::tx_metadata_t metadata, \ int num_channels) \ { std::vector\*> buffs(num_channels, &buff.front()); ``` // send data until the signal handler gets called while (not stop_signal_called) { // send the entire contents of the buffer tx_streamer->send(buffs, buff.size(), metadata); metadata.start_of_burst = false; metadata.has_time_spec = false; } // send a mini EOB packet metadata.end_of_burst = true; tx_streamer->send("", 0, metadata); ``` } 2. the loop handling the tuning and receiving: I use the usrp.get_time_now() function to timing the loop. Here is what I’ve found: The uhd ad9361 seems to run a calibration procedure when there is a frequency jump over 100 MHz. And each calibration takes about 2 seconds for my measurements. With my current setup (100 steps and 10 MHz frequency step size), the total time of the loop is 25.6 seconds. There are 9 calibrations in the loop which takes 18 seconds. My goal is to find the source code that implements AD9361’s tuning function in the UHD source code so that I can comment out the calibration part to speed up the frequency tuning. The following source code files are related to AD9361 tuning: * the set_tx_frequency() implemented in `uhd/host/lib/usrp/dboard/e3xx/e3xx_radio_control_impl.cpp` * the tune method in line 227 in the above figure calls the tune() function in: `uhd/host/lib/usrp/dboard/e3xx/e3xx_ad9361_iface.cpp` **Notice that the original source code is “catalina_tune” and I changed it to “tune” because my experiments showed “tune” is much faster than “catalina_tune”.** * Finally, I find the tune() function above seems to call the tune() function in: `uhd/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp` I find in line 85 AD9361_CAL_VALID_WINDOW is defaulted to 100 MHz and I change the 100 MHz to 1 GHz. But nothing seems to change, the device still do a calibration every 100 MHz. I also comment out the calibration code in `uhd/host/lib/usrp/common/ad9361_driver/ad9361_device.cppb`, but still nothing seems to be changed. The device is still doing calibration every 100 MHz. **Anyone knows where the source code for tuning ad9361 with E312 device is ? I wish I can locate the tuning source code so that I can change it to speed up frequency tuning.** In my application, if I can turn off the calibration that happens every 100MHz, then the total tuning time is only 8 seconds, which is just what I need. But I can not locate the true tuning source code. Thanks, Yan ___ USRP-users mailing list -- usrp-users@lists.ettus.com To unsubscribe send an email to usrp-users-le...@lists.ettus.com
[USRP-users] E312 ad9361 tuning() source code (new version)
Hi, all, I am having a USRP E312 and is working on implementing a stepped frequency radar application. The bandwidth of the radar is 1 GHz and the frequency step size is 10 MHz. My current implementation is similar to the example code “txrx_loopback_to_file.cpp” : a transmit thread sending a same baseband signal at the background; a loop handling the tuning center frequency and receiving data to a buffer. The following shows the code snippets. 1. the transmit thread function: just sending a same baseband signal continuously void transmit_worker(\ std::vector> buff, \ uhd::tx_streamer::sptr tx_streamer, \ uhd::tx_metadata_t metadata, \ int num_channels) {\ std::vector\*> buffs(num_channels, &buff.front()); // send data until the signal handler gets called \ while (not stop_signal_called) {\ // send the entire contents of the buffer tx_streamer->send(buffs, buff.size(), metadata); metadata.start_of_burst = false; metadata.has_time_spec = false; } // send a mini EOB packet metadata.\ end_of_burst = true; tx_streamer->send("", 0, metadata); } 1. the loop handling the tuning and receiving: // tuning and receiving \ int count = 100; // number of frequencies \ int freq_step = 10e6; // frequency step size \ double start = usrp->get_time_now().get_real_secs(); \ \ for(int i = 0; i < count; i++) {\ uhd::tune_request_t tune_request(600e6 + i\*freq_step);\ // tuning usrp->set_rx_freq(tune_request, 0); usrp->set_tx_freq(tune_request, 0); // receive samples stream_cmd.time_spec = usrp->get_time_now() + uhd::time_spec_t(0.01); rx_stream->issue_stream_cmd(stream_cmd); size_t num_rx_samps = rx_stream->recv(buff_ptrs\[i\], samps_per_buff, md); } I use the usrp.get_time_now() function to timing the loop. Here is what I’ve found: The uhd ad9361 seems to run a calibration procedure when there is a frequency jump over 100 MHz. And each calibration takes about 2 seconds for my measurements. With my current setup (100 steps and 10 MHz frequency step size), the total time of the loop is 25.6 seconds. There are 9 calibrations in the loop which takes 18 seconds. My goal is to find the source code that implements AD9361’s tuning function in the UHD source code so that I can comment out the calibration part to speed up the frequency tuning. The following source code files are related to AD9361 tuning: * the set_tx_frequency() implemented in `uhd/host/lib/usrp/dboard/e3xx/e3xx_radio_control_impl.cpp` double e3xx_radio_control_impl::set_tx_frequency(const double freq, const size_t chan) { RFNOC_LOG_TRACE("set_tx_frequency(f=" << freq << ", chan=" << chan << ")"); std::lock_guard l(_set_lock); double clipped_freq = uhd::clip(freq, AD9361_TX_MIN_FREQ, AD9361_TX_MAX_FREQ); double coerced_freq = _ad9361->tune(get_which_ad9361_chain(TX_DIRECTION, chan, _fe_swap), clipped_freq); \ // The E3xx devices have one LO for TX, if we change one channel's frequency, we change the other, too for (size_t chan_idx = 0; chan_idx < E3XX_NUM_CHANS; ++chan_idx) { radio_control_impl::set_tx_frequency(coerced_freq, chan_idx); } // Front-end switching \ _set_atr_bits(chan); return coerced_freq; } * the tune method in line 227 in the above figure calls the tune() function in: `uhd/host/lib/usrp/dboard/e3xx/e3xx_ad9361_iface.cpp` double tune(const std::string& which, const double value) override { ``` // return _rpcc->request_with_token( // E3XX_TUNE_TIMEOUT, this->_rpc_prefix + "catalina_tune", which, value); return _rpcc->request_with_token( E3XX_TUNE_TIMEOUT, this->_rpc_prefix + "tune", which, value); ``` } Notice that the original source code is “catalina_tune” and I changed it to “tune” because my experiments showed “tune” is much faster than “catalina_tune”. * Finally, I find the tune() function above seems to call the tune() function in: `uhd/host/lib/usrp/common/ad9361_driver/ad9361_device.cpp` const double ad9361_device_t::AD9361_MAX_GAIN = 89.75; const double ad9361_device_t::AD9361_MIN_CLOCK_RATE = 220e3; const double ad9361_device_t::AD9361_MAX_CLOCK_RATE = 61.44e6; const double ad9361_device_t::AD9361_CAL_VALID_WINDOW = 100e6; // Max bandwdith is due to filter rolloff in analog filter stage const double ad9361_device_t::AD9361_MIN_BW = 200e3; const double ad9361_device_t::AD9361_MAX_BW = 56e6; I find in `ad9361_device.cpp `that AD9361_CAL_VALID_WINDOW is defaulted to 100 MHz and I change the 100 MHz to 1 GHz. But nothing seems to change, the device still do a calibration every 100 MHz. I also comment out the calibration code in `uhd/host/lib/usrp/common/ad9361_driver/ad9361_device.cppb`, but still nothing seems to be changed. The device is still doing calibration every 100 MHz. Anyone knows where the source code for tuning ad9361 with E312 device is ? I wish I can locate the tuning source code so that I can change it to speed up frequency tuning. In my application, if I can turn off the calibration that happens every 100MHz, then the total tuning time is onl
[USRP-users] what is the purpose of issue_stream_cmd() for the rx_streamer?
Hi all, Does anyone know the purpose of issue_stream_cmd() for the rx_streamer? When I use the rx_streamer to stream data to the host, I just call the recv() method. The question is what is the purpose of issue_stream_cmd() for rx_streamer in uhd? Thanks, Yan ___ USRP-users mailing list -- usrp-users@lists.ettus.com To unsubscribe send an email to usrp-users-le...@lists.ettus.com