Click on our menu buttons immediately below to find MegaSquirt® information quickly:
MicroSquirt® Module
V1/V2 MicroSquirt®
Important Safety Information
MicroSquirt® Support Forum
- MShift™ TCU
- MShift™ Intro
- GPIO Build Guide for 4L60E
- Base circuits
- GPO1, GPO2, GPO3,
GPO4 (gear LEDs)
- VB1, VB2, VB3, VB4
- PWM1, PWM2, PWM3, PWM4
- GPI1, GPI2, GPI5
(2/4WD, Input2, downshift)
- GPI3 (Temperature)
- GPI4 (Brake sense)
- EGT1, EGT2, EGT3,
EGT4 (non-CAN Load, line pressure, Input3, Input1)
- VR1 (Vehicle
Speed Sensor)
- VR2 (Upshift button)
- Finishing Touches
- Testing your
GPIO Board
- External Wiring Guide for 4L60E
- Current Release Code
- User Settings
- βeta Code
- Code Archives
- Purchase a
GPIO kit
- Working with the Shift Table
- Serial
Connection Troubleshooting
- CANbus
Set-Up
- Solving VSS
Issues
- Ports, pins, circuits, connections
- MShift™ Discussion
Forums
- Misc. MShift™
Topics
- MShift™ sitemap
- Template Project Code
- GPIO Board Intro
- MShift™/GPIO
Support Forum
|
MegaSquirt-II™/MicroSquirt®/Sequencer™ Code Revisions
This is a list of codes that have been produced by Bowling and Grippo for MS-II™.
There are two hardware versions of MegaSquirt-II™, and two corresponding code versions. ALL MS-II™s sold since August 2005 are V2 MS-II™s (the vast majority of MS-II™s) have a blue solder mask and use the V2 code and INI that starts here. Older MS-II™s with the green solder mask use the V1 code and INI from the top of the page.
Oldest code is at the top, most recent code is at the bottom (click here to go to bottom).
Version 1.000
main.c, Monitor_v.abs.s19
This version has all the basic capabilities of MegaSquirt-I, but much higher precision -
in the µsec range. All V1.xxx codes are intended for the non-CAN MegaSquirt-II (green) only. This code adds:
- Larger tuning tables (12x12),
- WBO2 AFR control,
- Stepper IAC,
- dual tables, and
- ignition control which assumes 1 coil and a mechanical distributor to
distribute spark, or EDIS for multi-coil wasted spark.
Version 1.100
main.c, Monitor_v.abs.s19
- Made serial comms more robust:
- added one word read, write + verify commands,
- write to ram inhibit when overrun detection,
- receiver timeout check.
Version 1.200
main.c, Monitor_v.abs.s19
- Fixed various problems with trigger offsets ATDC (charge time can occur after
input capture at very low rpms and other related ignition timing problems.)
Version 1.300, ..., 1.340 - current release code
main.c, Monitor_v.abs.s19
- Changed tps, tpsdot units to % x 10;
- added accel tailoff algorithm.
Version 2.000
not released as a beta
This version works with the CAN MegaSquirt-II (blue) and has a template for CAN (controller area network) communications.
Additional changes:
- increased input area to 4 x 512 byte blocks;
- inhibit coil charge 2 sec after turning ign key on;
- changed ports for FP, Idle (but connect to same pins on motherboard);
- knock ADC input in Vx100;
- all unused ports initialized as inputs.
- Made IACstart, PrimeP, CWU,CWH, AWEV,AWC,asecount ints instead of bytes.
- PrimeP,AWEV,AWC made function of initial coolant temperature.
- Expanded IAC control options for cranking plus switch to time based after
start;
- added pulse tolerance inputs for cranking and after start;
- IAC option(5) to always enable stepper motor chip for 15 minutes after start,
then revert to option 2.
Version 2.100
main.c, Monitor_v.abs.s19
- Added crank trigger mode. Ignition fires with only mechanical advance (i.e., the trigger offset) during cranking;
- added kpa to display outputs.
Version 2.200
not released as a beta
- Modified/ added ADC averaging:
- provided lag filter averaging for all ADC inputs (also for rpm).
- Relocated VE tables in anticipation of Block Learn Mode for Automatic Mixture control.
Version 2.300
- Improved ego closed loop correction algorithms;
- flex fuel correction for alternative fuels;
- generic spare output ports;
- fixed logic error for IdleCtl=5;
- added fix to maintain coherence of inputs when changed thru serial port.
Version 2.310, 2.320, 2.330, 2340, 2.350, 2.360 - former release code
main.c, Monitor_v.abs.s19
- Fixed bug in ASE logic;set PW=0 in RevLimit mode;
- GCC compatibility changes;
- fixed bug in spare port hysteresis;
- changed some defaults;
- fixed bug in masking of TimerIn interrupts for dt/2;
- limited pw_open in case of battery spikes.
- Fixed stepper motor bug.
Version 2.400
not released as a beta
- Added automatic mixture control;
- mod to AE;
- expanded warmup inputs;
- moved DoOnStack to permanent RAM;
- added option for 2 NBs;
- added knock retard based on ADC7 sensor.
Version 2.500
not released as a beta
- Added wheel decoding;
- added simple AE taper based on rpm;
- added time,% parameters to control tach input interrupt masking;
- 5 sec min for persistence of AS pulse tolerance;
- extended pulse tolerance range from 100 to 255.
Version 2.510, 2.520, 2.530, 2.540
not released as a beta
- Added fix to extend rpm range for wheel decoding; fixed AMC logic.
Version 2.600, 2.610, 2.620, 2.630, 2.640, 2.660, 2.670, 2.671, 2.672, 2.681-2.686, 2.687
main.c, Monitor_v.abs.s19
- Added small model multi-page memory;
- added X-tau transient compensation;
- spark retard as function of manifold air temperature;
- added table fuel corrections for air density and barometric pressure;
- added spk retard correction for flex fuel;
- added injector test mode.
- Fixed bug in table burner;
- added ego volt outputs for narrow band sensor;
- shortened serial ISR time to expand wheel decoder range.
- Provided input for PWM stepper frequency.
- Added check for serial overrun flag.
- Limit baro to 80-120 kPa for baro correction option 1.
- Put COP (computer operating properly) timeout in main loop.
- Made NB AFRtarget Vx100 in code.
- Reduced default tau table.
- Fixed burn in Injector Test mode.
Version 2.700
not released as a beta
- Added dual spark outputs;
- allow alpha-N at lo rpm or at hi rpm.
Version 2.800
not released as a beta
- Added MAF capability, including MAP/ MAF blend,
- 3-port selection for MAF input;
- added option to multiply pulse width equation by AFRStoich / AFRtgt[map,rpm];
- added option to use map/baro as index in VE, spark, and FR tables.
- Set pulse width to 0 when VE = 0 to avoid any fuel dribble (i.e., no opening time applied).
- Added option for wasted spark/ COP (requires external hardware).
- For PredOpt=2, use 1st derivative ignition prediction if slow rate of change.
Version 2.810
not released as a beta
- Removed option for wasted spark/ COP (will be moved to router board).
Version 2.823
released as a beta Nov.07/06
main.c, Monitor_v2.823.abs.s19
- Added 2 cylinder COP/ 4 cylinder wasted spark using cam sync and/or toothed wheel.
- Changes to make starting faster.
- Shortened CPU time in TimerClock.
Version 2.831
released as a beta Dec.19/06
main.c, Monitor_v2.831.abs.s19
- At startup set IAC step to crank position instead of fully open.
- Replaced derivative next tach prediction algorithms with alpha, beta, gamma prediction filter.
- Added serial/ CAN code to interface between MT and auxiliary boards.
- Improved serial reliability.
Version 2.850
released as a beta Jan.23/07
main.c, Monitor_v2.850.abs.s19
- Scaled IAT-based spark retard to allow user to set rpm limiting on IAT correction. It has a Hi and Lo Rpm and goes from full IAT table retard at and above Hi rpm to no retard at and below Lo rpm, interpolate in between. The default rpms are Lo=800 and Hi=1500.
- Added option for dual spark cam inputs for 2 cyl., with Option = 6 same as 1 (2 ignition inputs and 2 outputs) except timing signal from 1 cam tooth, 2 cylinder only.
Version 2.862 - former release code
main.c, Monitor_v2.862.abs.s19
- Scaled MAT-based spark retard by rpm.
- Put kpaix into outpc.
- Provided spark offset to allow odd-fire for all dual output spark options.
- Provided user input for minimum step size for IAC motor moves.
- Provided option to do error check of tach synch even with accel/decel.
- Fixed bug in kpaix calculation.
- Added fuel,spark,Idle adjustments for use with GPIO board.
- Fixed problem with trig offset in dual spark mode.
- Added serial reconnect for all cases + reduced timeout from 10 to 5 sec.
- Fixed oddang/dual spark error.
- Added more CAN code for compatibility with GPIO board.
- Added spare variable counter for detecting extra(++)/ missing(--) tach or tooth pulses.
- Improved reliability of overdwell detection logic.
- Fixed/upgraded CAN comms for gpio board.
- Added dual spark options 7,8 = options 2,3 with crank synch on 2nd input.
Version 2.870
released as a beta May.20/07
main.c, Monitor_v2.870.abs.s19
- Increased threshold for dwell accel correction to keep dwell more stable.
- Put delay in for VR sensor and spark driver delays.
- Put loop for serial table ram versus flash verification in main loop.
- Removed board_id_type array and made mycan_id an input variable.
Version 2.871, 2.873
released as beta Sept.10/07
main.c,
Monitor_v2.873.abs.s19,
INI file,
help file.
- Moved map sampling, pulse width calculation and actual injection(s) to each tach pulse + InjStart deg.
- Added asynchronous TPSdot sample rate input.
- Simplified, improved X-Tau algorithm.
- Added impulse pulse width which is added to normal pulse width if pin E0 LOW (NO2 trigger) or every impulseSec, if impulseSec > 0. The latter can be turned on/off from PC and can, in conjunction with O2 sensor, be used to tune X-Tau parameters.
- Removed decel enleanment from gammae.
- RPM > 0 required for cranking.
- Refined X-Tau to handle dry port at startup, re-start, and re-synch.
- On re-synch, inject on 1st tach pulse rather than waiting Divider pulses.
- Cranking pulse width now goes through topen, batcor, flex fuel and X-Tau calculations.
- Fixed asecount logic so warmup light doesn't come on incorrectly.
- Added MAP trending to predict significant change in map faster.
- Added independent X-Tau loops for each injection bank.
- Made Tau long variable to handle warmup and cold AE.
- Replaced MAP with kpa for knock detect, ego corr; this allows these algorithms to also work with MAF and/or alpha-N.
- Fixed bug in dual spark ignition interrupt service routine (ISR).
Version 2.88, 2.881, 2.883, 2.884, 2.886, 2,887, 2.888, 2.890
main.c source code,
Monitor_v2.891.abs.s19,
INI file,
(Starting with code version 2.889+, each release has its own INI, so for example 2.891 code (Monitor_v2.891.abs.s19) has a specific 2.891 INI (megasquirt-II.ini.2.891). 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.)
settings.ini,
help file.
- Fixed problem with prime pulse and extended max length to seconds.
- Multiplied alpha_map by baro/1000 to emulate change of alpha_map with altitude.
- Added ECU type input to prevent damaging components by a default configuration incompatible with the hardware.
- Cut dwell timeout to 0.3 sec to reduce chance of over-dwell.
- Improved dual spark logic to prevent missed ignition outputs.
- Added baro correction and air density correction correction to crank pulse width.
- Default warmup X-Tau % values reduced to avoid low rpm oscillation.
- Fixed ASE (afterstart enrichment) if start at rpm > crank_rpm.
- Fixed N2O enrichment calculation to be % of time between tach pulses.
- Fixed bug causing spark time tooth offset with 1,2 cylinder wheel.
- Changed wheel decode and wasted/COP Dual Spark ignition into a tooth(angle) based system to improve accuracy of spark timing. The fractional excess of tooth is the only part that remains time based.
- Moved Ign_TimerIn ISR to page 3D.
- Update altcount during cranking so will keep injector banks in synch when come out of cranking (only significant with cam sync).
- Fixed tach output logic for MicroSquirt.
- The spark retard input variable for the Rev Limiter was made a positive-only variable, since no one would advance spark to limit rpm. This expands its range to 0 to 25.5°, instead of +/-12.5°
- The injector test mode was found to be broken, and is fixed in this version.
- Added N2O spark retard,
- Fixed M-0 with crank sync option to yield correct rpm for the 2 cylinder case,
- Fixed bug in altcount at TPS WOT issue,
- Prevent IAC from going to cranking position on missed VR re-synchs,
- Fixed x-tau sum reset bug,
- Locked out missing tooth wheel decode when EDIS selected,
- Added spark adjustment versus baro for alphaN,
- Decreased dwell timeout at lost synch to 20 milliseconds.
- Fixed problem with rejecting noise (extra tooth) in missing tooth gap.
- Set PulseTol to cover manual resynch as well as auto resynch case.
Version 2.900, 2.905, 2.920 - current MS-II™ release code (February 10, 2013)
Monitor_v2.920.abs.s19,
INI file,
settings.ini,
help file.
- Inj Test Mode fix,
- 2 small changes that affect only MAF configurations,
- The ini file requires the use of TunerStudioMS - it will not work with MegaTune. The reason is a table generator program was added to allow loading new MAF tables and MegaTune won't recognize this program.
- Added serCAN comm from 3.xxx code.
- Added MShift outmsg format as default.
Added Signature in Table Descriptors.
- Fixed bug in sync search for wheel gap.
- Added nested interrupts to allow operation with Android phones.
- Fixed overflow problem in warmup.
Version 3.103, 3.104, 3.105, 3.106, 3.108, 3.110
Monitor_v3.110.abs.s19,
INI file,
settings.ini,
help file.
- All functions of 2.885 code.
- First code from B&G with the sequential functions enabled for use with the MS-II Sequencer™ (backwards compatible for MS-II™ and MicroSquirt™).
- Has individual cylinder fuel and spark trim.
- Compiled with Codewarrior 4.5 (older codes were compiled with CW3.1),
- Fixed bug in altcount at TPS WOT issue.
Version 3.430
Monitor_v3.430.abs.s19,
INI file,
settings.ini,
- Fixed a problem with cylinder number and cylinder trim indexes. This required update of the router code to v1.250
- Improved range of MAF airflow calculation and corrected calculation of injector pulsewidth:
Old Equation:
Pw = Topen + MAP x VE x ReqFuel /
New Eq (model-based):
Pw(sec) = Topen + ((MAF(g/s) x (120 / Rpm) / No_cyl) / AFRTGT) / InjFlowRate(g/s)
- Re-ordered tooth pulse processing to make more robust error detection.
- Made check to resynch if a tach pulse occurs in a missing tooth gap – this is not allowed.
- Fixed InjStartTime so fuel as well as spark works properly for odd-fire
engines. This will make sensor sampling more consistent . See Figures
1A, B, C below. In the figures the InjStrt is a percentage of one tach cycle for which the injection is delayed relative to the start of the tach cycle. You can’t delay so much that the injection starts with less than 2 ms remaining before the end of the tach cycle. This is because the router must receive the starting edge of the pulse width from the ECU before the next tach cycle, and the 2 ms allows for prediction error, interrupt latency and pulse width calculation time.
2-cylinder sequential
Even Fire (Odd Angle = 0 deg)
InjStrt= 0%----------- InjStrt= 78%
/__ /
|---|------------------| 2 ms |
Inj1________| |__________________|________|______________________________
InjStrt= 0%------------à InjStrt= 78%
/____ /
|----|-------------------| 2 ms |
Inj2 _____________________________| |___________________|_______|________
------------|--------------------------|---------------------------|---------
-----------Tach 1--------------------Tach 2-----------------------Tach 3
Figure 1A.
Note that if the Odd_Angle offset is positive, as below, meaning the offset is to be added to Ign 2, Inj 2 outputs to advance(+) rather than retard(-) relative to Ign 1, Inj 1, then InjStart can not be 0%. The equation in the code is:
Actual InjStrt = Input InjStrt - OddAngle (in % of tach period), =0 if result < 0.
InjStrt can be entered as 0, but the delay relative to cylinder 2 TDC will actually be (Odd_Angle degrees / tach cycle degrees) x 100 = 16% in the examples shown below. So in order for the fuel to be injected at the same relative position in each cylinder, InjStart must be set to 16% or else Inj 1 will open immediately after TDC1, but Inj 2 is forced in the code to open 60 deg after TDC2 at the earliest
2-cylinder sequential
Odd Fire (Odd Angle = +60 deg)
InjStrt= 16%----------- InjStrt= 78%
/___ /
|---|---------------------| 2 ms |
Inj1 ___|___| |_______________|________|______________________________________
60 deg
InjStrt= 16%----à InjStrt= 78%
/____ /
|----|---------------| 3 ms |
Inj2 _________________________________| |_______________|________________|________
--------|----------------------------|------|-------------------------------|--------
---Tach=TDC 1---------------------- TDC2--Tach 2-------------------------- Tach=TDC 3
60 deg
Figure 1B.
With a negative Odd Angle, there is no problem with both injectors opening right after tach, but the range through which you can move the injection is limited to 56% before the ‘2 ms before tach’ limit is reached on the second injector channel.
2-cylinder sequential
Odd Fire (Odd Angle = -80 deg)
InjStrt= 0%---- InjStrt= 56%
/_____ /
|-----|------------| 4.1 ms |
Inj1 ____| |____________|_____________|_____________________________________________
InjStrt= 0%-------- InjStrt= 56%
/____ /
|----|--------------| 2 ms|
Inj2 ______________________________________| |______________|_______|_________________
----------|--------------------------------|--------|------------------------------------|---
---Tach=TDC 1-----------------------------Tach 2--TDC2---------------------------- Tach=TDC 3
80 deg
Figure 1C.
- A soft rev limit was added as a third option for sequential mode. This starts randomly cutting fuel to the cylinders starting at Rpm1, with complete fuel cut by Rpm2.
- Reset egocount when leave O2 closed_loop, so it will have to count back up before the first correction can be made after closed loop is restarted.
- Made MicroSquirt® fueling sequential in dual spark sequential modes, alternating, by tying the injector bank activated to the ignition Output Compare channel rather than the alternating count (altcount) which isn't updated in cranking (only in flood clear), so it can start off randomly, while the first OC channel number to be updated is consistently the same after synch.
- The CAN Id for the router processor = 14. This id should not be used for gpio devices.
- Modified CAN pass-through mode to request up to 80 bytes of data and write up to 65K with one serial message.
- Made mods to serial and CAN code to make them closer to universal, standalone modules.
- Relocated flash burn subroutines to unbanked flash to handle tables in arbitrary banked flash.
- Increased stack size to avoid overflow.
- Added code to handle spare I/O or PWM outputs in sequencer.
- Added cranking pulsewidth for sequencer. Made FuelAdj %x10.
- Made fuel injection timing tooth angle-based.
- Changed Tacho from fixed pw to 30% duty cycle.
- Fixed pwm idle so works properly prior to synch.
- Added new option for soft fuel cut rev limit (for sequential mode).
- Modified CAN pass-through mode to request up to 80 bytes of data and write up to 65K with
one serial message, Fixed bug in flex fuel.
- Remove T can/ serial mode (not needed).
- Made serial and CAN into semi-universal, standalone modules. Uses can_id = 14 for sequencer
router processor.
- Re-ordered tooth pulse processing to make more robust error detection.
Improved range of airflow calc.
- Modified InjStartTime for 2nd cylinder if odd-fire engine.
Relocated flash burn subroutines to unbanked flash to handle tables in arbitrary banked
flash.
- Increased stack size.
- Made check to resynch if a tach pulse is in missing teeth gap.
- Provided 1 cyl, 2 cyl-wasted option to use only 1 ignition output or tie the 2 together.
- Corrected calculation of pw when using MAF options and added maf + map/no blend option.
- Fixed trimoff index kluge - use with seqv1.240+.
- Added capability for injector test mode and Prime Pulse - use with seqv1.250+.
- Added preliminary model-based options: manifold filling for maf + map case; residual gas
model to calculate VE for map-only case.
- Increased sizeof outpc to 130 bytes.
- Fixed CAN pass-thru and outmsg bugs - use with seqv1.260+.
- Fixed overflow bug in after start warmup.
- Fixed maf-map unnecessary blending.
- Added code for frequency based maf.
- Fixed load_43 calc.
- Added option to put 2nd EGO on AD7.
- Restored dual table capability for sequencer (use ve2, afr2 on 2nd, 4th,.. cyls).
- Fixed bug with ego control loop with dual NB sensors.
- Limited baro to 80-120 if separate baro sensor.
- Added tach pulse fixed width/ duty cycle options.
- Added Sequencer capability for Injector Test Mode and Prime Pulse – use with seqv1.250+.
- Restored capability to compensate x, tau parameters for coolant temperature during the warmup period. The coolant compensation should NOT be made more than about 2 or 3 times (200-300%) for tau, and X, after coolant compensation, should generally not exceed 60-70%. This in no way replaces the normal warmup enrichment, which compensates for poor fuel mixing, a separate effect from wall wetting.
- Fixed overflow bug in after start warmup engine cycle count.
- 3.4xx code may not load on MS-II's with older bootloader code (may require bootloader update via BDM cable if code loading stops at 37%). See (2) here for more information.
Version 3.730, 3.760, 3.770
Monitor_v3.770.abs.s19,
INI file,
settings.ini,
help file.
- First version for production Sequencer board. Swaps T7(IACA) to T3 so T7 can be MAF Frequency input.
- Fixed possible bug in wasted->seqtl, 2 cyl fuel trim.
- Forced spark polarity for Sequencer.
- Added AutoTrigger option to automatically calculate adv_offset, Delay_Teeth, No_Skip_Teeth.
- Expanded option to also use input start of FI in crank deg rel to TDCC1 to calculate spk_fuel_offset and pInjStart.
- Unfixed bug in wasted->seqtl.
- Added capability of entering sample deg for MAP, MAF separate from injection start deg.
- Moved InjTest to subroutine on PAGE 38C, therefore had to remove auto reboot.
- Added expanded dual table options. Provided changing afrstoich inputs for FlexFuel.
- Improved MAF frequency accuracy. Fixed fuel timing error for odd-fire. Sample map every other cylinder for odd-fire engines, so will get consistent map readings.
- Made cam tooth feature apply for all numbers of cylinders; made sequential logic for 2 cyl in MicroSquirt® same as for Sequencer™ 4,6,8 cyl.
Version 3.830 (released Feb 10, 2013)
Monitor_v3.830.abs.s19,
INI file,
settings.ini,
help file.
- Added Signature in Table Descriptors.
- Fixed bug in sync search for wheel gap.
- Added nested interrupts to allow operation with Android phones
- Fixed overflow problem in warmup.
Version 3.830b (Current MicroSquirt®/Sequencer™ release code - released Dec. 15, 2016)
Monitor_v3.830b.abs.s19,
INI file,
settings.ini,
help file.
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.
© 2006, 2013 Al Grippo and Bruce Bowling - All rights reserved. MegaSquirt® and MicroSquirt® are registered trademarks.