Best place to start is at the beginning. The problem is, which beginning. There is a beginning to the platform, and a beginning to the process of engine management. I guess the platform is something that can come later, so, I will begin with the process of engine management.
Engines (internal combustion type), have some basic principles. They need air, fuel, and spark to make them work. Engine diagnostics tell us, if you take any one of the three away, the motor doesn't run. We will start with the spark generation, and how to get it "just right". Now, to make my train of thought a little more difficult to follow, a little bit about problem solving. Dijkstra tells us, if a problem seems too big, solve the parts that you can solve, then work on filling in the parts that are left. For a process problem, quite often, the "steady state" is the main part of the process, and the management of the exceptions is where things get troubled. So for our engine management problem, we will start from the steady state condition (no changes due to acceleration, positive or negative).
Kind of a long winded introduction to get us to a point of where I want to start the discussion, which is about timing. I am going to work with four cycle motors in this series, so people interested in two cycle, or diesel, will have to wait until another series. Four cycle, means the crankshaft turns twice causing the piston to rise and fall twice, per each sequence (called a cam cycle). There is a compression sequence, and an exhaust sequence. The compression sequence is where the spark needs to happen. But when in that cycle should we make the spark happen? Still more background. For the energy event during the compression, we have an air:fuel mix that is put under pressure, and ignited by a spark. How to generate the spark in just a moment, first when exactly do we need to make the spark happen. The way the ignition occurs is interesting because it is not immediate. If you were to take a very high speed film of the ignition event, you would see that when the spark ignites the air:fuel mix, the burn extends from the ignition point in a plume. Because of the properties of the fuel, this rate is fairly constant. Keeping in mind different fuel types have a different burn rate (alcohol, very fast, diesel, very slow). The ideal timing for ignition, is so the plume reaches the top of top of the piston, just as it reaches its state of top dead center(TDC) (highest point in the cycle). To make this happen, the ignition needs to happen a little before TDC, this is referred to as the advance. The advance changes as the motor changes speed, the faster the motor is turning the earlier the advance needs to be. Luckily for us, we are dealing with the steady state first, so adjustments to advance will come later.
Our next piece of the timing puzzle is about generating the spark, this is done in many different ways, but we will be starting with the conventional method first, the ignition coil. Coils work on an interesting electrical principle. By applying a direct current to the coil, for a brief period, it behaves like a resistor until it reaches its saturation point (can't absorb more current), then it behaves like a shorted wire (no resistance). When the current is removed from the coil quickly, an interesting phenomenon occurs, called field collapse. This drives a voltage at a high current spike through the circuit, which generates the spark at the plug. I over simplified because I don't want to get too hung up in coil design and efficiencies, again this leans toward exceptions. What I did want to cover was there was a period of time before the ignition, when we need to charge the coil. This time is called the dwell, and dwell is dependent on the type of coil, but some general cases can be used for now and we will just call it our dwell.
Now we have what we need for our basic system, at least for one cylinder. Oh, first diversion from general case engine model, the cylinder object. If we write all the code for a single cylinder, then make N number of instances, we can have any number of cylinders we want in our motor. Information we have about our cylinder is the angle of its TDC, the dwell time for the coil it is attached to (multiple coils are an exception to be discussed). So we need to determine some elements; current angle in cam cycle, and engine speed, which will help determine the value of the advance. Sounds like we need some inputs, most engines with electronic ignition systems have a couple of signals that are helpful, called cam and crank. These signals are generated from the camshaft, and crankshaft. and have one, or a series of triggering elements mounted to produce a signal to identify position. Here is where I am going to diverge again. The thing we are interested in, is rotational speed, and current position. The cam and crank are a closed system, so the process is continually repeating, and once we have identified were we are in a cam cycle, as long as the speed remains consistent, we should know were we are at any time, and additional inputs, provide additional information.
Lets look at a common type of cam and crank configuration 4x crank and single pulse cam. The good thing for this part is the engine manufacturers go though a very large effort to make sure the active edge of the crank and cam signals are extremely precise. As a result each active edge of the crank is exactly 90 degrees from the previous signal. Also, the cam signal only occurs one time in a cam cycle. This gives us our prime reference. How this works is, a value of TDC0 is set, based on the operation of the motor, which is the 0 degree reference point and synchronized with one of the crank signals (called teeth), and the cam signal is given as number of crank signals from cam to TDC.
So we have input signals, and can begin doing some determination. Starting our timer when we get a crank event, and stopping the timer when the next event occurs, we now know how fast the motor is running, because the time dT, to move 90 degrees is 1/4 the time for a full rotation. and if we convert the units of dT to one minute, then multiply by 4 to provide RPM. If we know which crank signal just passed, we also know our position, this is possible if we have had a cam signal, in which case we count the number of teeth for cam to TDC. Some clever calculation will let us know where we are, as soon as the cam signal is detected, because cam to TDC means the crank signal that just passed when the cam signal is detected is 2x number of teeth - cam to TDC number. Now that we have our information, we can get to work, since it is ridiculous to think that a motor doesn't change velocity we will need to provide continuous update to the dT value, so the stopwatch idea is not practical. Instead, we will use a free running timer, and get a trigger time when the crank event is recorded. Then, take previous recorded timer value, and current recorded timer value, and the difference is our dT that gives us our rotational speed. Hopefully, you can begin to see now, that the number of events in a crank, provided they are equally spaced, is only significant to determine accuracy of rotational speed, and more quickly determine change.
The result also provides a means of predicting the precise moment when the next event will occur, as well as other, future events. This is important, because from our earlier discussion, the spark event needs to occur before the TDC event (which is usually synchronized with a crank event), and the start of dwell needs to occur before the spark event. Also, remembering, starting the dwell too soon, can cause potential damage due to heat buildup from a shorted system, so the dwell cannot be started too soon. I will finish off this first entry by establishing some formulas to use...
t0 is the previous recorded event time (time of the previous crank event), in an arbitrary unit of "ticks"
t1 is the current recorded event time (time of this crank event), again in the arbitrary unit of "ticks"
dT is the delta time providing rotational speed (t0 - t1) in ticks
teeth is the number of crank events in a single rotation
TicsPerMin is the number of tick units in a single minute
RPM is now calculated as: TicsPerMin / (dT * teeth)
Top Comments