Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TwinRX] LO sharing Phase Alignment Problems Multiple of 90 degrees, pi/2 WITH PYTHON API #769

Open
UTAAR opened this issue Jul 4, 2024 · 0 comments

Comments

@UTAAR
Copy link

UTAAR commented Jul 4, 2024

Issue Description

This issue has already been treated in the following issue:

#670

However, only a solution for the C++ API was found there. Since we are using the Python API, it would be good if a solution to this issue could be provided, especially since the phase coherent operation of the TwinRX is a fundamental feature of it.

This issue consists in having different phase differences between the two same channels of a single TwinRX when using the same LOs for both channels. The variation of the phase difference occurs whenever the unit is power cycled or whenever the software is re-run. This variation is always a multiple of 90º. In particular, we get 4 different values of the phase difference: 34º, 124º, 214º and 304º.

Setup Details

X310 with a single TwinRX in slot B. The other slot is empty.
UHD 4.6 (installed through radioconda). Windows 11.
A signal generator is used, connected through a cable to a 1:2 splitter, which is then connected via two cables of the same length and model to each of the 2 input ports of the TwinRX.
The frequency is 5.895 GHz, the signal is unmodulated (CW) and the amplitude is -30 dBm.

Expected Behavior

Phase difference should be constant when sharing LO, not change by 90º multiples whenever the USRP is power cycled or the software is re-run.

Actual Behaviour

Phase difference changes by 90º multiples every time that the USRP is power cycled or the software is re-run.

Steps to reproduce the problem

We obtain the samples using a Python script, after which we have used Matlab to plot "phase_diff". The Python script is the following:

import uhd
import scipy.io
import numpy as np

usrp = uhd.usrp.MultiUSRP("type=x300")

ns = int(1e4)
cf = 5.895e9
sr = 1e6 # Minimum sample rate is 2e5
receive_channs = [1,2] # Channel 1 = B TX/RX, channel 2 = B RX2
gain1 = 60
gain2 = 60
sz = (2,ns)
samp_all = np.zeros(sz,dtype=complex)
div_all = np.zeros([1,ns],dtype=complex)

st_args = uhd.usrp.StreamArgs("fc32", "sc16")
st_args.channels = [1, 2]
metadata = uhd.types.RXMetadata()
streamer = usrp.get_rx_stream(st_args)
recv_buffer = np.zeros((2, 1000), dtype=np.complex64)
usrp.set_rx_rate(sr, 1)
usrp.set_rx_freq(uhd.libpyuhd.types.tune_request(cf), 1)
usrp.set_rx_gain(gain1, 1)
usrp.set_rx_rate(sr, 2)
usrp.set_rx_freq(uhd.libpyuhd.types.tune_request(cf), 2)
usrp.set_rx_gain(gain2, 2)
usrp.set_rx_antenna('RX1', 1)
usrp.set_rx_antenna('RX2', 2)

usrp.set_rx_lo_source('internal','all', 1)
usrp.set_rx_lo_source('companion','all', 2)

stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)
channels = [1, 2]
stream_cmd.stream_now = (len(channels) == 1)

stream_cmd.time_spec = uhd.types.TimeSpec(
usrp.get_time_now().get_real_secs() + 0.05)
streamer.issue_stream_cmd(stream_cmd)

samples = np.zeros((2,ns), dtype=np.complex64)
for i in range(ns//1000):
streamer.recv(recv_buffer, metadata)
samples[0,i*1000:(i+1)1000] = recv_buffer[0,:]
samples[1,i
1000:(i+1)*1000] = recv_buffer[1,:]

samp_all[0:,range(0,ns)] = samples
div_all[:,range(0,ns)] = samples[0,:]/samples[1,:]
phase_diff = np.angle(div_all)*180/np.pi

stream_cmd = uhd.types.StreamCMD(uhd.types.StreamMode.stop_cont)
streamer.issue_stream_cmd(stream_cmd)

scipy.io.savemat('phase_diff.mat', dict(phase_diff=phase_diff))
scipy.io.savemat('samps.mat', dict(samps=samp_all))

Additional Information

We have also observed that, consistently, the first 24 samples have abnormal values, i.e., if you take the 20*log10(samples), the values start at -Inf and then progressively rise up to the correct values. This also impacts the phase difference values of the first samples. For example, in this case, we get around -38 (channel 2) / -40 (channel 1) dB"m", which is also surprising because we have a symmetrical setup, i.e., the expected difference in received power is lower than the 2 dB we are getting. All this is not critical at this moment, since we are focusing on the phase difference first, but any additional information would be appreciated.

Attached are the plots for the phase differences . Please note that the red line with the average phase is computed omitting the first samples, whose phase difference is NaN (because the samples themselves are 0). Please also note that the range of the phase is -180º to 180º, so -146º = 214º and -56º = 304º.

Issue_PDiff8(afterpowercycle)
Issue_PDiff1
Issue_PDiff2
Issue_PDiff4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant