[Discuss-gnuradio] re-initialize multi usrp object

2018-08-31 Thread Sanjoy Basak
Hi All,
I need to re-initialize multi usrp object in my (c++) application on the
runtime. How should I reset the multi usrp object?
If I use reset command, it gives error on the runtime.
Could anyone tell me what is the correct way to re-initialize the multi
usrp object?

uhd::usrp::multi_usrp::sptr usrp;
string args="addr0=192.168.10.1,addr1=192.168.10.2";
usrp = uhd::usrp::multi_usrp::make(args);
uhd::usrp::subdev_spec_t subdev("A:0 B:0");

//receive and operate
...

//reinitialize usrp
usrp.reset();
string args="addr0=192.168.10.1,addr1=192.168.10.2";
usrp=uhd::usrp::multi_usrp::make(args);
uhd::usrp::subdev_spec_t subdev("A:0 B:0");

I am using usrp x310, ubuntu 14.04 and uhd 3.9 lts.

Best regards
Sanjoy
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] about phase sync MIMO X310

2015-07-22 Thread Sanjoy Basak
 Hi Marcus,

Thank you very much for pointing out the errors.

I removed the set_time_next_pps from my code. I can do time sync without
this. So I am fine with it.

However, I am not getting time sync with set_command_time(). I am not
really sure why but this is not giving me time sync. When I check the
receive file in Matlab, I see around 35000 zeros at the beginning of my
first OFDM symbol for 2MSPS and this number varies with every initiation.
The reason could be my set_command_time is controlling the transmitter to
send signal at the specified time. But the receiver is not waiting, its
getting started at the beginning.
This is my code.

time.sleep(1)

cmd_time =self.usrp_source0.get_time_last_pps()
cmd_time0 = self.usrp_sink0.get_time_last_pps()

real_seconds = uhd.time_spec_t.get_real_secs(cmd_time)
real_seconds0 = uhd.time_spec_t.get_real_secs(cmd_time0)

print real_seconds
print real_seconds0
future_real_seconds = real_seconds + 1
future_real_seconds0 = real_seconds0 + 1

print future_real_seconds
print future_real_seconds0

future_cmd_time = uhd.time_spec_t(future_real_seconds)
future_cmd_time0 = uhd.time_spec_t(future_real_seconds0)

self.usrp_source0.set_command_time(future_cmd_time)
self.usrp_source0.set_center_freq(uhd.tune_request(f,0), 0)
self.usrp_source0.set_center_freq(uhd.tune_request(f,0), 1)

self.usrp_sink0.set_command_time(future_cmd_time0)
self.usrp_sink0.set_center_freq(uhd.tune_request(f,0), 0)
self.usrp_sink0.set_center_freq(uhd.tune_request(f,0), 1)

self.usrp_source0.clear_command_time()
self.usrp_sink0.clear_command_time()


I exchanged set_command_time with set_start_time to check, set_start_time
is giving time sync as before, a constant sample shift for every
initiation, but no phase sync.

For one X310, I tried this

now = usrp_source0.get_time_now()
starttime = now + uhd.time_spec(0.1)
usrp_source0.set_command_time(starttime)
usrp_sink0.set_command_time(starttime)
self.usrp_source0.set_center_freq(uhd.tune_request(f,0), 0)
self.usrp_source0.set_center_freq(uhd.tune_request(f,0), 1)
self.usrp_sink0.set_center_freq(uhd.tune_request(f,0), 0)
self.usrp_sink0.set_center_freq(uhd.tune_request(f,0), 1)
self.usrp_source0.clear_command_time()
self.usrp_sink0.clear_command_time()

result: no time sync.

Am I making any mistake again or what exactly is going wrong? Please let me
know.

Phase sync about SBX is not written specifically in the Device
synchronization site, whereas about UBX, it is written that the phase sync
works perfectly
"*X300/X310, phase sync with UBX fully works*."

Can I expect similar behavior with *SBX-120*?

*The phase offset drifts+periodic calibration necessary? *
If I just need to take a measurement for 5 minutes (say for example), Do I
need calibration in between 5 minutes?

All I need is to have a zero phase difference between 2 (or more) RX OFDM
symbols over the receive frames.

Please let me know.

Best regards
Sanjoy
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] problem with send() function making OOT

2015-07-18 Thread Sanjoy Basak
Hi Marcus,

I need help regarding the phase sync part that you mentioned in your
previous post here.

"There's one thing that could use improvement in the echotimer code: If
the set_?x_freq() were done after the time and clock sources had been
set as a timed command (i.e. after calling set_command_time()), then the
SBX daughterboards would always have the same phase relationship after
tuning to the same frequency, which might be really handy in MIMO."

This part I tried in python, however, I am not actually getting any
phase sync between the receive files. I am not really sure whether
defining freq after set_command_time() in python can really help.
However, please let me know what modification should I make or what
exactly I need to do.

I am putting the python code here that I am using right now for 2 usrps.
2 TXs are in one x310 (on gpsdo) and 2 RXs are on the other one
(external ref).
and the connection is TX-wire-30_dB_attenuator-wire-RX, I am taking
wired measurement. I am using 2.45 GHz freq.

---
self.usrp_source0 = uhd.usrp_source(
  ",".join(("addr=172.xx.xx.73", "")),
  uhd.stream_args(
cpu_format="fc32",
channels=range(2),
  ),
)

self.usrp_sink0 = uhd.usrp_sink(
  ",".join(("addr=172.xx.xx.75", "")),
  uhd.stream_args(
cpu_format="fc32",
channels=range(2),
  ),
)


self.usrp_source0.set_clock_source("external", 0)
self.usrp_source0.set_time_source("external", 0)
self.usrp_source0.set_subdev_spec("A:0 B:0", 0)
self.usrp_source0.set_time_unknown_pps(uhd.time_spec())
self.usrp_source0.set_samp_rate(samp_rate)
self.usrp_source0.set_gain(26, 0)
self.usrp_source0.set_antenna("RX2", 0)
self.usrp_source0.set_gain(26, 1)
self.usrp_source0.set_antenna("RX2", 1)

self.usrp_sink0.set_clock_source("gpsdo", 0)
self.usrp_sink0.set_time_source("gpsdo", 0)
self.usrp_sink0.set_subdev_spec("A:0 B:0", 0)
self.usrp_sink0.set_time_unknown_pps(uhd.time_spec())
self.usrp_sink0.set_samp_rate(samp_rate)
self.usrp_sink0.set_gain(0, 0)
self.usrp_sink0.set_antenna("TX/RX", 0)
self.usrp_sink0.set_gain(0, 1)
self.usrp_sink0.set_antenna("TX/RX", 1)

  time.sleep(1)
  print "receiver pps time:"
  cmd_time = self.usrp_source0.get_time_last_pps()
  print "transmitter pps time:"
  cmd_time0 = self.usrp_sink0.get_time_last_pps()
  real_seconds = uhd.time_spec_t.get_real_secs(cmd_time)
  real_seconds0 = uhd.time_spec_t.get_real_secs(cmd_time0)

  print real_seconds
   print real_seconds0


  self.usrp_source0.set_time_next_pps(uhd.time_spec_t(0.0))
  self.usrp_sink0.set_time_next_pps(uhd.time_spec_t(0.0))

  now = self.usrp_source0.get_time_now()
  starttime = now + uhd.time_spec(1.5)
  self.usrp_source0.set_start_time(starttime)
  self.usrp_sink0.set_start_time(starttime)

self.usrp_source0.set_center_freq(f, 0)
self.usrp_source0.set_center_freq(f, 1)
self.usrp_sink0.set_center_freq(f, 0)
self.usrp_sink0.set_center_freq(f, 1)

self.blocks_throttle_0_1 =
blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.blocks_throttle_0_0_0 =
blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.blocks_throttle_0_0 =
blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1,
samp_rate,True)
self.blocks_file_source_0_0 =
blocks.file_source(gr.sizeof_gr_complex*1,
"/home/sanjoy/Desktop/new/siso with new preamble
3/20150603_siso_echotimer/floatgen.bin", True)
self.blocks_file_source_0 =
blocks.file_source(gr.sizeof_gr_complex*1,
"/home/sanjoy/Desktop/new/siso with new preamble
3/20150603_siso_echotimer/floatgen.bin", True)
self.blocks_file_sink_0_0 =
blocks.file_sink(gr.sizeof_gr_complex*1,
"/home/sanjoy/Desktop/siso2.bin", False)
self.blocks_file_sink_0_0.set_unbuffered(False)
self.blocks_file_sink_0 =
blocks.file_sink(gr.sizeof_gr_complex*1,
"/home/sanjoy/Desktop/siso1.bin", False)
self.blocks_file_sink_0.set_unbuffered(False)
-

My system config is usrp X310, daughterboard SBX-120, uhd 3.9.

best regards
Sanjoy

-- 
Posted via http://www.ruby-forum.com/.

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] problem with send() function making OOT

2015-06-28 Thread Sanjoy Basak
Hi Marcus,
Thanks for the reply.
This worked today. Unfortunately set_command_time(), 
clear_command_time() did not work well with my setup.
The Rx start point was varying with every initiation.

With the same code today I tried with set_start_time() and this worked 
really well.
The time sync property with 2 X310 is the same like 1 X310.
Thanks a lot.

Best regards
Sanjoy

-- 
Posted via http://www.ruby-forum.com/.

___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] problem with send() function making OOT

2015-06-27 Thread Sanjoy Basak
Hi Marcus,
Thank you very much for the tips and suggestions. This is really 
helpful.
You are right, I should not rely on Echotimer, rather I should try to 
make one, based on my requirements.

First I tried the python code. This really worked for one X310 frontend 
ports. I tried for 1Tx -2Rx and 2Tx – 1Rx. Those are time aligned with 
the python code you suggested.

However, this is not working for 2 X310s. I am not being able to make 
time aligned Tx, Rx. I am using external reference. Would you please 
suggest me some code/ modification for pyton file, so that the ports can 
be time aligned.

I also tried the code suggested in this link
http://usrp-users.ettus.narkive.com/6qvbyOIf/synchronizing-usrp-front-ends-via-gnu-radio

The code is actually to synchronize Tx front ends of 2 X310s.
I tried this for 1Tx - 1 Rx (Tx on usrp with gpsdo and Rx on usrp with 
external reference). But this did not help to synchronize on time.

Best regards
Sanjoy

-- 
Posted via http://www.ruby-forum.com/.
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


Re: [Discuss-gnuradio] problem with send() function making OOT

2015-06-25 Thread Sanjoy Basak
Hi Marcus,
Thanks for the response. I did not get any notification in my inbox. So
I put it there.

I am trying to implement MIMO OFDM radar with X310.
With this, I am actually trying to achieve time sync for X310. With
separate UHD source and sink--I could not achieve time sync with
different ports.

The code is from CEL,KIT --Echotimer. I tried it over X310, after using
the subdev_spec, it worked nicely for SISO. I am trying to use it for
MIMO. I am not really much good at this coding. I just started learning
it this month.

I will try to correct the code with the points you mentioned.
I am putting the the impl.cc code, which is a bit large. But it would be
really kind if you can go through and find any further problem to
correct.

best regards
Sanjoy Basak
thesis student, IHE, KIT

The subdev spec and others I hardcoded those to check whether works or
not.

/* -*- c++ -*- */
/*
 * Copyright 2014 Communications Engineering Lab, KIT.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include 
#include "usrp_echotimer_cc_impl.h"
#include 

namespace gr {
  namespace radar {

usrp_echotimer_cc::sptr
usrp_echotimer_cc::make(int samp_rate, float center_freq, int
num_delay_samps, std::string args_tx, std::string wire_tx, std::string
clock_source_tx, std::string time_source_tx, std::string antenna_tx1,
std::string antenna_tx2, float gain_tx, float timeout_tx, float wait_tx,
float lo_offset_tx, std::string wire_rx, std::string antenna_rx, float
gain_rx, float timeout_rx, float wait_rx, float lo_offset_rx,
std::string spec_tx, std::string spec_tx2, std::string spec_rx, const
std::string& len_key)
{
  return gnuradio::get_initial_sptr
(new usrp_echotimer_cc_impl(samp_rate, center_freq,
num_delay_samps, args_tx, wire_tx, clock_source_tx, time_source_tx,
antenna_tx1, antenna_tx2, gain_tx, timeout_tx, wait_tx, lo_offset_tx,
wire_rx, antenna_rx, gain_rx, timeout_rx, wait_rx, lo_offset_rx,
spec_tx, spec_tx2, spec_rx, len_key));
}

/*
 * The private constructor
 */
usrp_echotimer_cc_impl::usrp_echotimer_cc_impl(int samp_rate, float
center_freq, int num_delay_samps, std::string args_tx, std::string
wire_tx, std::string clock_source_tx, std::string time_source_tx,
std::string antenna_tx1, std::string antenna_tx2, float gain_tx, float
timeout_tx, float wait_tx, float lo_offset_tx, std::string wire_rx,
std::string antenna_rx, float gain_rx, float timeout_rx, float wait_rx,
float lo_offset_rx, std::string spec_tx, std::string spec_tx2,
std::string spec_rx, const std::string& len_key)
  : gr::tagged_stream_block("usrp_echotimer_cc",
  gr::io_signature::make(2, 2, sizeof(gr_complex)),
  gr::io_signature::make(1, 1, sizeof(gr_complex)), len_key)
{
d_samp_rate = samp_rate;
d_center_freq = center_freq;
d_num_delay_samps = num_delay_samps;
d_out_buffer.resize(0);

//* Setup USRP TX *//

d_spec_tx=spec_tx;
d_spec_tx2=spec_tx2;
d_args_tx = args_tx;
d_wire_tx = wire_tx;
d_clock_source_tx = clock_source_tx;
d_time_source_tx = time_source_tx;
d_antenna_tx1 = antenna_tx1;
d_antenna_tx2 = antenna_tx2;
d_lo_offset_tx = lo_offset_tx;
d_gain_tx = gain_tx;
d_timeout_tx = timeout_tx; // timeout for sending
d_wait_tx = wait_tx; // secs to wait befor sending

// Setup USRP TX: args (addr,...)
d_usrp_tx = uhd::usrp::multi_usrp::make(d_args_tx);
std::cout << "Using USRP Device (TX): " << std::endl <<
d_usrp_tx->get_pp_string() << std::endl;

//setup subdev spec
d_usrp_tx -> set_tx_subdev_spec ( uhd::usrp::subdev_spec_t ("B:0
A:0"));
//set_subdev_spec(const std::string &spec_tx, size_t mboard);

//setup subdev spec for tx2--same usrp
//d_usrp_tx -> set_tx_subdev_spec ( uhd::usrp::subdev_spec_t
(d_spec_tx2),0);

// Setup USRP TX: sample rate
std::cout << "Setting TX Rate: " << d_samp_rate << std::endl;
d_usrp_tx->set_tx_rate(d_samp_rate);
std::cout << "Actual TX Rate: " << d_usrp_tx->get_tx_rate() <<
std::endl;

// Setup USRP TX: gain
set_tx_gain(d_gain_tx);

// Setup USRP TX: 

[Discuss-gnuradio] problem with send() function making OOT

2015-06-24 Thread Sanjoy Basak
Hi all,

I am trying to make 2 TX 1Rx tagged stream block(OOT). For 1Tx 1Rx, it was
working fine. I am trying to extend it. Now the problem is, I am not being
able to configure the send() function.

If I try make test, it does not show any problem. However, when I check
after reception I find that 1 transmitter is transmitting, and another is
not. I checked the every port of my USRP X310, it is working fine.


 Here's the code. I putting a short part where I have problem. Please let
me if you need the header and grc file as well, to correct the code.


 - - -

void

usrp_echotimer_cc_impl::send()

{

// Data to USRP

num_tx_samps = d_tx_stream->send(d_in_send1, total_num_samps,
d_metadata_tx, total_num_samps/(float)d_samp_rate+d_timeout_tx);

num_tx_samps = d_tx_stream->send(d_in_send0, total_num_samps,
d_metadata_tx, total_num_samps/(float)d_samp_rate+d_timeout_tx);

 }

  int

usrp_echotimer_cc_impl::work (int noutput_items,

gr_vector_int &ninput_items,

gr_vector_const_void_star &input_items,

gr_vector_void_star &output_items)

{

gr_complex *in0 = (gr_complex *) input_items[0];

gr_complex *in1 = (gr_complex *) input_items[1];

gr_complex *out = (gr_complex *) output_items[0];

 // Set output items on packet length

noutput_items = ninput_items[0]=ninput_items[1];

 // Resize output buffer

if(d_out_buffer.size()!=noutput_items) d_out_buffer.resize(noutput_items);

   // Send thread

d_in_send0 = in0;

d_in_send1 = in1;

d_noutput_items_send = noutput_items;

d_thread_send =
gr::thread::thread(boost::bind(&usrp_echotimer_cc_impl::send, this));

 // Receive thread

d_out_recv = &d_out_buffer[0];

d_noutput_items_recv = noutput_items;

d_thread_recv =
gr::thread::thread(boost::bind(&usrp_echotimer_cc_impl::receive, this));


-

My system config is X310, daughterboard SBX-120 and I am using UHD-3.9

I checked the subdev specification, gain and frequency assignment. Those
are fine.

Please let me know how to correct and thanks in advance.


best regards

Sanjoy
___
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio