mirror of https://github.com/rusefi/rusefi-1.git
boost fixes (#2230)
* fix boost pin reinit * call boost from periodic slow * ui Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
84cacc86bd
commit
fa30efbc94
|
@ -40,21 +40,12 @@ void BoostController::init(SimplePwm* pwm, const ValueProvider3D* openLoopMap, c
|
|||
m_pid.initPidClass(pidParams);
|
||||
}
|
||||
|
||||
|
||||
void BoostController::reset() {
|
||||
m_shouldResetPid = true;
|
||||
}
|
||||
|
||||
void BoostController::onConfigurationChange(pid_s* previousConfiguration) {
|
||||
if (!m_pid.isSame(previousConfiguration)) {
|
||||
m_shouldResetPid = true;
|
||||
}
|
||||
}
|
||||
|
||||
int BoostController::getPeriodMs() {
|
||||
return GET_PERIOD_LIMITED(&engineConfiguration->boostPid);
|
||||
}
|
||||
|
||||
expected<float> BoostController::observePlant() const {
|
||||
return Sensor::get(SensorType::Map);
|
||||
}
|
||||
|
@ -125,7 +116,7 @@ expected<percent_t> BoostController::getClosedLoop(float target, float manifoldP
|
|||
return 0;
|
||||
}
|
||||
|
||||
float closedLoop = m_pid.getOutput(target, manifoldPressure);
|
||||
float closedLoop = m_pid.getOutput(target, manifoldPressure, SLOW_CALLBACK_PERIOD_MS / 1000.0f);
|
||||
|
||||
#if EFI_TUNER_STUDIO
|
||||
if (engineConfiguration->debugMode == DBG_BOOST) {
|
||||
|
@ -149,23 +140,29 @@ void BoostController::setOutput(expected<float> output) {
|
|||
setEtbWastegatePosition(percent PASS_ENGINE_PARAMETER_SUFFIX);
|
||||
}
|
||||
|
||||
void BoostController::PeriodicTask() {
|
||||
void BoostController::update() {
|
||||
m_pid.iTermMin = -50;
|
||||
m_pid.iTermMax = 50;
|
||||
|
||||
update();
|
||||
ClosedLoopController::update();
|
||||
}
|
||||
|
||||
BoostController boostController;
|
||||
static BoostController boostController;
|
||||
static bool hasInitBoost = false;
|
||||
|
||||
void updateBoostControl() {
|
||||
if (hasInitBoost) {
|
||||
boostController.update();
|
||||
}
|
||||
}
|
||||
|
||||
void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE) {
|
||||
engineConfiguration->boostPwmFrequency = 55;
|
||||
engineConfiguration->boostPwmFrequency = 33;
|
||||
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->boostPid.maxValue = 20;
|
||||
engineConfiguration->boostPid.minValue = -20;
|
||||
engineConfiguration->boostControlPin = GPIO_UNASSIGNED;
|
||||
engineConfiguration->boostControlPinMode = OM_DEFAULT;
|
||||
|
||||
|
@ -203,12 +200,6 @@ void startBoostPin() {
|
|||
#endif /* EFI_UNIT_TEST */
|
||||
}
|
||||
|
||||
void stopBoostPin() {
|
||||
#if !EFI_UNIT_TEST
|
||||
efiSetPadUnused(activeConfiguration.boostControlPin);
|
||||
#endif /* EFI_UNIT_TEST */
|
||||
}
|
||||
|
||||
void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfiguration) {
|
||||
boostController.onConfigurationChange(&previousConfiguration->boostPid);
|
||||
}
|
||||
|
@ -242,7 +233,7 @@ void initBoostCtrl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
|
||||
#if !EFI_UNIT_TEST
|
||||
startBoostPin();
|
||||
boostController.Start();
|
||||
hasInitBoost = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -13,16 +13,12 @@
|
|||
|
||||
class SimplePwm;
|
||||
|
||||
class BoostController : public ClosedLoopController<float, percent_t>, public PeriodicTimerController {
|
||||
class BoostController : public ClosedLoopController<float, percent_t> {
|
||||
public:
|
||||
DECLARE_ENGINE_PTR;
|
||||
|
||||
void init(SimplePwm* pmw, const ValueProvider3D* openLoopMap, const ValueProvider3D* closedLoopTargetMap, pid_s* pidParams);
|
||||
|
||||
// PeriodicTimerController implementation
|
||||
int getPeriodMs() override;
|
||||
void PeriodicTask() override;
|
||||
void reset();
|
||||
void update();
|
||||
|
||||
// Called when the configuration may have changed. Controller will
|
||||
// reset if necessary.
|
||||
|
@ -47,7 +43,8 @@ private:
|
|||
};
|
||||
|
||||
void startBoostPin();
|
||||
void stopBoostPin();
|
||||
void initBoostCtrl(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX);
|
||||
void setDefaultBoostParameters(DECLARE_CONFIG_PARAMETER_SIGNATURE);
|
||||
void onConfigurationChangeBoostCallback(engine_configuration_s *previousConfiguration);
|
||||
|
||||
void updateBoostControl();
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "gppwm.h"
|
||||
#include "tachometer.h"
|
||||
#include "dynoview.h"
|
||||
#include "boost_control.h"
|
||||
#if EFI_MC33816
|
||||
#include "mc33816.h"
|
||||
#endif // EFI_MC33816
|
||||
|
@ -193,6 +194,10 @@ void Engine::periodicSlowCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
|||
|
||||
updateIdleControl();
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
updateBoostControl();
|
||||
#endif // EFI_BOOST_CONTROL
|
||||
|
||||
cylinderCleanupControl(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
||||
standardAirCharge = getStandardAirCharge(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||
|
|
|
@ -379,9 +379,6 @@ void applyNewHardwareSettings(void) {
|
|||
stopHD44780_pins();
|
||||
#endif /* #if EFI_HD44780_LCD */
|
||||
|
||||
#if EFI_BOOST_CONTROL
|
||||
stopBoostPin();
|
||||
#endif
|
||||
if (isPinOrModeChanged(clutchUpPin, clutchUpPinMode)) {
|
||||
efiSetPadUnused(activeConfiguration.clutchUpPin);
|
||||
}
|
||||
|
|
|
@ -3171,9 +3171,8 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00"
|
|||
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 }
|
||||
field = "Min adjustment", boostPid_minValue, { isBoostControlEnabled && boostType == 1 }
|
||||
field = "Max adjustment", boostPid_maxValue, { isBoostControlEnabled && boostType == 1 }
|
||||
|
||||
dialog = boostTableDialog, "", card
|
||||
panel = boostTable2Tbl
|
||||
|
|
Loading…
Reference in New Issue