Example of how to create a calculated PID.
The PID will calculate the angular velocity of the crank shaft. We will create two formulae: one in metric m/s and one in imperial ft/s.
Originally Posted by
Joecar
The equation is:
v = r * w
where:
r = crank radius = stroke/2
w = angular velocity = 2*pi*rpm/60
v = linear velocity at radius r
i.e. v = 2*pi*r*rpm/60
Assuming the stroke on an LS1 is 3.625 inches...
Stroke in feet is 0.30208, radius of crank is 0.15104 feet.
Stroke in meters is 0.092075 meters, radius of crank is 0.0460375 meters.
ft/s = 2*3.14159*0.15104*{SAE.RPM}/60 (where crank radius is measured in feet)
m/s = 2*3.14159*0.0460375*{SAE.RPM}/60 (where crank radius is measured in meters)
Both formulae can be simplified to:
ft/s = 0.002517*{SAE.RPM}
m/s = 0.004821*{SAE.RPM}
Calculated PIDs should be added to the calc_pids.txt file in the Configuration directory.
Usually, three entries need to be added to this file.
1. We need to add the units for ft/s and m/s.
(NOTE: common units are already defined in sae_generic.txt you do not need to add them in the calc_pids.txt file if they already exist in the sae_generic.txt configuration file.
Define the new units by adding the following entries under the *UNITS section in the calc_pids.txt file:
Code:
#Code System Abbr Description
#-------- ---------- -------- -------------------------------------------------------------
ftps Imperial ft/s "Feet per second"
mps Metric m/s "Meters per second"
- Code is the code by which we can reference the units from other entries in the configuration files.
System is one of Metric, Imperial or None and specifies to which measuring system the units belong.
Abbr is the abbreviation that will be displayed by EFILive
Description describes the units, if the description contains spaces or commas it must be enclosed in double quotes. It is usually a good idea to include the quotes anyway.
Next we need to define a SLOT.
For normal PIDs the SLOT defines Scaling, Limits, Offset and Transfer.
For calculated PIDs the SLOT defines Limits and the expression like this:
Code:
#Units Low High Fmt Expression
#------------ ------------- ------------- ---- --------------------------------------------------------------
*CLC-00-001
ftps 0.0 180.0 0.1 "0.002517*{SAE.RPM}"
mps 0.0 60.0 0.1 "0.004821*{SAE.RPM}"
The SLOT name *CLC-00-001 is made up of four segments:- * which is used in the configuration files as the "start of section" specifier. Since each SLOT is defined in it's own section, each SLOT name must begin with *.
CLC which declares the SLOT as a calculated PID SLOT.
00 which specifies the number of bits required to transmit the raw data from the PCM to EFILive. Since calculated PIDs are NOT transmitted from the PCM to EFILive this value is always 00.
001 which is a unique sequence number and may be any value between 000 and 899 inclusive. EFILive reserves 900-999 for pre-defined calculated PIDs (see sae_generic.txt for definitions of predefined calculated PIDs).
- Low and high are used to specify the "normal" range of values of the PID. These values are used by EFILive to populate the gauge and chart scales
FMT is the number of decimal places that EFILive will display. EFILive rounds the value to fit the required number of decimal places.
Expression is the formula that is evaluated by EFILive. PID names must be enclosed in curly braces. If a PID has more than one unit defined and you want to select a particular unit (metric or imperial), then append a dot and the unit's code to the PID name, inside the curly brace.
Lastly we need to add the PID itself.
Code:
#Code PRN SLOT Units System Description
#------------------------- ---- ------------ ---------------- ---------------- ------------------------------------------
CALC.CKSPEED F600 CLC-00-001 "mps,ftps" Performance "Crank speed"
- Code is the PID name that is visible in EFILive and MUST begin with CALC. for calculated PIDs.
PRN (Parameter reference number) is the internal id of the PID. It must be unique. The OBD II specification reserves PRNs from $F000 to $F6FF for scan tools. Further, EFILive reserves $F500 to $F5FF for predefined calculated PIDs. We recommend using $F600 to $F6FF for your own calculated PIDs.
SLOT is the name of the SLOt that was added previously, without the * section marker.
Units is a comma separated list of units that MUST be declared in the associated SLOT definition. Only one unit from each system is allowed. (i.e. you can't have two imperial units or two metric units).
Description describes the PID.
Note: calculated PIDs may contain other calculated PIDs. The order of evaluation of calculated PIDs becomes important. Calculated PIds are evaluated in PRN order. The calculated PID with the lowest PRN will be evaluated first.
For more information about calculated PIDs see pages 58-60 of the EFILive user manual.