Robin2:
You need to tell us what the program actually does and what you want it to do that is different.
I actually did say that my aim is to control the injection of a 4 stroke diesel engine and for now I want to know the position of cylinder 1. This information can be red from the camshaft sensor.
Robin2:
Would it matter if you missed the very first occurrence of the double pulse when the engine starts?
No it doesn't matter.
Robin2:
Your diagram shows 3 single pulses between every double pulse - can that pattern be relied on?
Yes it can be, because it is a periodic signal, double pulse corresponds to cylinder 1, than, based on the injection cycle (1,3,4,2) every pulse corresponds to one teeth of the cylinders 3, 4 and 2.