MegaSquirt-II Code Revisions
Oldest code is at the top, oldest 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 - current release code (Mar.8/09)
main.c source code,
Monitor_v2.890.abs.s19,
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 3.103, 3.104, 3.105, 3.106, 3.108, 3.110 (current beta code)
main.c source code,
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.
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, 2009 Al Grippo and Bruce Bowling - All rights reserved. MegaSquirt® and MicroSquirt® are registered trademarks.