mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-28 05:12:27 +00:00
Input Shaping Calib: Types, RepRap + Improvements (#10913)
* IS Freq duplicated as Base * IS jerk to 5 * JD jerk to 0 * Base 1 layer + MINIMUM_CRUISE_RATIO=0 * Tab * Remove IS BASE * Update Plater.cpp * Klipper Jerk 5, Others 10 * JD in Marlin2 * Types * Horizontal * Different lists * RepRap IS writer * Smart Flavors and axis * RepRap values lowercase * Hide Y axix for RepRap * Max Jerk or JD * Reorder * Removed dual list + Default * RepRap show UpperCase use LowerCase * RepRap P"type" Type of input shaping to use, not case sensitive. * RepRap DAA * Reorder Klipper * Custom Firmware Note * Better Display Co-Authored-By: yw4z <28517890+yw4z@users.noreply.github.com> * Better notes * Update + Clean Wiki Co-Authored-By: gregmatic <60957555+gregmatic@users.noreply.github.com> * Wiki Update Update Images Improve guide Co-Authored-By: Cameron D <30559428+cdunn95@users.noreply.github.com> * Fix G-code generation issue and refine input shaping calibration documentation --------- Co-authored-by: yw4z <28517890+yw4z@users.noreply.github.com> Co-authored-by: gregmatic <60957555+gregmatic@users.noreply.github.com> Co-authored-by: Cameron D <30559428+cdunn95@users.noreply.github.com> Co-authored-by: SoftFever <softfeverever@gmail.com>
This commit is contained in:
@@ -3788,23 +3788,31 @@ LayerResult GCode::process_layer(
|
||||
}
|
||||
case CalibMode::Calib_Input_shaping_freq: {
|
||||
if (m_layer_index == 1){
|
||||
gcode += writer().set_input_shaping('A', print.calib_params().start, 0.f);
|
||||
gcode += writer().set_input_shaping('A', print.calib_params().start, 0.f, print.calib_params().shaper_type);
|
||||
if (m_writer.get_gcode_flavor() == gcfKlipper) {
|
||||
// Disable minimum cruise ratio to ensure consistent motion for calibration
|
||||
gcode += "SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO=0\n";
|
||||
}
|
||||
} else {
|
||||
if (print.calib_params().freqStartX == print.calib_params().freqStartY && print.calib_params().freqEndX == print.calib_params().freqEndY) {
|
||||
gcode += writer().set_input_shaping('A', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3));
|
||||
gcode += writer().set_input_shaping('A', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3), "");
|
||||
} else {
|
||||
gcode += writer().set_input_shaping('X', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3));
|
||||
gcode += writer().set_input_shaping('Y', 0.f, (print.calib_params().freqStartY) + ((print.calib_params().freqEndY)-(print.calib_params().freqStartY)) * (m_layer_index - 2) / (m_layer_count - 3));
|
||||
gcode += writer().set_input_shaping('X', 0.f, (print.calib_params().freqStartX) + ((print.calib_params().freqEndX)-(print.calib_params().freqStartX)) * (m_layer_index - 2) / (m_layer_count - 3), "");
|
||||
gcode += writer().set_input_shaping('Y', 0.f, (print.calib_params().freqStartY) + ((print.calib_params().freqEndY)-(print.calib_params().freqStartY)) * (m_layer_index - 2) / (m_layer_count - 3), "");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CalibMode::Calib_Input_shaping_damp: {
|
||||
if (m_layer_index == 1){
|
||||
gcode += writer().set_input_shaping('X', 0.f, print.calib_params().freqStartX);
|
||||
gcode += writer().set_input_shaping('Y', 0.f, print.calib_params().freqStartY);
|
||||
if (m_writer.get_gcode_flavor() == gcfKlipper) {
|
||||
// Disable minimum cruise ratio to ensure consistent motion for calibration
|
||||
gcode += "SET_VELOCITY_LIMIT MINIMUM_CRUISE_RATIO=0\n";
|
||||
}
|
||||
gcode += writer().set_input_shaping('X', 0.f, print.calib_params().freqStartX, print.calib_params().shaper_type);
|
||||
gcode += writer().set_input_shaping('Y', 0.f, print.calib_params().freqStartY, print.calib_params().shaper_type);
|
||||
} else {
|
||||
gcode += writer().set_input_shaping('A', print.calib_params().start + ((print.calib_params().end)-(print.calib_params().start)) * (m_layer_index) / (m_layer_count), 0.f);
|
||||
gcode += writer().set_input_shaping('A', print.calib_params().start + ((print.calib_params().end)-(print.calib_params().start)) * (m_layer_index) / (m_layer_count), 0.f, "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -352,8 +352,10 @@ std::string GCodeWriter::set_pressure_advance(double pa) const
|
||||
return gcode.str();
|
||||
}
|
||||
|
||||
std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) const
|
||||
std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq, std::string type) const
|
||||
{
|
||||
if (FLAVOR_IS(gcfMarlinLegacy))
|
||||
throw std::runtime_error("Input shaping is not supported by Marlin < 2.1.2.\nCheck your firmware version and update your G-code flavor to ´Marlin 2´");
|
||||
if (freq < 0.0f || damp < 0.f || damp > 1.0f || (axis != 'X' && axis != 'Y' && axis != 'Z' && axis != 'A'))// A = all axis
|
||||
{
|
||||
throw std::runtime_error("Invalid input shaping parameters: freq=" + std::to_string(freq) + ", damp=" + std::to_string(damp));
|
||||
@@ -361,14 +363,17 @@ std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) co
|
||||
std::ostringstream gcode;
|
||||
if (FLAVOR_IS(gcfKlipper)) {
|
||||
gcode << "SET_INPUT_SHAPER";
|
||||
if (!type.empty() && type != "Default") {
|
||||
gcode << " SHAPER_TYPE=" << type;
|
||||
}
|
||||
if (axis != 'A')
|
||||
{
|
||||
if (freq > 0.0f) {
|
||||
gcode << " SHAPER_FREQ_" << axis << "=" << std::fixed << std::setprecision(2) << freq;
|
||||
}
|
||||
if (damp > 0.0f){
|
||||
gcode << " DAMPING_RATIO_" << axis << "=" << damp;
|
||||
}
|
||||
gcode << " DAMPING_RATIO_" << axis << "=" << std::fixed << std::setprecision(3) << damp;
|
||||
}
|
||||
} else {
|
||||
if (freq > 0.0f) {
|
||||
gcode << " SHAPER_FREQ_X=" << std::fixed << std::setprecision(2) << freq << " SHAPER_FREQ_Y=" << std::fixed << std::setprecision(2) << freq;
|
||||
@@ -377,7 +382,18 @@ std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) co
|
||||
gcode << " DAMPING_RATIO_X=" << std::fixed << std::setprecision(3) << damp << " DAMPING_RATIO_Y=" << std::fixed << std::setprecision(3) << damp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
} else if (FLAVOR_IS(gcfRepRapFirmware)) {
|
||||
gcode << "M593";
|
||||
if (!type.empty() && type != "Default" && type != "DAA") {
|
||||
gcode << " P\"" << type << "\"";
|
||||
}
|
||||
if (freq > 0.0f) {
|
||||
gcode << " F" << std::fixed << std::setprecision(2) << freq;
|
||||
}
|
||||
if (damp > 0.0f){
|
||||
gcode << " S" << std::fixed << std::setprecision(3) << damp;
|
||||
}
|
||||
} else if (FLAVOR_IS(gcfMarlinFirmware)) {
|
||||
gcode << "M593";
|
||||
if (axis != 'A')
|
||||
{
|
||||
@@ -391,6 +407,8 @@ std::string GCodeWriter::set_input_shaping(char axis, float damp, float freq) co
|
||||
{
|
||||
gcode << " D" << std::fixed << std::setprecision(3) << damp;
|
||||
}
|
||||
} else {
|
||||
throw std::runtime_error("Input shaping is only supported by Klipper, RepRapFirmware and Marlin 2");
|
||||
}
|
||||
if (GCodeWriter::full_gcode_comment){
|
||||
gcode << " ; Override input shaping";
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
std::string set_accel_and_jerk(unsigned int acceleration, double jerk);
|
||||
std::string set_junction_deviation(double junction_deviation);
|
||||
std::string set_pressure_advance(double pa) const;
|
||||
std::string set_input_shaping(char axis, float damp, float freq) const;
|
||||
std::string set_input_shaping(char axis, float damp, float freq, std::string type) const;
|
||||
std::string reset_e(bool force = false);
|
||||
std::string update_progress(unsigned int num, unsigned int tot, bool allow_100 = false) const;
|
||||
// return false if this extruder was already selected
|
||||
|
||||
@@ -37,6 +37,7 @@ struct Calib_Params
|
||||
bool print_numbers;
|
||||
double freqStartX, freqEndX, freqStartY, freqEndY;
|
||||
int test_model;
|
||||
std::string shaper_type;
|
||||
std::vector<double> accelerations;
|
||||
std::vector<double> speeds;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user