Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@
*/
//#define FAN_KICKSTART_TIME 100 // (ms)
//#define FAN_KICKSTART_POWER 180 // 64-255
//#define FAN_KICKSTART_LINEAR // Set kickstart time linearly based on the speed, e.g. for 20% (51) it will be FAN_KICKSTART_TIME * 0.2.
// Useful for quick speed up to low speed. Kickstart power must be set to 255.

// Some coolers may require a non-zero "off" state.
//#define FAN_OFF_PWM 1
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@

// Fan Kickstart
#if FAN_KICKSTART_TIME && !defined(FAN_KICKSTART_POWER)
#define FAN_KICKSTART_POWER 180
#define FAN_KICKSTART_POWER TERN(FAN_KICKSTART_LINEAR, 255, 180)
#endif

// Servos
Expand Down
8 changes: 6 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,12 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
#endif

// Fan Kickstart power
#if FAN_KICKSTART_TIME && !WITHIN(FAN_KICKSTART_POWER, 64, 255)
#error "FAN_KICKSTART_POWER must be an integer from 64 to 255."
#if FAN_KICKSTART_TIME
#if ENABLED(FAN_KICKSTART_LINEAR) && FAN_KICKSTART_POWER != 255
#error "FAN_KICKSTART_LINEAR requires a FAN_KICKSTART_POWER of 255."
Copy link
Member

Choose a reason for hiding this comment

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

This requirement can probably be removed by only kick-starting the fan when the power is set below FAN_KICKSTART_POWER, and then applying the time scaling based on fan_speed / FAN_KICKSTART_POWER.

#elif !WITHIN(FAN_KICKSTART_POWER, 64, 255)
#error "FAN_KICKSTART_POWER must be an integer from 64 to 255."
#endif
#endif

/**
Expand Down
16 changes: 10 additions & 6 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,16 +1310,20 @@ void Planner::recalculate(const_float_t safe_exit_speed_sqr) {

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 ENABLED(FAN_KICKSTART_LINEAR)
static uint8_t set_fan_speed[FAN_COUNT] = { 0 };
#endif
if (fan_speed[f] > FAN_OFF_PWM) {
if (fan_kick_end[f] == 0) {
fan_kick_end[f] = ms + FAN_KICKSTART_TIME;
const bool first_kick = fan_kick_end[f] == 0 && TERN1(FAN_KICKSTART_LINEAR, fan_speed[f] > set_fan_speed[f]);
if (first_kick)
fan_kick_end[f] = ms + (FAN_KICKSTART_TIME) TERN_(FAN_KICKSTART_LINEAR, * (fan_speed[f] - set_fan_speed[f]) / 255);
if (first_kick || PENDING(ms, fan_kick_end[f])) {
fan_speed[f] = FAN_KICKSTART_POWER;
return;
}
else if (PENDING(ms, fan_kick_end[f]))
fan_speed[f] = FAN_KICKSTART_POWER;
}
else
fan_kick_end[f] = 0;
fan_kick_end[f] = 0;
TERN_(FAN_KICKSTART_LINEAR, set_fan_speed[f] = fan_speed[f]);
}

#endif
Expand Down