Engine control unit and electronic engine management

How the ECU's hardware and software calculate fuel and spark every cycle: base air mass, target lambda, warm-up and transient corrections, closed-loop fuel trims, interpolated ignition maps and limp-home, with map-interpolation, pulse-width and ADC numericals.

Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Modern emission norms such as BS-VI cannot be met with carburettors and mechanical distributors. The engine control unit (ECU) reads a dozen sensors, calculates fuel quantity and spark timing for every cylinder event, runs closed-loop corrections and monitors itself, all within a few milliseconds. Every calibration, tuning or diagnosis job on a modern engine starts with knowing how this loop is organised.

Key ideas

ECU hardware.

  • Power supply: regulates battery voltage, provides a stable 5 V reference for sensors, and survives cranking dips and load-dump spikes.
  • Input conditioning: filters and scales analogue signals (MAP, TPS, temperatures, O₂) for an analogue-to-digital converter (ADC); conditions pulse signals (crank, cam, wheel speed) for timer-capture inputs.
  • Microcontroller: typically a 32-bit automotive processor with a real-time operating system. Tasks are scheduled by time (e.g. every 10 ms) and by crank angle (every tooth or cylinder event).
  • Memory: flash for program and calibration maps, RAM for working values, EEPROM or emulated flash for adaptive values and stored fault codes.
  • Output drivers: injector drivers, ignition-coil drivers, PWM low-side switches for solenoids, H-bridges for the throttle motor, relay drivers.
  • Communication: CAN with other ECUs and the diagnostic connector; a watchdog resets the processor if software hangs.

Fuel control.

  1. Base air mass per cylinder per cycle, from a MAF sensor or by speed-density (MAP, intake temperature, rpm and a volumetric-efficiency map).
  2. Base fuel = air mass ÷ target air–fuel ratio. The target is λ = 1 for most operation (needed for the three-way catalyst), richer at full load for power and component protection.
  3. Corrections: cold-start and warm-up enrichment (fuel condenses on cold walls), acceleration enrichment on rapid throttle opening, deceleration fuel cut-off, and wall-wetting compensation.
  4. Closed-loop lambda control: once the O₂ sensor is hot and the engine is in normal operation, a short-term fuel trim (STFT) responds to the sensor switching rich and lean, and a long-term fuel trim (LTFT) learns persistent offsets (e.g. an air leak or ageing injector) and stores them. The loop is open during cold start, wide-open throttle and fuel cut.
  5. Pulse width = required fuel ÷ injector flow + battery-voltage-dependent dead time.

Ignition control. A base timing map of engine speed × load (MAP or air mass per stroke), interpolated between breakpoints, then corrected for coolant and intake temperature and reduced cylinder-by-cylinder when the knock sensor detects knock. Dwell time is set from battery voltage so coil energy stays constant.

Other functions. Idle speed control (throttle or bypass air plus spark), electronic throttle control in a torque-based structure (pedal request → torque demand → throttle, spark, fuel), variable valve timing, EGR, evaporative purge, catalyst heating after cold start, cooling fan and alternator set point, rev limiter, and immobiliser.

Diagnostics and safety. The ECU checks sensor signals for range and plausibility, monitors misfire and catalyst efficiency, stores fault codes and lights the malfunction indicator lamp (next topic). If a key sensor fails it uses a substitute value and runs in limp-home mode.

Open loop vs closed loop. Open-loop control computes the output from a model and maps and does not check the result; closed-loop control measures the result (λ, knock, idle speed) and corrects. Engine management combines both: maps give a fast, nearly right answer, and feedback trims the error.

Formulas

λ = AFR_actual / AFR_stoich

  • Dimensionless; AFR is by mass. AFR_stoich ≈ 14.7 for petrol.

m_f = m_a / (λ_target × AFR_stoich)

  • m_f: fuel mass per cylinder per cycle (kg), m_a: air mass per cylinder per cycle (kg), λ_target: desired λ.

t_pw = t_base × (1 + STFT + LTFT) + t_d(V_batt)

  • t_pw: final pulse width (s), t_base: effective opening time for the base fuel (s), STFT and LTFT: fuel trims as fractions (e.g. +0.04), t_d: dead time at the present battery voltage (s).

y = y₁ + (x − x₁) × (y₂ − y₁) / (x₂ − x₁)

  • Linear interpolation between map breakpoints x₁, x₂ with values y₁, y₂; applied along one axis and then the other for a 2-D (bilinear) map.

V_LSB = V_ref / 2ⁿ, V_in ≈ code × V_ref / 2ⁿ

  • V_LSB: ADC resolution (V), V_ref: reference voltage (V), n: number of bits, code: ADC output count.

t = θ / (6 × n)

  • Time (s) for the crank to turn θ degrees at n rpm.

Worked examples

Example 1 (standard). An ignition map gives: at 40 kPa — 30° BTDC at 2000 rpm and 34° at 3000 rpm; at 60 kPa — 24° at 2000 rpm and 28° at 3000 rpm. Find the spark advance at 2400 rpm and 52 kPa, and the time from spark to TDC.

  1. Speed fraction = (2400 − 2000) / (3000 − 2000) = 0.4.
  2. At 40 kPa: 30 + 0.4 × (34 − 30) = 31.6°. At 60 kPa: 24 + 0.4 × (28 − 24) = 25.6°.
  3. Load fraction = (52 − 40) / (60 − 40) = 0.6; advance = 31.6 + 0.6 × (25.6 − 31.6) = 28.0°.
  4. t = θ / (6 n) = 28 / (6 × 2400) = 1.94 × 10⁻³ s.

Answer: 28.0° BTDC, fired 1.94 ms before TDC.

Example 2 (GATE level). (a) The ECU's base effective injection time is 6.0 ms. Short-term trim is +4 %, long-term trim −2 %, and at the present battery voltage the dead time is 1.1 ms. Find the commanded pulse width. (b) A MAP sensor's output is linear from 0.5 V at 20 kPa to 4.5 V at 105 kPa. A 10-bit ADC with a 5.0 V reference returns code 512. Find the voltage, the MAP and the pressure resolution of one ADC count.

  1. t_pw = 6.0 × (1 + 0.04 − 0.02) + 1.1 = 6.12 + 1.1 = 7.22 ms.
  2. V_in = 512 × 5.0 / 1024 = 2.50 V.
  3. Sensor slope = (105 − 20) / (4.5 − 0.5) = 21.25 kPa/V; MAP = 20 + (2.50 − 0.5) × 21.25 = 62.5 kPa.
  4. V_LSB = 5.0 / 1024 = 4.88 mV; pressure per count = 0.00488 × 21.25 = 0.104 kPa.

Answer: 7.22 ms; 2.50 V, 62.5 kPa, about 0.10 kPa per count.

Common mistakes

  • Thinking the O₂ sensor sets the fuel quantity. The base quantity comes from air mass and maps; the sensor only trims it in closed loop.
  • Expecting closed-loop control at cold start or full throttle, where the ECU deliberately runs open loop.
  • Treating a large positive long-term trim as a fault in the ECU, when it usually points to an air leak, low fuel pressure or a weak injector.
  • Interpolating a 2-D map along only one axis.
  • Forgetting the dead time is added, not multiplied, by the trims.
  • Using 2ⁿ − 1 and 2ⁿ inconsistently in ADC problems; state which convention you use.

For GATE ME

This topic appears through control and measurement ideas: open-loop versus closed-loop, feedback, linear interpolation, ADC resolution and quantisation, and IC-engine fuel and timing numericals (air–fuel ratio, λ, crank angle to time). Practise bilinear interpolation and fuel-mass calculations with consistent units.

Quick check

  1. Name two conditions under which the ECU runs fuel control open loop.
  2. What is long-term fuel trim?
  3. A 12-bit ADC has a 5 V reference. What is its resolution?
  4. Why does the ECU store calibration maps in flash memory?
  5. What does the ECU do if the coolant temperature sensor fails?

Answers: 1. Cold start/warm-up before the O₂ sensor is ready, and wide-open throttle enrichment (also deceleration fuel cut-off). 2. A learned, stored correction for persistent fuel errors, built up from the short-term trim. 3. 5 / 4096 = 1.22 mV. 4. It keeps data without power but can be reprogrammed for updates. 5. Sets a fault code, lights the MIL and substitutes a default value (limp-home), often running the cooling fan continuously.

Try answering each one aloud before you open it.

  1. 1.What is an Engine Control Unit (ECU) and what is its primary function in a vehicle?Concept

    The engine control unit is a microcontroller-based computer that runs the engine. It reads sensors such as crank position, air mass or MAP, throttle, temperatures, oxygen and knock, calculates fuel quantity and injection timing, spark timing and dwell, and drives the injectors, coils, throttle motor and other actuators every engine cycle. It also runs idle, emissions and VVT control, stores fault codes, communicates over CAN, and falls back to limp-home values if a sensor fails. The aim is to give the driver's requested torque at the lowest fuel use within emission limits.

  2. 2.Explain the concept of electronic engine management in modern vehicles.Concept

    Electronic engine management refers to the use of electronic systems to control engine functions such as fuel injection, ignition timing, and emissions. It involves sensors, actuators, and control units that work together to optimize engine performance, improve fuel efficiency, and reduce emissions. This system allows for precise control and adaptability to different driving conditions.

  3. 3.Why is a throttle position sensor important in an electronic engine management system?Application

    A throttle position sensor is crucial because it provides real-time data on the position of the throttle valve. This information is used by the ECU to determine the correct amount of fuel to inject and to adjust the ignition timing. Accurate throttle position data ensures smooth acceleration, optimal fuel efficiency, and reduced emissions.

  4. 4.How does the ECU adjust the air-fuel ratio in response to sensor inputs?Application

    First the ECU works out the air mass per cylinder per cycle, either from the MAF sensor or by speed-density from MAP, intake temperature, rpm and a volumetric-efficiency map. It divides that by the target air-fuel ratio, which is usually λ = 1, to get base fuel, and adds corrections for warm-up, acceleration and deceleration fuel cut-off. In closed loop the O₂ sensor feedback adjusts a short-term fuel trim, and persistent offsets are learned into a long-term trim. The final pulse width is the trimmed fuel divided by injector flow, plus a battery-voltage dead time.

  5. 5.Calculate the air-fuel ratio if the mass of air entering the engine is 14.7 kg and the mass of fuel is 1 kg.Numerical

    The air-fuel ratio is calculated by dividing the mass of air by the mass of fuel. In this case, the air-fuel ratio is 14.7 kg of air / 1 kg of fuel = 14.7:1.

  6. 6.If an ECU is programmed to maintain a stoichiometric air-fuel ratio of 14.7:1, how much fuel is required for 29.4 kg of air?Numerical

    To maintain a stoichiometric air-fuel ratio of 14.7:1, the mass of fuel required is calculated by dividing the mass of air by the air-fuel ratio. For 29.4 kg of air, the fuel required is 29.4 kg / 14.7 = 2 kg.

  7. 7.Explain how the ECU uses feedback from the lambda sensor to control emissions.Application

    A three-way catalyst converts CO, HC and NOx efficiently only in a narrow window around λ = 1: if the mixture is lean, NOx is not reduced, and if it is rich, CO and HC pass through. The upstream lambda sensor tells the ECU whether the exhaust is rich or lean, and the ECU trims the injected fuel the other way, so the mixture oscillates closely around stoichiometric. This oscillation also lets the catalyst's oxygen storage buffer the swings. A second sensor after the catalyst checks that it is still storing oxygen, which is how OBD monitors catalyst efficiency.

  8. 8.What could be the consequences of a malfunctioning mass airflow sensor in an engine management system?Application

    A malfunctioning mass airflow sensor can lead to incorrect readings of the air entering the engine, causing the ECU to miscalculate the air-fuel mixture. This can result in poor engine performance, increased fuel consumption, rough idling, and higher emissions. It may also trigger the check engine light.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?