From e6ee99874a233ceffbfd763f8fba83ac9339917c Mon Sep 17 00:00:00 2001 From: Tim Connors Date: Wed, 22 Jan 2025 18:03:38 +1100 Subject: [PATCH] fixed broken logic introduced in e29a05f Sorry people, when I rearranged the logic in e29a05f for: $desired_temp1 < $weighted_temp < $desired_temp2 I ORed instead of ANDed, but didn't test it until I just pushed out my ansible config to that host right now, several months later! --- fan-speed-control.pl | 10 +++++++--- readme.md | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fan-speed-control.pl b/fan-speed-control.pl index 778cab4..7d64f24 100755 --- a/fan-speed-control.pl +++ b/fan-speed-control.pl @@ -144,20 +144,24 @@ sub set_fans_servo { # which we multiply later to be ranged roughly # between 0-100% of # ($static_speed_low - $static_speed_high) - if ($weighted_temp > $base_temp and - $weighted_temp < $desired_temp1) { + if (($weighted_temp > $base_temp) and + ($weighted_temp < $desired_temp1)) { # slope m = (y2-y1)/(x2-x1) # y - y1 = (x-x1)(y2-y1)/(x2-x1) # y1 = 0 ; x1 = base_temp ; y2 = demand1 ; x2 = desired_temp1 # x = weighted_temp $demand = 0 + ($weighted_temp - $base_temp ) * ($demand1 - 0 )/($desired_temp1 - $base_temp ); - } elsif (($weighted_temp >= $desired_temp1) or ($weighted_temp < $desired_temp2)) { + } elsif (($weighted_temp >= $desired_temp1) and + ($weighted_temp < $desired_temp2)) { # y1 = demand1 ; x1 = desired_temp1 ; y2 = demand2 ; x2 = desired_temp2 $demand = $demand1 + ($weighted_temp - $desired_temp1) * ($demand2 - $demand1)/($desired_temp2 - $desired_temp1); } elsif ($weighted_temp >= $desired_temp2) { # y1 = demand2 ; x1 = desired_temp2 ; y2 = demand3 ; x2 = desired_temp3 # demand will increase above $demand3 for temps above $desired_temp3, linearly, until we cap it below $demand = $demand2 + ($weighted_temp - $desired_temp2) * ($demand3 - $demand2)/($desired_temp3 - $desired_temp2); + } else { + # the only possibility left is $weighted_temp < $base_temp + # which we've already decided is demand=0 } printf "demand(%0.2f)", $demand if $print_stats; $demand = int($static_speed_low + $demand/100*($static_speed_high-$static_speed_low)); diff --git a/readme.md b/readme.md index 399be1b..ebe182d 100755 --- a/readme.md +++ b/readme.md @@ -93,7 +93,10 @@ Jan 03 02:59:23 pve1 fan-speed-control.pl[3648151]: --> disable dynamic fan cont > sensors > sudo hddtemp /dev/sd? ``` -Whatever. Note that hddtemps and inlet (ambient air *intake*, which measures your room temperature) temperature are polled less frequently than coretemps, given they don't change as rapidly and are more expensive to read. +Whatever. Note that hddtemps and inlet (ambient air *intake*, which +measures your room temperature) temperature are polled less frequently +than coretemps, given they don't change as rapidly and are more expensive +to read. This script monitors the ambient air temperature (you will likely need to modify the $ipmi_inlet_sensorname variable to find the correct @@ -108,7 +111,7 @@ quickly towards full speed much beyond that. It also has an ambient air temperature threshold of 32degrees where it gives up and delegates control back to the firmware. The ambient temperature reading doesn't normally affect how hard your fans have to spin, and is only used to -fallback to iDRAC mode so that your machine doesn't explode if eg., you've +fallback to iDRAC mode so that your machine doesn't explode if eg., you've had an air-conditioning failure. Don't run your bedroom IT closet at 32 degrees yeah? @@ -129,7 +132,7 @@ Historical notes and stuff it's partially relying on behind the scenes, and if y 1. Enable IPMI in iDrac 2. Install ipmitool on linux, win or mac os -3. Run the following command to issue IPMI commands: +3. Run the following command to issue IPMI commands: `ipmitool -I lanplus -H -U root -P ` (we don't use lanplus though) @@ -175,4 +178,4 @@ TLDR; I take _NO_ responsibility if you mess up anything. ***** -All of this was inspired by [this Reddit post](https://www.reddit.com/r/homelab/comments/72qust/r510_noise/dnkofsv/) by /u/whitekidney +All of this was inspired by [this Reddit post](https://www.reddit.com/r/homelab/comments/72qust/r510_noise/dnkofsv/) by /u/whitekidney