output channel tweaks (#4023)

* shuffle around output channels

* postState should take a ref

* s

* s

* patch input file

* limits

* accel bad bounds check

* units

* units

* Revert "accel bad bounds check"

This reverts commit b2bb493be3.

* missed an autoscale
This commit is contained in:
Matthew Kennedy 2022-03-24 05:58:55 -07:00 committed by GitHub
parent 2ec769c66d
commit f1742c44ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 55 additions and 51 deletions

View File

@ -63,7 +63,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
uint16_t autoscale lambdaValue;@@GAUGE_NAME_LAMBDA@@;"",{1/@@PACK_MULT_LAMBDA@@}, 0, 0, 0, 0
uint8_t autoscale knockRetard;;"deg",{1/10}, 0, 0, 0, 0
uint8_t idleCurrentPosition;;"",1, 0, 0, 0, 0
uint8_t autoscale idleCurrentPosition;;"%", 0.5, 0, 0, 100, 1
uint16_t autoscale VBatt;@@GAUGE_NAME_VBAT@@;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 0, 0
@ -200,7 +200,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
int16_t autoscale rawPpsSecondary;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3
int8_t[12 iterate] autoscale knock;;"",1, 0, 0, 0, 0
int8_t[12 iterate] autoscale knock;;"dBv",1, 0, 0, 0, 0
uint8_t autoscale tcuDesiredGear;@@GAUGE_NAME_DESIRED_GEAR@@;"gear",1, 0, 0, 0, 0
uint8_t autoscale flexPercent;@@GAUGE_NAME_FLEX@@;"%",{1/2}, 0, 0, 0, 0
@ -228,7 +228,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
int16_t autoscale vvtPositionB2I;@@GAUGE_NAME_VVT_B2I@@;"deg",{1/@@PACK_MULT_ANGLE@@}, 0, 0, 0, 0
int16_t autoscale vvtPositionB2E;@@GAUGE_NAME_VVT_B2E@@;"deg",{1/@@PACK_MULT_ANGLE@@}, 0, 0, 0, 0
int16_t[2 iterate] autoscale fuelPidCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t[2 iterate] autoscale fuelPidCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, -20, 20, 2
int16_t autoscale rawTps1Secondary;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3
int16_t autoscale rawTps2Primary;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3
@ -237,18 +237,18 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
uint16_t knockCount;"knock: count";"",1, 0, 0, 0, 0
int16_t autoscale accelerationZ;@@GAUGE_NAME_ACCEL_Z@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationRoll;@@GAUGE_NAME_ACCEL_ROLL@@;"",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationYaw;@@GAUGE_NAME_ACCEL_YAW@@;"",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationRoll;@@GAUGE_NAME_ACCEL_ROLL@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale accelerationYaw;@@GAUGE_NAME_ACCEL_YAW@@;"G",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int8_t[4 iterate] autoscale vvtTargets;;"deg",1, 0, 0, 0, 0
uint16_t turboSpeed;@@GAUGE_NAME_TURBO_SPEED@@;"hz",1, 0, 0, 0, 0
struct pid_status_s
float iTerm;;"", 1, 0, -10000, 10000, 3
float dTerm;;"", 1, 0, -10000, 10000, 3
float output;;"", 1, 0, -10000, 10000, 3
float error;;"", 1, 0, -10000, 10000, 3
int resetCounter;;"", 1, 0, -10000, 10000, 0
int16_t autoscale iTerm;;"", 0.01, 0, -327, 327, 2
int16_t autoscale dTerm;;"", 0.01, 0, -327, 327, 2
int16_t autoscale output;;"", 0.01, 0, -327, 327, 2
int16_t autoscale error;;"", 0.01, 0, -327, 327, 2
uint32_t resetCounter;;"", 1, 0, 0, 10000, 0
end_struct
uint16_t[2 iterate] wbTemperature;;"deg C", 1, 0, 0, 1000, 0
@ -260,7 +260,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
int16_t autoscale accPedalSplit;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
int16_t autoscale m_requested_pump;"DI: Pump Angle";"deg",{1/@@PACK_MULT_ANGLE@@}, 0, 0, 0, 0
int16_t autoscale boostControlTarget;"Pump Angle";"deg",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0
int16_t autoscale boostControlTarget;@@GAUGE_NAME_BOOST_TARGET@@;"kPa",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0
int8_t autoscale sparkCutReason;"Spark Cut Code";"code",1, 0, 0, 0, 0
int8_t autoscale fuelCutReason;"Fuel Cut Code";"code",1, 0, 0, 0, 0
float fuel_requested_percent;"DI: fuel_requested_percent";"v", 1, 0, 0, 100, 0
@ -288,7 +288,7 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
int luaInvocationCounter;;"count",1, 0, 0, 0, 0
int luaLastCycleDuration;;"nt",1, 0, 0, 0, 0
uint8_t testBenchIter;;"count",1, 0, 0, 0, 0
uint8_t[75 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
uint8_t[15 iterate] unusedInTheMiddle;;"",1, 0, 0, 0, 0
int16_t autoscale auxLinear1;@@GAUGE_NAME_AUX_LINEAR_1@@;"", 0.01, 0, 0, 0, 0
int16_t autoscale auxLinear2;@@GAUGE_NAME_AUX_LINEAR_2@@;"", 0.01, 0, 0, 0, 0
@ -304,9 +304,9 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
bit tpsAccelActive
uint8_t TEMPLOG_MAP_AT_CYCLE_COUNT;;"", 1, 0, -10000, 10000, 3
uint8_t boostControllerOutput;;"", 1, 0, -10000, 10000, 0
uint8_t boostControllerClosedLoopPart;;"", 1, 0, -10000, 10000, 0
uint8_t boostControllerOpenLoopPart;;"", 1, 0, -10000, 10000, 0
uint8_t TEMPLOG_map_peak;;"", 1, 0, -10000, 10000, 3
uint8_t autoscale boostControllerOutput;@@GAUGE_NAME_BOOST_OUTPUT@@;"%", 0.5, 0, 0, 100, 1
uint8_t autoscale boostControllerOpenLoopPart;@@GAUGE_NAME_BOOST_OPEN_LOOP@@;"%", 0.5, 0, 0, 100, 1
float autoscale TEMPLOG_MAP_AT_SPECIAL_POINT;;"", 1, 0, -10000, 10000, 3
float autoscale TEMPLOG_MAP_AT_DIFF;;"", 1, 0, -10000, 10000, 3
@ -321,19 +321,15 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
uint8_t vvtSyncCounter;;"", 1, 0, -10000, 10000, 3
uint8_t vvtStateIndex;;"", 1, 0, -10000, 10000, 3
uint16_t autoscale fallbackMap;;"kPa", 0.1, 0, 0, 1000, 1
float autoscale TEMPLOG_MAP_INSTANT_AVERAGE;;"", 1, 0, -10000, 10000, 3
int8_t autoscale boostControllerClosedLoopPart;@@GAUGE_NAME_BOOST_CLOSED_LOOP@@;"%", 0.5, 0, -50, 50, 1
uint8_t unused503;;"", 1, 0, 0, 0, 0
uint8_t fallbackMap;;"", 1, 0, -10000, 10000, 3
uint8_t TEMPLOG_map_peak;;"", 1, 0, -10000, 10000, 3
uint8_t TEMPLOG_map_length;;"", 1, 0, -10000, 10000, 3
uint8_t TEMPLOG_mapIndex;;"", 1, 0, -10000, 10000, 3
uint16_t autoscale timingCltCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
uint16_t autoscale timingIatCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
uint16_t autoscale timingPidCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, 0, 0, 0
uint16_t autoscale instantMAPValue;Instant MAP;"kPa",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 0, 0
int16_t autoscale timingCltCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, -20, 20, 2
int16_t autoscale timingIatCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, -20, 20, 2
int16_t autoscale timingPidCorrection;;"%",{1/@@PACK_MULT_PERCENT@@}, 0, -20, 20, 2
uint16_t autoscale instantMAPValue;Instant MAP;"kPa",{1/@@PACK_MULT_PRESSURE@@}, 0, 0, 655, 2
uint16_t mostRecentTimeBetweenSparkEvents;;"", 1, 0, -10000, 10000, 3
uint16_t mostRecentTimeBetweenIgnitionEvents;;"", 1, 0, -10000, 10000, 3
@ -341,7 +337,6 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
uint16_t maxLockedDuration;;"", 1, 0, -10000, 10000, 3
uint16_t maxTriggerReentrant;;"", 1, 0, -10000, 10000, 3
uint16_t canWriteOk;;"", 1, 0, -10000, 10000, 3
uint16_t canWriteNotOk;;"", 1, 0, -10000, 10000, 3
@ -361,14 +356,16 @@ uint16_t rpmAcceleration;dRPM;"RPM/s",1, 0, 0, 0, 0
int idleState;;"", 1, 0, -10000, 10000, 3
float injectorFlowPressureRatio;;"", 1, 0, -10000, 10000, 3
float injectorFlowPressureDelta;;"", 1, 0, -10000, 10000, 3
float injectorFlowPressureDelta;;"kPa", 1, 0, -10000, 10000, 1
float etbFeedForward;;"", 1, 0, -10000, 10000, 3
float etbFeedForward;;"%", 1, 0, -10000, 10000, 3
float etbIntegralError;;"", 1, 0, -10000, 10000, 3
float etbCurrentTarget;;"", 1, 0, -10000, 10000, 3
float etbCurrentTarget;;"%", 1, 0, -10000, 10000, 3
pid_status_s alternatorStatus
pid_status_s idleStatus
pid_status_s etbStatus
pid_status_s boostStatus
uint8_t[76 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
end_struct

View File

@ -103,4 +103,8 @@ static constexpr LogField fields[] = {
{engine->outputChannels.fuelCutReason, "Fuel Cut Code", "", 0},
{engine->outputChannels.auxLinear1, GAUGE_NAME_AUX_LINEAR_1, "", 2},
{engine->outputChannels.auxLinear2, GAUGE_NAME_AUX_LINEAR_2, "", 2},
{engine->outputChannels.boostControllerOutput, GAUGE_NAME_BOOST_OUTPUT, "%", 1},
{engine->outputChannels.boostControllerClosedLoopPart, GAUGE_NAME_BOOST_CLOSED_LOOP, "%", 1},
{engine->outputChannels.boostControllerOpenLoopPart, GAUGE_NAME_BOOST_OPEN_LOOP, "%", 1},
{engine->outputChannels.boostControlTarget, GAUGE_NAME_BOOST_TARGET, "kPa", 1},
};

View File

@ -46,7 +46,7 @@ void AlternatorController::onFastCallback() {
// this block could be executed even in on/off alternator control mode
// but at least we would reflect latest state
#if EFI_TUNER_STUDIO
alternatorPid.postState(&engine->outputChannels.alternatorStatus);
alternatorPid.postState(engine->outputChannels.alternatorStatus);
#endif /* EFI_TUNER_STUDIO */
bool alternatorShouldBeEnabledAtCurrentRpm = Sensor::getOrZero(SensorType::Rpm) > engineConfiguration->cranking.rpm;

View File

@ -111,23 +111,23 @@ percent_t BoostController::getClosedLoopImpl(float target, float manifoldPressur
if (isBelowClosedLoopThreshold) {
// We're below the CL threshold, inhibit CL for now
m_pid.reset();
closedLoopPart = 0;
return closedLoopPart;
return 0;
}
closedLoopPart = m_pid.getOutput(target, manifoldPressure, SLOW_CALLBACK_PERIOD_MS / 1000.0f);
engine->outputChannels.boostControllerClosedLoopPart = closedLoopPart;
return closedLoopPart;
return m_pid.getOutput(target, manifoldPressure, SLOW_CALLBACK_PERIOD_MS / 1000.0f);
}
expected<percent_t> BoostController::getClosedLoop(float target, float manifoldPressure) {
auto closedLoop = getClosedLoopImpl(target, manifoldPressure);
closedLoopPart = getClosedLoopImpl(target, manifoldPressure);
engine->outputChannels.boostControllerClosedLoopPart = closedLoopPart;
m_pid.postState(engine->outputChannels.boostStatus);
#if EFI_TUNER_STUDIO
engine->outputChannels.boostControlTarget = target;
#endif /* EFI_TUNER_STUDIO */
return closedLoop;
return closedLoopPart;
}
void BoostController::setOutput(expected<float> output) {

View File

@ -543,7 +543,7 @@ void EtbController::update() {
#if EFI_TUNER_STUDIO
// Only debug throttle #1
if (m_function == ETB_Throttle1) {
m_pid.postState(&engine->outputChannels.etbStatus);
m_pid.postState(engine->outputChannels.etbStatus);
engine->outputChannels.etbFeedForward = engine->engineState.etbFeedForward;
engine->outputChannels.etbStatus.output = directPwmValue;
}

View File

@ -344,7 +344,7 @@ float IdleController::getIdlePosition() {
if (engineConfiguration->idleMode == IM_AUTO) {
// see also tsOutputChannels->idlePosition
getIdlePid()->postState(&engine->outputChannels.idleStatus);
getIdlePid()->postState(engine->outputChannels.idleStatus);
engine->outputChannels.idleState = idleState;
} else {
engine->outputChannels.idleCurrentPosition = iacPosition;

View File

@ -76,7 +76,7 @@ expected<percent_t> VvtController::getClosedLoop(angle_t target, angle_t observa
}
#if EFI_TUNER_STUDIO
static debug_mode_e debugModeByIndex[4] = {DBG_VVT_1_PID, DBG_VVT_2_PID, DBG_VVT_3_PID, DBG_VVT_4_PID};
static constexpr const debug_mode_e debugModeByIndex[4] = {DBG_VVT_1_PID, DBG_VVT_2_PID, DBG_VVT_3_PID, DBG_VVT_4_PID};
if (engineConfiguration->debugMode == debugModeByIndex[index]) {
m_pid.postState(&engine->outputChannels);

View File

@ -15,8 +15,8 @@ enum class ClearReason : uint8_t {
StopRequested, // 7
EtbProblem, // 8
LaunchCut, // 9
InjectorDutyCycle,
FloodClear,
InjectorDutyCycle, // 10
FloodClear, // 11
};
// Only allows clearing the value, but never resetting it.

View File

@ -1735,6 +1735,10 @@ end_struct
#define GAUGE_NAME_AUX_LINEAR_1 "Aux Linear 1"
#define GAUGE_NAME_AUX_LINEAR_2 "Aux Linear 2"
#define GAUGE_NAME_BOOST_OUTPUT "Boost Output"
#define GAUGE_NAME_BOOST_CLOSED_LOOP "Boost Closed Loop"
#define GAUGE_NAME_BOOST_OPEN_LOOP "Boost Open Loop"
#define GAUGE_NAME_BOOST_TARGET "Boost Target"
#define INDICATOR_NAME_CLUTCH_UP "clutch: up"
#define INDICATOR_NAME_CLUTCH_DOWN "clutch: down"

View File

@ -1009,7 +1009,6 @@ canWriteOkGauge = canWriteOk,"canWriteOk", "", -10000.0,10000.0, -10000.0,10000.
canWriteNotOkGauge = canWriteNotOk,"canWriteNotOk", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
gaugeCategory = MAP Cam
TEMPLOG_MAP_INSTANT_AVERAGEGauge = TEMPLOG_MAP_INSTANT_AVERAGE,"TEMPLOG_MAP_INSTANT_AVERAGE", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
TEMPLOG_map_peakGauge = TEMPLOG_map_peak,"TEMPLOG_map_peak", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
TEMPLOG_MAP_AT_SPECIAL_POINTGauge = TEMPLOG_MAP_AT_SPECIAL_POINT,"TEMPLOG_MAP_AT_SPECIAL_POINT", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
TEMPLOG_MAP_AT_DIFFGauge = TEMPLOG_MAP_AT_DIFF,"TEMPLOG_MAP_AT_DIFF", "", -10000.0,10000.0, -10000.0,10000.0, -10000.0,10000.0, 3,3
@ -1277,7 +1276,7 @@ gaugeCategory = DynoView
indicator = { isFanOn }, "fan off", "fan on", white, black, green, black
indicator = { isFan2On }, "fan 2 off", "fan 2 on", white, black, green, black
indicator = { isMainRelayOn }, "main relay off", "main relay on", white, black, green, black
indicator = { isCylinderCleanupActivated}, "no cyl cleanup", "cyl cleanup", white, black, yellow, black
indicator = { fuelCutReason == 11 }, "no cyl cleanup", "cyl cleanup", white, black, yellow, black
indicator = { isFuelPumpOn}, "pump off", "pump on", white, black, green, black
indicator = { clutchUpState }, "Clutch Up", "clutch Up", white, black, red, black
indicator = { clutchDownState }, "Clutch Down", "Clutch Down", white, black, yellow, black

View File

@ -135,11 +135,11 @@ void Pid::postState(TunerStudioOutputChannels *tsOutputChannels) const {
postState(tsOutputChannels, 1);
}
void Pid::postState(pid_status_s *pidStatus) const {
pidStatus->output = output;
pidStatus->error = getPrevError();
pidStatus->iTerm = iTerm;
pidStatus->dTerm = dTerm;
void Pid::postState(pid_status_s& pidStatus) const {
pidStatus.output = output;
pidStatus.error = getPrevError();
pidStatus.iTerm = iTerm;
pidStatus.dTerm = dTerm;
}
/**

View File

@ -58,7 +58,7 @@ public:
float getPrevError(void) const;
void setErrorAmplification(float coef);
#if EFI_TUNER_STUDIO
void postState(pid_status_s *pidStatus) const;
void postState(pid_status_s& pidStatus) const;
void postState(TunerStudioOutputChannels *tsOutputChannels) const;
void postState(TunerStudioOutputChannels *tsOutputChannels, int pMult) const;
#endif /* EFI_TUNER_STUDIO */