gufus wrote:JimWright wrote:I took the code posted, and revised it slightly to add a midpoint setting.
I tested your midpoint logic and the script failed, your code didn' even start. My code and yours both failed, I'm still using on/off.
I'm doing something wrong (but I can't see it)
I'd be interested in your modified code, maybe PID code eh 
OK, I blame your script, since I used that as a base. LOL
Actually, I think you're setting the temps wrong, based on the original script at /sbin/fan_ctrl.sh. You are taking the entire values return, rather than just the first two characters. Also, your CPU_OFF temp was set higher than the CPU_ON.
So, I just now used the original /sbin/fan_ctrl.sh as a base, and created the following:
#!/bin/sh
CPU_TEMP=`cut -c1-2 /sys/class/hwmon/hwmon2/temp1_input`
DDR_TEMP=`cut -c1-2 /sys/class/hwmon/hwmon1/temp1_input`
WIFI_TEMP=`cut -c1-2 /sys/class/hwmon/hwmon1/temp2_input`
echo "CPU_TEMP = $CPU_TEMP, DDR_TEMP = $DDR_TEMP, WIFI_TEMP = $WIFI_TEMP"
CPU_LOW=55 # Script default is 85
CPU_MID=65 # Script default not specified
CPU_HIGH=80 # Script default is 95
DDR_LOW=55 # Script default is 65
DDR_MID=65 # Script default not specified
DDR_HIGH=70 # Script default is 75
WIFI_LOW=55 # Script default is 100
WIFI_MID=65 # Script default not specified
WIFI_HIGH=75 # Script default is 115
if [ -d /sys/devices/pwm_fan ];then
FAN_CTRL=/sys/devices/pwm_fan/hwmon/hwmon0/pwm1
elif [ -d /sys/devices/platform/pwm_fan ];then
FAN_CTRL=/sys/devices/platform/pwm_fan/hwmon/hwmon0/pwm1
else
exit 0
fi
FAN_SPEED=`cat $FAN_CTRL`
echo "CPU_TEMP = $CPU_TEMP, DDR_TEMP = $DDR_TEMP, WIFI_TEMP = $WIFI_TEMP, FAN = $FAN_SPEED"
if [ "$CPU_TEMP" -ge "$CPU_HIGH" -o "$DDR_TEMP" -ge "$DDR_HIGH" -o "$WIFI_TEMP" -ge "$WIFI_HIGH" ];then
echo "255" > $FAN_CTRL
elif [ "$CPU_TEMP" -ge "$CPU_MID" -o "$DDR_TEMP" -ge "$DDR_MID" -o "$WIFI_TEMP" -ge "$WIFI_MID" ];then
echo "192" > $FAN_CTRL
elif [ "$CPU_TEMP" -ge "$CPU_LOW" -o "$DDR_TEMP" -ge "$DDR_LOW" -o "$WIFI_TEMP" -ge "$WIFI_LOW" ];then
echo "64" > $FAN_CTRL
else
echo "0" > $FAN_CTRL
fi
One thing that I noticed since I last checked this script was that there is a midpoint set, my version actually has 4 setpoints as a result, and the Belkin numbers listed in your script were different than the ones in the the /sbin/fan_ctrl.sh one.
Also, I checked the sensor output, and saw that my running temp was far lower than what would trigger the script, so I lowered the triggers for the fans to kick in. My current values are:
root@OpenWrt:/sbin# sensors
tmp421-i2c-0-4c
Adapter: mv64xxx_i2c adapter
temp1: +44.5 C
temp2: +47.9 C
armada_thermal-virtual-0
Adapter: Virtual device
temp1: +50.8 C
Also, in my script, I'm echoing back the varlables so I can monitor when testing manually, including the current fan speed before any changes. So, fan speed is readable to use for some calculations.
As I mentioned earlier, this script is called on a regular interval and no values are preserved between runs, so collecting a history of values to use in calculations isn't really feasable without creating a data file to store these, without rewriting the script to stay running constantly.
(Last edited by JimWright on 4 Jun 2015, 01:18)