discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss-gnuradio] USRP data sample values incorrect


From: Ujala Qasim
Subject: [Discuss-gnuradio] USRP data sample values incorrect
Date: Mon, 25 May 2009 12:10:59 +0600

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. 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]