Junction Deviation Machine Limit (#9234)

* Junction Deviation Machine Limit

jd 3

JD menu 2

JD operativo

limpieza

final

* default JD print menu without warnings

* to fix multiple instances

* Only at first layer

* Calibs upgrade

* Shown on Marlin2

Shown on Marlin2
CodeCleaning

* Update Calibration.md

* set on writer

---------

Co-authored-by: Ian Bassi <ian.bassi@outlook.com>
This commit is contained in:
Rodrigo
2025-04-15 10:49:17 -03:00
committed by GitHub
parent 035b047fef
commit 8cdc9c02df
13 changed files with 82 additions and 20 deletions

View File

@@ -3139,6 +3139,9 @@ void GCode::print_machine_envelope(GCodeOutputStream &file, Print &print)
print.config().machine_max_jerk_y.values.front() * factor,
print.config().machine_max_jerk_z.values.front() * factor,
print.config().machine_max_jerk_e.values.front() * factor);
// New Marlin uses M205 J[mm] for junction deviation (only apply if it is > 0)
file.write_format(writer().set_junction_deviation(config().machine_max_junction_deviation.values.front()).c_str());
}
}
@@ -3783,9 +3786,6 @@ LayerResult GCode::process_layer(
}
case CalibMode::Calib_Input_shaping_freq: {
if (m_layer_index == 1){
if (print.config().gcode_flavor.value == gcfMarlinFirmware) {
gcode += writer().set_junction_deviation(0.25);//Set junction deviation at high value to maximize ringing.
}
gcode += writer().set_input_shaping('A', print.calib_params().start, 0.f);
} else {
if (print.calib_params().freqStartX == print.calib_params().freqStartY && print.calib_params().freqEndX == print.calib_params().freqEndY) {
@@ -3799,9 +3799,6 @@ LayerResult GCode::process_layer(
}
case CalibMode::Calib_Input_shaping_damp: {
if (m_layer_index == 1){
if (print.config().gcode_flavor.value == gcfMarlinFirmware) {
gcode += writer().set_junction_deviation(0.25); // Set junction deviation at high value to maximize ringing.
}
gcode += writer().set_input_shaping('X', 0.f, print.calib_params().freqStartX);
gcode += writer().set_input_shaping('Y', 0.f, print.calib_params().freqStartY);
} else {
@@ -3826,6 +3823,9 @@ LayerResult GCode::process_layer(
gcode += m_writer.set_jerk_xy(m_config.initial_layer_jerk.value);
}
if (m_writer.get_gcode_flavor() == gcfMarlinFirmware && m_config.default_junction_deviation.value > 0) {
gcode += m_writer.set_junction_deviation(m_config.default_junction_deviation.value);
}
}
if (! first_layer && ! m_second_layer_things_done) {

View File

@@ -1038,6 +1038,10 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
if (machine_max_jerk_e != nullptr)
m_time_processor.machine_limits.machine_max_jerk_e.values = machine_max_jerk_e->values;
const ConfigOptionFloats* machine_max_junction_deviation = config.option<ConfigOptionFloats>("machine_max_junction_deviation");
if (machine_max_junction_deviation != nullptr)
m_time_processor.machine_limits.machine_max_junction_deviation.values = machine_max_junction_deviation->values;
const ConfigOptionFloats* machine_max_acceleration_extruding = config.option<ConfigOptionFloats>("machine_max_acceleration_extruding");
if (machine_max_acceleration_extruding != nullptr)
m_time_processor.machine_limits.machine_max_acceleration_extruding.values = machine_max_acceleration_extruding->values;

View File

@@ -37,6 +37,7 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
if (use_mach_limits) {
m_max_jerk_x = std::lrint(print_config.machine_max_jerk_x.values.front());
m_max_jerk_y = std::lrint(print_config.machine_max_jerk_y.values.front());
m_max_junction_deviation = (print_config.machine_max_junction_deviation.values.front());
};
m_max_jerk_z = print_config.machine_max_jerk_z.values.front();
m_max_jerk_e = print_config.machine_max_jerk_e.values.front();
@@ -315,14 +316,22 @@ std::string GCodeWriter::set_accel_and_jerk(unsigned int acceleration, double je
std::string GCodeWriter::set_junction_deviation(double junction_deviation){
std::ostringstream gcode;
if (FLAVOR_IS_NOT(gcfMarlinFirmware)) {
throw std::runtime_error("Junction deviation is only supported by Marlin firmware");
if (FLAVOR_IS(gcfMarlinFirmware) && junction_deviation > 0 && m_max_junction_deviation > 0) {
// Clamp the junction deviation to the allowed maximum.
gcode << "M205 J";
if (junction_deviation <= m_max_junction_deviation) {
gcode << std::fixed << std::setprecision(3) << junction_deviation;
} else {
gcode << std::fixed << std::setprecision(3) << m_max_junction_deviation;
}
if (GCodeWriter::full_gcode_comment) {
gcode << " ; Junction Deviation";
}
gcode << "\n";
}
gcode << "M205 J" << std::fixed << std::setprecision(3) << junction_deviation << " ; Junction Deviation\n";
return gcode.str();
}
std::string GCodeWriter::set_pressure_advance(double pa) const
{
std::ostringstream gcode;

View File

@@ -138,6 +138,7 @@ public:
double m_last_jerk;
double m_max_jerk_z;
double m_max_jerk_e;
double m_max_junction_deviation;
unsigned int m_travel_acceleration;
unsigned int m_travel_jerk;

View File

@@ -822,7 +822,7 @@ static std::vector<std::string> s_Preset_print_options {
"wall_generator", "wall_transition_length", "wall_transition_filter_deviation", "wall_transition_angle",
"wall_distribution_count", "min_feature_size", "min_bead_width", "post_process", "min_length_factor",
"small_perimeter_speed", "small_perimeter_threshold","bridge_angle","internal_bridge_angle", "filter_out_gap_fill", "travel_acceleration","inner_wall_acceleration", "min_width_top_surface",
"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk",
"default_jerk", "outer_wall_jerk", "inner_wall_jerk", "infill_jerk", "top_surface_jerk", "initial_layer_jerk","travel_jerk","default_junction_deviation",
"top_solid_infill_flow_ratio","bottom_solid_infill_flow_ratio","only_one_wall_first_layer", "print_flow_ratio", "seam_gap",
"role_based_wipe_speed", "wipe_speed", "accel_to_decel_enable", "accel_to_decel_factor", "wipe_on_loops", "wipe_before_external_loop",
"bridge_density","internal_bridge_density", "precise_outer_wall", "overhang_speed_classic", "bridge_acceleration",
@@ -875,6 +875,7 @@ static std::vector<std::string> s_Preset_machine_limits_options {
"machine_max_speed_x", "machine_max_speed_y", "machine_max_speed_z", "machine_max_speed_e",
"machine_min_extruding_rate", "machine_min_travel_rate",
"machine_max_jerk_x", "machine_max_jerk_y", "machine_max_jerk_z", "machine_max_jerk_e",
"machine_max_junction_deviation",
};
static std::vector<std::string> s_Preset_printer_options {

View File

@@ -1516,6 +1516,17 @@ StringObjectException Print::validate(StringObjectException *warning, Polygons*
}
}
// check junction deviation
const auto max_junction_deviation = m_config.machine_max_junction_deviation.values[0];
if (warning_key.empty() && m_default_object_config.default_junction_deviation.value > max_junction_deviation) {
warning->string = L( "Junction deviation setting exceeds the printer's maximum value "
"(machine_max_junction_deviation).\nOrca will "
"automatically cap the junction deviation to ensure it doesn't surpass the printer's "
"capabilities.\nYou can adjust the "
"machine_max_junction_deviation value in your printer's configuration to get higher limits.");
warning->opt_key = warning_key;
}
// check acceleration
const auto max_accel = m_config.machine_max_acceleration_extruding.values[0];
if (warning_key.empty() && m_default_object_config.default_acceleration > 0 && max_accel > 0) {

View File

@@ -2553,6 +2553,14 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("default_junction_deviation", coFloat);
def->label = L("Junction Deviation");
def->tooltip = L("Marlin Firmware Junction Deviation (replaces the traditional XY Jerk setting)");
def->sidetext = L("mm");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("outer_wall_jerk", coFloat);
def->label = L("Outer wall");
def->tooltip = L("Jerk of outer walls");
@@ -3437,6 +3445,15 @@ void PrintConfigDef::init_fff_params()
def->set_default_value(new ConfigOptionFloats(axis.max_jerk));
}
}
// M205 J... [mm] machine junction deviation limits
def = this->add("machine_max_junction_deviation", coFloats);
def->full_label = L("Maximum Junction Deviation");
def->category = L("Machine limits");
def->tooltip = L("Maximum junction deviation (M205 J, only apply if JD > 0 for Marlin Firmware)");
def->sidetext = L("mm");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{0. ,0. });
// M205 S... [mm/sec]
def = this->add("machine_min_extruding_rate", coFloats);

View File

@@ -899,6 +899,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, initial_layer_jerk))
((ConfigOptionFloat, travel_jerk))
((ConfigOptionBool, precise_z_height))
((ConfigOptionFloat, default_junction_deviation))
((ConfigOptionBool, interlocking_beam))
((ConfigOptionFloat,interlocking_beam_width))
@@ -1070,6 +1071,8 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloats, machine_max_jerk_y))
((ConfigOptionFloats, machine_max_jerk_z))
((ConfigOptionFloats, machine_max_jerk_e))
// M205 J... [mm]
((ConfigOptionFloats, machine_max_junction_deviation))
// M205 T... [mm/sec]
((ConfigOptionFloats, machine_min_travel_rate))
// M205 S... [mm/sec]