Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

comm.PreambleDetector System object

Detect preamble in data

Description

The comm.PreambleDetector System object™ detects a preamble in an input data sequence. A preamble is a set of symbols or bits used in packet-based communication systems to indicate the start of a packet. The preamble detector object finds the location corresponding to the end of the preamble.

To detect a preamble in an input data sequence:

  1. Create a comm.PreambleDetector object and set the properties of the object.

  2. Call step to detect the presence of a preamble.

Note

Alternatively, instead of using the step method to perform the operation defined by the System object™, you can call the object with arguments, as if it were a function. For example, y = step(obj,x) and y = obj(x) perform equivalent operations.

Construction

prbdet = comm.PreambleDetector creates a preamble detector object, prbdet, using the default properties.

prbdet = comm.PreambleDetector(Name,Value) specifies additional properties using Name,Value pairs. Unspecified properties have default values.

prbdet = comm.PreambleDetector(prb,Name,Value) specifies the preamble, prb in addition to those properties specified by using Name,Value pairs.

Example:

prbdet = comm.PreambleDetector('Input','Bit','Detections','First');

Properties

expand all

Type of input data, specified as 'Symbol' or 'Bit'. For binary inputs, set this parameter to 'Bit'. For all other inputs, set this parameter to 'Symbol'. Symbol data can be of data type single or double while bit data can, in addition, support the Boolean, int8, and uint8 data types.

Preamble sequence, specified as a real or complex column vector. The object uses this sequence to detect the presence of the preamble in the input data. If Input is 'Bit', the preamble must be a binary sequence. If Input is 'Symbol', the preamble can be any real or complex sequence.

Data Types: double | single | logical | int8 | uint8
Complex Number Support: Yes

Detection threshold, specified as a nonnegative scalar. When the computed detection metric is greater than or equal to Threshold, the preamble is detected. This property is available when Input is set to 'Symbol'. Tunable.

Number of preambles to detect, specified as 'All' or 'First'.

  • 'All' — Detects all the preambles in the input data sequence.

  • 'First' — Detect only the first preamble in the input data sequence.

Methods

resetReset states of preamble detector object
stepDetect preamble in data
Common to All System Objects
clone

Create System object with same property values

getNumInputs

Expected number of inputs to a System object

getNumOutputs

Expected number of outputs of a System object

isLocked

Check locked states of a System object (logical)

release

Allow System object property value changes

Examples

expand all

Specify a six-bit preamble.

prb = [1 0 0 1 0 1]';

Create a preamble detector object using preamble prb and taking bit inputs.

prbdet = comm.PreambleDetector(prb,'Input','Bit');

Generate a binary data sequence containing two preambles and using random bits to represent the data fields.

pkt = [prb; randi([0 1],10,1); prb; randi([0 1],10,1)];

Locate the indices of the two preambles. The indices correspond to the end of the preambles.

idx = prbdet(pkt)
idx =

     6
    22

The detector correctly identified indices 6 and 22 as the end of the two preambles inserted in the sequence.

Create a preamble and apply QPSK modulation.

p1 = [0 1 2 3 3 2 1 0]';
p = [p1; p1];
prb = pskmod(p,4,pi/4,'gray');

Create a comm.PreambleDetector object using preamble prb.

prbdet = comm.PreambleDetector(prb)
prbdet = 
  comm.PreambleDetector with properties:

         Input: 'Symbol'
      Preamble: [16x1 double]
     Threshold: 3
    Detections: 'All'

Generate a sequence of random symbols. The first sequence represents the last 20 symbols from a previous packet. The second sequence represents the symbols from the current packet.

d1 = randi([0 3],20,1);
d2 = randi([0 3],100,1);

Modulate the two sequences.

x1 = pskmod(d1,4,pi/4,'gray');
x2 = pskmod(d2,4,pi/4,'gray');

Create a sequence of modulated symbols consisting of the remnant of the previous packet, the preamble, and the current packet.

y = [x1; prb; x2];

Add white Gaussian noise.

z = awgn(y,10);

Determine the preamble index and the detection metric.

[idx,detmet] = prbdet(z);

Calculate the number of elements in idx. Because the number of elements is greater than one, the detection threshold is too low.

numel(idx)
ans = 80

Display the five largest detection metrics.

detmetSort = sort(detmet,'descend');
detmetSort(1:5)
ans = 

   16.3115
   13.6900
   10.5698
    9.1920
    8.9706

Increase the threshold and determine the preamble index.

prbdet.Threshold = 15;
idx = prbdet(z)
idx = 36

The result of 36 corresponds to the sum of the preamble length (16) and the remaining samples in the previous packet (20). This indicates that the preamble has been successfully detected.

Algorithms

Bit Inputs

When the input data is composed of bits, the preamble detector uses an exact pattern match.

Symbol Inputs

When the input data is composed of symbols, the preamble detector uses a cross-correlation algorithm. An FIR filter, in which the coefficients are specified from the preamble, computes the cross-correlation between the input data and the preamble. When a sequence of input samples matches the preamble, the filter output reaches its peak. The index of the peak corresponds to the end of the preamble sequence in the input data. See Discrete FIR Filter for further information on the FIR filter algorithm.

The cross-correlation values that are greater than or equal to the specified threshold are reported as peaks. As a result, there may be no detected peaks or there may be as many detected peaks as there are input samples. Consequently, the selection of the detection threshold is very important.

Extended Capabilities

Introduced in R2016b

Was this topic helpful?