# comm.GeneralQAMTCMDemodulator

Demodulate convolutionally encoded data mapped to arbitrary QAM constellation

## Description

The `GeneralQAMTCMDemodulator` object uses the Viterbi algorithm to decode a trellis-coded modulation (TCM) signal that was previously modulated using an arbitrary signal constellation.

To demodulate a signal that was modulated using a trellis-coded, general quadrature amplitude modulator:

1. Define and set up your general QAM TCM modulator object. See Construction.

2. Call `step` to demodulate a signal according to the properties of `comm.GeneralQAMTCMDemodulator`. 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.GeneralQAMTCMDemodulator` creates a trellis-coded, general quadrature amplitude (QAM TCM) demodulator System object, `H`. This object demodulates convolutionally encoded data that has been mapped to an arbitrary QAM constellation.

`H = comm.GeneralQAMTCMDemodulator(Name,Value)` creates a general QAM TCM demodulator 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.GeneralQAMTCMDemodulator(TRELLIS,Name,Value)` creates a general QAM TCM demodulator 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 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 value that results from `poly2trellis`(```[1 3]```, `[1 0 0; 0 5 2]`). `TerminationMethod` Termination method of encoded frame Specify the termination method as one of `Continuous` | `Truncated` | `Terminated`. The default is `Continuous`. When you set this property to `Continuous`, the object saves the internal state metric at the end of each frame. The next frame uses the same state metric. The object treats each traceback path independently. If the input signal contains only one symbol, use `Continuous` mode. When you set this property to `Truncated`, the object treats each input vector independently. The traceback path starts at the state with the best metric and always ends in the all-zeros state. When you set this property to `Terminated`, the object treats each input vector independently, and the traceback path always starts and ends in the all-zeros state. `TracebackDepth` Traceback depth for Viterbi decoder Specify the scalar, integer number of trellis branches to construct each traceback path. The default is `21`. The Traceback depth parameter influences the decoding accuracy and delay. The decoding delay indicates the number of zero symbols that precede the first decoded symbol in the output. When you set the `TerminationMethod` property to `Continuous`, the decoding delay consists of `TracebackDepth` zero symbols or `TracebackDepth`$×$K zero bits for a rate K/N convolutional code. When you set the `TerminationMethod` property to `Truncated` or `Terminated`, no output delay occurs and the traceback depth must be less than or equal to the number of symbols in each input vector. `ResetInputPort` Enable demodulator 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`. `Constellation` Signal constellation Specify a double- or single-precision complex vector. This vector lists the points in the signal constellation that were used to map the convolutionally encoded data. The constellation must be specified in set-partitioned order. See documentation for the General TCM Encoder block for more information on set-partitioned order. The length of the constellation vector must equal the number of possible input symbols to the convolutional decoder of the general QAM TCM demodulator object. This corresponds to 2N for a rate K/N convolutional code. The default corresponds to a set-partitioned order for the points of an 8-PSK signal constellation. This value is expressed as exp($2×\pi ×j×\left[\begin{array}{cccccccc}0& 4& 2& 6& 1& 5& 3& 7\end{array}\right]}{8}$). `OutputDataType` Data type of output Specify output data type as one of `logical` | `double`. The default is `double`.

## Methods

 reset Reset states of the general QAM TCM demodulator object step Demodulate convolutionally encoded data mapped to arbitrary QAM constellation
Common to All System Objects
`release`

Allow System object property value changes

## Examples

collapse all

Modulate and demodulate noisy data using QAM TCM modulation with an arbitrary 4-point constellation. Estimate the resultant BER.

Define a trellis structure with two input symbols and four output symbols using a [171 133] generator polynomial. Define an arbitrary four-point constellation.

```qamTrellis = poly2trellis(7,[171 133]); refConst = exp(pi*1i*[1 2 3 6]/4);```

Create a QAM TCM modulator and demodulator System object™ pair using `qamTrellis` and `refConst`.

```hMod = comm.GeneralQAMTCMModulator(qamTrellis,'Constellation', refConst); hDemod = comm.GeneralQAMTCMDemodulator(qamTrellis,'Constellation',refConst);```

Create an AWGN channel object in which the noise is set by using a signal-to-noise ratio.

```hAWGN = comm.AWGNChannel('NoiseMethod','Signal to noise ratio (SNR)', ... 'SNR',4);```

Create an error rate calculator with delay (in bits) equal to the product of `TracebackDepth` and the number of bits per symbol

```hError = comm.ErrorRate(... 'ReceiveDelay', hDemod.TracebackDepth*log2(qamTrellis.numInputSymbols));```

Generate random binary data and apply QAM TCM modulation. Pass the signal through an AWGN channel and demodulate. Collect the error statistics.

```for counter = 1:10 % Generate binary data data = randi([0 1],500,1); % Modulate modSignal = step(hMod,data); % Pass through an AWGN channel noisySignal = step(hAWGN,modSignal); % Demodulate receivedData = step(hDemod,noisySignal); % Calculate the error statistics errorStats = step(hError,data,receivedData); end```

Display the BER and the number of bit errors.

```fprintf('Error rate = %5.2e\nNumber of errors = %d\n', ... errorStats(1), errorStats(2))```
```Error rate = 1.16e-02 Number of errors = 58 ```

## Algorithms

This object implements the algorithm, inputs, and outputs described on the General TCM Decoder block reference page. The object properties correspond to the block parameters.