ETB auto-tune
This commit is contained in:
parent
8fdc48be40
commit
3e7adb5ea6
|
@ -59,9 +59,12 @@
|
||||||
#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
|
#if EFI_ELECTRONIC_THROTTLE_BODY || defined(__DOXYGEN__)
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "pwm_generator.h"
|
#include "pwm_generator.h"
|
||||||
|
#include "pid_auto_tune.h"
|
||||||
extern TunerStudioOutputChannels tsOutputChannels;
|
extern TunerStudioOutputChannels tsOutputChannels;
|
||||||
static bool shouldResetPid = false;
|
static bool shouldResetPid = false;
|
||||||
|
|
||||||
|
static PID_AutoTune autoTune;
|
||||||
|
|
||||||
static LoggingWithStorage logger("ETB");
|
static LoggingWithStorage logger("ETB");
|
||||||
/**
|
/**
|
||||||
* @brief Control Thread stack
|
* @brief Control Thread stack
|
||||||
|
@ -82,7 +85,7 @@ static Pid pid(&engineConfiguration->etb);
|
||||||
|
|
||||||
static float prevTps;
|
static float prevTps;
|
||||||
|
|
||||||
static float currentEtbDuty;
|
static percent_t currentEtbDuty;
|
||||||
|
|
||||||
static bool wasEtbBraking = false;
|
static bool wasEtbBraking = false;
|
||||||
|
|
||||||
|
@ -95,6 +98,15 @@ static msg_t etbThread(void *arg) {
|
||||||
shouldResetPid = false;
|
shouldResetPid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (engine->etbAutoTune) {
|
||||||
|
autoTune.Runtime(&logger);
|
||||||
|
|
||||||
|
etbPwmUp.setSimplePwmDutyCycle(autoTune.output);
|
||||||
|
|
||||||
|
pid.sleep();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
percent_t throttlePedal = getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE);
|
percent_t throttlePedal = getPedalPosition(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
percent_t tps = getTPS();
|
percent_t tps = getTPS();
|
||||||
|
@ -142,6 +154,9 @@ static void setThrottleConsole(int level) {
|
||||||
static void showEthInfo(void) {
|
static void showEthInfo(void) {
|
||||||
static char pinNameBuffer[16];
|
static char pinNameBuffer[16];
|
||||||
|
|
||||||
|
scheduleMsg(&logger, "etbAutoTune=%d",
|
||||||
|
engine->etbAutoTune);
|
||||||
|
|
||||||
scheduleMsg(&logger, "throttlePedal=%f %f/%f @%s",
|
scheduleMsg(&logger, "throttlePedal=%f %f/%f @%s",
|
||||||
getPedalPosition(),
|
getPedalPosition(),
|
||||||
engineConfiguration->throttlePedalUpVoltage,
|
engineConfiguration->throttlePedalUpVoltage,
|
||||||
|
@ -227,6 +242,16 @@ void startETBPins(void) {
|
||||||
outputDirectionClose.initPin("etb dir close", boardConfiguration->etbDirectionPin2);
|
outputDirectionClose.initPin("etb dir close", boardConfiguration->etbDirectionPin2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setTempOutput(float value) {
|
||||||
|
autoTune.output = value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setTempStep(float value) {
|
||||||
|
autoTune.oStep = value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void initElectronicThrottle(void) {
|
void initElectronicThrottle(void) {
|
||||||
// these two lines are controlling direction
|
// these two lines are controlling direction
|
||||||
// outputPinRegister("etb1", ELECTRONIC_THROTTLE_CONTROL_1, ETB_CONTROL_LINE_1_PORT, ETB_CONTROL_LINE_1_PIN);
|
// outputPinRegister("etb1", ELECTRONIC_THROTTLE_CONTROL_1, ETB_CONTROL_LINE_1_PORT, ETB_CONTROL_LINE_1_PIN);
|
||||||
|
@ -239,7 +264,10 @@ void initElectronicThrottle(void) {
|
||||||
|
|
||||||
startETBPins();
|
startETBPins();
|
||||||
|
|
||||||
addConsoleActionI("e", setThrottleConsole);
|
addConsoleActionI("set_etb", setThrottleConsole);
|
||||||
|
|
||||||
|
addConsoleActionF("set_etb_output", setTempOutput);
|
||||||
|
addConsoleActionF("set_etb_step", setTempStep);
|
||||||
|
|
||||||
apply();
|
apply();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue