How Cars Work · On the Same Wire

Taking turns

There is one obvious problem. If every computer can speak on the same wire, what happens when two of them try to speak at the same time?

They have to take turns.

The CAN bus has a clever rule for deciding who goes first. Every message has a priority number (which is, conveniently, just the same as its ID). When two computers try to talk at the same time, the one with the higher-priority message wins, and the lower-priority one waits a fraction of a millisecond and tries again.

Important messages — engine timing, brake commands, anything safety-critical — get high priority. Less urgent messages — door lock states, dashboard light statuses — get lower priority. The bus organizes itself, with no central controller and no traffic cop, just a rule that makes the right thing happen automatically.

Each message is short. About eight bytes of data — enough for a handful of numbers. The CAN bus runs at half a million bits per second, so dozens of messages can fit into a single millisecond. Plenty of bandwidth to keep all the computers in sync.

Six computers, half a second

Here is what this looks like in real time. Your mom is driving down a wet highway, and the car suddenly starts to slide sideways through a curve. Watch what happens — all in less than a second:

1. The yaw sensor detects that the car is rotating faster than the steering wheel input would suggest. It puts a message on the bus: “yaw rate higher than expected.”

2. The stability computer, which has been listening for that message, picks it up. It already knows, from messages it received earlier in the same second, the steering angle (from the steering computer), the wheel speeds (from the brake module), and the engine torque (from the ECU).

3. The stability computer does some quick math and decides the right rear wheel needs a brief, firm brake to pull the car back into line.

4. The stability computer sends a message on the bus: “brake module: please apply firm pressure to the right rear caliper for 200 milliseconds.”

5. The brake module, which has been listening for messages addressed to it, picks up that command. It applies the brake.

6. Meanwhile, the dashboard module — which is also listening to the bus — sees the “stability control activated” message and lights up a small icon to let the driver know the car is helping.

7. A fraction of a second later, the yaw sensor reports that the spin has stopped. The stability computer tells the brake module to release. The dashboard turns off the icon.

Total elapsed time: maybe 200 milliseconds — about as fast as you can blink. Six different computers, communicating across one pair of wires, working together to keep the car going where it is supposed to go. None of them in charge of the others. Each one doing its own job, listening to and producing messages on the same shared line.

That is the modern car.

All 13 chapters of How Cars Work · Library · All courses