Hi all,
I’m trying to capture some over-the-air data using a USRP and a RFX2400
card. Using usrp_fft.py or usrp_rx_cfile.py works fine as long as the
decimation rate is 8 or above. Unfortunately my signal has a 10MHz
bandwidth, so I would like to use a decimation rate of 4 (16Msps I&Q).
This
results in overflows due to the USB rate. It seems that the normal
solution
for this is to enable 8 bit samples. Both usrp_fft.py and
usrp_rx_cfile.py
have a “-8” option, however when I use that option the data is all
zeroes.
So, I snooped around and found a C++ file by Firas A. Hamza that
removed
the python hocus pocus and talked to the usrp library directly. Same
problem
- works fine as long as the 8 bit sample transfer is not enabled.
I also tried this with a DBSRX daughter card (and an appropriate
frequency).
Same problem.
Has anyone had any luck using 8 bit sample mode lately? I’ve included
theC++
file below (Note: had to modify it to use shared pointers).
Thanks,
Mike
// Simple C++ USRP interfacing demonstration program
//
//
// This program modified from C++ code found in document:
// The USRP under 1.5X Magnifying Lens!
// By:
// Firas A. Hamza
// Rev 1.0
// Last updated: 12-Jun-2008
// This program was derived and modified from test_usrp_standard_rx.cc
/* -- c++ -- /
/
- Copyright 2003,2006,2007,2008 Free Software Foundation, Inc.
- This file is part of GNU Radio
- GNU Radio 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.
- GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
- the Free Software Foundation, Inc., 51 Franklin Street,
- Boston, MA 02110-1301, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include “usrp_standard.h”
#define SAMPLES_PER_READ (512) // Must be a
multiple
of 128
// Dumy Function to process USRP data
void process_data(int *buffer)
{
int i;
int max = 0;
for (i = 0; i < SAMPLES_PER_READ; i++)
{
if (buffer[i] > max)
{
max = buffer[i];
}
}
printf(“max: %d\n”, max);
}
int
main (int argc, char **argv)
{
bool width_8_p = true;
int which_board = 0;
int decim = 64;
double center_freq = 2647000000;
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[SAMPLES_PER_READ];
int bufsize = SAMPLES_PER_READ*4;
// usrp_standard_rx *urx = usrp_standard_rx::make (which_board, decim,
1,
-1, mode,
// fusb_block_size, fusb_nblocks);
usrp_standard_rx_sptr urx = usrp_standard_rx::make (which_board,
decim, 1,
-1, mode, fusb_block_size, fusb_nblocks, “std_4rx_0tx.rbf”);
if (urx == 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,
true)))
{
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;
}