ジャンル不定の日記です。

lm_sensorsでファンコントロール

今のPCってBIOSにファンコン機能ついてるからPCでファンコンとかしなくなってたが、
仮想通貨のマイニングやってみたら60度越えちゃってたんでlm_sensorsでファンコントロールすることにした。

まず、元々のBIOSのファンコン設定だが、
CPUファンが自動でケースファンが50%出力で固定の設定だった。
ケースファンが回転数上がらない設定だったから、ケースファンが全力出せばもうちょい下げれそう。

BIOSのファンコン設定はlm_sensorsのファンコン設定した後に無効にしたが、そしたらlm_sensorsのデバイス番号が変わっちゃった。
BIOSのファンコンは事前に無効(固定)にしておいた方が良さそう。

lm_sensorsはインストールして、
$ sudo sensors-detect
で全部Enterした。
$ sensors
で温度やファンスピードが見れる。

ちなみに、メーカー製のPC使う人はわからないんじゃないかと思うが、
CPUのファンは普通標準のだから問題ないが、ケースファンは回転数検知できるファンを対応コネクタにつけてないと制御できない。
今回のPCはケースファンコネクタ1個でPWMファン分岐ケーブル使って2ファンを一緒に制御できるようにしてある。

ファンコン設定
$ sudo pwmconfig
# pwmconfig revision $Revision$ ($Date$)
This program will search your sensors for pulse width modulation (pwm)
controls, and test each one to see if it controls a fan on
your motherboard. Note that many motherboards do not have pwm
circuitry installed, even if your sensor chip supports pwm.

We will attempt to briefly stop each fan using the pwm controls.
The program will attempt to restore each fan to full speed
after testing. However, it is ** very important ** that you
physically verify that the fans have been to full speed
after the program has completed.

Found the following devices:
   hwmon0 is k10temp
   hwmon1 is fam15h_power
   hwmon2/device is f71808a
   hwmon3 is radeon

Found the following PWM controls:
   hwmon2/device/pwm1           current value: 255
   hwmon2/device/pwm2           current value: 255
   hwmon2/device/pwm3           current value: 127

Giving the fans some time to reach full speed...
Found the following fan sensors:
   hwmon2/device/fan1_input     current speed: 4373 RPM
   hwmon2/device/fan2_input     current speed: 2431 RPM
   hwmon2/device/fan3_input     current speed: 0 ... skipping!

Warning!!! This program will stop your fans, one at a time,
for approximately 5 seconds each!!!
This may cause your processor temperature to rise!!!
If you do not want to do this hit control-C now!!!
Hit return to continue:
pwmconfigコマンドの使い方がわかりにくかったが、
まずデバイス名が表示される。
hwmon0がk10tempなんで名前的にCPUなのがわかる。(AMDの場合)
BIOSのファンコン有効にしてた時はk10tempがhwmon0じゃなかった。
そして、hwmon2/device/fan3_inputはファンスピードが検知できてない。(ファン繋いでないし、PWMじゃないコネクタと思う。)
hwmon2/device/fan1_inputとhwmon2/device/fan2_inputは検知できてるが、番号的にも速度的にも1がCPUファンで2がケースファン。

なので、今回制御するファンは、
hwmon2/device/fan1_input ←CPUファン
hwmon2/device/fan2_input ←ケースファン
対応するPWMは、
hwmon2/device/pwm1とhwmon2/device/pwm2。
温度はhwmon0のCPU以外にhwmon2/device is f71808aにも温度計が2箇所ついてるが、
どっちのファンもCPU温度で制御することにした。

Testing pwm control hwmon2/device/pwm1 ...
  hwmon2/device/fan1_input ... speed was 4373 now 4249
    no correlation
  hwmon2/device/fan2_input ... speed was 2431 now 2521
    no correlation

No correlations were detected.
There is either no fan connected to the output of hwmon2/device/pwm1,
or the connected fan has no rpm-signal connected to one of
the tested fan sensors. (Note: not all motherboards have
the pwm outputs connected to the fan connectors,
check out the hardware database on http://www.almico.com/forumindex.php)

Did you see/hear a fan stopping during the above test (n)?
pwmconfigの続きでEnter押すと先に進む。
何言ってんだかわからんが、ここで「y」にするとhwmon2/device/pwm1が制御対象になる。
次はhwmon2/device/pwm2の確認になるので再度「y」。
hwmon2/device/pwm3は制御できないので「n」。(yでも無効設定なだけで問題はないのかも?)

Testing is complete.
Please verify that all fans have returned to their normal speed.

The fancontrol script can automatically respond to temperature changes
of your system by changing fanspeeds.
Do you want to set up its configuration file now (y)?
What should be the path to your fancontrol config file (/etc/fancontrol)?
Loading configuration from /etc/fancontrol ...

Select fan output to configure, or other action:
1) hwmon2/device/pwm2  3) Change INTERVAL     5) Save and quit
2) hwmon2/device/pwm1  4) Just quit           6) Show configuration
select (1-n):
制御対象のファンを選択し終わったら、またしても何言ってんだか・・・
だが、1と2には選択したPWMが表示されてるので、この2つを設定。

Devices:
hwmon0 is k10temp
hwmon1 is fam15h_power
hwmon2/device is f71808a
hwmon3 is radeon

Current temperature readings are as follows:
hwmon0/temp1_input      47
hwmon2/device/temp1_input       128
hwmon2/device/temp2_input       48
hwmon3/temp1_input      46

Select a temperature sensor as source for hwmon2/device/pwm1:
1) hwmon0/temp1_input
2) hwmon2/device/temp1_input
3) hwmon2/device/temp2_input
4) hwmon3/temp1_input
5) None (Do not affect this PWM output)
select (1-n):
デバイスと取得可能な温度計が表示される。
今回はk10temp(CPU温度)で制御するんで正解は「1」
hwmon2/device/pwm2の方も同じく設定して、
5) Save and quitすると制御温度と回転数聞いてくるが、とりあえず全部Enter。
/etc/fancontrolに設定ファイルが出来上がる。

# Configuration file generated by pwmconfig, changes will be lost
INTERVAL=10
DEVPATH=hwmon0=devices/pci0000:00/0000:00:18.3 hwmon2=devices/platform/f71882fg.2560
DEVNAME=hwmon0=k10temp hwmon2=f71808a
FCTEMPS=hwmon2/device/pwm1=hwmon0/temp1_input hwmon2/device/pwm2=hwmon0/temp1_input
FCFANS=hwmon2/device/pwm1= hwmon2/device/pwm2=
MINTEMP=hwmon2/device/pwm1=20 hwmon2/device/pwm2=20
MAXTEMP=hwmon2/device/pwm1=60 hwmon2/device/pwm2=60
MINSTART=hwmon2/device/pwm1=150 hwmon2/device/pwm2=150
MINSTOP=hwmon2/device/pwm1=100 hwmon2/device/pwm2=100
できあがった設定ファイルだが、MINTEMPが20だと20℃超えるとファン回転数が上がり始める。
温度低すぎるんでMINTEMPは40にした。
パット見で全くわからん設定ファイルだが、考えながらじっくり見ればなんとなく・・・

MINTEMP設定温度以下でファン最低出力。
MAXTEMP設定温度以上でファン最高出力。
その間は徐々に変わっていく感じ。
数値は℃。

PWMはMAXが255。
MINSTOPが最低値だが、回転数が低すぎるとモーターは回れないので0に近いと止まる。止める運用もあるのかもしれないが。
MINSTARTは止まっちゃってる状態からの始動出力。止まってる時は慣性がないから始動にはパワーが必要。

ケースファンの回転数が温度に応じて上がるようになって50どちょいに収まった。
が、もう夜だから室温もだいぶ違う気が・・・

まあ、温度に連動してケースファンが頑張るようになったから元の状態よりは温度上がりにくいはず。
60℃で全力出すはずだから、それ以上温度上がるようならどうしようもない。