parent
3559d8eb3b
commit
2fbedc000f
|
@ -199,23 +199,9 @@ expected<percent_t> EtbController::getOpenLoop(percent_t target) const {
|
|||
return ff;
|
||||
}
|
||||
|
||||
expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t actualThrottlePosition) {
|
||||
if (m_shouldResetPid) {
|
||||
m_pid.reset();
|
||||
m_shouldResetPid = false;
|
||||
}
|
||||
|
||||
// Only report the 0th throttle
|
||||
if (m_myIndex == 0) {
|
||||
#if EFI_TUNER_STUDIO
|
||||
// Error is positive if the throttle needs to open further
|
||||
tsOutputChannels.etb1Error = target - actualThrottlePosition;
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
}
|
||||
|
||||
// Only allow autotune with stopped engine
|
||||
if (GET_RPM() == 0 && engine->etbAutoTune) {
|
||||
bool isPositive = actualThrottlePosition > target;
|
||||
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;
|
||||
|
||||
float autotuneAmplitude = 20;
|
||||
|
||||
|
@ -284,6 +270,25 @@ expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t act
|
|||
|
||||
// Bang-bang control the output to induce oscillation
|
||||
return autotuneAmplitude * (isPositive ? -1 : 1);
|
||||
}
|
||||
|
||||
expected<percent_t> EtbController::getClosedLoop(percent_t target, percent_t actualThrottlePosition) {
|
||||
if (m_shouldResetPid) {
|
||||
m_pid.reset();
|
||||
m_shouldResetPid = false;
|
||||
}
|
||||
|
||||
// Only report the 0th throttle
|
||||
if (m_myIndex == 0) {
|
||||
#if EFI_TUNER_STUDIO
|
||||
// Error is positive if the throttle needs to open further
|
||||
tsOutputChannels.etb1Error = target - actualThrottlePosition;
|
||||
#endif /* EFI_TUNER_STUDIO */
|
||||
}
|
||||
|
||||
// Only allow autotune with stopped engine
|
||||
if (GET_RPM() == 0 && engine->etbAutoTune) {
|
||||
return getClosedLoopAutotune(actualThrottlePosition);
|
||||
} else {
|
||||
// Normal case - use PID to compute closed loop part
|
||||
return m_pid.getOutput(target, actualThrottlePosition);
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
expected<percent_t> getOpenLoop(percent_t target) const override;
|
||||
expected<percent_t> getClosedLoop(percent_t setpoint, percent_t target) override;
|
||||
expected<percent_t> getClosedLoopAutotune(percent_t actualThrottlePosition);
|
||||
|
||||
void setOutput(expected<percent_t> outputValue) override;
|
||||
|
||||
|
|
Loading…
Reference in New Issue