Support to accumulate PWM of different controllers for same sensor
Description:
1. Add one property: accumulateSetPoint in zone of fan table that could
be used to enable accumulation of output PWM of different controllers
with same sensor.
2. Add one property: checkHysterWithSetpt in pid info of fan table to
select to compare current input and setpoint to check hysteresis.
3. The purpose of accumulate the stepwise output and PID output for
one sensor is that the setting of stepwise could use to prevent
the fan speed from suddenly increasing from a very low speed to a
very high speed due to reaching the setpoint.
Use stepwise before setpoint could also keep the PWM steady at
low ambient temperature.
Design:
1. Search "accumulateSetPoint" field in fan table.
If the value was true, accumulate the output PWM of different
controllers with same profile name.
2. Support two method to calculate PID output that could be chosen by
setting the "checkHysterWithSetpt" to true in pid info of fan table.
If the flag was set to true, it won't calculate PWM output if the
input lower than setpoint.
Test Case:
1. Check the output PWM of different controllers with same profile
name could be accumulated - pass.
2. Set "checkHysterWithSetpt" to true and check PID output would not be
calculated if the input temperature was lower than setpoint - pass.
Please see more details in gist:
https://gist.github.com/DelphineCCChiu/a6170d3e1a12fc4ee76fad324382fba3
Change-Id: I9f38f250d72545784c6c11be2fde7d45f0b385c4
Signed-off-by: Delphine CC Chiu <Delphine_CC_Chiu@wiwynn.com>
diff --git a/pid/zone.cpp b/pid/zone.cpp
index e5eddca..5332efe 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -120,15 +120,32 @@
return;
}
- _SetPoints.push_back(setPoint);
+ auto profileName = name;
+ if (getAccSetPoint())
+ {
+ /*
+ * If the name of controller is Linear_Temp_CPU0.
+ * The profile name will be Temp_CPU0.
+ */
+ profileName = name.substr(name.find("_") + 1);
+ _SetPoints[profileName] += setPoint;
+ }
+ else
+ {
+ if (_SetPoints[profileName] < setPoint)
+ {
+ _SetPoints[profileName] = setPoint;
+ }
+ }
+
/*
* if there are multiple thermal controllers with the same
* value, pick the first one in the iterator
*/
- if (_maximumSetPoint < setPoint)
+ if (_maximumSetPoint < _SetPoints[profileName])
{
- _maximumSetPoint = setPoint;
- _maximumSetPointName = name;
+ _maximumSetPoint = _SetPoints[profileName];
+ _maximumSetPointName = profileName;
}
}
@@ -208,7 +225,16 @@
void DbusPidZone::addThermalInput(const std::string& therm,
bool missingAcceptable)
{
- _thermalInputs.push_back(therm);
+ /*
+ * One sensor may have stepwise and PID at the same time.
+ * Searching the sensor name before inserting it to avoid duplicated sensor
+ * names.
+ */
+ if (std::find(_thermalInputs.begin(), _thermalInputs.end(), therm) ==
+ _thermalInputs.end())
+ {
+ _thermalInputs.push_back(therm);
+ }
if (missingAcceptable)
{
@@ -287,6 +313,33 @@
}
/*
+ * Combine the maximum SetPoint Name if the controllers have same profile
+ * name. e.g., PID_BB_INLET_TEMP_C + Stepwise_BB_INLET_TEMP_C.
+ */
+ if (getAccSetPoint())
+ {
+ auto profileName = _maximumSetPointName;
+ _maximumSetPointName = "";
+
+ for (auto& p : _thermals)
+ {
+ auto controllerID = p->getID();
+ auto found = controllerID.find(profileName);
+ if (found != std::string::npos)
+ {
+ if (_maximumSetPointName.empty())
+ {
+ _maximumSetPointName = controllerID;
+ }
+ else
+ {
+ _maximumSetPointName += " + " + controllerID;
+ }
+ }
+ }
+ }
+
+ /*
* If the maximum RPM setpoint output is below the minimum RPM
* setpoint, set it to the minimum.
*/
@@ -579,4 +632,9 @@
}
}
+bool DbusPidZone::getAccSetPoint(void) const
+{
+ return _accumulateSetPoint;
+}
+
} // namespace pid_control