Introduction
Introduction
This project is my own offshoot of the EFI332 project mailing list. The EFI332 list never got a chance to serve it's purpose, through the rantings of a troll in 2000, and a hard drive crash that wiped out the list and the archives, the list has dwindled to a small number of people mostly talking about using a PowerPC instead of the '332 chip.
I still feel that the MC68332 is still a good processor for the job, powerful enough to power all but the most challenging project, but small enough to be completely understood by a person willing to learn. The methods and algorithms in use here are directly applicable to the PowerPC chip, it has the all important TPU (though a better one), the serial ports (though a better one), SPI controller (though a better one), and the ADCs are very similar (though they are built in and better).
The whole idea behind using the '332 is that the TPU takes care of the actual running of the engine letting the main processor be freed up to watch what the engine is doing (O2 sensor level, engine speed, etc.). The TPU is an independent coprocessor that is used to execute time based digital I/O functions such as pulse width modulation, serial port I/O, pulse generation, and pulse capture.
Motorola, now Freescale, created a set of functions for the TPU for automotive systems. The basis is two functions, one that tracks a toothed wheel connected to the crankshaft (to a precision of 1/100th of a tooth) within a 720 degree engine cycle, and one that is driven by the camshaft to figure out which half of the engine cycle is happening. To provide outputs, Motorola has routines to generate pulses at a given engine angle with a high time that can be specified as either an end angle or a time from the begin angle.
So, the crank and cam inputs synchronize the TPU with the engine, and the output functions turn output bits on and off at exactly the right times to drive the injectors and ignition coils.
Information about some of the important parts
Injectors
There are two important parameters when taking about injectors; the “impedance” and the nozzle style.
When taking about impedance, what is actually being referred to is the electrical resistance of the electromagnetic solenoid coil that opens the valve of the injector. There is a lot of mystery about the impedance for no particularly good reason. The reason is quite clear, there must a restriction to the flow of electrical current or the coil will overheat and fail. The amount of current that will flow in a circuit, in amperes, is proportional to the voltage in the circuit, in volts, divided by the resistance of the injector, in ohms. If the impedance is zero, the amount of current that will flow can go to infinity (not physically realistic, but think of a main power cable shorted to the frame, the battery may explode).
So, if we have the fabled “low impedance” injector with a nominal resistance of 2Ω and we are driving it with a charged battery at 13.6 volts, we will have a current of 6.8 Amps. That is over 90 Watts, a lot of current, far too much for the injector to be able to convert into heat for a long time.
A high impedance injector would have a resistance somewhere around 10 to 16Ω, which would give a current of about 1.3 to 0.9 Amps. This amount of current, about 13 Watts, can be handled without melting the injector.
Why is there a difference? A low impedance injector is able to make a stronger magnetic field, opening the valve faster, giving better response to the input signal.
But won't the low impedance injector melt? Only if it isn't handled properly. What is typically done is that the injector is allowed to draw a large amount of current for a small time, say 4 ms. (enough time to open but not enough to get hot), then the current is restricted to about an Amp, just enough to keep the valve open. This is called “peak and hold”.
A high impedance injector can be attached directly to raw power and it will limit its own current draw. Less electronics are needed in the controller but the response time of the injector is slower. In a lot of cases the speed is not an issue and you can save a dollar in parts in hundreds of thousands of cars.
There are two nozzle styles, pintle and orifice plate. With a pintle style injector you have, effectively, a rod plugging a hole. When the solenoid pulls back on the rod the hole opens, shooting out a stream of fuel. Atomization isn't great, but it is simple. With an orifice plate style injector, there is a plate in the nozzle tip with a bunch of holes in it. The rod is pulled back and the fuel is forced to make its way through the holes in the plate. This is like having a whole bunch of little injectors instead of just one big one. The net effect is that the fuel liquid is more effectively vaporized.
So what? When you read the discussion section, you will find that the A series engine needs to have the fuel injected while the inlet valve is open. You cannot simply store fuel fog in the inlet tract and wait for the valve to open and suck it in. The superior atomization of the orifice plate injectors may be a drawback in this case. The fog will have a lower propagation velocity and may hang around in the port waiting for the next intake cycle rather than making it into the cylinder. This would show up as a mixture differential between the adjacent cylinders.
Other information
There is a mystical 80% rule for injectors, “never drive an injector at more than 80% of maximum pulse width”. Why? It's not because the injector will overheat (actually injectors are flow tested at 100% normally, and they are current limited), it's because if you run out of fuel pressure at full power you will run lean and ruin the engine. You can only run an injector to a maximum of 100% (always open), after that it will flow no more fuel but your air volume will continue to increase making the mixture lean. 80% gives you enough “head room” so that you have adequate fuel available at full power even if your injectors are dirty and your oxygen sensor tells the computer to give more fuel.
Ignition
There are a few ways to do ignition under computer control; points replacement, wasted spark, and coil on plug.
With a points replacement system, all you are doing is replacing the points that live in a distributor, the distributor is still used to “distribute” the spark to the plugs. Mechanical advance is calculated from the engine speed, the vacuum advance is calculated from the manifold pressure sensor, and the timing is calculated from the crankshaft position sensor. The computer controls some sort of high power transistor to fire a conventional coil connected to the distributor. This system can get rid of a lot of the ignition scatter that comes with worn bearings in the distributor housing, but you still have the wearing pieces like the rotor and cap. This system can be done using something like the legendary MSD ignition boxes, but a simple BOSCH coil amp does the same thing and they are almost free at the bone yards.
A wasted spark system does away with the distributor (hooray). A double ended ignition coil is used to fire two spark plugs simultaneously, one that is in the normal compression stroke, and the other which is 360° out of order on the exhaust stroke. Firing a plug on the exhaust stroke does nothing, it is wasted. The advance calculations are the same as above, but you have to keep track of (number of cylinders/2) values. But, you don't use a distributor. This system can be done using two BOSCH coil amps or one of their multiple channel amps, but they are harder to find. The ignition coils of this type are almost free at the bone yards.
A coil on plug system has one coil per plug and it is typically mounted directly to the top of the plug (thus coil on plug). You have one amp per coil, one per plug. The advance calculations are as above but you have to keep track of each cylinder individually. The benefit is that you have no distributor or plug wires. The only consumable part is the plugs. The coils for this system tend to be quite long and this system is typically only done with very expensive, high performance cars with dual overhead cams. The coils extend from the top of the cam covers far down into the head to the plugs. There have been some bikes that use this system, but I can't offer much guidance as to where one might look for parts.
Mass air flow sensors
A mass air flow sensor (MAF) is an electronic device that is installed between the air cleaner and the throttle body and is used to measure the amount of air that is flowing through the system. It does not report air volume (CFM or M3/minute), it reports mass flow (kg/minute). This is very useful since the air:fuel ratio is a mass ratio, not a volume ratio. You need 14.7kg. of air for each kg. of fuel not so many cubic feet of fuel for each cubic foot of air. Air and fuel have different densities and that is taken into consideration in the calculations.
The nice thing about a MAF is that it takes into consideration the changing air densities since the dense, humid air at sea level has a higher density than the thin, dry air up at the ski lodge. The sensor adapts for you.
Program structure
The program starts with the system startup code, that starts the processor. Next the mainline sets up the rest of the system, initializes the application environment, starts the TPU waiting for the engine to be started, then monitors the system, altering the TPU parameters to change the ignition and injection timing.
Using a real time operating system (RTOS) as a basis to the system gives a whole bunch of flexibility. Adding a process to provide a command line interpreter or data logger is easy compared to altering the event loop.