log afr in addition to lambda (#1920)

* log afr

* log it

* weird double commas
This commit is contained in:
Matthew Kennedy 2020-10-31 14:52:07 -07:00 committed by GitHub
parent dd8d10366f
commit 15d5c872c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 6 deletions

View File

@ -257,8 +257,9 @@ typedef struct {
scaled_high_pressure highFuelPressure; // 278
scaled_lambda targetLambda; // 280
scaled_afr airFuelRatio; // 282
uint8_t unusedAtTheEnd[6]; // we have some unused bytes to allow compatible TS changes
uint8_t unusedAtTheEnd[4]; // we have some unused bytes to allow compatible TS changes
// Temporary - will remove soon
TsDebugChannels* getDebugChannels() {

View File

@ -30,6 +30,7 @@ static const LogField fields[] = {
{tsOutputChannels.throttle2Position, GAUGE_NAME_TPS2, "%", 2},
{tsOutputChannels.pedalPosition, GAUGE_NAME_THROTTLE_PEDAL, "%", 2},
{tsOutputChannels.manifoldAirPressure, GAUGE_NAME_MAP, "kPa", 1},
{tsOutputChannels.airFuelRatio, GAUGE_NAME_AFR, "afr", 2},
{tsOutputChannels.lambda, GAUGE_NAME_LAMBDA, "", 3},
{tsOutputChannels.vBatt, GAUGE_NAME_VBAT, "v", 2},
{tsOutputChannels.oilPressure, GAUGE_NAME_OIL_PRESSURE, GAUGE_NAME_FUEL_PRESSURE_HIGH_UNITS, 0},

View File

@ -526,7 +526,9 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
// offset 20
tsOutputChannels->lambda = Sensor::get(SensorType::Lambda).value_or(0);
float lambdaValue = Sensor::get(SensorType::Lambda).value_or(0);
tsOutputChannels->lambda = lambdaValue;
tsOutputChannels->airFuelRatio = lambdaValue * ENGINE(engineState.stoichiometricRatio);
// offset 24
tsOutputChannels->engineLoad = getEngineLoadT(PASS_ENGINE_PARAMETER_SIGNATURE);

View File

@ -81,4 +81,5 @@ public:
multispark_state multispark;
float targetLambda = 0.0f;
float stoichiometricRatio = 0.0f;
};

View File

@ -13,6 +13,7 @@ mass_t FuelComputerBase::getCycleFuel(mass_t airmass, int rpm, float load) const
ENGINE(engineState.currentAfrLoad) = load;
ENGINE(engineState.targetLambda) = lambda;
ENGINE(engineState.targetAFR) = afr;
ENGINE(engineState.stoichiometricRatio) = stoich;
return airmass / afr;
}

View File

@ -1621,6 +1621,7 @@ end_struct
#define GAUGE_NAME_TCHARGE "fuel: SD tCharge"
#define GAUGE_NAME_TARGET_AFR "fuel: target AFR"
#define GAUGE_NAME_TARGET_LAMBDA "fuel: target lambda"
#define GAUGE_NAME_AFR "Air/Fuel Ratio"
#define GAUGE_NAME_LAMBDA "Lambda"
#define GAUGE_NAME_IAC "Idle Air Valve"

View File

@ -210,15 +210,15 @@ enable2ndByteCanID = false
tpsADC = scalar, U16, 24, "ADC", 1, 0.0;
; air flow/mass measurments
MAFValue = scalar, U16, 26, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0
MAFValue = scalar, U16, 26, "V",{1/@@PACK_MULT_VOLTAGE@@}, 0
massAirFlowValue= scalar, U16, 28, "Kg/h", {1/@@PACK_MULT_MASS_FLOW@@}, 0
MAPValue = scalar, U16, 30, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0
baroPressure = scalar, U16, 32, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0
lambdaValue = scalar, U16, 34, "",,{1/@@PACK_MULT_LAMBDA@@},, 0.0
lambdaValue = scalar, U16, 34, "",{1/@@PACK_MULT_LAMBDA@@}, 0.0
engineLoad = scalar, U16, 36, "%",{1/@@PACK_MULT_PERCENT@@}, 0.0 ; Blend of MAP and TPS, depends on algorithm
; misc sensors
VBatt = scalar, U16, 38, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0.0
VBatt = scalar, U16, 38, "V",{1/@@PACK_MULT_VOLTAGE@@}, 0.0
oilPressure = scalar, U16, 40, "kPa",{1/@@PACK_MULT_PRESSURE@@}, 0.0
vvtPosition = scalar, U16, 42, "deg",{1/@@PACK_MULT_ANGLE@@}, 0
@ -228,7 +228,7 @@ enable2ndByteCanID = false
; fuel math
chargeAirMass = scalar, U16, 44, "g",0.001, 0
crankingFuelMs = scalar, U16, 46, "mg",{1/@@PACK_MULT_FUEL_MASS@@}, 0.0
currentTargetAfr= scalar, U16, 48, "ratio",,{1/@@PACK_MULT_AFR@@},, 0
currentTargetAfr= scalar, U16, 48, "ratio",{1/@@PACK_MULT_AFR@@}, 0
baseFuel = scalar, U16, 50, "mg",{1/@@PACK_MULT_FUEL_MASS@@}, 0
fuelRunning = scalar, U16, 52, "mg",{1/@@PACK_MULT_FUEL_MASS@@}, 0
actualLastInjection=scalar,U16, 54, "ms",{1/@@PACK_MULT_MS@@}, 0.0
@ -370,6 +370,7 @@ enable2ndByteCanID = false
lowFuelPressure = scalar, S16, 276, "kpa", {1/@@PACK_MULT_PRESSURE@@}, 0
highFuelPressure = scalar, S16, 278, "bar", {1/@@PACK_MULT_HIGH_PRESSURE@@}, 0
targetLambda = scalar, U16, 280, "",{1/@@PACK_MULT_LAMBDA@@}, 0.0
AFRValue = scalar, U16, 282, "AFR",{1/@@PACK_MULT_AFR@@}, 0.0
;
; see TunerStudioOutputChannels struct
@ -939,6 +940,7 @@ gaugeCategory = Sensors - Basic
RPMGauge = RPMValue, "RPM - engine speed", "RPM", 0, 15000, 200, 500, 6000, 6000, 0, 0
CLTGauge = coolant, "Coolant temp", "deg C", -40, 140, -15, 1, 95, 110, 1, 1
IATGauge = intake, "Intake air temp", "deg C", -40, 140, -15, 1, 95, 110, 1, 1
afr1Gauge = AFRValue, "Air fuel ratio", "", 10, 19.4, 12, 13, 15, 16, 2, 2
lambda1Gauge = lambdaValue, "Lambda", "", 0.65, 1.2, 0.7, 0.75, 1.1, 1.15, 3, 2
MAFGauge = MAFValue, "Mass air flow", "v", 0, 5, 0, 1, 3, 4, 1, 1
VBattGauge = VBatt, "Battery voltage", "V", 8, 21, 9, 10, 17, 19, 1, 1
@ -1130,6 +1132,7 @@ gaugeCategory = Knock
entry = TPS2Value, @@GAUGE_NAME_TPS2@@, float, "%.2f"
entry = MAFValue, @@GAUGE_NAME_MAF@@, float, "%.2f"
entry = MAPValue, @@GAUGE_NAME_MAP@@, float, "%.1f"
entry = AFRValue, @@GAUGE_NAME_AFR@@, float, "%.2f"
entry = lambdaValue, @@GAUGE_NAME_LAMBDA@@, float, "%.2f"
entry = VBatt, @@GAUGE_NAME_VBAT@@, float, "%.2f"
entry = engineLoad, @@GAUGE_NAME_ENGINE_LOAD@@, float, "%.1f"