Main Content

capture

Capture RF signal data using USRP radio

Since R2023b

Description

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

[data,metadata] = capture(rx,length,unit) specifies the capture length unit. The function converts length units into N samples and returns ceil(N) samples.

[data,metadata,timestamp] = capture(rx,length,unit) also returns the timestamp of each received sample from a USRP radio.

example

[data,metadata,timestamp] = capture(___,Filename=filename) specifies filename, a filename for the captured data, in addition to inputs from any of the prior syntaxes. The function saves the captured data and metadata to a baseband file reader file named filename.

Examples

collapse all

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

Configure SDR Hardware

If your radio hardware is already configured for host-radio communication, skip this section. To configure your radio hardware for host-radio communication, follow the steps in the Guided USRP Radio Support Package Hardware Setup. Attach an antenna suitable for the 2.4GHz band to the first RX channel.

Configure Receiver System Object

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

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

Initiate Data Capture

Call the capture function, specifying the receiver object and a capture duration. The function returns the captured 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 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 function uses this object to communicate with the USRP radio connected to the host computer.

Capture duration, specified as a positive scalar. 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. Specify the unit of capture duration as samples or seconds in the unit argument.

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 rx. The function returns ceil(N) samples.

Filename for saving captured data and metadata, specified as a character vector or string scalar. When you specify this input, the function saves the captured data and metadata to a baseband file. To read this file, use the comm.BasebandFileReader System object. The saved file has the .bb extension.

Example: "rxdata" or "rxdata.bb" configures the function to save data to a file with the name rxdata and the .bb extension.

Data Types: char | string

Output Arguments

collapse all

Output signal received from the radio hardware, returned as a complex-valued matrix. The number of columns in the matrix depends on the number of channels in use, as specified by the ChannelMapping property of the input receiver rx. Each column corresponds to a channel of complex data received on one channel. The number of rows equals the length of received data.

The output signal supports complex values with these data types:

  • 8-bit signed integers — Output values are the raw 8-bit I and Q samples from the board.

  • 16-bit signed integers — Output values are the raw 16-bit in-phase (I) and quadrature phase (Q) samples from the USRP radio.

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

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

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

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

Capture-time configuration settings for the SDR device, returned as a structure that contains these fields:

FieldDescription
Date

Date and time of the data capture.

BasebandSampleRate

Baseband sampling rate, in Hz, configured in the SDR device.

CenterFrequency

Center frequency, in Hz, configured in the SDR device.

DeviceName

Name of the SDR USRP device.

ChannelMapping

Channel mapping value configured in the SDR device.

CaptureLengthSamples

Capture length in samples.

CaptureLengthSeconds

Capture length in seconds.

SDRuReceiverConfiguration

List of property values and settings that describe the System object state.

Gain

Gain value, in dB, configured in the SDR device.

GainSource

Gain source value configured in the SDR device.

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 to "GPSDO".

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

Version History

Introduced in R2023b