Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: teensy 3.2 ignition timing controller?

  1. #1

    teensy 3.2 ignition timing controller?

    I want to build a controller that will allow me to read and then simulate a multi toothed wheel on an engine for the purpose of advancing or retarding the signal seen by the actual engine computer.

    Ultimately, the signal would be read by the teensy as a frequency in, and the teensy will then output a copy of that signal to the engines computer, but delayed a percentage ( to retard the ignition timing) or calculated/predicted and sent out in advance of the actual incoming signal ( to advance the ignition timing ).

    There are a few things that complicate this task;

    First, the toothed wheel , sometimes called a tone ring, has 34 evenly spaced teeth, and one large tooth that is twice as wide as the others, this is used as an indexing mark for the engines computer. But what this means is that one cannot simply measure the time between each tooth to calculate delays or predict when to output a signal, the wide tooth needs to be accounted for.

    second is the fact that the frequency of the signal will constantly be changing as the engine speed changes so the math would seem to get fairly complicated.

    A project like this is way outside my humble hobbyist skill set, but i would like to do it anyway, both as a practical matter and a learning exercise.

    I am assuming the best way to start would be to use a pin interrupt on the incoming signal, do some comparing and math based on that interrupt, and then use an internal timer to trigger an output.

    Much past that though i am in very unfamiliar territory. So i thought i would ask some of you more advanced programmers if this seems feasible, and were you to try such a thing how you might get it done.

    the signal coming in will vary from about 60hz ( engine cranking ) to about 3600hz ( engine at 6000rpm ) so nothing terribly fast.

    Any advice/guidance you could give would be greatly appreciated.


  2. #2
    Junior Member
    Join Date
    Mar 2016
    What type of input are you going to be using to determine your desired ignition advance? How often do you think the desired advance/retard will change.

    Just brainstorming here but if I were developing this I would probably start with something like this

    an interrupt gets fired on each tooth. It saves the last two tooth times. On first revolution it compares the tooth time with the previous tooth time. If its roughly 2 times then it sets a current tooth variable to 1 and a found position variable to true. From this point on this interrupt also increments the current tooth variable. and resets it back to 1 at the appropriate time.

    A intervalTimer set to fire every n us or so (No idea how often to run this depends on how much timing resolution you want)

    This intervalTimer reads the current desired timing advance, calculates the difference in the two tooth times stored above, and looks at how much time has elapsed since the last tooth. I would multiply the difference in the two times by a float say .5-1.5 depending on desired timing advance .5 would be full advance and 1.5 full retard. If more time than the result of that calculation has elapsed then initiate whatever action you need to to start ignition.

    You need to be careful with any variable larger than 1 byte that gets modified inside the interrupt or intervalTimer, turn interrupts off when reading or writing the variable and back on as soon as finished.

    There may be large problems with this as I also have never attempted something like this.

    Actually just realized that there is no way that we have a 1 to 1 mapping of cylinders to teeth so the above is woefully insufficient.

    How many cylinders do you have... do you know at what tooth and tooth position each cylinder is at tdc?
    Last edited by Jason_C; 11-05-2017 at 03:47 AM.

  3. #3
    Jason, thanks for your advice. What you propose is pretty much what I was thinking. To answer a couple of your questions.

    It is an 8 cylinder engine ( a typical V8 ).
    I have no idea what the relationship is between the indexing tooth of the trigger wheel and the position of the cylinders, however that could be determined to some degree by hooking a lab scope up to the crank signal and the trigger signal for #1 cylinder

  4. #4
    Junior Member
    Join Date
    Aug 2017
    Murfreesboro, Tn, USA
    Not to discourage you, but I want to make sure you understand just a few of the parameters that go into mapping ignition systems.

    You'll have a base table that will generally fall under common operating conditions (engine to temperature and vehicle moving if its a vehicle) usually with axes of load and rpm, then there's air temperature compensation, coolant temp compensation, cranking, warmup, and a variety of any additional maps created for any power adders. Then there's ignition coil charge time which is another added variable to the mix, although you can get away with a fairly static value as long as your battery is consistent.

    Based on not bringing up any cam trigger, im assuming this is either a wasted spark or distributed coil system, with my bets going on a distributor.

    Im also fairly certain you miscounted the crank teeth, 36-1 crank triggers are quite common among v8s. (the number of total teeth including missing teeth has to be divisible by the number of cylinders on every ecu ive dealt with)

    Id tap into the position signals and just modify the output signal to the coil(s) as the objective. if they're variable reluctance, make sure you shield the signals as they're prone to noise.

    Id also have a hard time acknowledging such a task when there's a lot of options out there already out there with Speeduino would be the least expensive option im aware of.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts