# comm.FSKDemodulator

Demodulate using M-ary FSK method

## Description

The `comm.FSKDemodulator` System object™ noncoherently demodulates a signal that was modulated using the M-ary frequency shift keying (M-FSK) method. The input is a baseband representation of the modulated signal. The input and output for this object are discrete-time signals. For more information, see Algorithms.

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

1. Create the `comm.FSKDemodulator` object and set its properties.

2. Call the object with arguments, as if it were a function.

## Creation

### Syntax

``fskdemodulator = comm.FSKDemodulator``
``fskdemodulator = comm.FSKDemodulator(Name=Value)``
``fskdemodulator = comm.FSKDemodulator(M,freqSep,RS,Name=Value)``

### Description

example

````fskdemodulator = comm.FSKDemodulator` creates a demodulator System object that demodulates an M-FSK modulated signal by using a noncoherent energy detector.```
````fskdemodulator = comm.FSKDemodulator(Name=Value)` creates an FSK demodulator object and sets properties using one or more name-value arguments. For example, `comm.FSKDemodulator(BitOutput=true)` configures the object to return binary output values.```
````fskdemodulator = comm.FSKDemodulator(M,freqSep,RS,Name=Value)` creates an M-FSK demodulator object with the `ModulationOrder` property set to `M`, the `FrequencySeparation` property set to `freqSep`, the `SymbolRate` property set to `RS`, and optional name-value arguments.```

## Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the `release` function unlocks them.

If a property is tunable, you can change its value at any time.

Number of frequencies in the modulated signal, specified as a positive integer ≥ 2.

Note

The modulation order, M, must be a power of two, such that M = 2K, where K is a positive integer when you set `SymbolMapping` to `'Gray'` or you set `BitOutput` to `true`.

Data Types: `double`

Option to provide the output as integers or groups of bit values, specified as a numeric or logical `0` (`false`) or `1` (`true`).

Data Types: `logical`

Symbol encoding mapping, specified as `'Gray'` or `'Binary'`. Each integer or group of log2(M) bits corresponds to one symbol. M represents the value of the `ModulationOrder` property.

• When you set this property to `'Gray'`, the object maps symbols to a Gray-encoded ordering.

• When you set this property to `'Binary'`, the object maps symbols to a natural binary-encoded ordering.

For either type of mapping, the object maps the lowest frequency to the integer 0 and maps the highest frequency to the integer (M – 1). In baseband simulation, the lowest frequency is the negative frequency with the largest absolute value.

Frequency separation between successive tones in the modulated signal in hertz, specified as a positive scalar value. For more information, see Avoid Output Signal Aliasing.

Data Types: `double`

Number of samples per input symbol, specified as positive integer. For more information, see Avoid Output Signal Aliasing.

Data Types: `double`

Symbol rate in symbols per second, specified as a positive scalar. The symbol duration remains the same, regardless of whether the output signal is bits or integers. For more information, see Avoid Output Signal Aliasing.

Data Types: `double`

Data type of output

Specify the output data type as one of `"double"`, `"logical"`, `"int8"`, `"uint8"`, `"int16"`, `"uint16"`, `"int32"`, or `"uint32"`.

• When you set the `BitOutput` property to `false` and the `ModulationOrder` property to `2`, you can set this property to `"logical"`.

• When you set the `BitOutput` property to `true`, the output data type must be set to `"logical"` or `"double"`.

## Usage

### Syntax

``y = fskdemodulator(x)``

### Description

example

````y = fskdemodulator(x)` demodulates the input signal by using the FSK method. The output is the modulated FSK baseband signal.```

### Input Arguments

expand all

Modulated input signal, specified as a column vector. The length of `x` must be an integer multiple of the `SamplesPerSymbol` property value.

Data Types: `double` | `single`

### Output Arguments

expand all

Output signal, returned as an integer or bit-valued column vector.

• When you set `BitOutput` to `false`, the object returns an N / NSPS-by-1 vector. N is the length of the input signal `x` and NSPS is the value of the `SamplesPerSymbol` property. The elements of the output vector are integers in the range [`0`, (M – 1)]. M represents the value of the `ModulationOrder` property.

• When you set `BitOutput` to `true`, the object returns a column vector of length equal to N × log2(M). The output vector contains bit representations of integers in the range [`0`, (M – 1)]. Groups of log2(`M`) bits are mapped onto a symbol, with the first bit representing the MSB and the last bit representing the LSB.

The `OutputDataType` property specifies the data type of the output.

## Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named `obj`, use this syntax:

`release(obj)`

expand all

 `step` Run System object algorithm `release` Release resources and allow changes to System object property values and input characteristics `reset` Reset internal states of System object

## Examples

collapse all

Modulate and demodulate a signal using 8-FSK modulation with a frequency separation of 100 Hz.

Create FSK modulator and demodulator System objects with modulation order 8 and 100 Hz frequency separation.

```M = 8; freqSep = 100; fskmodulator = comm.FSKModulator(M,freqSep); fskdemodulator = comm.FSKDemodulator(M,freqSep);```

Create an additive white Gaussian noise channel with a signal-to-noise ratio of -2 dB.

```awgnchan = comm.AWGNChannel( ... NoiseMethod="Signal to noise ratio (SNR)", ... SNR=-2);```

Create an error rate calculator object.

`errRate = comm.ErrorRate;`

Transmit one hundred 50-symbol frames using 8-FSK modulation in an AWGN channel.

```for counter = 1:100 data = randi([0 M-1],50,1); modSignal = fskmodulator(data); noisySignal = awgnchan(modSignal); receivedData = fskdemodulator(noisySignal); errorStats = errRate(data,receivedData); end```

Display the error statistics.

```es1 = 'Error rate = %4.2e\n'; es2 = 'Number of errors = %d\n'; es3 = 'Number of symbols = %d\n'; fprintf([es1 es2 es3],errorStats)```
```Error rate = 1.40e-02 Number of errors = 70 Number of symbols = 5000 ```

The FSK modulator System object can be configured to modulate data input as integer values or as binary values. The FSK demodulator System object can be configured to demodulate symbols and output as integer values or as binary values. Each integer or group of log2(M) bits corresponds to one symbol. M represents the value of the `ModulationOrder` property. Compute the expected signal lengths for input and output of FSK modulation and demodulation of the integer and binary signals. Display the resulting signal lengths for input and output of the FSK modulated and demodulated integer and binary signals.

Define variable to use when configuring FSK modulator and demodulator objects.

```M = 8; % Modulation order freqSep = 100; % Frequency separation nspf = 21; % Number of samples per frame sps = 10; % Samples per symbol fskmod_bit = comm.FSKModulator(M,freqSep, ... BitInput=true, ... SamplesPerSymbol=sps); fskmod_bif = comm.FSKModulator(M,freqSep, ... BitInput=false, ... SamplesPerSymbol=sps); fskdemod_bot = comm.FSKDemodulator(M,freqSep, ... BitOutput=true, ... SamplesPerSymbol=sps); fskdemod_bof = comm.FSKDemodulator(M,freqSep, ... BitOutput=false, ... SamplesPerSymbol=sps); ```

Generate integer data and modulate data by using an FSK modulator object configured to accept bit data (`BitInput=true`).

```bindata = randi([0 1],nspf*M,1); modSignal = fskmod_bit(bindata);```

Demodulate the data, and then output binary data from the first demodulator object and integer data from the second demodulator. Compute the expected and resulting input and output signal lengths.

```rxData_bot = fskdemod_bot(modSignal); rxData_bof = fskdemod_bof(modSignal);```

Compute expected input and output lengths for a binary input signal.

```Nbit = length(bindata); Nsym = sps*length(bindata)/log2(M); Nbot = (length(modSignal)/sps)*log2(M); Nbof = length(modSignal)/sps; expLen = sprintf(' Nbit Nsym Nbot Nbof\n %d %d %d %d', ... length(bindata),length(modSignal), ... length(rxData_bot),length(rxData_bof))```
```expLen = ' Nbit Nsym Nbot Nbof 168 560 168 56' ```

Display input and output lengths for a binary input signal.

```sigLen = sprintf(' bit sym bot bof\n %d %d %d %d', ... length(bindata),length(modSignal), ... length(rxData_bot),length(rxData_bof))```
```sigLen = ' bit sym bot bof 168 560 168 56' ```

Generate integer data and modulate data by using an FSK modulator object configured to accept integer data (`BitInput=false`).

```data = randi([0 M-1],nspf,1); modSignal = fskmod_bif(data);```

Because the input length changes, you must release the demodulator objects before reusing them. Demodulate the data, and then output binary data from the first demodulator object and integer data from the second demodulator. Compute the expected and resulting input and output signal lengths.

```release(fskdemod_bot) release(fskdemod_bof) rxData_bot = fskdemod_bot(modSignal); rxData_bof = fskdemod_bof(modSignal);```

Compute expected input and output lengths for an integer input signal.

```Nbif = length(data); Nsym = sps*length(data); Nbot = (length(modSignal)/sps)*log2(M); Nbof = length(modSignal)/sps; expLen = sprintf('Nbif Nsym Nbot Nbof\n %d %d %d %d', ... length(data),length(modSignal), ... length(rxData_bot),length(rxData_bof))```
```expLen = 'Nbif Nsym Nbot Nbof 21 210 63 21' ```

Display input and output lengths for an integer input signal.

```sigLen = sprintf(' bif sym bot bof\n %d %d %d %d', ... length(data),length(modSignal), ... length(rxData_bot),length(rxData_bof))```
```sigLen = ' bif sym bot bof 21 210 63 21' ```

expand all

## Algorithms

Demodulation of M-FSK modulated signals is performed by using a noncoherent detection, which configures an energy detector that does not exploit phase measurements. The demodulator knows that M possible waveforms were transmitted and must decide which is received during each time duration T.

As described in Sklar [1], the general analytical expression for M-FSK modulation is

`${s}_{i}\left(t\right)=\sqrt{\frac{2E}{T}\mathrm{cos}\left({\omega }_{i}t+\varphi \right)}\begin{array}{cc}& \begin{array}{c}\text{0}\le t\le T\\ i\text{=1,}...\text{,}M\end{array}\end{array}$`

• E is the symbol energy.

• T is the symbol time duration.

• ωi is the frequency term that has M discreet values.

• M is the modulation order and specifies the number of waveforms.

• ϕ is the phase offset.

The noncoherent energy detector of the M-FSK demodulator selects decision regions for each ωi waveform based on which decision region yields the maximum output.

For more details, see the Noncoherent Detection of FSK section in Sklar, [1].

## References

[1] Sklar, Bernard. Digital Communications: Fundamentals and Applications. 2nd ed. Upper Saddle River, N.J: Prentice-Hall PTR, 2001.

## Version History

Introduced in R2012a