Boost pr (#1114)
* boost control * cleanup * Delete rusefi_config.txt * Add files via upload * Delete rusefi_config.txt * Add files via upload * Update rusefi.input * Update boost_control.cpp
This commit is contained in:
parent
8c3d8d5665
commit
4b4e683957
|
@ -13,6 +13,7 @@
|
|||
#include "../stm32f4ems/efifeatures.h"
|
||||
|
||||
#pragma once
|
||||
#define EFI_BOOST_CONTROL TRUE
|
||||
|
||||
// Warning! This is a test config!
|
||||
|
||||
|
|
|
@ -0,0 +1,194 @@
|
|||
/*
|
||||
* boost_control.cpp
|
||||
*
|
||||
* Created on: 13. des. 2019
|
||||
* Author: Ola Ruud
|
||||
*/
|
||||
#include "global.h"
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
#include "tunerstudio_configuration.h"
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
#include "engine.h"
|
||||
#include "boost_control.h"
|
||||
#include "tps.h"
|
||||
#include "map.h"
|
||||
#include "io_pins.h"
|
||||
#include "engine_configuration.h"
|
||||
#include "pwm_generator_logic.h"
|
||||
#include "pid.h"
|
||||
#include "engine_controller.h"
|
||||
#include "periodic_task.h"
|
||||
#include "pin_repository.h"
|
||||
#include "pwm_generator.h"
|
||||
#include "pid_auto_tune.h"
|
||||
#include "local_version_holder.h"
|
||||
#define NO_PIN_PERIOD 500
|
||||
|
||||
#if defined(HAS_OS_ACCESS)
|
||||
#error "Unexpected OS ACCESS HERE"
|
||||
#endif
|
||||
|
||||
EXTERN_ENGINE;
|
||||
|
||||
static Logging *logger;
|
||||
static boostOpenLoop_Map3D_t boostMapOpen("boostmapopen", 1);
|
||||
static boostOpenLoop_Map3D_t boostMapClosed("boostmapclosed", 1);
|
||||
static SimplePwm boostPwmControl("boost");
|
||||
static pid_s *boostPidS = &persistentState.persistentConfiguration.engineConfiguration.boostPid;
|
||||
static Pid boostControlPid(boostPidS);
|
||||
|
||||
|
||||
static bool shouldResetPid = false;
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
extern TunerStudioOutputChannels tsOutputChannels;
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
|
||||
|
||||
static void pidReset(void) {
|
||||
boostControlPid.reset();
|
||||
}
|
||||
|
||||
|
||||
class BoostControl: public PeriodicTimerController {
|
||||
int getPeriodMs()
|
||||
override {
|
||||
return GET_PERIOD_LIMITED(&engineConfiguration->boostPid);
|
||||
}
|
||||
void PeriodicTask() override {
|
||||
if (shouldResetPid) {
|
||||
pidReset();
|
||||
shouldResetPid = false;
|
||||
}
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
boostControlPid.postState(&tsOutputChannels);
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
float rpm = GET_RPM_VALUE;
|
||||
float mapValue = getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
if (!engineConfiguration->isBoostControlEnabled)
|
||||
return;
|
||||
bool enabledAtEngineRunning = rpm > engineConfiguration->cranking.rpm;
|
||||
if (!enabledAtEngineRunning) {
|
||||
boostControlPid.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
percent_t openLoopDuty = boostMapOpen.getValue(rpm / RPM_1_BYTE_PACKING_MULT, mapValue/ LOAD_1_BYTE_PACKING_MULT) * LOAD_1_BYTE_PACKING_MULT;
|
||||
percent_t duty, closedLoopDuty = 0;
|
||||
|
||||
if (engineConfiguration->boostType == OPEN_LOOP) {
|
||||
duty = openLoopDuty;
|
||||
}
|
||||
else if (engineConfiguration->boostType == CLOSED_LOOP) {
|
||||
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
float targetBoost = boostMapClosed.getValue(rpm / RPM_1_BYTE_PACKING_MULT, tps / TPS_1_BYTE_PACKING_MULT) * LOAD_1_BYTE_PACKING_MULT;
|
||||
closedLoopDuty = openLoopDuty + boostControlPid.getOutput(targetBoost, mapValue);
|
||||
duty = closedLoopDuty;
|
||||
}
|
||||
|
||||
|
||||
boostControlPid.iTermMin = -50;
|
||||
boostControlPid.iTermMax = 50;
|
||||
|
||||
if (engineConfiguration->debugMode == DBG_BOOST) {
|
||||
#if EFI_TUNER_STUDIO
|
||||
tsOutputChannels.debugFloatField1 = openLoopDuty;
|
||||
tsOutputChannels.debugFloatField7 = closedLoopDuty;
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
}
|
||||
boostPwmControl.setSimplePwmDutyCycle(PERCENT_TO_DUTY(duty));
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
static BoostControl BoostController;
|
||||
|
||||
|
||||
void setBoostPFactor(float value) {
|
||||
engineConfiguration->boostPid.pFactor = value;
|
||||
boostControlPid.reset();
|
||||
|
||||
}
|
||||
|
||||
void setBoostIFactor(float value) {
|
||||
engineConfiguration->boostPid.iFactor = value;
|
||||
boostControlPid.reset();
|
||||
}
|
||||
|
||||
|
||||
void setBoostDFactor(float value) {
|
||||
engineConfiguration->boostPid.dFactor = value;
|
||||
boostControlPid.reset();
|
||||
}
|
||||
|
||||
void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
|
||||
|
||||
engineConfiguration->isBoostControlEnabled = true;
|
||||
engineConfiguration->boostPwmFrequency = 55;
|
||||
engineConfiguration->boostPid.offset = 0;
|
||||
engineConfiguration->boostPid.pFactor = 0.5;
|
||||
engineConfiguration->boostPid.iFactor = 0.3;
|
||||
engineConfiguration->boostPid.periodMs = 100;
|
||||
engineConfiguration->boostPid.maxValue = 99;
|
||||
engineConfiguration->boostPid.minValue = -99;
|
||||
engineConfiguration->boostControlPin = GPIO_UNASSIGNED;
|
||||
engineConfiguration->boostControlPinMode = OM_DEFAULT;
|
||||
|
||||
setLinearCurve(config->boostRpmBins, 0, 8000 / RPM_1_BYTE_PACKING_MULT, 1);
|
||||
setLinearCurve(config->boostMapBins, 0, 300 / LOAD_1_BYTE_PACKING_MULT, 1);
|
||||
for (int loadIndex = 0;loadIndex<BOOST_LOAD_COUNT;loadIndex++) {
|
||||
for (int rpmIndex = 0;rpmIndex<BOOST_RPM_COUNT;rpmIndex++) {
|
||||
config->boostTableOpenLoop[loadIndex][rpmIndex] = config->boostMapBins[loadIndex];
|
||||
}
|
||||
}
|
||||
setLinearCurve(config->boostTpsBins, 0, 100 / TPS_1_BYTE_PACKING_MULT, 1);
|
||||
for (int loadIndex = 0;loadIndex<BOOST_LOAD_COUNT;loadIndex++) {
|
||||
for (int rpmIndex = 0;rpmIndex<BOOST_RPM_COUNT;rpmIndex++) {
|
||||
config->boostTableClosedLoop[loadIndex][rpmIndex] = config->boostTpsBins[loadIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void turnBoostPidOn() {
|
||||
if (CONFIG(boostControlPin) == GPIO_UNASSIGNED){
|
||||
return;
|
||||
}
|
||||
startSimplePwmExt(&boostPwmControl, "Boost", &engine->executor,
|
||||
CONFIG(boostControlPin), &enginePins.boostPin,
|
||||
engineConfiguration->boostPwmFrequency, 0.5f,
|
||||
(pwm_gen_callback*) applyPinState);
|
||||
}
|
||||
|
||||
void startBoostPin(void) {
|
||||
|
||||
turnBoostPidOn();
|
||||
|
||||
}
|
||||
void stopBoostPin(void) {
|
||||
brain_pin_markUnused(activeConfiguration.boostControlPin);
|
||||
}
|
||||
|
||||
void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfiguration) {
|
||||
shouldResetPid = !boostControlPid.isSame(&previousConfiguration->boostPid);
|
||||
}
|
||||
|
||||
void initBoostCtrl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX){
|
||||
logger = sharedLogger;
|
||||
boostMapOpen.init(config->boostTableOpenLoop, config->boostMapBins, config->boostRpmBins);
|
||||
boostMapClosed.init(config->boostTableClosedLoop, config->boostTpsBins, config->boostRpmBins);
|
||||
boostControlPid.reset();
|
||||
startBoostPin();
|
||||
BoostController.Start();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -76,7 +76,7 @@
|
|||
#include "lada_kalina.h"
|
||||
#include "zil130.h"
|
||||
#include "honda_600.h"
|
||||
|
||||
#include "boost_control.h"
|
||||
#if EFI_IDLE_CONTROL
|
||||
#include "idle_thread.h"
|
||||
#endif /* EFI_IDLE_CONTROL */
|
||||
|
@ -183,6 +183,10 @@ void incrementGlobalConfigurationVersion(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
#if EFI_ALTERNATOR_CONTROL
|
||||
onConfigurationChangeAlternatorCallback(&activeConfiguration);
|
||||
#endif /* EFI_ALTERNATOR_CONTROL */
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
onConfigurationChangeBoostCallback(&activeConfiguration);
|
||||
#endif
|
||||
#if EFI_ELECTRONIC_THROTTLE_BODY
|
||||
onConfigurationChangeElectronicThrottleCallback(&activeConfiguration);
|
||||
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
|
||||
|
@ -646,6 +650,9 @@ static void setDefaultEngineConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
setDefaultEtbParameters(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
setDefaultEtbBiasCurve(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
#endif /* EFI_ELECTRONIC_THROTTLE_BODY */
|
||||
#if EFI_BOOST_CONTROL
|
||||
setDefaultBoostParameters(PASS_CONFIG_PARAMETER_SIGNATURE);
|
||||
#endif
|
||||
|
||||
CONFIG(mafSensorType) = Bosch0280218037;
|
||||
setBosch0280218037(config);
|
||||
|
|
|
@ -13,6 +13,7 @@ CONTROLLERSSRC =
|
|||
CONTROLLERS_SRC_CPP = \
|
||||
$(CONTROLLERS_DIR)/actuators/electronic_throttle.cpp \
|
||||
$(CONTROLLERS_DIR)/actuators/alternator_controller.cpp \
|
||||
$(CONTROLLERS_DIR)/actuators/boost_control.cpp \
|
||||
$(CONTROLLERS_DIR)/actuators/idle_thread.cpp \
|
||||
$(CONTROLLERS_DIR)/actuators/pwm_tester.cpp \
|
||||
$(CONTROLLERS_DIR)/actuators/algo/aux_pid.cpp \
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include "accelerometer.h"
|
||||
#include "counter64.h"
|
||||
#include "perf_trace.h"
|
||||
#include "boost_control.h"
|
||||
|
||||
#if EFI_SENSOR_CHART
|
||||
#include "sensor_chart.h"
|
||||
|
@ -787,6 +788,9 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
|
|||
initAlternatorCtrl(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
initBoostCtrl(sharedLogger PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
#endif
|
||||
#if EFI_AUX_PID
|
||||
initAuxPid(sharedLogger);
|
||||
#endif
|
||||
|
|
|
@ -142,6 +142,7 @@ void EnginePins::unregisterPins() {
|
|||
unregisterOutputIfPinChanged(fsioOutputs[i], fsioOutputPins[i]);
|
||||
}
|
||||
|
||||
unregisterOutputIfPinOrModeChanged(boostPin, boostControlPin, boostControlPinMode);
|
||||
unregisterOutputIfPinOrModeChanged(alternatorPin, alternatorControlPin, alternatorControlPinMode);
|
||||
unregisterOutputIfPinOrModeChanged(mainRelay, mainRelayPin, mainRelayPinMode);
|
||||
unregisterOutputIfPinOrModeChanged(starterRelay, starterRelayPin, starterRelayPinMode);
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#include "engine_configuration.h"
|
||||
#include "aux_pid.h"
|
||||
#include "perf_trace.h"
|
||||
|
||||
#include "boost_control.h"
|
||||
#if EFI_MC33816
|
||||
#include "mc33816.h"
|
||||
#endif /* EFI_MC33816 */
|
||||
|
@ -345,6 +345,9 @@ void applyNewHardwareSettings(void) {
|
|||
stopHD44780_pins();
|
||||
#endif /* #if EFI_HD44780_LCD */
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
stopBoostPin();
|
||||
#endif
|
||||
if (isPinOrModeChanged(clutchUpPin, clutchUpPinMode))
|
||||
brain_pin_markUnused(activeConfiguration.clutchUpPin);
|
||||
|
||||
|
@ -390,6 +393,9 @@ void applyNewHardwareSettings(void) {
|
|||
startVSSPins();
|
||||
#endif /* EFI_VEHICLE_SPEED */
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
startBoostPin();
|
||||
#endif
|
||||
#if EFI_AUX_PID
|
||||
startAuxPins();
|
||||
#endif /* EFI_AUX_PID */
|
||||
|
|
|
@ -667,6 +667,17 @@ fileVersion = { @@TS_FILE_VERSION@@ }
|
|||
xBins = tpsTpsAccelFromRpmBins, TPSValue
|
||||
yBins = tpsTpsAccelToRpmBins, TPSValue
|
||||
zBins = tpsTpsAccelTable
|
||||
|
||||
table = boostTableTbl, boostMapOpen, "", 1
|
||||
xBins = boostRpmBins, RPMValue
|
||||
yBins = boostMapBins, MAPValue
|
||||
zBins = boostTableOpenLoop
|
||||
|
||||
table = boostTable2Tbl, boostMapClosed, "", 1
|
||||
xBins = boostRpmBins, RPMValue
|
||||
yBins = boostTpsBins, TPSValue
|
||||
zBins = boostTableClosedLoop
|
||||
|
||||
|
||||
|
||||
table = fsioTable1Tbl, fsioTable1Map, "FSIO Table #1", 1
|
||||
|
@ -1214,7 +1225,10 @@ menuDialog = main
|
|||
subMenu = cltIdleCurve, "CLT multiplier"
|
||||
subMenu = iacCoastingCurve, "Coasting IAC Position for Auto-Idle", 0, {useIacTableForCoasting == 1}
|
||||
|
||||
menu = "&FSIO"
|
||||
menu = "&Advanced"
|
||||
subMenu = boostDialog, "Boost Control"
|
||||
subMenu = boostPidDialog, "Closed Loop Boost", { boostType == 1 }
|
||||
subMenu = std_separator
|
||||
subMenu = fsioInputsDialog, "FSIO inputs"
|
||||
subMenu = auxPidDialog, "Aux PID"
|
||||
subMenu = fsioOutputsDialog, "FSIO outputs"
|
||||
|
@ -2496,6 +2510,36 @@ cmd_set_engine_type_default = "w\x00\x31\x00\x00"
|
|||
field = "ADC #2", fsioAdc2
|
||||
field = "ADC #3", fsioAdc3
|
||||
field = "ADC #4", fsioAdc4
|
||||
|
||||
;Boost Open Loop
|
||||
|
||||
dialog = boost_left, ""
|
||||
field = "Enable", isBoostControlEnabled
|
||||
field = "Control Mode", boostType, { isBoostControlEnabled }
|
||||
field = "Output", boostControlPin, { isBoostControlEnabled }
|
||||
field = "Output Mode", boostControlPinMode, { isBoostControlEnabled }
|
||||
field = "Frequency", boostPwmFrequency, { isBoostControlEnabled }
|
||||
|
||||
dialog = boostDialog, "", border
|
||||
panel = boost_left, West
|
||||
panel = boostTableTbl, Center
|
||||
|
||||
;Boost Closed Loop
|
||||
|
||||
dialog = boostPidleft, ""
|
||||
field = "P Gain", boostPid_pFactor, { isBoostControlEnabled && boostType == 1 }
|
||||
field = "I Gain", boostPid_iFactor, { isBoostControlEnabled && boostType == 1 }
|
||||
field = "D Gain", boostPid_dFactor, { isBoostControlEnabled && boostType == 1 }
|
||||
field = "Control Period", boostPid_periodMs, { isBoostControlEnabled && boostType == 1 }
|
||||
field = "Min Duty", boostPid_minValue, { isBoostControlEnabled && boostType == 1 }
|
||||
field = "Max Duty", boostPid_maxValue, { isBoostControlEnabled && boostType == 1 }
|
||||
|
||||
dialog = boostTableDialog, "", card
|
||||
panel = boostTable2Tbl
|
||||
|
||||
dialog = boostPidDialog, "", border
|
||||
panel = boostPidleft, West
|
||||
panel = boostTableDialog, Center
|
||||
|
||||
help = veTableDialogHelp, "Volumetric Efficiency"
|
||||
text = "Volumetric Efficiency is used to calculate fuel in Speed Density mode"
|
||||
|
|
Loading…
Reference in New Issue