<< Home
EFI Analytics
Performance, Drivability & Efficiency. Simplified!
MegaLogViewer MS
MegaLogViewer MegaSquirt Edition
MegaSquirt EFI Forum Index
Quick Links:     VE Table Tuning Instructions     Change Log     Download JRE     FAQ    Download    Upgrade Registration
Buy MegaLogViewer MS Now!

Also See MegaLogViewer HD -
General Purpose supporting the most file types.
Try MegaLogViewer MS Now!

Also see MegaLogViewer BigStuff3

MegaLogViewer Formulas

MegaLogViewer uses a custom built math parser that gives the end user a great deal of power to add their own custom fields or filters. The Math Parser executes logical evaluation and equation execution. You can reference fields to be used as input to your custom calculations. Here are some samples and explanations:
Advanced Configuration
Simple Calculations
Advanced Math Functions
Logical Conditions & Expressions
In-Line Evaluation


Advanced Configuration

Most functions used are available from the drop down menu's. However, if you want to create your own custom fields MegaLogViewer.properties can be edited in any text editor. i.e. notepad or vi
Any Math functions can be added in free text, they will be interpreted at runtime.

This file allows you to alter any field by formula
Commented lines in properties files begin with a #

Max number of Graphs By default you can have up to 5 graphs. If you would like more
Edit:
numberOfGraphs=5
in the MSGraph.properties file to what ever value suites you.
The same applies to:
numberOfOverlayGraphs=2
numberOfOverlays=3

Please note that the MSGraph.properties file will be part of a upgrade and may overwrite your changes. Save them else where if you wish to re-apply them.
The user.properties file will not be over written by an upgrade.

Field Groups

Formula Groups will create checkbox selectable menu to append one of many formula options

Example: (from MSGraph.properties)
~~~~~~~~~~~snippet~~~~~~~~~~~~~~
FORMULA_GROUP_AFR=Wideband\ O2-AFR
AFR_OPTIONS=Off;Innovate\ 0-5;Innovate\ 0-2;TechEdge-DIY;AME;
AFR_SOLUTIONS=\ ;[O2]*2+10;[O2]*5+10;[O2|TechEdge-DIYwbo2.inc];[O2|aemWBo2.inc];
~~~~~~~~~~~end snippet~~~~~~~~~~~~

to visualize this better compare these 3 lines to the "Wideband O2-AFR" selections under "Calculated Fields" while running the app.
These 3 lines create the avalailable selections for Wideband O2.
FORMULA_GROUP_ used as prefix to define any formula set where
only one should be selected at a time. The section between the prefix and = will be the display name.
In this case the Menu Name is "AFR(WBO2)", to add a space to a name, you must use "\ "

_Options list the display names shown on the sub menu
Separate each display name with a semicolon ";"
_SOLUTIONS contains the formula and/or mapping file to apply, separating each option formula with a ;
for file mapping give inc file and field separated by |

[O2]*2+10 will be interpreted as AFR(WBO2)=(O2 field value) x 2 + 10
This formula will be applied if the "Innovate 0-5" option is selected.

[O2|TechEdge-DIYwbo2.inc] is interpreted as AFR(WBO2)=(O2 Field Value) lookup in TechEdge-DIYwbo2.inc file.
The closest 2 values in the inc file will be found and interpolated.

Appended Fields

Appended Fields will add a new field calculated from current record fields, past record fields, mapping files and user prompts.
Each defined APPENDED_FIELD will become a Menu Item on the "Optional Fields" Menu. You can then turn them on an off while running the app.
Prefix:APPEND_FIELD_ - any entry starting with this prefix will be identified as an Appended field.
The new field name follows imediately after the prefix.
APPEND_FIELD_VAC(inHg) - defines a new Appended Field named "VAC(inHg)"
After the = comes the formula used to create the field:
~~~~~~~~~~~~~~~~ Snippet ~~~~~~~~~~~~~~~~~~~~~~~~~~
APPEND_FIELD_VAC(inHg)={Engine off MAP pressure in KPA}-[MAP]*0.29536
~~~~~~~~~~~~~~~~ End Snippet ~~~~~~~~~~~~~~~~~~~~~~

{Engine off MAP pressure in KPA} - will prompt the user for a numeric value to replace this when they activate this field.
[MAP] - will use the current record MAP value.
The new field value will be calculated as:
VAC(inHg)=(user Input)-(MAP Value)*0.29536


Exmple 2:
~~~~~~~~~~~~~~~~ Snippet ~~~~~~~~~~~~~~~~~~~~~~~~~~
APPEND_FIELD_deltaRPM=[RPM]-[RPM-1]
~~~~~~~~~~~~~~~~ End Snippet ~~~~~~~~~~~~~~~~~~~~~~
interpreted as:
deltaRPM = (Current RPM)-(Last record RPM)

APPENDED Fields are now preffered to remapping. They will show on the menu as switchable.
Appended Fields will add a new field with the calculated value but leave the original field as found
Field re-mapping replaces the original field with the new calculated field.

MSGraph.properties remapping Rules:
Formula remappings are identified by COLUMN_FORMULA=some formula with no spaces
Name mappings are identified by COLUMN_NAME=New Name, spaces are fine.
Formulas are evaluated left to right, no hierarchy.
logVal can be anywhere in the formula, 10*logVal = logVal*10, there must be a logVal though
There shouldn't be a limit to formula length.

Example:
RPM can be different for various versions of MegaSquirt.
If your RPM's are recorded divided by 100 (3200 RPM is logged as 32)
you can correct this in the MSGraph.properties file.
This is corrected by default, so if you are seeing very high RPM's you will need to comment out this line.
1) open MSGraph.properties
2) You will see a section like this
~~~~~~~~~~~snippet~~~~~~~~~~~~~~
# Mappings use these to apply formulas to alter data
# remove for raw data. If your log file contains
# actual RPM's comment out with a #

RPM_FORMULA=logVal*100

~~~~~~~~~~end snippet~~~~~~~~~~~~~~~~
3) Comment Lines begin with # and are there for information only
4) RPM_FORMULA=logVal*100 - tells MSGraph to apply this formula to the column named RPM.
5) ^ For RPM, take the logVal, multiply by 100


These formulas can be applied for more complex scenarios also.
i.e. you can turn O2 Volts into AFR on a linear WB controller
such as Innovate, this is already in the file.

Example:

~~~~~~~~~~~~~~~snippet~~~~~~~~~~~~~~~~~~

# Innovate 0-5 WB formula
# Comment out for Volts(default)
O2_NAME=AFR
AFR_FORMULA=logVal*2+10

~~~~~~~~~~end snippet~~~~~~~~~~~~~~~~
First the column name O2 is remapped to AFR
Then the formula must be applied to the new name.

Simple calculations:
deltaRPM=[RPM]-[RPM-1]
interpreted as:
deltaRPM = (Current RPM)-(RPM 1 record back)

You can reference previous records by incuding the -x inside the []. As seen above [RPM] references the current RPM, where [RPM-1] now references the RPM 1 record previous. You can reference back further, i.e [RPM-2] will reference 2 records back, [RPM-3] is 3 back, and so on. All references are relative.
Operators:

  • +
  • -
  • /
  • *
  • ^
  • &
  • |
Math is executed from left to right, operation hierarchy is not recognized. If you need to
insure execution order parenthesis are honored.
calcValu = [RPM]/([RPM]*1.2)
the [RPM]*1.2 will be executed first.

Advanced Math functions:
Supported Advanced Math functions are:

  • sin - Math.sin
  • cos - Math.cos
  • arcsin - Math.asin
  • arccos - Math.acos
  • tan - Math.tan
  • atan - Math.atan
  • square root - Math.sqrt
  • absolute - Math.abs
  • log - Math.log
To use these Math Functions:
result = Math.func(expression)

Example:
calcVal = Math.abs([RPM]-[RPM-5])
the calcVal will alway represent the absolute value difference between the current RPM and RPM 5 records earlier.

Logical Conditions
Conditions will result in a true or false state. These can be used in several places including Custom Filters in VE Analyze.
[RPM]>2000
interpreted as:
true when RPM is greater than 2000, false if 2000 RPM or below

Any form of complex math expresion can be used on each side of the operator.
Supported comparators:

  • ==
  • !=
  • >=
  • <=
  • >
  • <
You can also use compound conditions separated by:
  • &&
  • ||
Example:
[RPM] > 2000 || [RPM] < 1000
This would return false for any RPM value from 1000 to 2000, otherwise it will return true.

In-line evaluation
In some instances you may want different calculations performed based on a condition. this can be performed with an in-line evaluation
output = {condition} ? {true expression} : {false expression}

Example:
calcVal = [RPM] > 1000 ? [RPM] : 0
this will provide RPM for anything over 1000, anything under will be 0
Naturally You can get as fancy as needed in the condition, true expression and false expression. some good examples of rather complex calculations can be found in the MSGraph.properties file for MegaLogViewer. Checkout the calculations for "Instant MPG" or HP


©2006-2020 EFI Analytics