Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
83
Issues
83
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
815e1295
Commit
815e1295
authored
Feb 03, 2016
by
Adam Wujek
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
userspace/libwr: add possibility to use hysteresis to control fans' speed
Signed-off-by:
Adam Wujek
<
adam.wujek@cern.ch
>
parent
4a6d01ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
104 additions
and
1 deletion
+104
-1
Kconfig
Kconfig
+35
-0
wrs-user-manual.in
doc/wrs-user-manual.in
+11
-0
fan.c
userspace/libwr/fan.c
+58
-1
No files found.
Kconfig
View file @
815e1295
...
...
@@ -662,4 +662,39 @@ config MONIT_DISABLE
Disable monit to prevent processes' restarts. It may be useful for
development.
menu "Fan speed control"
config FAN_HYSTERESIS
bool "Use hysteresis to control fan speed"
default n
help
Disable monit to prevent processes' restarts. It may be useful for
development.
config FAN_HYSTERESIS_T_DISABLE
int "Disable fans temperature"
default 60
range 0 80
depends on FAN_HYSTERESIS
help
Temperature at which fans are disabled when working in hysteresis mode.
config FAN_HYSTERESIS_T_ENABLE
int "Enable fans temperature"
default 65
range 0 80
depends on FAN_HYSTERESIS
help
Temperature at which fans are enabled when working in hysteresis mode.
Maximum allowed value is 80
config FAN_HYSTERESIS_PWM_VAL
int "Value of fans' PWM"
default 100
range 4 1000
depends on FAN_HYSTERESIS
help
PWM value used to drive fans. Range from 4 to 1000.
endmenu
endmenu
doc/wrs-user-manual.in
View file @
815e1295
...
...
@@ -707,6 +707,17 @@ value is changed by the web interface, proper action is taken.
re-spawns processes that have died. This option is useful mostly during
development.
@item CONFIG
_
FAN
_
HYSTERESIS
@itemx CONFIG
_
FAN
_
HYSTERESIS
_
T
_
DISABLE
@itemx CONFIG
_
FAN
_
HYSTERESIS
_
T
_
ENABLE
@itemx CONFIG
_
FAN
_
HYSTERESIS
_
PWM
_
VAL
Use hysteresis to control switch's fans. Enable fans with PWM value
@t
{
CONFIG
_
FAN
_
HYSTERESIS
_
PWM
_
VAL
}
when PLL's temperature exceeds
@t
{
CONFIG
_
FAN
_
HYSTERESIS
_
T
_
ENABLE
}
. Disable fans when temperature drops
below @t
{
CONFIG
_
FAN
_
HYSTERESIS
_
T
_
DISABLE
}
. These options are intended to
be used during development to reduce noise generated by switch.
@end table
@c ==========================================================================
...
...
userspace/libwr/fan.c
View file @
815e1295
...
...
@@ -24,11 +24,13 @@
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <libwr/wrs-msg.h>
#include <libwr/pio.h>
#include <libwr/fan.h>
#include <libwr/hal_shmem.h>
#include <libwr/config.h>
#include <at91_softpwm.h>
...
...
@@ -49,6 +51,10 @@
static
int
is_cpu_pwn
=
0
;
static
int
enable_d0
=
0
;
static
int
fan_hysteresis
=
0
;
static
int
fan_hysteresis_t_disable
=
0
;
static
int
fan_hysteresis_t_enable
=
0
;
static
int
fan_hysteresis_pwm_val
=
0
;
static
i2c_fpga_reg_t
fpga_sensors_bus_master
=
{
.
base_address
=
FPGA_I2C_ADDRESS
,
...
...
@@ -204,6 +210,7 @@ static int shw_init_i2c_sensors(void)
int
shw_init_fans
(
void
)
{
uint32_t
val
=
0
;
char
*
config_item
;
//Set the type of PWM
if
(
shw_get_hw_ver
()
<
330
)
...
...
@@ -255,6 +262,42 @@ int shw_init_fans(void)
pi_init
(
&
fan_pi
);
/* check wether config fields exist, atoi has to have valid string */
config_item
=
libwr_cfg_get
(
"FAN_HYSTERESIS"
);
if
((
config_item
)
&&
!
strcmp
(
config_item
,
"y"
))
{
fan_hysteresis
=
1
;
pr_info
(
"enable fan hysteresis
\n
"
);
config_item
=
libwr_cfg_get
(
"FAN_HYSTERESIS_T_ENABLE"
);
if
(
config_item
)
{
fan_hysteresis_t_enable
=
atoi
(
config_item
);
/* don't allow fan_hysteresis_t_enable to be higher
* than 80 deg */
if
(
fan_hysteresis_t_enable
>=
80
)
fan_hysteresis_t_enable
=
80
;
}
config_item
=
libwr_cfg_get
(
"FAN_HYSTERESIS_T_DISABLE"
);
if
(
config_item
)
{
fan_hysteresis_t_disable
=
atoi
(
config_item
);
}
config_item
=
libwr_cfg_get
(
"FAN_HYSTERESIS_PWM_VAL"
);
if
(
config_item
)
{
fan_hysteresis_pwm_val
=
atoi
(
config_item
);
}
if
(
fan_hysteresis_pwm_val
<
4
)
{
/* set minimum pwm value to 4 */
fan_hysteresis_pwm_val
=
4
;
}
pr_info
(
"set temp enable to %d for fan hysteresis
\n
"
,
fan_hysteresis_t_enable
);
pr_info
(
"set temp disable to %d for fan hysteresis
\n
"
,
fan_hysteresis_t_disable
);
pr_info
(
"set pwm value to %d for fan hysteresis
\n
"
,
fan_hysteresis_pwm_val
);
}
return
0
;
}
...
...
@@ -268,7 +311,21 @@ void shw_update_fans(struct hal_temp_sensors *sensors)
float
t_cur
=
tmp100_read_temp
(
TEMP_SENSOR_ADDR_PLL
);
float
drive
=
pi_update
(
&
fan_pi
,
t_cur
-
DESIRED_TEMPERATURE
);
//pr_info("t=%f,pwm=%f\n",t_cur , drive);
shw_pwm_speed
(
0xFF
,
drive
/
1000
);
//enable two and one
if
(
fan_hysteresis
)
{
if
(
t_cur
<
fan_hysteresis_t_disable
)
{
/* disable fans */
shw_pwm_speed
(
0xFF
,
0
);
}
if
(
t_cur
>
fan_hysteresis_t_enable
)
{
/* enable fans with given value */
shw_pwm_speed
(
0xFF
,
((
float
)
fan_hysteresis_pwm_val
)
/
1000
);
}
}
else
{
/* use PI controller for FANs speeds */
shw_pwm_speed
(
0xFF
,
drive
/
1000
);
}
/* update sensor values */
sensors
->
fpga
=
tmp100_read_reg
(
TEMP_SENSOR_ADDR_FPGA
,
0
,
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment