On Mon, Dec 16, 2024 at 1:57 PM Marcus D. Leech <patchvonbr...@gmail.com>
wrote:

> On 16/12/2024 13:47, Christophe Grimault wrote:
>
> I followed your advice and I'm getting closer !-)
>
> I tried this :
>
> usrp = uhd.usrp.MultiUSRP(f"addr=192.168.30.2")
> duration = 10.0start_time_spec = 
> uhd.libpyuhd.types.time_spec(usrp.get_time_now().get_real_secs() + 1.0)
>
> rx_rates = [390625.0*2, 390625.0]
> # ---------------# Craft commands# ---------------# Start with chan 0 
> ...usrp.set_rx_rate(rx_rates[0], chan=0)
> rx_tune_request0 = uhd.types.TuneRequest(1100.0e6)
> usrp.set_rx_freq(tune_request=rx_tune_request0, chan=0)
> usrp.set_rx_gain(45.0, chan=0)
> num_samps0 = math.ceil(int(usrp.get_rx_rate(chan=0)) * duration)
>
> rx_streamer_args0 = uhd.usrp.StreamArgs("fc32", "sc16")
> rx_streamer_args0.channels = [0]
> rx_streamer0 = usrp.get_rx_stream(rx_streamer_args0)
> max_samps_per_packet = rx_streamer0.get_max_num_samps()
> L0 = math.ceil(num_samps0 / max_samps_per_packet) * max_samps_per_packet
> recv_buffer0 = np.zeros(L0, dtype=np.complex64)
> stream_cmd0 = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)  
> #num_done)stream_cmd0.stream_now = Falsestream_cmd0.num_samps = num_samps0
> stream_cmd0.time_spec = start_time_spec
> # Then chan 1, which is 2 times slower.usrp.set_rx_rate(rx_rates[1], chan=1)
> rx_tune_request1 = uhd.types.TuneRequest(1100.0e6)
> usrp.set_rx_freq(tune_request=rx_tune_request1, chan=1)
> usrp.set_rx_gain(35.0, chan=1)
> num_samps1 = math.ceil(int(usrp.get_rx_rate(chan=1)) * duration)
>
> rx_streamer_args1 = uhd.usrp.StreamArgs("fc32", "sc16")
> rx_streamer_args1.channels = [1]
> rx_streamer1 = usrp.get_rx_stream(rx_streamer_args1)
> max_samps_per_packet = rx_streamer1.get_max_num_samps()
> L1 = math.ceil(num_samps1 / max_samps_per_packet) * max_samps_per_packet
> recv_buffer1 = np.zeros(L1, dtype=np.complex64)
> stream_cmd1 = uhd.types.StreamCMD(uhd.types.StreamMode.start_cont)  
> #num_done)stream_cmd1.stream_now = Falsestream_cmd1.num_samps = num_samps1
> stream_cmd1.time_spec = start_time_spec
> # --------------------------------------------------# Launch sampling on both 
> streamers, i.e. channels# 
> --------------------------------------------------rx_streamer0.issue_stream_cmd(stream_cmd0)
> rx_streamer1.issue_stream_cmd(stream_cmd1)
>
> metadata0 = uhd.types.RXMetadata()
> nb_samples0 = rx_streamer0.recv(recv_buffer0, metadata0, 3.0)
>
> metadata1 = uhd.types.RXMetadata()
> nb_samples1 = rx_streamer1.recv(recv_buffer1, metadata1, 3.0)
>
> metadata0.time_spec.get_real_secs() - metadata1.time_spec.get_real_secs()
>
> And got the attached figures.
>
> Over the 10 s of capture, I switch of the signal at the same time on both
> channels (exact same time because the switch is before the RF coupler).
> Both capture are roughly aligned in time, but when I zoom, I see 26 us of
> delay (which is roughly 10 samples at rx_rate_1 of 390625). Am I wrong
> expecting a "perfect timing" ? And when I compute :
>
> metadata0.time_spec.get_real_secs() - metadata1.time_spec.get_real_secs()
>
> still I get 0.0 us.
>
> What am I doing wrong ? Shall I launch threads ?
>
> Any thoughts ?
>
> Thanks in advance
>
> Chris
>
> A cursory inspection of your code doesn't indicate any glaring errors, but
> your start-time is only 1 second ahead of when
>   you get the time from the device.  That MAY not be enough to get both
> streamers set-up so that they'll "trigger" at the
>   same time.
>
> What device type is this?
>

My guess is that you're going through another Halfband FIR filter
somewhere, so there is group delay that isn't being accounted for in the
digital filters.

What is the lag (in samples) of the lower rate sampled signal?

Brian
_______________________________________________
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