Skip to content

Commit

Permalink
Update & fixes XY_FREQUENCY_LIMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
studiodyne committed Apr 25, 2020
1 parent 756c8a9 commit d2753a6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,9 @@
* See http://hydraraptor.blogspot.com/2010/12/frequency-limit.html
* Use M201 F<freq> G<min%> to change limits at runtime.
*/
//#define XY_FREQUENCY_LIMIT 10 // (Hz) Maximum frequency of small zigzag infill moves. Set with M201 F<hertz>.
#define XY_FREQUENCY_LIMIT 10 // (Hz) Maximum frequency of small zigzag infill moves. Set with M201 F<hertz>.
#ifdef XY_FREQUENCY_LIMIT
#define XY_FREQUENCY_MIN_PERCENT 25 // (percent) Minimum FR percentage to apply. Set with M201 G<min%>.
#define XY_FREQUENCY_MIN_PERCENT 5 // (percent) Minimum FR percentage to apply. Set with M201 G<min%>.
#endif

// Minimum planner junction speed. Sets the default minimum speed the planner plans for at the end
Expand Down
1 change: 0 additions & 1 deletion Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ namespace Language_en {
PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("A-Travel");
PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Frequency max");
PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min");
PROGMEM Language_Str MSG_XY_FREQUENCY_LENGTH = _UxGT("long min");
PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Steps/mm");
PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT("steps/mm");
PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT("steps/mm");
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/language/language_fr.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ namespace Language_fr {
PROGMEM Language_Str MSG_A_RETRACT = _UxGT("Acc.rétraction");
PROGMEM Language_Str MSG_A_TRAVEL = _UxGT("Acc.course");
PROGMEM Language_Str MSG_XY_FREQUENCY_LIMIT = _UxGT("Fréquence max");
PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Feed min");
PROGMEM Language_Str MSG_XY_FREQUENCY_LENGTH = _UxGT("long min");
PROGMEM Language_Str MSG_XY_FREQUENCY_FEEDRATE = _UxGT("Vitesse min");
PROGMEM Language_Str MSG_STEPS_PER_MM = _UxGT("Pas/mm");
PROGMEM Language_Str MSG_A_STEPS = LCD_STR_A _UxGT(" pas/mm");
PROGMEM Language_Str MSG_B_STEPS = LCD_STR_B _UxGT(" pas/mm");
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 @@ -2097,7 +2097,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
if (segment_time_us < xy_freq_min_interval_us) {
const int32_t least_xy_segment_time = _MIN(_MAX(xs0, xs1, xs2), _MAX(ys0, ys1, ys2));
if (least_xy_segment_time < xy_freq_min_interval_us) {
const float freq_xy_feedrate = (speed_factor * least_xy_segment_time) / xy_freq_min_interval_us;
float freq_xy_feedrate = (speed_factor * least_xy_segment_time) / xy_freq_min_interval_us;
NOLESS(freq_xy_feedrate, xy_freq_min_speed_factor);
NOMORE(speed_factor, freq_xy_feedrate);
}
Expand Down
33 changes: 17 additions & 16 deletions Marlin/src/module/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@ class Planner {
#if ENABLED(SD_ABORT_ON_ENDSTOP_HIT)
static bool abort_on_endstop_hit;
#endif
#ifdef XY_FREQUENCY_LIMIT
static int8_t xy_freq_limit_hz; // Minimum XY frequency setting
static float xy_freq_min_speed_factor; // Minimum speed factor setting
static int32_t xy_freq_min_interval_us; // Minimum segment time based on xy_freq_limit_hz
static inline void refresh_frequency_limit() {
//xy_freq_min_interval_us = xy_freq_limit_hz ?: LROUND(1000000.0f / xy_freq_limit_hz);
if ( !xy_freq_limit_hz ) return ;
else xy_freq_min_interval_us = LROUND(1000000.0f / xy_freq_limit_hz);
}
static inline void set_min_speed_factor_u8(const uint8_t v255) {
xy_freq_min_speed_factor = float(ui8_to_percent(v255)) / 100;
}
static inline void set_frequency_limit(const uint8_t hz) {
xy_freq_limit_hz = constrain(hz, 0, 100);
refresh_frequency_limit();
}
#endif

private:

Expand Down Expand Up @@ -379,22 +396,6 @@ class Planner {
static uint8_t g_uc_extruder_last_move[EXTRUDERS];
#endif

#ifdef XY_FREQUENCY_LIMIT
static int8_t xy_freq_limit_hz; // Minimum XY frequency setting
static float xy_freq_min_speed_factor; // Minimum speed factor setting
static int32_t xy_freq_min_interval_us; // Minimum segment time based on xy_freq_limit_hz
static inline void refresh_frequency_limit() {
xy_freq_min_interval_us = xy_freq_limit_hz ?: LROUND(1000000.0f / xy_freq_limit_hz);
}
static inline void set_min_speed_factor_u8(const uint8_t v255) {
xy_freq_min_speed_factor = float(ui8_to_percent(v255)) / 100;
}
static inline void set_frequency_limit(const uint8_t hz) {
xy_freq_limit_hz = constrain(hz, 0, 100);
refresh_frequency_limit();
}
#endif

#if HAS_SPI_LCD
volatile static uint32_t block_buffer_runtime_us; // Theoretical block buffer runtime in µs
#endif
Expand Down

0 comments on commit d2753a6

Please sign in to comment.