Ignition Timing, Engine and Fuel Map

I have now implemented more accurate ignition timing control which is based on degrees before top dead centre rather than a fixed time period.

I’ve also implemented a simple fuel map with the ability to store new values, display the map and save the map over serial from the Arduino.

I have made the fuel duration and ignition timing variable using potentiometers and the Arduino analogue inputs. Since the Stellaris launchpad PWM outputs are 3.3v I have had to tie a 3.3v reference to the Arduino aref pin and set the analogReference to EXTERNAL. I have also added a simple low pass RC filter between the PWM pin and the analog input to help smooth it, since otherwise, the analog input will only ever read 0 or 1024, depending on the part of the cycle that the PWM is in. An alternative to this is to implement a low pass filter in software. I’m sure that there are a number of ways to do this, but a common one is to create an array which you push elements on to and discard the oldest measurement, then average that array. This should work, but always seems a not memory and processor intensive for me. Another trick is to use the formula

val = 0.999*val + 0.001*newVal

This has the are effect, what is is effectively doing is to say take most of the old value and a little of the new value and that’s your average. This would be placed inside the measurement loop. The problem with it is that it uses floating point calculations, which may be more processor and memory intensive than the array method depending on your hardware. I would have to perform tests to see which is best for the Arduino (which doesn’t have dedicated floating point hardware).

I’m currently having a problem with the Stellaris Launchpad where writing a new capture and compare value to the timer is taking a long time or in some way causing the timer to reset and hence this messes up the missing tooth generation algorithm. I also don’t seem to be able to set this timer value from any interrupt routines, but only from the main loop.

Thinking about it, I have a feeling that when I write a new value to the timer capture register, it also resets the current time count which hence causes the timer to take longer than it would have done to lapse and trigger the interrupt. I will have to look into this.

3 thoughts on “Ignition Timing, Engine and Fuel Map


    I am working on a similar project for timing the ignition system. Well, i didn’t exactly understand the use of the fuel map. When i get my signals from the crank shaft sensor and the TPS, i wonder why we need both the signals as doesn’t the RPM change depending on the TPS signal and hence can’t we just control the ignition timing according to anyone signal ? And how do i feed in the fuel map to the microcontroller to compare the values. I am weak in programming so can you help me understand the process of programming the microcontroller for eg: on a TI msp430 to achieve ignition timing using a fuel map?

    thanks in advance 😀

    1. Scott Snowden Post author


      Well you require the 2-dimensional map because you want to be able to operate your engine under different loads. Therefore, the throttle position and engine speed are actually independent, and a change in either one might require a different amount of fuel. For example, you might operate the engine at 1000 RPM with the throttle only 10% open, and this condition may require only 5% of maximum fuel injection. In another situation, you may need to operate the engine at 1000 RPM but driving a very high load, and so the throttle may be 100% open, requiring 50% of maximum fuel injection width.

      For programming this, you basically use a 2-dimensional array, which can also be thought of as an array of arrays. You can visualise the map like an excel spreadsheet with TPS down one side and engine speed along the other.

      In pseudo-code this might look like this (not sure about the specifics of programming an MSP430).

      // Eng Spd: 1000, 2000, 3000
      map[3][2] = [[ 5, 10, 30], // TPS 10 %
      [ 50, 75, 100]] // TPS 100 %

      fuel_amount = map[speed][TPS]

      Good luck!

      1. thanawat worgjariyakamol

        Dear Scott snowden
        I read your project Arduino ecu i am interested in your project but now i need to modify arduino ecu
        use with motorbike my motorbike now engine revolution from 1750-9000 rpm only but i am need
        boost the engine rpm revolution from 1750 rpm to 12000 or 15000 rpm how i can modify the new
        software the input sensor crank/sensor; tps/sensor;map/sensor or 02/sensor but output to control
        fuel injector; and ignition coil;
        best regards


Leave a Reply

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