set 50% target for ETB autotune (#2459)

* 50% target for autotne

* pass target in

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2021-03-15 05:54:55 -07:00 committed by GitHub
parent 046f486b62
commit a9c8b39dac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View File

@ -269,6 +269,11 @@ expected<percent_t> EtbController::getSetpointWastegate() const {
}
expected<percent_t> EtbController::getSetpointEtb() const {
// Autotune runs with 50% target position
if (m_isAutotune) {
return 50.0f;
}
// A few extra preconditions if throttle control is invalid
if (startupPositionError) {
return unexpected;
@ -326,9 +331,10 @@ expected<percent_t> EtbController::getOpenLoop(percent_t target) const {
return ff;
}
expected<percent_t> EtbController::getClosedLoopAutotune(percent_t actualThrottlePosition) {
// Estimate gain at 60% position - this should be well away from the spring and in the linear region
bool isPositive = actualThrottlePosition > 60.0f;
expected<percent_t> EtbController::getClosedLoopAutotune(percent_t target, percent_t actualThrottlePosition) {
// Estimate gain at current position - this should be well away from the spring and in the linear region
// GetSetpoint sets this to 50%
bool isPositive = actualThrottlePosition > target;
float autotuneAmplitude = 20;
@ -444,10 +450,8 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t obs
}
// Only allow autotune with stopped engine, and on the first throttle
if (GET_RPM() == 0
&& engine->etbAutoTune
&& m_function == ETB_Throttle1) {
return getClosedLoopAutotune(observation);
if (m_isAutotune) {
return getClosedLoopAutotune(target, observation);
} else {
// Check that we're not over the error limit
float errorIntegral = m_errorAccumulator.accumulate(target - observation);
@ -539,6 +543,11 @@ void EtbController::update() {
m_pid.showPidStatus(&logger, "ETB");
}
// Update local state about autotune
m_isAutotune = GET_RPM() == 0
&& engine->etbAutoTune
&& m_function == ETB_Throttle1;
ClosedLoopController::update();
DISPLAY_STATE(Engine)

View File

@ -52,7 +52,7 @@ public:
expected<percent_t> getOpenLoop(percent_t target) const override;
expected<percent_t> getClosedLoop(percent_t setpoint, percent_t observation) override;
expected<percent_t> getClosedLoopAutotune(percent_t actualThrottlePosition);
expected<percent_t> getClosedLoopAutotune(percent_t setpoint, percent_t actualThrottlePosition);
void setOutput(expected<percent_t> outputValue) override;
@ -83,6 +83,9 @@ private:
float m_idlePosition = 0;
float m_wastegatePosition = 0;
// This is set if automatic PID cal shoudl be run
bool m_isAutotune = false;
// Autotune helpers
bool m_lastIsPositive = false;
efitick_t m_cycleStartTime = 0;