Main Content

Barker Code Generator

Generate bipolar Barker Code

  • Barker Code Generator block

Libraries:
Communications Toolbox
Communications Toolbox / Comm Sources / Sequence Generators

Description

The Barker Code Generator block generates a bipolar Barker code. The short length and low correlation sidelobes make Barker codes useful for frame synchronization in digital communications systems. For more information, see Barker Codes.

Examples

expand all

The cm_ex_various_barker_code_length model shows the output from Barker Code Generator blocks configured for 15 samples per frame at a sample time of 1, and code lengths set to 3, 4, 7, and 13. The plot shows that the code sequence repeats, as needed, to fill a 15 sample frame.

Plot the Barker code sequences. Each Barker Code Generator block outputs one frame with 15 samples. Comparing the code sequences you can see the code is repeated to fill the frame.

Construct two frames consisting of a 7-bit Barker code preamble and a 14-bit payload field. Detect the preamble locations by using the Preamble Detector block.

Based on detection of a Barker code preamble by the Preamble Detector block, the model displays the index location of the last bit in each preamble detected. To load the model and to configure the runtime preamble setting, callback functions are used. For more information, see Model Callbacks (Simulink).

  • When loading the model, a PostLoadFcn callback initializes the preamble value of the Preamble Detector block.

  • For runtime execution, an InitFcn callback gets the runtime setting for the preamble from the Barker Code Generator block.

The Barker Code Generator block outputs a bipolar (-1,1) signal that must be converted to unipolar (0,1) for the Preamble Detector block. When you run the model, the display shows the numbers 7 and 28 corresponding to the locations at the end of the two preambles.

Extended Examples

Ports

Output

expand all

Barker code frame, returned as a column vector. If the frame length exceeds the Barker code length, the block fills the frame by repeating the Barker code.

Dependencies

Set the data type of the output with the Output data type parameter.

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Length of the generated code, specified as 1, 2, 3, 4, 5, 7, 11, or 13. For more information, see Barker Codes.

Example: 2 outputs the Barker code [–1;1].

Positive scalars specify the time in seconds between each sample of the output signal. If you set the sample time to -1, the output signal inherits the sample time from downstream. For information on the relationship between the Sample time and Samples per frame parameters, see Sample Timing.

Samples per output frame, specified as a positive integer. If Samples per frame is M, the block outputs a frame containing M samples comprised of length N Barker code sequences. N is the length of the generated code, which is set by the Code length parameter. When M is not an integer multiple of N, consecutive frames maintain continuity of the Barker code across frame boundaries.

For information on the relationship between Sample time and Samples per frame, see Sample Timing.

Output data type, specified as double or int8.

Type of simulation to run, specified as Code generation or Interpreted execution.

  • Code generation — Simulate the model by using generated C code. The first time you run a simulation, Simulink generates C code for the block. The model reuses the C code for subsequent simulations unless the model changes. This option requires additional startup time, but the speed of the subsequent simulations is faster than with the Interpreted execution option.

  • Interpreted execution — Simulate the model by using the MATLAB® interpreter. This option shortens startup time, but the speed of subsequent simulations is slower than with the Code generation option. In this mode, you can debug the source code of the block.

For more information, see Interpreted Execution vs. Code Generation (Simulink).

Block Characteristics

Data Types

double | integer

Multidimensional Signals

no

Variable-Size Signals

no

More About

expand all

Extended Capabilities

Version History

Introduced before R2006a

expand all