ETB live docs

This commit is contained in:
rusefi 2019-08-15 21:01:04 -04:00
parent d345369ac2
commit fe43256c91
10 changed files with 77 additions and 26 deletions

View File

@ -248,6 +248,8 @@ static void onlineApplyWorkingCopyBytes(int currentPageId, uint32_t offset, int
}
}
extern Pid etbPid;
static const void * getStructAddr(int structId) {
switch (structId) {
case LDS_CLT_INDEX:
@ -260,6 +262,11 @@ static const void * getStructAddr(int structId) {
return static_cast<wall_fuel_state*>(&engine->wallFuel);
case LDS_TRIGGER_INDEX:
return static_cast<trigger_central_s*>(&engine->triggerCentral);
#if EFI_ELECTRONIC_THROTTLE_BODY
case LDS_ETB:
return static_cast<pid_state_s*>(&etbPid);
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
default:
return NULL;
}

View File

@ -160,7 +160,7 @@ static EtbControl etb1;
extern percent_t mockPedalPosition;
static Pid pid(&engineConfiguration->etb);
Pid etbPid(&engineConfiguration->etb);
static percent_t directPwmValue = NAN;
static percent_t currentEtbDuty;
@ -181,7 +181,7 @@ class EtbController : public PeriodicTimerController {
// set debug_mode 17
if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_PID) {
#if EFI_TUNER_STUDIO
pid.postState(&tsOutputChannels);
etbPid.postState(&tsOutputChannels);
tsOutputChannels.debugIntField5 = feedForward;
#endif /* EFI_TUNER_STUDIO */
} else if (engineConfiguration->debugMode == DBG_ELECTRONIC_THROTTLE_EXTRA) {
@ -192,7 +192,7 @@ class EtbController : public PeriodicTimerController {
}
if (shouldResetPid) {
pid.reset();
etbPid.reset();
shouldResetPid = false;
}
@ -244,18 +244,38 @@ class EtbController : public PeriodicTimerController {
feedForward = interpolate2d("etbb", targetPosition, engineConfiguration->etbBiasBins, engineConfiguration->etbBiasValues);
pid.iTermMin = engineConfiguration->etb_iTermMin;
pid.iTermMax = engineConfiguration->etb_iTermMax;
etbPid.iTermMin = engineConfiguration->etb_iTermMin;
etbPid.iTermMax = engineConfiguration->etb_iTermMax;
currentEtbDuty = feedForward +
pid.getOutput(targetPosition, actualThrottlePosition);
etbPid.getOutput(targetPosition, actualThrottlePosition);
etb1.dcMotor.Set(ETB_PERCENT_TO_DUTY(currentEtbDuty));
if (engineConfiguration->isVerboseETB) {
pid.showPidStatus(&logger, "ETB");
etbPid.showPidStatus(&logger, "ETB");
}
DISPLAY_TEXT(Electrnoic_Throttle);
DISPLAY_SENSOR(TPS)
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Pedal);
DISPLAY_SENSOR(PPS);
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Output);
DISPLAY(DISPLAY_FIELD(output));
DISPLAY_TEXT(iTerm);
DISPLAY(DISPLAY_FIELD(iTerm));
DISPLAY_TEXT(eol);
DISPLAY_TEXT(Settings);
DISPLAY(DISPLAY_CONFIG(ETB_PFACTOR));
DISPLAY(DISPLAY_CONFIG(ETB_IFACTOR));
DISPLAY(DISPLAY_CONFIG(ETB_DFACTOR));
tsOutputChannels.etbTarget = targetPosition;
tsOutputChannels.etb1DutyCycle = currentEtbDuty;
// Error is positive if the throttle needs to open further
@ -302,7 +322,7 @@ static void showEthInfo(void) {
currentEtbDuty,
engineConfiguration->etbFreq);
scheduleMsg(&logger, "close dir=%s", hwPortname(CONFIGB(etb1.directionPin2)));
pid.showPidStatus(&logger, "ETB");
etbPid.showPidStatus(&logger, "ETB");
}
/**
@ -310,7 +330,7 @@ static void showEthInfo(void) {
*/
void setEtbPFactor(float value) {
engineConfiguration->etb.pFactor = value;
pid.reset();
etbPid.reset();
showEthInfo();
}
@ -318,7 +338,7 @@ static void etbReset() {
scheduleMsg(&logger, "etbReset");
etb1.dcMotor.Set(0);
pid.reset();
etbPid.reset();
mockPedalPosition = MOCK_UNDEFINED;
}
@ -328,7 +348,7 @@ static void etbReset() {
*/
void setEtbIFactor(float value) {
engineConfiguration->etb.iFactor = value;
pid.reset();
etbPid.reset();
showEthInfo();
}
@ -337,7 +357,7 @@ void setEtbIFactor(float value) {
*/
void setEtbDFactor(float value) {
engineConfiguration->etb.dFactor = value;
pid.reset();
etbPid.reset();
showEthInfo();
}
@ -346,7 +366,7 @@ void setEtbDFactor(float value) {
*/
void setEtbOffset(int value) {
engineConfiguration->etb.offset = value;
pid.reset();
etbPid.reset();
showEthInfo();
}
@ -397,7 +417,7 @@ void stopETBPins(void) {
}
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration) {
shouldResetPid = !pid.isSame(&previousConfiguration->etb);
shouldResetPid = !etbPid.isSame(&previousConfiguration->etb);
}
void startETBPins(void) {
@ -496,7 +516,7 @@ void initElectronicThrottle(void) {
addConsoleActionI("set_etbat_period", setAutoPeriod);
addConsoleActionI("set_etbat_offset", setAutoOffset);
pid.reset();
etbPid.reset();
etbController.Start();
}

View File

@ -812,6 +812,6 @@ int getRusEfiVersion(void) {
if (initBootloader() != 0)
return 123;
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
return 20190810;
return 20190815;
}
#endif /* EFI_UNIT_TEST */

View File

@ -34,6 +34,7 @@ java -DSystemOut.name=gen_config2 ^
%LIVE_DOCS_COMMAND% controllers/sensors/thermistors.cpp
%LIVE_DOCS_COMMAND% controllers/sensors/tps.cpp
%LIVE_DOCS_COMMAND% controllers/math/speed_density.cpp
%LIVE_DOCS_COMMAND% controllers/actuators/electronic_throttle.cpp
java -DSystemOut.name=gen_config2 ^
-jar ../java_tools/ConfigDefinition.jar ^

View File

@ -10,6 +10,7 @@
#include "global.h"
#include "engine_configuration_generated_structures.h"
#include "engine_state_generated.h"
#if EFI_PROD_CODE || EFI_SIMULATOR
#include "tunerstudio_configuration.h"
@ -28,7 +29,7 @@
#define MS2SEC(x) (x * 0.001)
class Pid {
class Pid : public pid_state_s {
public:
Pid();
@ -61,8 +62,6 @@ public:
#endif /* EFI_TUNER_STUDIO */
float minResult;
float maxResult;
float iTerm;
float dTerm; // we are remembering this only for debugging purposes
void showPidStatus(Logging *logging, const char*msg);
void sleep();
int resetCounter;
@ -73,10 +72,6 @@ private:
pid_s *pid;
float previousError;
// these are only used for logging
float target;
float input;
float output;
float errorAmplificationCoef;
private:

View File

@ -1,6 +1,6 @@
package com.rusefi.config.generated;
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Sat Aug 10 16:23:55 EDT 2019
// this file was generated automatically by rusEfi tool ConfigDefinition.jar based on integration\rusefi_config.txt Thu Aug 15 20:04:48 EDT 2019
// by class com.rusefi.output.JavaFieldsConsumer
import com.rusefi.config.*;
@ -873,6 +873,7 @@ public class Fields {
public static final int lcdThreadPeriodMs_offset = 720;
public static final int LDS_CLT_INDEX = 0;
public static final int LDS_ENGINE_STATE_INDEX = 3;
public static final int LDS_ETB = 7;
public static final int LDS_FUEL_TRIM_INDEX = 4;
public static final int LDS_IAT_INDEX = 1;
public static final int LDS_SPEED_DENSITY_INDEX = 2;

View File

@ -198,7 +198,7 @@ public enum Sensor {
public static Sensor find(String value) {
for (Sensor s : values())
if (s.name.equals(value))
if (s.name.equals(value) || s.name().equals(value))
return s;
throw new IllegalStateException("Sensor not found: " + value);
}

View File

@ -48,7 +48,7 @@ import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
* @see EngineSnifferPanel
*/
public class Launcher {
public static final int CONSOLE_VERSION = 20190814;
public static final int CONSOLE_VERSION = 20190815;
public static final String INPUT_FILES_PATH = "..";
private static final String TAB_INDEX = "main_tab";
protected static final String PORT_KEY = "port";

View File

@ -0,0 +1,23 @@
package com.rusefi.ldmp.generated;
import com.rusefi.ldmp.*;
public class ElectronicThrottleMeta {
public static final Request[] CONTENT = new Request[]{
new TextRequest("Electrnoic_Throttle"),
new SensorRequest("TPS"),
new TextRequest("eol"),
new TextRequest("Pedal"),
new SensorRequest("PPS"),
new TextRequest("eol"),
new TextRequest("Output"),
new FieldRequest("output"),
new TextRequest("iTerm"),
new FieldRequest("iTerm"),
new TextRequest("eol"),
new TextRequest("Settings"),
new ConfigRequest("ETB_PFACTOR"),
new ConfigRequest("ETB_IFACTOR"),
new ConfigRequest("ETB_DFACTOR"),
};
}

View File

@ -1,6 +1,7 @@
package com.rusefi.ui.livedocs;
import com.opensr5.ConfigurationImage;
import com.rusefi.FileLog;
import com.rusefi.binaryprotocol.BinaryProtocol;
import com.rusefi.config.Field;
import com.rusefi.config.generated.EngineState;
@ -186,6 +187,9 @@ public class LiveDocPanel {
liveDocs.add(createPanel("Idle", "", Fields.LDS_ENGINE_STATE_INDEX,
EngineState.VALUES, IdleThreadMeta.CONTENT), CONSTRAINTS);
liveDocs.add(createPanel("ETB", "", Fields.LDS_ETB,
EngineState.VALUES, ElectronicThrottleMeta.CONTENT), CONSTRAINTS);
return liveDocs;
}
}