Why does USB have 4 lines instead of 3?

No, D- is not ground. Data is sent over a differential line, which means that D- is a mirror image of D+, so both Data lines carry the signal. The receiver subtracts D- from D+. If some noise signal would be picked up by both wires, the subtraction will cancel it.

enter image description here

So differential signalling helps suppressing noise. So does the type of wiring, namely twisted pair. If the wires ran just parallel they would form a (narrow) loop which could pick up magnetic interference. But thanks to the twists the orientation of the wires with respect to the field changes continuously. An induced current will be cancelled by a current with the opposite sign half a twist further.
Suppose you have a disturbance working vertically on the twisted wire. You could regard each half twist as a small loop picking up the disturbance. Then it's easy to see that the next tiny loop sees the opposite field (upside down, so to speak), so that cancels the first field. This happens for each pair of half twists.
A similar balancing effect occurs for capacitance to ground. In a straight pair one conductor shows a higher capacitance to ground than the other, while in a twisted pair each wire will show the same capacitance.

enter image description here

edit
Cables with several twisted pairs like cat5 have a different twist length for each pair to minimize crosstalk.


It's a differential (or balanced) signal, rather than a single ended (unbalanced) signal.

This means the receiver "measures" the voltage between them, rather than between one and ground.
Say D+ is at 2V, and D- is at 1V. Now say the wire picks up some external noise (RF, mains hum, etc) It is very likely that both cables will pick up the same noise signal since they are twisted together and of the same impedance.
Say we pick up 50mV of noise. So now D+ has 2050mV on it, and D- has 1050mV - the difference between them is still 1V (1000mV) though, and this is what the receiver will "see".
If this had been done with a single ended cable, then D+ (no D-) would be at 1050mV, and ground would still be at 0V, so the receiver would see 1050mV.

This is an bit of an over simplification (but gets the basic concept across) - the ground could also pick up some noise (or have it present to start with), but due to the mismatched impedance between it and the signal the amount of noise picked up on each line will be different and this difference will be seen at the receiving end. Also it may be present initially (e.g. ground loop) which is a big problem for single ended systems.
Matching the impedances of the lines in a balanced connection is very important for good common mode rejection (i.e. rejection of the signal common to both signals) as it only works if both lines pick up exactly the same amount of noise. The signals do not have to be symmetrical. However the noise is created, as long as it affects both signals equally then the common mode rejection will be very good.


Actually, that was tried once: The Apple Desktop Bus (ADB) was used to connect keyboards and mice to Apple Macintosh computers from about 1986 until Apple ditched it for USB in 1997 with the iMac.

It had four wires: 5V, ground, data, and power-switch. The power-switch line was just for the power button on the keyboard, which connected the line to ground, and told the power supply to start up the machine. It had to be its own wire so it still worked even if the 5V line was off.

Other than that, the data line carried everything... very slowly. The bus never really progressed beyond being a desktop device bus because it not only had a single-ended signal, but it had length limits (you get reflections off the end of the bus, since it's not terminated at each end).

So Intel decided to use differential signaling for USB. If you want a good idea of what differential signaling buys you, compare the performance in noise of the single-ended RS-232 bus to the differential RS-422 bus. RS-422 can be driven over a longer cable with less source voltage at a given bit error rate.

Why is this? The long version takes a day's lecture in electromagnetics class. The short version is that a noise signal will induce the same voltage in both wires of a differential pair, so the comparator at the receiver end cancels it out (it rejects common-mode voltage very well). A single-ended line has no comparable guarantee, since there's no guarantee that the ground line and signal line will pick up the same noise signal; grounds might even be connected via chassis ground and the return current will take completely different routes.