diff --git a/ConfigSamples/AzteegX5Mini.delta/Version2/config b/ConfigSamples/AzteegX5Mini.delta/Version2/config index 7fe8d055c1..c013541a03 100644 --- a/ConfigSamples/AzteegX5Mini.delta/Version2/config +++ b/ConfigSamples/AzteegX5Mini.delta/Version2/config @@ -6,7 +6,10 @@ arm_radius 203.00 # this is the hori default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ). delta_segments_per_second 100 # segments per second used for deltas diff --git a/ConfigSamples/AzteegX5Mini.delta/config b/ConfigSamples/AzteegX5Mini.delta/config index c32445d5be..eea826b05d 100644 --- a/ConfigSamples/AzteegX5Mini.delta/config +++ b/ConfigSamples/AzteegX5Mini.delta/config @@ -6,7 +6,10 @@ arm_radius 203.00 # this is the hori default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ). delta_segments_per_second 100 # segments per second used for deltas diff --git a/ConfigSamples/AzteegX5Mini/Version2/config b/ConfigSamples/AzteegX5Mini/Version2/config index c9005eed4a..5867bd5115 100755 --- a/ConfigSamples/AzteegX5Mini/Version2/config +++ b/ConfigSamples/AzteegX5Mini/Version2/config @@ -1,7 +1,10 @@ # Robot module configurations : general handling of movement G-codes and slicing into moves default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ). # Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions diff --git a/ConfigSamples/AzteegX5Mini/config b/ConfigSamples/AzteegX5Mini/config index 952a969b12..c8049a0454 100755 --- a/ConfigSamples/AzteegX5Mini/config +++ b/ConfigSamples/AzteegX5Mini/config @@ -1,7 +1,10 @@ # Robot module configurations : general handling of movement G-codes and slicing into moves default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for these segments. Smaller values mean more resolution, higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian coordinates robots ). # Arm solution configuration : Cartesian robot. Translates mm positions into stepper positions diff --git a/ConfigSamples/Smoothieboard.delta/config b/ConfigSamples/Smoothieboard.delta/config index ffb71ddc73..5cfd0140ac 100644 --- a/ConfigSamples/Smoothieboard.delta/config +++ b/ConfigSamples/Smoothieboard.delta/config @@ -2,9 +2,10 @@ # Robot module configurations : general handling of movement G-codes and slicing into moves default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for - # these segments. Smaller values mean more resolution, - # higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 0.5 # Lines can be cut into segments ( not useful with cartesian # coordinates robots ). delta_segments_per_second 100 # for deltas only same as in Marlin/Delta, set to 0 to disable diff --git a/ConfigSamples/Smoothieboard/config b/ConfigSamples/Smoothieboard/config index 04471b59af..d365ade80e 100644 --- a/ConfigSamples/Smoothieboard/config +++ b/ConfigSamples/Smoothieboard/config @@ -2,9 +2,10 @@ ## Robot module configurations : general handling of movement G-codes and slicing into moves default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for - # these segments. Smaller values mean more resolution, - # higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 5 # Lines can be cut into segments ( not usefull with cartesian # coordinates robots ). diff --git a/ConfigSamples/rotary.delta/config b/ConfigSamples/rotary.delta/config index 671db5c43e..ede0ec9cfd 100644 --- a/ConfigSamples/rotary.delta/config +++ b/ConfigSamples/rotary.delta/config @@ -2,9 +2,10 @@ # Robot module configurations : general handling of movement G-codes and slicing into moves default_feed_rate 4000 # Default rate ( mm/minute ) for G1/G2/G3 moves default_seek_rate 4000 # Default rate ( mm/minute ) for G0 moves -mm_per_arc_segment 0.5 # Arcs are cut into segments ( lines ), this is the length for - # these segments. Smaller values mean more resolution, - # higher values mean faster computation +mm_per_arc_segment 0.0 # Fixed length for line segments that divide arcs 0 to disable +mm_max_arc_error 0.01 # The maximum error for line segments that divide arcs 0 to disable + # note it is invalid for both the above be 0 + # if both are used, will use largest segment length based on radius #mm_per_line_segment 0.5 # Lines can be cut into segments ( not useful with cartesian # coordinates robots ). delta_segments_per_second 100 # for deltas only same as in Marlin/Delta, set to 0 to disable diff --git a/src/modules/robot/Robot.cpp b/src/modules/robot/Robot.cpp index e61f3bc88e..09f6fd5712 100644 --- a/src/modules/robot/Robot.cpp +++ b/src/modules/robot/Robot.cpp @@ -46,6 +46,7 @@ using std::string; #define mm_per_line_segment_checksum CHECKSUM("mm_per_line_segment") #define delta_segments_per_second_checksum CHECKSUM("delta_segments_per_second") #define mm_per_arc_segment_checksum CHECKSUM("mm_per_arc_segment") +#define mm_max_arc_error_checksum CHECKSUM("mm_max_arc_error") #define arc_correction_checksum CHECKSUM("arc_correction") #define x_axis_max_speed_checksum CHECKSUM("x_axis_max_speed") #define y_axis_max_speed_checksum CHECKSUM("y_axis_max_speed") @@ -180,7 +181,8 @@ void Robot::load_config() this->seek_rate = THEKERNEL->config->value(default_seek_rate_checksum )->by_default( 100.0F)->as_number(); this->mm_per_line_segment = THEKERNEL->config->value(mm_per_line_segment_checksum )->by_default( 0.0F)->as_number(); this->delta_segments_per_second = THEKERNEL->config->value(delta_segments_per_second_checksum )->by_default(0.0f )->as_number(); - this->mm_per_arc_segment = THEKERNEL->config->value(mm_per_arc_segment_checksum )->by_default( 0.5f)->as_number(); + this->mm_per_arc_segment = THEKERNEL->config->value(mm_per_arc_segment_checksum )->by_default( 0.0f)->as_number(); + this->mm_max_arc_error = THEKERNEL->config->value(mm_max_arc_error_checksum )->by_default( 0.01f)->as_number(); this->arc_correction = THEKERNEL->config->value(arc_correction_checksum )->by_default( 5 )->as_number(); this->max_speeds[X_AXIS] = THEKERNEL->config->value(x_axis_max_speed_checksum )->by_default(60000.0F)->as_number() / 60.0F; @@ -1018,9 +1020,18 @@ bool Robot::append_arc(Gcode * gcode, const float target[], const float offset[] // Mark the gcode as having a known distance this->distance_in_gcode_is_known( gcode ); + // limit segments by maximum arc error + float arc_segment = this->mm_per_arc_segment; + if ((this->mm_max_arc_error > 0) && (2 * radius > this->mm_max_arc_error)) { + float min_err_segment = 2 * sqrtf((this->mm_max_arc_error * (2 * radius - this->mm_max_arc_error))); + if (this->mm_per_arc_segment < min_err_segment) { + arc_segment = min_err_segment; + } + } // Figure out how many segments for this gcode - uint16_t segments = floorf(gcode->millimeters_of_travel / this->mm_per_arc_segment); + uint16_t segments = ceilf(gcode->millimeters_of_travel / arc_segment); + //printf("Radius %f - Segment Length %f - Number of Segments %d\r\n",radius,arc_segment,segments); // Testing Purposes ONLY float theta_per_segment = angular_travel / segments; float linear_per_segment = linear_travel / segments; diff --git a/src/modules/robot/Robot.h b/src/modules/robot/Robot.h index 0d1945906f..1ac3cc87ff 100644 --- a/src/modules/robot/Robot.h +++ b/src/modules/robot/Robot.h @@ -107,6 +107,7 @@ class Robot : public Module { float feed_rate; // Current rate for feeding moves ( mm/min ) float mm_per_line_segment; // Setting : Used to split lines into segments float mm_per_arc_segment; // Setting : Used to split arcs into segments + float mm_max_arc_error; // Setting : Used to limit total arc segments to max error float delta_segments_per_second; // Setting : Used to split lines into segments for delta based on speed float seconds_per_minute; // for realtime speed change