Manchester encoding explained

Manchester encoding combines the clock and data of (typically) synchronous data into one serial data stream. The combination is simply an exclusive - NOR:


manchester data = NRZ data ^ (NRZ clock)'


where
NRZ data == Non-Return to Zero data. A fancy way of saying there is no
encoding i.e. a logic 1 is +5 volts and a logic 0 is 0 volts.
NRZ clock == A clock whose rising edge occurs in the middle of each NRZ data bit

  ^   == exclusive or operator
( )'  == The boolean complement operator

Here's an example comparing NRZ to Manchester:
          -+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+
NRZ        |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
clock      +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--

           +-----+     +-----+           +-----------------+
NRZ        |     |     |     |           |                 |
data      -+     +-----+     +-----------+                 +---
              1     0     1     0     0     1     1     1

Manchester    +-----+     +-----+  +--+     +--+  +--+  +--+
Encoded       |     |     |     |  |  |     |  |  |  |  |  |
Data      ----+     +-----+     +--+  +-----+  +--+  +--+  +--

Click here for this and other encoding schemes.


If you wish to "bit-bang" the serial data stream and decode the Manchester data, typically, a bit-banging algorithm goes as follows.



The "continuous edges" of Manchester-encoded data dilemmma/panacea depends on your computing resources. If you have to use the PIC16C54 with a 32kHz crystal, your capabilities are extremely limited. Instruction cycles are around 125 usec. However, you need at least two cycles to acquire one sample.
Yet a moderate data rate of 9600 baud (NRZ) has a bit time of about 100 usec.
I think you see the picture.

On the other hand, if you can increase the frequency, then it is possible to continuously re-synchronize to the data. This will allow you to accurately sample the middle of the data bits, and perhaps saving you the burden of having to filter the data.


Thanks to Scott Dattalo for this.