In this article I will discuss engine control units (ecu).
The modern ecu is a powerful and very flexible tool in controlling an engine.
To keep things short I will only be talking about how an ecu controls fuel and ignition timing.
To start off, this computer needs to know exactly what position the engine is in. And for 4 stroke engines, it needs to know if it's on its power stroke or its intake stroke.
To accomplish this, most ecu driven vehicles use a proximity or hall effects sensor on the crank (or cam shaft). By sending a signal every time the engine turns over the ecu can interpret exactly where the engine is and how fast it's spinning.
Now knowing this information the ecu uses a few different "maps" to figure out how much fuel to give, when to give it, and when to ignite it. These maps are nothing more then tables. (See picture below for an example)
These tables can be 2 dimensional, 3d, 4d, or even 5d. The higher the dimension, the more variables the output value depends on. For example, a 2d Fuel map table could give you an output fuel amount based upon engine speed and throttle position. Other dimensions can include everything from engine temperature to intake pressure to air temperature.
These added dimensions are a very detailed way of adjusting the engines settings. Many aspects of the engine can be simplified and 4d/5d maps are often times overkill. These simplifications are known as adders and multipliers. Adders are numbers that add onto timing to advance or retard by set intervals. Multipliers are numbers that multiply the amount of fuel used.
For example, when you start up a vehicle for the first 10-30 seconds the engine is actually being flooded with up to 20x more fuel then it would normally consume. If you have ever tried to start a pull start motor without first choking off the engine then you probably have an idea of how hard it is to start an engine without enough fuel.
Now you have an idea just some of the tools car companies have to control an engine, careful tweaking of these numbers will always end up yielding a compromise between power, fuel economy, and engine life/temperature. To say that any one car company is better then another because they can tune an engine to get more power, or more fuel economy is stupid because tuning that way was a trade off in some other regard.