I want to implement a digital Manchester encoded data receiver. The application is not dissimilar to the KeeLoq system. That is, there is no time for long link training - I want the receiver to recover the clock and parse the data from a single packet, without relying on anything before or after it. Since this is a digital receiver, the receiver has 100s of samples worth of history to re-process to allow it to do this.
I am finding clock recovery harder than expected. Averaging the number of samples between each transition and taking this as the half-bit period works in many cases, but simple simulations show that with certain payloads (i.e. those with lots of transitions) this average is pushed too high. In any case, skewing of the estimated half-bit period due to these, even when it still works, will surely mean the receiver is less robust than it could be. I have a preamble which facilitates clock recovery, but I can see (with simulation) in some cases it will not be long enough and the average is skewed too much by the full-bit periods in the payload. My application is unusual in that the underlying line rate is very low, so efficiency and latency is important.
There must be some way to take advantage of the bimodal nature of the period distribution to make a very reliable estimator, but I can't think how to do it efficiently.
What is a good approach to a digital Manchester receiver, with very low latency link establishment?
By efficiently, I mean computationally - I can probably do a brute-force search comparing the differences between normalised histograms, but I wondered if there was a better way.
EDIT: It occurred to me just now that I don't need to match a distribution to a histogram, because the Manchester encoding by nature applies another constraint: the distance between the peaks is related to the peak bin itself. So all I have to do is find the highest peak in the histogram, and then determine whether I have found the half or full width interval, by looking at the bin values x2 above or 1/2x below. I will prototype this and see if it works, but of course leave the question open for better ideas!