Bitcoin Forum
May 01, 2024, 09:29:04 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Two useful perl scripts - part 1 (fan speed)  (Read 1056 times)
marvinmartian (OP)
Full Member
***
Offline Offline

Activity: 224
Merit: 100



View Profile
July 10, 2011, 03:53:55 PM
 #1

Been wanting to share these for a while.  My miners wouldn't be able to run at peak efficiency without them.  Hopefully they'll be of use to others as well.

1.  Fan speed script

I was trying to find a link to this script (not mine) but can't anymore.  Since the header has all the author's info, and GPL2, I'll just post that here.  He did a nice job with it imho.  But as always, USE AT YOUR OWN RISK.  Farming out fan speed and GPU clock settings to another app can be very, very risky.

----- snip -----

#!/usr/bin/perl -w
# 2008 by Bernhard M. Wiedemann <bernhard lsmod.de>
# Licensed under GNU GPL v2 or later

use strict;

# those below default settings mean:
# spin fan at 100% at 80+ C
# spin fan at 8% at 48- C

my %options=qw(hightemp 80 lowtemp 48 highfan 100 lowfan 8 updateinterval 10 debug 0);


sub diag($)
{ print(@_,"\n") if $options{debug} }


sub setfan($)
{
    my($percent)=@_;
    system("aticonfig", "--pplib-cmd", "set fanspeed 0 $percent");
}

sub mydie($)
{
    setfan($options{highfan});
    print (caller(),@_);
    exit 1;
}


sub gettemp()
{
    $_=`aticonfig --adapter=0 --od-gettemperature`;
    if(m/Sensor 0: Temperature - (\d+\.\d+) C/) {

    } else {mydie "bad temp read: $_"}
    return $1
}

$SIG{INT}=$SIG{TERM}=sub{setfan($options{highfan}) ; exit 2;};

open(STDIN, "</dev/null");
if(!$options{debug}) {
    open(STDOUT, ">/dev/null");
    open(STDERR, ">/dev/null");
    if(fork()>0) {exit 0} # background
    if(fork()>0) {exit 0} # background
}

my $trange=$options{hightemp}-$options{lowtemp};
my $frange=$options{highfan}-$options{lowfan};
while(1) {
    my $t=gettemp();
    my $x=($t-$options{lowtemp})/$trange; # number between 0 and 1
    if($x<0) {$x=0}
    if($x>1) {$x=1}
    my $fan=int($x*$frange+$options{lowfan});
    diag "temp at $t";
    diag "setting fan to $fan";
    setfan($fan);
    sleep $options{updateinterval};
}

"... and the geeks shall inherit the earth."
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!