USRP data sample values incorrect


#1

Hi,I am trying to capture the data samples from the USB port of USRP
using
the following code:

#include “usrp_standard.h”

// Dumy Function to process USRP data
void process_data(int buffer)
{
}
#define SAMPELS_PER_READ (512) // Must be a multiple of 128
int main (int argc, char **argv)
{
bool loopback_p = false;
bool counting_p = false;
bool width_8_p = false;
int which_board = 0;
int decim = 8; // 32 MB/sec
double center_freq = 0;
int fusb_block_size = 0;
int fusb_nblocks = 0;
int nchannels = 1;
int gain = 0;
int mode = 0;
int noverruns = 0;
bool overrun;
int total_reads = 10000;
int i;
int buf[SAMPELS_PER_READ];
int bufsize = SAMPELS_PER_READ
4;

if (loopback_p) mode |= usrp_standard_rx::FPGA_MODE_LOOPBACK;

if (counting_p) mode |= usrp_standard_rx::FPGA_MODE_COUNTING;

usrp_standard_rx_sptr urx = usrp_standard_rx::make (which_board, decim,
1,
-1, mode, fusb_block_size, fusb_nblocks);

if (urx.px == 0)
{
fprintf (stderr, “Error: usrp_standard_rx::make\n”);
exit (1);
}

if (width_8_p)
{
int width = 8;
int shift = 8;
bool want_q = true;
if (!urx->set_format(usrp_standard_rx::make_format(width, shift,
want_q)))
{
fprintf (stderr, “Error: urx->set_format\n”);
exit (1);
}
}
// Set DDC center frequency
urx->set_rx_freq (0, center_freq);
// Set Number of channels
urx->set_nchannels(1);
// Set ADC PGA gain
urx->set_pga(0,gain);
// Set FPGA Mux
urx->set_mux(0x32103210); // Board A only
// Set DDC decimation rate
urx->set_decim_rate(decim);
// Set DDC phase
urx->set_ddc_phase(0,0);

urx->start(); // Start data transfer

printf(“USRP Transfer Started\n”);
// Do USRP Samples Reading
for (i = 0; i < total_reads; i++)
{
urx->read(&buf, bufsize, &overrun);
if (overrun)
{
printf (“USRP Rx Overrun\n”);
noverruns++;
}
// Do whatever you want with the data
process_data(&buf[0]);
}

urx->stop(); // Stop data transfer
printf(“USRP Transfer Stoped\n”);

//delete urx;
return 0;
}

However I am getting the following values of data samples:

0
0
65535
0
0
0
65533
-1
6
65533
-131076
0
65537
1
0
65536
-131076
-196608
-65536
-65536

Now, these data values are not possible as the data samples from USRP
are 16
bit signed integer values, therefore they should lie in the range of
-32768
to +32768. I can’t understand the problem. Can someone please explain?

Thanks.


#2

On Mon, May 25, 2009 at 12:10:59PM +0600, Ujala Q. wrote:

Hi,I am trying to capture the data samples from the USB port of USRP using
the following code:

#include “usrp_standard.h”

int buf[SAMPELS_PER_READ];
int bufsize = SAMPELS_PER_READ*4;

// Do USRP Samples Reading
for (i = 0; i < total_reads; i++)
{
urx->read(&buf, bufsize, &overrun);

You are trying to pass the address of the address of the buffer.

The line should be:

urx->read(buf, bufsize, &overrun);

Eric


#3

I made the change and I am still getting the same values.


#4

The following article states that ideally the sample values should be
symmetric about 0, when tuned to 100.1 MHz. And the values shown are
between
-70 and 170:http://www.linuxjournal.com/article/7505

However my values are very big. What could be the problem?
Also when I set my center_freq to 100100000 (100.1 MHz, in set_rx_freq
function), will the USRP automatically be detecting signals in te FM
band?