New command line options:
--avalon-fan
Set fanspeed percentage for avalon, single value or range (default: 20-100)
--avalon-freq Set frequency range for avalon-auto, single value or range
Well, i would finish soon code for custom fans to allow setting MIN/MAX_PWM value (currently hardcoded 0x20, 0xA0 values) and inverse pwm option behavior when 0x00 = full speed (im back to original solution when change in temp_rise(), temp_drop() functions is needed) would you also include this changes after i test them on my inverse PWM fans?
To allow avalon be more flexible with different type of fans - like this :
0x00 = 4320 RPM
0x20 = 3840 RPM
0x40 = 3120 .. 3000 RPM
0x80 = 1440 .. 1320 RPM
0x84 = 1200 .. 1080 RPM
0x88 = 960 .. 840 RPM
0x8A = 720 .. 600 RPM
0x8C = STOP , 0 RPM
ADD:
Edited fresh sources, now with
--avalon-fan i think only one additional option is needed,
so i added options
--avalon-invert-pwm and functions temp_rise_invert(), temp_drop_invert(), adjust_fan_invert()
also changed some places where DEFAULT_PWM_MIN/MAX constants appears.
I will post the changes once i test them on my setup.
ADD:
So it works as expected! I think im done here.
Now what i have done to the latest cgminer sources from git :
in cgminer.c , inserted @ LINE 1063
OPT_WITHOUT_ARG("--avalon-invert-pwm",
opt_set_bool, &opt_avalon_invert_pwm,
"Enable avalon use with inverted PWM fans."),
in driver-avalon.h , inserted @ LINE 164
extern bool opt_avalon_invert_pwm;
in driver-avalon.c
inserted @ LINE 13
bool opt_avalon_invert_pwm;
changed in function avalon_init_task()
at->fan_pwm_data = (fan ? fan : AVALON_DEFAULT_FAN_MAX_PWM);
to
if (!opt_avalon_invert_pwm)
at->fan_pwm_data = (fan ? fan : AVALON_DEFAULT_FAN_MAX_PWM);
else
at->fan_pwm_data = (fan ? fan : 0);
changed in function avalon_detect_one()
info->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM;
to
if (!opt_avalon_invert_pwm)
info->fan_pwm = AVALON_DEFAULT_FAN_MIN_PWM;
else
info->fan_pwm = AVALON_DEFAULT_FAN_MAX_PWM - AVALON_DEFAULT_FAN_MIN_PWM;
changed in function avalon_update_temps()
adjust_fan(info);
to
if (!opt_avalon_invert_pwm)
adjust_fan(info);
else
adjust_fan_invert(info);
added function adjust_fan_invert()
static inline void adjust_fan_invert(struct avalon_info *info)
{
int temp_new;
temp_new = info->temp_sum / info->temp_history_count;
if (temp_new > info->temp_old)
temp_rise_invert(info, temp_new);
else if (temp_new < info->temp_old)
temp_drop_invert(info, temp_new);
else {
/* temp_new == info->temp_old */
if (temp_new > opt_avalon_temp)
temp_rise_invert(info, temp_new);
else if (temp_new < opt_avalon_temp - AVALON_TEMP_HYSTERESIS)
temp_drop_invert(info, temp_new);
}
info->temp_old = temp_new;
if (info->temp_old <= opt_avalon_temp)
info->optimal = true;
else
info->optimal = false;
}
added function temp_rise_invert()
static void temp_rise_invert(struct avalon_info *info, int temp)
{
if (temp >= opt_avalon_temp + AVALON_TEMP_HYSTERESIS * 3) {
info->fan_pwm = 0;
return;
}
if (temp >= opt_avalon_temp + AVALON_TEMP_HYSTERESIS * 2)
info->fan_pwm -= 10;
else if (temp > opt_avalon_temp)
info->fan_pwm -= 5;
else if (temp >= opt_avalon_temp - AVALON_TEMP_HYSTERESIS)
info->fan_pwm -= 1;
else
return;
if (info->fan_pwm < (AVALON_PWM_MAX - opt_avalon_fan_max))
info->fan_pwm = (AVALON_PWM_MAX - opt_avalon_fan_max);
}
added function temp_drop_invert()
static void temp_drop_invert(struct avalon_info *info, int temp)
{
if (temp <= opt_avalon_temp - AVALON_TEMP_HYSTERESIS * 3) {
info->fan_pwm = (AVALON_PWM_MAX - opt_avalon_fan_min);
return;
}
if (temp <= opt_avalon_temp - AVALON_TEMP_HYSTERESIS * 2)
info->fan_pwm += 10;
else if (temp <= opt_avalon_temp - AVALON_TEMP_HYSTERESIS)
info->fan_pwm += 5;
else if (temp < opt_avalon_temp)
info->fan_pwm += 1;
if (info->fan_pwm > (AVALON_PWM_MAX - opt_avalon_fan_min))
info->fan_pwm = (AVALON_PWM_MAX - opt_avalon_fan_min);
}
So, this change allow to use inverted PWM fans, and also correctly works with --avalon-fan options
ckolivas, please include this changes in future releases! (donation would be send)