Ignition Control with Atmega128

Thread Starter


Joined Nov 4, 2008
I am currently in the process of building an ignition control module for both a three cylinder and a four cylinder engine and I am using a atmega128. I am having some difficulty getting the output to be consistent. I think I may have some kind of interrupt issue. I am reading the signal from the cam sensor, I have converted it to a digital pulse and there are six periods for each revolution of the cam (3 per revolution of the crank, note: this is for 3 cylinder engine). one of the teeth is longer so I get five short pulses an one long. the long pulse tells me where top dead center is for the number 1 cylinder. i can detect this pulse, but I am having trouble getting the correct output based on this pulse. What I mean is that I want output to the 1st cylinder on this tooth. so I detect this tooth grab the index for it, calculate the index for the proceeding tooth (ie long_tooth_index-1) and then on the next cycle where the tooth_index = long_tooth_index-1. I want to count for a time period(this delay is the count to degrees before top dead center which the ignition is fired) and then fire for a time period to an output. I can also do this but for some reason it doesnt stay consistent. I can provide more details if necessary.


Joined Feb 4, 2008
If the long teeth comes into position when at the same time the firing has to be made it wont work because electronics need some time to process the signal and drive the output. In that time the piston will move away from the perfect firing position and thus you loose synchronization. You have to adjust the sensor which senses the long teeth to sense it a bit earlier than the perfect firing position of the piston as to give this time interval for the electronics to process the signal. This time interval must be variable and depend on the speed of the engine. The greater the speed the more 'earlier' you have to sense the long teeth position.
It would be helpful to provide some diagrams if possible.


Joined Apr 20, 2004
Have you characterized the signal out of the cam sensor? Does it need a bit of conditioning before applying it to the uC? Are you coding in assembler or using a C complier? Are you allowing for increased RPM with smaller TDC delay values? How are you tracking the index tooth, as it's period also decreases with RPM?


Joined Oct 14, 2005
It might be possible to keep track of five short pulse, and then the next pulse must be the long one. It is also possible to predict the speed of revolution and guesstimate when the next long pulse would come. So you would have time to prepare for firing, etc.

Just an idea.