Megasquirt-3 MS3 Programmable On/Off Outputs (Spare Output Ports)

Home

Introduction - Settings - Wiring - Shift Light example

Introduction

The 'Programmable On/Off Outputs' system allows for user-defined on/off type outputs such as custom shift lights by defining logical conditions to switch the output. These settings are not required when the outputs are used for other built-in features.
(e.g. do not try to configure a spare port FIDLE if you want to use FIDLE with the idle-control system. If you have configured an output to be used for two features the code will report a 'config error' and show rpms > 65000 and refuse to run - fix the mistake in your settings.)

Settings

Output Port pane
In the left hand pane, ports currently configured through this system are shown with a green bulb. To configure a port, click on the name to highlight it and then view or alter the settings in the right hand pane.

Port Settings pane

Enabled
This enables or disables the selected port. (Toggles green bulb on/off)
Do not try to configure a port already used for another feature.

Power On Value
Whether the output should be on (1) or off (0) when Megasquirt first starts. Ensure that this matches up with the output from the initial conditions.

Trigger Value
The output state when your conditions are met. On (1) or Off (0)
Typical settings would have the power on value as 0 and the trigger value as 1.

Conditions

Output channel
This is a list of Megasquirt variables - much the same as the various gauges you can select in TunerStudio.

> = <
This 'logical operator' forms part of the equation.

  • > is greater than
  • = is equals (not much use)
  • < is less than
  • And performs a bitwise AND operation. (Useful for setting outputs based on status bits.)

    Threshold
    The value compared against.

    Hysteresis
    It is very common for a value to hover around the threshold which would cause the output to turn on and off rapidly. This setting helps to prevent that by creating a dead band below the threshold before the output turns back off again.

    Additional condition

  • No additional condition - only a single condition is used
  • Or - output triggers if either condition 1 OR condition 2 is met
  • And - output triggers only when condition 1 AND condition 2 are both met

    Example 1
    The screenshot above shows a single condition suitable as a shift light. When rpm is greater then 5900 then the 'PP3 Boost' output is enabled. The hysteresis condition stops the light from flashing on/off if the rpms are 5900,5899,5900 etc. as the light will turn off only when the rpms drop below 5800 (5900-100)
    In the screenshot, no other spare ports are enabled.

    Example 2
    bitwise AND used in programmeable outputs
    The screenshot above shows a bitwise AND operation being used to set an output. When 'status3' ANDed with 128 is true (this means Launch ON) the 'PP3 Boost' output is enabled. The hysteresis condition is not used.
    Bitwise ANDs are a more technical feature. To establish what the status bits mean, delve into the ms3.ini supplied with the firmware.

    Wiring

    When utilising the MS3X card, there are a number of outputs readily used with the spare ports system. All outputs are ground-switching.
    In the following diagram you can see a valve or a relay being switched. Small indicator bulbs may also be directly connected. Do not attempt to directly connect large loads such as fans or pumps - always use a relay or a driver designed for that size of load.
    The MS3X 'PWM' outputs are internally protected against 'flyback' from relay coils.
    MS3X PWM / spare port wiring

    Without the MS3X you will likely need to DIY some circuits to use the outputs. Never directly route a raw signal from the CPU outside the Megasquirt case - always use a protective driver circuit similar to this:
    relay driver


    Shift Light Example

    One typical use of the Spare Output Ports is for a shift light. You need to pick an output that you will wire the light to and choose the rpm that you want the light to come on at.

    In this example we are using "Boost" as the output with a 5900 rpm setting.

    The settings are as above:


    MS3X shift light wiring

    If you have a question, comment, or suggestion for this FAQ please post it on the forum.

    No part of this manual may be reproduced or changed without written permission from James Murray and Ken Culver.