From d8d592179eef0e9e19283f5de66912d36d725fa7 Mon Sep 17 00:00:00 2001 From: Emanuele Caruso Date: Fri, 22 Apr 2011 21:10:10 +0200 Subject: Added min constant speed units configuration value for acceleration. Disabled manage_heating while accelerating or decelerating. Updated acceleration configuration values to better default values. --- Tonokip_Firmware/Tonokip_Firmware.pde | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Tonokip_Firmware/Tonokip_Firmware.pde') diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde index 902310c..edc4f56 100644 --- a/Tonokip_Firmware/Tonokip_Firmware.pde +++ b/Tonokip_Firmware/Tonokip_Firmware.pde @@ -55,7 +55,9 @@ unsigned long long_full_velocity_units = full_velocity_units * 100; unsigned long max_x_interval = 100000000.0 / (min_units_per_second * x_steps_per_unit); unsigned long max_y_interval = 100000000.0 / (min_units_per_second * y_steps_per_unit); unsigned long max_interval, interval; -boolean acceleration_enabled; +unsigned long x_min_constant_speed_steps = min_constant_speed_units * x_steps_per_unit, + y_min_constant_speed_steps = min_constant_speed_units * y_steps_per_unit, min_constant_speed_steps; +boolean acceleration_enabled,accelerating; float destination_x =0.0, destination_y = 0.0, destination_z = 0.0, destination_e = 0.0; float current_x = 0.0, current_y = 0.0, current_z = 0.0, current_e = 0.0; long x_interval, y_interval, z_interval, e_interval; // for speed delay @@ -799,19 +801,21 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin previous_micros_y=micros()*100; interval = y_interval; virtual_full_velocity_steps = long_full_velocity_units * y_steps_per_unit /100; - full_velocity_steps = min(virtual_full_velocity_steps, delta_y / 2); + full_velocity_steps = min(virtual_full_velocity_steps, (delta_y - y_min_constant_speed_steps) / 2); steps_remaining = delta_y; steps_to_take = delta_y; max_interval = max_y_interval; + min_constant_speed_steps = y_min_constant_speed_steps; } else if (steep_x) { error_y = delta_x / 2; previous_micros_x=micros()*100; interval = x_interval; virtual_full_velocity_steps = long_full_velocity_units * x_steps_per_unit /100; - full_velocity_steps = min(virtual_full_velocity_steps, delta_x / 2); + full_velocity_steps = min(virtual_full_velocity_steps, (delta_x - x_min_constant_speed_steps) / 2); steps_remaining = delta_x; steps_to_take = delta_x; max_interval = max_x_interval; + min_constant_speed_steps = x_min_constant_speed_steps; } previous_micros_z=micros()*100; previous_micros_e=micros()*100; @@ -819,8 +823,15 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin if(full_velocity_steps == 0) full_velocity_steps++; long full_interval = interval;//max(interval, max_interval - ((max_interval - full_interval) * full_velocity_steps / virtual_full_velocity_steps)); if(interval > max_interval) acceleration_enabled = false; + if(min_constant_speed_steps >= steps_to_take) { + acceleration_enabled = false; + full_interval = max(max_interval, interval); // choose the min speed between feedrate and acceleration start speed + } + if(full_velocity_steps < virtual_full_velocity_steps && acceleration_enabled) full_interval = max(interval, + max_interval - ((max_interval - full_interval) * full_velocity_steps / virtual_full_velocity_steps)); // choose the min speed between feedrate and speed at full steps unsigned long steps_done = 0; unsigned int steps_acceleration_check = 1; + accelerating = acceleration_enabled; //move until no more steps remain while(x_steps_remaining + y_steps_remaining + z_steps_remaining + e_steps_remaining > 0) { @@ -838,9 +849,11 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin } else { interval = max_interval - ((max_interval - full_interval) * steps_remaining / virtual_full_velocity_steps); } + accelerating = true; } else if (steps_done - full_velocity_steps >= 1 || !acceleration_enabled){ //Else, we are just use the full speed interval as current interval interval = full_interval; + accelerating = false; } //If there are x or y steps remaining, perform Bresenham algorithm @@ -900,7 +913,7 @@ void linear_move(unsigned long x_steps_remaining, unsigned long y_steps_remainin } //If more that half second is passed since previous heating check, manage it - if( (millis() - previous_millis_heater) >= 500 ) { + if(!accelerating && (millis() - previous_millis_heater) >= 500 ) { manage_heater(); previous_millis_heater = millis(); -- cgit v1.2.1