# M-Array DPSK decoding and encoding

So i'm trying to figure how how to do the encoding and decoding of an M-array Differential Phase Shift Keying (DPSK) signal. I understand how to do it for binary DPSK, but on higher ordered signals I'm missing something. Here's how I would do it for binary DPSK (M=2).

The steps should be as follows: get Data sequence -> Differential encoding -> assign phase for Tx -> (on the receiver side) do Differential decoding - assign bits from phase. The following assumes an initial bit of 1, where 1 corresponds to a phase of $\pi$

$\;\;\;\;$Data Sequence $b$ = | 1 0 1 1 0 0 1 0 1 0

$\;\;\;\;$Diff Encoding $a$ = 1 | 0 0 1 0 0 0 1 1 0 0 -> this opperation should be $a_k = a_{k-1}\oplus b_k$

$\;\;\;\;$Assign phase $\phi$= $\pi$ | 0 0 $\pi$ 0 0 0 $\pi$ $\pi$ 0 0

$\;\;\;\;$Diff Decoding $\rho$= $\ $$\$$\$| $\pi$ 0 $\pi$ $\pi$ 0 0 $\pi$ 0 $\pi$ 0 -> where $\rho = \phi_n - \phi_{n-1}$

$\;\;\;\;$Phase to bit = $\;\;\;\;\;\;\;$| 1 0 1 1 0 0 1 0 1 0

So I end up with my original sequence. but if I try to do this with M=4, I don't end up with the same sequence. Lets assume for M = 4 that 00 = 0, 01 = $\frac{\pi}{2}$, 11 = $\pi$ , and 10 = $\frac{3\pi}{2}$, and that we start with initial data 11

$\;\;\;\;$Data Sequence $b$ = $\$ | 10 11 00 10 10

$\;\;\;\;$Diff Encoding $a$ = 11 | 00 11 11 01 11 -> this opperation should be $a_k = a_{k-1}\oplus b_k$ = ($a_{k-1} + b_k$) mod M

$\;\;\;\;$Assign phase $\phi$= $\$ $\pi$ | 0 $\pi$ $\pi$ $\frac{\pi}{2}$ $\pi$

$\;\;\;\;$Diff Decoding $\rho$=$\ $$\$$\ $$\$$\$ | $\pi$ $\pi$ 0 $\frac{3\pi}{2}$ $\frac{\pi}{2}$ -> where $\rho = \phi_n - \phi_{n-1}$

$\;\;\;\;$Phase to bit =$\,$ $\, $$\,$$\, $$\,$$\, $$\,$$\, $$\,$$\,$ | 11 11 00 10 01

So here I don't end up with the same sequence. I'm not quite sure where I'm messing up there. If feel like if I can do this for M=4 I can do this for any size M. Can someone help me see where I'm going wrong? Thanks for your time!

As vaz's answer suggests, your differential encoding is incorrect. In QPSK regarded as a phase-shift-keyed signaling scheme as opposed to a 4-QAM scheme (see this previous answer of mine for some details), the input dibit $(b_I,b_Q)$ is treated as being the Gray-coded integer representation of the integers $\{0, 1, 2, 3\}$ and the phase of the RF carrier in the corresponding signaling interval is
$0$ or $\pi/2$ or $\pi$ or $3\pi/2$. In tabular form, we have $$\begin{array}{|c|c|c|c|c|c|} \hline (b_I,b_Q) & \text{normal value} ~k & \text{Gray code value} ~\ell &\text{phase-modulated signal}\\ \hline (0,0) & 0 & 0 & \sqrt{2}\cos\left(2\pi f_c t - 0\frac{\pi}{2}\right)\\ (0,1) & 1 & 1 & \sqrt{2}\cos\left(2\pi f_c t - 1\frac{\pi}{2}\right)\\ (1,1) & 3 & 2 & \sqrt{2}\cos\left(2\pi f_c t - 2\frac{\pi}{2}\right)\\ (1,0) & 2 & 3 & \sqrt{2}\cos\left(2\pi f_c t - 3\frac{\pi}{2}\right)\\ \hline \end{array}$$ That is, we can say that the QPSK modulator input $(b_I,b_Q)$ is regarded as the Gray code representation of the integer $\ell \in \{0,1,2,3\}$ and the modulator produces the output $$\sqrt{2}\cos\left(2\pi f_c t - \ell\frac{\pi}{2}\right).$$

In differential QPSK (DQPSK), the input dibit Gray-code value is subtracted (differential, get it?) from the previous transmitted dibit Gray-code value (left-handed folks can use addition if they prefer) to get the next transmitted dibit Gray code value. That is, with $\ell$ continuing to stand for Gray code value, we have that $$a_{\ell}[n] \equiv a_{\ell}[n-1] \mp b_{\ell}[n] \bmod 4. \tag{1}$$ At the demodulator, we have $$\hat{b}_{\ell}[n]\equiv \hat{a}_{\ell}[n-1] \mp \hat{a}_{\ell}[n] \bmod 4 \tag{2}$$ where the carets denote the demodulated symbols and it is the job of the project manager to make sure that the modulator designer and the demodulator designer both use the same sign ($+$ or $-$) in $(1)$ and $(2)$. In well-designed DQPSK systems, there is no explicit (two-bit binary) arithmetic used in $(2)$, and the DQPSK demodulator determines $b_{\ell}[n]$ from soft-decision data or more usually, the raw matched-filter/correlator outputs in the I and Q branches at two successive sampling instants.

Finally, you can apply the same idea to $M$-PSK with $M = 2^n > 4$ with the successive phase shifts being labeled with the Gray-coded representations of the integers $\{0, 1, 2, \ldots, 2^n-1\}$. Equations $(1)$ and $(2)$ above get modified to be arithmetic modulo $M$ but the same ideas work. The receivers are more complicated, though.

First, it seems that your encoding for $M=4$ is not correct. If you start with $a_0 = 11$ ($\phi = \pi)$ and your first data symbol is $10$, which implies a $+3 \pi/2$ phase shift according to your definition, you should end up transmitting with $\phi = \pi/2$, not $0$.

For the encoding, you may consider use an integer representation, as suggested in another question here, so that 00:=0, 01:=1, 11:=2 and 10:=3.

So, if your input data is $b =[ 10 ~ 11 ~ 00 ~ 10 ~ 10 ]$, the encoded data is (starting from 11:=2):

$a_1 = 2 + 3 \mod 4 = 1 \equiv 01$

$a_2 = 1 + 2 \mod 4 = 3 \equiv 10$

and so on.

• If i work backwards from what my data should end up being (which is the same as the starting data) I end up that my encoded bits should end up being 01 10 10 11 01, but i'm not sure sure what operation I should do in order to get there from my original data. I've tried a bitwise XOR operation, and a add with moduls M, but i'm still not getting that. Do you know what operation i should do to find $a_k$? Thanks for your input on this! – gerrgheiser Apr 25 '16 at 13:26
• oops, I think I've made a mistake: the operation $a_k=a_{k−1} \oplus b_k$ does the trick, I just forgot to take the module. So $a_k = (01 + 10) mod 4$, which is 00, in fact. I'll update my answer. – vaz Apr 25 '16 at 15:49
• When calculating $a_2$, you have $a_2 = 1+2$, the 1 comes from $a_1$ but where does the 2 come from? I would have though 11 would have been 3 because it's 3 in binary. This may be where my confusion is. Thanks for your help with this! – gerrgheiser Apr 26 '16 at 2:50
• The integer representation is a definition, it's not a binary-to-integer conversion. The idea behind is basically that if your current phase is $\phi_k$, the next symbol will shift your phase by $\Delta \phi$, and you get $\phi_{k+1} = \phi_k + \Delta \phi$, which is equal to $\phi_{k+1} \mod 2 \pi$. The integer representation is equivalent to that, it follows every possible shift in the same order, i.e., $0\rightarrow0$, $1 \rightarrow \pi/2$, ..., $3 \rightarrow 3\pi/2$, so $i_{k+1}=( i_k + \Delta i )\mod 4$. – vaz Apr 26 '16 at 7:12