Main Content

preambleDetector

Configure SDR as preamble detector

Since R2022a

Description

Use the preambleDetector object to configure the specified software-defined radio (SDR) as a preamble detector. You can use the preamble detector to detect and capture a signal of interest from the air using a correlation with a known preamble sequence. The object specifies the preamble sequence and the thresholding and triggering parameters. For more details on the internal architecture of the preamble detector, see Algorithms.

This diagram shows a conceptual overview of detecting and capturing radio signals in Wireless Testbench™ using a radio that you configure with this object. The object also enables you to send a test waveform for detection and capture. The onboard data buffering ensures contiguous data capture and transmit.

Arrows appoint the path of the captured data and the path of the transmit waveform. The captured data path consists of radio antenna, preamble detection, onboard memory, and MATLAB. The transmit waveform path consists of MATLAB, onboard memory, and radio antenna.

Creation

Description

example

pd = preambleDetector(radio) creates a preamble detector configuration object for the specified radio, radio.

Note

The object requires exclusive access to radio hardware resources. Before creating this object, clear any existing Wireless Testbench object associated with the specified radio from the workspace.

example

pd = preambleDetector(radio,Name=Value) sets properties using one or more name-value arguments. For example, CaptureDataType="double" sets the data type of the returned captured signal to double.

Input Arguments

expand all

Radio setup configuration, specified as a string scalar. To create a radio setup configuration, set up your radio and save your radio setup configuration using the Radio Setup wizard. To list all saved radio setup configurations, call the radioConfigurations function.

For a list of supported radios, see Supported Radio Devices.

Example: "MyRadio" indicates that you saved a radio setup configuration under the name MyRadio in the Radio Setup wizard.

Properties

expand all

Capture center frequency in Hz, specified as a positive numeric scalar. The valid center frequency range depends on the radio device.

Radio DeviceCenter Frequency

USRP™ N310

1 MHz to 6 GHz

USRP N320

1 MHz to 6 GHz

USRP N321

1 MHz to 6 GHz

USRP X310

10 MHz to 6 GHz

USRP X410

1 MHz to 8 GHz

Data Types: double

Capture radio gain in dB, specified as a positive numeric scalar. The valid gain range depends on the radio device.

Radio DeviceCapture Radio Gain

USRP N310

0 dB to 75 dB

USRP N320

0 dB to 60 dB

USRP N321

0 dB to 60 dB

USRP X310

0 dB to 31.5 dB

USRP X410

0 dB to 60 dB

Data Types: double

Capture radio antenna, specified as a string scalar. Use this table to identify a supported radio antenna port on the radio device and the corresponding string constant that you can specify for this property. The default value depends on the radio.

Radio DeviceSupported Antenna PortString Scalar

USRP N310

RF0 channel: RX2 port"RF0:RX2" (default)
RF1 channel: RX2 port"RF1:RX2"
RF2 channel: RX2 port"RF2:RX2"
RF3 channel: RX2 port"RF3:RX2"

USRP N320

RF0 channel: RX2 port"RF0:RX2" (default)
RF1 channel: RX2 port"RF1:RX2"

USRP N321

RF0 channel: RX2 port"RF0:RX2" (default)
RF1 channel: RX2 port"RF1:RX2"

USRP X310

RFA channel: RX2 port

"RFA:RX2" (default)

RFB channel: RX2 port

"RFB:RX2"

USRP X410

DB0 RF0 channel: RX 1 port

"DB0:RF0:RX1" (default)

DB0 RF1 channel: RX 1 port

"DB0:RF1:RX1"

DB1 RF0 channel: RX 1 port

"DB1:RF0:RX1"

DB1 RF1 channel: RX 1 port

"DB1:RF1:RX1"

Note

When you update this property, the execution time of the next object function call increases by a few seconds.

Data Types: string

Baseband sample rate in Hz, specified as a positive numeric scalar. For more information on how the radio achieves the specified sample rate, see Baseband Sample Rate in NI USRP Radios.

The sample rate depends on the radio device.

Radio DeviceSample Rate

USRP N310

  • 120,945 Hz to 76.8 MHz

  • 122.88 MHz

  • 125.00 MHz

  • 153.60 MHz (default)

USRP N320

  • 196,851 Hz to 125 MHz

  • 200.00 MHz

  • 245.76 MHz

  • 250.00 MHz (default)

USRP N321

  • 196,851 Hz to 125 MHz

  • 200.00 MHz

  • 245.76 MHz

  • 250.00 MHz (default)

USRP X310

  • 181,418 Hz to 100 MHz

  • 184.32 MHz

  • 200.00 MHz (default)

USRP X410

  • 241,890 Hz to 125 MHz

  • 245.76 MHz

  • 250.00 MHz (default)

Note

To update this property, you must stop any ongoing transmission by calling the stopTransmission function on the object. When you update this property, the execution time of the next object function call increases by a few seconds.

Data Types: double

Data type of the captured data, specified as "int16", "double", or "single". Use this property to set the data type of the captured data that the capture object function returns.

Note

When you update this property, the execution time of the next object function call increases by a few seconds.

Data Types: string

Since R2024a

Unit of capture request timestamp, specified as "datetime" or "sample-clock-cycle". Use this property to set the data type of the timestamp that the capture object function returns.

Data Types: string

Behavior of the capture or plotThreshold object functions upon dropped samples, specified as one of these values.

  • "error" — The object function stops with an error message.

  • "warning" — The object function displays a warning message.

  • "none" — The object function ignores dropped samples.

Data Types: string

Preamble sequence, specified as a numeric column vector of length between 4 and 1024 and vector elements in the range [–1, 1]. The first object function call validates the preamble length against the maximum preamble length.

You can assign a double, single, or fi (requires Fixed-Point Designer™) data type to this property. To assign a fixed-point data type, use the fi (Fixed-Point Designer) object. The fixed-point data type must be signed with the WordLength property set to 16 and FractionLength property set to 15.

Note

To update this property, you must stop any ongoing transmission by calling the stopTransmission function on the object. When you update this property, the execution time of the next object function call increases by a few seconds.

Data Types: double | single | fi

Threshold calculation method to trigger data capture, specified as one of these values.

For more details, see Internal Architecture of Preamble Detection.

Note

To update this property, you must stop any ongoing transmission by calling the stopTransmission function on the object. When you update this property, the execution time of the next object function call increases by a few seconds.

Data Types: string

Fixed threshold value, specified as a numeric scalar in the range [0, 4095]. For more details, see Internal Architecture of Preamble Detection.

Dependencies

This property applies only when you set ThresholdMethod to "fixed".

Data Types: double

Adaptive threshold offset to avoid false trigger points, specified as a numeric scalar in the range [0, 2]. For more details, see Internal Architecture of Preamble Detection.

Dependencies

This property applies only when you set ThresholdMethod to "adaptive".

Data Types: double

Adaptive threshold gain value applied to the average input signal power before adaptive threshold calculation, specified as a numeric scalar in the range [0, 64]. For more details, see Internal Architecture of Preamble Detection.

Dependencies

This property applies only when you set ThresholdMethod to "adaptive".

Data Types: double

Trigger point offset, specified as an integer in the range [–4095, 4096]. This value specifies the start of data capture relative to the trigger point. For more details, see Thresholding and Triggering.

Note

To update this property, you must stop any ongoing transmission by calling the stopTransmission function on the object. When you update this property, the execution time of the next object function call increases by a few seconds.

Data Types: double

Object Functions

captureCapture signal of interest from the air upon detection
plotThresholdPlot preamble detection signals for triggering
transmitTransmit waveform using preamble or energy detector
stopTransmissionStop transmission from preamble or energy detector

Examples

collapse all

Define a preamble sequence with good correlation properties. For example, generate and normalize a Zadoff-Chu sequence of length 137.

seq = zadoffChuSeq(38,137);
preamble = seq/norm(seq,2); 

Create and configure a preamble detector object, specifying a radio setup configuration previously saved in the Radio Setup wizard. Set the sample rate to 10.24 MHz and the center frequency to 2.2 GHz.

pd = preambleDetector("MyRadio")
pd = 
  preambleDetector with properties:

                   Antennas: "RF0:RX2"
            CenterFrequency: 2.4000e+09
                 SampleRate: 250000000
                  RadioGain: 10
                   Preamble: [16×1 double]
            CaptureDataType: "int16"
              TriggerOffset: 0
       DroppedSamplesAction: "error"
            ThresholdMethod: "adaptive"
              TimestampUnit: "datetime"
    AdaptiveThresholdOffset: 0
      AdaptiveThresholdGain: 0

pd.SampleRate = 10.24e6;
pd.CenterFrequency = 2.2e9;
pd.CaptureDataType = "double";

Specify the preamble.

pd.Preamble = preamble; 

Set the trigger offset to a negative value to capture 500 samples before the trigger point.

pd.TriggerOffset = -500;

Capture 10 ms of data with a timeout of 1 second.

[data,timestamp,droppedSamples,status] = capture(pd,milliseconds(10),seconds(1));

Define a preamble sequence with good correlation properties. For example, generate and normalize a Zadoff-Chu sequence of length 137.

seq = zadoffChuSeq(38,137);
preamble = seq/norm(seq,2); 

Create and configure a preamble detector object, specifying a radio setup configuration previously saved in the Radio Setup wizard. Set the sample rate to 10.24 MHz and the center frequency to 2.2 GHz.

pd = preambleDetector("MyRadio",SampleRate=10.24e6,CenterFrequency=2.2e9)
pd = 
  preambleDetector with properties:

                   Antennas: "RF0:RX2"
            CenterFrequency: 2.2000e+09
                 SampleRate: 10240000
                  RadioGain: 10
                   Preamble: [16×1 double]
            CaptureDataType: "int16"
              TriggerOffset: 0
       DroppedSamplesAction: "error"
            ThresholdMethod: "adaptive"
              TimestampUnit: "datetime"
    AdaptiveThresholdOffset: 0
      AdaptiveThresholdGain: 0

Specify the preamble.

pd.Preamble = preamble; 

Capture ten consecutive signals with the specified preamble with a capture length of 5 ms and a timeout of 2 s.

[data,timestamp,droppedSamples,status] = capture(pd,milliseconds(5),seconds(2),"NumCaptures",10);

Tips

You cannot use save and load to store and reload Wireless Testbench objects. Instead, you can re-create the object with these steps:

  1. Write code to create a preambleDetector object with a saved radio setup configuration radio and set the properties.

  2. Save the code to a script.

  3. Run the script in a new MATLAB® session with the same saved radio setup configuration.

Algorithms

expand all

Version History

Introduced in R2022a

expand all