From dca2d484ee91ee40fc94509d831ef2c5fa792ca0 Mon Sep 17 00:00:00 2001 From: James Feist Date: Fri, 15 Feb 2019 16:14:31 -0800 Subject: DBusConfiguration: Fix scaling Revert the removal of the /100 because that caused 90% to be passed as 90 instead of .9. To counter-act this multiply the stepwise controller by 100 so that setting 50 is 50%. Tested-by: Used sensor override to make stepwise jump threshold and got desired pwm result. Change-Id: I629bf0d4b0b3bc77660c09fccae82b1bdac4c578 --- pid/fancontroller.cpp | 6 ------ pid/stepwisecontroller.cpp | 2 ++ test/pid_stepwisecontroller_unittest.cpp | 10 ++++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pid/fancontroller.cpp b/pid/fancontroller.cpp index ee43e4e..4a61def 100644 --- a/pid/fancontroller.cpp +++ b/pid/fancontroller.cpp @@ -14,8 +14,6 @@ * limitations under the License. */ -#include "config.h" - #include "fancontroller.hpp" #include "util.hpp" @@ -128,12 +126,8 @@ void FanController::outputProc(double value) } #endif -// in the dbus configurations the /100 is added to the configurations -// directly so this step is not needed -#if !CONFIGURE_DBUS // value and kFanFailSafeDutyCycle are 10 for 10% so let's fix that. percent /= 100; -#endif // PidSensorMap for writing. for (const auto& it : _inputs) diff --git a/pid/stepwisecontroller.cpp b/pid/stepwisecontroller.cpp index 43fd241..fee25ab 100644 --- a/pid/stepwisecontroller.cpp +++ b/pid/stepwisecontroller.cpp @@ -95,6 +95,8 @@ double StepwiseController::inputProc(void) void StepwiseController::outputProc(double value) { + // values are 10 for 10% + value *= 100; _owner->addRPMSetPoint(value); return; diff --git a/test/pid_stepwisecontroller_unittest.cpp b/test/pid_stepwisecontroller_unittest.cpp index e3c4f09..5b1e655 100644 --- a/test/pid_stepwisecontroller_unittest.cpp +++ b/test/pid_stepwisecontroller_unittest.cpp @@ -12,6 +12,8 @@ using ::testing::Return; using ::testing::StrEq; +constexpr size_t scale = 100; // values are 10 for 10% + TEST(StepwiseControllerTest, HysteresisTestPositive) { // Verifies positive hysteresis works as expected @@ -38,8 +40,8 @@ TEST(StepwiseControllerTest, HysteresisTestPositive) .WillOnce(Return(31.0)) // return 40 .WillOnce(Return(32.0)); // return 60 - EXPECT_CALL(z, addRPMSetPoint(40.0)).Times(2); - EXPECT_CALL(z, addRPMSetPoint(60.0)).Times(1); + EXPECT_CALL(z, addRPMSetPoint(40.0 * scale)).Times(2); + EXPECT_CALL(z, addRPMSetPoint(60.0 * scale)).Times(1); for (int ii = 0; ii < 3; ii++) { @@ -73,8 +75,8 @@ TEST(StepwiseControllerTest, HysteresisTestNegative) .WillOnce(Return(27.0)) // return 60 .WillOnce(Return(26.0)); // return 40 - EXPECT_CALL(z, addRPMSetPoint(40.0)).Times(1); - EXPECT_CALL(z, addRPMSetPoint(60.0)).Times(2); + EXPECT_CALL(z, addRPMSetPoint(40.0 * scale)).Times(1); + EXPECT_CALL(z, addRPMSetPoint(60.0 * scale)).Times(2); for (int ii = 0; ii < 3; ii++) { -- cgit v1.2.3