This article builds upon the introductory article about baseband modulation where Manchester code was explained, and hopefully understood and accepted by the reader as a viable code.
One problem with the "vanilla" Manchester code, and for instance with many other codes, is that an inversion of polarity (that inverts all chirps) will lead to RX detecting an inverted message.
0 | 1 | 0 |
0 | 1 | 1 | 0 | 0 | 1 |
1 | 0 | 0 | 1 | 1 | 0 |
1 | 0 | 1 |
This happens easier than you might think: cables are built with inverted wires, users connect the plug the wrong way, and some filters that eliminate DC bias invert the signal by design.
A simple and clever solution is to decode the message based on changes or differences of signal. No change is 0, change is 1. Level changes are reliably detected regardless of polarity.
In order to RX rely on changes, the TX must send a modified bit stream. The simplest way to do it is to integrate, that is, keep summing the message bits (and making 1+1=0). By integrating at one side and differentiating at the other side, we end up with the original message.
0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
... any line code (e.g. Manchester) takes place here...
1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 |
x | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
Note that, in the received message, we lose the very first bit, because we did not have a previous bit to differentiate. This is another reason why the preamble is so important: errors like this fall over the preamble, not over the message.
Differential encoding can be understood as a very simple form of convolutional coding since each transmitted symbol depends on a number of previous symbols (in this case, just two).
Differential Manchester is also known as the FM (Frequency Modulation) encoding, employed in early floppy disks and hard drives.