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


MegaShift™ and Spare Port Outputs

As of the 2.120 MShift™ code, the uses of the 'spare ports' has been expanded and simplified1. Code version 5.002+ adds the optional use of the speedo output and PC line pressure output as spare outputs. In addition to certain user spare port conditions, TCC mode for spare port 1, and shift solenoid for spare port 2, all modes have bit-banged pulse width modulation (PWM) (Spare Port 1 & 2) or timer PWM (Spare Port 0).

A dedicated PWM mode has been added for all three spare outputs, and TCC, selective clutch, and shift solenoid modes have been made available on all three spare port outputs.

The PWM settings for the three spare ports are independent. They each have their own:

The user can set the PWM frequencies for spare port 1 and 2 from 30.6 Hertz to 1953 Hertz.

The spare ports use pulse width modulation is ALL modes. The spareport's PWM table is used whenever the output is ON, so the controller reports the current PWM%. If you want an ON/OFF digital output, set the entire PWM% table to 100% and set the OFF value to 0% for a typical output. If you want an inverted output because of the particular characteristics of your output circuit or your device, set the PWM table 0% for all cells and set 100% as the off value.

There are 5 mode options available for each of the 4 spare ports:

Spare PortSpeedo
Output
Line Pressure
Output
User
Spare
Output
PWM TCC Shift
Solenoid
Selective
Clutch
Spare Port 0
(v4.100 and higher)
Spare Port 1
(v2.120 and higher)
Spare Port 2
(v2.120 and higher)
Spare Port 3
(v5.002 and higher)

The spare port's circuit hardware must be built appropriately for any of these outputs to handle the device it is connect to. Note that any output that is pulse width modulated must have a recirculation diode installed on the controlled device. It does not hurt to have such a diode installed on every output, even if it is ON/OFF.

Spare Port Modes:

The function of each spare port can be selected under: Spare Ports→Spare Ports Function→Spare Port X Usage (there are 5 modes for each of the three spare ports, corresponding to 5 values of the parameter spX_mode. Note that the PWM table for the respective port is used to set the ON state in any of the modes.):

  1. User Spare Ports/Speedo Output/Dedicated Line Pressure*:
    1. Spare Port 1 and Spare Port 2: User controlled settings control the behavior based on speed, rpm, load. ON and OFF PWM percentages are based on the 12 element table (ON) and PWM OFF value (OFF). The PWM is updated continuously based on the index value. The AND'ed conditions, thresholds, and hysteresis values are set under: Spare Ports→User Spare Port X. Spare ports 1 or 2 cannot be used as speedo outputs.
    2. Spare Port 0: Can be used as a speedometer output. Signal will be derived from VSS input. See this link: Output Pulse/Mile for more information.
    3. Spare Port 3 as a dedicated PC Output: Can be used as a line pressure output. The PWM will be derived from the 16x9 line prssure table, unless the pressure exceeds the up/downshift limit pressure for that shift, or if the RPM is less than 300 RPM (in which case it is set to 100% pressure = 0% PWM).

      Note that:

      • The line pressure table is 100-PWM%, while the spare port 3 table is PWM%, so for example a value of 75% in the line pressure table would be the same as a value of 25% (100-75) in the spare port table.
      • The tables and bins for the line pressure table and the spare port 3 PWM table are independent,
      • You can switch between spare port 3's line pressure and PWM modes without affecting the PWM percent values in either. The tables, bins, and parameters will not be transferred by TunerStudio between the two when you switch modes, however
      • The period setting (=1/frequency) is shared between the line pressure and other modes, so if you change it in one mode, it will remain changed if you switch modes.

  2. PWM mode: Use the only PWM 12 or 144 element table and OFF value to set the state. This setting relies on the 'PWM active' parameter (below) to determine when the PWM state is ON or OFF. The PWM can be set to a range of values from 0% to 100% in 12 bins (and the user can select if the interpolated PWM percent varies with load, temperature, speed, or engine rpm. The user can also set a single separate OFF value for the PWM. If the user doesn't want varying PWM, and wants and ON/OFF output instead, they can simply set all the table values to 100% and the OFF value to 0% (or vice-versa).

    Spare Ports→Spare Port X PWM Setup→PWM Active (spX_active):
    In PWM mode, the user has 3 choices as to when the PWM table is used:

    1. always ON: PWM percent is always based on the 12 element table, whether shifting or not. The OFF value is not used.
    2. ON except while shifting: PWM percent is based on 12 element table, except during shifting when it is set to the user specified OFF value.
    3. ON only during shift*: PWM percent is based on 12 element table during shifting, but when not shifting the PWM percent is set to the user specified OFF value. (This is the inverse of the previous mode.)
    * = default value; X = 0,1,2

    PWM mode for Spare Port 3 is a bit different than for the other spare ports. Spare port 3 can be used in PWM mode as a alternate algorithm for the line pressure output. The PWM will be derived from spare port 3's 16x9 PWM table (not the 16x9 load × speed line pressure table), unless:

    1. Shift PWM Option is set to:
      • 'Use OFF value', then the fixed OFF valued specified for spare port 3 will be used during shifts, OR
      • 'Use shift limits', then the higher PWM value (i.e. lower pressure for a bleed valve) of the table or (100 - maximum line pressure upshift/downshift) setting will be used (see: www.msgpio.com/manuals/mshift/V5tune.html#gl)
    2. If the Spare Port 3 'Table Active' value is set to 'ON if RPM>300, else OFF' then the PWM will be set to the OFF value when the engine RPM is less than 300 (i.e. if not running or cranking). This setting can reduce current draw when not running if set to 0%, and can reduce the electrical noise associated with pulse width modulating the pressure control valve.

    Note that:

The pulse width modulation uses a table lookup for the ON state and has an OFF value as well as index options. The user can select the index value to use ('Spare Ports→Spare Port X PWM Setup→PWM Index') to interpolate the 12 element PWM% table based on the bins in the 'Spare Ports→Spare Port X PWM Index' table. The possible index values are:

  1. Load*,
  2. Speed,
  3. RPM,
  4. Temperature (only positive temperatures are allowed).
  5. Current Gear**,
  6. MAP**,
  7. TPS**,
* = default value; X = 0,1,2
** = 5.002 code and higher

The default mode for spare port 3 is line pressure mode (the only function for this output in previous codes). Note that if PWM mode is selected the defaults are:

  • TCC mode: Output is ON (PWM% from 12x1 table for spare port 1 and 2, from the 16x9 table for spare port 0 and 3) while TCC is engaged, OFF otherwise. None of the spare port TCC settings affect the main TCC output on PT3 (which has its own PWM frequency, PWM algorithm, etc.)

  • Use as Shift Solenoid: Output state is changed at some shifts based on user's output pattern. PWM% from 12x1 table for spare port 1 and 2, from the 16x9 table for spare port 0 and 3. Note that if you want to have a constant PWM% for the shift solenoid, you should enter that value in all 12/144 bins of the spare output's PWM table. As of V2.120 code Spare Port 2 becomes OUTPUT4, Spare Port 1 becomes OUTPUT7.

    This gives the possibility of eight (8) possible shift solenoid outputs (9 in the 5.xxx+ beta code), depending on the outputs potential use for other functions:

    PinNameNotesPWM
    PE4OUTPUT1Standard shift solenoid output.PWM parameters shared with OUTPUT 5 & 6 - 30.6 to 1953 Hertz
    PM2OUTPUT2Standard shift solenoid output.Has own PWM parameters - 31 to 1953 Hertz
    PT1OUTPUT3Standard shift solenoid output.Timer channel PWM
    PA0OUTPUT4aka. SP2; must set mode to "Use as Shift Solenoid" 12x1 PWM lookup table - 30.6 to 1953 Hertz
    PAD01OUTPUT5aka. SWB; only available if using voltage based manual shift leverPWM parameters shared with OUTPUT 1 & 6
    PAD03OUTPUT6aka. SWC; only available if using voltage based manual shift leverPWM parameters shared with OUTPUT 1 & 5
    PT7OUTPUT7aka. SP1; must set mode to "Use as Shift Solenoid" 12x1 PWM lookup table - 30.6 to 1953 Hertz
    PT4OUTPUT8aka. SP0/speedo output; must set mode to "Use as Shift Solenoid"; 4.1xx+ code only16x9 look-up table,
    Timer channel PWM
    PT2OUTPUT9aka. SP3/line pressure output; must set mode to "Use as Shift Solenoid"; 5.xxx+ code only16x9 look-up table,
    Timer channel PWM
  • * = default value; X = 0,1,2

    So there are 8 possible shift solenoids, and 6 possible PWM frequencies and percentages.

  • Selective Clutch: Output is ON (PWM% from 12x1 table for spare port 1 and 2, from the 16x9 table for spare port 0) while shifting AND Clutch Output1 Pattern is ON for target gear, OFF otherwise. You set the shifts to activate the spare port under 'Shift Output Patterns → Clutch Pattern'. This is similar to the PWM mode 'ON only during shift' except that the user can select which shifts are active, whereas the 'ON only during shift' is active during ALL shifts.

    As of 5.102 code, the selective clutch outputs on spare port 1 and spare port 2 can be set to engage momentarily when the TCC engages (called 'TCC follow mode'), as well as when certain up/down shifts occur. This is a useful function for some VW/Audi transmissions1. Under 'Shift Output Patterns → Clutch TCC Activation' you will find a number of settings to also activate the spare port when the TCC is engaged. There are:

    The menu is only accessible when the particular spare port has been set to selective clutch mode.

    Note that any output that is pulse width modulated must have a recirculation diode installed on the controlled device. It does not hurt to have such a diode installed on every output, even if it is ON/OFF.


    1 One such transmission is the VW/Audi 097 model transmission which uses 7 solenoid outputs. Solenoid N94 is activated during downshifts to 2nd and 3rd and upshifts to 4th (and this was handled by the 5.101 and older code using the 'selective clutch' spare port function). However, N94 is also activated whenever the TCC is initially engaged (but only in 3rd gear and only for a second or so) and this is now handled natively in the 5.102+ code.

    MegaSquirt® and MicroSquirt® and GPIO™ controllers are experimental devices intended for educational purposes.
    MegaSquirt® and MicroSquirt® and GPIO™ 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.
    © 2012, 2015 Bruce Bowling and Al Grippo. All rights reserved.