If temperature rises after ramping to 100% PWM, then stop controlling the fan and set it to full ON.

#599, #595, #593.
pull/610/head
Christopher Young 2017-05-17 17:18:00 -04:00
rodzic 0d146d1747
commit f2c311db6d
1 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -63,19 +63,37 @@ func fanControl(pwmDutyMin int, pin int, tempTarget float32) {
}
})
pwmDuty := 0
tempWhenRampStarted := float32(0.)
for {
if temp > (tempTarget + hysteresis) {
if tempWhenRampStarted < 1. {
tempWhenRampStarted = temp
}
pwmDuty = iMax(iMin(pwmDutyMax, pwmDuty+1), pwmDutyMin)
if pwmDuty == pwmDutyMax {
// At the maximum duty cycle currently.
// Has the temperature increased "substantially" since the ramp-up started?
if temp > (tempWhenRampStarted + hysteresis) {
// Give up. The fan does not like the PWM control.
break
}
}
} else if temp < (tempTarget - hysteresis) {
pwmDuty = iMax(pwmDuty-1, 0)
if pwmDuty < pwmDutyMin {
pwmDuty = 0
tempWhenRampStarted = 0.
}
}
//log.Println(temp, " ", pwmDuty)
C.pwmWrite(cPin, C.int(pwmDuty))
time.Sleep(delaySeconds * time.Second)
}
// Default to "ON".
C.pinMode(cPin, C.OUTPUT)
C.digitalWrite(cPin, C.HIGH)
}
// Service has embedded daemon