From a9d9c60b6aa2f38f57090d809c9afa115bc50479 Mon Sep 17 00:00:00 2001 From: jamesgo <> Date: Wed, 14 Dec 2016 17:22:30 +0000 Subject: [PATCH] 93_PWMR.pm : fix adjust rounding of PVal and newpulsePID git-svn-id: https://svn.fhem.de/fhem/trunk@12775 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/93_PWMR.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fhem/FHEM/93_PWMR.pm b/fhem/FHEM/93_PWMR.pm index aef144326..0e8a7d35f 100644 --- a/fhem/FHEM/93_PWMR.pm +++ b/fhem/FHEM/93_PWMR.pm @@ -41,6 +41,7 @@ # 16.11.16 GA fix format desired-temp with one digit after the decimal point # 17.11.16 GA add internals for configuration parameters: p_factor, p_tsensor, p_actor, p_window, p_pid # 11.12.16 GA add alternative PID calculation, selectable by usePID=2, implementation from user Albatros_ +# 14.12.16 GA fix adjust rounding of PVal and newpulsePID # module for PWM (Pulse Width Modulation) calculation @@ -1094,6 +1095,7 @@ PWMR_ReadRoom(@) my $IVal = $ISum; my $DVal = $room->{c_PID_DFactor} * ($room->{h_deltaTemp_D} - $room->{h_deltaTemp}); + $PVal = sprintf ("%.4f", $PVal); $IVal = minNum (1, sprintf ("%.4f", $IVal)); $DVal = minNum (1, sprintf ("%.4f", $DVal)); @@ -1101,8 +1103,8 @@ PWMR_ReadRoom(@) my $newpulsePID = ($PVal + $IVal + $DVal); - $newpulsePID = minNum ($MaxPulse, sprintf ("%.4f", $newpulsePID)); - $newpulsePID = maxNum (0, sprintf ("%.4f", $newpulsePID)); + $newpulsePID = minNum ($MaxPulse, sprintf ("%.2f", $newpulsePID)); + $newpulsePID = maxNum (0, sprintf ("%.2f", $newpulsePID)); my $PWMPulsePID = $newpulsePID * 100; my $PWMOnTimePID = sprintf ("%02s:%02s", int ($newpulsePID * $cycletime / 60), ($newpulsePID * $cycletime) % 60);