Main Content

capture

Capture RF data using SDRu receiver

Since R2023b

Add-On Required: This feature requires the Communications Toolbox Support Package for USRP Radio add-on.

Description

[data,metadata] = capture(rx,length) captures ceil(length) continuous data samples using the USRP™ radio hardware associated with a comm.SDRuReceiver System object™ rx. The function returns the captured data samples, data, and the capture-time configuration settings for the radio device, metadata.

example

[data,metadata] = capture(rx,length,unit) specifies the capture length unit, unit, in addition to the input arguments in the previous syntax. The function converts length units into N samples and returns ceil(N) samples.

example

[data,metadata,timestamp] = capture(rx,length,unit) returns the timestamp of each received sample from a USRP radio, timestamp, in addition to the output arguments in the previous syntaxes.

example

[data,metadata,timestamp] = capture(___,Filename=filename) saves the captured data and metadata to a baseband file reader file named filename.

Examples

collapse all

First, configure your radio hardware for host-radio communication by following the steps in Guided USRP Radio Support Package Hardware Setup. Create a comm.SDRuReceiver System object for your USRP radio.

rx = comm.SDRuReceiver
rx = 
  comm.SDRuReceiver with properties:

                 Platform: 'N200/N210/USRP2'
                IPAddress: '192.168.10.2'
           ChannelMapping: 1
          CenterFrequency: 2.4500e+09
    LocalOscillatorOffset: 0
                     Gain: 8
                PPSSource: 'Internal'
        EnableTimeTrigger: false
              ClockSource: 'Internal'
      EnableMIMOCableSync: false
          MasterClockRate: 100000000
         DecimationFactor: 512
        TransportDataType: 'int16'
           OutputDataType: 'Same as transport data type'
          SamplesPerFrame: 362
          EnableBurstMode: false

Set the decimation factor to 250 and the center frequency to 2 GHz.

rx.DecimationFactor = 250; 
rx.CenterFrequency = 2e9;

Capture 1 second of RF data.

[data,metadata]= capture(rx,1,"Seconds");

Release the hardware resources.

release(rx);

Use the capture function and a USRP™ radio to capture WLAN signals.

Configure SDR Hardware

To configure your radio hardware for host-radio communication, see Guided USRP Radio Support Package Hardware Setup. Attach an antenna that is compatible with the 2.4 GHz band to the first RX channel.

Configure Receiver System Object

Create a receiver System object and set the center frequency to 2.4 GHz.

centerFrequency = 2.4e9;
rx = comm.SDRuReceiver(Platform = 'B210',SerialNum = '3136D5F',...
    MasterClockRate = 60e6,DecimationFactor = 3,...
    CenterFrequency = centerFrequency,...
    OutputDataType = 'double',Gain=61);

Initiate Data Capture

Call the capture function by specifying the receiver object and a capture duration. The function returns the captured data in data, the configuration settings in the structure metadata, and the timestamp of each received sample in a column vector timestamp. After capturing the WLAN signal, unlock the receiver object by using the release function.

[data,metadata,timestamp]= capture(rx,5,'Seconds');
linux; GNU C++ version 10.3.0; Boost_107800; UHD_4.2.0.0-vendor

---------- see libuhd version information above this line ----------
release(rx);

To calculate the sample rate, divide the master clock rate by the decimation factor. Use the spectrumAnalyzer System object to visualize the received WLAN signal.

sampleRate = rx.MasterClockRate/rx.DecimationFactor;
scope = spectrumAnalyzer(SampleRate=sampleRate);
scope(data)
release(scope);

usrp_capture.png

Input Arguments

collapse all

Receiver, specified as a comm.SDRuReceiver System object. The capture function uses this object to communicate with the USRP radio connected to the host computer.

Capture duration, specified as a positive scalar. Specify the unit of capture duration as samples or seconds using the unit input argument.

The maximum number of samples you can capture is 256e6. When you set the ChannelMapping property, the object restricts the number of samples per channel to equal fractions of 256e6 divided by the number of channels.

Data Types: double

Capture duration unit, specified as one of these values:

  • "Samples" — The function returns ceil(length) samples.

  • "Seconds" — The function converts length seconds into N samples based on the BasebandSampleRate property of the input receiver System object rx. The function returns ceil(N) samples.

File name for saving captured data and metadata, specified as a string scalar or character vector. Use this option to save the captured data and metadata to a baseband file. If the file name does not include an extension, the function appends the file name with .bb.

To read the baseband file, use the comm.BasebandFileReader System object.

Example: "rxdata.bb" or "rxdata"

Data Types: char | string

Output Arguments

collapse all

Output signal, returned as a complex-valued matrix. The number of columns in the matrix depends on the number of channels specified by the ChannelMapping property of the input receiver System object rx. Each column contains the complex data received on one channel. The number of rows is equal to the length of the received data.

The output signal supports complex values with these data types:

  • 8-bit signed integers — data is the raw 8-bit in-phase (I) and quadrature phase (Q) samples from the board.

  • 16-bit signed integers — data is the raw 16-bit I and Q samples from the USRP radio.

  • Single-precision floating point — data is the scaled output values in the range [–1, 1].

  • Double-precision floating point — data is the scaled output values in the range [–1, 1].

To specify the data type, use the OutputDataType property of the input receiver System object rx.

Data Types: int8 | int16 | single | double
Complex Number Support: Yes

Capture-time configuration settings of the radio device, returned as a structure containing these fields. The radio device is the USRP radio associated with the input receiver rx.

FieldDescription
Date

Date and time of the data capture.

DeviceName

Model number of the USRP radio device.

ChannelMapping

Channel mapping value of the radio device.

BasebandSampleRate

Baseband sample rate in Hz of the radio device.

CaptureLengthSamples

Capture length in samples.

CaptureLengthSeconds

Capture length in seconds.

CenterFrequency

Center frequency in Hz of the radio device.

GainSource

Gain source of the radio device, returned as either "Input Port" or "Property".

Gain

Gain value in dB of the radio device.

SDRuReceiverConfiguration

Structure than includes the property values and settings that describe the System object state of the input receiver rx.

Data Types: struct

Timestamp of each received sample, returned as a column vector. The length of this output equals the length of received data.

  • To get the GPS timestamp of each received sample from a USRP radio, set the PPSSource property of the input receiver System object rx to "GPSDO".

  • To get the timestamp of each received sample from bundled radios, set the PPSSource property of the input receiver System object rx to "GPSDO" or "External".

Version History

Introduced in R2023b

expand all

See Also

Functions

Objects