Tweak fan kickstart / speed code

2.0.x
Scott Lahteine 7 years ago
parent 8602461da8
commit 9e3c41f9e8

@ -188,7 +188,7 @@ script:
- opt_set_adv FAN_MIN_PWM 50 - opt_set_adv FAN_MIN_PWM 50
- opt_set_adv FAN_KICKSTART_TIME 100 - opt_set_adv FAN_KICKSTART_TIME 100
- opt_set_adv XY_FREQUENCY_LIMIT 15 - opt_set_adv XY_FREQUENCY_LIMIT 15
- opt_enable_adv SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER - opt_enable_adv SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER FAN_KICKSTART_TIME
- opt_enable_adv ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ADVANCED_OK - opt_enable_adv ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED ADVANCED_OK
- opt_enable_adv VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL - opt_enable_adv VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS ACTION_ON_KILL
- opt_enable_adv EXTRA_FAN_SPEED FWERETRACT Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS - opt_enable_adv EXTRA_FAN_SPEED FWERETRACT Z_DUAL_STEPPER_DRIVERS Z_DUAL_ENDSTOPS

@ -421,76 +421,35 @@ void Planner::check_axes_activity() {
unsigned char axis_active[NUM_AXIS] = { 0 }, unsigned char axis_active[NUM_AXIS] = { 0 },
tail_fan_speed[FAN_COUNT]; tail_fan_speed[FAN_COUNT];
#if FAN_COUNT > 0
for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
#endif
#if ENABLED(BARICUDA) #if ENABLED(BARICUDA)
#if HAS_HEATER_1 #if HAS_HEATER_1
uint8_t tail_valve_pressure = baricuda_valve_pressure; uint8_t tail_valve_pressure;
#endif #endif
#if HAS_HEATER_2 #if HAS_HEATER_2
uint8_t tail_e_to_p_pressure = baricuda_e_to_p_pressure; uint8_t tail_e_to_p_pressure;
#endif #endif
#endif #endif
if (blocks_queued()) { if (blocks_queued()) {
#if FAN_COUNT > 0
for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
#endif
block_t* block;
#if ENABLED(BARICUDA)
block = &block_buffer[block_buffer_tail];
#if HAS_HEATER_1
tail_valve_pressure = block->valve_pressure;
#endif
#if HAS_HEATER_2
tail_e_to_p_pressure = block->e_to_p_pressure;
#endif
#endif
for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) {
block = &block_buffer[b];
LOOP_XYZE(i) if (block->steps[i]) axis_active[i]++;
}
}
#if ENABLED(DISABLE_X)
if (!axis_active[X_AXIS]) disable_X();
#endif
#if ENABLED(DISABLE_Y)
if (!axis_active[Y_AXIS]) disable_Y();
#endif
#if ENABLED(DISABLE_Z)
if (!axis_active[Z_AXIS]) disable_Z();
#endif
#if ENABLED(DISABLE_E)
if (!axis_active[E_AXIS]) disable_e_steppers();
#endif
#if FAN_COUNT > 0 #if FAN_COUNT > 0
#ifdef FAN_MIN_PWM for (uint8_t i = 0; i < FAN_COUNT; i++)
#define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0) tail_fan_speed[i] = block_buffer[block_buffer_tail].fan_speed[i];
#else
#define CALC_FAN_SPEED(f) tail_fan_speed[f]
#endif
#ifdef FAN_KICKSTART_TIME #ifdef FAN_KICKSTART_TIME
static millis_t fan_kick_end[FAN_COUNT] = { 0 }; static millis_t fan_kick_end[FAN_COUNT] = { 0 };
#define KICKSTART_FAN(f) \ #define KICKSTART_FAN(f) \
if (tail_fan_speed[f]) { \ if (tail_fan_speed[f]) { \ // is the fan turned on?
millis_t ms = millis(); \ millis_t ms = millis(); \
if (fan_kick_end[f] == 0) { \ if (fan_kick_end[f] == 0) { \ // not yet kickstarted?
fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \ fan_kick_end[f] = ms + FAN_KICKSTART_TIME; \ // kickstart until this time
tail_fan_speed[f] = 255; \ tail_fan_speed[f] = 255; \ // full speed
} else if (PENDING(ms, fan_kick_end[f])) \ } else if (PENDING(ms, fan_kick_end[f])) \ // kickstart in progress?
tail_fan_speed[f] = 255; \ tail_fan_speed[f] = 255; \ // keep full speed going
} else fan_kick_end[f] = 0 } else fan_kick_end[f] = 0 // fan off? kick next time
#if HAS_FAN0 #if HAS_FAN0
KICKSTART_FAN(0); KICKSTART_FAN(0);
@ -504,6 +463,12 @@ void Planner::check_axes_activity() {
#endif // FAN_KICKSTART_TIME #endif // FAN_KICKSTART_TIME
#ifdef FAN_MIN_PWM
#define CALC_FAN_SPEED(f) (tail_fan_speed[f] ? ( FAN_MIN_PWM + (tail_fan_speed[f] * (255 - FAN_MIN_PWM)) / 255 ) : 0)
#else
#define CALC_FAN_SPEED(f) tail_fan_speed[f]
#endif
#if ENABLED(FAN_SOFT_PWM) #if ENABLED(FAN_SOFT_PWM)
#if HAS_FAN0 #if HAS_FAN0
thermalManager.soft_pwm_amount_fan[0] = CALC_FAN_SPEED(0); thermalManager.soft_pwm_amount_fan[0] = CALC_FAN_SPEED(0);
@ -528,6 +493,51 @@ void Planner::check_axes_activity() {
#endif // FAN_COUNT > 0 #endif // FAN_COUNT > 0
block_t* block;
#if ENABLED(BARICUDA)
block = &block_buffer[block_buffer_tail];
#if HAS_HEATER_1
tail_valve_pressure = block->valve_pressure;
#endif
#if HAS_HEATER_2
tail_e_to_p_pressure = block->e_to_p_pressure;
#endif
#endif
for (uint8_t b = block_buffer_tail; b != block_buffer_head; b = next_block_index(b)) {
block = &block_buffer[b];
LOOP_XYZE(i) if (block->steps[i]) axis_active[i]++;
}
}
else {
#if FAN_COUNT > 0
for (uint8_t i = 0; i < FAN_COUNT; i++) tail_fan_speed[i] = fanSpeeds[i];
#endif
#if ENABLED(BARICUDA)
#if HAS_HEATER_1
tail_valve_pressure = baricuda_valve_pressure;
#endif
#if HAS_HEATER_2
tail_e_to_p_pressure = baricuda_e_to_p_pressure;
#endif
#endif
}
#if ENABLED(DISABLE_X)
if (!axis_active[X_AXIS]) disable_X();
#endif
#if ENABLED(DISABLE_Y)
if (!axis_active[Y_AXIS]) disable_Y();
#endif
#if ENABLED(DISABLE_Z)
if (!axis_active[Z_AXIS]) disable_Z();
#endif
#if ENABLED(DISABLE_E)
if (!axis_active[E_AXIS]) disable_e_steppers();
#endif
#if ENABLED(AUTOTEMP) #if ENABLED(AUTOTEMP)
getHighESpeed(); getHighESpeed();
#endif #endif

Loading…
Cancel
Save