OpenCorsairLink in a jail to control fans?

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I've really enjoyed the proces of getting it to work and I followed your instructions for the Grafana graphs.
Great!

Do you think there's anyway I can break that cycle and smooth out the curve so it doesn't keep raising and lowering the FanDuty but keeps it at a more stable percentage?
The fans are controlled by the PID values, but there are also the "Resting Points" (I just made that term up to cover these values from the config):

Code:
#---------------------------------------------------------------------------
## CPU FAN DUTY LEVELS
## These levels are used to control the CPU fans
#---------------------------------------------------------------------------
my $fan_duty_high = 100;    # percentage on, ie 100% is full speed.
my $fan_duty_med  = 80;
my $fan_duty_low  = 55;

#---------------------------------------------------------------------------
## HD FAN DUTY LEVELS
## These levels are used to control the HD fans
#---------------------------------------------------------------------------
my $hd_fan_duty_high     = 100;    # percentage on, ie 100% is full speed.
my $hd_fan_duty_med_high = 80;
my $hd_fan_duty_med_low  = 50;
my $hd_fan_duty_low      = 30;     # some 120mm fans stall below 30.


If you can find the magic numbers there, the fan will happily sit at or near one of those numbers with hardly any fluctuation.

I would expect that the ideal numbers for a given system will vary based on ambient temperature, airflow and average workload... if your fans can do 800RPM and keep the disks below your target temperature, the med_low setting should be the % that gets your fans to spin at 800RPM. (as an example).
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
I would expect that the ideal numbers for a given system will vary based on ambient temperature, airflow and average workload... if your fans can do 800RPM and keep the disks below your target temperature, the med_low setting should be the % that gets your fans to spin at 800RPM. (as an example).

Still not much succes and I feel like it's getting worse. I've tried these two different settings of the HD FAN DUTY LEVELS.

Code:
my $hd_fan_duty_high     = 100;    # percentage on, ie 100% is full speed.
my $hd_fan_duty_med_high = 60;
my $hd_fan_duty_med_low  = 40;
my $hd_fan_duty_low      = 20;     # some 120mm fans stall below 30.

Code:
my $hd_fan_duty_high     = 100;    # percentage on, ie 100% is full speed.
my $hd_fan_duty_med_high = 80;
my $hd_fan_duty_med_low  = 60;
my $hd_fan_duty_low      = 30;     # some 120mm fans stall below 30.

Still looking like this :( do yo have any other suggestions for me?

1610745614610.png
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Is there a setting to set the granularity of the temperature measurements? You're scaling up at every degree increase. You probably want to only scale up by 5 or so degrees.
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
Is there a setting to set the granularity of the temperature measurements? You're scaling up at every degree increase. You probably want to only scale up by 5 or so degrees.

This is the script that controls everything that I'm running:


Do you mean the frequency at which the HDD temperatures are measured? There is this setting:

Code:
#---------------------------------------------------------------------------
## HD POLLING INTERVAL
## The controller will only poll the harddrives periodically. Since hard
## drives change temperature slowly this is a good thing. 180 seconds is a
## good value.
#---------------------------------------------------------------------------
my $hd_polling_interval = 90;    # seconds

I have this set to 120 seconds currently.

And there's the configuration file which I've discussed before with @sretalla but I don't understand the 3 middle values: Kp, Ki and Kd but he mentioned those values should be fine.

Code:
our $config_num_disks = 2; # number of warmest disks to use for average temperature
our $config_Ta = 36.0;       # target average temperature for X warmest disks
our $config_Kp = 8/3;
our $config_Ki = 0;
our $config_Kd = 18;
our $config_hd_fan_start = 36; # HD fan duty cycle when script starts
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Those are the PID control constants, which govern the hysteresis or lag of the fan control. See https://robotics.stackexchange.com/...i-and-kd-affect-the-heading-of-a-differential for a good introduction to the concepts. In this case, Kp is how responsive the PID controller should be to temperature changes, and Kd is how fast the ramp-up rate should be. You can try adjusting these to reduce the sensitivity to single degree changes.
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
Those are the PID control constants, which govern the hysteresis or lag of the fan control. See https://robotics.stackexchange.com/...i-and-kd-affect-the-heading-of-a-differential for a good introduction to the concepts. In this case, Kp is how responsive the PID controller should be to temperature changes, and Kd is how fast the ramp-up rate should be. You can try adjusting these to reduce the sensitivity to single degree changes.

OK, I will try to experiment a bit with these values. Unfortunately my understanding of this material is not that great and my math skills are severely lacking. I think I have a very basic grasp of this. Does the polling interval have any influence on the PID values and the way the changes are made? I increased it from 90 to 120 seconds, should I decrease it again?
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
The polling rate affects the averaging over time, but there's very little difference between 90 and 120 seconds. I'd put things back to the default rate.
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
This guy explained it really well for me to understand what is happening my controller.


My configuration file is currently like this:

Code:
our $config_num_disks = 2;     # number of warmest disks to use for average temperature
our $config_Ta = 36.0;         # target average temperature for X warmest disks
our $config_Kp = 6/3;
our $config_Ki = 0;
our $config_Kd = 16;
our $config_hd_fan_start = 48; # HD fan duty cycle when script starts


And my measurement interval is 90 seconds.

It looks better now but I still see a couple of moments where the duty cycle is going up and down.

It's not where I want it to be, maybe I should starting using the Integral part also? Not sure, maybe lower the Kd value a bit more? Suggestions are welcome.

1610788163765.png
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
How about increasing the number of disks to average?
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
Well, I don't want to do that I think. I only have 4 disks and I want to use the warmest or 2 most warmest disks to make sure they don't go over 40°C which is the max allowed temperature I've set. It's always been the case that ada0 is about 4-5°C cooler than ada2. This is the log right now.

Code:
PID Fan Controller Log  ---  Target 2 Disk HD Temperature = 36.00 deg C  ---  PID Control Gains: Kp =  2.000, Ki =  0.000, Kd =  16.0
                               Max   Ave  Temp   Fan   Fan  Fan %   CPU    P      I      D      Fan
2021-01-16 da0  da1  da2  da3 Temp  Temp   Err  Mode   RPM Old/New Temp  Corr   Corr   Corr    Duty
10:00:34   33   35   37   35  ^37  36.00  0.00   n/a   757  54/49   32   0.00   0.00   -5.33   48.67%
10:02:03   33   35   37   35  ^37  36.00  0.00   n/a   757  49/49   31   0.00   0.00    0.00   48.67%
10:03:34   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   31   0.00   0.00    0.00   48.67%
10:05:03   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   31   0.00   0.00    0.00   48.67%
10:06:33   33   35   37   35  ^37  36.00  0.00   n/a   757  49/49   31   0.00   0.00    0.00   48.67%
10:08:04   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   31   0.00   0.00    0.00   48.67%
10:09:34   33   35   37   35  ^37  36.00  0.00   n/a   757  49/49   31   0.00   0.00    0.00   48.67%
10:11:03   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   32   0.00   0.00    0.00   48.67%
10:12:34   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   32   0.00   0.00    0.00   48.67%
10:14:04   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   32   0.00   0.00    0.00   48.67%
10:15:34   33   35   37   35  ^37  36.00  0.00   n/a   757  49/49   31   0.00   0.00    0.00   48.67%
10:17:04   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   32   0.00   0.00    0.00   48.67%
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Ok, try lowering Kd another 1 or 2 steps, and maybe increasing Ki by 1.
 

Mannekino

Patron
Joined
Nov 14, 2012
Messages
332
I've done a little experiment today by raising the ambient temperature in the room my TrueNAS server is in. I increased it from about 18.5°C to 23.5°C and below are the results. There is still some overshoot/oscillation I'd like to get rid off but it's getting better. Any further suggestions for tuning?

I am satisfied with the response to the raise of ambient temperature, this would be a realistic scenario in the summer when it can easily get 24+°C in my home. I'm measuring the HDD temps at 120 seconds interval. I currently have the following settings.

Code:
our $config_num_disks = 2;     # number of warmest disks to use for average temperature
our $config_Ta = 36.0;         # target average temperature for X warmest disks
our $config_Kp = 2;
our $config_Ki = 1;
our $config_Kd = 8;
our $config_hd_fan_start = 48; # HD fan duty cycle when script starts

1610820185436.png

And the log for the last hour

Code:
PID Fan Controller Log  ---  Target 2 Disk HD Temperature = 36.00 deg C  ---  PID Control Gains: Kp =  2.000, Ki =  1.000, Kd =   8.0
                               Max   Ave  Temp   Fan   Fan  Fan %   CPU    P      I      D      Fan
2021-01-16 da0  da1  da2  da3 Temp  Temp   Err  Mode   RPM Old/New Temp  Corr   Corr   Corr    Duty
18:01:39   34   35   36   36  ^36  36.00  0.00   n/a   805  52/52   33   0.00   0.00    0.00   52.00%
18:03:38   34   35   37   36  ^37  36.50  0.50   n/a   877  52/57   33   2.00   1.00    2.00   57.00%
18:05:39   34   35   37   36  ^37  36.50  0.50   n/a   923  57/60   38   2.00   1.00    0.00   60.00%
18:07:39   34   35   37   36  ^37  36.50  0.50   n/a   968  60/63   33   2.00   1.00    0.00   63.00%
18:09:39   34   35   36   36  ^36  36.00  0.00   n/a   934  63/61   31   0.00   0.00   -2.00   61.00%
18:11:39   34   35   36   35  ^36  35.50 -0.50   n/a   866  61/56   32  -2.00  -1.00   -2.00   56.00%
18:13:39   34   35   36   35  ^36  35.50 -0.50   n/a   818  56/53   32  -2.00  -1.00    0.00   53.00%
18:15:38   34   35   36   35  ^36  35.50 -0.50   n/a   772  53/50   32  -2.00  -1.00    0.00   50.00%
18:17:39   34   35   36   35  ^36  35.50 -0.50   n/a   724  50/47   33  -2.00  -1.00    0.00   47.00%
18:19:39   34   35   37   36  ^37  36.50  0.50   n/a   830  47/54   32   2.00   1.00    4.00   54.00%
18:21:38   34   35   37   36  ^37  36.50  0.50   n/a   877  54/57   32   2.00   1.00    0.00   57.00%
18:23:39   34   35   37   36  ^37  36.50  0.50   n/a   921  57/60   33   2.00   1.00    0.00   60.00%
18:25:39   33   35   36   35  ^36  35.50 -0.50   n/a   817  60/53   32  -2.00  -1.00   -4.00   53.00%
18:27:39   33   35   36   35  ^36  35.50 -0.50   n/a   772  53/50   31  -2.00  -1.00    0.00   50.00%
18:29:39   33   35   36   35  ^36  35.50 -0.50   n/a   723  50/47   32  -2.00  -1.00    0.00   47.00%
18:31:39   34   35   37   35  ^37  36.00  0.00   n/a   758  47/49   32   0.00   0.00    2.00   49.00%
18:33:39   34   35   37   36  ^37  36.50  0.50   n/a   830  49/54   31   2.00   1.00    2.00   54.00%
18:35:39   33   35   37   36  ^37  36.50  0.50   n/a   874  54/57   31   2.00   1.00    0.00   57.00%
18:37:39   33   35   37   35  ^37  36.00  0.00   n/a   842  57/55   31   0.00   0.00   -2.00   55.00%
18:39:39   33   35   36   35  ^36  35.50 -0.50   n/a   771  55/50   33  -2.00  -1.00   -2.00   50.00%
18:41:39   33   35   36   35  ^36  35.50 -0.50   n/a   723  50/47   31  -2.00  -1.00    0.00   47.00%
18:43:39   33   35   37   35  ^37  36.00  0.00   n/a   759  47/49   33   0.00   0.00    2.00   49.00%
18:45:38   33   35   37   36  ^37  36.50  0.50   n/a   829  49/54   31   2.00   1.00    2.00   54.00%
18:47:38   33   35   37   36  ^37  36.50  0.50   n/a   875  54/57   32   2.00   1.00    0.00   57.00%
18:49:38   33   35   36   35  ^36  35.50 -0.50   n/a   771  57/50   37  -2.00  -1.00   -4.00   50.00%
18:51:39   33   35   36   35  ^36  35.50 -0.50   n/a   723  50/47   33  -2.00  -1.00    0.00   47.00%
18:53:39   33   35   37   35  ^37  36.00  0.00   n/a   760  47/49   32   0.00   0.00    2.00   49.00%
18:55:39   33   35   37   36  ^37  36.50  0.50   n/a   829  49/54   31   2.00   1.00    2.00   54.00%
18:57:39   33   35   37   35  ^37  36.00  0.00   n/a   802  54/52   32   0.00   0.00   -2.00   52.00%
18:59:38   33   35   36   35  ^36  35.50 -0.50   n/a   723  52/47   32  -2.00  -1.00   -2.00   47.00%
19:01:39   33   35   37   35  ^37  36.00  0.00   n/a   758  47/49   31   0.00   0.00    2.00   49.00%
19:03:39   33   35   37   35  ^37  36.00  0.00   n/a   759  49/49   32   0.00   0.00    0.00   49.00%
19:05:38   33   35   37   35  ^37  36.00  0.00   n/a   759  49/49   33   0.00   0.00    0.00   49.00%
19:07:39   33   35   37   35  ^37  36.00  0.00   n/a   758  49/49   31   0.00   0.00    0.00   49.00%
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
do you know if the OpenCorsairLink.elf binary is capable of controlling a Corsair H150i PRO AIO?
I'm not in possession of one to test, so can't say for sure, but what I can say is that I see the last developer commit on a bunch of the files notes that support for the H100i was added (but is READ ONLY).

By all means, test it, but I expect you won't be able to use it to adjust fan speeds. No harm in trying though.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
I should mention here that I've made an attempt at making this compatible with SCALE:


I also already made both the Linux and FreeBSD binaries of OpenCorsairLink available in this post:
 

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
As TS I stumbled on to my own topic of 2018 :cool:...
Since I want to upgrade my systems to TrueNas Scale... and use the original "fanscript" for my current TrueNas Core systems (Both running on supermicro mobo's) , I was wondering what would be best to use in scale:
The OpencorsairLink way (Which seems to be abandonnend)... or the NAS_FAN_Control script...
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
My 2 github repositories are there for different reasons...

OpenCorsairLink is a binary (in C++) that communicates with the Corsair Commander Pro or some other Corsair devices over USB HID control.

It's that binary which is used (if needed) by my fanscript (the other github repo), still works fine even though the original developer stopped supporting it.

If you're running a Supermicro board with IPMI, then you don't need to concern yourself with the OpenCorsairLink one as you don't need it with the script in supermicro mode.
 
Last edited:

Platter7

Dabbler
Joined
Sep 22, 2018
Messages
35
My 2 github repositories are there for different reasons...

OpenCorsairLink is a binary (in C++) that communicates with the Corsair Commander Pro or some other Corsair devices over USB HID control.

It's that binary which is used (if needed) by my fanscript (the other github repo), still works fine even though the original developer stopped supporting it.

If you're running a Supermicro board with IPMI, then you don't need to concern yourself with the OpenCorsairLink one as you don't need it with the script in supermicro mode.
It was clear to me that there is some extra hardware involved in the Opencorsairlink/Corsair commander Pro route... but I thought maybe there are some reasons to choose one above the other... such as better cooling results, more easy to set up and maintain/adjust, but also... the commander pro can controle 6 individual fans vs 2 zones in the fanscript for supermicro boards...
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
The commander pro has some up-sides in terms of the 6 connections and 4 temperature sensors built in, but if all you want is to control disk fans and CPU extractors, the supermicro mode does just fine at that.

Also, if you're using the supermicro IPMI, you have your choice of 5 or 6 scripts floating around the forums to use without needing the mods I did... although what I did probably does a fine job for supermicro too.

I only created/use it because I don't have a board that supports fan control through its IPMI and need the Commander Pro to get any software control over fan speed to keep it quiet.
 
Top