# What are the options for turning a bit stream into a byte stream?

I am creating a system (modulator and demodulator) for broadcasting binary data through an analog signal. I'm using BPSK with great success – at least, I'm generating great graphs.

Green is input signal, red is carrier phase, pink is digital zeroes and ones.

My question is – now that I have that pink stream of binary data, how to delineate bytes? I have been reading about clock recovery, 8b/10b, Manchester, NRZI... And I'm a little confused about what those offer me.

I imagine I could just come up with a system like Manchester, where each 0 is just 01 and each 1 is 10 – and then use a pattern like 0000 to mean "start of next byte" – but this doesn't seem right. Under that system, how would you interpret 10000010? It could mean the last byte ended with a 1 and the next byte starts with a 1 – or it could mean the exact opposite – the last byte ends with a 0 and the next byte starts with a 0.

I know there must be some basic DSP concepts that could help me here, please point me to some resources!

• With Manchester coding, each $8$-bit data byte will get mapped to $16$ zeroes and ones on the channel. Consider inserting a pattern such as $10111101$ into the Manchester-coded bit pattern after, say, $4$ data bytes $= 1$ $32$-bit data word $=64$ Manchester-coded channel bits. – Dilip Sarwate May 6 '13 at 14:38

I would use a frame alignment word to synchronize your data. The basic idea is to insert your FAW at the beginning of every $N$ bytes. After you demodulate the data you look for the FAW to synchronize the data. To avoid false positives you should try to have a longish FAW (16 bits should be plenty) and look for repeated FAWs. To avoid inefficient overhead you should try to make $N$ large compared to the size of the FAW.