This is the continuation of the Megasquirt/EDIS installation article found here (which I apparently ran out of article room in):
This article will focus specifically on how to tune an EFI installation on your 2002. It will focus on Megasquirt as the example (since that is what I installed on my car and thus am most familiar with), but the general process is still applicable to other type of EFI setups.
Note: Before you ask, no, I will NOT share my actual *.msq files. That's a great way for an amateur to screw up their engine by 'just trying.' I will however share and explain screenshots of the parameters that I use in my car. It is then up to YOU to understand this and use the information to build up your own parameters. I have traditionally used Megatune but have just recently been trying out TunerStudio Lite, so you will see screenshots from both pieces of software in this write-up.
Section VII - Tuning
1.) Engine parameters
2.) Cranking and Starting
5.) Acceleration enrichment
6.) Speed-Density vs. Alpha-N and the VE table
7.) EGO and AFR table
8.) Spark advance table
9.) Datalogging and tuning
So you finally have Megasquirt (or another EFI) hardware installed on your 2002 and all wired up. But there's still more work to do before you try to crank the car up for the first time! Let's first double check that you didn't miss anything and have all of the prerequisites for loading up your first tune:
A.) All hardware is installed (manifold, throttle body, fuel rail, injectors, fuel filter, fuel pump, O2 sensor, coolant sensor, intake air temp sensor, throttle position sensor, fast idle circuit, and if applicable, EDIS hardware).
B.) All wiring is correct, hooked up, and SAFE (e.g. right size wiring, fused, etc.)
C.) Megasquirt controller boots properly, has firmware loaded, and can communicate with your tuning laptop (via Megatune, Tunerstudio, etc.)
So basically make sure everything is installed, wired properly, and you have proper communication to the EFI controller. A great first test of things in general is that when the Megasquirt unit is first powered up, it should briefly run the fuel pump for 2-3 seconds in order to prime and pressurize the fuel system. This also gives you a chance to make SURE that you don't have any fuel leaks, which obviously would be a bad thing!
I'll detail the basic setup process specific for my 2002 below, but in addition to my walk through I would strongly encourage you to also read and understand the details of the system straight from the source in the Megamanual:
There's also a great write-up on using the TunerStudio software here:
On a final note, make sure you go through and put in the base settings for each and every one of these sections BEFORE YOU ATTEMPT TO START YOU CAR FOR THE FIRST TIME!
1.) - Engine Parameters
OK, now let's start taking a closer look into the details of programming the controller, starting with entering the details of YOUR specific engine, which is what all later calculations will be based on. At its core, EFI control is actually rather simple. It just aims to inject the right amount of fuel to proportionally match the amount of oxygen entering each cylinder. But to know how much oxygen is entering each cylinder, we first need to know things like how many cylinders are on the engine, the volume of each cylinder, and how efficiently they draw in fresh air. Obviously our 2.0L engines have 4 cylinders each with a theoretical maximum volume of 0.5L of fresh air each. This is our starting point. In my Megasquirt's general settings, I have identified my ECU type as Megasquirt 2, and total engine displacement of 121 cubic inches. All other parameters I have left at their default values:
The next important part to setup is the injection control settings. This tells the controller the details of my injectors (how many, how much fuel they flow, etc.) and how I want them controlled. The first step is to click on the 'Required Fuel' box up top and enter the engine and injector details, and the program then calculates a baseline for how long the injectors need to be open to provide the right amount of fuel under ideal circumstances. The lower portion then is where you decide HOW you want this amount of fuel to be delivered. In this example for my car, I have all four injectors firing simultaneously twice per engine cycle. This means (for a 4-stroke engine) all injectors will fire once per 360 degree crank revolution, and each firing will deliver half the required amount of fuel. Other options would be to fire them just once with the full amount of fuel per 720 degrees, or every 180 degrees with 1/4 the amount of fuel. You also have the option to batch fire just one bank of injectors instead of all of them together, but I think this makes more sense V-configuration engines where the two injector banks are two separate fuel rails for each cylinder head, and personally I don't see any reason to try this on a 2002:
2.) - Cranking and Starting
In the general settings, you can choose to set starting parameters, like priming pulse, cranking pulse, after-start enrichment, etc. to use a two-point linear calculation or a table-based calculation (based on coolant temperature) that lets you do more fine-tuning of the parameters. I use the table option, but still keep things pretty linear.
The priming pulse is a bit of gas injected BEFORE you even start cranking to 'prime' the initial intake charge. I have this set from 6.0ms at beyond-cold temperatures to 2.0ms at beyond-hot temperatures:
Similarly, the cranking pulse is the injector pulse width during cranking (I think by default 'cranking' is defined as less than 300 RPM, you can adjust this but it seems fine for most cars). For this I go as high as 10ms for below-freezing conditions to 3.0ms for a fully hot-start. Obviously this is an important one for achieving easy cold starting. I admit though that I live in a rather mild climate so haven't really tested this very much on sub-freezing days, and I suspect my hot-start parameters are a bit on the rich side, but I have not fully run this one down yet. I'm basically saying, take these values with a grain of salt, and if anyone wants to propose more fully-researched values, I'd be happy to hear from you!
3.) - Warmup
But wait, there's more! After the engine catches and has started, it still wants more fuel than normal for a few seconds while everything 'gets moving,' so to speak. This is accomplished by setting an addition enrichment percentage (added to the normal VE fueling calculated value), again based on temperature. There's actually two tables involved, the first is how MUCH additional enrichment is provided (the afterstart enrichment, or ASE, percentage), and the second is for how LONG, in engine cycles, it is applied for (ASE Taper):
Ok, now we've gotten the starting and first ~30 seconds of parameters set, but what about for the rest of the time it takes for the car to get warmed up to operating temperature? Well, again there's two adjustments for this. The first is warmup enrichment. This is basically the same idea as ASE, but now base purely on coolant temperature and input as a total percentage of normal calculated fuel amount. I consider my car 'up to operating temperature' by about 170 degrees F, though you'll notice I chose phase out the warm up enrichment a little earlier at 150 degrees. Those last 20 degrees don't seem to matter much in how it runs, and for keeping the normal tuning process clean I like to not have to worry about factoring in warmup enrichment as a variable. One other variable to notice in here is the Flood Clear Threshold %. This is another starting parameter and is the throttle position at which Megasquirt assumes that you've accidentally flooded the engine and will SHUT DOWN all the injectors during cranking. This is a nice feature, but if you are used to starting your car with the throttle open, that will be a habit that you need to break! With properly set up Megasquirt tune, you should let it handle everything and always keep you foot off the pedal during starting in all conditions.
4.) - Idle
Now that we have the fuel set up for the warmup phase, obviously the next important part is the intake air. This is set in the Idle PWM duty cycle if using a PWM valve, or in Idle Steps if using an IAC stepper motor. Note that there are conditions for cranking/starting to be set here as well. For starting, the IAC can be set to a cranking position, and move to the right spot per engine temperature. This is set in the Idle Control table. The Start Value is how many steps the stepper motor retracts (opens) when first powered up. This should be enough to get it from the fully closed to fully open position. The next box, cranking position, is how far it then closes back down from the fully open position. This then is effectively how much air your letting in during cranking, or put another way, how much throttle you want during starting, but without using the gas pedal. The third important box is the crank-to-run taper time, which is the number of seconds after the engine has started that it will hold this position before closing down further to the calculated position for the current engine temperature:
Now that the starting parameters are set, next up is the warmup parameters. This is similarly adjusted as a table of IAC steps per temperature. Remember you'll want the IAC fully closed by the time the engine is warmed up, so this value in steps should match the start value from earlier, so that it always runs from fully open to fully closed:
5.) - Acceleration Enrichment
Ok, this should cover all of the basic parameters for getting the car started and idling from cold to warm, other than the main VE table. There's one last area that we want to adjust first before getting there though, and that is acceleration enrichment. Just like the accelerator pump on a carburetor, this system provides a little extra fuel during the transient periods that you are actually changing the throttle position. It can use either changes in manifold absolute pressure (MAP), or changes is throttle position (TPS) as inputs, or a combination of the two. I use a 50/50 split of both, found it's smart to raise the threshold a bit, so that normal 'noise' from either the MAP or TPS sensor doesn't trigger any unwanted acceleration enrichment to kick in. Tuning this acceleration enrichment properly will help give you that nice snappy throttle response you undoubtedly want:
You can also take this one step further if you want and try playing with the X-Tau correction tables. X-Tau corrects for an amount of fuel that gets 'stuck' on the walls of the intake port and valve (momentarily leaner), and then gets burned up *later* once it evaporates (momentarily richer), but I've never personally turned on X-Tau correction or tried to mess with it at all, so I can't offer you much advice beyond the basic operating principal here.
6.) Speed-Density vs. Alpha-N and the VE table
Finally to the main fun part, the VE table! Let's firstly understand exactly what this is. At the very beginning in the Injection Control section, we told Megasquirt how much fuel our 2.0L engine will need under IDEAL conditions with perfect cylinder filling, but what about real-world conditions? This is where the VE table comes into play. At idle with a closed throttle plate, each cylinder isn't pulling in a full 0.5L worth of air, so clearly less fuel is necessary. Cylinder filling is also different at different RPMs; even at full throttle there's a difference in how much air the engine can pull in at 2000 vs. 5000 RPM. These two variables, engine load and engine speed, are the axes of the VE table, and the values then are nothing more than a percentage of that ideal amount of fuel for perfect cylinder filling. So referencing the earlier Required Fuel value that we calculated as 17.6 (in ms), a value in the VE table of 50 would mean that we're asking for 8.8ms of fuel at that particular operating point.
Now with that all cleared up, we ready to address the difference between speed-density and Alpha-N. Fortunately it's pretty straight forward: speed-density uses manifold absolute pressure (or MAP) as the input for engine load, and Alpha-N uses the throttle position for load instead. In my humble opinion, speed-density is the superior method. Alpha-N works OK if you don't have a good MAP signal (for instance in an ITB setup), but if you CAN get a good MAP signal, then that's better for two reasons. First, it automatically compensates for changes in elevation. Going for a nice drive up into the mountains? No problem, as the air gets less dense, this is automatically reflected in the MAP, and Megasquirt leans things out for you. It's like changing out jets while driving! Secondly, I like that MAP is a more direct measurement of engine load, where as throttle position is one step further removed. (Incidentally mass air flow, or MAF, is one step better still, as it directly measures the mass of the oxygen entering the intake, which is why all modern OEM applications use it).
Note: it's important to also use (and calibrate) an intake air temperature (IAT) sensor when using speed-density. The intake air changes density with temperature (aka there's less oxygen available at a given pressure with warmer air as opposed to cooler air), so the input from the IAT allows Megasquirt to compensate for this. Other than calibrating your sensor, I don't think there is any other setup needed for IAT correction, unless you wish to set up a non-linear correction curve (not sure when this is necessary though).
Anyway, without further ado, here is what my VE table looks like:
Remember yous might need to look a bit different, depending on your engine/pistons/cam/etc! I'll explain a few of the more important regions of the table now though:
Idle - I have my car set to idle at about 900 RPM and there it's at about 40 kPa. I've found a VE of about 44 to give the smoothest, tad-rich (AFR ~14.0) idle. Notice that I keep this area of the VE table pretty flat with a lot of 44s so that a little fluctuation in idle speed or MAP signal won't drastically affect the injector pulse widths.
Cruising - This is in the mid-MAP range (around 40-70kPa) from 2000-4000 RPM. Here the VE tables are only in the 50-60 range, not a whole lot higher than idle, compared to the 70 and up for most of the higher load and higher rev area. While cruising down the highway or a back road with only light throttle, you can really run much leaner than when you're accelerating, and thereby get much better fuel economy. More on this is the AFR section but for now just remember to not get too aggressive with the VEs in this area.
Peak power/torque - Just the opposite of cruising, here at high load you want to error on the richer side. At full throttle above idle and higher RPMs with even a modest amount of throttle applied, I'm pretty much have the VEs at least up to 75, and they climb from there up to above 100 in the peak power band. You may also notice that my MAP axis goes up to 110kPa: above atmospheric pressure. This is because the 318i manifold has magnificent resonance properties in the mid-range (due to its long intake runners) and thus delivers a healthy bit of supercharging in this sweet spot, so I needed to run the table up into that range to capture this. Megasquirt will extrapolate linearly out beyond the VE table, but I prefer to try to keep everything under my control as much as possible. Note that for a turbo application, your VE table MAP axis should run all the way up to your max boost pressure, and VEs should also be increased accordingly.
Overrun - This is the high vacuum area at the very bottom of the table (20-30kPa) when the throttle is closed for deceleration. Obviously you don't need much fuel here, so the VE numbers stay pretty low. I do raise them a tad at the low RPM just so the area around idle is smoother, though in truth I'm not sure if seeing as low as 20kPa at <1200 RPM is even realistic.
7.) EGO and AFR table
If you're an experienced carb tuner, it's entirely possible to develop a pretty good VE table with just narrow-band or no O2 feedback (my dad and I did this on his 911 Megasquirt build) and achieve pretty good results. But in this day and age, using wide-band O2 feedback makes this infinitely simpler, and utilizing the AFR table and EGO closed-loop feedback in Megasquirt makes it so easy it almost feels like cheating.
NOTE: I STRONGLY recommend leaving closed-loop EGO correction OFF or at least restricted with very limited authority while you develop your VE table until it's quite good on it's own. Just last weekend on my way to the Vintage my EGR sensor started to fail and reading very (untruthfully) rich, which caused the EGO control to reduce fuel and made the car run LEAN! Fortunately the EGO only had 5% authority, so I was only running 5% lean. But if I had for example had the EGO dialed up to 30%, then it would have instead run 30% and that would have been VERY bad! You want a good solid VE table as you basis, with EGO just for tuning feedback and at the most fine adjustments while running.
The AFR table is just what it sounds like. It looks just like the VE table only here the numbers are your desired AFR target at the given operating points. Just like I mentioned for the VE table above, I like my idle area to be just on the rich side of stoichiometric, lean while cruising, rich under heavy load, and a bit lean on overrun, and smooth transitions between these areas:
Again you should decide what works best for your own specific car, but this should give you and idea for a starting point. Next, here is what my EGO control settings look like. With a well developed VE table, I allow it the authority to adjust the fueling amount by 10% to try and hit the AFR targets. While dialing in an early VE table, I would suggest starting with no more than 5% (have some EGO is helpful during tuning, as it allows you to see in the datalogs when the EGO is kicking in and how much). I also cut the EGO control out at idle (only active above 1200 RPM) and at full throttle (only active below 75% TPS or 90 kPa). This is generally considered good practice so that the controller doesn't end up 'chasing its tail' in a feedback loop in these sensitive areas:
8.) Spark advance table
Assuming that you're using Megasquirt to control your ignition (or even if you using something different like the 123Ignition distributor), you'll need to program in your desired ignition curve. The factory advance curve is a pretty good but conservative starting point, with about 15 degrees of advance at idle and 30 degrees of 'all-in' advance by 3000 RPM, and then an additional of ~5 degrees or so added for the overrun/high vacuum areas. My advance curve is slightly more aggressive than stock but still on the conservative side. I found the biggest improvement to come from a steeper climb in advance just above idle helps a lot with pulling off the line. I've think that 2002s tend to really like more advance in general, and I think with good 91 octane gas and a well dialed-in VE tune you can get all the way up to 40 degrees all-in, but play it safe starting out and increase slowly to avoid issues with pinging/detonation! I also found it helpful to increase advance just a bit *below* idle speed, so that idle sits in a bit of a 'valley' in the advance curve, which helps keep it stable:
9.) Datalogging and tuning
Congratulations, you now have all of basics setup and should be ready to try starting your car! Here's my recommendation of steps to follow for the first startup:
1.) Cranking - Double check your timing, cranking/ASE, and idle control settings and then make sure the engine at least catches after a small amount of cranking. It's OK if it doesn't want to idle yet, but if it doesn't want to fire at all then go back to the wiring and these three settings first.
2.) Idle - First aim for a faster than normal idle, maybe ~1200 RPM, and adjust the warmup and fast idle parameters to try and keep it in this range until the car is fully warmed up. Once it's warm, make sure all warmup enrichment and fast idle adjustments have all cut out, and then work on the VE table, timing, and the mechanical idle stop to get a smooth idle at your desired idle RPM with an AFR in the low 14s. After you have a good warm idle, you'll probably need to go back later after another cold start and re-tweak the warmup and fast idle settings.
3.) Accel enrichment - Once you've got the car warmed up and idling nicely, start playing with the acceleration enrichment settings to get good throttle response so that the engine revs up quickly when you blip the gas and then returns back to a good idle without drama.
4.) Datalogging - Great, now time for a test drive! But before you pull out of the driveway, start recording a datalog (built-in capability with TunerStudio). This will let you review everything that happens during your drive and decide where and what adjustments need to be made accordingly. Here's an example from one of my logs. Let's just focus on the top most of the three graphs. Here, white is RPM, red is MAP, and green is AFR (you may want to enlarge for better viewing):
In the first (left) half of the graph, I'm cruising and then decelerating. MAP is generally low, AFR is staying on the high side, and RPM is coming down with a few upward blips where I downshift. As soon as I come to a stop (low point on white RPM line), I then do a moderate acceleration in 1st and then close to full throttle for 2nd and 3rd (middle portion of the graph). If you look closely you can see a brief point early in the 1st gear run-up where the RPM drops just a little (I'm pretty sure this is due to the clutch engaging) and the AFR goes a bit high/lean - This is an area where I should consider increasing the value in the VE table! The gear shifts are the 'spikes' in the RPM line. Right where the indicator line is at I have lots of throttle (93.5 kPa) in 2nd gear at 4139 RPM and AFR is 13.2. In the tiny gauges at the very bottom of the screen, you can see that my target AFR (AFRtrgt1) in this area is set to 12.5, so I might want to richen this are up slightly, but 13.2 is already pretty good. The thing that does jump out at me in this section though are the low (rich) spikes in the AFR line right when I close the throttle (MAP goes low) to shift. This means I ought to decrease the amount of fuel during deceleration in my acceleration enrichment parameters (decel cut is just the opposite of accel enrichment for when the throttle is actively closing). In the last (right) section of the datalog, I shift into 4th and am back up to speed and cruising again and the AFRs nicely go back up the leaner cruising numbers. It takes some practice to get the hang of looking at and correctly interpreting all of this stuff in the datalogs, but THIS IS HOW YOU TUNE, FOLKS, so start grabbing some data and practicing! You should be able to get things running pretty well with just a few goes, but it will take many, many different rounds of test drives and the resulting finer and finer tweaks to get things close to perfect, but hey, this is part of the fun of DIY Megasquirt after all!
Good luck and I encourage you to post additional questions and/or datalogs in the comments if you need further help with any specifics!