Click on our menu buttons immediately below to find MegaSquirt® information quickly:

Tuning Your MegaSquirt-II™ (or MicroSquirt®) Controller

If you are not familiar with tuning EFI systems, you might want to review the material in the Principles of Tuning page before reading this document.

Tuning Theory

Tuning involves setting all the parameters that the MegaSquirt-II™ (or MicroSquirt®) controller uses to be optimal for your non-pollution controlled engine, injection components, and driving style. These include things like cold start pulse widths and acceleration enrichments. The most fundamental parameters are in the 12×12 volumetric efficiency (VE) table(s), the 12×12 air/fuel ratio (AFR) table(s), and the 12×12 spark advance table.

Be sure to read all of this document, and the configuration document BEFORE starting to tune your engine. Not doing so can cause damage to your engine. Also see the code specific tuning parameter's guide for the code you are running, such as those for 2.905 or 3.770

In general, this is all much easier to understand when you are working on a running engine. Trying to estimate what your engine will specifically need beforehand can be more confusing than productive. It is worthwhile exercise to understand the requirements, but always remember that ultimately you will rely on your “seat of the pants” and O2 sensor (as well as drag strip times, exhaust gas temperature sensors, etc., etc., if you have them available) to tune your engine.

When tuning:

Note that in this manual we assume you are running gasoline. However, other fuels have different Air/Fuel Ratio (AFR) requirements. Below is a chart of the equivalent air/fuel ratios for several alternative fuels:

Air/Fuel Ratio Equivalents





















































































Tuning Software

The software application you use to tune and configure your MegaSquirt-II™ (or MicroSquirt®) is called TunerStudioMS+ by Phil Tobin.

You also need computer (ideally a laptop) and a conventional serial port to communicate with your MegaSquirt-II™ controller (or your MicroSquirt® controller). USB will may work, and many people have reported that they have been successful using a USB-serial adapter. Just about any computer that is capable of running Java will be fast enough, but get the fastest laptop computer you think is reasonably priced.

This section of the manual deals with tuning the 'on vehicle' performance and tuning of your MegaSquirt-II™ (or MicroSquirt®). There are extensive instructions on configuring MegaSquirt-II™ (or MicroSquirt®) in the Configuring MegaSquirt-II™ (or MicroSquirt®) section of this manual. Be sure to read and understand the configuration information before attempting to tune your engine.

Before Starting Your Engine

If your engine is newly assembled, consider running it on a known good carburetor and mechanical distributor before attempting to run it on MegaSquirt-II™ (or MicroSquirt®). This way you wont have to worry about proper run-in for the cam shaft, proper ignition timing, etc., while trying to get a reasonable initial tune into MegaSquirt-II™ (or MicroSquirt®).

Before starting, make sure to:

If you are not entirely sure about your ignition settings, check the supported list for the settings you should use:

If your module isn't on the 'officially supported' list yet, you'll need to understand the relationship between the trigger offset, the input capture (falling or rising edge), and the spark out (going high or going low). Here are some tips if you module isn't on that list:

  1. The MS-II™ignition pin (when connected direct to the port with the IGN-JS10 jumper in place) has an internal 5 Volt pullup, but it is only capable of 25 milliAmps max or so (10 milliAmps is safer). This may not be enough current for your coil's transistor, so you might need to use the VB921 (or BIP373) high current circuit (JS10-IGBTIN & IGBTOUT-IGN jumpers). This doesn't have a pull up in place, to add one see step #65 here:

  2. For the input capture, you have to keep in mind that the optoisolator inverts the signal from the module:

    You *could* use either edge IF both event are fixed with respect to the crank position (TDC). This is true for optical sensors, and may be for Hall sensors as well.

    With a VR sensor, both of these event are definitely NOT fixed, only one is (it corresponds to the 'zero-crossing'), so you have to be sure to get it right. See this web page for a detailed explanation.

  3. Spark Output is much the same (triggering on different edges gives different timing), you are telling your MegaSquirt® controller which edge of the output wave to send as the spark timing. However, 'spark output' also has another function: it sends the dwell info. Often if you get both the input capture and spark output wrong, the timing will be close, but vary with dwell (and hence rpm).

    If your module relies on your MegaSquirt® controller to set the dwell, the 'Spark Output' should be set so the coil does NOT charge when the engine is off.

    You can test this by looking for:

    However, in some cases the module, and/or wiring will prevent charging when the engine is off, even if the spark output is incorrect. So knowing what sort of signal the module expects is very helpful, and this info can sometimes be found in the service manual, etc.

  4. Failing that, you can try is setting the dwell to 0.3 milliseconds while idling. If the engine runs rough or dies, the spark output setting is likely correct (since the coil doesn't have enough current to make a reasonable spark). Note that extended running with the Spark Output set incorrectly can burn out the coil and/or the module.

  5. Then, use a timing light to compare the timing as reported by TunerStudioMS to that seen on the timing light, after you have set the trigger offset ('Tools/Trigger Wizard' in TunerStudioMS).

    The indicated and observed advance should be very close over a wide range of rpms (I usually test at idle, ~1500 rpm, ~2000 rpm, and ~3000 rpm, with a 4 cylinder, I'd also check ~4000 rpm) . If the indicated and observed timing values aren't the same at these rpms, then either:

    Note that if you change the 'Input Capture' setting, you MUST recalibrate the trigger offset.

The 'easiest' way to do all of this is on oscilloscope, but most people don't have one of those. You will want to get the ignition parameters set first, as soon as you get started.

Get the Engine Started and Idling

You start, naturally enough, by getting your engine started. (Be sure you have configured your MegaSquirt-II™ (or MicroSquirt®) first, following the instructions on the Configuring MegaSquirt-II™ (or MicroSquirt®) page.)

Be sure to set your base timing before starting your car (if it has not been previously been set). And verify that you have entered the base timing value into the 'Advance Offset (deg)' field of the dialog at 'Settings/Ignition Options'.

Note that the prime pulse is NOT meant to provide starting fuel (it is meant to clear any air that might have leaked into the fuel system while the engine was shut down). Supplying fuel for starting is what the cranking pulses are for (as they are both rpm and temperature dependent, and thus much more likely to give the fuel you need). Generally, keep the prime pulse as short as possible (typically around 2.0 milliseconds is a good starting point), and tune the starting using the cranking pulse widths instead.

Typically, the first time someone tries to start their engine with MegaSquirt® EFI Controller, it starts after about 5 minutes of alternating various cranking pulse widths numbers to get started (on the Enrichments page), and changing the:

Check that the IGN LED on your MegaSquirt® controller (the LED closest the DB9 serial connector) flashes on and off as you crank the engine. If it doesn't, your MegaSquirt® controller either:

You need to check both of these conditions and fix which ever is not right.

If you have been trying to start your engine for more than 15 to 20 minutes, you ought to investigate other sources of problems before continuing to try to start the engine.

Properly tuned, your MegaSquirt® controller will start your engine quickly and reliably. If you have trouble with starting, either hot or cold starts (or both):

Setting the PWM Criteria

To tune the PWM [pulse width modulation] values for your engine, you need to know what kind of injectors you have: low impedance or high impedance.

The injector opening time and PWM time threshold should be set to approximately the same value. So adjust the PWM time threshold, and the opening time together. However, once you start to tune the 'fine tune' the idle, if you have to revisit the PWM parameters, change only the PWM time threshold, but do not change the opening time.

The reason for this is that changing the opening time also changes the AFR, especially at low rpms, so it forces you to also retune the VE table. So unless they get to be different by more than about 0.5 milliseconds, leave the opening time alone after tuning the idle and cruise VEs (unless your are willing to retune those areas).

On the car, setting the PWM parameters is very easy to do and only takes a few minutes. At idle the overall injector pulse widths are small compared to their close time, so this will allow you to adjust the values. In other words, adjust the PWM current limit before taking the car out on the street where injector pulse widths become high, increasing the possibility of overheating your injectors (and blowing fuses).

You may find that you can idle at a very low PWM%, but the engine will stumble or cough if given any throttle. This can be due to a too low PWM% especially if your injectors are large and the idle pulse width is approximately equal to the PWM Time Threshold. In that case you may be idling almost entirely on the PWM Time Threshold. So rev the engine occasionally as you are tuning the PWM parameters, to ensure that you haven't gone too low.

Also, for some setups, an initial PWM Current Limit of 30% may be too low on a V3 main board (75% on a V2.2 main board without the flyback board), so they will need to increase this value - same for the time threshold. Use PWM time threshold values greater than about 1.5 to 1.7 milliseconds only with great caution – it is possible to burn out your injectors!

Note that if you are running the active flyback circuit and need PWM% of 40% or more to run properly (or 80% on a V2.2 with the standard flyback circuit but without the flyback board), your flyback circuit isn't working properly! Troubleshoot that circuit carefully to find out why.


When your MegaSquirt® controller resets, TunerStudioMS displays a 'RESET X' in the lower right corner (where X is the cumulative number of resets (including restarts)) - it will also beep. Resets can cause a number of problems that cause the engine to run badly, including messing up the baro correction and enabling after start enrichment. So you should try to cure any reset issues before putting a lot of effort into tuning.

Resets generally indicate that the power to the processor was interrupted. This could mean that the input power actually was cut, but it can also mean that there was a power surge into the back plane (ground), so that there was no longer a 5v differential between the inputs and the grounds...

Resets are often caused by noisy power supplies (usually the alternator), or poor grounds.

First, fix the grounds, make sure all are perfect and do not connect to areas that are dirty, rusted or painted. Place them close together.

To check the alternator, you can shut the engine off, remove the wiring to the alternator (don't let it ground on anything, some wires might be hot). The start the engine and see if the resets go away. If the resets disappear, the alternator is the problem.

You can fix the alternator and/or add a car stereo power filter to the MegaSquirt® controller's 12V supply. These are cheap (~$5) and widely available. They typically have three wires: one from a switched 12V source (the original source for the MegaSquirt® controller), one to go to the MegaSquirt® controller (with clean power), and a ground wire.

Ignition noise, solenoids turning on or off, and that sort of thing can also cause resets. Check your harness routing to see if any ground or signal wires are near noise sources such as spark plug wires or the coil. Finally, non-resistor spark plugs have been known to cause resets. Use resistor plugs whenever possible.

Setting the Cold Start and Warm-Up Enrichments

If it is cold out, you may have to figure out the cold start enrichments/warm up enrichments right away to keep the engine running until it warms up. If it is reasonably warm out, the default values may be sufficient and you may be able leave the cold start enrichments until you have the VE table and other parameters in a reasonable state of tune.

During cranking mode (defined as when the RPM is less than 400), your MegaSquirt® controller produces cranking pulse widths that are calculated by a linear interpolation of two end-point values defined by the user, one at -40°F and one at 170°F. these are set in the warm-up wizard under 'Tuning' in TunerStudioMS. They are called Pulsewidth at -40°F (ms) (CWU) and Pulsewidth at 170°F (ms) (CWH).

A typical setting for a Chevrolet 350 small block V8 with a Tuned Port Injection set-up and 30 lb/hr injectors is 2.0 milliseconds at 170°F and 10.0 milliseconds at -40°F. The optimal values for your combination are likely different, though generally should follow a similar pattern.

During cranking, MegaSquirt-II™ (or MicroSquirt®) injects one pulse for every ignition event, so for an 8-cylinder it shoots out 8 times for 720 degrees crankshaft, with all injectors squirting. So with the above values, at 170 degrees, the effective amount of fuel per cylinder is 8 × 2 = 16 milliseconds. For -40°F it is 10 × 8 = 80 milliseconds.

Note that even in a 'piggy-back' application, do not set your MegaSquirt® controller's cranking pulse widths to zero. This will cause unpredictable pulse widths up to 13 milliseconds. Instead, set them to 0.1 milliseconds in that application. This allows very little fuel to flow.

Once the engine fires up (defined by engine RPM greater than 300 RPM), the engine goes into after start enrichment (ASE). The after start enrichment starts out at a user-defined percentage enrichment value (typically around 20%), and ramps down to 0% after so many ignition trigger events, which is user-defined (use about 200 for this number to start). This is an enrichment above the normal warm-up enrichment, which is temperature dependent.

Tuning the Idle Control

MegaSquirt-II™ (or MicroSquirt®) can control either an ON/OFF solenoid style valve, and PWM idle valve, or a stepper motor IAC. The FIdle valve has a single set point, a PWM valve can be set to different speeds, while a stepper has a number of possibilities for adding air (thus raising the idle speed by differing amounts). See the IAC page for more information on these different idle speed control devices.

The stepper motor IAC can be set to close in ten discrete steps with increasing temperature. These are stored in an array called 'iacstep_table' in the code. You can enter the cumulative number of steps in the dialog at 'Tables/Idle Steps' in TunerStudioMS. Generally, the default values will be suitable for initial tuning, you can fine tune them later to get the idle speed you desire at each temperature. Note that the total number of steps (i.e., the 170° entry) should match the 'Start Value' (IACStart) in the 'Idle Control' dialog under 'Settings'. The default is 160 steps in both cases.

Then make sure the final value in the IAC step table is 0 to 10 more than the start value. Note that the start value represents retraction, and the IAC step table values are extensions.

Getting the start value right is important for consistent operation, it can't be too few at all or too many by very much - either of these will definitely result in inconsistent operation.

The IAC is temperature controlled in normal circumstances, except for cranking and immediately after a start. When your MegaSquirt® controller is powered up, the stepper is retracted by the 'start value' number of steps. It is then extended to the 'Cranking Position (steps)' while cranking. When cranking stops and the engine is running:

For some IAC stepper motors, you might need some adjustment because the power resistor values may not be quite low enough for your application. This would cause sporadic problems that may be worse now that the weather has become colder. To see if this is the problem, cut the leads off a resistor or use a small piece of wire and solder it across the two power resistors on the bottom of the MegaSquirt-II™ board. These are the two large brown units on the BOTTOM of the board, on the end opposite the side of the board with the 2x3 pin header. These have large solder pads on each side - just jumper across each one so you get 0 Ohms and see if this improves operation. This is very likely to be the problem for those who see the proper step commands given in software but inconsistent response from the motor.

The other thing to note about bench testing the IAC stepper motor is that there is a designed in delay in the commands to the motor so it is not constantly moving. While it is warming up it makes a move, then waits for a significant temperature change (the amount you entered in the 'Hysteresis (°F)' field in TunerStudioMS, the default is 5°F) as well as a few seconds of elapsed time before the next change is made. So if you rapidly increase the coolant input on the bench, it catches the first few degrees of change and responds with a small movement, then waits a few seconds then makes a large movement because by then you have jacked the coolant to max. This is not a problem in real life, because the engine takes several minutes to warm up.

Note that one more thing can cause inconsistent IAC operation: If the intake air is unheated, and the throttle body is unheated, and the temperature is a bit above freezing with high humidity, then the IAC passage can 'ice up'. This happens because the temperature drops due to the pressure drop across the IAC pintle, and the moisture in the air freezes (exactly like carburetor icing). This prevents the IAC from moving, so steps are lost and the idle stays high.

If the passage ices up, but you drive for a few more minutes, then restart the car, the radiated engine heat is usually enough to melt the ice, and the IAC closes completely, apparently 'fixing' the problem. This usually won't happen much below freezing, though (the air is too dry).

With tuning of the above numbers, nearly any engine can be tuned to fire immediately, every time, just like any new OEM fuel injected car. However it may take some trial and error to converge on the best numbers, especially the after start enrichment, which needs to be just right, or the engine will run rough or stall immediately after starting.

You can do this as the engine warms by adjusting the warm-up enrichment bins, loading it to the ECU, and noting the effect on idle quality. It will take several starts {from a cold soak} to get this close to optimum. Then you can play around with revving the engine in neutral and adjusting the mix to stoichiometric. Tuning to this point is easy enough to do without an O2 sensor by adjusting for maximum vacuum (lowest MAP kPa) at any given rpm.

Note that if you get a uneven idle speeds, in the sense that sometimes when you start the engine you have idles speeds that are higher or lower than other times, you may have to increase your IAC Start value. This may be necessary to be sure the IAC is all the way open under all start-up conditions. With an insufficient number of steps, whether or not the IAC is open all the way depends to some degree on where the stepper is at start-up. For example, if it was already open 20 steps, then it might open all the way. If it was completely closed, it might only open 160 steps (or whatever you have set as your Start value). But regardless of how much it opens, the idle speed is determined from that 'offset'.

This can result in idle speeds that are dependent on the stepper position at last 'shut down', if the 'Start value' is not at least as many steps as the physical range of the stepper motor. By increasing the IAC Start value, you will get consistent warm-up idle speeds. When you increase the Start value, say by 20 steps, you may have to add the same amount to the IAC step table. However, if adding to the step table decreases the idle speed under all conditions, it probably means your 'Start value' was already all the way open.

Note that you can also set the cold advance values to provide a better warm-up, though this is considered 'fine tuning', and the values generally should be left alone until you have the fuel and spark table dialled in.

Tuning the VE Table(s)

The VE table represents the volumetric efficiency and air/fuel ratio at each rpm and kPa (0=total vacuum, 100=atmosphere, etc.).

Volumetric efficiency is the ratio of the amount of air actually fills the cylinder to the amount that would fill the cylinder in a static situation. The VE is used in the 'fuelling equation'.

There are a number of ways to specify VE. Your MegaSquirt® controller specifies it relative to the manifold absolute pressure and includes the AFR in the VE table.

That is:

VE = (actual air mass)/(theoretical air mass)*AFRstoich/AFRactual

So for MegaSquirt-II™ (or MicroSquirt®), entering a larger VE in the table makes that point richer, and a smaller number makes that point leaner.

When tuning the VE and AFR tables, it's always a good idea to keep the fueling equation in mind:

pulse width = Req_Fuel × VE(rpm,kpa) × MAP × E + Injector_open_time

To set up the fuel curves for the engine with MegaSquirt-II™ (or MicroSquirt®), you have a number of parameters to work with. The most important of these are the Req_Fuel value, the 12×12 Air/Fuel Ratio (AFR) table, and the VE table (12×12 volumetric efficiency table).

You should be aiming to achieve 12-13:1 air/fuel ratios under full throttle, and 15-17:1 under light loads for a naturally aspirated engine. Boosted engine may require a richer mixture under power. Conventional wisdom (not always right) suggests that you tune for ~13.1:1 at peak torque, and 12.5:1 at peak power for a naturally aspirated engine. Boosted engines can run as rich as ~10.5:1 to 11.0:1 under boost. In all cases, you don't want to run lean at high loads - it can be very destructive to your engine.

The idea that lean mixtures at high loads burns holes in pistons is correct, but it is for a different reason than some people think.

The exhaust gases are always hot, to different degrees. However, with a lean mixture, there is extra oxygen left over in the combustion products (by the very definition of lean).

Combining very hot oxygen with hot aluminum results in the aluminum (the piston) burning (the aluminum chemically combines with the left-over oxygen), just like if it had been hit with an oxy-acetylene gas cutting torch! The burning of the aluminum adds further heat, and the process gets catastrophically destructive in a hurry.

The chemical equation is:

4 Al + 3 O22 Al2O3

Note that at low loads there isn't enough heat in the combustion products to raise the piston temperature enough to initiate burning of the aluminum, so lean mixtures at low loads are safe (and save fuel).

With rich mixtures, the aluminum can't burn (there's no oxygen left after combustion, and it's too cool in the chamber before combustion), it has to melt instead, and this harder to do (the endothermic phase change absorbs a fair bit of energy, unlike the exothermic burning of a lean mix which gives off energy).

Detonation can also be caused by lean mixtures, which is another reason to avoid running lean at high loads. It *will* cause huge spikes in the cylinder pressure (that is audible as 'knock'), that can damage the pistons and even the cylinders by over stressing them with mechanical loads. It must be avoided at all costs.

Rich mixtures burn more slowly (because there's not enough oxygen for the amount of fuel) than lean mixtures (for which an excess of oxygen ensures quick combustion), and this can result in detonation as the unburned portion of the chamber is compressed and heated by the still combusting portion. At low loads, the cylinder combustion speed is much slower (because the air fuel density is much lower), making detonation less likely, so lean mixtures are again okay.

To start you tuning efforts with MegaSquirt-II™ (or MicroSquirt®), you can calculate an initial VE table that has sufficient RPM and kPa bins, as well as an estimate of the VE based on your maximum torque and horsepower figures. To do this, use the Tables/VE Tables/Tools/Generate VE Table utility in TunerStudioMS2.25+. This calculated VE table will need to be tuned carefully to avoid damage to your engine, however.

You can also use automatic mixture correction to help tune your VE table. Read about it here:

Note: Exhaust leaks 'upstream' of the oxygen sensor will cause the sensor to misread the air/fuel ratio and enrich the mixture. Air injection systems, if upstream of the sensor, will do the same under some conditions. Make sure your exhaust manifold gaskets, etc. are in good shape and your sensors see only exhaust gas before using the closed loop EGO sensor feedback feature of MegaSquirt-II™ (or MicroSquirt®)!

Deciding exactly when (and how much) you should run rich is mostly a "seat of the pants" thing. When tuning, you will find the engine will surge (at low loads) and "coughs" at higher loads if it is run lean. Adjust the AFR at the point where this happens so the this does not occur. Check the plugs for detonation (tiny black and white flecks) when tuning at high loads and rpms if you suspect detonation at all. Note that detonation can be caused either by a lean fuel condition (VE too low) or too much spark advance (for the fuel). The simplest way to distinguish these two conditions is with an oxygen sensor. A narrow band should read at least 0.8 volts under full throttle, at least for a starting point in tuning WOT. There are more details later in this section.

Volumetric Efficiency (VE) entries in the 12×12 MegaSquirt-II™ (or MicroSquirt®) VE table are expressed as a percent (i.e. 65 represents 65% volumetric efficiency).

For MegaSquirt-II™ (or MicroSquirt®), VE (= percentage cylinder filling) is relative to manifold pressure, according to the following equation:

mass air in cylinder = (VE x MAP x cylinder volume) / R(constant) x MAT

So mass air increases with boost (MAP), as we all know, but VE, the efficiency of the engine geometry and valve timing, does not keep rising. There are many reasons for this, one of the most important being residual exhaust gas in the cylinder, which displaces the air you are trying to stuff in there. The mechanism by which EGR enters the cylinder is the intake/exhaust valve overlap. As boost increases, this window between intake and exhaust allows more residual gas to flow back into the cylinder because the exhaust backpressure rises at very high boost, and can become greater than the intake pressure. So in practice, VEs are never much greater than about 130%. There is more on the MegaSquirt fuelling equation here:

You can set RPM and MAP sensor values for table wherever you want them, but they must be in the same order as in the table supplied with the software. The same rpm and kPa values are used for all tables in MegaSquirt-II™ (or MicroSquirt®).

For normally aspirated engines, values above 100 kPa are essentially wasted. Put them so they cover entire rpm/boost range of your engine. That is, you want to cover from your slowest idle speed to your red line, and from the kPa at idle or deceleration (whichever is lower) to full throttle (with boost, if applicable). Evenly spaced values work well, but you may choose different values to suit your combination.

Even a turbocharged engine capable of 20 lbs/in of boost will generally not have extremely large VE numbers. The addition of fuel for boost comes through the MAP term in the fuel equation:

pulse width = Req_Fuel × VE(rpm,kpa) × MAP × E + Injector_open_time

In essence, the mass of the air entering a cylinder is computed using the ideal gas law (PV=NRT), where the pressure p is a function of VE and MAP, the volume v = cylinder displacement, the air temperature t is a function of E, r is the gas constant. We are looking for n, the mass of inducted air) and then that result is combined with a characteristic number for a given injector.

If you get the injector opening time correct, and the REQ_FUEL accurately represents the flow rate of your injectors, then the VE entries will be close to the VE noted above. However, if your opening time is not right, or your REQ_FUEL is not, then the numbers will be skewed by the amount the values are in error. In general, except for when you are first trying to get your engine started, use the calculated value for REQ_FUEL and do not change it.

In theory, at stoichiometric mixtures, the VE values at 100kPa would reflect the torque curve of the engine at WOT (ignoring friction effects), assuming a constant AFR level.

Tuning the AFR Table(s)

Air/Fuel Ratio (AFR) entries in the 12×12 MegaSquirt-II™ AFR table are expressed as a ratio of air to fuel by volume (for example 14.7:1 represents a chemically correct ("stoichiometric") ratio for gasoline. A ratio of ~16.5:1 gives good fuel economy at low engine speeds and loads, while a ratio of ~12.5:1 gives maximum power at high loads and rpms. These entries are used to only to adjust the oxygen sensor target voltage, and only if you have a wide band sensor.

MegaSquirt-II™ (or MicroSquirt®) uses one or two 12×12 Air Fuel Ratio (AFR) tables for tuning. MegaSquirt-II™ (or MicroSquirt®) uses the AFR table in different ways, depending on the EGO feedback option you have selected:

Note the EGO feedback does not operate if any of the following are true:

  1. Your MegaSquirt-II™ (or MicroSquirt®) controller has not been receiving an active tach signal for 30 seconds,
  2. The coolant temperature sensor has not reached the Active Above Coolant Temp (°) (EgoTemp),
  3. The TPS is above the 'Active Below TPS (v)' setting, and
  4. The MAP sensor reading is above the 'Active Below MAP (kPa)' setting, and
  5. Either or both of the 'Controller Step Size' (EgoStep) or 'Controller Authority ± (%)' (EgoLimit) are zero.

These are set in the 'Settings/EGO Control' dialog. In particular, unless your 'Active Below MAP' is higher than your baro reading, you will not generate EGO feedback on the stimulator without applying a vacuum to the MAP sensor.

If you do not have a wide band sensor installed, you can calculated the VE value required to produce any other AFR:

newVE% = oldVE% × (stoich(14.7) / desired AFR)

For example, if you have a stoichiometric mixture (NB02 = 0.50 volts) with 65% VE at a certain RPM and kPa, then to lean the mix to 16.0:1 you need:

65% × (14.7 / 16.0) = 60%

To richen an 80% VE entry to 12.5:1 from stoichiometric:

80% × (14.7 / 12.5) = 94%

However, you cannot use the narrow band signal to determine a stoichiometric ratio at high engine speeds and loads - this will damaged your engine if you try! A wide band sensor and controller can be used under these conditions for feedback control.

With wide band sensors, simply set the desired AFR (and type), and adjust the VE table to minimize the EGO correction at all engine speeds and loads.

With a narrow band sensor, you have more work to do. Have someone ride with you and bring up the tuning page. See where the dot hangs around when you are under moderate load - this is where you need to focus on tuning. Later you will try to estimate the higher load numbers from those you determine under lesser loads.

Use the up-arrow + shift to richen the VE values - enrich (with increased VE number) the four corners around where the dot is - give each corner five up-arrow-shifts, and see if this helps. Be sure to turn on EGO correction, and then tune using the EGO correction gauge rather than the EGO voltage gauge. If correction is below 100%, then raise VE to raise correction and so on.

You can also datalog the engine parameters (including O2 volts) and inspect the resulting file to see where the VE needs to be raised or lowered according to the MAP, rpm, and AFR (if you have a wideband O2 sensor).

Tuning the Spark Table

Spark advance refers to the position at which the spark occurs in the crankshaft's revolution. It is measured in degrees before top dead center - °BTDC (when the piston is at its highest). The spark occurs before the piston reaches the top of the cylinder because the fuel takes some time to burn, and we want it well under way at maximum compression. Lower cylinder (and manifold) pressures result in slower burning, so low MAP kPa values have higher spark advance numbers in the table. However, because the burn time is relatively constant for a given pressure, the timing must be advanced in degrees as engine speed (rpm) rises.

For MegaSquirt-II™ (as for most other ignition systems), the total ignition advance is based on three types of advance:

Total advance = initial advance + RPM based advance + vacuum advance

In particular, MegaSquirt-II™ (or MicroSquirt®) uses three factors to determine the total advance (called adv_deg).

  1. The first is the relevant value from the (rpm x kPa table), called ign_table(rpm,kPa).
  2. The second is the advance offset (adv_offset), roughly equivalent to the initial timing.
  3. And the final value that MegaSquirt-II™ (or MicroSquirt®) uses, not present in the above equation, is the cold_adv_deg, which is a 1x10 table based on engine coolant temperature (clt). A cooler engine is less susceptible to detonation, so it can use more advance, and thus make more power and be more efficient.

So with MegaSquirt-II™ (or MicroSquirt®), the advance equation becomes:

adv_deg = adv_offset + ign_table(rpm, kpa) + cold_adv_deg

In the code, all of these advance factors are in tenths of a degree (1/10°), and all are positive only. All ignition parameters are in crank degrees as opposed to distributor degrees.

Before tuning your advance table, be sure to use a timing light to verify that your 'trigger offset' is calibrated. Changing the Trigger Offset in TunerStudioMS will not change the displayed advance, instead, it changes the actual advance as seen with a timing light. Your goal is to make these two match.

To do this, get your engine warmed-up (otherwise the timing moves as the temperature increases) and idling, then use a timing light to verify to be certain your actual advance as shown by a timing light equals your the advance display on the advance gauge in TunerStudioMS. (26.3° in this case). (Note that positive numbers denote BTDC, and negative numbers denote after TDC.)

In the above illustration, you want the 'big' displayed number - 26.3 - to match the number the timing light gives you. You make it match by adjusting the small number - 8.0 - up or down (using the +/- buttons or typing it in).

So in the above example, we wouldn't know how to adjust it, because we are missing the timing light info. But if the timing light showed 28.3 degrees, we would change the trigger angle to 10.0 . This takes 2 degrees out of the timing (because MS-II™only adds 26.3-10 = 16.3 degrees, instead of 26.3 - 8 = 18.3 degrees), and the big number should match the timing light, so your trigger offset is correct.

Note that you can also make the big number and timing light match by rotating the distributor. This has the advantage of allowing you to specify the trigger offset directly to your desired value, and still have the correct timing. If you choose this method, you rotate the distributor until the timing light value (which changes with distributor rotation) matches the big number (which doesn't change). Then your trigger offset is correctly calibrated, and set to your chosen value.

The trigger offset value can theoretically be set anywhere physically, however, since it may be used for cranking and 'fault mode' timing (GM 7-pin HEI), it is best to set it at a reasonable number for idle, say ~8° BTDC (or whatever is recommended by the module's manufacturer). Check this with a timing light. To get the trigger offset to this value, you may have to rotate your distributor or move your crankshaft VR sensor.

The trigger offset is a quick way to move the entire table around. This could help in for example dyno tuning if you wanted to see in one run what retarding everywhere did to you, then start moving things around according to the horsepower curve compared to baseline with 0° offset.

To set the spark advance table, you should try to understand what your engine needs in the following areas:

  1. total advance at WOT: should be from ~24° to ~40° depending on your bore size and combustion chamber characteristics. Older design engines (i.e. push rods, domed pistons, etc.), and those with large bores (big blocks, etc.) need more advance, about 36 to 38°. Newer designs (4 valve/cylinder, swirl port engines, etc.), and small bores, generally require less, about 28 to 32°. Engines that have a lot of miles on them require less as well, because of oil leakage into the chamber. Lower octane fuel also requires less advance (it burns more quickly), so if you are running 87 octane, use a few degrees less total advance than if you are running 94 octane.

  2. initial advance (adv_offset + ign_table(idle)): this is the rough equivalent of the old 'idle advance with the vacuum line disconnected' figure. In MegaSquirt-II™ (or MicroSquirt®), it is the advance at the lowest rpm bin and a MAP value of 100 kPa. Larger initial advance numbers produce a slightly more fuel efficient idle, but may make the idle unstable and result in higher emissions (this is why most engines use the no vacuum advance at idle). Too much initial advance can also make the engine hard to start. Generally, keep the initial advance at 6° to 10°.

  3. RPM based advance: Generally for a performance engine, you want the advance to be 'all-in' by 3000 rpm. So for a given MAP (say 100 kPa) the spark advance should rise from the initial value to the maximum by about 3000 rpm. Your particular settings will depend on your MAP and RPM bins.

  4. vacuum (MAP) advance: as the load on the engine is reduced, the fuel burns more slowly and more advance is required. This means that you should have the advance increase for a given rpm as the MAP value decreases in kPa. So, for example, if you have 32° advance at 4000 rpm and 100 kPa, you might have 40° advance at 4000 rpm and 50 kPa. You can make the intervening values evenly spaced to begin with, and tune them later. You can experiment by using up to 10° to 20° more advance at the lowest kPa bins compared to the highest kPa bins.

For example, most small block Chevrolet V8 engines like about 32° to 38° degrees total advance at wide open throttle (WOT), depending on the heads, compression ratio, and fuel used. Note that you are aiming to have the RPM based advance (analogous to centrifugal advance on an old style distributor) come in at the right rate relative to engine RPM. Typically, you want it "all in" by about 2800-3200 RPMs for a street performance motor. Additional advance above this RPM point isn't needed because increased combustion chamber turbulence results in faster burn times. Note that getting the advance in sooner does NOT build peak HP, but it does build low rpm torque.

Note that the optimum amount of total advance is not necessarily the most that doesn't detonate. For example, with a modern cylinder head design, you might get maximum power at 32°, but might not experience any detonation until 38°-40°. However you will still want the advance to come in as quickly as possible (without knocking) up to 32°.

The exception to maximizing the total advance is the initial advance the engine uses when cranking. Higher initial advance will generate better 'off-idle' response (especially with an automatic transmission), but can cause hard starting, to the point of physically breaking the starter. Some sources recommend up to 14° to 20° of initial advance for performance engines. However, if you have installed your MegaSquirt-II™ (or MicroSquirt®) controller on a high compression, large displacement engine that already puts an additional strain on the starter, limit your initial advance to 4°-6°, then have the advance come in rapidly after 600 to 800 rpm.

You might be tempted to be clever and set the high kPa/low rpm bins (bottom right) to 0°, so that the starting would be easy, and the cranking bypass signal will not be needed. However, you need to consider two things:

  1. one might have to use the cranking bypass, the module may not work otherwise, and
  2. the engine really may not want to transition smoothly from cranking to starting unless the high kPa/low rpm bins are at least 8° to 10°.

To tune the spark table, you will need drive the car and listen for detonation. If you hear any (or better yet, if a datalog shows any feedback from the knock sensor) reduce the advance at the spark advance table point where the detonation occurred. Start at low engine speeds and low engine loads, and work towards higher speeds/loads progressively. Always keep the spark table smooth by adjusting the neighboring 'cells', or driveability may suffer.

Let up on the throttle immediately if you hear the rattles of detonation. Then remove and inspect your spark plugs. Look for evidence of detonation on the porcelin nose of the spark plug that surrounds the center electrode. Detonation will show as "salt and pepper", which is tiny flecks of carbon and/or aluminum that indicate detonation has occurred.

If there are no 'rattles', and no “salt and pepper”, you can increase the advance by a few degrees, and repeat. Check the spark plugs after each drive. As you continue to increase advance, you will eventually either hear detonation (let off the gas immediately!) or you will slow down. At this point, decrease the advance at that point of the spark advance table, increase the VE at the same point in the VE table, or use higher quality fuel. Do not continue to operate an engine that shows signs of detonation, even if it is brief.

If you experience detonation in your engine, then either:

Setting the Acceleration Enrichments

In addition to the 'regular' acceleration enrichments, also check the X-Tau enrichments.

MegaSquirt-II™ (or MicroSquirt®) has blended MAPdot/TPSdot abilities for acceleration enrichment. You can select the proportion of each using the slider in the 'Tuning/Acceleration' dialog in TunerStudioMS (the variable is called Tps_acc_wght in the code). If you choose 100%, you get accel enrichment based on TPS only, if you choose 0%, you get accel enrichment based on MAP only. Of course you can set it to any integer between these (99%, 98%, 97%, ... 3%, 2%, 1%, etc.) and get 'blended' accel enrichment.

The default values are a good place to start (especially if your req_fuel is somewhere between 10 and 20 milliseconds). (To convert v/s (used with older versions of TunerStudioMS) to %/s, assume that 0%=0 Volts and 100% = 5 Volts (which isn't quite true, but it is a start), then 1.0 v/s = 20 %/s, etc.)

The values on the upper right are the TPS based values (as noted by the heading above them), those on the upper left are the MAP based values.

The two vertical columns show the current TPSdot and MAPdot values, with the recent peaks 'tell-taled' in red.

Larger values in the "Value (ms)" entries increase the amount of accel enrichment. Smaller values decrease the amount of accel enrichment.

The slider chooses the percentage of MAP versus TPS, somewhere between 30% and 60% is good for most installations. Some installations may need to use values outside this range to solve specific issues.

MegaSquirt-II™ (or MicroSquirt®) also has user configurable accel taper tuning:

The accel time is time during which the full accel enrichment is added to the injector pulse width (in seconds not milliseconds). The accel taper time allows you to have the accel enrichment taper from the set value to the end pulse width gradually, rather than having the accel enrichment end abruptly.

Each of these accel enrichments schemes has its own threshold (the rate below which no accel enrichment is applied). For MAPdot this is the MAPdot Threshold (kPa/s) (MapThresh), for TPSdot it is the TPSdot threshold (v/s) (TpsThresh).

By watching the bar graphs in the accel wizard, you can see how much noise there is in the respective sensor signals. try to set you threshold(s) above these levels to avoid unwanted accel enrichment, which can make you engine run very poorly.

After you have the VE table dialed in, then start adjusting the acceleration enrichment. You may want to try a short acceleration shot time (like 0.2 seconds) and increase the accel enrichment bins.

If the car does not buck under acceleration, you are close to correct settings. If it bucks and stumbles, then it is going too lean and you need to richen that part of the table. Before tuning decel [or accel], make sure you have your VE table close to correct first! One way to do this is to get the VE table set up by setting the TPSdot threshold setting very high (250 kpa/sec or 250 %/s, something like that) so that TPS enrich/enlean never kicks in. Then, (in steady state) set up VE table.

To adjust the accel bins, start with them high, then reduce the lowest bin value by 0.1 milliseconds at a time until the engine stumbles or coughs under gentle opening of the throttle. If it never stumbles, increase the rate at which you open the throttle and try again. If it stumbles even with the above values, double them and try again.

Then repeat with the next higher bin and slightly faster throttle movement. Continue with each higher bin and more aggressive throttle application until all the bin are satisfactory.

The Decel fuel amount (%) (TPSDQ) enrichment can be used to improve the economy of your vehicle. It reduces the amount of fuel injected when the TPS (and/or MAP) are decreasing. A decel fuel amount setting of 100% means no cut. 1% means reduce the pulse width by 99%, to 1% of what it normally would be. Note that decel 'enrichment' is ONLY applied above 1500 rpm.

Tuning for Economy

To get maximum fuel economy, you should aim to:

Tuning the engine for maximum economy with a wide band oxygen sensor is relatively easy. Set your cruise areas of the AFR table to a lean value, say 16.5:1. If you get surging (which indicates a lean misfire) decrease the AFR entries (say to 16.2:1) and try again. A lean 'surge' that feels like someone is pushing the car forwards, then pulling it backwards while you have a constant accelerator pedal position. Generally, this is a sign that you are too lean.

If you don't get any surging, increase the AFR values a bit (say to 16.8:1) until you see signs of surging, then decrease it by about 0.3:1 to 0.5:1. If your EGO ± Limit (%) is sufficient (given the state of tune of your VE table), you should be getting good economy.

With a narrow band, it's a bit tougher to set it for maximum economy. You can adjust the VE table, but the EGO correction tries to bring it back to a stoichiometric AFR.

You could raise your 'EGO Active Above RPM' to just above your cruise rpm, but depending on where that is, it might not be all that workable.

A better method, if you have a narrow band oxygen sensor, is:

Do this for all the values in the VE table you actually cruise at, but not the higher rpm, higher load areas of the VE table.

That keeps the EGO at 16.5:1 at cruise, but lets you set it anywhere else in the rest of the table.

Tuning and Emissions

MegaSquirt® and MicroSquirt® controllers are experimental devices intended for educational and research purposes. MegaSquirt® and MicroSquirt® controllers are not for sale or use on pollution controlled vehicles. Check the laws that apply in your locality to determine if using a MegaSquirt® or MicroSquirt® controller is legal for your application.

Automotive emissions occur in several forms:

  1. Tail-pipe emissions: This is what most people think of as 'vehicle emissions'; the products of burning fuel in the vehicle's engine, emitted from the vehicle's exhaust system. The major pollutants include:
    1. Unburned Hydrocarbons (HC): Unburned hydrocarbon emissions result when fuel molecules in the engine do not burn or burn only partially. Often this is the result of ignition misfires, low compression, oil leakage past the rings or valves, or excessively rich mixtures (or conversely, lean mixtures that are too lean to ignite, resulting in a lean misfire - and *all* of the fuel passes through as unburned HC!). Hydrocarbons, once released into the atmosphere, react in the presence of nitrogen oxides and sunlight to form ground-level ozone (O3), a major component of smog (see below for details).
    2. Nitrogen oxides (NOx): Nitrogen oxides (technically 'mono-nitrogen oxides': NO and NO2) are generated when normally inert nitrogen in the air reacts with oxygen under the high temperature and pressure conditions inside the engine. These are exacerbated by anything that raises the combustion temperature and pressure or the availability of free oxygen: higher compression ratios, lean mixtures, retarded ignition timing, raised boost, etc. Nitrogen oxides (NOx), like hydrocarbons, are precursors to the formation of ozone (O3). They also break down in the atmosphere to form nitric acid (HNO3) which contributes to the formation of acid rain.
    3. Carbon monoxide (CO): Carbon monoxide is a product of incomplete combustion and occurs when carbon in the fuel is partially oxidized rather than fully oxidized to carbon dioxide (CO2). It is most likely to occur with excessively rich mixtures. Carbon monoxide reduces the flow of oxygen in the bloodstream and as a result is particularly dangerous to people with heart disease.
    4. Carbon dioxide (CO2): Emissions of carbon dioxide are an increasing concern as its role in global warming as a greenhouse gas has become more apparent in recent years.

  2. Evaporative emissions: These are produced by the evaporation of raw fuel, and can be a significant contributor to urban smog, since the heavier hydrocarbon molecules stay close to ground level rather than dissipating into the upper atmosphere. Fuel can evaporate from a vehicle in a number of ways:
    1. Gas tank venting: as the temperature rises from cooler overnight temperatures to the heat of mid-day (plus any additional radiant heat from the exhaust system, etc.) the gasoline's vapor pressure increases as well, increasing the pressure inside the fuel tank by several pounds per square inch above atmospheric pressure. A some point this pressure must be relieved, and before emissions control it was simply vented into the atmosphere as unburned hydrocarbon emissions (HC). Now, however, this function is often under the control of the ECU, and is carefully managed. Such gases may be trapped in charcoal canister and fed to the engine's intake system at appropriate times, for example.
    2. Running losses: the escape of gasoline vapors (unburned hydrocarbons) from the hot engine, such as when the engine is shut off, and residual fuel remaining in the intake tract evaporates and can escape into the atmosphere if it isn't carefully planned and managed.
    3. Re-fuelling losses: can create a lot of hydrocarbon vapor emission (HC). The empty space inside a vehicle's tank is filled with hydrocarbon gases, and as the tank is filled, these gases are forced out into the atmosphere. In addition, there is loss from further evaporation as the fuel tank is opened for re-fuelling, and fuel spillage.

  3. Life cycle emissions: These are produced as a direct result of the activities associated with the manufacture, maintenance, and disposal of the automobile. Life cycle emissions include such items as:
    1. Manufacturing power supply requirements mean that there may be emissions from the power generating source (coal fired plant, etc.). These include the power requires to run plants, as well as the power required to smelt the metals used, etc.
    2. Volatile solvents used a number of stages in the manufacturing process (painting, plastics manufacturing, cleaning, etc.).
    3. Out-gassing of synthetic materials utilized to reduce weight and simplify manufacturing (such as 'lost foam' casting processes, etc.).
    4. Maintenance requirements such as oil and filter changes, battery replacement, repainting when necessary (including collision damage), etc.
    5. Disposal requirements including contaminated lubricants, air conditioning refrigerant, tires, heavy or rare-earth metals, and landfill space requirements.

Traditionally, gasoline is a complex mixture of hydrocarbons (molecules made up of hydrogen atoms on a chain of carbon atoms) of the form CαHβ. It might have trace amounts of nitrogen as well. Oxygen was not historically a part of the structure (though is often included now, more on this below!). The average ratio of carbon to hydrogen in the gasoline hydrocarbon mix is around 8 carbon atoms to 18 hydrogen atoms, i.e. C8H18. By the way, C8H18 is the formula for 'octane' ('oct' implies '8'), and is the basis of the 'octane rating' for knock.

A simplified chemical equation for perfect gasoline/air combustion (the ratio of fuel to air required for perfect combustion is known as stoichiometric (pronounced 'stoy-eék-ee-o-metric') is:

C8H18 + 12.5 O28 CO2 + 9 H2O

The oxygen (O2) is consumed from the intake air. Nitrogen (N2) is also present in the atmospheric air, but ideally does not participate in any reactions (it is quite inert at low temperatures). Note that the combustion products are carbon dioxide (CO2) and water (H2O), if the combustion is 'perfect'.

However, in the real world, not all the fuel burns:

The result is unburned hydrocarbon (HC) emissions (which can also refer to hydrocarbons that are only partially burned).

As well, the heat of combustion may cause the normally inert nitrogen (N2) that composes ~80% of the intake air to break down and combine with oxygen, resulting in oxides of nitrogen emissions (NOx) - single nitrogen atoms with one or more oxygen atoms attached. (Note this is different from nitrous oxide, which is N2O, i.e. two nitrogen atoms are attached to one oxygen atom.) NOx is especially likely to be produced if the combustion temperature is high (high compression, etc.) and if the mixture is lean (because there is excess oxygen remaining even after burning all the fuel).

Finally, some of the fuel won't be able to combine completely with oxygen (which may be locally consumed within the combustion chamber - especially if the mixture is rich), and the result is carbon monoxide (CO) emissions.

So the 'real world' chemical equation for gasoline combustion looks more like:

C8H18 + ~12.5 O2 + ? N2<8 CO2 + <9 H2O + ? HC + ? NOx + ? CO + ? H2

The numbers on the right hand side (the products of combustion) vary considerably with operating conditions, a multitude of design factors, and fueling/ignition strategies.

There is a general relationship between the air/fuel ratio and the regulated tail pipe emissions put out by a given engine design:

What is Smog?

Smog (a term originating in England from the days when coal and peat fired heating created a thick mixture of smoke and fog - "smog"!) is an accumulation of ozone and volatile organic compounds (called VOC) such as peroxyacetyl nitrate (PAN). These are referred to as 'secondary pollutants', because they are formed by the reaction of precursor pollutants emitted by burning fossil fuels, such as nitrogen oxides and hydrocarbons. The energy from sunlight makes the smog forming reactions possible. The result is photochemical smog, the brown haze in the sky that is especially prevalent on hot sunny days.

To form photochemical smog, three main ingredients are needed: nitrogen oxides (NOx), hydrocarbons (HC), and energy from the sun in the form of ultraviolet light (which we will denote as = E - the energy of a photon).

In the atmosphere, the nitric oxide resulting from gasoline combustion combines with atmospheric molecular oxygen to form nitrogen dioxide (NO2) within a few hours.

2 NO + O22 NO2

Nitrogen dioxide (NO2) absorbs sunlight energy and splits to form nitric oxide and atomic oxygen:

NO2 + → NO + O

Then, in sunlight, the atomic oxygen (O) combines with molecular oxygen gas (O2) to form ozone (O3):

O + O2 + → O3

If there were no other precursors present, ozone and nitric oxide would then react to form nitrogen dioxide and molecular oxygen:

O3 + NO ←→ NO2 + O2

This last reaction can proceed in either direction, depending on temperature and the amount of sunlight. If there is a lot of sunlight and the temperature is high, the equation moves to produce the products on the left, and more ozone is produced.

However, engines also emit hydrocarbons (HC) as well as oxides of nitrogen. Hydrocarbons (HC) are the other main precursor forming photochemical smog (besides NOx). When hydrocarbons are present, nitric oxide (NO) preferentially reacts with them instead of reacting with the ozone. This reaction can produce a variety of toxic products, such as a volatile compound (VOC) known as PAN (peroxyacetyl nitrate), CH3COOONO2. (Organic compounds are all chemical compounds containing carbon-hydrogen (C-H) bonds of covalent character. The U.S. Environmental Protection Agency defines a VOC as any organic compound that participates in a photoreaction.) The reactions of NOX and unburned hydrocarbons (HC) are:

NO + HC → CH3COOONO2 and various other volatile organic compounds

NO2 + HC → CH3COOONO2 and various other volatile organic compounds

The result is that there are two problems created by the reaction of the tail pipe pollutants in the atmosphere:

  • Considerable quantities of volatile reactive organic compounds, like PAN, are generated directly that result in the smog you see and the health problems it creates, and
  • When the nitric oxide (NO) reacts with hydrocarbons, it is not available to react with ozone to break it back down to molecular oxygen. As a direct result, ozone may accumulate to damaging levels.

The effects resulting from exposure to photochemical smog range from irritations of the respiratory tract (such as coughing and wheezing and breathing discomfort) and small biochemical or physiological changes, to severe breathing difficulties, markedly reduced lung capacity and efficiency, and aggravation of existing respiratory and cardiovascular conditions.

Ozone affects lung functioning in a variety of ways, causing inflammation in the respiratory tract and damage to lung tissue, contributing to reduced inhalation capacity and lung function.

Studies show there is no safe level of smog. Damaging health effects from exposure to smog can be caused by exposure to large concentrations over a short time span, or by chronic exposure to small amounts over long periods of time.

In addition to the effect on human health, ozone can kill plant cells, reduce plant growth, and make plants more susceptible to damage from other causes. Oxidants such as ozone can also corrode and degrade many common materials such as rubber, nylon, fabric, and paint.

Acid Rain

In addition to smog, automotive emissions can contribute to acid rain. In the air, nitric oxide (NO) is oxidized to nitrogen dioxide (NO2), which in turn reacts with water in the air to give nitric acid (HNO3). This acid dissociates in water to yield hydrogen ions and nitrate ions (NO3-) - i.e., acid rain!

3 NO2 + H2O → 2 HNO3 + NO

Acid rain triggers a number of inorganic and biochemical reactions with harmful effects on the environment:

  • Many lakes have become so acidic that fish and other creatures cannot live in them,
  • Degradation of soil minerals by acid rain produces metal ions that are then washed away in the runoff:
    • Toxic ions, such as Al3+, are released into the water supply, harming everything in the water and all life that depends on the water (for drinking, etc.).
    • Important minerals, such as Ca2+, are leached from the soil, which can deprive trees and agricultural crops of essential minerals needed for life and healthy growth.
  • Atmospheric acidity is transported over long distances by wind currents, so acid-rain effects can be have effects far from where pollutants was originally generated.

A catalytic converter can further reduce tail pipe emissions substantially below what the engine itself produces. This eliminates them from being able to become the precursors to photochemical smog in the atmosphere. A 3-way catalytic converter will support the following chemical reactions in the exhaust gas stream:

The net result is that NOx, CO, and HC are reduced (while CO2 and H2O are increased somewhat).

However, the catalytic converter requires a near stoichiometric mixture to for maximum efficiency, because it only as a limited ability to store oxygen. If the mixture is too rich, there won't be enough oxygen to oxidize the unburned hydrocarbon and carbon monoxide. If the mixture is too lean, the oxides of nitrogen won't be completely reduced. ('Oxidation' is a chemistry term meaning to add oxygen to a molecule, 'reduction' is a chemistry term mean to remove oxygen from a molecule)

The catalytic converter must also reach its 'light off' temperature (around 400° to 600°F) before it will catalyze any of the above reactions - so getting it hot quickly is very important to reducing 'start-up' emissions. This often means a bit of a trade off - for example, retarded timing and a richer mixture to maximize the heat in the exhaust gases while warming up. (Manufacturers have be searching for a method to store converter heat on shut down (the operating temperature may reach 1200° to 1600°F) so it can be used to heat the converter on start up - a number of methods have been proposed, but none have been implemented in production vehicles at the time this is written, to our knowledge.)

The narrow band oxygen sensors are very sensitive to the exhaust gases that result from a stoichiometric mixture. Richer than stoichiometric (by as little as 0.2:1 AFR!) and they give a signal near 1 Volt. Leaner than stoich. and they give a signal near 0 volts. The result is that the narrow band sensor makes a good 'switch' to tell the fuel system to add or subtract fuel to meet the requirements of the catalytic converter for minimal emissions.

For research and educational purposes, properly tuning your engine for minimal emissions using a MegaSquirt® EFI controller generally requires expensive test equipment. However, as a rough initial plan for such a research program, you can:

Here is an example of how a few changes affected one engine:

Baseline Timing
Retarded 10°
Advanced 10°
HC 1.00 0.78 1.14 1.39 0.88
CO 14.5 11.6 13.0 81.0 9.8
NOx 2.91 1.89 5.18 0.71 3.03
Not usually tested
22.3 19.8 23.8 17.4 25.4
Not usually tested
305 307 298 246 310

You can see that retarding the timing and leaning the mixture slightly gives the best possible compromise, increasing only the NOx slightly among the regulated emissions. (The above was without a catalytic converter. With a converter, emissions would have been best at a stoichiometric mixture and the timing retarded somewhat.)

Tuning Issues

If you have a very long duration cam in your motor, and it idles poorly, you might be able to get it to idle better through careful tuning with MegaSquirt-II™ (or MicroSquirt®). Often a rough idle may be caused by too lean air/fuel ratios. This is really is more of a cam issue than a fueling issue. The exhaust valve is held open later into the intake stroke and the intake opens earlier near the end of the exhaust stroke. At low speeds and relatively high intake vacuum you get more exhaust contamination of the fresh air/fuel charge. As you get more contamination of the air/fuel charge you typically need a richer mixture to get it to ignite and burn properly.

This means you probably cannot run a stoichiometric [chemically correct] mixture of 14.7:1 with a long duration cam at idle. You need to run richer. So you tune your idle to achieve the lowest MAP reading at your chosen idle rpm.

Make sure you are not allowing EGO correction at idle if you have a very long duration cam! It will be trying to “correct” your mixture back to a lousy idle. So set the EGO Active Above RPM to a few hundred RPM above your idle speed. This will ensure that MegaSquirt-II™ (or MicroSquirt®) does not try to lean the mixture back to stoichiometric to compensate for your adjustments. If you have a wide-band O2 sensor, you can simply set the AFR table value to give you the lowest MAP reading (maximum vacuum) at idle.

Another tip you can try if you have a large overlap cam is to pinch off the MAP hose slightly while the engine is idling, and see if the idle quality improves. If so, then try a restriction in the MAP vacuum line. People have reported success using a 0.040" (1mm) MIG welder jet and a small plastic fuel filter in the vacuum line to MegaSquirt-II. (Place the filter closest to MegaSquirt-II, the restriction closest to the engine). This has the effect of damping the vacuum pulsation the MAP sensor sees. You will have to experiment with restrictor sizes to see what works for your system.

A few more things to try:

1) Check your VE table entries near the idle point - if the RPM or MAP fluctuate, then you can get rolling idles, etc. You may have to move some of the bins around to bracket the idle RPM/MAP region, and keep flat VE values within this.

2) If you run low-impedance injectors, you need to tune your PWM current limit. Start with 30% (on a V3 main board) or 75% PWM (V2.2 main board) and 1.0 millisecond time threshold. Once you get idling, then first adjust the PWM duty cycle down until you notice a change in idle quality, then move the value back up 3 - 5%. Do the same with the time threshold. On the car it is very easy to do and only takes a few minutes. And, at idle, the overall injector pulse widths are small compared to their close time, so this will allow you to adjust the values. In other words, adjust the PWM current limit before taking the car out on the street where injector pulse widths become high.

Your engine will idle at a certain vacuum. It might help on a street use motor on the VE map to use a lower point for starting MAP than idle vacuum. For example you can have yours set at 20 even though you idle at 27 or so. This allows you to run less fuel on overrun deceleration and coast events (not just for a second like the TPS will do). This allows you a saving of 3-4 MPG on average driving and you might be able to run more advanced timing under this vacuum.

On the other hand, you may want to do the opposite. You can increase the VE values just to the left and above idle. You can make them really rich [say double the idle VE value, to keep the car from stalling. This seems to work really well, if the engine starts to stumble, the PW goes up and it recovers.

By working with the RPM and MAP bins, you should be able to work out a set of values that lets you run lean at cruise and decel [where the RPM is above idle, and MAP below idle], but rich when stalling [RPM below idle].

On the warm up enrichments page, the warm up enrichment only goes to 160º F. The 160º F bin value of the enrichment (which should ideally be 100%) is used at all temperatures above 160º F.

The system compensates automatically for any amount of idle solenoid bypass air because of the effect it has on the MAP value [i.e. the vacuum in the manifold is lowered by the bypass air, this is sensed by the Manifold Absolute Pressure sensor, and the processor decides to inject more fuel. The effect is exactly the same as if you had cracked open the throttle a bit. The fuel goes around the throttle plates, which are never truly closed. They are set at the opening required for the slowest throttle speed desired for the engine under optimal conditions, which leave plenty of room for the fuel to get by. The fast idle air then adds to this baseline amount of air to raise the idle speed. In some circumstances, you may want to run without oxygen sensor feedback, called “open loop”. The best way of forcing MegaSquirt-II™ (or MicroSquirt®) to run open loop is to change the O2 sensor step to 0 [zero] on the enrichments page. It will still log the O2 voltage, but not do anything about it.

With the version 1.000 (and higher) code the MegaSquirt-II™ (or MicroSquirt®) fuel pump output is programmed with a priming pulse option to shut off the unit in case of an engine stall, etc. It turns on the pump immediately when the power is applied and shuts it off 2 seconds later if the engine is not running. If you set the width of priming pulse in MegaSquirt-II™ (or MicroSquirt®) to zero, then the system defaults to not turning on the pump until the first tach pulse. If this field is non-zero, then when the key is turned on, the injectors will fire once with a duration specified by the priming pulse field, and the pump is also activated, and will stay on for two seconds if there is no tach activity, or for as long as there tach activity plus two seconds. When you start cranking, the pump comes on, and times out two seconds after the last pulse on the tach signal.

On start-up MegaSquirt-II™ (or MicroSquirt®) records the ambient barometric pressure. The barometer correction multiplier to VE increases as pressure decreases (if set in TunerStudioMS). If it the ambient baro pressure is low (high altitude) the algorithm adds fuel. This is mostly because at a given MAP, the engine will flow more air with less exhaust back pressure and therefore needs more fuel at higher altitudes. Once running the MAP sensor determines fuel based on you VE table entries which are then scaled by the baro correction recorded at start-up. The correction values used by MegaSquirt-II™ came from a code disassembly of a 1990 Corvette ECU.

If your TunerStudioMS displays unusual values for the barometer on the runtime display, 76 kPa, for example, you may be resetting while running. TunerStudioMS has a check that detects most resets by watching the seconds value. If the seconds goes to zero from any value other than 255, then it signals a reset with an audible “beep” and sets a counter visible on the lower right corner of the screen, where it normally says "connected".

As well, you can check the datalog seconds count - make sure it counts up to 255, and then rolls over to zero and continues again and again. If you get shorter counts (like say 56 then a roll over) then the processor is resetting. Note that most of the time on the car you will not notice that the reset has occurred because it happens so fast. What happens when the engine has a running reset (when the engine is running and the processor resets), then it grabs the barometer near the beginning of the MegaSquirt-II™ (or MicroSquirt®) processor boot procedure. If the engine is running, then it will grab engine vacuum and use this for barometer.

For normal operation the processor comes up so fast that it has grabbed the MAP value before the engine has a chance to start cranking, much less running.


Datalogging allows you to create a running record of the MegaSquirt-II™ (or MicroSquirt®) real-time variables. Once you have enabled datalogging (by clicking on the Datalog menu item on the File list), TunerStudioMS polls the MegaSquirt-II™ (or MicroSquirt®) controller when any of the front page, runtime display or tuning page are active, and writes this data to a file. The file has a comma-separated value format and defaults to having an extension of ".msl" (or ".xls", so Microsoft Excel will open them automatically if you have Excel installed on your system).

To view MegaSquirt-II™ (or MicroSquirt®) datalogs, you can use Phil Tobbin's excellent MegaLogViewer. MegaLogViewer supports:

Seeing your datalogs graphed can give you a very clear idea of how your electronic fuel injection is working, and make it much easier to spot problems. Get MegaLogViewer here

Note that the datalog includes an 'EngineBit' field. This bit will tell you if the engine was accelerating, warming-up, etc., and can be used to sort unsuitable data lines (because O2 correction is not active under acceleration, warm-up, etc.) from the file.

The enginebit has 7 binary bits. The rightmost bit represents running. It is 1 if ready to run, zero if not ready, so 000001 = 1 or 000000 = 0. The next rightmost value is for cranking, 000010 = 2 if cranking. The fields are:

Binary BitDecimalMeaning
0000X004Start-Up enrich
000X0008Warm-Up enrich
00X000016TPS accel enrich
0X0000032Decel enlean
X00000064MAP accel enrich

Note that the only suitable value for reading narrow band O2 sensor values is when the engine bit is equal to 1 (i.e. running and no enrichments).

MegaSquirt® and MicroSquirt® controllers are experimental devices intended for educational purposes.
MegaSquirt® and MicroSquirt® controllers are not for sale or use on pollution controlled vehicles. Check the laws that apply in your locality to determine if using a MegaSquirt® or MicroSquirt® controller is legal for your application.
©2004, 2011 Bruce Bowling and Al Grippo. All rights reserved. MegaSquirt® and MicroSquirt® are registered trademarks. This document is solely for the support of MegaSquirt® boards from Bowling and Grippo.