Skip to content

Commit 3e753ab

Browse files
committed
fix: Small fixes to pressure controller
1 parent 13dcf68 commit 3e753ab

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

lib/NayrodPID/src/PressureController/PressureController.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void PressureController::update(ControlMode mode) {
6262
float flowOutput = getPumpDutyCycleForFlowRate();
6363
float pressureOutput = getPumpDutyCycleForPressure();
6464
*_ctrlOutput = std::min(flowOutput, pressureOutput);
65-
if (mode == ControlMode::FLOW) {
65+
if (flowOutput < pressureOutput) {
6666
_errorInteg = 0.0f; // Reset error buildup in flow target
6767
}
6868
} else if (mode == ControlMode::FLOW) {
@@ -97,6 +97,9 @@ float PressureController::pumpFlowModel(float alpha) const {
9797
float PressureController::getPumpDutyCycleForFlowRate() const {
9898
// Afine model base on one Gaggia Classic Pro Unit measurements
9999
const float availableFlow = _Q1 * _filteredPressureSensor + _Q0;
100+
if (availableFlow <= 0.0f) {
101+
return 0.0f;
102+
}
100103
return *_rawFlowSetpoint / availableFlow * 100.0f;
101104
}
102105

0 commit comments

Comments
 (0)