PINE64

Full Version: Tutorial:How to Configure ATS Fan control
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Hello all,
I told you that I would create a tutorial about ATS Configuration, and here it is( sorry for the late on this.. ).

You need a supported Kernel for this to work( at least you need kernel 4.4.132-1083 ).
But the one bellow will work for sure:
Code:
apt-get update
apt-get install linux-image-4.4.138-1097-rockchip-ayufan-gb5128c0a1684 linux-headers-4.4.138-1097-rockchip-ayufan-gb5128c0a1684 linux-firmware-image-4.4.138-1097-rockchip-ayufan-gb5128c0a1684
reboot

This tutorial is about the version 0.2.0 ( Install Point 2. or 3.  ), it is updated with the status of the project..

So please refer only to this first comment,
Some of comments below could be outdated( as the project is been updated.. )..



1) ATS, has a configuration file '/etc/ats.conf'

Code:
SYSTEM = {
    BOARD = {
        NAME    = "ROCKPRO64",
        CPU    = "RK3399"
    },

    THERMAL0_CTL    = "/sys/class/thermal/thermal_zone0/temp",
    THERMAL1_CTL    = "/sys/class/thermal/thermal_zone1/temp",
    PWM_CTL        = "/sys/class/hwmon/hwmon0/pwm1",

    MAX_CONTINUOUS_THERMAL_TEMP    = 60,
    MIN_CONTINUOUS_THERMAL_TEMP    = 40,

    MAX_PWM                = 255,
    MIN_PWM                = 40,

    ALWAYS_ON            = false,

    PROFILE_NAME            = "profile0",
    PROFILE_NR            = 0
}
return SYSTEM

This File will define when ATS is active or not,
IF fan is always on, and the max power applied...

The values above are the default ones..

THERMAL0_CTL - CPU Thermal SysFs Control
THERMAL1_CTL - GPU Thermal SysFs Control
PWM_CTL      - Power Control

MAX_CONTINUOUS_THERMAL_TEMP - Maximum Temperature were ATS adjust Fan power [ -20, 70 [,
                              Above this, power is always Maximum..
MIN_CONTINUOUS_THERMAL_TEMPMinimum Temperature were ATS adjust Fan power [ -20, 70 [,
                              Bellow this, power is always Off.

MAX_PWM - Max PWM Fan Power ] 0, 255 ], above 255 ATS will automatically assign value 255, and bellow 0, the same.
MIN_PWMMin PWM Fan Power [ 0, 255 [, bellow 0 ATS will automatically assign value 40, and above 254, the same.

ALWAYS_ON - Tell ATS when Fan should be ON/OFF { true, false },
          - true, if you want the Fan always ON.
          - false,if you want the Fan Cycling ON/OFF,
            In this case, the algorithm works always in a 2 steps way( Time for Fan on, and Time for Fan off ):
            - Timer for Fan ON, will increase with temperature rising, or decrease when temperature fall..
            - Timer for Fan OFF, will decrease with temperature rising, or increase when temperature fall.. 


The values bellow( introduced in version 0.1.8 ), probably will be scratched out, because its almost impossible to create profiles with so different configurations any one has( different heatsinks, different Fans, different Humidity/Temperatures around the globe... ).

Instead, the controls above, would be better,( don't delete them because the code needs to be adjusted first for that..) 

PROFILE_NAME - The name of the profile
PROFILE_NR   - Profile number


2) A Practical Case..

Imagine you want max power at 100, the Fan always ON, and max power( 100 ) to be reached at 65°C:

Code:
SYSTEM = {
    BOARD = {
        NAME    = "ROCKPRO64",
        CPU    = "RK3399"
    },

    THERMAL0_CTL    = "/sys/class/thermal/thermal_zone0/temp",
    THERMAL1_CTL    = "/sys/class/thermal/thermal_zone1/temp",
    PWM_CTL        = "/sys/class/hwmon/hwmon0/pwm1",

    MAX_CONTINUOUS_THERMAL_TEMP    = 65,
    MIN_CONTINUOUS_THERMAL_TEMP    = 40,

    MAX_PWM                = 100,
    MIN_PWM                = 40,

    ALWAYS_ON            = true,

    PROFILE_NAME            = "profile0",
    PROFILE_NR            = 0
}
return SYSTEM



3) Stop ATS, and start it again( new values will be read ).

Code:
service ats stop && service ats start



4) Check values applied,
   Start ats in test mode:

Code:
[email protected]:~# ats -t
info:'SYSTEM' Table
info:    'BOARD' Table
info:        'NAME' = ROCKPRO64
info:        'CPU'  = RK3399
info:    'THERMAL0_CTL' = /sys/class/thermal/thermal_zone0/temp
info:    'THERMAL1_CTL' = /sys/class/thermal/thermal_zone1/temp
info:    'PWM_CTL'      = /sys/class/hwmon/hwmon0/pwm1
info:    'MAX_CONTINUOUS_THERMAL_TEMP' = 65
info:    'MIN_CONTINUOUS_THERMAL_TEMP' = 40
info:    'MAX_PWM' = 100
info:    'MIN_PWM' = 40
info:    'ALWAYS_ON' = true
info:    'PROFILE_NAME' = profile0
info:    'PROFILE'      = 0
info:'Pratio' timers
info:    'Pratio[ -20 - 40 [' = 0
info:    'Pratio[ 40 ]'       = 40
info:    'Pratio[ 41 ]'       = 42
info:    'Pratio[ 42 ]'       = 44
info:    'Pratio[ 43 ]'       = 47
info:    'Pratio[ 44 ]'       = 49
info:    'Pratio[ 45 ]'       = 52
info:    'Pratio[ 46 ]'       = 54
info:    'Pratio[ 47 ]'       = 56
info:    'Pratio[ 48 ]'       = 59
info:    'Pratio[ 49 ]'       = 61
info:    'Pratio[ 50 ]'       = 64
info:    'Pratio[ 51 ]'       = 66
info:    'Pratio[ 52 ]'       = 68
info:    'Pratio[ 53 ]'       = 71
info:    'Pratio[ 54 ]'       = 73
info:    'Pratio[ 55 ]'       = 76
info:    'Pratio[ 56 ]'       = 78
info:    'Pratio[ 57 ]'       = 80
info:    'Pratio[ 58 ]'       = 83
info:    'Pratio[ 59 ]'       = 85
info:    'Pratio[ 60 ]'       = 88
info:    'Pratio[ 61 ]'       = 90
info:    'Pratio[ 62 ]'       = 92
info:    'Pratio[ 63 ]'       = 95
info:    'Pratio[ 64 ]'       = 97
info:    'Pratio[ 65 ]'       = 100
info:    'Pratio[ 65 - 70 ['  = 255
Stop ATS Service first [ service ats stop ]..

Here you can see at end:
'Stop ATS Service first [ service ats stop ]..'

No problem,
When you started ats in test mode, it detected that Service launched in 3) was already running..

So it report the config, and exit from test mode( The Service launched in 3) continues running, as expected )..
Its nice when you wanted to know what values are configured for example..

That's it!!
Hope you find a good tuning for your Fan/Cooler. Shy

Best Regards,
(12-12-2018, 09:13 AM)tuxd3v Wrote: [ -> ]Hello all,
I told you that I would create a tutorial about ATS Configuration, and here it is( sorry for the late on this.. ).

Hello, please help me.
I use a RockPro64 4Gb.


Code:
[email protected]:~# uname -a
Linux rockpro64 4.4.138-1094-rockchip-ayufan-gf13a8a9a4eee #1 SMP Thu Aug 9 20:29:55 UTC 2018 aarch64 GNU/Linux

I installed by these instructions.
  1. apt-get install lua5.3 lua5.3-dev luarocks gcc make
  2. ln -s /usr/bin/lua5.3 /usr/bin/lua
  3. luarocks build https://raw.githubusercontent.com/tuxd3v...8.rockspec
Code:
[email protected]:~# ats -v
ATS - .. Active Termal Service..
   - .. Version: 0.1.7

[email protected]:~# service ats status
● ats.service - ATS - Active Thermal Service
  Loaded: loaded (/lib/systemd/system/ats.service; enabled; vendor preset: enabled)
  Active: active (running) since Thu 2018-12-13 11:24:01 UTC; 47s ago
Main PID: 2417 (lua)
   Tasks: 1 (limit: 4915)
  CGroup: /system.slice/ats.service
          └─2417 lua /usr/local/sbin/ats
Dec 13 11:24:01 rockpro64 systemd[1]: Started ATS - Active Thermal Service.

The fan turns, even test ats -t works

Code:
[email protected]:~# ats -t
Stopping for[ seconds ]............... 10
CPU Temperature[ max 70 °C ].......... 60
GPU Temperature[ max 70 °C ].......... 60
Fan PWM Duty Cycle value[ 0 - 255 ]... 190
--------------------
Running for[ seconds ]................ 6
CPU Temperature[ max 70 °C ].......... 38
GPU Temperature[ max 70 °C ].......... 38
Fan PWM Duty Cycle value[ 0 - 255 ]... 0
--------------------
Stopping for[ seconds ]............... 120
CPU Temperature[ max 70 °C ].......... 38
GPU Temperature[ max 70 °C ].......... 38
Fan PWM Duty Cycle value[ 0 - 255 ]... 0
--------------------
^Clua: /usr/local/sbin/ats:407: interrupted!
stack traceback:
       [C]: in function 'sleep'
       /usr/local/sbin/ats:407: in main chunk
       [C]: in ?


But over 1) ATS, has a configuration file '/etc/ats.conf' I can not control the fan. I try to change the values, e.g. :
MAX_CONTINUOUS_THERMAL_TEMP, MIN_CONTINUOUS_THERMAL_TEMP no success. Or ALWAYS_ON does not work either.
Where is the mistake, what am I doing wrong?


Question 2: I have a NASCase, I want to have 2 fans: 1 for CPU, 2 for NASCase / HDD. Where and how can you connect and control this?
(12-13-2018, 06:37 AM)Neo2018 Wrote: [ -> ]But over 1) ATS, has a configuration file '/etc/ats.conf' I can not control the fan. I try to change the values, e.g. :
MAX_CONTINUOUS_THERMAL_TEMP, MIN_CONTINUOUS_THERMAL_TEMP no success. Or ALWAYS_ON does not work either.
Where is the mistake, what am I doing wrong?

You need to install the version that is in master branch.. do this:

Code:
luarocks build https://raw.githubusercontent.com/tuxd3v/ats/master/ats-master-0.rockspec


Question 2: I have a NASCase, I want to have 2 fans: 1 for CPU, 2 for NASCase / HDD. Where and how can you connect and control this?

At least for now,
ATS, only provide 2 sources of Temperature Control( CPU + GPU ).
To Connect 2 fans, youwould need to conect the second one to the conector close to the Power Plug( The bigger white plug ).

See this  reply from romtorwator
Thanks for quick support.
(12-13-2018, 09:58 AM)tuxd3v Wrote: [ -> ]You need to install the version that is in master branch.. do this:
Code:
luarocks build https://raw.githubusercontent.com/tuxd3v/ats/master/ats-master-0.rockspec
Great it works now! Super Software Thanks for that!
Code:
[email protected]:~# ats -v
ATS --- Active Termal Service, Powered by: Lua 5.3
   --  Copyright © 2018 Carlos Domingues<[email protected]>
   --  Version: 0.2.0


Quote:At least for now,
ATS, only provide 2 sources of Temperature Control( CPU + GPU ).
To Connect 2 fans, youwould need to conect the second one to the conector close to the Power Plug( The bigger white plug ).
See this  reply from romtorwator

Sorry, but which plug exactly 23 ? >  23     CON15         4     DC out for SATA disk cable (direct connect from DC-IN)
The plug is occupied with me HDD power supply / Power Cable for dual SATA Drives / (PCI-e to Dual SATA-II Interface Card).
Or am I completely wrong? How should it all look like? Do you have an example photo / picture? I do not understand.
Do you mean that reply? How is it controlled?

Is there another way to cool the "NASCase" with GRIPO / Script / Python etc .... Does somebody has any idea?
(12-13-2018, 11:41 AM)Neo2018 Wrote: [ -> ]Thanks for quick support.
(12-13-2018, 09:58 AM)tuxd3v Wrote: [ -> ]You need to install the version that is in master branch.. do this:
Code:
luarocks build https://raw.githubusercontent.com/tuxd3v/ats/master/ats-master-0.rockspec
Great it works now! Super Software Thanks for that!

You Welcome,
thanks [Image: shy.png]

(12-13-2018, 09:58 AM)Neo2018 Wrote: [ -> ]Sorry, but which plug exactly 23 ? >  23     CON15         4     DC out for SATA disk cable (direct connect from DC-IN)
The plug is occupied with me HDD power supply / Power Cable for dual SATA Drives / (PCI-e to Dual SATA-II Interface Card).
Or am I completely wrong? How should it all look like? Do you have an example photo / picture? I do not understand.
Do you mean that reply? How is it controlled?

Is there another way to cool the "NASCase" with GRIPO / Script / Python etc .... Does somebody has any idea?

I was thinking about the conector 23..
But you already have it populated with Sata power for the disk..

1) If you are not using too much CPU:
    The CPU heatsink alone will do, without any fan above..
    In this case,
    You can put the NasFan connected to Fan Conector 4.

2) If you have, the CPU processing a  lot:
    You would need to have a conector that will do,1 conector -> to 2 power derivation, connected to Conector 23.
    In this way,
    You can have power to disks, and power to  NASFan, but no control of NasFan, ON/OFF, etc, Fan will be always at Max speed   

   To Control NasFan in this situation, you will need one of the options:
      2a) The romtorwator, solution of a thermostat, or other identical..
      2b)  Or a replication, of the circuit schematic that control pwm for fan in RockPro64 ( page 6 ),
             The possibility of this situation will be addressed in future versions of ATS, were will be there a option for GPIO PWM..
             Also, at the moment there are options to control GPIO on 3.9 Working Features, search there for "GPIO pins"..

             But the power circuitry, will need to exist in some form, ( ..it could be connected to Conector 23, and a pin connected to GPIO, for example, for pwm control  )
(12-14-2018, 04:16 AM)tuxd3v Wrote: [ -> ]2) If you have, the CPU processing a  lot:
    You would need to have a conector that will do,1 conector -> to 2 power derivation, connected to Conector 23.
    In this way,
    You can have power to disks, and power to  NASFan, but no control of NasFan, ON/OFF, etc, Fan will be always at Max speed   

   To Control NasFan in this situation, you will need one of the options:
      2a) The romtorwator, solution of a thermostat, or other identical..
Thanks for the complete education, helped me a lot.
I will probably use KSD9700 40-NO, it seems to me the best and fastest solution.
It is a real pity that it is not immediately an extra plug for NasCase is provided.
I will report who I installed it.
Thank you.
(12-14-2018, 11:47 AM)Neo2018 Wrote: [ -> ]
(12-14-2018, 04:16 AM)Thanks for the complete education, helped me a lot. Wrote: [ -> ]I will probably use KSD9700 40-NO, it seems to me the best and fastest solution.
It is a real pity that it is not immediately an extra plug for NasCase is provided. 
I will report who I installed it. 
Thank you...

You Welcome,
It his indeed the fastest Solution, at least for now..

In that Way,
You can have CPU fan connected to Conector 4. Shy
Could this possibly work on a Rock64?
(12-22-2018, 05:29 AM)va88 Wrote: [ -> ]Could this possibly work on a Rock64?

At the moment it wouldn't work, in future releases perhaps..
I am redesigning the Backend of ATS, so accept different input sources and different output sources.

But the most important are SysFs and PWM..
In Rock64 I don't know if there are any pwm driver there, or if there are any fan conector..

It could be possible to generate the pwm, via GPIO, but a HardWare power driver( like in Rockpro64 need to exist in some form to switch the fan On/Off ).
It could be even a breakout board connected to gpio and 12 volts, receiving pwm from ATS for example..

I don't know much about rock64
(12-22-2018, 03:44 PM)tuxd3v Wrote: [ -> ]RockPro64
Hello tuxd3v,
i have a completely different question, maybe you can help me or an idea!
I create for me a welcome message for "SSH-Putty" connection. > EXAMPLE. On my RaspberryPi there is a command to read the CPU temperature "vcgencmd measure_temp" and I get a simple output>
Code:
[email protected]:~ $ vcgencmd measure_temp
temp=45.6'C
For the welcome message, for the temperature I use this code and get the>
Code:
# Temperatur
TEMP=`vcgencmd measure_temp | cut -c "6-9"
............
............
\033[0;35m+    \033[0;37mTemperatur \033[0;35m= \033[1;32m$TEMP °C
............
............
EXAMPLE >
Code:
[email protected]:~ $ sh welcome.sh
+++++++++++++++++: System Data :++++++++++++++++++++++++++++++++
+ Date and Time = Tue 25 Dec 13:22:22 CET 2018
+      Hostname = myhomeserver
+        Uptime = 0 Tage, 0:42 Stunden
+        Kernel = 4.14.79-v7+
+     CPU model = ARMv7 Processor rev 4 (v7l)
+      RAM (MB) = Belegt 313MB von 875MB
+      Speicher = Frei:  1.1T | Belegt: 2.6T | Gesamt: 3.6T
+    Temperatur = 41.3 °C
++++++++++++++++++: MY IP  :+++++++++++++++++++++++++++++++++++++
 | AA | 00.00.00.000 <-> 00-00-00-00.---------.com. |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
With RockPro64 I only know the command> "armbianmonitor -m". But the output is long and continuous. >
Code:
[email protected]:~# armbianmonitor -m
Stop monitoring using [ctrl]-[c]
Stop monitoring using [ctrl]-[c]
Time       big.LITTLE   load %cpu %sys %usr %nice %io %irq   CPU  C.St.

13:30:45:  408/1416MHz  0.08   2%   0%   1%   0%   0%   0% 39.4°C  1/3
13:30:50:  408/ 408MHz  0.07   2%   0%   1%   0%   0%   0% 38.8°C  1/3
13:30:55:  408/ 408MHz  0.06   1%   0%   1%   0%   0%   0% 38.8°C  0/3
13:31:00:  408/ 600MHz  0.06   1%   0%   1%   0%   0%   0% 38.1°C  0/3^C

I can not integrate that into the welcome message.
I do not get far with Google Search.
I'm not a noob but that's new to me.
Can you please tell me what I can use in my case? You had to do with it too?
Thank you very much!
Merry Charismas !
Pages: 1 2 3