diff options
author | FormerLurker <hochgebe@gmail.com> | 2020-05-02 18:06:40 +0300 |
---|---|---|
committer | FormerLurker <hochgebe@gmail.com> | 2020-05-02 18:06:40 +0300 |
commit | 8d7b572cc7fa7faf795db88a29340b6380090f8f (patch) | |
tree | 5c5b2fb251af89e0c9038be84236c6df85d098fb /ArcWelderInverseProcessor | |
parent | 4fcf89d4995921b89b579d06052df11b66e4879f (diff) |
Add enhanced progress and complete statistics for arc welder. Add ARC_SEGMENTS_PER_SEC to inverse processor.
Diffstat (limited to 'ArcWelderInverseProcessor')
4 files changed, 44 insertions, 24 deletions
diff --git a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.cpp b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.cpp index 4d1e2fa..38da205 100644 --- a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.cpp +++ b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.cpp @@ -32,7 +32,7 @@ int main(int argc, char* argv[]) { std::string info = "Arc Welder: Inverse Processor v0.1.rc1.dev0\nConverts G2/G3 commands to G1/G2 commands.\nCopyright(C) 2020 - Brad Hochgesang\n"; std::cout << info; - TestInverseProcessor(ARC_GYROID_BENCHY_DIFFICULT, "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\test_output.gcode"); + TestInverseProcessor(SIX_SPEED_TEST, "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\test_output.gcode"); } static void TestInverseProcessor(std::string source_path, std::string target_path) diff --git a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.h b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.h index d17f2dd..5647357 100644 --- a/ArcWelderInverseProcessor/ArcWelderInverseProcessor.h +++ b/ArcWelderInverseProcessor/ArcWelderInverseProcessor.h @@ -46,6 +46,9 @@ static std::string SUPER_HUGE_TEST = "C:\\Users\\Brad\\Documents\\3DPrinter\\Ant static std::string TORTURE_TEST = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\stereographic_projection_0.2mm_PLA_MK2.5MMU2_2h49m.gcode"; static std::string ORCHID_POD = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\Pla_OrchidPot.gcode"; static std::string ARC_GYROID_BENCHY_DIFFICULT = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\AS_BenchyArc_Difficult.gcode"; +static std::string SIX_SPEED_TEST = "C:\\Users\\Brad\\Documents\\3DPrinter\\AntiStutter\\SixSpeedTest_AS.gcode"; + + // Issues static std::string ISSUE_MIMUPREFERIDA = "C:\\Users\\Brad\\Documents\\AntiStutter\\Issues\\MIMUPREFERIDA\\TESTSTUTTER.gcode"; static std::string ISSUE_PRICKLYPEAR = "C:\\Users\\Brad\\Documents\\AntiStutter\\Issues\\PricklyPear\\Barbarian.gcode"; diff --git a/ArcWelderInverseProcessor/inverse_processor.cpp b/ArcWelderInverseProcessor/inverse_processor.cpp index 57144b8..02991f4 100644 --- a/ArcWelderInverseProcessor/inverse_processor.cpp +++ b/ArcWelderInverseProcessor/inverse_processor.cpp @@ -68,15 +68,18 @@ inverse_processor::inverse_processor(std::string source_path, std::string target // 20200417 - FormerLurker - Declare two globals and pre-calculate some values that will reduce the // amount of trig funcitons we need to call while printing. For the price of having two globals we // save one trig calc per G2/G3 for both MIN_ARC_SEGMENTS and MIN_MM_PER_ARC_SEGMENT. This is a good trade IMHO. + + #ifdef MIN_ARC_SEGMENTS // Determines the radius at which the transition from using MM_PER_ARC_SEGMENT to MIN_ARC_SEGMENTS - /*const float*/arc_max_radius_threshold = MM_PER_ARC_SEGMENT / (2.0F * sin(M_PI / MIN_ARC_SEGMENTS)); + arc_max_radius_threshold = MM_PER_ARC_SEGMENT / (2.0F * sin(M_PI / MIN_ARC_SEGMENTS)); #endif +/* #if defined(MIN_ARC_SEGMENTS) && defined(MIN_MM_PER_ARC_SEGMENT) // Determines the radius at which the transition from using MIN_ARC_SEGMENTS to MIN_MM_PER_ARC_SEGMENT. - /*const float*/arc_min_radius_threshold = MIN_MM_PER_ARC_SEGMENT / (2.0F * sin(M_PI / MIN_ARC_SEGMENTS)); + arc_min_radius_threshold = MIN_MM_PER_ARC_SEGMENT / (2.0F * sin(M_PI / MIN_ARC_SEGMENTS)); #endif - +*/ } gcode_position_args inverse_processor::get_args_(bool g90_g91_influences_extruder, int buffer_size) @@ -202,7 +205,7 @@ void inverse_processor::process() } float radius = hypot(offset[X_AXIS], offset[Y_AXIS]); // Compute arc radius for mc_arc uint8_t isclockwise = cmd.command == "G2" ? 1 : 0; - output_file << mc_arc(position, target, offset, X_AXIS, Y_AXIS, Z_AXIS, static_cast<float>(p_pre_pos->f), radius, isclockwise, 0, p_cur_pos->is_extruder_relative) << "\n"; + output_file << mc_arc(position, target, offset, X_AXIS, Y_AXIS, Z_AXIS, static_cast<float>(p_cur_pos->f), radius, isclockwise, 0, p_cur_pos->is_extruder_relative) << "\n"; } else { @@ -256,7 +259,7 @@ std::string inverse_processor::mc_arc(float* position, float* target, float* off float rt_axis0 = target[axis_0] - center_axis0; float rt_axis1 = target[axis_1] - center_axis1; // 20200419 - Add a variable that will be used to hold the arc segment length - float mm_per_arc_segment; + float mm_per_arc_segment = MM_PER_ARC_SEGMENT; // CCW angle between position and target from circle center. Only one atan2() trig computation required. float angular_travel_total = atan2(r_axis0 * rt_axis1 - r_axis1 * rt_axis0, r_axis0 * rt_axis0 + r_axis1 * rt_axis1); @@ -265,18 +268,29 @@ std::string inverse_processor::mc_arc(float* position, float* target, float* off #ifdef MIN_ARC_SEGMENTS // 20200417 - FormerLurker - Implement MIN_ARC_SEGMENTS if it is defined - from Marlin 2.0 implementation // Do this before converting the angular travel for clockwise rotation + if (radius < arc_max_radius_threshold) mm_per_arc_segment = radius * ((2.0f * M_PI) / MIN_ARC_SEGMENTS); +#endif + +#ifdef ARC_SEGMENTS_PER_SEC + // 20200417 - FormerLurker - Implement MIN_ARC_SEGMENTS if it is defined - from Marlin 2.0 implementation + float mm_per_arc_segment_sec = (feed_rate / 60.0f) * (1.0f / ARC_SEGMENTS_PER_SEC); + if (mm_per_arc_segment_sec < mm_per_arc_segment) + mm_per_arc_segment = mm_per_arc_segment_sec; +#endif + #ifdef MIN_MM_PER_ARC_SEGMENT -// 20200417 - FormerLurker - Implement MIN_MM_PER_ARC_SEGMENT if it is defined -// This prevents a very high number of segments from being generated for curves of a short radius - if (radius < arc_min_radius_threshold) mm_per_arc_segment = MIN_MM_PER_ARC_SEGMENT; - else + // 20200417 - FormerLurker - Implement MIN_MM_PER_ARC_SEGMENT if it is defined + // This prevents a very high number of segments from being generated for curves of a short radius + if (mm_per_arc_segment < MIN_MM_PER_ARC_SEGMENT) mm_per_arc_segment = MIN_MM_PER_ARC_SEGMENT; #endif - if (radius < arc_max_radius_threshold) mm_per_arc_segment = radius * ((2.0f * M_PI) / MIN_ARC_SEGMENTS); - else mm_per_arc_segment = MM_PER_ARC_SEGMENT; -#else - // 20200418 - FormerLurker - Use the standard segment length - mm_per_arc_segment = MM_PER_ARC_SEGMENT; + +#if defined(MIN_MM_PER_ARC_SEGMENT) || defined(ARC_SEGMENTS_PER_SEC) || defined(MIN_ARC_SEGMENTS) + if (mm_per_arc_segment > MM_PER_ARC_SEGMENT) + mm_per_arc_segment = MM_PER_ARC_SEGMENT; #endif + + + // Adjust the angular travel if the direction is clockwise if (isclockwise) { angular_travel_total -= 2 * M_PI; } //20141002:full circle for G03 did not work, e.g. G03 X80 Y80 I20 J0 F2000 is giving an Angle of zero so head is not moving @@ -293,9 +307,9 @@ std::string inverse_processor::mc_arc(float* position, float* target, float* off if (millimeters_of_travel_arc < 0.001) { return ""; } // Calculate the total travel per segment // Calculate the number of arc segments - uint16_t segments = static_cast<uint16_t>(floor(millimeters_of_travel_arc / mm_per_arc_segment)); + uint16_t segments = static_cast<uint16_t>(ceil(millimeters_of_travel_arc / mm_per_arc_segment)); // Ensure at least one segment - if (segments < 1) segments = 1; + //if (segments < 1) segments = 1; // Calculate theta per segments and linear (z) travel per segment float theta_per_segment = angular_travel_total / segments; diff --git a/ArcWelderInverseProcessor/inverse_processor.h b/ArcWelderInverseProcessor/inverse_processor.h index 761e186..b84b92a 100644 --- a/ArcWelderInverseProcessor/inverse_processor.h +++ b/ArcWelderInverseProcessor/inverse_processor.h @@ -34,13 +34,15 @@ typedef signed char int8_t; #define M_PI 3.14159265358979323846f // pi enum AxisEnum { X_AXIS = 0, Y_AXIS= 1, Z_AXIS = 2, E_AXIS = 3, X_HEAD = 4, Y_HEAD = 5 }; // Arc interpretation settings: -#define MM_PER_ARC_SEGMENT 1.0f // The maximum length of an arc segment if a full circle of the same radius has more than MIN_ARC_SEGMENTS (if defined) -#define N_ARC_CORRECTION 25 // The number of interpolated segments that will be generated without a floating point correction -// 20200417 - FormerLurker - Add Additional Arc Config Values -#define MIN_ARC_SEGMENTS 32 // The minimum segments in a full circle. If not defined, MM_PER_ARC_SEMGMENT is enforced always -#define MIN_MM_PER_ARC_SEGMENT 0.25f // the minimum length of an interpolated segment. Must be smaller than MM_PER_ARC_SEGMENT if defined. +#define MM_PER_ARC_SEGMENT 2.0f // REQUIRED - The enforced maximum length of an arc segment +#define MIN_MM_PER_ARC_SEGMENT 0.2f /* OPTIONAL - the enforced minimum length of an interpolated segment. Must be smaller than + MM_PER_ARC_SEGMENT if defined. Only has an effect if MIN_ARC_SEGMENTS or ARC_SEGMENTS_PER_SEC is defined */ + // If both MIN_ARC_SEGMENTS and ARC_SEGMENTS_PER_SEC is defined, the minimum calculated segment length is used. +#define MIN_ARC_SEGMENTS 20 // OPTIONAL - The enforced minimum segments in a full circle of the same radius. +#define ARC_SEGMENTS_PER_SEC 40 // OPTIONAL - Use feedrate to choose segment length. +#define N_ARC_CORRECTION 25 // OPTIONAL - The number of interpolated segments that will be generated without a floating point correction //#define ARC_EXTRUSION_CORRECTION // If defined, we should apply correction to the extrusion length based on the - // difference in true arc length. The correctly is extremely small, and may not be worth the cpu cycles + // difference in true arc length. The correctly is extremely small, and may not be worth the cpu cycles class inverse_processor { public: @@ -54,8 +56,9 @@ private: std::string source_path_; std::string target_path_; gcode_position* p_source_position_; + float arc_max_radius_threshold; - float arc_min_radius_threshold; + //float arc_min_radius_threshold; float total_e_adjustment; int trig_calc_count = 0; }; |