summaryrefslogtreecommitdiff
path: root/Tonokip_Firmware/Tonokip_Firmware.pde
diff options
context:
space:
mode:
authorEmanuele Caruso <emanuele.caruso@gmail.com>2011-04-22 21:18:13 +0200
committerEmanuele Caruso <emanuele.caruso@gmail.com>2011-04-22 21:18:13 +0200
commit6becb19dc530abebf30b69ba8bd3d7fd34907b49 (patch)
treeb4859d6afb424a64841676646ce8fd2327e5323c /Tonokip_Firmware/Tonokip_Firmware.pde
parent218d454bf4e8f84b81cde738a401d51f260e85a0 (diff)
parentd8d592179eef0e9e19283f5de66912d36d725fa7 (diff)
Merge branch 'minconstspeed'
Diffstat (limited to 'Tonokip_Firmware/Tonokip_Firmware.pde')
-rw-r--r--Tonokip_Firmware/Tonokip_Firmware.pde21
1 files changed, 17 insertions, 4 deletions
diff --git a/Tonokip_Firmware/Tonokip_Firmware.pde b/Tonokip_Firmware/Tonokip_Firmware.pde
index ad26775..d838d7a 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
@@ -814,19 +816,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;
@@ -834,8 +838,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) {
@@ -853,9 +864,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
@@ -915,7 +928,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();