The Quadrature Demod block accepts a stream of complex samples, such as the narrow baseband stream containing the desired signal, and produces a stream of floats that represent a frequency demodulation. This block is most useful in demodulating FM, FSK, GMSK, and similar modulations that carry information through changes in frequency.

This block does not support C++ output, so it cannot be used when the output language of a flowgraph in GRC is C++.

## Mathematical Description

The output of the block is the signal frequency in relation to the sample rate, multiplied with the gain. It produces this by calculating the product of the one-sample delayed-&-conjugated input and the undelayed signal, and then calculates the argument (a.k.a. angle, in radians) of the resulting complex number:

${\displaystyle y[n]=\mathrm {arg} \left(x[n]\,{\bar {x}}[n-1]\right)}$

Let x be a complex sinusoid with amplitude A>0, (absolute) frequency ${\displaystyle f\in \mathbb {R} }$ and phase ${\displaystyle \phi _{0}\in [0;2\pi ]}$ sampled at f_s>0 so, without loss of generality,

${\displaystyle x[n]=Ae^{j2\pi ({\frac {f}{f_{s}}}n+\phi _{0})}}$

then

${\displaystyle y[n]=\mathrm {arg} \left(Ae^{j2\pi \left({\frac {f}{f_{s}}}n+\phi _{0}\right)}{\overline {Ae^{j2\pi ({\frac {f}{f_{s}}}(n-1)+\phi _{0})}}}\right)\ }$

${\displaystyle =\mathrm {arg} \left(A^{2}e^{j2\pi \left({\frac {f}{f_{s}}}n+\phi _{0}\right)}e^{-j2\pi ({\frac {f}{f_{s}}}(n-1)+\phi _{0})}\right)\ }$

${\displaystyle =\mathrm {arg} \left(A^{2}e^{j2\pi \left({\frac {f}{f_{s}}}n+\phi _{0}-{\frac {f}{f_{s}}}(n-1)-\phi _{0}\right)}\right)\ =\mathrm {arg} \left(A^{2}e^{j2\pi \left({\frac {f}{f_{s}}}n-{\frac {f}{f_{s}}}(n-1)\right)}\right)\ }$

${\displaystyle =\mathrm {arg} \left(A^{2}e^{j2\pi \left({\frac {f}{f_{s}}}\left(n-(n-1)\right)\right)}\right)\ }$

${\displaystyle =\mathrm {arg} \left(A^{2}e^{j2\pi {\frac {f}{f_{s}}}}\right)}$

${\displaystyle A}$ is real, and so is ${\displaystyle A^{2}}$, and hence only scales, therefore ${\displaystyle \mathrm {arg} (\cdot )}$ is invariant: = arg ${\displaystyle \left(e^{j2\pi {\frac {f}{f_{s}}}}\right)={\frac {f}{f_{s}}}}$

## Parameters

Gain
Gain setting to adjust the output amplitude. Set based on converting the phase difference between samples to a nominal output value. Default: "samp_rate/(2*math.pi*fsk_deviation_hz)".

## Example Flowgraph

### Example 1

This flowgraph shows the Quadrature Demod block as a Frequency Shift Keying detector. First, the Frequency Xlating FIR Filter acts as a channelizer, extracting a narrow baseband signal from a wider stream. Then the Quadrature Demod block returns floats that are >1 if the upper frequency is louder, 0 if they are equal, and <0 if the lower frequency is louder, thus demodulating FSK. In this scenario, if fsk_deviation is defined as the difference between the upper and lower frequencies, and the baseband sampling rate is known (after the decimating from the Freq Xlating FIR Filter block), then a good formula for the Gain parameter would be baseband_samp_rate / (math.pi * fsk_deviation). This causes the block to produce output floats that will never have a magnitude greater than 1.0 for the actual symbols.

### Example 2

This flowgraph shows BFSK signal recovery using Quadrature Demod block

Transmitted and received bits using above example

C++ files