The issue is on the tracker here: http://issues.freeems.org/view.php?id=135
Missing teeth decoders are all about time differencing. The only logic is with respect to timing and ratios. You watch input pulses come in and record stamps and then periods and then compare periods (as soon as you have two).
Given M minus N terminology, there are three cases for gaining sync:
Common Case
Probability = ((M-N)-2)/M
First tooth is any tooth that isn't the one of the two before or the one after after the missing teeth. We must wait for up to (M-N)-3 teeth to come past before finding that our next one is large relative to our last two.
Rare case 1
Probability = (N + 1)/M
First tooth is the one after the missing teeth. (M-N)-1 evenly spaced pulses come past and we know the next one must be a long pulse because we are on the tooth before it.
Rare case 2
Probability = 1/M
First tooth is the one before the missing teeth. The first period is large and the two following periods are small.
Rare case 3
Probability = 1/M
First tooth is the one before the one before the missing teeth. The first period is small, the middle period is large and the last period is small.
More Certain Sync
Because it's a bit risky to take a scheduling gospel from just two periods (3 teeth), we double check this to ensure that any pair that matches one of our three sync opportunities is followed by the appropriate pair. We will check for the following before declaring sync:
- If (M-N)-1 even periods were observed when we found a preliminary sync, then the next period MUST be the gap.
- If we had a small period and then a large period, we will check to make sure that we get a small period on the next cycle.
- If we had a large period and then a small period, we will check to make sure that the next one is small and comparable also.
If the sensor wiring is reversed you get the situation where there are two wider teeth in a row.
Where N = 1 the wide period is approximately 2x the narrow ones before and after it. If reversed you get two, both approximately 1.5x the narrow ones before and after them.
Where N = 2 the wide period is approximately 3x the narrow ones before and after it. If reversed you get two, both approximately 2x the narrow ones before and after them.
For N = 3 it's 4x or a pair of 2.5x.
Thus it is always long period = (N+1) * normalPeriod
Reversed, the two long periods = ((N+2)/2) * normalPeriod
Thus I think that I can write this to output a specific error for the case when the wiring is backwards telling you to swap it.
Reading RPM
A rough RPM reading can be obtained as soon as we see two periods and decide if we are on a sync point, or waiting to find one. This can be used for preliminary scheduling to speed starting slightly. Accurate and stable RPM reading must wait until
(2*M)/cylinderCount periods have been measured (for a four stroke crank mounted application).
With just cylinder count we can set up the RPM to work smoothly on this type, so it might ignore configuration for RPM calcs and be smart always. We will see.
Noise Filtering
As part of our sync mechanism we're already filtering noise, however there is one more opportunity to catch out bad wiring and save the engine and that is tooth width. Tooth width varies with RPM due to sensor clearances etc, however at any given RPM it should be pretty stable and noise pulses are usually much narrower. We can difference these, one from the next, and lose sync if there are any out of the allowed range.
Different Applications
There are a number of use cases for the missing tooth style decoder. Some are outlined below:
- Cam mounted, 720 degrees, 4 stroke
- Crank mounted, 360 degrees, 4 stroke
- Crank mounted, 360 degrees, 4 stroke, with short cam sync pulse
- Crank mounted, 360 degrees, 4 stroke, with 50/50 cam sync
- Crank mounted, 360 degrees, 2 stroke
- 12 minus 1 on the crank, four stroke
- 36 minus 1 on the crank, four stroke
- 60 minus 2 on the crank, four stroke
- 24 minus 1 on the cam, four stroke
Right, to eclipse to knock this one out! :-)
Fred.