Thanks for the quick response Marcus!

It seems to be fairly frequency dependent. I'm attaching a link to a
data file so y'all can take a look at what I mean. I ran a dense-ish
sweep several times to try to get a feel for how reproducible things
were /etc. The transmitter was retuned at each frequency, but the
receiver was only retuned every 10MHz. 
https://u.pcloud.link/publink/show?code=XZviezXZGl5Ypkv46LSVf9l9n1YtOV05z92k
in this file: 
* blue or green text = range of datapoints that seem to have
reproducible phase offsets (I alternated between blue and green when I
noticed a "jump" in the value ;; sometimes these jumps were 90/180/270
degree, but often not, and were reproducible regardless)
* orange text = phase offset is off in some consistent manner
(90/180/270 degree jump) and/or reproducible aberrant value
* red text = phase offset seems to be random/garbage
* red background = invalid datapoint (either tone is at unexpected bin
on channel 1, channel 2, or both ;; this is one of the other questions
I was alluding to in my first email, I'm presuming its a separate
issue, but maybe not. It's worth noting that when the tone is observed
at the wrong frequency, the frequency where it is observed is often a
multiple of the reference clock instead)

Dustin

P.S. It took me quite a while to go through this file, I need to find a
better way to go about that ....

On Wed, 2020-11-11 at 14:14 -0500, Marcus D. Leech via USRP-users
wrote:
> On 11/11/2020 11:26 AM, Dustin Widmann via USRP-users wrote:
> > 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
> Do the unexpected phase offsets only occur over certain frequency
> ranges 
> or over the whole scan range?
> 
> 
> 
> _______________________________________________
> USRP-users mailing list
> USRP-users@lists.ettus.com
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com



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

Reply via email to