Main Content

energyDetector

Configure SDR as energy detector

Since R2023b

Description

Use the energyDetector object to configure the specified software-defined radio (SDR) as an energy detector. You can use the energy detector to detect and capture a signal of interest from the air using an increase in signal energy as the trigger. The object specifies the energy threshold and triggering parameters. For details, see Internal Architecture of Energy Detection.

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, energy detection, onboard memory, and MATLAB. The transmit waveform path consists of MATLAB, onboard memory, and radio antenna.

Creation

Description

example

ed = energyDetector(radio) creates an energy 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

ed = energyDetector(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 plotDetectionSignals 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

Energy integration window length, specified as a numeric scalar in the range [0, 4095]. The number of samples in the sliding window that is used to calculate the signal energy and the energy increase. For details, see Thresholding and Triggering.

Data Types: double

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

  • "adaptive" — Two thresholds must be met to trigger a data capture. The energy increase in dB, which is the ratio between the signal energy in the current window and the signal energy in the previous window, is compared against a constant threshold specified by the EnergyDeltaThreshold property. The signal energy is also compared against a constant threshold, specified by the MinimumEnergy property. Together, these thresholds are adaptive to channel noise.

  • "fixed" — The signal energy is compared against a constant threshold, specified by the FixedThreshold property.

For details, see Algorithms.

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, 8191]. For details, see Thresholding and Triggering.

Dependencies

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

Data Types: double

Minimum energy threshold value, specified as a numeric scalar in the range [0, 8191]. This value is the minimum energy at which the EnergyDeltaThreshold is applied in adaptive threshold mode. Set this threshold relative to the noise floor so that noise variations under this level do not cause false triggers. For details, see Thresholding and Triggering.

Dependencies

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

Data Types: double

Energy delta threshold, specified as the energy increase threshold in dB. This value is the ratio between the signal energy in the current window and the signal energy in the previous window, expressed in decibels. Set this threshold relative to the WindowLength property. For example:

  • An energy increase of 3 dB corresponds to a two-fold increase in signal energy between two adjacent windows.

  • An energy increase of 20 dB corresponds to a one-hundred-fold increase in signal energy between two adjacent windows.

For details, see Thresholding and Triggering.

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 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
plotDetectionSignalsPlot energy detection signals for triggering
transmitTransmit waveform using preamble or energy detector
stopTransmissionStop transmission from preamble or energy detector

Examples

collapse all

Create and configure an energy detector object, specifying a radio setup configuration previously saved in the Radio Setup wizard.

ed = energyDetector("MyRadio")
ed = 
  energyDetector with properties:

                Antennas: "RF0:RX2"
         CenterFrequency: 2.4000e+09
              SampleRate: 250000000
               RadioGain: 10
         CaptureDataType: "int16"
            WindowLength: 300
           TriggerOffset: 0
    DroppedSamplesAction: "error"
         ThresholdMethod: "adaptive"
           TimestampUnit: "datetime"
           MinimumEnergy: 1.0000e-04
    EnergyDeltaThreshold: 1

ed.SampleRate = 30.72e6;
ed.CenterFrequency = 2.45e9;
ed.CaptureDataType = "double";

Set the energy increase threshold to 3 dB.

ed.EnergyDeltaThreshold = 3;

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

ed.TriggerOffset = -100;

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

[data,timestamp,droppedSamples,status] = capture(ed,milliseconds(3),seconds(1));

Create and configure an energy detector object, specifying a radio setup configuration previously saved using the Radio Setup wizard. Set the data type of the captured data to double and the unit of the capture request timestamp to sample clock cycles.

ed = energyDetector("MyRadio",CaptureDataType="double",TimestampUnit="sample-clock-cycle")
ed = 
  energyDetector with properties:

                Antennas: "RF0:RX2"
         CenterFrequency: 2.4000e+09
              SampleRate: 250000000
               RadioGain: 10
         CaptureDataType: "double"
            WindowLength: 300
           TriggerOffset: 0
    DroppedSamplesAction: "error"
         ThresholdMethod: "adaptive"
           TimestampUnit: "sample-clock-cycle"
           MinimumEnergy: 1.0000e-04
    EnergyDeltaThreshold: 1

Capture five consecutive signals that meet the default thresholding criteria with a capture length of 1 ms and a timeout of 1 s.

[data,timestamp,droppedSamples,status] = capture(ed,milliseconds(1),seconds(1),"NumCaptures",5);

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 energyDetector 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 R2023b

expand all