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<std::complex<float>> buff, \
uhd::tx_streamer::sptr tx_streamer, \
uhd::tx_metadata_t metadata, \
int num_channels) {\
std::vector<std::complex<float>\*> 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<std::mutex> 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<double>(
//     E3XX_TUNE_TIMEOUT, this->_rpc_prefix + "catalina_tune", which, value);

    return _rpcc->request_with_token<double>(
    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 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

Reply via email to