ECU Inputs: Crankshaft and Camshaft Position Detection
Crankshaft and camshaft position sensing is one of the fundamental keys to proper ECU operation. If the ECU does not know where the crankshaft is, it has no idea when to generate sparks or to inject fuel. To get this information, the ECU has a set of sensors that it uses to detect the position of the crankshaft and the camshaft as they rotate. In order for the Aprilia ECU to determine where the crankshaft is at a given point in time, it needs to know things like:
The current position of the alternator rotor
The location of the camshaft, relative to the location of the crankshaft
The mechanical relationship between the alternator rotor and the crankshaft
The elapsed time since a particular crankshaft reference event
Once all of this information is gathered and processed, the ECU will be able to determine the location of the crankshaft while the engine is running. Once the ECU knows where the crankshaft is, it can make decisions about when to start charging a coil, or when to fire a spark, or when to turn the fuel injectors on and off.
The ECU is also capable of determining if its crankshaft and camshaft sensors are malfunctioning.
Of course, when we are done figuring this out, it would be sensible to try and verify that it is accurate.

In the case of Aprilia's Rotax V990 engine, it turns out that the basic crankshaft position sensing mechanism is built around knowing where the alternator rotor is. Since the alternator rotor is locked to the crankshaft with a key, if the ECU can determine where the alternator rotor is located, it also knows where the crankshaft is located.
The alternator has raised steel protrusions around its perimeter, as seen in the pictures. A magnetic-reluctance position sensor mounted in the top of the alternator cover puts out a signal to the ECU whenever it sees the start (or the end) of a protrusion pass by. Measurements show that the leading edge (the start) of each raised protrusion is located exactly 60 degrees apart from the start of the next protrusion, meaning that the start of the protrusions are spaced evenly around the circumference of the rotor. Notice in the photo on the right that one of the protrusions is much longer than the rest. The start of the long protrusion is exactly 60 degrees away from the start of the protrusions on either side. Measuring the width of the protrusions shows that the five small ones are 7.0 degrees wide, while the long one is 40 degrees wide. Viewed facing the front (open) side of the alternator, the protrusions look something like this:

The bumps can be numbered to tell them apart from each other. I have numbered them in this fashion for reasons that will become clear later. The ECU sensor circuitry that watches the protrusions creates a waveform for the processor such that the output signal is normally high, except where the protrusions are located where the signal goes low. The result is that the ECU will see a repeating waveform that looks something like this:

The low-going dips correspond to the bumps on the alternator rotor. The extra-wide low-going signal corresponds to the longer-than-normal protrusion numbered '3' in the first diagram.
Since the Rotax is a 4-stroke engine, the complete 4-stroke "intake-compression-power-exhaust" sequence takes two full rotations of the crankshaft. Looking at the output of the crankshaft sensor, there is no way for the ECU to tell if the crank is on its intake-compression rotation, or on its power-exhaust rotation. To get this information, the ECU needs a signal from the camshaft. Since a 4-stroke camshaft always rotates at 1/2 the crankshaft speed, a signal generated once per rotation of the camshaft would supply the proper information. Even so, there is one more clever bit of information to extract from the position of the cam. Instead of just telling the ECU if the engine is on an odd or even crank rotation, the cam sensor can be used to tell the ECU exactly where the crankshaft is, for at least one point in time. To understand how, consider that there are six crankshaft reference pulses generated per rotation, and twelve crankshaft reference pulses per pair of rotations making up the full 4-stroke sequence. The output of camshaft signal is designed to tell the ECU which crankshaft reference pulse is the first of the twelve that make up the pair of rotations:
The cam sensor is normally low. During one of the crankshaft reference events, the cam signal goes high. During the next crankshaft reference pulse, the cam sensor drops low again. This low-going transition tells the ECU that the next crankshaft reference pulse is CR0, the first of the twelve repeating crankshaft reference events. Subsequent crankshaft reference pulses are labeled CR1 through CR11, and then the sequence repeats from CR0 again. The blue arrow in the diagram above shows how the falling edge of the cam sensor identifies CR0 as being the next crankshaft sensor event. This is why the bumps were numbered from 0 through 5 on the alternator rotor. The '0' bump is the first bump that will go past the crankshaft sensor after the cam sensor fires. Since the crank turns twice between camshaft events, the 0 bump identifies both CR0 and CR6, the 1 bump is CR1 and CR7, and so on up to the 5 bump identifying CR5 and CR11. Now it is possible to go back to the rotor and map the bumps to their corresponding crankshaft reference (CR) numbers as they are known inside the CPU firmware:

If you were to examine the ECU firmware, it shows that when the ECU powers on, it really has absolutely no idea where the crankshaft is. When you push the starter and the engine begins to rotate, the ECU watches the crankshaft reference pulses go by. It basically ignores the crankshaft reference pulses until it sees the camshaft signal transition from high to low. As soon as ECU sees the high to low transition on the cam sensor, it knows that the next low-going edge on the crank sensor will correspond to the start of crankshaft reference pulse CR0.
As soon as CR0 is identified, the ECU knows that each subsequent crank sensor event counts upwards until the next camshaft event, when the counter goes back to CR0 again. This process of counting CR events from 0 through 11 repeats until as long as the motor is running.
The fact that there are 12 separate CR events is important to the ECU. The ECU is designed to perform specific tasks based on what CR event just happened. For example, the ECU firmware shows that it is programmed to fire the front cylinder spark plug on the rising edge (the trailing edge) of the CR5 bump, but only if the engine turning so slowly as if it were being cranked by the starter.
Rotor to Crankshaft Relationship
The next puzzle is to determine the relationship between the location of the CR events and the position of the crankshaft. As mentioned earlier, we know that there is a permanent, fixed relationship between the rotor and the crankshaft because the rotor is physically keyed to the crankshaft. Unfortunately, it is not completely obvious what that relationship might be. There are two ways to figure it out:
Measure TDC (Top Dead Center) on one of the cylinders and see how it compares to the location of the CR reference protrusions on the alternator.
Do some firmware detective work.
To avoid taking my bike apart, I went with method #2.
The Rotax shop manual says on page 2-6-00 that when the bike is being started, the ignition spark occurs at 5 degrees BTDC (Before Top-Dead-Center). An examination of the ECU firmware shows that when the engine is turning very slowly (as would happen when cranking it with the starter) the trailing edge of the CR5 protrusion is used to fire the front cylinder sparkplug. This means that the rising edge of the low-going pulse on CR5 must be 5 degrees BTDC. Since the CR5 protrusion was measured to be 7.0 degrees wide, this tells us that the leading edge of CR5 must be at 12 degrees BTDC for the front cylinder. Since we know that the sparkplug is being fired, we also know that the downward movement of the front piston will start 5 degrees after the rising edge of CR5. In the same fashion, the ECU firmware fires the rear spark during an engine start at 5 degrees BTDC for the rear cylinder. This means that the rear cylinder power stroke must begin 5 degrees after the rising edge of CR10. Putting it all together, we can completely map out the relationship between the CR events and the crankshaft position:
As things turn out, none of the CR events corresponds exactly to TDC or BDC. The closest we get is that the trailing edge of CR5 and CR10 are 5 degrees ahead of TDC for the front and rear cylinders, respectively. This may seem weird to have nothing line up with TDC or BDC, but in truth, the ECU could care less. All it wants is to just know where the reference points are. Everything else, it can calculate from the reference points.
Notice that the 4-stroke event cycle is skewed by 60 degrees (one reference period) between the front and rear cylinders. This is because the Rotax engine has a 60 degree cylinder angle, meaning that the cylinders are splayed 60 degrees apart, as compared to traditional Harley twins at 45 degrees and traditional Ducati twins at 90 degrees. If the engine was a parallel twin firing its cylinders on opposite phases of the 4-stroke engine cycle, the power strokes would occur exactly 360 degrees apart, evenly spaced as the engine rotates. Since the Rotax is a 60 degree V-twin, the rear cylinder fires only 300 degrees after the front (60 degrees early from a full crank rotation), and the front cylinder fires 420 degrees later (60 degrees late). This uneven firing timing gives the Rotax a 'raspier' sound than a 90 degree twin like a Ducati.
Fine Tracking of Crankshaft Position
To this point, all the ECU knows is where the crankshaft is at 12 different points as it spins one complete revolution. While that is a good start, it does not actually cover the actual needs of the ECU. For example, if the ECU wants to fire a spark at 22 degrees before TDC, there are no crankshaft reference events to tell the ECU when the crank is at 22 degrees BTDC. To get this fine crankshaft position information, the ECU adds time to the equation.
Examining the firmware shows that the ECU is constantly calculating the engine RPM based on how long it took the crank to make its last 1/2 of a revolution. The trick is that the ECU uses that 1/2 revolution RPM calculation to make a prediction about how fast the engine will turn through the next CR reference period, being the next 1/6 of a rotation. So how accurate could this prediction be? In general, it is pretty darn accurate. Consider that an engine only ever radically changes its RPM during a power stroke. At all other times, there is no power being dumped into the drivetrain, and the flywheel does its best to ensure that the engine keeps rotating the same speed. In truth, even with the flywheel, the engine will always be slowing down a little between power pulses from the power stroke. Ignoring the power stroke completely, and ignoring the slight slowdown on all the non power strokes, it turns out that the ECU can basically assume that the engine is running at a constant speed between power strokes. This might seem a bit weird, but it turns out that this method of predicting how fast the engine is going to turn in the next 1/6 of a rotation is quite accurate for the ECU's purposes.
So now that the ECU can predict the future, how does it make use of that ability? One common use is to calculate spark advance. The process goes something like this: the ECU knows that CR5 starts at 12 degrees BTDC, so it can calculate that that CR4 must occur at 60 degrees before that, starting at 72 degrees BTDC. As soon as the ECU sees CR4 go by, it predicts exactly how long it will take the CR4 period to take, based on the last 1/2 revolution of the crankshaft. In other words, the ECU now knows how long it is going to take the engine to go from 72 degrees BTDC (the start of CR4) to 12 degrees BTDC (the start of CR5). With this information, picking a specific spark advance is a simple math calculation: if the ECU felt like generating a spark at 42 degrees BTDC (halfway between the start and the end of CR4), all it has to do is wait for half the time that it believes that CR4 will take and then fire the spark. Since the ECU is capable of measuring time down to 2 millionths of a second, it can position its spark delay event very accurately. Even at 10000 RPM, the crankshaft will only rotate 0.12 of a degree in 2 millionths of a second.
So interestingly enough, it turns out that the ECU actually generates a spark delay, not a spark advance! The only reason we call it a 'spark advance' is that the spark still occurs in advance of TDC, even though it is a delay from the ECU's point of view.
So what happens if a sensor breaks? How does the ECU detect that and not try to do something bad like firing the spark when the piston is only half way up the compression cycle? In this case, the ECU uses the crankshaft and the camshaft sensors to cross-check each other. The ECU firmware that processes camshaft events makes sure that it sees crankshaft events occur in between each camshaft event. The ECU knows that it should see twelve crankshaft sensor events for every cam event. If the camshaft processing firmware notices that it has seen 30 camshaft events without the crankshaft sensor seeing any crankshaft events, the ECU can safely say that the crankshaft sensor is not working.
In the same sort of fashion, the ECU counts crankshaft events, and knows that it should see a camshaft event every twelve crank events. If the ECU counts 255 crankshaft events without seeing a cam even, it can make a determination that the cam sensor might be broken.

To check out my interpretation of the firmware functionality, I connected the ECU to a logic analyzer. A logic analyzer is a device that is able to watch a large number of digital signals simultaneously and capture how they change in relation to each other over time. The connections are made by hooking test clips to the appropriate pins on the ECU board. Seen on the right, the test setup resembles brain surgery: the patient lays there with the top of their skull removed, connected to test equipment while the measurements are taken.
The diagram below is a trace captured from the logic analyzer. It shows the crankshaft and camshaft position signals, as well as the ignition and injector outputs for both the front and the rear cylinders. The crankshaft reference names have been added in red. The blue arrow shows how the falling edge of the camshaft event identifies the next crankshaft event as CR0, the start event.
Notes:
See how the engine slows down (CR periods get larger) as the starter cranks the engine through the compression stroke CR2-4 for the front cylinder.
The ECU notices the slow rotation and delays the front ignition event until the rising edge of CR5, labeled CR5a in the screen shot. The rising edge on IG1_F indicates the coil being discharged causing a spark to fire on the front cylinder.
Notice that as soon as the front cylinder fires, the subsequent CR periods get significantly shorter because of the power stroke during CR5,6,7 as the engine rapidly comes up to idle speed.
The blue arrow shows how falling edge of the camshaft pulse indicates to the ECU that the next CR event will be CR0. See the analyzer trace (below) for a more detailed view.
Looking at the front cylinder again, notice that the injector squirts during CR10. The Crankshaft Reference Table (above), shows that this means that the fuel is being squirted just before the intake stroke begins on CR11. This gives the fuel spray time to atomize into the intake tract before the engine starts drawing on the intake stroke.
The ECU notices the increase in rotation speed for the second front cylinder ignition event. You can see that instead of occurring at CR5a when the starter was cranking, it now occurs at approximately CR5 since the engine is turning faster.
The 'dwell' time (the time that the ignition coils are being charged) corresponds to the periods where the ignition signals IG1_F and IG2_R are low. When the engine is being cranked by the starter, the ECU always starts charging the coils at the start of CR4. When the engine is running, the ECU backs off on the dwell time. An excessive dwell time does not provide much improvement in the strength of the spark. It can overheat the ignition coil though, so there really is no reason to make it longer than necessary.
Here is another analyzer trace taken while the engine was running at roughly 2000 RPM:
Once again, the blue arrow indicates that CR0 starts with the first falling edge of the crankshaft sensor after the falling edge of the camshaft sensor. Now that the engine is up to speed, notice that the front cylinder ignition event (signified by the rising edge of IG1_F) occurs during CR4 instead of CR5a as it did during the start cycle. According to a ruler measuring a logic analyzer printout, the spark fired 40 mm into a CR4 period that was 48mm wide. Doing the math shows that this would correspond to firing 50 degrees into CR4, or 10 degrees before CR5 since all CR events are 60 degrees wide. Since we also know that CR5 starts 12 degrees BTDC, this means that at 2000 RPM, the computer is firing the spark 10+12 or 22 degrees BTDC. The Rotax manual on page 2-6-00 says that at 2800 RPM, the engine should be running at 21.8 degrees of advance, plus or minus 2 degrees. Hmmm. I might need to rework the measurements or the math...
It will be worth it in the end.





Wright Cyclone in full song.