diff options
| author | James Feist <james.feist@linux.intel.com> | 2018-09-20 15:46:58 -0700 |
|---|---|---|
| committer | James Feist <james.feist@linux.intel.com> | 2018-09-21 12:13:58 -0700 |
| commit | 3dfaafdacaeaf2b21ff24f3cb314b71c911e2cea (patch) | |
| tree | 80ae538890b851786c8d46898b905b1af12735cf /pid/ec | |
| parent | 9f044415a21272b554fa7594ade21927154afcb0 (diff) | |
| download | phosphor-pid-control-3dfaafdacaeaf2b21ff24f3cb314b71c911e2cea.tar.gz phosphor-pid-control-3dfaafdacaeaf2b21ff24f3cb314b71c911e2cea.zip | |
Add hysteresis to stepwise controller
Tested-by: Ran on platform monitoring output and wrote
unit test
Change-Id: I74a1d21544c1a9cb4c1cb26dd4a353cbff0442d0
Signed-off-by: James Feist <james.feist@linux.intel.com>
Diffstat (limited to 'pid/ec')
| -rw-r--r-- | pid/ec/stepwise.cpp | 3 | ||||
| -rw-r--r-- | pid/ec/stepwise.hpp | 2 |
2 files changed, 4 insertions, 1 deletions
diff --git a/pid/ec/stepwise.cpp b/pid/ec/stepwise.cpp index 4246fb3..4a71532 100644 --- a/pid/ec/stepwise.cpp +++ b/pid/ec/stepwise.cpp @@ -16,6 +16,7 @@ #include "stepwise.hpp" +#include <cmath> #include <cstddef> #include <limits> @@ -29,7 +30,7 @@ float stepwise(const ec::StepwiseInfo& info, float input) for (size_t ii = 1; ii < ec::maxStepwisePoints; ii++) { - if (info.reading[ii] == std::numeric_limits<float>::quiet_NaN()) + if (std::isnan(info.reading[ii])) { break; } diff --git a/pid/ec/stepwise.hpp b/pid/ec/stepwise.hpp index ed07b44..4034b47 100644 --- a/pid/ec/stepwise.hpp +++ b/pid/ec/stepwise.hpp @@ -29,6 +29,8 @@ struct StepwiseInfo float ts; // sample time in seconds float reading[maxStepwisePoints]; float output[maxStepwisePoints]; + float positiveHysteresis; + float negativeHysteresis; }; float stepwise(const ec::StepwiseInfo& info, float value); |

