Differential Signaling

Last time, I talked a little about USB vs. RS232. I knew I was disappointed to see serial ports ***a***become such a rarity, but judging by the comments, some people were even less happy than I was!

RS232 is a good example of a single-ended I/O specification. If the voltage is above some threshold, the logic value is in one state; and if the voltage is below some other threshold, the logic value is in the other state. Lots of things use this kind of signaling, even things like conventional TTL and CMOS logic.

RS232 first appeared in 1962 and, at the time, was usually connecting some combination of a modem, a teleprinter, and a computer. Cables were short and speeds were slow. In those days, long runs were done through current loop signaling, but that’s another story.
Single-ended I/O, however, has some notable problems. Because it is voltage sensitive, long (or otherwise lossy) wires will drop voltage and cause failures. Noise on the line can also cause errors, as can capacitive and inductive effects. Another issue can occur when the sender and the receiver have different ideas of what ground is (which is really a variation on the lossy wire problem). Normal RS232 (if there is such a thing) often uses +/-12V at the sender with thresholds set to minimize these problems. But some systems use +/-5V or even 0 and 5V. Problems occur more easily at lower voltage levels.

With today’s electronics using lower voltages like 1.8V or even less, these problems can become much worse. That’s driven a significant move to differential signaling. The idea is not new. RS422, RS485, and MIDI all use this form of signaling. So do new standards like SATA, FireWire, HDMI, and — as I mentioned last time — USB.

The idea is simple. Each bit uses two wires instead of one. One raw logic state is signified by one wire being more positive than the other. The opposite logic state is when the first wire is less positive than the other. In USB, these wires are D+ and D-. Before USB 3.0, these were the only two signaling wires and they were used half-duplex (that is, the computer sends to the device and then switches the wires to listen for a response). USB 3.0 adds another pair of wires so the host and the device can talk at the same time.

The USB spec calls out two states for the two wires: J and K. The host has pull-down resistors (that is, a resistor that grounds each data line). USB devices pull one line high with another resistor with a smaller value. That’s how USB hosts detect a device plug. The lines go from both being low to one being high and one being low. Of course, this isn’t differential signaling, yet. It just serves to tell the host someone is at the end of the wire.

Unlike RS232, USB data uses an NRZI encoding. A 0 causes the lines to change state (from J to K or from K to J). A 1 causes no change at all. That means a lot of 1s can cause the line to stall in the J or K state, and that can cause problems. So USB stacks stuff extra 0 bits into long streams of 1s.

There’s a lot more to it, of course. However, why is differential better? The key is in the reception of the data. To receive a differential signal, a receiver uses a differential amplifier. Say you are signaling with 0V and 3.6 volts (typical for low speed USB). The differential amplifier will subtract the two input wires. So you will either get 3.6V or -3.6V out. That doubles the noise margin for a given voltage level. In addition, most noise you’d get from outside sources (lightning storms, motors, radio transmitters) will be roughly the same magnitude on both wires. So when you subtract, the noise magically disappears! That’s called common mode rejection.

Within certain limitations, grounding isn’t a problem either. If the sender’s ground is offset from yours by, say, 2V, you’ll see 2V and 5.6V on the wires; and when you subtract, you get the right numbers anyway. When you have negative voltages on the wire, this can help with lossy cables as well, since equal magnitude drops in both wires look like common mode noise.

So while I too miss the days when it was simple to throw together a bit-banged serial port in software, you have to admit that USB has some distinct advantages over serial. In addition, the new serial chips and CPUs are making it easier to use than ever. So don’t fear USB.

Leave a Reply

Your email address will not be published. Required fields are marked *