Configuring MegaSquirt-II™ (or MicroSquirt)

Tuning Software

The software applications you can use to tune and configure your MegaSquirt-II™ (or MicroSquirt) are called TunerStudio by Phil Tobin or MegaTune2.25+ by Eric Fahlgren.

You also need Windows 9X/ME/XP and a conventional serial port to communicate with MegaSquirt-II™ (or MicroSquirt). 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 booting Windows 95 (or better) will be fast enough, but get the fastest laptop computer you think is reasonably priced.

To tune all the parameters of MegaSquirt-II™ (or MicroSquirt®) so that your engine runs the best it can, you will need to do the following:

  1. First, install and learn to use MegaTune2.25 or higher,
  2. Next, set the constants,
  3. Get the engine started and idling,
  4. Then tune the PWM criteria,
  5. Then tune the cold start and warm-up enrichments,
  6. Then tune the VE table, the AFR table, and the spark advance table,
  7. Finally, set the acceleration enrichments,

This section of the manual covers the first two items. the remainder are covered in the Tuning MegaSquirt-II™ (or MicroSquirt) section. Before starting this section, be sure you have read and understood the information on the MegaSquirt-II™ (or MicroSquirt) Installation page.

Using MegaTune2.25+

General Advice and Operation

Some general principles to follow when setting the configuration parameters are:

Some Warnings

Note that it is possible to damage your engine and/or MegaSquirt® by choosing inappropriate tuning or set-up parameters in MegaTune. Be sure to read this document, and all associated tuning documents that apply to your engine, vehicle, and tuning circumstances. In particular, read the safety precautions.

Installing MegaTune

MegaTune has an 'automated' install package, similar to most other modern Windows software. You download the set-up file (see below), click on it, and the package installs itself. You may have to select some options, or you may chose to select all the defaults.

Files

Get the latest version of MegaTune from www.megamanual.com/files/software/.

To install the latest version of MegaTune on your computer:

  1. Click this link to go to the release site,

  2. Select the file MegaTune225p3_setup.exe and double click on it.

  3. Choose 'Run' or 'Run program from current location' when prompted.
  4. Choose all the defaults when installing the program, and it will create a folder called 'C:\Program files\MegaSquirt\MegaTune225' and subfolders 'mtCfg' and 'carMtCfg'. The install program also creates an icon on your desktop with the name MegaTune225..., DON'T click it yet, you need to set up MegaTune (see 'Using MegaTune225 below').

  5. The install program will also create a folder in 'C:\Program files\MegaSquirt\' called 'Car1', this is where all your vehicle specific information will go.

  6. Start up the MT Configurator (mtCfg.exe), which opens automatically during the installation process (it can be opened directly from the MegaTune folder at any later time). Open the MegaTune2.25bxxx tree item, and you'll see a number of megasquirt-II.ini.N.N files. Pick the one where N.N matches the version of embedded code you are running, highlight the .ini file version that you wish to use and execute File -> Activate. This will rename it to be "megasquirt-II.ini" (deleting the existing megasquirt-II.ini file first). It will then be used by MegaTune when it starts up.

    (New code versions (2.889+) have their own INI, so for example 2.890 code (Monitor_v2.890.abs.s19) has a specific 2.980 INI (megasquirt-II.ini.2.890).

    You will find the INI files here: http://www.megamanual.com/files/ini/ and the code S19 loadable files here: http://www.megamanual.com/files/code/

    Note that all older 2.XY (prior to 2.889) use the same 2.X INI file. For example, the 2.35 code uses the 2.3 INI file. This is the way the older code upgrades are designed. Major revisions were incremented by +0.1 and require a new INI file, minor revisions (+0.01) use the same INI file.)

  7. You need to tell MegaTune which version of MegaSquirt® you have (MS, MS-II, MSnS-E, etc.), as well as the EGO type, etc. To do this, use the mtCfg program, which opens automatically during the installation process (it can be opened directly from the MegaTune folder at any later time). Look for the CODE_VARIANT variable, it will be in 'Car1/settings.ini/Settings/CODE_VARIANT' in the directory tree on the left side of the mtCfg window. Click on CODE_VARIANT. You can then use the drop box in the upper right section of the window to select your code variant.

    While you are in the setting.ini files, you can verify or change the EGO sensor option under LAMBDA_SENSOR if necessary.

    You can use mtCfg to change the color depth, temperature units (°F/C) and a large number of other parameters for MegaTune. See the documentation in the files displayed in mtCfg.

    Be sure to 'Save' the file.

  8. Increase the value of the interwrite delay from the default of 1. An interwrite delay value of 5 seems to cure most comm issues. You will find this value in the common.ini file, which is usually in the 'mtCommon' subfolder of the MegaSquirt® folder (i.e., C:\Program Files\MegaSquirt\mtCommon\common.ini). Make sure the preceeding line reads "writeBlocks = off", do not edit that line unless it says "on" (the comment is misleading, interwrite delay is still used if writeBlocks = off). You can open common.ini with Notepad, or copy it from this link: common.ini (right click and 'save as').

  9. You should now be able to launch MegaTune. Double-click the MegaTune icon (created above) on the desktop. In order to communicate with MegaSquirt-II™ (or MicroSquirt), you may need to set the serial port configuration. To do this, got to the Communications/Settings dialog on the MegaTune menu.

If you use a USB adapter, be SURE to set the buffer size to ZERO (0). You can change this in the Control Panel, look under 'System, Hardware, Device Manager'. The default buffer size for these adapters is typically 14 bytes. If this is the case with yours and you left the default, you would have no control over the data flow no matter what else you do.

When MegaSquirt® is loaded and communicating with MegaSquirt-II™ (or MicroSquirt), the first thing you will see is the front page, which shows eight of the more useful gauges:

A number of the sensor readings are displayed, as well as some outputs. For example, the injector pulse width is the measure in milliseconds of how long the injector is opened for each pulse, regardless of how many times it is opened in a cycle. Duty cycle gives the percentage of time the injector is open irrespective of individual pulse duration.

There is a bar gauge across the bottom of the window shows the oxygen sensor reading. The scale is determined by egoGauge value in the Tuning section of the MegaTune2.25+.ini file. This same setting controls the analog and bar gauges on the tuning page. The first value of this setting controls the lowest voltage displayed on the gauges, the second number controls the highest and the optional third value specifies the “alert” value, above which the LEDs are red. The bottom of the front page contains a status bar. The current file name (used for Save operations) is displayed in the left part of the status bar, followed by “saved” status. When the memory image has been modified since the last Open or Save operation, this entry shows “SAVED” in bold face.

However the front page is limited to eight gauges, which may not be enough, especially when you are learning to use MegaTune. If you go to the 'Tuning/Realtime Display', you can see many more at once:

This is a good page to monitor while experimenting with the stimulator and MegaSquirt-II™ (or MicroSquirt).

MegaTune2.25+ allows you to save and restore configurations as disk files (they have an .msq extension). Use the Open, Save and Save As menu items to do this.

Setting the General Parameters

Note that as the code develops, some advanced options may not be documented here. To find information on these advanced options, see the MegaTune help file.

Some general principles to follow when setting the configuration parameters are:

Now we are ready to start configuring MegaSquirt-II™ (or MicroSquirt)!

On the main MegaTune2.25+ menu is an item called 'Settings/General'.

You can set these as follows:

If you are using a knock sensor, separate baro sensor, or non-standard MAP sensor, you can configure MegaSquirt-II™ (or MicroSquirt) to work with them using the 'Sensor Calibration' dialog under 'Tools'.

The MegaSquirt-II™ code is set up for the standard General Motors temperature sensors. If you are using other sensors, you can use the 'Calibrate Thermistor Tables' dialog under 'Tools'. You enter the bias resistor value and three temperature/resistance points, and the table is created and downloaded to MegaSquirt-II™ (or MicroSquirt) for you.

IMPORTANT NOTE: Do NOT burn tables ('Calibrate AFR Table' or 'Calibrate Thermistor Tables') on a running engine. Even idle is NOT allowed, because these tables ONLY exist in flash, so once a table is erased, there is nothing but garbage in there until it is re-programmed, one word at a time. Until that reprogramming is complete, operating the engine is unsafe.

MegaSquirt uses coolant and air temperature sensors to determine the warm-up characteristics of the engine and the density of the intake air. They are essential to proper functioning of a MegaSquirt® controller. Both sensors are Negative Temperature Coefficient (NTC) thermistors. This means that they are resistors whose resistance decreases as their temperature goes up.

MegaSquirt® uses the temperature sensor as one leg of a voltage divider. 5.00 Volts (we will call this Vs) is supplied to a default 2,490 Ohm (2.49K Ohm) resistor (called a "bias resistor", and we will denote it as Rb) and this resistor is connected to the temperature sensor (denoted here by Rs) which in turn is connected to ground.

The voltage between the two resistors is:

V = Vs * (Rs/(Rb+Rs)) = 5.00 * (Rs/(Rs+2490))

Resistor Rp does not affect the voltage divider, it simply limits the current to the processor pin (there should be very little current anyhow, the input is "high impedance").

MegaSquirt-II reads this voltage as a series of voltage steps: 1023 0.005 Volt steps. The conversion from volts to steps is done by the analog-to-digital converter (ADC).

To use a MegaSquirt® controller with an air cooled engine, you will have to decide where the best place is for the coolant sensor: in the oil, or on the cylinder head (CHT). There are various arguments for and against using either CHT or oil temperature as the 'coolant' temperature input on air cooled motors. A lot depends on whether the motor is substantially oil cooled or not. Since the CTS input is used for warmup enrichment, you want something that responds fairly rapidly, so this is highly engine-dependent.

For high temperature applications (i.e. air cooled engines with a CHT), in MS-II you can set the #unset EXPANDED_CLT_TEMP by changing:

#unset EXPANDED_CLT_TEMP

to

# set EXPANDED_CLT_TEMP:

Then the upper temperature limit should be 600 degrees F. This is from the INI notes:

; FAHRENHEIT (Expanded/Normal):
;     Low Limit: -40F/-40F
;     High limit: 600F/300F
;     Low danger: 150F/50F
;     Low warning: 200F/150F
;     High warning: 325F/200F
;     High danger: 350F/220F
However, you have to calibrate the thermistor table(s) appropriately.

However, note that the tuning software limits the temperature range. The thinking is that if you are at an extreme it is probably a bad or missing sensor, so it goes to a default value. This isn't a big deal in TunerStudio though, you can change these limits in the ms2ReferenceTables.ini file. You can adjust these limits if EXPANDED_CLT_TEMP is set. Currently only the CLT sensor respects EXPANDED_CLT_TEMP, the IAT does not.

IAT min = -40, max=350 if outside that range it goes to 70 CLT min = -40, max=350 if outside that range it goes to 180 CLT with EXTENDED_CLT_TEMP min = -40, max=400 if outside that range it goes to 350 default

Here is the section of the ms2ReferenceTables.ini file that controls that:

; tableLimits (optional) = intentifier, min, max, defaultVal
; will set the default value if value is outside the min and max limits.
tableLimits = 001, -40, 350, 70
#if EXPANDED_CLT_TEMP
tableLimits = 000, -40, 400, 350
#else
tableLimits = 000, -40, 350, 180
#endif"
So the user can just edit the one line in ms2ReferenceTables.ini using notepad.exe or something similar to change it from:

tableLimits = 000, -40, 400, 350

to something like:

tableLimits = 000, -40, 600, 350

or similar, and it should work once the user re-burns the table.

The additional problem with very high temperatures is that the difference in voltage gets very small (and MegaSquirt can only read discrete voltage steps, about 5 milliVolts for each of the 1023 steps from 0.00 to 5.00). Also, if the volts at the processor pin gets very near 5.00 (~4.98) the values defaults to a safe value because it assumes there is an open circuit.

The ADC count result from the voltage divider circuit (above) is:

ADC Count = V/Vs = ADC max count * (Rs/(Rb+Rs))
      = 1023 * (Rs/(Rs+2490)) for a MS-II (10-bit ADC)

One thing you can do is use a lower bias resistor (R7 for the CLT circuit) - this will give you more resolution at the high end of the temperature scale (but loose it at the cold end). The default value is 2.49K Ohms, and if that is what is in there you might try 2.2K Ohms or less (down as low as 1.0K). Note that you have to re-calibrate the thermistor tables when you change resistor values.

Here is a simple ADC count calculator that shows the number ADC steps for a given bias resistor and sensor resistance. If the ADC count values are very high or very low at your sensor's resistance (at a given temperature), the temperature range may be restricted:

Bias resistor:
Ωhms
Voltage supply:
Volts
Sensor resistance: Ωhms ADC resolution:
ADC Count:

For air-cooled use, side of the argument says to use the CHT over the oil, as the oil takes over twice as long to get to operating temperature than water in a water-cooled car does. The engine does not need to run rich for long periods, only enough to keep the car driveable while it is warming up. Once the cylinder head is up to temperature, the car is usually quite driveable. For an air cooled engine you can drill and tap into a fin in the head for the CHT sensor.

The other side says that it does not matter if the oil warms more slowly, you can just set the warm-up enrichment to come off at a lower temperature. In that case, the GM coolant sensor fitted in the oil (sump) will work nicely. Search the archives for extensive discussions on these points. It is your decision.

Idle Control Settings

The basic idea of IAC is that the motor or PWM solenoid starts out with a large opening of the air valve at cold startup, then gradually closes as the coolant temperature rises. The basic motor position at any given time is determined from the input table of step position versus coolant temperature. To this basic control algorithm, several features have been added as described below. You need to set MegaSquirt-II™ (or MicroSquirt) to tell it if you have a fast idle "solenoid type" valve or a stepper motor IAC, or neither. These are selected under Settings/Idle Control in MegaTune:

If you have an IAC stepper motor, you will have to choose between 'moving only' and 'always active'. If you set your stepper to 'always on' for 15 min or so and it doesn't feel too hot to you, then you can leave it that way. Apparently this is what General Motors does. But if you want to be safe you can test it on the bench for 15 min or so. It will get right warm, but it shouldn't burn your fingers just touching it. If it gets too hot, use 'moving only' instead.

Setting the Injector Criteria

Before attempting to start your MegaSquirt-II™ (or MicroSquirt) equipped engine, you will need to set a number of parameters that determine how MegaSquirt® injects fuel. These include the injector open time, Req_Fuel, injector control criteria, PWM criteria, EGO characteristics, etc. These constants are either calculated, or based on the configuration of your system. For the most part, these are very similar to those from MegaSquirt.

Note that for a Wankel rotary engine (Mazda 13B, etc.), see the MegaSquirt & Rotary Engines document for settings and other advice.

On the Settings/Injector Characteristics page:

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. If you are running high-impedance injectors (greater than 10 Ohms), then set the PWM time to a number like 25.4, in essence you are disabling the PWM mode. This allows full voltage to the injectors throughout the pulse width.

For low-impedance injectors (less than 3 Ohms), you need to limit the current to avoid overheating the injectors. To do this, there is a period of time that you apply full battery voltage [peak] current, then switch over to a lower current-averaged [hold] current, i.e. peak and hold. Alternatively, you can add resistors in series with the injectors. See the Injectors and Fuel Supply section of the MegaSquirt® manual for more details.

To run low-impedance injectors with the PWM current limit mode, you need to set two parameters - the "PWM Current Limit %" and the "Time Threshold for PWM Mode" - both are on the “Constants” page. The current limit % is the percent duty cycle when the current limit is invoked. The time threshold is the amount of time from when the injector is first opened until the current limit is activated.

High impedance injectors can run on 12 Volts without problems. Low-impedance injectors require some form of current limiting. MegaSquirt® has pulse width modulation to limit the current. You need to set the PWM parameters to match your injectors:

Note that most distributors are shipping the V3 main board with the flyback circuit installed. If you are not sure, look for the presence of Q3 and Q11 on the heat sink (3rd and 7th from the left), or ask the distributor.

You will tune these after getting the engine running. See “Setting the PWM Criteria” in the tuning section of this manual. Failure to perform the tuning steps can result in damage to your injectors. If you have high-impedance injectors, set these values to 25.4 ms and 100%, and you do not need to tune them further.

On the 'Settings/Injector Control' page:

Note that for release 1.000, odd-fire is only in the code as a placeholder, there is no code supporting it at this time.

On the 'EGO Control' page:

Note that after you select your EGO sensor type, you should go to the 'Tools/Calibrate AFR Table' dialog and select the sensor output curve.

For example, if you have a narrow band sensor, select that; or if you have a DIY-WB controller select that, etc. Then click on the 'OK' button and a file will be create and downloaded to MegaSquirt-II™ (or MicroSquirt) that indicates the corresponding air/fuel ratio for various sensor/controller output voltages.

You can also create your own custom table by entering two point on the output curve.

There is more information on how to use these settings while tuning in the Tuning section.

IMPORTANT NOTE: Do NOT burn tables ('Calibrate AFR Table' or 'Calibrate Thermistor Tables') on a running engine. Even idle is NOT allowed, because these tables ONLY exist in flash, so once a table is erased, there is nothing but garbage in there until it is re-programmed, one word at a time. Until that reprogramming is complete, operating the engine is unsafe.

Setting the Tables:

Before starting your engine, you need to populate three types of tables: the VE table(s), the AFR table(s), and the ignition advance table.

Advance numbers can be specified in tenths of a degree (1/10°)

Setting the Ignition Options

MegaSquirt has a number of options:

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). There are some tip on setting these parameters in the tuning section of the MS-II manual.

In the 'Settings/Ignition Options' dialog you can select the:

Dwell Setting

Dwell is the length of time the coil charges to make each spark. It has to be long enough to make a decent spark, but too long heats the coil unnecessarily. It is in milliseconds, since the time between spark is typically a few dozen or less milliseconds. For example, for a V8 at 600 rpm, the time between sparks is 25 milliseconds. At 6000 rpm the time is just 2.5 milliseconds.

In general, use the default options and values unless you have a reason to do otherwise. You can calculate the appropriate times using the formula above and substituting different values for E.

MAP Sensor

If you have a non-standard MAP sensor (i.e., not the default MPX4250AP), then you need to do a calibration under 'Tools/Sensor Calibration'. You need to set both the MAP and barometer sensor to match the sensor(s) you are using. Press F1 while in the sensor calibration dialog to see values for some common sensors. Do NOT change the barometric correction, just the MAP and barometer sensor. You may need to edit the MegaTune ini files to show the full range of your sensor.



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, 2010 Bruce Bowling and Al Grippo and Lance Gardiner. All rights reserved. MegaSquirt® and MicroSquirt® are registered trademarks. This document is solely for the support of MegaSquirt® boards from Bowling and Grippo.