# comm.PSKDemodulator System object

Package: comm

Demodulate using M-ary PSK method

## Description

The `PSKDemodulator` object demodulates an input signal using the M-ary phase shift keying (M-PSK) method.

To demodulate a signal that was modulated using phase shift keying:

1. Define and set up your PSK demodulator object. See Construction.

2. Call `step` to demodulate the signal according to the properties of `comm.PSKDemodulator`. The behavior of `step` is specific to each object in the toolbox.

## Construction

`H = comm.PSKDemodulator` creates a demodulator System object™, `H`. This object demodulates the input signal using the M-ary phase shift keying (M-PSK) method.

`H = comm.PSKDemodulator(Name,Value)` creates an M-PSK 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.PSKDemodulator(M,PHASE,Name,Value)` creates an M-PSK demodulator object, `H`. This object has the `ModulationOrder` property set to `M`, the `PhaseOffset` property set to `PHASE`, and the other specified properties set to the specified values. `M` and `PHASE` are value-only arguments. To specify a value-only argument, you must also specify all preceding value-only arguments. You can specify name-value pair arguments in any order.

## Properties

 `ModulationOrder` Number of points in signal constellation Specify the number of points in the signal constellation as a positive, integer scalar value. The default is `8`. `PhaseOffset` Phase of zeroth point of constellation Specify the phase offset of the zeroth point of the constellation, in radians, as a real scalar value. The default is `pi/8`. `BitOutput` Output data as bits Specify whether the output consists of groups of bits or integer symbol values. The default is `false`. When you set this property to `true`, the `step` method outputs a column vector of bit values. The length of this vector equals log2(`ModulationOrder`) times the number of demodulated symbols. When you set this property to `false`, the `step` method outputs a column vector with a length equal to the input data vector. This vector contains integer symbol values between `0` and `ModulationOrder`-`1`. `SymbolMapping` Constellation encoding Specify how the object maps an integer or group of log2(`ModulationOrder`) bits to the corresponding symbol. Choose from `Binary` | `Gray` | `Custom`. The default is `Gray`. When you set this property to `Gray`, the object uses a Gray-encoded signal constellation. When you set this property to `Binary`, the integer m, between `0` $\le m\le$`ModulationOrder`–`1`) maps to the complex value exp(j$×$`PhaseOffset` + j$×$`2`$×$$\pi$$×$m/`ModulationOrder`). When you set this property to `Custom`, the object uses the signal constellation defined in the `CustomSymbolMapping` property. `CustomSymbolMapping` Custom constellation encoding Specify a custom constellation symbol mapping vector. The default is `0:7`. This property requires a row or column vector with a size of `ModulationOrder`. This vector must have unique integer values in the range [`0`, `ModulationOrder`–`1`]. The values must be of data type `double`. The first element of this vector corresponds to the constellation point at an angle of `0` + `PhaseOffset`, with subsequent elements running counterclockwise. The last element corresponds to the constellation point at an angle of –$\pi$/`ModulationOrder` + `PhaseOffset`. This property applies when you set the `SymbolMapping` property to `Custom`. `DecisionMethod` Demodulation decision method Specify the decision method the object uses as ```Hard decision``` | `Log-likelihood ratio` | ```Approximate log-likelihood ratio```. The default is `Hard decision`. When you set the `BitOutput` property to `false`, the object always performs hard decision demodulation. This property applies when you set the `BitOutput` property to `true`. `VarianceSource` Source of noise variance Specify the source of the noise variance as one of `Property` | ```Input port```. The default is `Property`. This property applies when you set the `BitOutput` property to true and the `DecisionMethod` property to `Log-likelihood ratio` or ```Approximate log-likelihood ratio```. `Variance` Noise variance Specify the variance of the noise as a positive, real scalar value. The default is 1. If this value is very small (i.e., SNR is very high), log-likelihood ratio (LLR) computations may yield Inf or –Inf. This result occurs because the LLR algorithm computes the exponential of very large or very small numbers using finite-precision arithmetic. In such cases, use approximate LLR instead because the algorithm for that option does not compute exponentials. This property applies when you set the `BitOutput` property to true, the `DecisionMethod` property to `Log-likelihood ratio`, or ```Approximate log-likelihood ratio```, and the `VarianceSource` property to `Property`. This property is tunable. `OutputDataType` Data type of output Specify the output data type as `Full precision` | ```Smallest unsigned integer``` | `double` | `single` | `int8` | `uint8` | `int16` | `uint16` | `int32` | `uint32`. The default is `Full precision`. This property applies when you set the `BitOutput` property to `false`. It also applies when you set the `BitOutput` property to `true` and the `DecisionMethod` property to `Hard decision`. In this second case, when the `OutputDataType` property is set to `Full precision`, the input data type is single- or double-precision, the output data has the same data type as the input. . When the input data is of a fixed-point type, the output data type behaves as if you had set the `OutputDataType` property to `Smallest unsigned integer`. When you set `BitOutput` to `true` and the `DecisionMethod` property to `Hard Decision`, then `logical` data type becomes a valid option. If you set the `BitOutput` property to `true` and the `DecisionMethod` property to ```Log-likelihood ratio``` or `Approximate log-likelihood ratio`, the output data has the same data type as the input. In this case, the data type must be single- or double-precision.

## Methods

 clone Create PSK demodulator object with same property values constellation Calculate or plot ideal signal constellation getNumInputs Number of expected inputs to step method getNumOutputs Number of outputs from step method isLocked Locked status for input attributes and nontunable properties release Allow property value and input characteristics changes step Demodulate using M-ary PSK method

## Examples

Modulate and demodulate a signal using 16-PSK modulation.

``` hMod = comm.PSKModulator(16, 'PhaseOffset',pi/16); hAWGN = comm.AWGNChannel('NoiseMethod', ... 'Signal to noise ratio (SNR)','SNR',15); hDemod = comm.PSKDemodulator(16, 'PhaseOffset',pi/16); %Create an error rate calculator hError = comm.ErrorRate; for counter = 1:100 % Transmit a 50-symbol frame data = randi([0 hMod.ModulationOrder-1],50,1); modSignal = step(hMod, data); noisySignal = step(hAWGN, modSignal); receivedData = step(hDemod, noisySignal); errorStats = step(hError, data, receivedData); end fprintf('Error rate = %f\nNumber of errors = %d\n', ... errorStats(1), errorStats(2))```

## Algorithms

This object implements the algorithm, inputs, and outputs described on the M-PSK Demodulator Baseband block reference page. The object properties correspond to the block parameters.