fan measurements fix: keep fanSpeedSoftPwm = 255 during measurements, selftest changes

This commit is contained in:
PavelSindler 2019-02-06 12:37:18 +01:00
parent 27d002a46f
commit 1ba046395e
3 changed files with 17 additions and 7 deletions

View File

@ -545,7 +545,12 @@ void check_axes_activity()
}
#endif//FAN_KICKSTART_TIME
#ifdef FAN_SOFT_PWM
fanSpeedSoftPwm = tail_fan_speed;
if (fan_measuring) { //if measurement is currently in process, fanSpeedSoftPwm must remain set to 255, but we must update fanSpeedBckp value
fanSpeedBckp = tail_fan_speed;
}
else {
fanSpeedSoftPwm = tail_fan_speed;
}
//printf_P(PSTR("fanspeedsoftPWM %d \n"), fanSpeedSoftPwm);
#else
analogWrite(FAN_PIN,tail_fan_speed);

View File

@ -759,7 +759,9 @@ void manage_heater()
if ((_millis() - extruder_autofan_last_check > FAN_CHECK_PERIOD) && (!fan_measuring)) {
extruder_autofan_last_check = _millis();
fanSpeedBckp = fanSpeedSoftPwm;
if (fanSpeedSoftPwm > MIN_PRINT_FAN_SPEED) {
if (fanSpeedSoftPwm >= MIN_PRINT_FAN_SPEED) { //if we are in rage where we are doing fan check, set full PWM range for a short time to measure fan RPM by reading tacho signal without modulation by PWM signal
// printf_P(PSTR("fanSpeedSoftPwm 1: %d\n"), fanSpeedSoftPwm);
fanSpeedSoftPwm = 255;
}
fan_measuring = true;
@ -767,8 +769,9 @@ void manage_heater()
if ((_millis() - extruder_autofan_last_check > FAN_CHECK_DURATION) && (fan_measuring)) {
countFanSpeed();
checkFanSpeed();
//printf_P(PSTR("fanSpeedSoftPwm 1: %d\n"), fanSpeedSoftPwm);
fanSpeedSoftPwm = fanSpeedBckp;
printf_P(PSTR("fan PWM: %d; extr fanSpeed measured: %d; print fan speed measured: %d \n"), fanSpeedBckp, fan_speed[0], fan_speed[1]);
//printf_P(PSTR("fan PWM: %d; extr fanSpeed measured: %d; print fan speed measured: %d \n"), fanSpeedBckp, fan_speed[0], fan_speed[1]);
extruder_autofan_last_check = _millis();
fan_measuring = false;
}

View File

@ -7372,9 +7372,11 @@ static bool lcd_selftest_fan_dialog(int _fan)
case 1:
//will it work with Thotend > 50 C ?
#ifdef FAN_SOFT_PWM
extruder_autofan_last_check = _millis();
fanSpeed = 255;
#ifdef FAN_SOFT_PWM
fanSpeed = 255;
fanSpeedSoftPwm = 255;
extruder_autofan_last_check = _millis(); //store time when measurement starts
fan_measuring = true; //start fan measuring, rest is on manage_heater
#else //FAN_SOFT_PWM
fanSpeed = 150; //print fan
#endif //FAN_SOFT_PWM
@ -7387,8 +7389,8 @@ static bool lcd_selftest_fan_dialog(int _fan)
lcd_print("|");
}
#ifdef FAN_SOFT_PWM
countFanSpeed();
fanSpeed = 0;
fanSpeedSoftPwm = 0;
#else //FAN_SOFT_PWM
fanSpeed = 0;
manage_heater(); //turn off fan