How Cars Work · The Brain

Senses

A computer cannot make decisions about something it cannot see. So the first thing the ECU needs is sensors — devices that measure something physical and turn it into an electrical signal the computer can read.

A modern engine has somewhere between fifteen and thirty sensors, depending on the car. Each one watches one thing.

The throttle position sensor watches how far down the gas pedal is pressed and tells the ECU how much power the driver is asking for. The mass airflow sensor sits in the intake and measures how many grams of air are flowing into the engine each second. The engine speed sensor reads the crankshaft and reports the current RPM. The coolant temperature sensor watches how hot the engine has gotten, so the ECU knows whether the engine has warmed up yet.

The cleverest one is probably the oxygen sensor. It sits in the exhaust pipe and measures how much oxygen is left in the burned gases on their way out. By measuring leftover oxygen, the ECU can tell whether the last batch of fuel was perfectly mixed, too rich, or too lean. It is like tasting your soup after cooking, to see whether the seasoning came out right.

There are more — knock sensors listening for engine pinging, camshaft position sensors, intake pressure sensors, and others. Each one feeds the ECU a different stream of numbers, dozens of times per second. Together, these sensors are the car’s senses. Without them the ECU is blind.

The brain itself

In the middle of all those sensor wires sits the ECU. From the outside, it looks like nothing — a small metal box about the size of a hardback book, usually bolted to the inside of a fender or near the dashboard. Inside is a circuit board, with a few microchips and some other electronic parts.

The most important chip on the board is the microprocessor — a small piece of silicon that can do simple arithmetic millions of times per second. (For comparison: your phone’s processor is about a hundred times faster than the one in an engine ECU. The ECU’s chip is much slower than your phone’s, but it doesn’t need to play games or stream videos. It just needs to make engine decisions, fast and reliably.)

Inside the microprocessor’s memory is the program — a long set of instructions the engineers wrote — and a big table of numbers called a map. The map is essentially a giant lookup table. For every combination of engine conditions, the map says: “given this airflow, this RPM, this temperature, fire the spark this many degrees before the piston reaches the top, and inject this many milliseconds’ worth of fuel.”

When the engine is running, the ECU’s program does roughly this, in a loop, dozens of times per second:

1. Read all the sensors. Get current numbers for airflow, RPM, temperature, oxygen, and so on.

2. Look up the right values in the map. Match the current conditions to the prescribed response.

3. Make small corrections. If the oxygen sensor says the last batch was a touch too rich, lean it out a touch; if too lean, richen it.

4. Send commands to the actuators. Tell the fuel injectors how long to spray and the ignition coils when to fire.

Then it does it all again. And again. And again. About a hundred times per second, every second the engine is running.

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