[USRP-users] USRP2 MATLAB

Mike McLernon Mike.McLernon at mathworks.com
Fri Feb 10 08:31:16 EST 2012


Hi Kaleem,

You are incrementing your timeCounter variable by 1 on each iteration of the loop, so that the loop executes only 10 times.  In the original FRS demo, the timeCounter incremented by frsRx.USRPFrameTime, which was considerably smaller than 1 second.  Thus, in that demo, the loop ran many times.

It's possible that MATLAB is running more quickly than the hardware, such that there is no data available from the USRP when MATLAB is looking for it.  Try making your time increment much smaller, so that the loop executes a lot more.  In that case, you should certainly have some time hits when the USRP does indeed have data to send to MATLAB.

Cheers,
Mike


-----Original Message-----
From: usrp-users-bounces at lists.ettus.com [mailto:usrp-users-bounces at lists.ettus.com] On Behalf Of Kaleem Ahmad
Sent: Friday, February 10, 2012 5:15 AM
To: usrp-users at lists.ettus.com
Subject: [USRP-users] USRP2 MATLAB

Hello everyone, 

I am using USRP2 with XCVR2450 daughter card with Windows XP and MATLAB R2011a in 2.4GHz ISM band. 

I am trying to implement a simple spectrum analyzer (based on energy detection) with MATLAB's SDRu package (NOT Simulink!!!). I started with a demo provided with the SDRu package (sdruFRSGMRSReceiver.m) and changed it to implement a simple fftplot. I am using fftplot.m given on following link: 

http://gnuradio.org/redmine/projects/gnuradio/repository/revisions/master/show/gnuradio-core/src/utils

Here is my code: 

---------USRP2 parameters--------------- 

USRP_SAMPLE_RATE            = 100e6;   
params.USRPDecimationFactor = 4;     
params.USRPGain             = 5;       

params.FrontEndSampleRate   = USRP_SAMPLE_RATE/params.USRPDecimationFactor; 
params.USRPFrameLength      = 1024; 

------------SDRu initilization------------- 

if strcmp(findsdru, 'No devices found')
  hSDRu = comm.SDRuReceiver( ... 
    'CenterFrequencySource', 'Input port', ... 
    'Gain',                  frsRx.USRPGain, ... 
    'DecimationFactor',      frsRx.USRPDecimationFactor, ... 
    'SampleRate',            frsRx.FrontEndSampleRate, ... 
    'FrameLength',           frsRx.USRPFrameLength, ... 
    'OutputDataType',        'single') 
  usrpAvailable = false;
else
  hSDRu = comm.SDRuReceiver('192.168.10.2', ... 
    'CenterFrequencySource', 'Input port', ... 
    'Gain',                  frsRx.USRPGain, ... 
    'DecimationFactor',      frsRx.USRPDecimationFactor, ... 
    'SampleRate',            frsRx.FrontEndSampleRate, ... 
    'FrameLength',           frsRx.USRPFrameLength, ... 
    'OutputDataType',        'single') 
  usrpAvailable = true;
end 

% Get the carrier frequency for the selected channel fc = convertChan2Freq(channel); 


------------main loop of my program----------------- 

  % Loop until it reaches the target stop time. 
  timeCounter = 0; 
  StopTime = 10 
  
   while timeCounter < StopTime 

    [data, len] = step(hSDRu, fc); 
    
    figure 
    plotfft (data, frsRx.FrontEndSampleRate) 

    timeCounter = timeCounter + 1; 
    
  end 

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

Using this code, I never see any signals in my plots, which are actually there as I can see from a spectrum analyzer which I have at my desk. In my plot I see only one peak at center frequency. 

My USRP2/MATLAB setup, SD card, UHD etc are all properly configured and working fine since I have tested with MATLAB's demos. 

My first question, is it correct way to configure the USRP2 using MATLAB. I mean I am only setting gain, decimation, samplerate, and frame length- Is anything else is required. 

Otherwise, should I do something between reading data from USRP2 (i.e.[data, len] = step(hSDRu, fc); 
) and fftplot().  I mean I am directly computing FFT using data read from USRP2, Is it correct OR should something else be done to prepare this data??? 

In [data, len] = step(hSDRu, fc), 'len' is always 0 even though I am getting some complex numbers in 'data', can you please comment why this is so. 

Best Regards 


Kaleem Ahmad


_______________________________________________
USRP-users mailing list
USRP-users at lists.ettus.com
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com




More information about the USRP-users mailing list