Linear Digital Modulator/Demodulator (modem) ============================================ .. author jgaeddert Joseph D. Gaeddert .. date January 1, 1975 .. location Boston, MA .. header /doc/cpfskmodem/banner.png .. keywords continuous phase, frequency shift keying, FSK, modem, Gauss, minimum shift keying, CPFSK, FSK, GMSK, MSK .. attention:: Re-work for RST, add figures The modem module implements a set of (mod)ulation/(dem)odulation schemes for encoding information into signals. For the analog modems, samples are encoded according to frequency or analog modulation. For the digital modems, data bits are encoded into symbols representing carrier frequency, phase, amplitude, etc. This section gives a brief overview of *linear* modulation schemes available in |liquid|, and provides a brief description of the interfaces. For *non-linear* digital modulation, see the documentation on :ref:`GMSK modem `, :ref:`CP-FSK modem `, :ref:`FSK modem `. Modulation Types ---------------- The ``modem`` object realizes the linear digital modulation library in which the information from a symbol is encoded into the amplitude and phase of a sample. The modem structure implements a variety of common modulation schemes, including (differential) phase-shift keying, and (quadrature) amplitude-shift keying. The input/output relationship for modulation/demodulation for the ``modem`` object is strictly one-to-one and is independent of any pulse shaping, or interpolation. In general, linear modems demodulate by finding :math:`\hat{s}`, the closest of :math:`M` symbols in the set :math:`\mathcal{S}_M = \{s_0,s_1,\ldots,s_{M-1}\}` to the received symbol :math:`r`, viz .. math:: \hat{s} = \underset{s_k \in \mathcal{S}_M}{\arg\min} \bigl\{ \| r - s_k \| \bigr\} :label: eq:modem:s_hat For arbitrary modulation schemes a linear search over all symbols in :math:`\mathcal{S}_M` is required which has a complexity of :math:`\mathcal{O}(M^2)`; however one may take advantage of symmetries in certain constellations to reduce this to :math:`\mathcal{O}(\log(M))`. .. table:: Linear modulation types available in |liquid| :widths: auto ============================================== ============= ================================== Modulation Scheme Bits/Symbol Description ============================================== ============= ================================== ``LIQUID_MODEM_UNKNOWN`` (none) unknown/unsupported scheme ``LIQUID_MODEM_PSK{2,4,8,16,32,64,128,256}`` 1-8 phase-shift keying ``LIQUID_MODEM_DPSK{2,4,8,16,32,64,128,256}`` 1-8 differential phase-shift keying ``LIQUID_MODEM_ASK{2,4,8,16,32,64,128,256}`` 1-8 amplitude-shift keying ``LIQUID_MODEM_QAM{4,8,16,32,64,128,256}`` 2-8 quadrature amplitude-shift keying ``LIQUID_MODEM_APSK{4,8,16,32,64,128,256}`` 2-8 amplitude/phase-shift keying ``LIQUID_MODEM_BPSK`` 1 binary phase-shift keying ``LIQUID_MODEM_QPSK`` 2 quaternary phase-shift keying ``LIQUID_MODEM_OOK`` 1 on/off keying ``LIQUID_MODEM_SQAM32`` 5 "square" 32-QAM ``LIQUID_MODEM_SQAM128`` 7 "square" 128-QAM ``LIQUID_MODEM_V29`` 4 V.29 star modem ``LIQUID_MODEM_ARB16OPT`` 4 optimal 16-QAM ``LIQUID_MODEM_ARB32OPT`` 5 optimal 32-QAM ``LIQUID_MODEM_ARB64OPT`` 6 optimal 64-QAM ``LIQUID_MODEM_ARB128OPT`` 7 optimal 128-QAM ``LIQUID_MODEM_ARB256OPT`` 8 optimal 256-QAM ``LIQUID_MODEM_ARB64VT`` 6 Virginia Tech logo ``LIQUID_MODEM_ARB`` 1-8 arbitrary signal constellation ============================================== ============= ================================== Dynamic-sized Modulation Types ------------------------------ Phase-shift Keying (PSK) ^^^^^^^^^^^^^^^^^^^^^^^^ With phase-shift keying the information is stored in the absolute phase of the modulated signal. This means that each of :math:`M=2^m` symbols in the constellation are equally spaced around the unit circle. .. qplot:: constellation modem/modem_constellation.c :args: psk2 :kwargs: {"scale":1.1} :width: 65% :name: modem-psk2 :caption: 2-PSK (generic BPSK) .. qplot:: constellation modem/modem_constellation.c :args: psk4 :kwargs: {"scale":1.1} :width: 65% :name: modem-psk4 :caption: 4-PSK (generic QPSK) .. qplot:: constellation modem/modem_constellation.c :args: psk8 :kwargs: {"scale":1.1} :width: 65% :name: modem-psk8 :caption: 8-PSK .. qplot:: constellation modem/modem_constellation.c :args: psk16 :kwargs: {"scale":1.1} :width: 65% :name: modem-psk16 :caption: 16-PSK .. qplot:: constellation modem/modem_constellation.c :args: psk32 :kwargs: {"scale":1.1} :width: 65% :name: modem-psk32 :caption: 32-PSK .. qplot:: constellation modem/modem_constellation.c :args: psk64 :kwargs: {"scale":1.1} :width: 65% :name: modem-psk64 :caption: 64-PSK [fig-modem-psk] depicts the constellation of PSK up to :math:`M=16` with the bits gray encoded. While |liquid| supports up to :math:`M=256`, values greater than :math:`M=32` are typically avoided due to error rates for practical signal-to-noise ratios. For an :math:`M`-symbol constellation, the :math:`k^{th}` symbol is .. math:: s_k = e^{j 2 \pi k/M} where :math:`k \in \{0,1,\ldots,M-1\}`. Specific schemes include BPSK (:math:`M=2`), .. math:: s_k = e^{j \pi k} = \begin{cases} +1 & k=0 \\ -1 & k=1 \end{cases} and QPSK (:math:`M=4`) .. math:: s_k = e^{j\left(\pi k/4 + \frac{\pi}{4}\right)} Demodulation is performed independent of the signal amplitude for coherent PSK. .. _dpsk: Differential Phase-shift Keying (DPSK) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Differential PSK (DPSK) encodes information in the phase change of the carrier. Like regular PSK demodulation is performed independent of the signal amplitude; however because the data are encoded using phase transitions rather than absolute phase, the receiver does not have to know the absolute phase of the transmitter. This allows the receiver to demodulate incoherently, but at a quality degradation of 3dB. As such the :math:`n^{th}` transmitted symbol :math:`k(n)` depends on the previous symbol, viz .. math:: s_k(n) = \exp\left\{ \frac{ j 2 \pi \Bigl(k(n) - k(n-1)\Bigr) } { M } \right\} .. _apsk: Amplitude/Phase-shift Keying (APSK) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Amplitude/phase-shift keying (APSK) is a specific form of quadrature amplitude modulation where constellation points lie on concentric circles. The constellation points are further apart than those of PSK/DPSK, resulting in an improved error performance. Furthermore the phase recovery for APSK is improved over regular QAM as the constellation points are less sensitive to phase noise. This improvement comes at the cost of an increased computational complexity at the receiver. Demodulation follows as a two-step process: first, the amplitude of the received signal is evaluated to determine in which level ("ring") the transmitted symbol lies. Once the level is determined, the appropriate symbol is chosen based on its phase, similar to PSK demodulation. Demodulation of APSK consumes slightly more clock cycles than the PSK and QAM demodulators. .. qplot:: constellation modem/modem_constellation.c :args: apsk4 :width: 65% :name: modem-apsk4 :caption: 4-APSK (1,3) .. qplot:: constellation modem/modem_constellation.c :args: apsk8 :width: 65% :name: modem-apsk8 :caption: 8-PSK (1,7) .. qplot:: constellation modem/modem_constellation.c :args: apsk16 :width: 65% :name: modem-apsk16 :caption: 16-APSK (4,12) .. qplot:: constellation modem/modem_constellation.c :args: apsk32 :width: 65% :name: modem-apsk32 :caption: 32-APSK (4,12,16) .. qplot:: constellation modem/modem_constellation.c :args: apsk64 :width: 65% :name: modem-apsk64 :caption: 64-APSK (4,14,20,26) .. qplot:: constellation modem/modem_constellation.c :args: apsk128 :width: 65% :name: modem-apsk128 :caption: 128-APSK (8,18,24,36,42) [fig-modem-apsk] depicts the available APSK signal constellations for :math:`M` up to 128. The constellation points and bit mappings have been optimized to minimize the bit error rate in 10 dB SNR. .. _ask: Amplitude-shift Keying (ASK) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Amplitude-shift keying (ASK) is a simple form of amplitude modulation by which the information is encoded entirely in the in-phase component of the baseband signal. The encoded symbol is simply .. math:: s_k = \alpha \bigl( 2 k - M - 1 \bigr) where :math:`\alpha` is a scaling factor to ensure :math:`E\{s_k^2\}=1`, .. math:: \alpha = \begin{cases} 1 & M=2 \\ 1/\sqrt{5} & M=4 \\ 1/\sqrt{21} & M=8 \\ 1/\sqrt{85} & M=16 \\ 1/\sqrt{341} & M=32 \\ \sqrt{3}/M & M \gt 32 \end{cases} .. qplot:: constellation modem/modem_constellation.c :args: ask2 :width: 65% :name: modem-ask2 :caption: 2-ASK .. qplot:: constellation modem/modem_constellation.c :args: ask4 :width: 65% :name: modem-ask4 :caption: 4-ASK .. qplot:: constellation modem/modem_constellation.c :args: ask8 :width: 65% :name: modem-ask8 :caption: 8-ASK .. qplot:: constellation modem/modem_constellation.c :args: ask16 :width: 65% :name: modem-ask16 :caption: 16-ASK [fig-modem-ask] depicts the ASK constellation map for :math:`M` up to 16. Due to the poor error rate performance of ASK values of :math:`M` greater than 16 are not recommended. .. _qam: Quadrature Amplitude Modulation (QAM) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Also known as quadrature amplitude-shift keying, QAM modems encode data using both the in-phase and quadrature components of a signal amplitude. In fact, the symbol is split into independent in-phase and quadrature symbols which are encoded separately as `LIQUID_MODEM_ASK` symbols. Gray encoding is applied to both the I and Q symbols separately to help ensure minimal bit changes between adjacent samples across both in-phase and quadrature-phase dimensions. This is made evident in [fig-modem-qam-64] where one can see that the first three bits of the symbol encode the in-phase component of the sample, and the last three bits encode the quadrature component of the sample. We may formally describe the encoded sample is .. math:: s_k = \alpha \Bigl\{ ( 2 k_i - M_i - 1 ) + j(2 k_q - M_q - 1) \Bigr\} where :math:`k_i` is the in-phase symbol, :math:`k_q` is the quadrature symbol, :math:`M_i = 2^{m_i}` and :math:`M_q = 2^{m_q}`, are the number of respective in-phase and quadrature symbols, :math:`m_i=\lceil \log_2(M) \rceil` and :math:`m_q=\lfloor \log_2(M) \rfloor` are the number of respective in-phase and quadrature bits, and :math:`\alpha` is a scaling factor to ensure :math:`E\{s_k^2\}=1`, .. math:: \alpha = \begin{cases} 1/\sqrt{2} & M=4 \\ 1/\sqrt{6} & M=8 \\ 1/\sqrt{10} & M=16 \\ 1/\sqrt{26} & M=32 \\ 1/\sqrt{42} & M=64 \\ 1/\sqrt{106} & M=128 \\ 1/\sqrt{170} & M=256 \\ 1/\sqrt{426} & M=512 \\ 1/\sqrt{682} & M=1024 \\ 1/\sqrt{1706} & M=2048 \\ 1/\sqrt{2730} & M=4096 \\ \sqrt{2/M} & \text{else} \end{cases} .. qplot:: constellation modem/modem_constellation.c :args: qam8 :kwargs: {"scale":1.5} :width: 65% :name: modem-qam8 :caption: 8-QAM constellation .. qplot:: constellation modem/modem_constellation.c :args: qam16 :kwargs: {"scale":1.5} :width: 65% :name: modem-qam16 :caption: 16-QAM constellation .. qplot:: constellation modem/modem_constellation.c :args: qam32 :kwargs: {"scale":1.6} :width: 65% :name: modem-qam32 :caption: 32-QAM constellation .. qplot:: constellation modem/modem_constellation.c :args: qam64 :kwargs: {"scale":1.6} :width: 65% :name: modem-qam64 :caption: 64-QAM constellation .. qplot:: constellation modem/modem_constellation.c :args: qam128 :kwargs: {"scale":1.6} :width: 65% :name: modem-qam128 :caption: 128-QAM constellation .. qplot:: constellation modem/modem_constellation.c :args: qam256 :kwargs: {"scale":1.6} :width: 65% :name: modem-qam256 :caption: 256-QAM constellation [fig-modem-qam] depicts the arbitrary rectangular QAM modem constellation maps for :math:`M` up to 256. Notice that all the symbol points are gray encoded to minimize bit errors between adjacent symbols. Fixed-size Modulation Types --------------------------- BPSK, QPSK, etc. Arbitrary Modulation Types -------------------------- |liquid| also allows the user to create their own modulation schemes by designating the full signal constellation. The penalty for defining a constellation as an arbitrary set of points is that it cannot be decoded systematically. All of the previous modulation schemes have the benefit of being very fast to decode, and do not necessitate searching over the entire constellation space to find the nearest symbol. An example interface for generating a pair of arbitrary modems is listed below. .. listing doc/modem/modem_arb.example.c Several pre-defined arbitrary signal constellations are available, including optimal QAM constellations, and some other fun (but perhaps not so useful) modulation schemes. .. qplot:: constellation modem/modem_constellation.c :args: arb16opt :width: 65% :name: modem-arb16opt :caption: Optimal 16-QAM .. qplot:: constellation modem/modem_constellation.c :args: arb32opt :width: 65% :name: modem-arb32opt :caption: Optimal 32-QAM .. qplot:: constellation modem/modem_constellation.c :args: arb64opt :width: 65% :name: modem-arb64opt :caption: Optimal 64-QAM .. qplot:: constellation modem/modem_constellation.c :args: arb128opt :width: 65% :name: modem-arb128opt :caption: Optimal 128-QAM .. qplot:: constellation modem/modem_constellation.c :args: arb256opt :width: 65% :name: modem-arb256opt :caption: Optimal 256-QAM [fig-modem-optqam] shows the constellation maps for the optimal QAM schemes. Notice that the constellations approximate a circle with each point falling on the lattice of equilateral triangles. Furthermore, adjacent constellation points differ by typically only a single bit to reduce the resulting bit error rate at the output of the demodulator. These constellations marginally out-perform regular square QAM (see Figures [fig-modem-M32] and [fig-modem-M128]) at the expense of a significantly increased computational complexity. .. qplot:: constellation modem/modem_constellation.c :args: sqam32 :width: 65% :name: modem-sqam32 :caption: "Square" 32-QAM .. qplot:: constellation modem/modem_constellation.c :args: sqam128 :width: 65% :name: modem-sqam128 :caption: "Square" 128-QAM .. qplot:: constellation modem/modem_constellation.c :args: V29 :width: 65% :name: modem-V29 :caption: V.29 .. qplot:: constellation modem/modem_constellation.c :args: arb64vt :width: 65% :name: modem-arb64vt :caption: Arbitrary 64-QAM VT [fig-modem-arb] depicts several available arbitrary constellation maps; however the user can create any arbitrary constellation map so long as no two points overlap (see `modem_arb_init()` and `modem_arb_init_file()` in [section-modem-digital-interface]). Interface --------- While the same modem structure may be used for both modulation and demodulation for most schemes, it is important to use separate objects for differential-mode modems (e.g. ``LIQUID_MODEM_DPSK``) as the internal state will change after each symbol. It is usually good practice to keep separate instances of modulators and demodulators. This holds true for most any encoder/decoder pair in |liquid|. An example of the `modem` interface is listed below. .. listing doc/modem/modem.example.c Listed below is the full interface to the ``modem`` family of objects. .. api:: modem