mirror of https://github.com/rusefi/rusefi.git
Boost (#5586)
* boost is engine module * only:idle leaves outputs --------- Co-authored-by: Matthew Kennedy <matthewkennedy@outlook.com>
This commit is contained in:
parent
903d7c1025
commit
e19204dd2e
|
@ -55,7 +55,7 @@ const injector_model_s* getLiveData(size_t) {
|
|||
template<>
|
||||
const boost_control_s* getLiveData(size_t) {
|
||||
#if EFI_BOOST_CONTROL
|
||||
return &engine->boostController;
|
||||
return &engine->module<BoostController>().unmock();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,8 @@ void BoostController::init(IPwm* pwm, const ValueProvider3D* openLoopMap, const
|
|||
|
||||
m_pid.initPidClass(pidParams);
|
||||
resetLua();
|
||||
|
||||
hasInitBoost = true;
|
||||
}
|
||||
|
||||
void BoostController::resetLua() {
|
||||
|
@ -37,8 +39,8 @@ void BoostController::resetLua() {
|
|||
luaOpenLoopAdd = 0;
|
||||
}
|
||||
|
||||
void BoostController::onConfigurationChange(pid_s* previousConfiguration) {
|
||||
if (!m_pid.isSame(previousConfiguration)) {
|
||||
void BoostController::onConfigurationChange(engine_configuration_s const * previousConfig) {
|
||||
if (!m_pid.isSame(&previousConfig->boostPid)) {
|
||||
m_shouldResetPid = true;
|
||||
}
|
||||
}
|
||||
|
@ -179,7 +181,7 @@ void BoostController::setOutput(expected<float> output) {
|
|||
setEtbWastegatePosition(boostOutput);
|
||||
}
|
||||
|
||||
void BoostController::update() {
|
||||
void BoostController::onFastCallback() {
|
||||
if (!hasInitBoost) {
|
||||
return;
|
||||
}
|
||||
|
@ -242,10 +244,6 @@ void startBoostPin() {
|
|||
#endif /* EFI_UNIT_TEST */
|
||||
}
|
||||
|
||||
void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfiguration) {
|
||||
engine->boostController.onConfigurationChange(&previousConfiguration->boostPid);
|
||||
}
|
||||
|
||||
void initBoostCtrl() {
|
||||
// todo: why do we have 'isBoostControlEnabled' setting exactly?
|
||||
// 'initVvtActuators' is an example of a subsystem without explicit enable
|
||||
|
@ -269,12 +267,11 @@ void initBoostCtrl() {
|
|||
boostMapClosed.init(config->boostTableClosedLoop, config->boostTpsBins, config->boostRpmBins);
|
||||
|
||||
// Set up boost controller instance
|
||||
engine->boostController.init(&boostPwmControl, &boostMapOpen, &boostMapClosed, &engineConfiguration->boostPid);
|
||||
engine->module<BoostController>().unmock().init(&boostPwmControl, &boostMapOpen, &boostMapClosed, &engineConfiguration->boostPid);
|
||||
|
||||
#if !EFI_UNIT_TEST
|
||||
startBoostPin();
|
||||
#endif
|
||||
engine->boostController.hasInitBoost = true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -13,15 +13,16 @@
|
|||
|
||||
struct IPwm;
|
||||
|
||||
class BoostController : public boost_control_s, public ClosedLoopController<float, percent_t> {
|
||||
class BoostController : public EngineModule, public boost_control_s, public ClosedLoopController<float, percent_t> {
|
||||
public:
|
||||
void init(IPwm* pmw, const ValueProvider3D* openLoopMap, const ValueProvider3D* closedLoopTargetMap, pid_s* pidParams);
|
||||
void update();
|
||||
|
||||
void onFastCallback() override;
|
||||
void resetLua();
|
||||
|
||||
// Called when the configuration may have changed. Controller will
|
||||
// reset if necessary.
|
||||
void onConfigurationChange(pid_s* previousConfiguration);
|
||||
void onConfigurationChange(engine_configuration_s const * previousConfig) override;
|
||||
|
||||
// Helpers for individual parts of boost control
|
||||
expected<float> observePlant() const override;
|
||||
|
@ -45,4 +46,3 @@ private:
|
|||
void startBoostPin();
|
||||
void initBoostCtrl();
|
||||
void setDefaultBoostParameters();
|
||||
void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfiguration);
|
||||
|
|
|
@ -306,7 +306,7 @@ void Engine::resetLua() {
|
|||
engineState.lua.luaDisableEtb = false;
|
||||
engineState.lua.luaIgnCut = false;
|
||||
#if EFI_BOOST_CONTROL
|
||||
boostController.resetLua();
|
||||
module<BoostController>().unmock().resetLua();
|
||||
#endif // EFI_BOOST_CONTROL
|
||||
ignitionState.luaTimingAdd = 0;
|
||||
ignitionState.luaTimingMult = 1;
|
||||
|
@ -548,10 +548,6 @@ void Engine::periodicFastCallback() {
|
|||
tachSignalCallback();
|
||||
|
||||
engine->engineModules.apply_all([](auto & m) { m.onFastCallback(); });
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
engine->boostController.update();
|
||||
#endif // EFI_BOOST_CONTROL
|
||||
}
|
||||
|
||||
EngineRotationState * getEngineRotationState() {
|
||||
|
|
|
@ -164,6 +164,9 @@ public:
|
|||
VvtController3,
|
||||
VvtController4,
|
||||
#endif // EFI_VVT_PID
|
||||
#if EFI_BOOST_CONTROL
|
||||
BoostController,
|
||||
#endif // EFI_BOOST_CONTROL
|
||||
EngineModule // dummy placeholder so the previous entries can all have commas
|
||||
> engineModules;
|
||||
|
||||
|
@ -198,10 +201,6 @@ public:
|
|||
SoftSparkLimiter ALSsoftSparkLimiter;
|
||||
#endif /* EFI_ANTILAG_SYSTEM */
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
BoostController boostController;
|
||||
#endif // EFI_BOOST_CONTROL
|
||||
|
||||
LambdaMonitor lambdaMonitor;
|
||||
|
||||
IgnitionState ignitionState;
|
||||
|
|
|
@ -185,17 +185,11 @@ void incrementGlobalConfigurationVersion(const char * msg) {
|
|||
|
||||
boardOnConfigurationChange(&activeConfiguration);
|
||||
|
||||
/**
|
||||
* All these callbacks could be implemented as listeners, but these days I am saving RAM
|
||||
*/
|
||||
engine->preCalculate();
|
||||
#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 */
|
||||
|
|
|
@ -773,15 +773,15 @@ void configureRusefiLuaHooks(lua_State* l) {
|
|||
|
||||
#if EFI_BOOST_CONTROL
|
||||
lua_register(l, "setBoostTargetAdd", [](lua_State* l) {
|
||||
engine->boostController.luaTargetAdd = luaL_checknumber(l, 1);
|
||||
engine->module<BoostController>().unmock().luaTargetAdd = luaL_checknumber(l, 1);
|
||||
return 0;
|
||||
});
|
||||
lua_register(l, "setBoostTargetMult", [](lua_State* l) {
|
||||
engine->boostController.luaTargetMult = luaL_checknumber(l, 1);
|
||||
engine->module<BoostController>().unmock().luaTargetMult = luaL_checknumber(l, 1);
|
||||
return 0;
|
||||
});
|
||||
lua_register(l, "setBoostDutyAdd", [](lua_State* l) {
|
||||
engine->boostController.luaOpenLoopAdd = luaL_checknumber(l, 1);
|
||||
engine->module<BoostController>().unmock().luaOpenLoopAdd = luaL_checknumber(l, 1);
|
||||
return 0;
|
||||
});
|
||||
#endif // EFI_BOOST_CONTROL
|
||||
|
|
|
@ -74,7 +74,8 @@ Usages:
|
|||
folder: controllers/actuators
|
||||
prepend: integration/rusefi_config_shared.txt
|
||||
output_name: boost
|
||||
constexpr: "engine->boostController"
|
||||
constexpr: "___engine.module<BoostController>()"
|
||||
isPtr: true
|
||||
conditional_compilation: "EFI_BOOST_CONTROL"
|
||||
|
||||
- name: ac_control
|
||||
|
|
Loading…
Reference in New Issue