Hi usrp-users!

I'm still relatively inexperienced with working with UHD and USRP
radios in general, but I feel like I'm getting better. Anyhow, I have
*several* questions, but I'll start with one. 

Setup:
USRP X310 Radio: A:UBX, B:TwinRX
If you're familiar with a "reflectometer", it's setup like that. If
not, the simplest sufficient test setup for this problem would be to
wire the UBX TX to a resistive splitter, to both ports of the TwinRX.
How the software works is very simple: the transmitter is tuned to a
frequency, transmit value is a tone at 0Hz (transmit an array of '1's),
receiver is tuned to a nearby frequency and the tone is observed on
both channels. The value of interest is the ratio of the value of the
tone of the two channels. The objective is to quickly and accurately do
this in a sweep across ~50MHz-6GHz. 

UHD version: UHD_4.0.0.0-1-gcf570707
What I expect: the phase difference between the two channels at any
given frequency to be consistent from run-to-run. 
What I see: I can usually get consistent results, but sometimes I see
90,180,270 degree offsets instead. 

I expect the relevant section to this problem to be when and how I
handle tuning, so I've included that below:

The tune function: (simplified for brevity/clarity)
_setFrequency(double freq) {
    double rx_freq = 0; int closest_idx = 0; double tx_freq = freq;
    bool tx_tuned = false; bool rx_tuned = false;
    // loop to get closest freq in a predefined list ; 
    // the idea is to tune the receiver much less often because
    // it seems to take a lot longer due to the need to use timed
    // commands
    for (int idx = 0; idx < _freq_list.size(); idx++) {
        if (std::abs(freq - _freq_list[idx]) < std::abs(freq-rx_freq)){
            closest_idx = idx;
            rx_freq = _freq_list[idx];
        }
    }
    if (tx_freq == rx_freq) {
        // (crudely) avoid tuning rx to exactly the same freq as tx
        tx_freq += 50e3;
    }
    if (_current_tx_freq != tx_freq) {
        _usrp->clear_command_time(); // tune tx immediately
        auto tx_req = uhd::tune_request_t(tx_freq);
        _usrp->set_tx_freq(tx_freq,0);
        _current_tx_freq = tx_freq;
        tx_tuned = true;
    }
    if (_current_rx_freq != rx_freq)
    {
        _usrp->clear_command_time();
        _usrp->set_command_time(_usrp-
>get_time_now()+uhd::time_spec_t(0.100));
        _usrp->set_rx_freq(rx_freq,0);
        _usrp->set_rx_freq(rx_freq,1);
        _delay_ms(250); // delay, but keep event loop alive
        // tune again, because it seems to help
        _usrp->clear_command_time();
        _usrp->set_command_time(_usrp-
>get_time_now()+uhd::time_spec_t(0.100));
        _delay_ms(250);
        _usrp->clear_command_time();
        rx_tuned = true;
        _current_rx_freq = rx_freq;
    }
    if (tx_tuned and not rx_tuned) {
        _delay_ms(50);
    }
}

to get a value: (simplified for brevity/clarity)
receive some samples of channel a and channel b
A = fft(a)
B = fft(b)
aindex = find the index of the tone in A (by looping through the values
of the magnitude of A)
bindex = find the index of the tone in B (by looping through the values
of the magnitude of B)
ensure that the tone is at the expected frequency for both channels
R = B[bindex] / A[aindex];
Rdb = 20 * log10(std::abs(R));
Rphase = std::arg(R)*180/M_PI;

Respectfully,
Dustin


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

Reply via email to