Send USRP-users mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of USRP-users digest..."


Today's Topics:

   1. Re: New to USRP :: software development platform
      recommendations sought (zeng)
   2. Re: USRP B210 (ali hanif via USRP-users)
   3. Re: USRP B210 (Martin Braun via USRP-users)
   4. Re: Using PPS input on N210 as a simple arbitrary time
      trigger (Matt Ettus via USRP-users)
   5. Phase Offset between USRP-B210 Channels
      (Stefan Ereth via USRP-users)
   6. Re: Phase Offset between USRP-B210 Channels
      (Marcus D. Leech via USRP-users)


----------------------------------------------------------------------

Message: 1
Date: Fri, 2 May 2014 03:33:49 +0000 (UTC)
From: zeng, xuewen via USRP-users <[email protected]>
To: [email protected]
Subject: Re: [USRP-users] New to USRP :: software development platform
        recommendations sought
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8

Patrick Sisterhen <patrick.sisterhen@...> writes:

> 
> ? ? ? ? b)
> if LabVIEW presents a more economic alternative
> As one point of comparison, you can
> use the USRP devices in LabVIEW on Windows without having the Modulation
> Toolkit or Digital Filter Design Toolkit (although both are very useful).
> ?LabVIEW has a fair amount of signal processing, probability/statistics,
> and linear algebra functionality built-in.
> The NI-USRP driver does not require
> you to build UHD or GnuRadio, but will peacefully co-exist with both if
> they are on your system.
> 
> Patrick Sisterhen
> National Instruments
> 
> _______________________________________________
> USRP-users mailing list
> USRP-users@...
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
> 

We did similar experiments you may want to do: combine matlab baseband 
signal processing with usrp real wolrd tranceiving. Matlab is used to 
generate baseband IQ data file with added noise, freq-offset & multi-path 
effects and up-sampling-pulse shaping filter, then tranceiving thru 
gnuradio+usrp and then back to matlab to proc the rxed baseband IQ data 
file. We used DIY usrp1 and gnuradio 3.2.2. We modified 
usrp_standard_tx.cpp to tx the IQ data file and used usrp_rx_cfile cmdlinee 
tool to save rxed int16 iq data to file. We need to locate the start of a 
frame by preample sync process.(ref: Frame synchronization in SC-FDE system 
using PN sequence modulation in Ieee explore, url: 
http://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=6197855&url=http%3A%
2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D6197855)
This experiment provides a low cost real world trx validation routine.
 
It also should be noted that RFX 900/2400 will add noticable extra noise 
and freq-offset. BasicRX/TX F transceiving maybe used to eval the matlab 
baseband proc.
I am wondering if Uhd based usrp-gnuradio or matlab provide ready tools for 
baseband IQ file trx experiment. Any info on this would be appreciated.

zeng,xuewen from zxwdsp (at) 126.ocm.






------------------------------

Message: 2
Date: Fri, 2 May 2014 10:03:32 +0500
From: ali hanif via USRP-users <[email protected]>
To: Matt Ettus <[email protected]>,        "[email protected]"
        <[email protected]>
Subject: Re: [USRP-users] USRP B210
Message-ID:
        <caejvf3sw4el5q-dh+vi7qj0vuta1epg-1kdv6gyzdxhoy87...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Can anyone tell what is the maximum gain value that i can use for my USRP
B210? and it will correspond to how much power at 2.4 GHz?
I mean with what relationship the output power increases with gain?


On Tue, Apr 29, 2014 at 1:28 PM, ali hanif <[email protected]> wrote:

> Thank you Matt
>
>
> On Tue, Apr 29, 2014 at 1:17 PM, Matt Ettus <[email protected]> wrote:
>
>>
>> In GNU Radio you should set the center frequency of the UHD block to be
>> the center frequency of your RF channel (i.e. 2.45 GHz or whatever).  Set
>> the UHD block sample rate to some rate >= 56 MHz, like 61.44 MS/s.  The
>> output will be a stream of complex floats centered at DC.
>>
>> Matt
>>
>>
>> On Tue, Apr 29, 2014 at 7:30 AM, ali hanif <[email protected]> wrote:
>>
>>> If i am not getting u wrong..u mean to say that i should design my flow
>>> graph in GNU by keeping the center frequency less than or equal to 56 MHz??
>>> and the signal which i will be getting from USRP Source block in GRC
>>> will always be centered at 0 Hz,no matter what is the receiving frequency
>>> as it is direct conversion??
>>>
>>>
>>>
>>> On Mon, Apr 28, 2014 at 6:35 PM, Matt Ettus <[email protected]> wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Sat, Apr 26, 2014 at 4:50 AM, ali hanif via USRP-users <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,I am using USRP B210...I am new to this field and I wanted to ask
>>>>> certain basic questions:
>>>>> 1) I have read that B210 has 56MHz of instantaneous bandwidth..does
>>>>> this mean that if i am transmitting or receiving a signal   at  2.4GHz 
>>>>> then
>>>>> this signal will have a bandwidth of 56 MHz? OR The Intermediate frequency
>>>>> after down conversion or before up conversion(in which low pass filters 
>>>>> and
>>>>> ADC/DAC in the USRP are operating) is 56 MHz?(as GNU Radio companion
>>>>> operates in baseband frequencies)
>>>>>
>>>>
>>>>
>>>> It means that your signals can be 56 MHz wide.  You could receive from
>>>> 2.400 to 2.456 MHz at once, for example.  There is no IF per se, since this
>>>> is direct conversion, but you can think of it like a 56 MHz wide IF.
>>>>
>>>>
>>>>
>>>>> 2) Is it possible to simultaneously transmit at a different frequency
>>>>> and receive at another frequency from USRP?
>>>>>
>>>>
>>>> Yes.
>>>>
>>>>
>>>>> 3)What is the output power of B210??
>>>>>
>>>>
>>>> About 50 mW, but this varies with frequency.
>>>>
>>>>
>>>>> Thnx in advance
>>>>>
>>>>> _______________________________________________
>>>>> USRP-users mailing list
>>>>> [email protected]
>>>>> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20140502/ce145b97/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 02 May 2014 08:33:31 +0200
From: Martin Braun via USRP-users <[email protected]>
To: "[email protected]" <[email protected]>
Subject: Re: [USRP-users] USRP B210
Message-ID: <[email protected]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

On 02.05.2014 07:03, ali hanif via USRP-users wrote:
> Can anyone tell what is the maximum gain value that i can use for my
> USRP B210? and it will correspond to how much power at 2.4 GHz?

You can run uhd_usrp_probe to get this info:
<snip>
|   |   |     _____________________________________________________
|   |   |    /
|   |   |   |       TX Frontend: A
|   |   |   |   Name: FE-TX2
|   |   |   |   Antennas: TX/RX
|   |   |   |   Sensors:
|   |   |   |   Freq range: 50.000 to 6000.000 Mhz
|   |   |   |   Gain range PGA: 0.0 to 89.8 step 0.2 dB
|   |   |   |   Connection Type: IQ
|   |   |   |   Uses LO offset: No
</snip>

As Matt said, you can get about 50 mW (at max gain), but the exact value 
depends on many things, including your software- and hardware setup.
You can *approximate* the actual power by deducting the offset from max 
gain from your max output power, but this is not entirely linear (e.g. 
you reduce gain by 10 dB, you lose about 10 dB of output power).

Martin




> I mean with what relationship the output power increases with gain?
>
>
> On Tue, Apr 29, 2014 at 1:28 PM, ali hanif <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Thank you Matt
>
>
>     On Tue, Apr 29, 2014 at 1:17 PM, Matt Ettus <[email protected]
>     <mailto:[email protected]>> wrote:
>
>
>         In GNU Radio you should set the center frequency of the UHD
>         block to be the center frequency of your RF channel (i.e. 2.45
>         GHz or whatever).  Set the UHD block sample rate to some rate >=
>         56 MHz, like 61.44 MS/s.  The output will be a stream of complex
>         floats centered at DC.
>
>         Matt
>
>
>         On Tue, Apr 29, 2014 at 7:30 AM, ali hanif
>         <[email protected] <mailto:[email protected]>> wrote:
>
>             If i am not getting u wrong..u mean to say that i should
>             design my flow graph in GNU by keeping the center frequency
>             less than or equal to 56 MHz??
>             and the signal which i will be getting from USRP Source
>             block in GRC will always be centered at 0 Hz,no matter what
>             is the receiving frequency as it is direct conversion??
>
>
>
>             On Mon, Apr 28, 2014 at 6:35 PM, Matt Ettus <[email protected]
>             <mailto:[email protected]>> wrote:
>
>
>
>
>                 On Sat, Apr 26, 2014 at 4:50 AM, ali hanif via
>                 USRP-users <[email protected]
>                 <mailto:[email protected]>> wrote:
>
>                     Hi,I am using USRP B210...I am new to this field and
>                     I wanted to ask certain basic questions:
>                     1) I have read that B210 has 56MHz of instantaneous
>                     bandwidth..does this mean that if i am transmitting
>                     or receiving a signal   at  2.4GHz then this signal
>                     will have a bandwidth of 56 MHz? OR The Intermediate
>                     frequency after down conversion or before up
>                     conversion(in which low pass filters and ADC/DAC in
>                     the USRP are operating) is 56 MHz?(as GNU Radio
>                     companion operates in baseband frequencies)
>
>
>
>                 It means that your signals can be 56 MHz wide.  You
>                 could receive from 2.400 to 2.456 MHz at once, for
>                 example.  There is no IF per se, since this is direct
>                 conversion, but you can think of it like a 56 MHz wide IF.
>
>                     2) Is it possible to simultaneously transmit at a
>                     different frequency and receive at another frequency
>                     from USRP?
>
>
>                 Yes.
>
>                     3)What is the output power of B210??
>
>
>                 About 50 mW, but this varies with frequency.
>
>                     Thnx in advance
>
>                     _______________________________________________
>                     USRP-users mailing list
>                     [email protected]
>                     <mailto:[email protected]>
>                     
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>
>
>
>
>
>
>
>
> _______________________________________________
> USRP-users mailing list
> [email protected]
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>




------------------------------

Message: 4
Date: Fri, 2 May 2014 16:49:46 +0200
From: Matt Ettus via USRP-users <[email protected]>
To: Kevin Klug <[email protected]>
Cc: "[email protected]" <[email protected]>
Subject: Re: [USRP-users] Using PPS input on N210 as a simple
        arbitrary time  trigger
Message-ID:
        <CAN=1kn-a_c9hma3mhb0+i_99hzyg0-fmejqhf0oimpxn0ze...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Kevin,

As Marcus said, you could probably use the PPS to set the time to 0, and
then have the event set to happen some small number of cycles after that.
 Alternatively, you could directly use the PPS as a trigger, but that will
take some FPGA coding on your part.

Matt



On Thu, May 1, 2014 at 2:13 AM, Kevin Klug via USRP-users <
[email protected]> wrote:

> Hi all,
>
> It is my understanding that the USRP's PPS input is only really used to
> initialize the sample time to 0 or absolute time once and then uses the
> external reference to count further seconds.
>
> If this is indeed the case, would it be possible to use the PPS input as a
> simple trigger for some event at an arbitrary time?
>
> For Example:
>
> ...
> // sync time to first PPS trigger
> ...
> uhd::time_spec_t last_pps_time = usrp->get_time_last_pps();
>
> while( 1 ){
>   if( last_pps_time != usrp->get_time_last_pps() ){
>     last_pps_time = usrp->get_time_last_pps();
>     // Code to transmit/receive/do something goes here
>
>   }
> }
>
> Thanks for help,
> Kevin
>
> _______________________________________________
> USRP-users mailing list
> [email protected]
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20140502/292ce903/attachment-0001.html>

------------------------------

Message: 5
Date: Fri, 2 May 2014 08:30:19 +0200
From: Stefan Ereth via USRP-users <[email protected]>
To: <[email protected]>
Subject: [USRP-users] Phase Offset between USRP-B210 Channels
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Hi all,
I'm saving IQ-Samples from both Channels of an USRP B210 for Direction of 
Arrival Estimation with Music. My source Code is based on the 
rx_multi_samples.cpp example. For tests I connected a sine-generator with a 
splitter to both channels. With a pulse sine a verified that the measured data 
is time aligned. (picture abs_pulse_sine in appendix) But the problem is, that 
there is a phase offset between the two channels of more than 180 degree. 
(picture real_sine and phase_diff) This offset varies by retuning.

I don't understand where this phase offset come from, because the LO of both 
channels is in the same Chip and should be phase aligned. Is this a known 
problem of the B210? Or is there an error in my source code?

Regards,
Stefan Ereth

//
// Copyright 2011 Ettus Research LLC
//
// This program 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 of the License, or
// (at your option) any later version.
//
// This program 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 program.  If not, see <http://www.gnu.org/licenses/>.
//
#define use_short
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <boost/thread.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <iostream>
#include <fstream>
#include <complex>

namespace po = boost::program_options;

int UHD_SAFE_MAIN(int argc, char *argv[]){
    uhd::set_thread_priority_safe();

    //variables to be set by po
    std::string args, sync, subdev, channel_list,file,file0,file1;
    double seconds_in_future, freq;
    size_t total_num_samps;
    double rate,gain,tx_gain;
    std::ofstream outfile,outfile2;

    //setup the program options
    po::options_description desc("Allowed options");
    desc.add_options()
        ("help", "help message")
        ("args", po::value<std::string>(&args)->default_value(""), "single uhd 
device address args")
        ("file", po::value<std::string>(&file)->default_value("measure0-1"), 
"name of the file to write binary samples to")
        ("secs", po::value<double>(&seconds_in_future)->default_value(1.0), 
"number of seconds in the future to receive")
        ("nsamps", po::value<size_t>(&total_num_samps)->default_value(10000), 
"total number of samples to receive")
        ("rate", po::value<double>(&rate)->default_value(8e6), "rate of 
incoming samples")
        ("sync", po::value<std::string>(&sync)->default_value("b210"), 
"synchronization method: now, pps, mimo")
        ("freq", po::value<double>(&freq)->default_value(800e6), "RF center 
frequency in Hz")
        ("gain", po::value<double>(&gain), "gain for the RF chain")
        ("tx-gain", po::value<double>(&tx_gain), "gain for the TX in 
calibration Mode")
        ("subdev", po::value<std::string>(&subdev), "subdev spec (homogeneous 
across motherboards)")
        ("v", "specify to enable inner-loop verbose")
        ("calc","specify to enable transmitting and recording of calibration 
data")
        ("channels", po::value<std::string>(&channel_list)->default_value("0"), 
"which channel(s) to use (specify \"0\", \"1\", \"0,1\", etc)")
    ;
    po::variables_map vm;
    po::store(po::parse_command_line(argc, argv, desc), vm);
    po::notify(vm);

    //print the help message
    if (vm.count("help")){
        std::cout << boost::format("UHD RX Multi Samples %s") % desc << 
std::endl;
        std::cout <<
        "    This is a demonstration of how to receive aligned data from 
multiple channels.\n"
        "    This example can receive from multiple DSPs, multiple 
motherboards, or both.\n"
        "    The MIMO cable or PPS can be used to synchronize the 
configuration. See --sync\n"
        "\n"
        "    Specify --subdev to select multiple channels per motherboard.\n"
        "      Ex: --subdev=\"0:A 0:B\" to get 2 channels on a Basic RX.\n"
        "\n"
        "    Specify --args to select multiple motherboards in a 
configuration.\n"
        "      Ex: --args=\"addr0=192.168.10.2, addr1=192.168.10.3\"\n"
        << std::endl;
        return ~0;
    }

    bool verbose = vm.count("v") == 1;
    bool calibration = vm.count("calc") == 1;
    


    /**************** RX Init *************************************************/
    //create a usrp device
    std::cout << std::endl;
    std::cout << boost::format("Creating the usrp device with: %s...") % args 
<< std::endl;
    uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);

    usrp->set_master_clock_rate(30e6); //less then 30.72e6 //M?glichkeit 1: 
Variable Clock-Rate
    //always select the subdevice first, the channel mapping affects the other 
settings
    if (vm.count("subdev")){
        uhd::usrp::subdev_spec_t subdevClass = subdev;
        std::cout << subdevClass.to_pp_string() << std::endl;
        usrp->set_rx_subdev_spec(subdevClass); //sets across all mboards
    }

    std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << 
std::endl;

    //set the rx sample rate (sets across all channels)
    std::cout << boost::format("Setting RX Rate: %f Msps... ") % (rate/1e6) << 
std::endl;
    usrp->set_rx_rate(rate);
    std::cout << boost::format("Actual RX Rate: %f Msps...") % 
(usrp->get_rx_rate()/1e6) << std::endl << std::endl;

    //set center Frequency
    std::cout << boost::format("Setting RX Freq: %f MHz...") % (freq/1e6) << 
std::endl;
    uhd::tune_request_t tune_request(freq);
    for(size_t i=0;i<usrp->get_rx_num_channels();i++)
        usrp->set_rx_freq(tune_request,i);
    std::cout << boost::format("Actual RX Freq: %f MHz...") % 
(usrp->get_rx_freq(1)/1e6) << std::endl << std::endl;

    //set the rf gain
    if (vm.count("gain")){
        for(size_t i=0;i<usrp->get_rx_num_channels();i++){
            std::cout << boost::format("Setting RX Gain for Channel %d: %f 
dB...") % i % gain << std::endl;
            usrp->set_rx_gain(gain,i);
            std::cout << boost::format("Actual RX Gain: %f dB...") % 
usrp->get_rx_gain() << std::endl << std::endl;
        }
    }

    //open files to write
    if(calibration) file+=".calc"; //Kalibrierdaten mit Endung .calc
    else    file+=".dat";   //Messdaten mit Endung.dat
    file0 = file;
    file1 = file;
    file0 += "0";
    file1 += "1";

    outfile.open(file0.c_str(), std::ofstream::binary);
    if(usrp->get_rx_num_channels()>1){
        outfile2.open(file1.c_str(),std::ofstream::binary);
    }



    /**************** Recieve Start ******************************************/
    //create a receive streamer
    //linearly map channels (index0 = channel0, index1 = channel1, ...)
    uhd::stream_args_t stream_args("sc16"); //complex short

    //stream_args.channels = channel_nums;
    for (size_t i = 0; i < usrp->get_rx_num_channels(); i++)
        stream_args.channels.push_back(i);
    uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);

    //setup streaming
    std::cout << std::endl;
    std::cout << boost::format(
        "Begin receiving of %u samples. Start in %f seconds in the future..."
    ) % total_num_samps % seconds_in_future << std::endl;
    uhd::stream_cmd_t 
stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
    stream_cmd.num_samps = total_num_samps;
    stream_cmd.stream_now = false;
    stream_cmd.time_spec = uhd::time_spec_t(seconds_in_future) + 
usrp->get_time_now();
    rx_stream->issue_stream_cmd(stream_cmd); //tells all channels to stream

    //meta-data will be filled in by recv()
    uhd::rx_metadata_t md;

    //allocate buffers to receive with samples (one buffer per channel)
    const size_t samps_per_buff = rx_stream->get_max_num_samps();
    std::vector<std::vector<std::complex<short> > > buffs(
        usrp->get_rx_num_channels(), std::vector<std::complex<short> 
>(samps_per_buff)
    );

    //create a vector of pointers to point to each of the channel buffers
    std::vector<std::complex<short> *> buff_ptrs;
    for (size_t i = 0; i < buffs.size(); i++) 
buff_ptrs.push_back(&buffs[i].front());

    //the first call to recv() will block this many seconds before receiving
    double timeout = seconds_in_future + 1; //timeout (delay before receive + 
padding)

    size_t num_acc_samps = 0; //number of accumulated samples
    while(num_acc_samps < total_num_samps){
        //receive a single packet
        size_t num_rx_samps = rx_stream->recv(
            buff_ptrs, samps_per_buff, md, timeout
        );

        //use a small timeout for subsequent packets
        timeout = 0.1;

        //handle the error code
        if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
        if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){
            throw std::runtime_error(str(boost::format(
                "Receiver error %s"
            ) % md.strerror()));
        }

        if(verbose) std::cout << boost::format(
            "Received packet: %u samples, %u full secs, %f frac secs"
        ) % num_rx_samps % md.time_spec.get_full_secs() % 
md.time_spec.get_frac_secs() << std::endl;

        //Schreiben der gelesenen Werte in die Dateien
        if(outfile.is_open())
            outfile.write((const char 
*)&buffs[0].front(),num_rx_samps*sizeof(buffs[0].front()));
        if(outfile2.is_open())
            outfile2.write((const char 
*)&buffs[1].front(),num_rx_samps*sizeof(buffs[1][0]));

        num_acc_samps += num_rx_samps;
    }

    if (num_acc_samps < total_num_samps) std::cerr << "Receive timeout before 
all samples received..." << std::endl;
    /**************************** Recieve End 
*******************************************************/
    if(outfile.is_open())
        outfile.close();
    if(outfile2.is_open())
        outfile2.close();

    //finished
    std::cout << std::endl << "Done! Mine" << std::endl << std::endl;

    return EXIT_SUCCESS;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: real_sine.png
Type: image/png
Size: 74238 bytes
Desc: not available
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20140502/4efb48f7/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phase_diff.png
Type: image/png
Size: 16884 bytes
Desc: not available
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20140502/4efb48f7/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abs_pulse_sine.png
Type: image/png
Size: 53427 bytes
Desc: not available
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20140502/4efb48f7/attachment-0005.png>

------------------------------

Message: 6
Date: Fri, 02 May 2014 11:48:36 -0400
From: "Marcus D. Leech via USRP-users" <[email protected]>
To: [email protected]
Subject: Re: [USRP-users] Phase Offset between USRP-B210 Channels
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"

On 05/02/2014 02:30 AM, Stefan Ereth via USRP-users wrote:
> Hi all,
> I'm saving IQ-Samples from both Channels of an USRP B210 for Direction of 
> Arrival Estimation with Music. My source Code is based on the 
> rx_multi_samples.cpp example. For tests I connected a sine-generator with a 
> splitter to both channels. With a pulse sine a verified that the measured 
> data is time aligned. (picture abs_pulse_sine in appendix) But the problem 
> is, that there is a phase offset between the two channels of more than 180 
> degree. (picture real_sine and phase_diff) This offset varies by retuning.
>
> I don't understand where this phase offset come from, because the LO of both 
> channels is in the same Chip and should be phase aligned. Is this a known 
> problem of the B210? Or is there an error in my source code?
>
> Regards,
> Stefan Ereth
>
> //
> // Copyright 2011 Ettus Research LLC
> //
> // This program 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 of the License, or
> // (at your option) any later version.
> //
> // This program 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 program.  If not, see<http://www.gnu.org/licenses/>.
> //
> #define use_short
> #include<uhd/utils/thread_priority.hpp>
> #include<uhd/utils/safe_main.hpp>
> #include<uhd/usrp/multi_usrp.hpp>
> #include<boost/program_options.hpp>
> #include<boost/format.hpp>
> #include<boost/thread.hpp>
> #include<boost/lexical_cast.hpp>
> #include<boost/algorithm/string.hpp>
> #include<iostream>
> #include<fstream>
> #include<complex>
>
> namespace po = boost::program_options;
>
> int UHD_SAFE_MAIN(int argc, char *argv[]){
>      uhd::set_thread_priority_safe();
>
>      //variables to be set by po
>      std::string args, sync, subdev, channel_list,file,file0,file1;
>      double seconds_in_future, freq;
>      size_t total_num_samps;
>      double rate,gain,tx_gain;
>      std::ofstream outfile,outfile2;
>
>      //setup the program options
>      po::options_description desc("Allowed options");
>      desc.add_options()
>          ("help", "help message")
>          ("args", po::value<std::string>(&args)->default_value(""), "single 
> uhd device address args")
>          ("file", po::value<std::string>(&file)->default_value("measure0-1"), 
> "name of the file to write binary samples to")
>          ("secs", po::value<double>(&seconds_in_future)->default_value(1.0), 
> "number of seconds in the future to receive")
>          ("nsamps", 
> po::value<size_t>(&total_num_samps)->default_value(10000), "total number of 
> samples to receive")
>          ("rate", po::value<double>(&rate)->default_value(8e6), "rate of 
> incoming samples")
>          ("sync", po::value<std::string>(&sync)->default_value("b210"), 
> "synchronization method: now, pps, mimo")
>          ("freq", po::value<double>(&freq)->default_value(800e6), "RF center 
> frequency in Hz")
>          ("gain", po::value<double>(&gain), "gain for the RF chain")
>          ("tx-gain", po::value<double>(&tx_gain), "gain for the TX in 
> calibration Mode")
>          ("subdev", po::value<std::string>(&subdev), "subdev spec 
> (homogeneous across motherboards)")
>          ("v", "specify to enable inner-loop verbose")
>          ("calc","specify to enable transmitting and recording of calibration 
> data")
>          ("channels", 
> po::value<std::string>(&channel_list)->default_value("0"), "which channel(s) 
> to use (specify \"0\", \"1\", \"0,1\", etc)")
>      ;
>      po::variables_map vm;
>      po::store(po::parse_command_line(argc, argv, desc), vm);
>      po::notify(vm);
>
>      //print the help message
>      if (vm.count("help")){
>          std::cout<<  boost::format("UHD RX Multi Samples %s") % desc<<  
> std::endl;
>          std::cout<<
>          "    This is a demonstration of how to receive aligned data from 
> multiple channels.\n"
>          "    This example can receive from multiple DSPs, multiple 
> motherboards, or both.\n"
>          "    The MIMO cable or PPS can be used to synchronize the 
> configuration. See --sync\n"
>          "\n"
>          "    Specify --subdev to select multiple channels per motherboard.\n"
>          "      Ex: --subdev=\"0:A 0:B\" to get 2 channels on a Basic RX.\n"
>          "\n"
>          "    Specify --args to select multiple motherboards in a 
> configuration.\n"
>          "      Ex: --args=\"addr0=192.168.10.2, addr1=192.168.10.3\"\n"
>          <<  std::endl;
>          return ~0;
>      }
>
>      bool verbose = vm.count("v") == 1;
>      bool calibration = vm.count("calc") == 1;
>
>
>
>      /**************** RX Init 
> *************************************************/
>      //create a usrp device
>      std::cout<<  std::endl;
>      std::cout<<  boost::format("Creating the usrp device with: %s...") % 
> args<<  std::endl;
>      uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);
>
>      usrp->set_master_clock_rate(30e6); //less then 30.72e6 //M?glichkeit 1: 
> Variable Clock-Rate
>      //always select the subdevice first, the channel mapping affects the 
> other settings
>      if (vm.count("subdev")){
>          uhd::usrp::subdev_spec_t subdevClass = subdev;
>          std::cout<<  subdevClass.to_pp_string()<<  std::endl;
>          usrp->set_rx_subdev_spec(subdevClass); //sets across all mboards
>      }
>
>      std::cout<<  boost::format("Using Device: %s") % usrp->get_pp_string()<< 
>  std::endl;
>
>      //set the rx sample rate (sets across all channels)
>      std::cout<<  boost::format("Setting RX Rate: %f Msps... ") % 
> (rate/1e6)<<  std::endl;
>      usrp->set_rx_rate(rate);
>      std::cout<<  boost::format("Actual RX Rate: %f Msps...") % 
> (usrp->get_rx_rate()/1e6)<<  std::endl<<  std::endl;
>
>      //set center Frequency
>      std::cout<<  boost::format("Setting RX Freq: %f MHz...") % (freq/1e6)<<  
> std::endl;
>      uhd::tune_request_t tune_request(freq);
>      for(size_t i=0;i<usrp->get_rx_num_channels();i++)
>          usrp->set_rx_freq(tune_request,i);
>      std::cout<<  boost::format("Actual RX Freq: %f MHz...") % 
> (usrp->get_rx_freq(1)/1e6)<<  std::endl<<  std::endl;
>
>      //set the rf gain
>      if (vm.count("gain")){
>          for(size_t i=0;i<usrp->get_rx_num_channels();i++){
>              std::cout<<  boost::format("Setting RX Gain for Channel %d: %f 
> dB...") % i % gain<<  std::endl;
>              usrp->set_rx_gain(gain,i);
>              std::cout<<  boost::format("Actual RX Gain: %f dB...") % 
> usrp->get_rx_gain()<<  std::endl<<  std::endl;
>          }
>      }
>
>      //open files to write
>      if(calibration) file+=".calc"; //Kalibrierdaten mit Endung .calc
>      else    file+=".dat";   //Messdaten mit Endung.dat
>      file0 = file;
>      file1 = file;
>      file0 += "0";
>      file1 += "1";
>
>      outfile.open(file0.c_str(), std::ofstream::binary);
>      if(usrp->get_rx_num_channels()>1){
>          outfile2.open(file1.c_str(),std::ofstream::binary);
>      }
>
>
>
>      /**************** Recieve Start 
> ******************************************/
>      //create a receive streamer
>      //linearly map channels (index0 = channel0, index1 = channel1, ...)
>      uhd::stream_args_t stream_args("sc16"); //complex short
>
>      //stream_args.channels = channel_nums;
>      for (size_t i = 0; i<  usrp->get_rx_num_channels(); i++)
>          stream_args.channels.push_back(i);
>      uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
>
>      //setup streaming
>      std::cout<<  std::endl;
>      std::cout<<  boost::format(
>          "Begin receiving of %u samples. Start in %f seconds in the future..."
>      ) % total_num_samps % seconds_in_future<<  std::endl;
>      uhd::stream_cmd_t 
> stream_cmd(uhd::stream_cmd_t::STREAM_MODE_NUM_SAMPS_AND_DONE);
>      stream_cmd.num_samps = total_num_samps;
>      stream_cmd.stream_now = false;
>      stream_cmd.time_spec = uhd::time_spec_t(seconds_in_future) + 
> usrp->get_time_now();
>      rx_stream->issue_stream_cmd(stream_cmd); //tells all channels to stream
>
>      //meta-data will be filled in by recv()
>      uhd::rx_metadata_t md;
>
>      //allocate buffers to receive with samples (one buffer per channel)
>      const size_t samps_per_buff = rx_stream->get_max_num_samps();
>      std::vector<std::vector<std::complex<short>  >  >  buffs(
>          usrp->get_rx_num_channels(), std::vector<std::complex<short>  
> >(samps_per_buff)
>      );
>
>      //create a vector of pointers to point to each of the channel buffers
>      std::vector<std::complex<short>  *>  buff_ptrs;
>      for (size_t i = 0; i<  buffs.size(); i++) 
> buff_ptrs.push_back(&buffs[i].front());
>
>      //the first call to recv() will block this many seconds before receiving
>      double timeout = seconds_in_future + 1; //timeout (delay before receive 
> + padding)
>
>      size_t num_acc_samps = 0; //number of accumulated samples
>      while(num_acc_samps<  total_num_samps){
>          //receive a single packet
>          size_t num_rx_samps = rx_stream->recv(
>              buff_ptrs, samps_per_buff, md, timeout
>          );
>
>          //use a small timeout for subsequent packets
>          timeout = 0.1;
>
>          //handle the error code
>          if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) break;
>          if (md.error_code != uhd::rx_metadata_t::ERROR_CODE_NONE){
>              throw std::runtime_error(str(boost::format(
>                  "Receiver error %s"
>              ) % md.strerror()));
>          }
>
>          if(verbose) std::cout<<  boost::format(
>              "Received packet: %u samples, %u full secs, %f frac secs"
>          ) % num_rx_samps % md.time_spec.get_full_secs() % 
> md.time_spec.get_frac_secs()<<  std::endl;
>
>          //Schreiben der gelesenen Werte in die Dateien
>          if(outfile.is_open())
>              outfile.write((const char 
> *)&buffs[0].front(),num_rx_samps*sizeof(buffs[0].front()));
>          if(outfile2.is_open())
>              outfile2.write((const char 
> *)&buffs[1].front(),num_rx_samps*sizeof(buffs[1][0]));
>
>          num_acc_samps += num_rx_samps;
>      }
>
>      if (num_acc_samps<  total_num_samps) std::cerr<<  "Receive timeout 
> before all samples received..."<<  std::endl;
>      /**************************** Recieve End 
> *******************************************************/
>      if(outfile.is_open())
>          outfile.close();
>      if(outfile2.is_open())
>          outfile2.close();
>
>      //finished
>      std::cout<<  std::endl<<  "Done! Mine"<<  std::endl<<  std::endl;
>
>      return EXIT_SUCCESS;
> }
>
>
> _______________________________________________
> USRP-users mailing list
> [email protected]
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
What are you passing in for the subdev argument?

What does

usrp->get_rx_num_channels()


Return in this example?


-- 
Marcus Leech
Principal Investigator
Shirleys Bay Radio Astronomy Consortium
http://www.sbrac.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.ettus.com/pipermail/usrp-users_lists.ettus.com/attachments/20140502/a7214738/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
USRP-users mailing list
[email protected]
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com


------------------------------

End of USRP-users Digest, Vol 45, Issue 2
*****************************************

Reply via email to