What a Wire Can Hold
Telegraph lines, bits and the Dallas 1-Wire protocol
Three things to spend
A wire holds exactly as many bits as its receiver can tell apart, and that number depends on three things: how many lines there are, how many states each can show, and how many moments get read.
Telegraph engineers worked this out by hand between the 1830s and the 1870s, long before Claude Shannon gave the quantity a unit in 1948. They bought lines, states or time according to what each one cost. Wire over distance cost the most, so they converged on a single line and spent time instead.
Dallas Semiconductor's 1-Wire bus, built for small sensors and memory chips, reaches the same single line for a different reason: it saves pins, not miles of wire. The two systems look alike on an oscilloscope, and they even share a way of telling one symbol from another. They differ in who keeps time and where the power comes from.
One line, one moment
A single telegraph line at a single moment holds one bit, provided the receiver knows it is being spoken to.
The line is a circuit: a battery, a long wire, a relay or sounder at each station, and usually the earth as the return path. A key makes or breaks that circuit, so current is either flowing or it is not. That is one distinction, and one distinction is one bit.
The catch is that silence is ambiguous. No current could mean a deliberate zero, a line with nothing to say, a cut wire or a flat battery. So a bare on-or-off line can carry a bit, but it cannot tell the receiver that a bit is being carried.
Telegraphers met this problem in two ways:
- Make idle a signal. American closed-circuit lines rested with current flowing and sent by interrupting it. A dead line then showed itself at once, because current held the sounder's lever down, and without it the lever came up and stayed up.
- Spend another state. Gauss and Weber sent positive or negative pulses instead of switching current on and off, so the receiver's magnet swung left or right. Rest now meant only rest, and each swing still carried one bit.
The first answer comes back in 1-Wire, which rests its line high and treats every low as an event.
More lines, more states, more time
Capacity multiplies across the three resources: N lines, each showing k distinguishable states, read over T moments.
bits = N × T × log2(k)That is a ceiling. The code decides how much of it to use, and historical telegraphs often used far less, on purpose.
The formula is older than the bit, and it came out of the telegraph. Harry Nyquist, writing on telegraph speed in the Bell System Technical Journal in 1924, gave it as W = K log m, where W is the speed and m is "the number of current values". Ralph Hartley generalised it in 1928 to H = n log s, for n selections from s symbols, taking as the measure of information "the logarithm of the number of possible symbol sequences". Shannon's paper of 1948 builds on "the important papers of Nyquist and Hartley", and credits the word bit to John Tukey.
| Scheme | Lines (N) | States per line (k) | Moments (T) | Ceiling | Actually used |
|---|---|---|---|---|---|
| One on/off line | 1 | 2 | 1 | 1 bit | 1 bit |
| Edison's quadruplex (1874), one direction | 1 | 4 | 1 | 2 bits | 2 bits |
| Baudot's five-unit code (1870s) | 1 | 2 | 5 | 5 bits | 5 bits |
| Five parallel on/off lines | 5 | 2 | 1 | 5 bits | 5 bits |
| Cooke and Wheatstone's five needles (1837) | 5 | 3 | 1 | 7.92 bits | 4.32 bits (20 letters) |
| Sömmerring's electrochemical telegraph (1809) | 35 | 2 | 1 | 35 bits | 5.13 bits (35 symbols) |
The last two rows show the gap. Sömmerring gave each symbol its own wire, the code now called one-hot: trivially easy to read and ruinous in wire. Cooke and Wheatstone moved exactly two needles at a time, so they pointed at a letter on a grid and the clerk needed no code book. Current went out along one needle's wire and back along the other's, giving 5 × 4 = 20 ordered pairs.
The quadruplex shows what extra states can do. Edison used two independent properties of the current, its direction and its strength, so one wire carried two bits at once, and a balanced circuit let it do so in both directions. The limit on this route is noise: every added level asks the receiver for a finer judgement, and long wires on wet poles leak. The Shannon–Hartley theorem later put a number on that limit, C = B log₂(1 + S/N): a line's capacity grows with its bandwidth, and only with the logarithm of its signal-to-noise ratio.
Five parallel lines and five moments on one line both come to five bits, so the formula alone cannot choose between them. Cost chooses. Five wires cost five times as much to string, while five moments cost only a longer wait, and over a hundred miles that decides it. Cooke and Wheatstone themselves went from five needles to two and then one within a few years.
The problem of the clock
Spending time instead of wire creates a new cost: both ends must agree on when one moment ends and the next begins.
A second line carrying a clock would settle it, and modern chip buses such as SPI and I²C do exactly that. On a telegraph route that meant paying for another wire, so the industry looked for ways to keep time on the line it already had. It found three, in rough historical order:
- A trained ear (Morse). The sender's hand sets a unit: in International Morse a dot is one unit, a dash three, the gap inside a letter one, between letters three, between words seven. The line is binary, but the meaning sits in the durations, so the listener recovers the rhythm continuously and tolerates a drifting hand. At 25 words per minute a dot lasts about 48 ms.
- Machines in step (Baudot). Rotating distributors at each end turned together, with correction signals to hold them in phase. Every character took five equal slots, and several operators could share a wire by taking turns. This was fast and expensive to keep aligned.
- Start and stop (teleprinters). The line rested in one state, and a start pulse tripped the receiver's cam to run through one character on its own motor. A stop pulse brought it to rest again. The clock only had to hold for one character, so a cheap motor would do, and every UART still works this way.
The pattern is that resynchronising more often lets you use a worse clock. Baudot's machines had to stay aligned for long stretches, while a teleprinter resets every character. 1-Wire takes this to its limit by resetting on every bit.
Dallas 1-Wire
1-Wire puts signalling, timing and the chips' own power on one data line plus a ground.
The name is generous in the way "single-wire telegraph" was: there is a return path, here a ground wire instead of the earth. A pull-up resistor, typically 4.7 kΩ, holds the line high, and each device can only pull it low through an open-drain transistor. In normal signalling nobody drives the line high, so devices cannot fight.
A slave can run with no power pin at all. It charges a small internal capacitor while the line is high and lives off that charge during lows. This is why the line must stay high most of the time, and why idle high is more than a convention.
Every exchange starts the same way. The master holds the line low for at least 480 µs as a reset, then releases it, and each slave answers with a presence pulse of 60 to 240 µs. After that, bits move in slots of 60 to 120 µs, and only the master ever begins one:
- Write 1: the master pulls low for 1 to 15 µs, then releases.
- Write 0: the master pulls low for 60 to 120 µs.
- Read: the master pulls low briefly and releases, then samples within 15 µs of the falling edge. A slave sending 0 keeps the line low, and a slave sending 1 does nothing.
On a write, the slave looks at the line roughly 15 to 60 µs after the falling edge, and that edge restarts its timer. Its oscillator therefore only has to hold for one slot, which is why a tiny chip with a poor clock can take part. An optional overdrive mode runs about ten times faster on the same principle.
Addressing is built into the silicon. Each device carries a factory-set 64-bit ROM code: an 8-bit family code, a 48-bit serial number and an 8-bit CRC. The Match ROM command selects one device, and Search ROM discovers all of them by walking a binary tree, one bit position at a time.
The search relies on the fact that a low from any device beats a high from all the others. At each position every remaining slave sends its bit and then the complement of that bit, and the master reads two values:
- 0 then 1: every remaining slave has a 0 here.
- 1 then 0: every remaining slave has a 1 here.
- 0 then 0: both values exist, so this is a branch to come back to.
- 1 then 1: no slave answered.
The master then writes the bit it wants to follow, and slaves holding the other value drop out until the next reset. A whole 64-bit address costs three slots per bit, and the bus finds its own population.
Telegraph line, the letter A
dot gap dash
on +--------+ +------------------------+
| | | |
off --+ +--------+ +-----
1 unit 1 unit 3 units
1-Wire bus, four time slots
write 1 write 0 read 1 read 0
high ---+ +------------+ +-+ +------------+ +------
| | | | | | | |
low +---+ +------------------+ +---+ +-=======+
: : : :
low 1-15 µs low 60-120 µs stays high slave holds lowThe colons mark when the receiver samples: the slave on a write, the master on a read. The = stretch is the slave holding the line low, inside a pulse the master began. The drawing is not to one scale: a Morse dot at 25 words per minute is about 48 ms, a 1-Wire slot about 60 µs.
A 1-Wire write is a dot or a dash inside a fixed frame: the slave ignores the pulse's length and looks once at a set delay.
What 1-Wire inherits, and what it changes
1-Wire keeps the telegraph's single line, its pulse-length symbols and its dominant state, and replaces the human operator with a master that owns all the timing.
Three things carry over:
- Length as the symbol. A short low and a long low are a dot and a dash. A Morse listener, though, judges length against the sender's rhythm, while a 1-Wire slave makes one look at one fixed delay and needs no rhythm at all.
- A dominant state. On a closed-circuit line, any one open key stops the current for the whole circuit, which is how a receiving operator could "break" a sender mid-message. On 1-Wire, any one device pulling low holds the line low for everyone. Series and parallel are duals here: a loop shares current, so open wins, and a bus shares voltage, so low wins.
- A shared line with addresses. Every station on a shared line heard all the traffic and listened for its call sign. Every 1-Wire slave sees all the traffic and waits for its ROM code.
The changes matter more:
- Who keeps time. Any telegraph operator may start sending, at their own speed. On 1-Wire even a slave's reply happens inside a pulse the master began, so the slave needs almost no sense of time.
- What a collision means. Two operators sending at once produce garble, and someone has to sort it out. Two slaves answering at once produce a defined result, and the ROM search reads it as information.
- Where the power comes from. A telegraph line powered its relays, and an office could work its sounder from a local battery. A parasitic 1-Wire slave has no other supply, so the code must leave it enough time high to survive.
- Who listens. Morse could tolerate an uneven hand because a person was decoding it. 1-Wire replaces that judgement with fixed windows, and it replaces "please repeat" with a CRC.
| Property | Telegraph line | Dallas 1-Wire |
|---|---|---|
| Conductors | One wire per circuit, earth return | One data line, one ground |
| Idle state | Current flowing (American closed circuit) | Line high through a pull-up |
| Who starts a symbol | Whoever is sending | Always the master |
| Symbol | Run lengths, read by ear | Fixed slot, sampled at a set delay |
| Resynchronised | Continuously, by the listener | At every bit's falling edge |
| Rate | About 21 signalling units a second at 25 words per minute, carrying roughly 10 bits/s of text | Roughly 16 kbit/s on the line at standard speed |
| Addresses | Call signs assigned by people | 64-bit codes set at the factory |
| Finding stations | Everyone knows the circuit list | Binary search over the wire |
| Receiver power | Line for the relay, often a local battery for the sounder | The line itself, if parasitic |
| Errors | An operator asks for a repeat | CRC, then the master retries |
| Reach | Hundreds of kilometres, with relays | As much as 200 m, with one sensor |
The last row hides a shared limit. Both systems are held back by the time it takes to charge a wire's capacitance through a resistance. Kelvin's law of squares described this for submarine cables, where signalling speed fell with the square of the length. On 1-Wire the same physics appears as the pull-up's struggle to bring the line back high before the next slot.
Closed-circuit telegraph: stations in series
line battery --- station A --- station B --- station C --- earth plate
| key closed key closed KEY OPEN |
+- - - - - - current returns through the earth - - - - - - +
1-Wire bus: devices in parallel
+V -- pull-up --+-----------+-----------+------ data line
| | |
master slave 1 slave 2
released released PULLING LOW
| | |
----------------+-----------+-----------+------ groundSeries and parallel are duals here: the loop shares current and the bus shares voltage, and in each, one station can overrule all the others.
The same bargain
The telegraph and 1-Wire made the same bargain, giving up wires and paying in time, and they differ mainly in who was asked to pay.
The telegraph paid with skilled people. A good operator was a clock, a decoder and an error corrector, which is why one wire could work at all. 1-Wire pays with a master that does all the thinking and a slot rate that is low by the standards of a chip. Its slave can be cheap enough to fit in a sensor, or a steel button on a key ring, because the master carries the burden the operator used to carry.
The arithmetic never changed. A line still holds what its receiver can tell apart, multiplied across lines, states and moments. What moved between 1837 and 1-Wire was the answer to a practical question: which of the three is cheapest here, and who has to keep time?
Sources
- DS18B20 datasheet, Dallas Semiconductor, as hosted by SparkFun; its Search ROM section gives the four read results quoted here
- Application note 126, 1-Wire Communication Through Software, Dallas Semiconductor, as hosted by Rose-Hulman Institute of Technology
- 1-Wire, Morse code, Baudot code, Émile Baudot, Cooke and Wheatstone telegraph, Electrical telegraph, Telegraph key, Telegraph sounder, Break key, Teleprinter, Asynchronous serial communication, Lord Kelvin and Bit, Wikipedia
- Quadruplex telegraph, The Thomas A. Edison Papers, Rutgers University
- Certain Factors Affecting Telegraph Speed, H. Nyquist, Bell System Technical Journal 3 (1924), 324–346
- Transmission of Information, R. V. L. Hartley, Bell System Technical Journal 7 (1928), 535–563, read in a scan
- A Mathematical Theory of Communication, C. E. Shannon, Bell System Technical Journal 27 (1948)
- Shannon–Hartley theorem, Wikipedia
- 1-Wire bus length, Wiren Board wiki, a third party citing Maxim's Tutorial 148
- Later patents on correcting rings in Baudot-type distributors, read only as search excerpts
- Not consulted: Tom Standage's The Victorian Internet (1998), and Maxim's application note 187, whose hosts did not answer