Skip to content

Commit 7d04087

Browse files
committed
Test related changes
1 parent 85b476b commit 7d04087

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pwm-fan.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LOGISTIC_TEMP_CRITICAL=75
3333
LOGISTIC_a=1
3434
LOGISTIC_b=10
3535
# uncomment and edit PID_THERMAL_IDEAL to set a fixed IDEAL temperature for the PID controller;
36-
# otherwise, the initial temperature after startup (+3°C) is used as reference.
36+
# otherwise, the initial temperature after startup is used as reference.
3737
#PID_THERMAL_IDEAL=45
3838
# https://en.wikipedia.org/wiki/PID_controller#Loop_tuning
3939
PID_Kp=$((DEFAULT_PERIOD/200))
@@ -283,7 +283,7 @@ function_pid () {
283283
controller_pid () {
284284
# i_error cannot be local to be cumulative since it was first declared.
285285
local p_error d_error model duty_cycle
286-
p_error="$((${TEMPS[-1]}-${PID_THERMAL_IDEAL:-$((THERMAL_INITIAL+3))}))"
286+
p_error="$((${TEMPS[-1]}-${PID_THERMAL_IDEAL:-$((THERMAL_INITIAL))}))"
287287
i_error="$((${i_error:-0}+p_error))"
288288
d_error="$((${TEMPS[-1]}-${TEMPS[-2]}))"
289289
# TODO: Kp, Ki, and Kd could be auto tunned here; currently, they are not declared and PID_ vars are used.
@@ -293,8 +293,12 @@ controller_pid () {
293293
# bound to duty cycle thresholds first in case model-based value is outside the valid range
294294
if [[ $((duty_cycle+model)) -lt "${DC_ABS_THRESH[0]}" ]]; then
295295
echo "${DC_ABS_THRESH[0]}" 2> /dev/null > "$CHANNEL_FOLDER"'duty_cycle'
296+
# reset i_error to prevent from acumulating further
297+
i_error=0
296298
elif [[ $((duty_cycle+model)) -gt "${DC_ABS_THRESH[-1]}" ]]; then
297299
echo "${DC_ABS_THRESH[-1]}" 2> /dev/null > "$CHANNEL_FOLDER"'duty_cycle'
300+
# reset i_error to prevent from acumulating further
301+
i_error=0
298302
else
299303
echo $((duty_cycle+model)) 2> /dev/null > "$CHANNEL_FOLDER"'duty_cycle'
300304
fi

0 commit comments

Comments
 (0)