Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controller fan PWM Scaling and Kickstart #24873

Merged
2 changes: 1 addition & 1 deletion Marlin/src/feature/controllerfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ControllerFan::update() {

#if FAN_KICKSTART_TIME
static millis_t fan_kick_end = 0;
if (speed != FAN_OFF_PWM) {
if (speed > FAN_OFF_PWM) {
if (!fan_kick_end) {
fan_kick_end = ms + FAN_KICKSTART_TIME; // May be longer based on slow update interval for controller fn check. Sets minimum
speed = FAN_KICKSTART_POWER;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ void Planner::recalculate(TERN_(HINTS_SAFE_EXIT_SPEED, const_float_t safe_exit_s

void Planner::kickstart_fan(uint8_t (&fan_speed)[FAN_COUNT], const millis_t &ms, const uint8_t f) {
static millis_t fan_kick_end[FAN_COUNT] = { 0 };
if (fan_speed[f] != FAN_OFF_PWM) {
if (fan_speed[f] > FAN_OFF_PWM) {
if (fan_kick_end[f] == 0) {
fan_kick_end[f] = ms + FAN_KICKSTART_TIME;
fan_speed[f] = FAN_KICKSTART_POWER;
Expand Down
14 changes: 7 additions & 7 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,19 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
#endif

#if EITHER(AUTO_POWER_E_FANS, HAS_FANCHECK)
uint8_t Temperature::autofan_speed[HOTENDS]; // = { 0 }
uint8_t Temperature::autofan_speed[HOTENDS] = {FAN_OFF_PWM};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++: All items to init the array must be included. Items after the last one are assumed to be 0.

#endif

#if ENABLED(AUTO_POWER_CHAMBER_FAN)
uint8_t Temperature::chamberfan_speed; // = 0
uint8_t Temperature::chamberfan_speed = {FAN_OFF_PWM}
#endif

#if ENABLED(AUTO_POWER_COOLER_FAN)
uint8_t Temperature::coolerfan_speed; // = 0
uint8_t Temperature::coolerfan_speed = {FAN_OFF_PWM};
#endif

#if BOTH(FAN_SOFT_PWM, USE_CONTROLLER_FAN)
uint8_t Temperature::soft_pwm_controller_speed;
uint8_t Temperature::soft_pwm_controller_speed = {FAN_OFF_PWM};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three items are not arrays.

#endif

// Init fans according to whether they're native PWM or Software PWM
Expand All @@ -345,11 +345,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
// HAS_FAN does not include CONTROLLER_FAN
#if HAS_FAN

uint8_t Temperature::fan_speed[FAN_COUNT]; // = { 0 }
uint8_t Temperature::fan_speed[FAN_COUNT] = {FAN_OFF_PWM};

#if ENABLED(EXTRA_FAN_SPEED)

Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT];
Temperature::extra_fan_t Temperature::extra_fan_speed[FAN_COUNT] = {FAN_OFF_PWM};

/**
* Handle the M106 P<fan> T<speed> command:
Expand All @@ -376,7 +376,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);

#if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE)
bool Temperature::fans_paused; // = false;
uint8_t Temperature::saved_fan_speed[FAN_COUNT]; // = { 0 }
uint8_t Temperature::saved_fan_speed[FAN_COUNT] = {FAN_OFF_PWM};
#endif

#if ENABLED(ADAPTIVE_FAN_SLOWING)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/tool_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ void fast_line_to_current(const AxisEnum fr_axis) { _line_to_current(fr_axis, 0.
#if HAS_FAN && TOOLCHANGE_FS_FAN >= 0
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = toolchange_settings.fan_speed;
gcode.dwell(SEC_TO_MS(toolchange_settings.fan_time));
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = 0;
thermalManager.fan_speed[TOOLCHANGE_FS_FAN] = FAN_OFF_PWM;
Copy link
Member

@thinkyhead thinkyhead Oct 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When speed is set to 0 it is then applied to the PWM as FAN_OFF_PWM. Other values may be applied literally — at least those which are > FAN_OFF_PWM since the last update.

#endif
}

Expand Down