comm.ConvolutionalEncoder

Convolutionally encode binary data

Description

The ConvolutionalEncoder object encodes a sequence of binary input vectors to produce a sequence of binary output vectors.

To convolutionally encode a binary signal:

  1. Define and set up your convolutional encoder object. See Construction.

  2. Call step to encode a sequence of binary input vectors to produce a sequence of binary output vectors according to the properties of comm.ConvolutionalEncoder. The behavior of step is specific to each object in the toolbox.

Note

Starting in R2016b, 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

H = comm.ConvolutionalEncoder creates a System object, H, that convolutionally encodes binary data.

H = comm.ConvolutionalEncoder(Name,Value) creates a convolutional encoder object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

H = comm.ConvolutionalEncoder(TRELLIS,Name,Value) creates a convolutional encoder object, H This object has the TrellisStructure property set to TRELLIS, and the other specified properties set to the specified values.

Properties

TrellisStructure

Trellis structure of convolutional code

Specify the trellis as a MATLAB structure that contains the trellis description of the convolutional code. Use the istrellis function to check if a structure is a valid trellis structure. The default is the result of poly2trellis(7, [171 133]).

TerminationMethod

Termination method of encoded frame

Specify how the encoded frame is terminated as one of Continuous | Truncated | Terminated. The default is Continuous. When you set this property to Continuous, the object retains the encoder states at the end of each input vector for use with the next input vector. When you set this property to Truncated, the object treats each input vector independently. The encoder states are reset at the start of each input vector. If you set the InitialStateInputPort property to false, the object resets its states to the all-zeros state. If you set the InitialStateInputPort property to true, the object resets the states to the values you specify in the initial states step method input. When you set this property to Terminated, the object treats each input vector independently. For each input vector, the object uses extra bits to set the encoder states to all-zeros states at the end of the vector. For a rate K/N code, the step method outputs a vector with length N×(L+S)K, where S = constraintLength–1 (or, in the case of multiple constraint lengths, S = sum(constraintLength(i)–1)). L is the length of the input to the step method.

ResetInputPort

Enable encoder reset input

Set this property to true to enable an additional input to the step method. The default is false. When this additional reset input is a nonzero value, the internal states of the encoder reset to their initial conditions. This property applies when you set the TerminationMethod property to Continuous.

DelayedResetAction

Delay output reset

Set this property to true to delay resetting the object output. The default is false. When you set this property to true, the reset of the internal states of the encoder occurs after the object computes the encoded data. When you set this property to false, the reset of the internal states of the encoder occurs before the object computes the encoded data. This property applies when you set the ResetInputPort property to true.

InitialStateInputPort

Enable initial state input

Set this property to true to enable a step method input that allows the specification of the initial state of the encoder for each input vector. The default is false. This property applies when you set the TerminationMethod property to Truncated.

FinalStateOutputPort

Enable final state output

Set this property to true to obtain the final state of the encoder via a step method output. The default is false. This property applies when you set the TerminationMethod property to Continuous or Truncated.

PuncturePatternSource

Source of puncture pattern

Specify the source of the puncture pattern as one of None | Property. The default is None. When you set this property to None the object does not apply puncturing. When you set this property to Property, the object punctures the code. This puncturing is based on the puncture pattern vector that you specify in the PuncturePattern property. This property applies when you set the TerminationMethod property to Continuous or Truncated.

PuncturePattern

Puncture pattern vector

Specify the puncture pattern used to puncture the encoded data as a column vector. The default is [1; 1; 0; 1; 0; 1]. The vector contains 1s and 0s, where the 0 indicates the punctured, or excluded, bits. This property applies when you set the TerminationMethod property to Continuous or Truncated and the PuncturePatternSource property to Property.

Methods

resetReset states of the convolutional encoder object
stepConvolutionally encode binary data
Common to All System Objects
release

Allow System object property value changes

Examples

collapse all

Transmit a convolutionally encoded 8-DPSK modulated bit stream through an AWGN channel. Then, demodulate and decode using a Viterbi decoder.

Create the necessary System objects.

hConEnc = comm.ConvolutionalEncoder;
hMod = comm.DPSKModulator('BitInput',true);
hChan = comm.AWGNChannel('NoiseMethod', ...
    'Signal to noise ratio (SNR)',...
    'SNR',10);
hDemod = comm.DPSKDemodulator('BitOutput',true);
hDec = comm.ViterbiDecoder('InputFormat','Hard');
hError = comm.ErrorRate('ComputationDelay',3,'ReceiveDelay', 34);

Process the data using the following steps:

  1. Generate random bits

  2. Convolutionally encode the data

  3. Apply DPSK modulation

  4. Pass the modulated signal through AWGN

  5. Demodulate the noisy signal

  6. Decode the data using a Viterbi algorithm

  7. Collect error statistics

for counter = 1:20
    data = randi([0 1],30,1);
    encodedData = step(hConEnc, data);
    modSignal = step(hMod, encodedData);
    receivedSignal = step(hChan, modSignal);
    demodSignal = step(hDemod, receivedSignal);
    receivedBits = step(hDec, demodSignal);
    errors = step(hError, data, receivedBits);
end

Display the number of errors.

errors(2)
ans = 3

Encode and decode a sequence of bits using a convolutional encoder and a Viterbi decoder with a defined puncture pattern. Verify that the input and output bits are identical

Define a puncture pattern matrix and reshape it into vector form for use with the Encoder and Decoder objects.

pPatternMat = [1 0 1;1 1 0];
pPatternVec = reshape(pPatternMat,6,1);

Create convolutional encoder and a Viterbi decoder in which the puncture pattern is defined by pPatternVec.

ENC = comm.ConvolutionalEncoder(...
    'PuncturePatternSource','Property', ...
    'PuncturePattern',pPatternVec);

DEC = comm.ViterbiDecoder('InputFormat','Hard', ...
    'PuncturePatternSource','Property',...
    'PuncturePattern',pPatternVec);

Create an error rate counter with the appropriate receive delay.

ERR = comm.ErrorRate('ReceiveDelay',DEC.TracebackDepth);

Encode and decode a sequence of random bits.

dataIn = randi([0 1],600,1);

dataEncoded = step(ENC,dataIn);

dataOut = step(DEC,dataEncoded);

Verify that there are no errors in the output data.

errStats = step(ERR,dataIn,dataOut);
errStats(2)
ans = 0

Algorithms

This object implements the algorithm, inputs, and outputs described on the Convolutional Encoder block reference page. The object properties correspond to the block parameters, except:

The operation mode Reset on nonzero input via port block parameter corresponds to the ResetInputPort property.

Extended Capabilities

Introduced in R2012a