D12 · Lesson 5 · Finding the bit clock
Why the receiver must decide when to sample, the eye diagram and its widest opening, clock drift between two crystals, choosing a sampling phase from the data, tracking it with transitions, and keeping transitions coming with bit stuffing and scrambling
The transmitter sends a bit every 1/1200 s by its own crystal. The receiver has a different crystal, switched on at a different moment, so it knows neither where each bit starts nor exactly how long a bit lasts. Sample at a bit's edge and the decision is a coin toss; sample near its middle and it's clean. Clock recovery finds the best sampling instant from the received signal itself and keeps adjusting it as the two clocks drift apart, which they always do.
- Eight bits of the byte B sent as half-sine pulses, positive for 1 and negative for 0, with time in bits.
- The dashed line is what the receiver gets by sampling each bit at phase p (a fraction of the bit) and holding the value: full height when p is near the middle, shrinking toward zero at the edges.
- Slide p to each of the eight sample positions an 8-sample-per-bit receiver could choose. The middle two are equally good.
Predict
The receiver's crystal runs 100 parts per million fast compared with the transmitter's. After how many bits has its sampling instant slid half a bit away from where it started?
Each bit, the sampling instant moves by 100 × 10⁻⁶ of a bit, so half a bit takes 0.5/10⁻⁴ = 5000 bits, about 4 s at 1200 baud. A long packet would end up sampling at the bit edges, so the receiver has to keep correcting its timing during the packet, using the transitions in the data.
Name it
The eye
Overlaying every bit's waveform on one bit interval draws the eye diagram: the traces for 1s and 0s separate most widely at the best sampling instant and close together near the edges. Noise and interference (lesson 6) shrink the opening. A half-sine pulse sampled a fraction p into the bit gives of its peak, so with S samples per bit, a sample taken d samples from the center keeps of it.
Choosing the phase
With S samples per bit, a simple receiver tries each of the S phases over a block of bits and keeps the one with the largest average , the widest eye. Its timing error is then at most half a sample, of a bit.
Tracking
Clocks differ by tens of parts per million, so the phase must follow drift. Early–late detectors compare samples a little before and after the chosen instant; the Gardner detector uses the sample midway between two decisions, which should be zero at a transition when the timing is right. Either one drives a loop that nudges the sampling instant, much like the PLL in lesson 8.
Keeping transitions coming
A tracker learns nothing from a long run of identical bits. Links keep transitions coming by:
- Bit stuffing: HDLC inserts a 0 after five 1s in a row; USB inserts one after six.
- Scrambling: an LFSR (C7) whitens the data so long runs become rare.
- Line codes: Manchester (lesson 6) has a transition in every bit.
Worked example
A receiver with 8 samples per bit picks the best of its 8 phases. How far off center can it be, and how much signal does that cost with half-sine pulses?
Show the solution
- Worst timing error. The best of 8 phases is at most half a sample off:
- Sample value. The half-sine pulse there is of the peak.
- Loss in decibels.
- What matters more. Finer timing gains little; drift matters much more.
Answer at most 1/16 of a bit off center, which costs 0.17 dB.
Worked example
What does HDLC's bit stuffing (a 0 after every five 1s in a row) add in the worst case, and on random data?
Show the solution
- Worst case, all ones. One extra bit per five:
- Random data as states. The count of consecutive 1s runs through states 0 to 4.
- Chance of sitting at 4. In the steady state it is
- Stuffing rate. A 1 arriving there (probability 1/2) forces a stuffed bit:
Answer 20% overhead in the worst case and about 1.6% on random data.
Worked example
The two ends' clocks differ by 100 ppm. How far does the sampling point drift over a 100-bit frame, and over 10,000 bits?
Show the solution
- Drift over a 100-bit frame. 100 ppm is : negligible over a short frame.
- Drift over 10,000 bits.
- What that means. Long transmissions need clock recovery that keeps tracking; a single phase choice at the start isn't enough.
Answer 0.01 bit over 100 bits, and a whole bit over 10,000.
Check
Find the best sampling phase and recover the bits.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Two clocks differ by 50 parts per million. After how many bits has a receiver's sampling instant slid half a bit?
Check
A receiver takes 16 samples per bit and samples a half-sine pulse 2 samples away from its center. What fraction of the peak does it get?
Check
A receiver takes 8 samples per bit at 300 baud and picks the best phase. What's its worst timing error?
Write units the way you normally would: 1.5 µs, 1500 ns and 0.0015 ms are the same answer.
Check
A link stuffs a 0 after every 5 1s in a row. What's the overhead, in percent, when the data is all 1s?
Check
Two clocks differ by 100 ppm, and a transmission lasts 100 bits.
(a)
How far does the sampling point drift?
(b)
After how many bits has it drifted a quarter bit?
Check
A receiver with 8 samples per bit picks the best phase for half-sine pulses.
(a)
How far off center can its sample be?
(b)
What signal loss does that cost?
Explain why
Why does a receiver need transitions in the data to keep its bit clock?
The receiver can only tell where bit boundaries are from the moments when the signal changes from one symbol to another. During a long run of identical bits the signal looks the same from one bit to the next, so nothing shows whether the receiver's sampling point is drifting toward an edge. Because its crystal never runs at exactly the transmitter's rate, the sampling point does drift, and after enough identical bits it can slide into the next bit and miscount the run. Bit stuffing, scrambling and line codes all exist to guarantee transitions often enough that the timing loop can keep correcting itself.
Practice
Keep practicing
8 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.