You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -3,13 +3,25 @@ A fan control script written in bash for the [**2-pin PH2.0 12v fan connector of
3
3
4
4
Many of the variables used in this fan controller can be modified directly from the CLI, such as setting custom temperature thresholds (`-t`, `-T`) or disabling temperature monitoring altogether (`-f`). For a more detailed description, see [**Usage**](#usage).
5
5
6
-
There's arguably more code here than necessary to run a fan controller. This was a hobby of mine (I wanted to revisit the first version which used a fixed table to set the speed) and an opportunity to learn more about bash and the sysfs interface.
6
+
There's arguably more code here than necessary to run a fan controller. This was a hobby of mine (I wanted to revisit the first version which used a fixed table to set the speed) and an opportunity to learn more about bash and the sysfs interface. There are multiple comments in the script as well, which makes it easy to edit for other similar cases.
7
7
8
8
This is free. There is NO WARRANTY. Use at your own risk.
9
9
10
10
If you have any issues or suggestions, open an issue or [send me an e-mail](mailto:me@cgomesu.com).
11
11
12
12
13
+
# Table of Contents
14
+
1.[Requisites](#requisites)
15
+
2.[Installation](#installation)
16
+
3.[Usage](#demos)
17
+
4.[Controllers](#controllers)
18
+
-[Logistic](#logistic)
19
+
5.[Implementation](#Implementation)
20
+
-[Systemd](#systemd)
21
+
22
+
[:arrow_up: top](#)
23
+
24
+
13
25
# Requisites
14
26
- Linux distro;
15
27
- Access to the [pwm sysfs interface](https://www.kernel.org/doc/Documentation/pwm.txt) (run with `sudo` permission or as `root`);
To install the fan controller script, run the following commands either as `root` or append `sudo` to each command with a user that has sudo permission:
44
55
45
-
# From now on, if you're not running as root, append 'sudo' if you run into permission issues
And if you run into any error messages, fix the issue and try again. Otherwise, press `Ctrl`+`c` to send an interrupt signal and stop the script.
48
71
49
-
# Test the script
50
-
./pwm-fan.sh -F 10
72
+
4.*Optional.* Check [Usage](#usage) for non-default options that you might want to test before running the script in the background.
51
73
52
-
# Check for any error messages
53
-
# When done, press Ctrl+C after to send a SIGINT and stop the script
54
-
```
74
+
5.*Optional.* If using thermal controllers, take a look at [Controllers](#controllers) to learn how to tune a few parameters to best fit your environment.
75
+
76
+
6. Lastly, see the [Implementation](#implementation) section for information on how to run the script in the background.
77
+
78
+
[:arrow_up: top](#)
55
79
56
80
57
81
# Usage
@@ -98,42 +122,76 @@ This is free. There is NO WARRANTY. Use at your own risk.
98
122
99
123
```
100
124
125
+
[:arrow_up: top](#)
126
+
101
127
102
128
# Examples
103
-
- Run with a custom period and min/max temperature thresholds
104
-
```
105
-
./pwm-fan.sh -p 25000000 -t 30 -T 60
106
-
```
129
+
- Run with a custom period and min/max temperature thresholds.
130
+
```
131
+
./pwm-fan.sh -p 25000000 -t 30 -T 60
132
+
```
133
+
134
+
- Run with defaults, except that the minimum duty cycle threshold is 40%.
135
+
```
136
+
./pwm-fan.sh -d 40
137
+
```
138
+
139
+
- Run in full speed mode all the time.
140
+
```
141
+
./pwm-fan.sh -f
142
+
```
143
+
144
+
- Set fan startup to 15 sec.
145
+
```
146
+
./pwm-fan.sh -F 15
147
+
```
107
148
108
-
-Run with defaults, except that the minimum duty cycle threshold is 40%
109
-
```
110
-
./pwm-fan.sh -d 40
111
-
```
149
+
-When using args `-u` and `-U` (introduced by [@araynard](https://github.com/araynard) via [#7](https://github.com/cgomesu/nanopim4-satahat-fan/pull/7)), it is recommended to leave a difference of at least 5°C between them. In most cases, `-u` can be set to a value slightly higher than the idle temperature *with* the fan, whereas `-U` can be set to a value slightly higher than the idle temperature *without* the fan.
150
+
```
151
+
./pwm-fan.sh -u 45 -U 55
152
+
```
112
153
113
-
- Run in full speed mode all the time
114
-
```
115
-
./pwm-fan.sh -f
116
-
```
154
+
[:arrow_up: top](#)
117
155
118
-
- Set fan startup to 10 sec
119
-
```
120
-
./pwm-fan.sh -F 10
121
-
```
122
156
123
-
- When using args `-u` and `-U` (introduced by [@araynard](https://github.com/araynard) via [#7](https://github.com/cgomesu/nanopim4-satahat-fan/pull/7)), it is recommended to leave a difference of at least 5°C between them. In most cases, `-u` can be set to a value slightly higher than the idle temperature *with* the fan, whereas `-U` can be set to a value slightly higher than the idle temperature *without* the fan.
124
-
```
125
-
./pwm-fan.sh -u 45 -U 55
126
-
```
157
+
# Controllers
158
+
## Logistic
159
+
The default thermal controller is based on a [logistic model](https://en.wikipedia.org/wiki/Logistic_function) that outputs the duty cycle in nanoseconds, owing to the constraint that *L* = upper duty cycle threshold, which can be specified via the argument `-D` in percentage of the period.
127
160
161
+
The following plot illustrates how the logistic controller changes the duty cycle as a function of the current temperature using default parameter values and three different mean temperatures:
128
162
129
-
# Run in the background
130
-
If you're running options different than the default values, first edit the `pwm-fan.service` file to include those options into the `ExecStart=` command execution.
The parameters *k* (*k* = *a*/*b*), as well as the critical temperature (75°C) used as reference for the moving mid-point, can both be modified by editing the script. The following plot illustrates the effects of changing *k* while holding the mean temperature constant (everything else follows default):
136
168
137
-
# Check the service status to make sure it's running without issues
Similarly, the following plot illustrates the effects of changing the critical temperature while holding the mean temperature constant (everything else follows default):
If you're running options different than the default ones, first edit the `systemd/pwm-fan.service` file to include those options into the `ExecStart=` command execution. Then, run the following commands to enable and start the `pwm-fan.service`:
0 commit comments