Mark Crankshaw wrote: > > As part of an engine ignition project I need to calculate an advance value > using a lookup and a measured RPM. Seems simple enough but I've come > across a small problem. Do all your calculations outside of the main loop and formulate it so you only have to use the results while the engine is running. My ignition code only uses about 50 words of ROM to control 3 stages of positive and negative advance, dwell, and vac advance. The code is all in line, ie no loops etc. which makes it execute very fast. From the time the points signal is detected until all timing values are known and in place, takes less than 30uS @8MHz. You can even take this delay into account for more precision. I think the automotive manufacturers even take into account the switching delays used to drive the coils etc. I was not too worried about this because my system was mainly intended for older slow revving engines. I used 24 bit calculations to achieve the results I got, but even so, the timing can still be a bit jerky, especially at high RPM. Still it not bad considering it's all squashed into an F84. If you are going to use a lookup table then this delay time will be a lot less, however, there is no user flexibillity with this arrangement. There is some ignition source code available on my web site that uses a lookup table. http://www.picnpoke.com/projects/ignition.html -- Best regards Tony PicNPoke - Multimedia 16F84 Beginners PIC Tools. http://www.picnpoke.com Email picnpoke@cdi.com.au