From fd9077bd03d1ea04a8208d76d9c61837d4d2a014 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sun, 8 Jul 2007 10:01:50 +0000 Subject: [PATCH] Use linear interpolation instead of quadratic to choose PWM values. This is simpler and will work better in most cases. For example this should address at least part of ticket #2224. It seems that quadratic was used to lower the average noise level, but I don't think this is a valid reason. The new MINPWM and MAXPWM parameters will also let the user control the noise level if really needed. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4588 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + doc/fancontrol.txt | 6 ++---- prog/pwm/fancontrol | 2 +- prog/pwm/fancontrol.pl | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 645a6baa..0d5eb0e1 100644 --- a/CHANGES +++ b/CHANGES @@ -31,6 +31,7 @@ SVN HEAD Check for configuration file validity Support optional min and max PWM values Better integration with init scripts + Use linear control instead of quadratic Program pwmconfig: Use smaller steps for low PWM values Support optional min and max PWM values Program mkpatch: Include w83627ehf diff --git a/doc/fancontrol.txt b/doc/fancontrol.txt index 25f8afb1..eee5bf49 100644 --- a/doc/fancontrol.txt +++ b/doc/fancontrol.txt @@ -120,16 +120,14 @@ fancontrol first reads its configuration, writes it to arrays and loops its main function. This function gets the temperatures and fanspeeds from kernel driver files and calculates new speeds depending on temperature changes, but only if the temp is between MINTEMP and MAXTEMP. After that, the -new values are written to the pwm outputs. Currently the speed increases -quadratically with rising temperature. This way you won't hear your fans most -of the time at best. +new values are written to the pwm outputs. The pwm value increases +linearly with rising temperature. Planned features rc-scripts for some gnu/linux-distributions smoother regulation (temp interpolation) -other curve styles (linear, exponential) gui for configuration If you have other wishes or want to contribute something, please let me know: diff --git a/prog/pwm/fancontrol b/prog/pwm/fancontrol index 107da10a..448b3d47 100755 --- a/prog/pwm/fancontrol +++ b/prog/pwm/fancontrol @@ -324,7 +324,7 @@ function UpdateFanSpeeds { then pwmval=$maxpwm # over max temp, use defined max pwm else # calculate the new value from temperature and settings - let pwmval="((${tval}-${mint})**2)*(${maxpwm}-${minso})/((${maxt}-${mint})**2)+${minso}" + let pwmval="(${tval}-${mint})*(${maxpwm}-${minso})/(${maxt}-${mint})+${minso}" if [ $pwmpval -eq 0 -o $fanval -eq 0 ] then # if fan was stopped start it using a safe value echo $minsa > $pwmo diff --git a/prog/pwm/fancontrol.pl b/prog/pwm/fancontrol.pl index cb7327bc..fe7f68b4 100755 --- a/prog/pwm/fancontrol.pl +++ b/prog/pwm/fancontrol.pl @@ -390,7 +390,7 @@ sub UpdateFanSpeeds() { $pwmval = MAX; } else { - $pwmval = eval ( ($tval - $mint) / ($maxt - $mint) )**2 ; + $pwmval = eval ( ($tval - $mint) / ($maxt - $mint) ); $pwmval *= (255 - $minso); $pwmval += $minso; $pwmval = int($pwmval);