If all you have is the spark signals then you are going to have to predict the future. But that's not how most ECU's work.
You know you need some spark advance - the spark fires before TDC almost all the time. Sometimes it's a lot before TDC. If all you have is a TDC sensor then that tells the ECU that it should have started the spark some time ago. So the actual sensed position is well before TDC. That way the ECU knows that it's 40 degrees before TDC and it can then do a simple delay to get to the desired spark time.
If you could add another crank sensor so your code gets a signal at -40 degrees (or something) then it doesn't have to predict the future. Remember too that fast RPM changes are still very slow for the Arduino so firing at the time that you calculated from the last complete revolution is usually good enough.
That schematic is useful. So what is the Arduino trying to do? Are you trying to add more advance above what the stock ECU does? What is this "future cause and catch misfire"?
MorganS:
You know you need some spark advance - the spark fires before TDC almost all the time.
Spark timing will never fall after TDC, nor will it ever fall more than about 40 degrees before TDC.
Without more information about EXACTLY what ignition system he's dealing with, it's kinda pointless to speculate. ALL modern systems use a multi-toothed wheel on the crankshaft (usually a "36-1" wheel) which gives a pulse every 10 degrees, with one "missing" pulse to indicate a position relative to TDC for cylinder 1. That signal is processed by hard-wired logic, and creates a timing reference signals to the ECU for EACH cylinders spark. Those signal events typically LEAD the maximum allowable spark advance, so a simple delay can be used to define the actual spark advance for each cylinder in a non-over-lapping manner (which is why I think the OPs description is very confused and wrong), and the time between successive events is used to determine RPM. Spark advance is calculated for EACH individuals cylinders spark, typically based on RPM, coolant and inlet air temps, manifold vacuum and/or throttle position, turbo-boost pressure, if any, knock-sensor input, and even barometric pressure, .
Again, without knowing EXACTLY what hardware the OP is dealing with, it's pointless to provide any more advice. The hand-waving description given so far are basically useless. This is why I asked if he was working with the Ford EDIS system, which is commonly used by "tinkerers". Besides which, the OP seems to have moved on, as he has provided no useful information in response to the many questions already asked over several days.
Regards,
Ray L.