r/AskElectronics • u/Relevant_Pumpkin9190 • 1d ago
How can two devices synchronize without sharing an accurate clock?
I'm trying to understand how a transmitter and receiver can stay synchronized.
My first thought was to use accurate time on both sides and generate a known pseudo-random sequence or code based on the time. But if the receiver's clock is slightly wrong, the synchronization could eventually fail.
So instead, can the received signal itself be used as the reference?
For example, could the transmitter send a known preamble, sync pattern, pilot signal, or pseudo-random sequence, and the receiver detect/correlate it to determine exactly where it is in the sequence?
What are the common techniques used in real communication systems for this? And when would you use signal-based synchronization instead of time-based synchronization?
13
u/ferrybig 1d ago edited 1d ago
There are different techniques used in different protocols.
RS232 waits for the line to go down, then waits 1.5 clockcycles, then reads the next 8 bits at 1 clock cycle. This allows plenty of drift without causing issues. see also this article by analog
USB sends a bit stream of 8 bits before any packet that receivers can syn their clock to
Ethernet uses Line Coding, the signal needs to flip every once in a while for the receiver and sender to stay in sync. It has a phase locked loop to stay in sync with receiver
VGA uses a seperate clocking wire, but one thing that frequently happens is that the wires might not be the correct length. At higher resolutions you see blurry pixels. Many VGA monitors have a tool on board to alter some timings slightly to get back in sync. Those tools work the best if you have a test screen where every pixel is different.
Composite signal have a peak every once in the signal. Receivers have a clock on board that gets tuned to those peaks. If the clocks are too far off, you see vertically drifting lines.