auto-sync

This commit is contained in:
rusEfi 2017-01-22 17:03:31 -05:00
parent 92e2b13300
commit ef496916f9
15 changed files with 43 additions and 11 deletions

View File

@ -149,7 +149,8 @@ typedef struct {
float debugFloatField6; // 256
float debugFloatField7; // 260
int firmwareVersion; // 264
int unused3[22];
float fuelPidCorrection; // 268
int unused3[21];
} TunerStudioOutputChannels;
#endif /* TUNERSTUDIO_CONFIGURATION_H_ */

View File

@ -245,6 +245,7 @@ static void printSensors(Logging *log, bool fileFormat) {
reportSensorF(log, fileFormat, "f: actual", "ms", ENGINE(actualLastInjection), 2);
reportSensorF(log, fileFormat, "f: lag", "ms", engine->engineState.injectorLag, 2);
reportSensorF(log, fileFormat, "f: running", "ms", ENGINE(engineState.runningFuel), 2);
reportSensorF(log, fileFormat, "f: pid", "ms", ENGINE(engineState.fuelPidCorrection), 2);
reportSensorF(log, fileFormat, "f: wall amt", "v", ENGINE(wallFuel).getWallFuel(0), 2);
reportSensorF(log, fileFormat, "f: wall crr", "v", ENGINE(wallFuelCorrection), 2);
@ -690,6 +691,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->injectorDutyCycle = getInjectorDutyCycle(rpm PASS_ENGINE_PARAMETER);
tsOutputChannels->fuelRunning = ENGINE(engineState.runningFuel);
tsOutputChannels->fuelPidCorrection = ENGINE(engineState.fuelPidCorrection);
tsOutputChannels->injectorLagMs = ENGINE(engineState.injectorLag);
tsOutputChannels->fuelBase = engine->engineState.baseFuel;
tsOutputChannels->actualLastInjection = ENGINE(actualLastInjection);

View File

@ -76,7 +76,7 @@ static msg_t auxPidThread(int param) {
float value = engine->triggerCentral.vvtPosition; // getVBatt(PASS_ENGINE_PARAMETER_F); // that's temporary
float targetValue = fsioTable1.getValue(rpm, getEngineLoadT(PASS_ENGINE_PARAMETER_F));
float pwm = auxPid.getValue(targetValue, value, 1);
float pwm = auxPid.getValue(targetValue, value);
if (engineConfiguration->isVerboseAuxPid1) {
scheduleMsg(logger, "aux duty: %f/value=%f/p=%f/i=%f/d=%f int=%f", pwm, value,
auxPid.getP(), auxPid.getI(), auxPid.getD(), auxPid.getIntegration());

View File

@ -170,6 +170,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
sparkDwell = getSparkDwell(rpm PASS_ENGINE_PARAMETER);
dwellAngle = sparkDwell / getOneDegreeTimeMs(rpm);
currentAfr = getAfr(PASS_ENGINE_PARAMETER_F);
// todo: move this into slow callback, no reason for IAT corr to be here
iatFuelCorrection = getIatCorrection(iat PASS_ENGINE_PARAMETER);
@ -179,7 +180,7 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_F) {
cltFuelCorrection = 1;
warmupAfrPid.reset();
} else {
cltFuelCorrection = warmupAfrPid.getValue(warmupTargetAfr, getAfr(PASS_ENGINE_PARAMETER_F), 1);
cltFuelCorrection = warmupAfrPid.getValue(warmupTargetAfr, currentAfr, 1);
}
#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
if (engineConfiguration->debugMode == WARMUP_ENRICH) {

View File

@ -148,6 +148,8 @@ public:
float currentVE;
float targetAFR;
float currentAfr;
/**
* pre-calculated value from simple fuel lookup
*/
@ -157,6 +159,11 @@ public:
*/
floatms_t baseFuel;
/**
* closed-loop fuel correction
*/
floatms_t fuelPidCorrection;
/**
* Total fuel with CLT, IAT and TPS acceleration corrections per cycle,
* as squirt duration.

View File

@ -141,7 +141,7 @@ floatms_t getRunningFuel(floatms_t baseFuel, int rpm DECLARE_ENGINE_PARAMETER_S)
float iatCorrection = ENGINE(engineState.iatFuelCorrection);
float cltCorrection = ENGINE(engineState.cltFuelCorrection);
ENGINE(engineState.runningFuel) = baseFuel * iatCorrection * cltCorrection;
ENGINE(engineState.runningFuel) = baseFuel * iatCorrection * cltCorrection + ENGINE(engineState.fuelPidCorrection);
return ENGINE(engineState.runningFuel);
}

View File

@ -85,7 +85,7 @@ static msg_t AltCtrlThread(int param) {
}
currentAltDuty = altPid.getValue(targetVoltage, vBatt, 1);
currentAltDuty = altPid.getValue(targetVoltage, vBatt);
if (boardConfiguration->isVerboseAlternator) {
scheduleMsg(logger, "alt duty: %f/vbatt=%f/p=%f/i=%f/d=%f int=%f", currentAltDuty, vBatt,
altPid.getP(), altPid.getI(), altPid.getD(), altPid.getIntegration());

View File

@ -69,7 +69,7 @@ static msg_t etbThread(void *arg) {
percent_t pedal = getPedalPosition(PASS_ENGINE_PARAMETER_F);
percent_t tps = getTPS();
currentEtbDuty = pid.getValue(pedal, getTPS(), 1);
currentEtbDuty = pid.getValue(pedal, getTPS());
etbPwmUp.setSimplePwmDutyCycle(currentEtbDuty / 100);

View File

@ -32,6 +32,10 @@ bool Pid::isSame(pid_s *pid) {
this->pid->offset == pid->offset && this->pid->pFactor == pid->pFactor;
}
float Pid::getValue(float target, float input) {
return getValue(target, input, 1);
}
float Pid::getValue(float target, float input, float dTime) {
float error = target - input;

View File

@ -22,6 +22,7 @@ public:
void init(pid_s *pid, float minResult, float maxResult);
bool isSame(pid_s *pid);
float getValue(float target, float input);
float getValue(float target, float input, float dTime);
void updateFactors(float pFactor, float iFactor, float dFactor);
void reset(void);

View File

@ -13,7 +13,7 @@ bool hasAfrSensor(DECLARE_ENGINE_PARAMETER_F) {
}
float getAfr(DECLARE_ENGINE_PARAMETER_F) {
afr_sensor_s * sensor = &engineConfiguration->afr;
afr_sensor_s * sensor = &CONFIG(afr);
float volts = getVoltageDivided("ego", sensor->hwChannel);

View File

@ -70,6 +70,7 @@ static Logging *logger;
#if ! EFI_UNIT_TEST
static pid_s *fuelPidS = &persistentState.persistentConfiguration.engineConfiguration.fuelClosedLoopPid;
static Pid fuelPid(fuelPidS, -100, 100);
extern TunerStudioOutputChannels tsOutputChannels;
#endif
// todo: figure out if this even helps?
@ -381,6 +382,14 @@ static void fuelClosedLoopCorrection(DECLARE_ENGINE_PARAMETER_F) {
return;
}
#if ! EFI_UNIT_TEST
engine->engineState.fuelPidCorrection = fuelPid.getValue(ENGINE(engineState.targetAFR), ENGINE(engineState.currentAfr), 1);
if (engineConfiguration->debugMode == DBG_FUEL_PID_CORRECTION) {
tsOutputChannels.debugFloatField1 = engine->engineState.fuelPidCorrection;
fuelPid.postState(&tsOutputChannels);
}
#endif
}
@ -513,9 +522,6 @@ void mainTriggerCallback(trigger_event_e ckpSignalType, uint32_t trgEventIndex D
if (CONFIG(fuelClosedLoopCorrectionEnabled)) {
fuelClosedLoopCorrection(PASS_ENGINE_PARAMETER_F);
}
}
efiAssertVoid(!CONFIG(useOnlyRisingEdgeForTrigger) || CONFIG(ignMathCalculateAtIndex) % 2 == 0, "invalid ignMathCalculateAtIndex");

View File

@ -42,7 +42,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jan 22 15:35:11 EST 2017
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Jan 22 16:15:28 EST 2017
pageSize = 16376
page = 1
@ -915,6 +915,7 @@ fileVersion = { 20161225 }
debugFloatField6 = scalar, F32, 256, "val", 1, 0.0;
debugFloatField7 = scalar, F32, 260, "val", 1, 0.0;
firmwareVersion = scalar,U32, 264, "version_f", 1, 0
fuelPidCorrection = scalar, F32, 268, "ms", 1, 0
egoCorrection = { 100 }
time = { timeNow }
@ -1189,6 +1190,8 @@ fileVersion = { 20161225 }
pulseWidthGauge = pulseWidth, "fuel final squirt, per injection", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
baseFuelGauge = baseFuel, "fuel: base duration, before corr", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
fuelPidCorrectionGauge = fuelPidCorrection, "fuel: closed loop correction", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
crankingFuelGauge = crankingFuel, "fuel: crank Width", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
iatCorrectionGauge = iatCorrection, "fuel: IAT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2
cltCorrectionGauge = cltCorrection, "fuel: CLT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2
@ -1292,6 +1295,7 @@ fileVersion = { 20161225 }
entry = pulseWidth, "fuel: pulse", float, "%.3f"
entry = baseFuel, "fuel: base", float, "%.2f"
entry = fuelPidCorrection,"fuel: pid", float, "%.2f"
entry = veValue, "fuel: VE", float, "%.3f"
entry = injectorDutyCycle,"fuel: duty cyc",float,"%.3f"

View File

@ -852,6 +852,7 @@ fileVersion = { 20161225 }
debugFloatField6 = scalar, F32, 256, "val", 1, 0.0;
debugFloatField7 = scalar, F32, 260, "val", 1, 0.0;
firmwareVersion = scalar,U32, 264, "version_f", 1, 0
fuelPidCorrection = scalar, F32, 268, "ms", 1, 0
egoCorrection = { 100 }
time = { timeNow }
@ -1126,6 +1127,8 @@ fileVersion = { 20161225 }
pulseWidthGauge = pulseWidth, "fuel final squirt, per injection", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
baseFuelGauge = baseFuel, "fuel: base duration, before corr", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
fuelPidCorrectionGauge = fuelPidCorrection, "fuel: closed loop correction", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
crankingFuelGauge = crankingFuel, "fuel: crank Width", "mSec", 0, 25.5, 1.0, 1.2, 20, 25, 3, 1
iatCorrectionGauge = iatCorrection, "fuel: IAT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2
cltCorrectionGauge = cltCorrection, "fuel: CLT correction", "mult", 0, 3, 0, 0, 3, 3, 2, 2
@ -1229,6 +1232,7 @@ fileVersion = { 20161225 }
entry = pulseWidth, "fuel: pulse", float, "%.3f"
entry = baseFuel, "fuel: base", float, "%.2f"
entry = fuelPidCorrection,"fuel: pid", float, "%.2f"
entry = veValue, "fuel: VE", float, "%.3f"
entry = injectorDutyCycle,"fuel: duty cyc",float,"%.3f"

View File

@ -37,6 +37,7 @@
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/ext_algo/nmea&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/ext_algo&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/math&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/sensors&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/algo&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/trigger&quot;"/>
@ -58,6 +59,7 @@
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/engines&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/ext_algo/nmea&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/ext_algo&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/math&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/sensors&quot;"/>
<listOptionValue builtIn="false" value="&quot;/cygdrive/c/stuff/rusefi_sourceforge/unit_tests/controllers/algo&quot;"/>